@@ -156,16 +156,18 @@ namespace stream::adaptive_bitrate {
156156 const long double recovered_ratio,
157157 const bool high_latency
158158 ) {
159- const auto severe_loss = unrecovered_ratio >= unrecovered_loss_threshold ||
160- snapshot.incomplete_fec_reports != 0 ||
161- snapshot.frame_loss_requests != 0 ;
162- if (severe_loss) {
163- return degradation_e::unrecovered_loss;
159+ using enum degradation_e;
160+
161+ if (const auto severe_loss = unrecovered_ratio >= unrecovered_loss_threshold ||
162+ snapshot.incomplete_fec_reports != 0 ||
163+ snapshot.frame_loss_requests != 0 ;
164+ severe_loss) {
165+ return unrecovered_loss;
164166 }
165167 if (recovered_ratio >= fec_pressure_threshold && high_latency) {
166- return degradation_e:: fec_pressure;
168+ return fec_pressure;
167169 }
168- return degradation_e:: none;
170+ return none;
169171 }
170172
171173 void controller_t::reset_degradation_confirmation () {
@@ -175,6 +177,8 @@ namespace stream::adaptive_bitrate {
175177 }
176178
177179 void controller_t::observe_degradation (const degradation_e degradation, const time_point_t now) {
180+ using enum degradation_e;
181+
178182 stable_since_ = now;
179183
180184 if (!first_bad_window_at_ || now < *first_bad_window_at_ ||
@@ -186,18 +190,18 @@ namespace stream::adaptive_bitrate {
186190 }
187191
188192 ++consecutive_bad_windows_;
189- if (degradation == degradation_e:: unrecovered_loss) {
190- candidate_degradation_ = degradation_e:: unrecovered_loss;
193+ if (degradation == unrecovered_loss) {
194+ candidate_degradation_ = unrecovered_loss;
191195 }
192196
193197 if (consecutive_bad_windows_ < 2 ) {
194198 return ;
195199 }
196200
197- if (candidate_degradation_ == degradation_e:: unrecovered_loss || degradation == degradation_e:: unrecovered_loss) {
198- pending_degradation_ = degradation_e:: unrecovered_loss;
199- } else if (pending_degradation_ == degradation_e:: none) {
200- pending_degradation_ = degradation_e:: fec_pressure;
201+ if (candidate_degradation_ == unrecovered_loss || degradation == unrecovered_loss) {
202+ pending_degradation_ = unrecovered_loss;
203+ } else if (pending_degradation_ == none) {
204+ pending_degradation_ = fec_pressure;
201205 }
202206 reset_degradation_confirmation ();
203207 }
@@ -252,8 +256,8 @@ namespace stream::adaptive_bitrate {
252256 const auto unrecovered_ratio = data_ratio (snapshot.unrecovered_data_packets , snapshot);
253257 const auto recovered_ratio = data_ratio (snapshot.fec_recovered_data_packets , snapshot);
254258 const auto high_latency = latency_is_high (snapshot.rtt_ms , snapshot.rtt_variance_ms , baseline_rtt_ms_);
255- const auto degradation = classify_degradation (snapshot, unrecovered_ratio, recovered_ratio, high_latency);
256- if ( degradation != degradation_e::none) {
259+ if ( const auto degradation = classify_degradation (snapshot, unrecovered_ratio, recovered_ratio, high_latency);
260+ degradation != degradation_e::none) {
257261 observe_degradation (degradation, now);
258262 return ;
259263 }
0 commit comments