diff --git a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc index da94baaa8b..a5260bb8ce 100644 --- a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc +++ b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc @@ -323,7 +323,9 @@ void LossBasedBweV2::UpdateResult() { /*new_estimate=*/bounded_bandwidth_estimate) && bounded_bandwidth_estimate < delay_based_estimate_ && bounded_bandwidth_estimate < max_bitrate_) { - loss_based_result_.state = LossBasedState::kIncreasing; + loss_based_result_.state = config_->use_padding_for_increase + ? LossBasedState::kIncreaseUsingPadding + : LossBasedState::kIncreasing; } else if (bounded_bandwidth_estimate < delay_based_estimate_ && bounded_bandwidth_estimate < max_bitrate_) { loss_based_result_.state = LossBasedState::kDecreasing; @@ -337,7 +339,9 @@ bool LossBasedBweV2::IsEstimateIncreasingWhenLossLimited( DataRate old_estimate, DataRate new_estimate) { return (old_estimate < new_estimate || (old_estimate == new_estimate && - loss_based_result_.state == LossBasedState::kIncreasing)) && + (loss_based_result_.state == LossBasedState::kIncreasing || + loss_based_result_.state == + LossBasedState::kIncreaseUsingPadding))) && IsInLossLimitedState(); } @@ -409,6 +413,8 @@ absl::optional LossBasedBweV2::CreateConfig( FieldTrialParameter min_num_observations("MinNumObservations", 3); FieldTrialParameter lower_bound_by_acked_rate_factor( "LowerBoundByAckedRateFactor", 0.0); + FieldTrialParameter use_padding_for_increase("UsePadding", false); + if (key_value_config) { ParseFieldTrial({&enabled, &bandwidth_rampup_upper_bound_factor, @@ -444,7 +450,8 @@ absl::optional LossBasedBweV2::CreateConfig( ¬_use_acked_rate_in_alr, &use_in_start_phase, &min_num_observations, - &lower_bound_by_acked_rate_factor}, + &lower_bound_by_acked_rate_factor, + &use_padding_for_increase}, key_value_config->Lookup("WebRTC-Bwe-LossBasedBweV2")); } @@ -504,6 +511,7 @@ absl::optional LossBasedBweV2::CreateConfig( config->min_num_observations = min_num_observations.Get(); config->lower_bound_by_acked_rate_factor = lower_bound_by_acked_rate_factor.Get(); + config->use_padding_for_increase = use_padding_for_increase.Get(); return config; } diff --git a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h index 9be8341a79..4a95c10f28 100644 --- a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h +++ b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h @@ -117,6 +117,7 @@ class LossBasedBweV2 { bool use_in_start_phase = false; int min_num_observations = 0; double lower_bound_by_acked_rate_factor = 0.0; + bool use_padding_for_increase = false; }; struct Derivatives { diff --git a/modules/congestion_controller/goog_cc/loss_based_bwe_v2_test.cc b/modules/congestion_controller/goog_cc/loss_based_bwe_v2_test.cc index a803f7d54d..a25dc95200 100644 --- a/modules/congestion_controller/goog_cc/loss_based_bwe_v2_test.cc +++ b/modules/congestion_controller/goog_cc/loss_based_bwe_v2_test.cc @@ -1435,5 +1435,29 @@ TEST_F(LossBasedBweV2Test, HasDelayBasedStateIfLossBasedBweIsMax) { DataRate::KilobitsPerSec(1000)); } +TEST_F(LossBasedBweV2Test, IncreaseUsingPaddingStateIfFieldTrial) { + ExplicitKeyValueConfig key_value_config( + ShortObservationConfig("UsePadding:true")); + LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); + loss_based_bandwidth_estimator.SetBandwidthEstimate( + DataRate::KilobitsPerSec(2500)); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWith50pLossRate( + /*first_packet_timestamp=*/Timestamp::Zero()), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/false); + ASSERT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, + LossBasedState::kDecreasing); + + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWithReceivedPackets( + /*first_packet_timestamp=*/Timestamp::Zero() + + kObservationDurationLowerBound), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/false); + EXPECT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, + LossBasedState::kIncreaseUsingPadding); +} + } // namespace } // namespace webrtc