diff --git a/modules/remote_bitrate_estimator/aimd_rate_control.cc b/modules/remote_bitrate_estimator/aimd_rate_control.cc index 1714dd115a..3a4ba85a0f 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control.cc +++ b/modules/remote_bitrate_estimator/aimd_rate_control.cc @@ -338,11 +338,6 @@ void AimdRateControl::ChangeBitrate(const RateControlInput& input, decreased_bitrate = beta_ * link_capacity_.estimate(); } } - if (estimate_bounded_backoff_ && network_estimate_) { - decreased_bitrate = std::max( - decreased_bitrate, network_estimate_->link_capacity_lower * beta_); - } - // Avoid increasing the rate when over-using. if (decreased_bitrate < current_bitrate_) { new_bitrate = decreased_bitrate; @@ -386,6 +381,12 @@ DataRate AimdRateControl::ClampBitrate(DataRate new_bitrate) const { } new_bitrate = std::min(upper_bound, new_bitrate); } + if (estimate_bounded_backoff_ && network_estimate_ && + network_estimate_->link_capacity_lower.IsFinite() && + new_bitrate < current_bitrate_) { + new_bitrate = + std::max(new_bitrate, network_estimate_->link_capacity_lower * beta_); + } new_bitrate = std::max(new_bitrate, min_configured_bitrate_); return new_bitrate; } diff --git a/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc b/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc index 5d9c328e06..e217a1a7bc 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc +++ b/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc @@ -255,7 +255,7 @@ TEST(AimdRateControlTest, SetEstimateIncreaseBweInAlr) { 2 * kInitialBitrateBps); } -TEST(AimdRateControlTest, SetEstimateClampedByNetworkEstimate) { +TEST(AimdRateControlTest, SetEstimateUpperLimitedByNetworkEstimate) { auto states = CreateAimdRateControlStates(/*send_side=*/true); NetworkStateEstimate network_estimate; network_estimate.link_capacity_upper = DataRate::KilobitsPerSec(400); @@ -265,6 +265,17 @@ TEST(AimdRateControlTest, SetEstimateClampedByNetworkEstimate) { network_estimate.link_capacity_upper); } +TEST(AimdRateControlTest, SetEstimateLowerLimitedByNetworkEstimate) { + auto states = CreateAimdRateControlStates(/*send_side=*/true); + NetworkStateEstimate network_estimate; + network_estimate.link_capacity_lower = DataRate::KilobitsPerSec(400); + states.aimd_rate_control->SetNetworkStateEstimate(network_estimate); + SetEstimate(states, 100'000); + // 0.85 is default backoff factor. (`beta_`) + EXPECT_EQ(states.aimd_rate_control->LatestEstimate(), + network_estimate.link_capacity_lower * 0.85); +} + TEST(AimdRateControlTest, SetEstimateIgnoresNetworkEstimatesLowerThanCurrent) { test::ScopedFieldTrials override_field_trials( "WebRTC-Bwe-EstimateBoundedIncrease/"