From 3d7771cc08eaca5de36773f4c76f6085c29c385e Mon Sep 17 00:00:00 2001 From: Diep Bui Date: Wed, 9 Nov 2022 16:09:11 +0000 Subject: [PATCH] Clean up loss based bwe v2: store delay based estimate locally. This is to avoid passing delay based estimate value twice from send side bwe. Bug: webrtc:12707 Change-Id: Idc77cf7c2f4ecc60ae1dcfead325320532e7a7ca Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/282864 Reviewed-by: Per Kjellander Commit-Queue: Diep Bui Cr-Commit-Position: refs/heads/main@{#38600} --- .../goog_cc/loss_based_bwe_v2.cc | 41 ++- .../goog_cc/loss_based_bwe_v2.h | 8 +- .../goog_cc/loss_based_bwe_v2_test.cc | 257 +++++++----------- .../goog_cc/send_side_bandwidth_estimation.cc | 3 +- 4 files changed, 122 insertions(+), 187 deletions(-) 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 1a694b7317..7a3d229e38 100644 --- a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc +++ b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc @@ -138,8 +138,7 @@ bool LossBasedBweV2::IsReady() const { num_observations_ > 0; } -LossBasedBweV2::Result LossBasedBweV2::GetLossBasedResult( - DataRate delay_based_limit) const { +LossBasedBweV2::Result LossBasedBweV2::GetLossBasedResult() const { Result result; result.state = current_state_; if (!IsReady()) { @@ -156,16 +155,16 @@ LossBasedBweV2::Result LossBasedBweV2::GetLossBasedResult( "statistics before it can be used."; } } - result.bandwidth_estimate = IsValid(delay_based_limit) - ? delay_based_limit + result.bandwidth_estimate = IsValid(delay_based_estimate_) + ? delay_based_estimate_ : DataRate::PlusInfinity(); return result; } - if (IsValid(delay_based_limit)) { + if (IsValid(delay_based_estimate_)) { result.bandwidth_estimate = std::min({current_estimate_.loss_limited_bandwidth, - GetInstantUpperBound(), delay_based_limit}); + GetInstantUpperBound(), delay_based_estimate_}); } else { result.bandwidth_estimate = std::min( current_estimate_.loss_limited_bandwidth, GetInstantUpperBound()); @@ -221,6 +220,7 @@ void LossBasedBweV2::UpdateBandwidthEstimate( DataRate delay_based_estimate, BandwidthUsage delay_detector_state, absl::optional probe_bitrate) { + delay_based_estimate_ = delay_based_estimate; if (!IsEnabled()) { RTC_LOG(LS_WARNING) << "The estimator must be enabled before it can be used."; @@ -245,7 +245,7 @@ void LossBasedBweV2::UpdateBandwidthEstimate( ChannelParameters best_candidate = current_estimate_; double objective_max = std::numeric_limits::lowest(); - for (ChannelParameters candidate : GetCandidates(delay_based_estimate)) { + for (ChannelParameters candidate : GetCandidates()) { NewtonsMethodUpdate(candidate); const double candidate_objective = GetObjective(candidate); @@ -309,11 +309,11 @@ void LossBasedBweV2::UpdateBandwidthEstimate( if (IsEstimateIncreasingWhenLossLimited(best_candidate)) { current_state_ = LossBasedState::kIncreasing; - } else if (IsValid(delay_based_estimate) && - best_candidate.loss_limited_bandwidth < delay_based_estimate) { + } else if (IsValid(delay_based_estimate_) && + best_candidate.loss_limited_bandwidth < delay_based_estimate_) { current_state_ = LossBasedState::kDecreasing; - } else if (IsValid(delay_based_estimate) && - best_candidate.loss_limited_bandwidth == delay_based_estimate) { + } else if (IsValid(delay_based_estimate_) && + best_candidate.loss_limited_bandwidth == delay_based_estimate_) { current_state_ = LossBasedState::kDelayBasedEstimate; } current_estimate_ = best_candidate; @@ -716,8 +716,7 @@ double LossBasedBweV2::GetAverageReportedLossRatio() const { return num_lost_packets / num_packets; } -DataRate LossBasedBweV2::GetCandidateBandwidthUpperBound( - DataRate delay_based_estimate) const { +DataRate LossBasedBweV2::GetCandidateBandwidthUpperBound() const { DataRate candidate_bandwidth_upper_bound = max_bitrate_; if (IsBandwidthLimitedDueToLoss() && IsValid(bandwidth_limit_in_current_window_)) { @@ -727,9 +726,9 @@ DataRate LossBasedBweV2::GetCandidateBandwidthUpperBound( if (config_->trendline_integration_enabled) { candidate_bandwidth_upper_bound = std::min(GetInstantUpperBound(), candidate_bandwidth_upper_bound); - if (IsValid(delay_based_estimate)) { + if (IsValid(delay_based_estimate_)) { candidate_bandwidth_upper_bound = - std::min(delay_based_estimate, candidate_bandwidth_upper_bound); + std::min(delay_based_estimate_, candidate_bandwidth_upper_bound); } } @@ -751,8 +750,8 @@ DataRate LossBasedBweV2::GetCandidateBandwidthUpperBound( return candidate_bandwidth_upper_bound; } -std::vector LossBasedBweV2::GetCandidates( - DataRate delay_based_estimate) const { +std::vector LossBasedBweV2::GetCandidates() + const { std::vector bandwidths; bool can_increase_bitrate = TrendlineEsimateAllowBitrateIncrease(); for (double candidate_factor : config_->candidate_factors) { @@ -770,16 +769,16 @@ std::vector LossBasedBweV2::GetCandidates( config_->bandwidth_backoff_lower_bound_factor); } - if (IsValid(delay_based_estimate) && + if (IsValid(delay_based_estimate_) && config_->append_delay_based_estimate_candidate) { if (can_increase_bitrate && - delay_based_estimate > current_estimate_.loss_limited_bandwidth) { - bandwidths.push_back(delay_based_estimate); + delay_based_estimate_ > current_estimate_.loss_limited_bandwidth) { + bandwidths.push_back(delay_based_estimate_); } } const DataRate candidate_bandwidth_upper_bound = - GetCandidateBandwidthUpperBound(delay_based_estimate); + GetCandidateBandwidthUpperBound(); std::vector candidates; candidates.resize(bandwidths.size()); 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 cad6294c15..2318fbc772 100644 --- a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h +++ b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h @@ -57,7 +57,7 @@ class LossBasedBweV2 { bool IsReady() const; // Returns `DataRate::PlusInfinity` if no BWE can be calculated. - Result GetLossBasedResult(DataRate delay_based_limit) const; + Result GetLossBasedResult() const; void SetAcknowledgedBitrate(DataRate acknowledged_bitrate); void SetBandwidthEstimate(DataRate bandwidth_estimate); @@ -139,9 +139,8 @@ class LossBasedBweV2 { // Returns `0.0` if not enough loss statistics have been received. double GetAverageReportedLossRatio() const; - std::vector GetCandidates( - DataRate delay_based_estimate) const; - DataRate GetCandidateBandwidthUpperBound(DataRate delay_based_estimate) const; + std::vector GetCandidates() const; + DataRate GetCandidateBandwidthUpperBound() const; Derivatives GetDerivatives(const ChannelParameters& channel_parameters) const; double GetFeasibleInherentLoss( const ChannelParameters& channel_parameters) const; @@ -193,6 +192,7 @@ class LossBasedBweV2 { DataRate max_bitrate_ = DataRate::PlusInfinity(); LossBasedState current_state_ = LossBasedState::kDelayBasedEstimate; DataRate probe_bitrate_ = DataRate::PlusInfinity(); + DataRate delay_based_estimate_ = DataRate::PlusInfinity(); }; } // namespace webrtc 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 688161ade4..e90a50765a 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 @@ -201,12 +201,14 @@ TEST_P(LossBasedBweV2Test, ReturnsDelayBasedEstimateWhenDisabled) { Config(/*enabled=*/false, /*valid=*/true, /*trendline_integration_enabled=*/GetParam())); LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); - - EXPECT_EQ(loss_based_bandwidth_estimator - .GetLossBasedResult( - /*delay_based_limit=*/DataRate::KilobitsPerSec(100)) - .bandwidth_estimate, - DataRate::KilobitsPerSec(100)); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + /*packet_results=*/{}, + /*delay_based_estimate=*/DataRate::KilobitsPerSec(100), + BandwidthUsage::kBwNormal, + /*probe_estimate=*/absl::nullopt); + EXPECT_EQ( + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, + DataRate::KilobitsPerSec(100)); } TEST_P(LossBasedBweV2Test, @@ -215,12 +217,14 @@ TEST_P(LossBasedBweV2Test, Config(/*enabled=*/true, /*valid=*/false, /*trendline_integration_enabled=*/GetParam())); LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); - - EXPECT_EQ(loss_based_bandwidth_estimator - .GetLossBasedResult( - /*delay_based_limit=*/DataRate::KilobitsPerSec(100)) - .bandwidth_estimate, - DataRate::KilobitsPerSec(100)); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + /*packet_results=*/{}, + /*delay_based_estimate=*/DataRate::KilobitsPerSec(100), + BandwidthUsage::kBwNormal, + /*probe_estimate=*/absl::nullopt); + EXPECT_EQ( + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, + DataRate::KilobitsPerSec(100)); } TEST_P(LossBasedBweV2Test, @@ -241,10 +245,8 @@ TEST_P(LossBasedBweV2Test, /*probe_estimate=*/absl::nullopt); EXPECT_TRUE(loss_based_bandwidth_estimator.IsReady()); - EXPECT_TRUE( - loss_based_bandwidth_estimator - .GetLossBasedResult(/*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate.IsFinite()); + EXPECT_TRUE(loss_based_bandwidth_estimator.GetLossBasedResult() + .bandwidth_estimate.IsFinite()); } TEST_P(LossBasedBweV2Test, NoBandwidthEstimateGivenNoInitialization) { @@ -261,10 +263,8 @@ TEST_P(LossBasedBweV2Test, NoBandwidthEstimateGivenNoInitialization) { /*probe_estimate=*/absl::nullopt); EXPECT_FALSE(loss_based_bandwidth_estimator.IsReady()); - EXPECT_TRUE( - loss_based_bandwidth_estimator - .GetLossBasedResult(/*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate.IsPlusInfinity()); + EXPECT_TRUE(loss_based_bandwidth_estimator.GetLossBasedResult() + .bandwidth_estimate.IsPlusInfinity()); } TEST_P(LossBasedBweV2Test, NoBandwidthEstimateGivenNotEnoughFeedback) { @@ -290,20 +290,16 @@ TEST_P(LossBasedBweV2Test, NoBandwidthEstimateGivenNotEnoughFeedback) { DataRate::KilobitsPerSec(600)); EXPECT_FALSE(loss_based_bandwidth_estimator.IsReady()); - EXPECT_TRUE( - loss_based_bandwidth_estimator - .GetLossBasedResult(/*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate.IsPlusInfinity()); + EXPECT_TRUE(loss_based_bandwidth_estimator.GetLossBasedResult() + .bandwidth_estimate.IsPlusInfinity()); loss_based_bandwidth_estimator.UpdateBandwidthEstimate( not_enough_feedback, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt); EXPECT_FALSE(loss_based_bandwidth_estimator.IsReady()); - EXPECT_TRUE( - loss_based_bandwidth_estimator - .GetLossBasedResult(/*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate.IsPlusInfinity()); + EXPECT_TRUE(loss_based_bandwidth_estimator.GetLossBasedResult() + .bandwidth_estimate.IsPlusInfinity()); } TEST_P(LossBasedBweV2Test, @@ -327,30 +323,24 @@ TEST_P(LossBasedBweV2Test, enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt); - EXPECT_NE(loss_based_bandwidth_estimator - .GetLossBasedResult( - /*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate, - DataRate::KilobitsPerSec(600)); + EXPECT_NE( + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, + DataRate::KilobitsPerSec(600)); loss_based_bandwidth_estimator.SetBandwidthEstimate( DataRate::KilobitsPerSec(600)); - EXPECT_EQ(loss_based_bandwidth_estimator - .GetLossBasedResult( - /*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate, - DataRate::KilobitsPerSec(600)); + EXPECT_EQ( + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, + DataRate::KilobitsPerSec(600)); loss_based_bandwidth_estimator.UpdateBandwidthEstimate( enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt); - EXPECT_NE(loss_based_bandwidth_estimator - .GetLossBasedResult( - /*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate, - DataRate::KilobitsPerSec(600)); + EXPECT_NE( + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, + DataRate::KilobitsPerSec(600)); } TEST_P(LossBasedBweV2Test, @@ -380,20 +370,16 @@ TEST_P(LossBasedBweV2Test, enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt); - EXPECT_EQ(loss_based_bandwidth_estimator_1 - .GetLossBasedResult( - /*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate, - DataRate::KilobitsPerSec(660)); + EXPECT_EQ( + loss_based_bandwidth_estimator_1.GetLossBasedResult().bandwidth_estimate, + DataRate::KilobitsPerSec(660)); loss_based_bandwidth_estimator_1.SetAcknowledgedBitrate( DataRate::KilobitsPerSec(900)); - EXPECT_EQ(loss_based_bandwidth_estimator_1 - .GetLossBasedResult( - /*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate, - DataRate::KilobitsPerSec(660)); + EXPECT_EQ( + loss_based_bandwidth_estimator_1.GetLossBasedResult().bandwidth_estimate, + DataRate::KilobitsPerSec(660)); loss_based_bandwidth_estimator_1.UpdateBandwidthEstimate( enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal, @@ -402,14 +388,9 @@ TEST_P(LossBasedBweV2Test, enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt); - EXPECT_NE(loss_based_bandwidth_estimator_1 - .GetLossBasedResult( - /*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate, - loss_based_bandwidth_estimator_2 - .GetLossBasedResult( - /*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate); + EXPECT_NE( + loss_based_bandwidth_estimator_1.GetLossBasedResult().bandwidth_estimate, + loss_based_bandwidth_estimator_2.GetLossBasedResult().bandwidth_estimate); } TEST_P(LossBasedBweV2Test, @@ -429,11 +410,9 @@ TEST_P(LossBasedBweV2Test, enough_feedback_no_received_packets, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt); - EXPECT_EQ(loss_based_bandwidth_estimator - .GetLossBasedResult( - /*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate, - DataRate::KilobitsPerSec(100)); + EXPECT_EQ( + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, + DataRate::KilobitsPerSec(100)); } TEST_P(LossBasedBweV2Test, BandwidthEstimateNotIncreaseWhenNetworkUnderusing) { @@ -459,19 +438,15 @@ TEST_P(LossBasedBweV2Test, BandwidthEstimateNotIncreaseWhenNetworkUnderusing) { loss_based_bandwidth_estimator.UpdateBandwidthEstimate( enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwUnderusing, /*probe_estimate=*/absl::nullopt); - EXPECT_LE(loss_based_bandwidth_estimator - .GetLossBasedResult( - /*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate, - DataRate::KilobitsPerSec(600)); + EXPECT_LE( + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, + DataRate::KilobitsPerSec(600)); loss_based_bandwidth_estimator.UpdateBandwidthEstimate( enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt); - EXPECT_LE(loss_based_bandwidth_estimator - .GetLossBasedResult( - /*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate, - DataRate::KilobitsPerSec(600)); + EXPECT_LE( + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, + DataRate::KilobitsPerSec(600)); } // When network is normal, estimate can increase but never be higher than @@ -499,21 +474,18 @@ TEST_P(LossBasedBweV2Test, /*probe_estimate=*/absl::nullopt); // If the delay based estimate is infinity, then loss based estimate increases // and not bounded by delay based estimate. - EXPECT_GT(loss_based_bandwidth_estimator - .GetLossBasedResult( - /*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate, - DataRate::KilobitsPerSec(600)); + EXPECT_GT( + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, + DataRate::KilobitsPerSec(600)); loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal, + enough_feedback_2, /*delay_based_estimate=*/DataRate::KilobitsPerSec(500), + BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt); // If the delay based estimate is not infinity, then loss based estimate is // bounded by delay based estimate. - EXPECT_EQ(loss_based_bandwidth_estimator - .GetLossBasedResult( - /*delay_based_limit=*/DataRate::KilobitsPerSec(500)) - .bandwidth_estimate, - DataRate::KilobitsPerSec(500)); + EXPECT_EQ( + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, + DataRate::KilobitsPerSec(500)); } // When loss based bwe receives a strong signal of overusing and an increase in @@ -548,11 +520,9 @@ TEST_P(LossBasedBweV2Test, UseAckedBitrateForEmegencyBackOff) { enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwOverusing, /*probe_estimate=*/absl::nullopt); // The estimate bitrate now is backed off based on acked bitrate. - EXPECT_LE(loss_based_bandwidth_estimator - .GetLossBasedResult( - /*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate, - acked_bitrate); + EXPECT_LE( + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, + acked_bitrate); } // When receiving the same packet feedback, loss based bwe ignores the feedback @@ -573,19 +543,15 @@ TEST_P(LossBasedBweV2Test, NoBweChangeIfObservationDurationUnchanged) { loss_based_bandwidth_estimator.UpdateBandwidthEstimate( enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt); - DataRate estimate_1 = loss_based_bandwidth_estimator - .GetLossBasedResult( - /*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate; + DataRate estimate_1 = + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate; // Use the same feedback and check if the estimate is unchanged. loss_based_bandwidth_estimator.UpdateBandwidthEstimate( enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt); - DataRate estimate_2 = loss_based_bandwidth_estimator - .GetLossBasedResult( - /*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate; + DataRate estimate_2 = + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate; EXPECT_EQ(estimate_2, estimate_1); } @@ -610,18 +576,14 @@ TEST_P(LossBasedBweV2Test, loss_based_bandwidth_estimator.UpdateBandwidthEstimate( enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt); - DataRate estimate_1 = loss_based_bandwidth_estimator - .GetLossBasedResult( - /*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate; + DataRate estimate_1 = + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate; loss_based_bandwidth_estimator.UpdateBandwidthEstimate( enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt); - DataRate estimate_2 = loss_based_bandwidth_estimator - .GetLossBasedResult( - /*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate; + DataRate estimate_2 = + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate; EXPECT_EQ(estimate_2, estimate_1); } @@ -646,18 +608,14 @@ TEST_P(LossBasedBweV2Test, loss_based_bandwidth_estimator.UpdateBandwidthEstimate( enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt); - DataRate estimate_1 = loss_based_bandwidth_estimator - .GetLossBasedResult( - /*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate; + DataRate estimate_1 = + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate; loss_based_bandwidth_estimator.UpdateBandwidthEstimate( enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwUnderusing, /*probe_estimate=*/absl::nullopt); - DataRate estimate_2 = loss_based_bandwidth_estimator - .GetLossBasedResult( - /*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate; + DataRate estimate_2 = + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate; EXPECT_LE(estimate_2, estimate_1); } @@ -689,18 +647,14 @@ TEST_P(LossBasedBweV2Test, loss_based_bandwidth_estimator.UpdateBandwidthEstimate( enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt); - DataRate estimate_1 = loss_based_bandwidth_estimator - .GetLossBasedResult( - /*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate; + DataRate estimate_1 = + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate; loss_based_bandwidth_estimator.UpdateBandwidthEstimate( enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwOverusing, /*probe_estimate=*/absl::nullopt); - DataRate estimate_2 = loss_based_bandwidth_estimator - .GetLossBasedResult( - /*delay_based_limit=*/DataRate::PlusInfinity()) - .bandwidth_estimate; + DataRate estimate_2 = + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate; EXPECT_LT(estimate_2, estimate_1); } @@ -725,15 +679,13 @@ TEST_P(LossBasedBweV2Test, enough_feedback_1, delay_based_estimate, BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt); EXPECT_EQ( - loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate) - .bandwidth_estimate, + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, delay_based_estimate); loss_based_bandwidth_estimator.UpdateBandwidthEstimate( enough_feedback_2, delay_based_estimate, BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt); EXPECT_EQ( - loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate) - .bandwidth_estimate, + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, delay_based_estimate); } @@ -761,7 +713,7 @@ TEST_P(LossBasedBweV2Test, enough_feedback_1, delay_based_estimate, BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt); LossBasedBweV2::Result result_at_loss = - loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate); + loss_based_bandwidth_estimator.GetLossBasedResult(); // Network recovers after loss. std::vector enough_feedback_2 = @@ -775,7 +727,7 @@ TEST_P(LossBasedBweV2Test, /*probe_estimate=*/absl::nullopt); LossBasedBweV2::Result result_after_recovery = - loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate); + loss_based_bandwidth_estimator.GetLossBasedResult(); EXPECT_EQ(result_after_recovery.bandwidth_estimate, result_at_loss.bandwidth_estimate * 1.5); } @@ -815,8 +767,7 @@ TEST_P(LossBasedBweV2Test, // The estimate is capped by acked_bitrate * BwRampupUpperBoundFactor. DataRate estimate_2 = - loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate) - .bandwidth_estimate; + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate; EXPECT_EQ(estimate_2, acked_bitrate * 1.2); } @@ -859,8 +810,7 @@ TEST_P(LossBasedBweV2Test, // The estimate is capped by current_estimate * kMaxIncreaseFactor because // it recently backed off. DataRate estimate_2 = - loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate) - .bandwidth_estimate; + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate; loss_based_bandwidth_estimator.UpdateBandwidthEstimate( enough_feedback_3, delay_based_estimate, BandwidthUsage::kBwNormal, @@ -868,8 +818,7 @@ TEST_P(LossBasedBweV2Test, // The latest estimate is the same as the previous estimate since the sent // packets were sent within the DelayedIncreaseWindow. EXPECT_EQ( - loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate) - .bandwidth_estimate, + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, estimate_2); } @@ -910,16 +859,14 @@ TEST_P(LossBasedBweV2Test, KeepIncreasingEstimateAfterDelayedIncreaseWindow) { // The estimate is capped by current_estimate * kMaxIncreaseFactor because it // recently backed off. DataRate estimate_2 = - loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate) - .bandwidth_estimate; + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate; loss_based_bandwidth_estimator.UpdateBandwidthEstimate( enough_feedback_3, delay_based_estimate, BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt); // The estimate can continue increasing after the DelayedIncreaseWindow. EXPECT_GE( - loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate) - .bandwidth_estimate, + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, estimate_2); } @@ -954,8 +901,7 @@ TEST_P(LossBasedBweV2Test, NotIncreaseIfInherentLossLessThanAverageLoss) { // Do not increase the bitrate because inherent loss is less than average loss EXPECT_EQ( - loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate) - .bandwidth_estimate, + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, DataRate::KilobitsPerSec(600)); } @@ -993,8 +939,7 @@ TEST_P(LossBasedBweV2Test, // Because LossThresholdOfHighBandwidthPreference is 20%, the average loss is // 10%, bandwidth estimate should increase. EXPECT_GT( - loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate) - .bandwidth_estimate, + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, DataRate::KilobitsPerSec(600)); } @@ -1032,8 +977,7 @@ TEST_P(LossBasedBweV2Test, // Because LossThresholdOfHighBandwidthPreference is 5%, the average loss is // 10%, bandwidth estimate should decrease. EXPECT_LT( - loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate) - .bandwidth_estimate, + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, DataRate::KilobitsPerSec(600)); } @@ -1071,7 +1015,7 @@ TEST_P(LossBasedBweV2Test, UseProbeResultWhenRecoveringFromLoss) { probe_estimate); LossBasedBweV2::Result result_after_recovery = - loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate); + loss_based_bandwidth_estimator.GetLossBasedResult(); EXPECT_EQ(result_after_recovery.bandwidth_estimate, probe_estimate); } @@ -1111,8 +1055,7 @@ TEST_P(LossBasedBweV2Test, // At 10% loss rate and high loss rate threshold to be 10%, cap the estimate // to be 500 * 1000-0.1 = 400kbps. EXPECT_EQ( - loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate) - .bandwidth_estimate, + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, DataRate::KilobitsPerSec(400)); } @@ -1152,8 +1095,7 @@ TEST_P(LossBasedBweV2Test, // At 50% loss rate and high loss rate threshold to be 30%, cap the estimate // to be the min bitrate. EXPECT_EQ( - loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate) - .bandwidth_estimate, + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, DataRate::KilobitsPerSec(10)); } @@ -1193,8 +1135,7 @@ TEST_P(LossBasedBweV2Test, // At 100% loss rate and high loss rate threshold to be 30%, cap the estimate // to be the min bitrate. EXPECT_EQ( - loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate) - .bandwidth_estimate, + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, DataRate::KilobitsPerSec(10)); } @@ -1225,8 +1166,7 @@ TEST_P(LossBasedBweV2Test, EstimateRecoversAfterHighLoss) { // Make sure that the estimate is set to min bitrate because of 100% loss // rate. EXPECT_EQ( - loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate) - .bandwidth_estimate, + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, DataRate::KilobitsPerSec(10)); // Create some feedbacks with 0 loss rate to simulate network recovering. @@ -1248,8 +1188,7 @@ TEST_P(LossBasedBweV2Test, EstimateRecoversAfterHighLoss) { // The estimate increases as network recovers. EXPECT_GT( - loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate) - .bandwidth_estimate, + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, DataRate::KilobitsPerSec(10)); } @@ -1271,9 +1210,7 @@ TEST_P(LossBasedBweV2Test, EstimateIsNotHigherThanMaxBitrate) { BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt); EXPECT_LE( - loss_based_bandwidth_estimator - .GetLossBasedResult(/*delay_based_estimate=*/DataRate::PlusInfinity()) - .bandwidth_estimate, + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, DataRate::KilobitsPerSec(1000)); } diff --git a/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc b/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc index 3ecc1d6f4b..7e5b2e3788 100644 --- a/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc +++ b/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc @@ -526,8 +526,7 @@ void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) { if (LossBasedBandwidthEstimatorV2ReadyForUse()) { LossBasedBweV2::Result result = - loss_based_bandwidth_estimator_v2_.GetLossBasedResult( - delay_based_limit_); + loss_based_bandwidth_estimator_v2_.GetLossBasedResult(); loss_based_state_ = result.state; UpdateTargetBitrate(result.bandwidth_estimate, at_time); return;