From fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:14:29 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- .../goog_cc/alr_detector_gn/moz.build | 5 - .../goog_cc/delay_based_bwe_gn/moz.build | 5 - .../goog_cc/estimators_gn/moz.build | 5 - .../goog_cc/goog_cc_gn/moz.build | 5 - .../goog_cc/link_capacity_estimator_gn/moz.build | 5 - .../goog_cc/loss_based_bwe_v1_gn/moz.build | 5 - .../goog_cc/loss_based_bwe_v2.cc | 184 ++++++---- .../goog_cc/loss_based_bwe_v2.h | 19 +- .../goog_cc/loss_based_bwe_v2_gn/moz.build | 5 - .../goog_cc/loss_based_bwe_v2_test.cc | 407 ++++++++++++--------- .../goog_cc/probe_controller_gn/moz.build | 5 - .../goog_cc/pushback_controller_gn/moz.build | 5 - .../goog_cc/send_side_bandwidth_estimation.cc | 30 +- .../goog_cc/send_side_bandwidth_estimation.h | 4 +- .../goog_cc/send_side_bwe_gn/moz.build | 5 - 15 files changed, 381 insertions(+), 313 deletions(-) (limited to 'third_party/libwebrtc/modules/congestion_controller/goog_cc') diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/alr_detector_gn/moz.build b/third_party/libwebrtc/modules/congestion_controller/goog_cc/alr_detector_gn/moz.build index b48fc38c39..40fd1189aa 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/alr_detector_gn/moz.build +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/alr_detector_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/delay_based_bwe_gn/moz.build b/third_party/libwebrtc/modules/congestion_controller/goog_cc/delay_based_bwe_gn/moz.build index 31d8c420f6..e2087c6126 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/delay_based_bwe_gn/moz.build +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/delay_based_bwe_gn/moz.build @@ -202,7 +202,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -212,10 +211,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/estimators_gn/moz.build b/third_party/libwebrtc/modules/congestion_controller/goog_cc/estimators_gn/moz.build index e233806b43..7b77d3dc86 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/estimators_gn/moz.build +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/estimators_gn/moz.build @@ -205,7 +205,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -215,10 +214,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_gn/moz.build b/third_party/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_gn/moz.build index 147a08113b..0e5182a469 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_gn/moz.build +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_gn/moz.build @@ -201,7 +201,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -211,10 +210,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/link_capacity_estimator_gn/moz.build b/third_party/libwebrtc/modules/congestion_controller/goog_cc/link_capacity_estimator_gn/moz.build index 0ee8a34df8..04b78b5988 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/link_capacity_estimator_gn/moz.build +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/link_capacity_estimator_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v1_gn/moz.build b/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v1_gn/moz.build index 5931292efe..d290fbe9ec 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v1_gn/moz.build +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v1_gn/moz.build @@ -196,7 +196,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -206,10 +205,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc b/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc index ef200869a6..8e1a3c4698 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc @@ -132,7 +132,7 @@ LossBasedBweV2::LossBasedBweV2(const FieldTrialsView* key_value_config) instant_upper_bound_temporal_weights_.resize( config_->observation_window_size); CalculateTemporalWeights(); - hold_duration_ = kInitHoldDuration; + last_hold_info_.duration = kInitHoldDuration; } bool LossBasedBweV2::IsEnabled() const { @@ -149,6 +149,10 @@ bool LossBasedBweV2::ReadyToUseInStartPhase() const { return IsReady() && config_->use_in_start_phase; } +bool LossBasedBweV2::UseInStartPhase() const { + return config_->use_in_start_phase; +} + LossBasedBweV2::Result LossBasedBweV2::GetLossBasedResult() const { if (!IsReady()) { if (!IsEnabled()) { @@ -289,50 +293,69 @@ void LossBasedBweV2::UpdateBandwidthEstimate( /*new_estimate=*/best_candidate.loss_limited_bandwidth); // Bound the best candidate by the acked bitrate. if (increasing_when_loss_limited && IsValid(acknowledged_bitrate_)) { + double rampup_factor = config_->bandwidth_rampup_upper_bound_factor; + if (IsValid(last_hold_info_.rate) && + acknowledged_bitrate_ < + config_->bandwidth_rampup_hold_threshold * last_hold_info_.rate) { + rampup_factor = config_->bandwidth_rampup_upper_bound_factor_in_hold; + } + best_candidate.loss_limited_bandwidth = std::max(current_best_estimate_.loss_limited_bandwidth, std::min(best_candidate.loss_limited_bandwidth, - config_->bandwidth_rampup_upper_bound_factor * - (*acknowledged_bitrate_))); + rampup_factor * (*acknowledged_bitrate_))); + // Increase current estimate by at least 1kbps to make sure that the state + // will be switched to kIncreasing, thus padding is triggered. + if (loss_based_result_.state == LossBasedState::kDecreasing && + best_candidate.loss_limited_bandwidth == + current_best_estimate_.loss_limited_bandwidth) { + best_candidate.loss_limited_bandwidth = + current_best_estimate_.loss_limited_bandwidth + + DataRate::BitsPerSec(1); + } } } - current_best_estimate_ = best_candidate; - UpdateResult(); - - if (IsInLossLimitedState() && - (recovering_after_loss_timestamp_.IsInfinite() || - recovering_after_loss_timestamp_ + config_->delayed_increase_window < - last_send_time_most_recent_observation_)) { - bandwidth_limit_in_current_window_ = - std::max(kCongestionControllerMinBitrate, - current_best_estimate_.loss_limited_bandwidth * - config_->max_increase_factor); - recovering_after_loss_timestamp_ = last_send_time_most_recent_observation_; - } -} - -void LossBasedBweV2::UpdateResult() { DataRate bounded_bandwidth_estimate = DataRate::PlusInfinity(); if (IsValid(delay_based_estimate_)) { bounded_bandwidth_estimate = std::max(GetInstantLowerBound(), - std::min({current_best_estimate_.loss_limited_bandwidth, + std::min({best_candidate.loss_limited_bandwidth, GetInstantUpperBound(), delay_based_estimate_})); } else { - bounded_bandwidth_estimate = - std::max(GetInstantLowerBound(), - std::min(current_best_estimate_.loss_limited_bandwidth, - GetInstantUpperBound())); + bounded_bandwidth_estimate = std::max( + GetInstantLowerBound(), std::min(best_candidate.loss_limited_bandwidth, + GetInstantUpperBound())); + } + if (config_->bound_best_candidate && + bounded_bandwidth_estimate < best_candidate.loss_limited_bandwidth) { + RTC_LOG(LS_INFO) << "Resetting loss based BWE to " + << bounded_bandwidth_estimate.kbps() + << "due to loss. Avg loss rate: " + << GetAverageReportedLossRatio(); + current_best_estimate_.loss_limited_bandwidth = bounded_bandwidth_estimate; + current_best_estimate_.inherent_loss = 0; + } else { + current_best_estimate_ = best_candidate; + if (config_->lower_bound_by_acked_rate_factor > 0.0) { + current_best_estimate_.loss_limited_bandwidth = + std::max(current_best_estimate_.loss_limited_bandwidth, + GetInstantLowerBound()); + } } if (loss_based_result_.state == LossBasedState::kDecreasing && - last_hold_timestamp_ > last_send_time_most_recent_observation_ && + last_hold_info_.timestamp > last_send_time_most_recent_observation_ && bounded_bandwidth_estimate < delay_based_estimate_) { - // BWE is not allowed to increase during the HOLD duration. The purpose of + // Ensure that acked rate is the lower bound of HOLD rate. + if (config_->lower_bound_by_acked_rate_factor > 0.0) { + last_hold_info_.rate = + std::max(GetInstantLowerBound(), last_hold_info_.rate); + } + // BWE is not allowed to increase above the HOLD rate. The purpose of // HOLD is to not immediately ramp up BWE to a rate that may cause loss. - loss_based_result_.bandwidth_estimate = std::min( - loss_based_result_.bandwidth_estimate, bounded_bandwidth_estimate); + loss_based_result_.bandwidth_estimate = + std::min(last_hold_info_.rate, bounded_bandwidth_estimate); return; } @@ -359,22 +382,38 @@ void LossBasedBweV2::UpdateResult() { RTC_LOG(LS_INFO) << this << " " << "Switch to HOLD. Bounded BWE: " << bounded_bandwidth_estimate.kbps() - << ", duration: " << hold_duration_.seconds(); - last_hold_timestamp_ = - last_send_time_most_recent_observation_ + hold_duration_; - hold_duration_ = std::min(kMaxHoldDuration, - hold_duration_ * config_->hold_duration_factor); + << ", duration: " << last_hold_info_.duration.ms(); + last_hold_info_ = { + .timestamp = last_send_time_most_recent_observation_ + + last_hold_info_.duration, + .duration = + std::min(kMaxHoldDuration, last_hold_info_.duration * + config_->hold_duration_factor), + .rate = bounded_bandwidth_estimate}; } last_padding_info_ = PaddingInfo(); loss_based_result_.state = LossBasedState::kDecreasing; } else { - // Reset the HOLD duration if delay based estimate works to avoid getting + // Reset the HOLD info if delay based estimate works to avoid getting // stuck in low bitrate. - hold_duration_ = kInitHoldDuration; + last_hold_info_ = {.timestamp = Timestamp::MinusInfinity(), + .duration = kInitHoldDuration, + .rate = DataRate::PlusInfinity()}; last_padding_info_ = PaddingInfo(); loss_based_result_.state = LossBasedState::kDelayBasedEstimate; } loss_based_result_.bandwidth_estimate = bounded_bandwidth_estimate; + + if (IsInLossLimitedState() && + (recovering_after_loss_timestamp_.IsInfinite() || + recovering_after_loss_timestamp_ + config_->delayed_increase_window < + last_send_time_most_recent_observation_)) { + bandwidth_limit_in_current_window_ = + std::max(kCongestionControllerMinBitrate, + current_best_estimate_.loss_limited_bandwidth * + config_->max_increase_factor); + recovering_after_loss_timestamp_ = last_send_time_most_recent_observation_; + } } bool LossBasedBweV2::IsEstimateIncreasingWhenLossLimited( @@ -394,6 +433,10 @@ absl::optional LossBasedBweV2::CreateConfig( FieldTrialParameter enabled("Enabled", true); FieldTrialParameter bandwidth_rampup_upper_bound_factor( "BwRampupUpperBoundFactor", 1000000.0); + FieldTrialParameter bandwidth_rampup_upper_bound_factor_in_hold( + "BwRampupUpperBoundInHoldFactor", 1000000.0); + FieldTrialParameter bandwidth_rampup_hold_threshold( + "BwRampupUpperBoundHoldThreshold", 1.3); FieldTrialParameter rampup_acceleration_max_factor( "BwRampupAccelMaxFactor", 0.0); FieldTrialParameter rampup_acceleration_maxout_time( @@ -445,12 +488,6 @@ absl::optional LossBasedBweV2::CreateConfig( FieldTrialParameter not_increase_if_inherent_loss_less_than_average_loss( "NotIncreaseIfInherentLossLessThanAverageLoss", true); - FieldTrialParameter high_loss_rate_threshold("HighLossRateThreshold", - 1.0); - FieldTrialParameter bandwidth_cap_at_high_loss_rate( - "BandwidthCapAtHighLossRate", DataRate::KilobitsPerSec(500.0)); - FieldTrialParameter slope_of_bwe_high_loss_func( - "SlopeOfBweHighLossFunc", 1000); FieldTrialParameter not_use_acked_rate_in_alr("NotUseAckedRateInAlr", true); FieldTrialParameter use_in_start_phase("UseInStartPhase", false); @@ -461,9 +498,12 @@ absl::optional LossBasedBweV2::CreateConfig( FieldTrialParameter use_byte_loss_rate("UseByteLossRate", false); FieldTrialParameter padding_duration("PaddingDuration", TimeDelta::Zero()); + FieldTrialParameter bound_best_candidate("BoundBestCandidate", false); if (key_value_config) { ParseFieldTrial({&enabled, &bandwidth_rampup_upper_bound_factor, + &bandwidth_rampup_upper_bound_factor_in_hold, + &bandwidth_rampup_hold_threshold, &rampup_acceleration_max_factor, &rampup_acceleration_maxout_time, &candidate_factors, @@ -491,16 +531,14 @@ absl::optional LossBasedBweV2::CreateConfig( &max_increase_factor, &delayed_increase_window, ¬_increase_if_inherent_loss_less_than_average_loss, - &high_loss_rate_threshold, - &bandwidth_cap_at_high_loss_rate, - &slope_of_bwe_high_loss_func, ¬_use_acked_rate_in_alr, &use_in_start_phase, &min_num_observations, &lower_bound_by_acked_rate_factor, &hold_duration_factor, &use_byte_loss_rate, - &padding_duration}, + &padding_duration, + &bound_best_candidate}, key_value_config->Lookup("WebRTC-Bwe-LossBasedBweV2")); } @@ -511,6 +549,10 @@ absl::optional LossBasedBweV2::CreateConfig( config.emplace(Config()); config->bandwidth_rampup_upper_bound_factor = bandwidth_rampup_upper_bound_factor.Get(); + config->bandwidth_rampup_upper_bound_factor_in_hold = + bandwidth_rampup_upper_bound_factor_in_hold.Get(); + config->bandwidth_rampup_hold_threshold = + bandwidth_rampup_hold_threshold.Get(); config->rampup_acceleration_max_factor = rampup_acceleration_max_factor.Get(); config->rampup_acceleration_maxout_time = rampup_acceleration_maxout_time.Get(); @@ -553,10 +595,6 @@ absl::optional LossBasedBweV2::CreateConfig( config->delayed_increase_window = delayed_increase_window.Get(); config->not_increase_if_inherent_loss_less_than_average_loss = not_increase_if_inherent_loss_less_than_average_loss.Get(); - config->high_loss_rate_threshold = high_loss_rate_threshold.Get(); - config->bandwidth_cap_at_high_loss_rate = - bandwidth_cap_at_high_loss_rate.Get(); - config->slope_of_bwe_high_loss_func = slope_of_bwe_high_loss_func.Get(); config->not_use_acked_rate_in_alr = not_use_acked_rate_in_alr.Get(); config->use_in_start_phase = use_in_start_phase.Get(); config->min_num_observations = min_num_observations.Get(); @@ -565,7 +603,7 @@ absl::optional LossBasedBweV2::CreateConfig( config->hold_duration_factor = hold_duration_factor.Get(); config->use_byte_loss_rate = use_byte_loss_rate.Get(); config->padding_duration = padding_duration.Get(); - + config->bound_best_candidate = bound_best_candidate.Get(); return config; } @@ -582,6 +620,18 @@ bool LossBasedBweV2::IsConfigValid() const { << config_->bandwidth_rampup_upper_bound_factor; valid = false; } + if (config_->bandwidth_rampup_upper_bound_factor_in_hold <= 1.0) { + RTC_LOG(LS_WARNING) << "The bandwidth rampup upper bound factor in hold " + "must be greater than 1: " + << config_->bandwidth_rampup_upper_bound_factor_in_hold; + valid = false; + } + if (config_->bandwidth_rampup_hold_threshold < 0.0) { + RTC_LOG(LS_WARNING) << "The bandwidth rampup hold threshold must" + "must be non-negative.: " + << config_->bandwidth_rampup_hold_threshold; + valid = false; + } if (config_->rampup_acceleration_max_factor < 0.0) { RTC_LOG(LS_WARNING) << "The rampup acceleration max factor must be non-negative.: " @@ -739,12 +789,6 @@ bool LossBasedBweV2::IsConfigValid() const { << config_->delayed_increase_window.ms(); valid = false; } - if (config_->high_loss_rate_threshold <= 0.0 || - config_->high_loss_rate_threshold > 1.0) { - RTC_LOG(LS_WARNING) << "The high loss rate threshold must be in (0, 1]: " - << config_->high_loss_rate_threshold; - valid = false; - } if (config_->min_num_observations <= 0) { RTC_LOG(LS_WARNING) << "The min number of observations must be positive: " << config_->min_num_observations; @@ -834,15 +878,19 @@ DataRate LossBasedBweV2::GetCandidateBandwidthUpperBound() const { std::vector LossBasedBweV2::GetCandidates( bool in_alr) const { + ChannelParameters best_estimate = current_best_estimate_; std::vector bandwidths; for (double candidate_factor : config_->candidate_factors) { bandwidths.push_back(candidate_factor * - current_best_estimate_.loss_limited_bandwidth); + best_estimate.loss_limited_bandwidth); } if (acknowledged_bitrate_.has_value() && config_->append_acknowledged_rate_candidate) { - if (!(config_->not_use_acked_rate_in_alr && in_alr)) { + if (!(config_->not_use_acked_rate_in_alr && in_alr) || + (config_->padding_duration > TimeDelta::Zero() && + last_padding_info_.padding_timestamp + config_->padding_duration >= + last_send_time_most_recent_observation_)) { bandwidths.push_back(*acknowledged_bitrate_ * config_->bandwidth_backoff_lower_bound_factor); } @@ -850,13 +898,13 @@ std::vector LossBasedBweV2::GetCandidates( if (IsValid(delay_based_estimate_) && config_->append_delay_based_estimate_candidate) { - if (delay_based_estimate_ > current_best_estimate_.loss_limited_bandwidth) { + if (delay_based_estimate_ > best_estimate.loss_limited_bandwidth) { bandwidths.push_back(delay_based_estimate_); } } if (in_alr && config_->append_upper_bound_candidate_in_alr && - current_best_estimate_.loss_limited_bandwidth > GetInstantUpperBound()) { + best_estimate.loss_limited_bandwidth > GetInstantUpperBound()) { bandwidths.push_back(GetInstantUpperBound()); } @@ -866,10 +914,10 @@ std::vector LossBasedBweV2::GetCandidates( std::vector candidates; candidates.resize(bandwidths.size()); for (size_t i = 0; i < bandwidths.size(); ++i) { - ChannelParameters candidate = current_best_estimate_; - candidate.loss_limited_bandwidth = std::min( - bandwidths[i], std::max(current_best_estimate_.loss_limited_bandwidth, - candidate_bandwidth_upper_bound)); + ChannelParameters candidate = best_estimate; + candidate.loss_limited_bandwidth = + std::min(bandwidths[i], std::max(best_estimate.loss_limited_bandwidth, + candidate_bandwidth_upper_bound)); candidate.inherent_loss = GetFeasibleInherentLoss(candidate); candidates[i] = candidate; } @@ -1037,14 +1085,6 @@ void LossBasedBweV2::CalculateInstantUpperBound() { instant_limit = config_->instant_upper_bound_bandwidth_balance / (average_reported_loss_ratio - config_->instant_upper_bound_loss_offset); - if (average_reported_loss_ratio > config_->high_loss_rate_threshold) { - instant_limit = std::min( - instant_limit, DataRate::KilobitsPerSec(std::max( - static_cast(min_bitrate_.kbps()), - config_->bandwidth_cap_at_high_loss_rate.kbps() - - config_->slope_of_bwe_high_loss_func * - average_reported_loss_ratio))); - } } cached_instant_upper_bound_ = instant_limit; diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h b/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h index 425ca2a0c8..9afbb11f1f 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h @@ -62,6 +62,9 @@ class LossBasedBweV2 { // Returns true if loss based BWE is ready to be used in the start phase. bool ReadyToUseInStartPhase() const; + // Returns true if loss based BWE can be used in the start phase. + bool UseInStartPhase() const; + // Returns `DataRate::PlusInfinity` if no BWE can be calculated. Result GetLossBasedResult() const; @@ -83,6 +86,8 @@ class LossBasedBweV2 { struct Config { double bandwidth_rampup_upper_bound_factor = 0.0; + double bandwidth_rampup_upper_bound_factor_in_hold = 0; + double bandwidth_rampup_hold_threshold = 0; double rampup_acceleration_max_factor = 0.0; TimeDelta rampup_acceleration_maxout_time = TimeDelta::Zero(); std::vector candidate_factors; @@ -111,9 +116,6 @@ class LossBasedBweV2 { double max_increase_factor = 0.0; TimeDelta delayed_increase_window = TimeDelta::Zero(); bool not_increase_if_inherent_loss_less_than_average_loss = false; - double high_loss_rate_threshold = 1.0; - DataRate bandwidth_cap_at_high_loss_rate = DataRate::MinusInfinity(); - double slope_of_bwe_high_loss_func = 1000.0; bool not_use_acked_rate_in_alr = false; bool use_in_start_phase = false; int min_num_observations = 0; @@ -121,6 +123,7 @@ class LossBasedBweV2 { double hold_duration_factor = 0.0; bool use_byte_loss_rate = false; TimeDelta padding_duration = TimeDelta::Zero(); + bool bound_best_candidate = false; }; struct Derivatives { @@ -152,6 +155,12 @@ class LossBasedBweV2 { Timestamp padding_timestamp = Timestamp::MinusInfinity(); }; + struct HoldInfo { + Timestamp timestamp = Timestamp::MinusInfinity(); + TimeDelta duration = TimeDelta::Zero(); + DataRate rate = DataRate::PlusInfinity(); + }; + static absl::optional CreateConfig( const FieldTrialsView* key_value_config); bool IsConfigValid() const; @@ -180,7 +189,6 @@ class LossBasedBweV2 { // Returns false if no observation was created. bool PushBackObservation(rtc::ArrayView packet_results); - void UpdateResult(); bool IsEstimateIncreasingWhenLossLimited(DataRate old_estimate, DataRate new_estimate); bool IsInLossLimitedState() const; @@ -204,8 +212,7 @@ class LossBasedBweV2 { DataRate max_bitrate_ = DataRate::PlusInfinity(); DataRate delay_based_estimate_ = DataRate::PlusInfinity(); LossBasedBweV2::Result loss_based_result_ = LossBasedBweV2::Result(); - Timestamp last_hold_timestamp_ = Timestamp::MinusInfinity(); - TimeDelta hold_duration_ = TimeDelta::Zero(); + HoldInfo last_hold_info_ = HoldInfo(); PaddingInfo last_padding_info_ = PaddingInfo(); }; diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2_gn/moz.build b/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2_gn/moz.build index ca9f20ab87..709bcdb937 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2_gn/moz.build +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2_test.cc b/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2_test.cc index 347e2a86d1..9b7ad03148 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2_test.cc +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2_test.cc @@ -795,7 +795,7 @@ TEST_F(LossBasedBweV2Test, // The estimate is capped by acked_bitrate * BwRampupUpperBoundFactor. EXPECT_EQ(result.bandwidth_estimate, estimate_1 * 0.9 * 1.2); - // But if acked bitrate decrease, BWE does not decrease when there is no + // But if acked bitrate decreases, BWE does not decrease when there is no // loss. loss_based_bandwidth_estimator.SetAcknowledgedBitrate(estimate_1 * 0.9); loss_based_bandwidth_estimator.UpdateBandwidthEstimate( @@ -809,6 +809,53 @@ TEST_F(LossBasedBweV2Test, result.bandwidth_estimate); } +// Ensure that the state can switch to kIncrease even when the bandwidth is +// bounded by acked bitrate. +TEST_F(LossBasedBweV2Test, EnsureIncreaseEvenIfAckedBitrateBound) { + ExplicitKeyValueConfig key_value_config(ShortObservationConfig( + "LossThresholdOfHighBandwidthPreference:0.99," + "BwRampupUpperBoundFactor:1.2," + // Set InstantUpperBoundBwBalance high to disable InstantUpperBound cap. + "InstantUpperBoundBwBalance:10000kbps,")); + std::vector enough_feedback_1 = + CreatePacketResultsWith100pLossRate( + /*first_packet_timestamp=*/Timestamp::Zero()); + LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); + DataRate delay_based_estimate = DataRate::KilobitsPerSec(5000); + + loss_based_bandwidth_estimator.SetBandwidthEstimate( + DataRate::KilobitsPerSec(600)); + loss_based_bandwidth_estimator.SetAcknowledgedBitrate( + DataRate::KilobitsPerSec(300)); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate(enough_feedback_1, + delay_based_estimate, + /*in_alr=*/false); + ASSERT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, + LossBasedState::kDecreasing); + LossBasedBweV2::Result result = + loss_based_bandwidth_estimator.GetLossBasedResult(); + DataRate estimate_1 = result.bandwidth_estimate; + ASSERT_LT(estimate_1.kbps(), 600); + + // Set a low acked bitrate. + loss_based_bandwidth_estimator.SetAcknowledgedBitrate(estimate_1 / 2); + + int feedback_count = 1; + while (feedback_count < 5 && result.state != LossBasedState::kIncreasing) { + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWithReceivedPackets( + /*first_packet_timestamp=*/Timestamp::Zero() + + feedback_count++ * kObservationDurationLowerBound), + delay_based_estimate, + /*in_alr=*/false); + result = loss_based_bandwidth_estimator.GetLossBasedResult(); + } + + ASSERT_EQ(result.state, LossBasedState::kIncreasing); + // The estimate increases by 1kbps. + EXPECT_EQ(result.bandwidth_estimate, estimate_1 + DataRate::BitsPerSec(1)); +} + // After loss based bwe backs off, the estimate is bounded during the delayed // window. TEST_F(LossBasedBweV2Test, @@ -1007,164 +1054,6 @@ TEST_F(LossBasedBweV2Test, DataRate::KilobitsPerSec(600)); } -TEST_F(LossBasedBweV2Test, - StricterBoundUsingHighLossRateThresholdAt10pLossRate) { - ExplicitKeyValueConfig key_value_config( - ShortObservationConfig("HighLossRateThreshold:0.09")); - LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); - loss_based_bandwidth_estimator.SetMinMaxBitrate( - /*min_bitrate=*/DataRate::KilobitsPerSec(10), - /*max_bitrate=*/DataRate::KilobitsPerSec(1000000)); - DataRate delay_based_estimate = DataRate::KilobitsPerSec(5000); - loss_based_bandwidth_estimator.SetBandwidthEstimate( - DataRate::KilobitsPerSec(600)); - - std::vector enough_feedback_10p_loss_1 = - CreatePacketResultsWith10pPacketLossRate( - /*first_packet_timestamp=*/Timestamp::Zero()); - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback_10p_loss_1, delay_based_estimate, - - /*in_alr=*/false); - - std::vector enough_feedback_10p_loss_2 = - CreatePacketResultsWith10pPacketLossRate( - /*first_packet_timestamp=*/Timestamp::Zero() + - kObservationDurationLowerBound); - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback_10p_loss_2, delay_based_estimate, - - /*in_alr=*/false); - - // 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().bandwidth_estimate, - DataRate::KilobitsPerSec(400)); -} - -TEST_F(LossBasedBweV2Test, - StricterBoundUsingHighLossRateThresholdAt50pLossRate) { - ExplicitKeyValueConfig key_value_config( - ShortObservationConfig("HighLossRateThreshold:0.3")); - LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); - loss_based_bandwidth_estimator.SetMinMaxBitrate( - /*min_bitrate=*/DataRate::KilobitsPerSec(10), - /*max_bitrate=*/DataRate::KilobitsPerSec(1000000)); - DataRate delay_based_estimate = DataRate::KilobitsPerSec(5000); - loss_based_bandwidth_estimator.SetBandwidthEstimate( - DataRate::KilobitsPerSec(600)); - - std::vector enough_feedback_50p_loss_1 = - CreatePacketResultsWith50pPacketLossRate( - /*first_packet_timestamp=*/Timestamp::Zero()); - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback_50p_loss_1, delay_based_estimate, - - /*in_alr=*/false); - - std::vector enough_feedback_50p_loss_2 = - CreatePacketResultsWith50pPacketLossRate( - /*first_packet_timestamp=*/Timestamp::Zero() + - kObservationDurationLowerBound); - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback_50p_loss_2, delay_based_estimate, - - /*in_alr=*/false); - - // 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().bandwidth_estimate, - DataRate::KilobitsPerSec(10)); -} - -TEST_F(LossBasedBweV2Test, - StricterBoundUsingHighLossRateThresholdAt100pLossRate) { - ExplicitKeyValueConfig key_value_config( - ShortObservationConfig("HighLossRateThreshold:0.3")); - LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); - loss_based_bandwidth_estimator.SetMinMaxBitrate( - /*min_bitrate=*/DataRate::KilobitsPerSec(10), - /*max_bitrate=*/DataRate::KilobitsPerSec(1000000)); - DataRate delay_based_estimate = DataRate::KilobitsPerSec(5000); - loss_based_bandwidth_estimator.SetBandwidthEstimate( - DataRate::KilobitsPerSec(600)); - - std::vector enough_feedback_100p_loss_1 = - CreatePacketResultsWith100pLossRate( - /*first_packet_timestamp=*/Timestamp::Zero()); - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback_100p_loss_1, delay_based_estimate, - - /*in_alr=*/false); - - std::vector enough_feedback_100p_loss_2 = - CreatePacketResultsWith100pLossRate( - /*first_packet_timestamp=*/Timestamp::Zero() + - kObservationDurationLowerBound); - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback_100p_loss_2, delay_based_estimate, - - /*in_alr=*/false); - - // 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().bandwidth_estimate, - DataRate::KilobitsPerSec(10)); -} - -TEST_F(LossBasedBweV2Test, EstimateRecoversAfterHighLoss) { - ExplicitKeyValueConfig key_value_config( - ShortObservationConfig("HighLossRateThreshold:0.3")); - LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); - loss_based_bandwidth_estimator.SetMinMaxBitrate( - /*min_bitrate=*/DataRate::KilobitsPerSec(10), - /*max_bitrate=*/DataRate::KilobitsPerSec(1000000)); - DataRate delay_based_estimate = DataRate::KilobitsPerSec(5000); - loss_based_bandwidth_estimator.SetBandwidthEstimate( - DataRate::KilobitsPerSec(600)); - - std::vector enough_feedback_100p_loss_1 = - CreatePacketResultsWith100pLossRate( - /*first_packet_timestamp=*/Timestamp::Zero()); - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback_100p_loss_1, delay_based_estimate, - - /*in_alr=*/false); - - // Make sure that the estimate is set to min bitrate because of 100% loss - // rate. - EXPECT_EQ( - loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, - DataRate::KilobitsPerSec(10)); - - // Create some feedbacks with 0 loss rate to simulate network recovering. - std::vector enough_feedback_0p_loss_1 = - CreatePacketResultsWithReceivedPackets( - /*first_packet_timestamp=*/Timestamp::Zero() + - kObservationDurationLowerBound); - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback_0p_loss_1, delay_based_estimate, - - /*in_alr=*/false); - - std::vector enough_feedback_0p_loss_2 = - CreatePacketResultsWithReceivedPackets( - /*first_packet_timestamp=*/Timestamp::Zero() + - kObservationDurationLowerBound * 2); - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback_0p_loss_2, delay_based_estimate, - - /*in_alr=*/false); - - // The estimate increases as network recovers. - EXPECT_GT( - loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, - DataRate::KilobitsPerSec(10)); -} - TEST_F(LossBasedBweV2Test, EstimateIsNotHigherThanMaxBitrate) { ExplicitKeyValueConfig key_value_config( Config(/*enabled=*/true, /*valid=*/true)); @@ -1494,6 +1383,92 @@ TEST_F(LossBasedBweV2Test, IncreaseUsingPaddingStateIfFieldTrial) { LossBasedState::kIncreaseUsingPadding); } +TEST_F(LossBasedBweV2Test, BestCandidateResetsToUpperBoundInFieldTrial) { + ExplicitKeyValueConfig key_value_config( + ShortObservationConfig("PaddingDuration:1000ms,BoundBestCandidate:true")); + LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); + loss_based_bandwidth_estimator.SetBandwidthEstimate( + DataRate::KilobitsPerSec(2500)); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWith50pPacketLossRate( + /*first_packet_timestamp=*/Timestamp::Zero()), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/true); + LossBasedBweV2::Result result_after_loss = + loss_based_bandwidth_estimator.GetLossBasedResult(); + ASSERT_EQ(result_after_loss.state, LossBasedState::kDecreasing); + + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWithReceivedPackets( + /*first_packet_timestamp=*/Timestamp::Zero() + + kObservationDurationLowerBound), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/true); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWithReceivedPackets( + /*first_packet_timestamp=*/Timestamp::Zero() + + 2 * kObservationDurationLowerBound), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/true); + // After a BWE decrease due to large loss, BWE is expected to ramp up slowly + // and follow the acked bitrate. + EXPECT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, + LossBasedState::kIncreaseUsingPadding); + EXPECT_NEAR(loss_based_bandwidth_estimator.GetLossBasedResult() + .bandwidth_estimate.kbps(), + result_after_loss.bandwidth_estimate.kbps(), 100); +} + +TEST_F(LossBasedBweV2Test, DecreaseToAckedCandidateIfPaddingInAlr) { + ExplicitKeyValueConfig key_value_config(ShortObservationConfig( + "PaddingDuration:1000ms," + // Set InstantUpperBoundBwBalance high to disable InstantUpperBound cap. + "InstantUpperBoundBwBalance:10000kbps")); + LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); + loss_based_bandwidth_estimator.SetBandwidthEstimate( + DataRate::KilobitsPerSec(1000)); + int feedback_id = 0; + while (loss_based_bandwidth_estimator.GetLossBasedResult().state != + LossBasedState::kDecreasing) { + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWith100pLossRate( + /*first_packet_timestamp=*/Timestamp::Zero() + + kObservationDurationLowerBound * feedback_id), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/true); + feedback_id++; + } + + while (loss_based_bandwidth_estimator.GetLossBasedResult().state != + LossBasedState::kIncreaseUsingPadding) { + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWithReceivedPackets( + /*first_packet_timestamp=*/Timestamp::Zero() + + kObservationDurationLowerBound * feedback_id), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/true); + feedback_id++; + } + ASSERT_GT( + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, + DataRate::KilobitsPerSec(900)); + + loss_based_bandwidth_estimator.SetAcknowledgedBitrate( + DataRate::KilobitsPerSec(100)); + // Padding is sent now, create some lost packets. + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWith100pLossRate( + /*first_packet_timestamp=*/Timestamp::Zero() + + kObservationDurationLowerBound * feedback_id), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/true); + EXPECT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, + LossBasedState::kDecreasing); + EXPECT_EQ( + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, + DataRate::KilobitsPerSec(100)); +} + TEST_F(LossBasedBweV2Test, DecreaseAfterPadding) { ExplicitKeyValueConfig key_value_config(ShortObservationConfig( "PaddingDuration:1000ms,BwRampupUpperBoundFactor:2.0")); @@ -1580,7 +1555,7 @@ TEST_F(LossBasedBweV2Test, IncreaseEstimateIfNotHold) { TEST_F(LossBasedBweV2Test, IncreaseEstimateAfterHoldDuration) { ExplicitKeyValueConfig key_value_config( - ShortObservationConfig("HoldDurationFactor:3")); + ShortObservationConfig("HoldDurationFactor:10")); LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); loss_based_bandwidth_estimator.SetBandwidthEstimate( DataRate::KilobitsPerSec(2500)); @@ -1629,36 +1604,126 @@ TEST_F(LossBasedBweV2Test, IncreaseEstimateAfterHoldDuration) { /*in_alr=*/false); EXPECT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, LossBasedState::kDecreasing); - estimate = + DataRate estimate_at_hold = loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate; - // During the hold duration, e.g. next 900ms, the estimate cannot increase. + // In the hold duration, e.g. next 3s, the estimate cannot increase above the + // hold rate. Get some lost packets to get lower estimate than the HOLD rate. for (int i = 4; i <= 6; ++i) { loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - CreatePacketResultsWithReceivedPackets( + CreatePacketResultsWith100pLossRate( /*first_packet_timestamp=*/Timestamp::Zero() + kObservationDurationLowerBound * i), /*delay_based_estimate=*/DataRate::PlusInfinity(), /*in_alr=*/false); EXPECT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, LossBasedState::kDecreasing); - EXPECT_EQ( + EXPECT_LT( loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, - estimate); + estimate_at_hold); + } + + int feedback_id = 7; + while (loss_based_bandwidth_estimator.GetLossBasedResult().state != + LossBasedState::kIncreasing) { + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWithReceivedPackets( + /*first_packet_timestamp=*/Timestamp::Zero() + + kObservationDurationLowerBound * feedback_id), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/false); + if (loss_based_bandwidth_estimator.GetLossBasedResult().state == + LossBasedState::kDecreasing) { + // In the hold duration, the estimate can not go higher than estimate at + // hold. + EXPECT_LE(loss_based_bandwidth_estimator.GetLossBasedResult() + .bandwidth_estimate, + estimate_at_hold); + } else if (loss_based_bandwidth_estimator.GetLossBasedResult().state == + LossBasedState::kIncreasing) { + // After the hold duration, the estimate can increase again. + EXPECT_GT(loss_based_bandwidth_estimator.GetLossBasedResult() + .bandwidth_estimate, + estimate_at_hold); + } + feedback_id++; } +} - // After the hold duration, the estimate can increase again. +TEST_F(LossBasedBweV2Test, HoldRateNotLowerThanAckedRate) { + ExplicitKeyValueConfig key_value_config(ShortObservationConfig( + "HoldDurationFactor:10,LowerBoundByAckedRateFactor:1.0")); + LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); + loss_based_bandwidth_estimator.SetBandwidthEstimate( + DataRate::KilobitsPerSec(2500)); loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - CreatePacketResultsWithReceivedPackets( + CreatePacketResultsWith50pPacketLossRate( + /*first_packet_timestamp=*/Timestamp::Zero()), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/false); + ASSERT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, + LossBasedState::kDecreasing); + + // During the hold duration, hold rate is not lower than the acked rate. + loss_based_bandwidth_estimator.SetAcknowledgedBitrate( + DataRate::KilobitsPerSec(1000)); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWith50pPacketLossRate( /*first_packet_timestamp=*/Timestamp::Zero() + - kObservationDurationLowerBound * 7), + kObservationDurationLowerBound), /*delay_based_estimate=*/DataRate::PlusInfinity(), /*in_alr=*/false); EXPECT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, - LossBasedState::kIncreasing); - EXPECT_GE( + LossBasedState::kDecreasing); + EXPECT_EQ( loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, - estimate); + DataRate::KilobitsPerSec(1000)); +} + +TEST_F(LossBasedBweV2Test, EstimateNotLowerThanAckedRate) { + ExplicitKeyValueConfig key_value_config( + ShortObservationConfig("LowerBoundByAckedRateFactor:1.0")); + LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); + loss_based_bandwidth_estimator.SetBandwidthEstimate( + DataRate::KilobitsPerSec(2500)); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWith100pLossRate( + /*first_packet_timestamp=*/Timestamp::Zero()), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/false); + ASSERT_LT( + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, + DataRate::KilobitsPerSec(1000)); + + loss_based_bandwidth_estimator.SetAcknowledgedBitrate( + DataRate::KilobitsPerSec(1000)); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWith100pLossRate( + /*first_packet_timestamp=*/Timestamp::Zero() + + kObservationDurationLowerBound), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/false); + EXPECT_EQ( + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, + DataRate::KilobitsPerSec(1000)); + + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWithReceivedPackets( + /*first_packet_timestamp=*/Timestamp::Zero() + + kObservationDurationLowerBound * 2), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/false); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWithReceivedPackets( + /*first_packet_timestamp=*/Timestamp::Zero() + + kObservationDurationLowerBound * 3), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/false); + + // Verify that the estimate recovers from the acked rate. + EXPECT_GT( + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, + DataRate::KilobitsPerSec(1000)); } TEST_F(LossBasedBweV2Test, EndHoldDurationIfDelayBasedEstimateWorks) { diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/probe_controller_gn/moz.build b/third_party/libwebrtc/modules/congestion_controller/goog_cc/probe_controller_gn/moz.build index 703c22a590..049ac6f477 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/probe_controller_gn/moz.build +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/probe_controller_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/pushback_controller_gn/moz.build b/third_party/libwebrtc/modules/congestion_controller/goog_cc/pushback_controller_gn/moz.build index 291502c95a..6e1d0acff5 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/pushback_controller_gn/moz.build +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/pushback_controller_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc b/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc index b09cb22f49..22693d67e9 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc @@ -203,9 +203,9 @@ TimeDelta RttBasedBackoff::CorrectedRtt() const { RttBasedBackoff::~RttBasedBackoff() = default; SendSideBandwidthEstimation::SendSideBandwidthEstimation( - const FieldTrialsView* key_value_config, - RtcEventLog* event_log) - : rtt_backoff_(key_value_config), + const FieldTrialsView* key_value_config, RtcEventLog* event_log) + : key_value_config_(key_value_config), + rtt_backoff_(key_value_config), lost_packets_since_last_loss_update_(0), expected_packets_since_last_loss_update_(0), current_target_(DataRate::Zero()), @@ -234,7 +234,7 @@ SendSideBandwidthEstimation::SendSideBandwidthEstimation( high_loss_threshold_(kDefaultHighLossThreshold), bitrate_threshold_(kDefaultBitrateThreshold), loss_based_bandwidth_estimator_v1_(key_value_config), - loss_based_bandwidth_estimator_v2_(key_value_config), + loss_based_bandwidth_estimator_v2_(new LossBasedBweV2(key_value_config)), loss_based_state_(LossBasedState::kDelayBasedEstimate), disable_receiver_limit_caps_only_("Disabled") { RTC_DCHECK(event_log); @@ -252,7 +252,7 @@ SendSideBandwidthEstimation::SendSideBandwidthEstimation( ParseFieldTrial({&disable_receiver_limit_caps_only_}, key_value_config->Lookup("WebRTC-Bwe-ReceiverLimitCapsOnly")); if (LossBasedBandwidthEstimatorV2Enabled()) { - loss_based_bandwidth_estimator_v2_.SetMinMaxBitrate( + loss_based_bandwidth_estimator_v2_->SetMinMaxBitrate( min_bitrate_configured_, max_bitrate_configured_); } } @@ -281,6 +281,10 @@ void SendSideBandwidthEstimation::OnRouteChange() { uma_update_state_ = kNoUpdate; uma_rtt_state_ = kNoUpdate; last_rtc_event_log_ = Timestamp::MinusInfinity(); + if (loss_based_bandwidth_estimator_v2_->UseInStartPhase()) { + loss_based_bandwidth_estimator_v2_.reset( + new LossBasedBweV2(key_value_config_)); + } } void SendSideBandwidthEstimation::SetBitrates( @@ -315,8 +319,8 @@ void SendSideBandwidthEstimation::SetMinMaxBitrate(DataRate min_bitrate, } else { max_bitrate_configured_ = kDefaultMaxBitrate; } - loss_based_bandwidth_estimator_v2_.SetMinMaxBitrate(min_bitrate_configured_, - max_bitrate_configured_); + loss_based_bandwidth_estimator_v2_->SetMinMaxBitrate(min_bitrate_configured_, + max_bitrate_configured_); } int SendSideBandwidthEstimation::GetMinBitrate() const { @@ -371,7 +375,7 @@ void SendSideBandwidthEstimation::SetAcknowledgedRate( *acknowledged_rate, at_time); } if (LossBasedBandwidthEstimatorV2Enabled()) { - loss_based_bandwidth_estimator_v2_.SetAcknowledgedBitrate( + loss_based_bandwidth_estimator_v2_->SetAcknowledgedBitrate( *acknowledged_rate); } } @@ -386,7 +390,7 @@ void SendSideBandwidthEstimation::UpdateLossBasedEstimator( report.packet_feedbacks, report.feedback_time); } if (LossBasedBandwidthEstimatorV2Enabled()) { - loss_based_bandwidth_estimator_v2_.UpdateBandwidthEstimate( + loss_based_bandwidth_estimator_v2_->UpdateBandwidthEstimate( report.packet_feedbacks, delay_based_limit_, in_alr); UpdateEstimate(report.feedback_time); } @@ -492,7 +496,7 @@ void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) { // We trust the REMB and/or delay-based estimate during the first 2 seconds if // we haven't had any packet loss reported, to allow startup bitrate probing. if (last_fraction_loss_ == 0 && IsInStartPhase(at_time) && - !loss_based_bandwidth_estimator_v2_.ReadyToUseInStartPhase()) { + !loss_based_bandwidth_estimator_v2_->ReadyToUseInStartPhase()) { DataRate new_bitrate = current_target_; // TODO(srte): We should not allow the new_bitrate to be larger than the // receiver limit here. @@ -534,7 +538,7 @@ void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) { if (LossBasedBandwidthEstimatorV2ReadyForUse()) { LossBasedBweV2::Result result = - loss_based_bandwidth_estimator_v2_.GetLossBasedResult(); + loss_based_bandwidth_estimator_v2_->GetLossBasedResult(); loss_based_state_ = result.state; UpdateTargetBitrate(result.bandwidth_estimate, at_time); return; @@ -690,13 +694,13 @@ bool SendSideBandwidthEstimation::LossBasedBandwidthEstimatorV1ReadyForUse() } bool SendSideBandwidthEstimation::LossBasedBandwidthEstimatorV2Enabled() const { - return loss_based_bandwidth_estimator_v2_.IsEnabled(); + return loss_based_bandwidth_estimator_v2_->IsEnabled(); } bool SendSideBandwidthEstimation::LossBasedBandwidthEstimatorV2ReadyForUse() const { return LossBasedBandwidthEstimatorV2Enabled() && - loss_based_bandwidth_estimator_v2_.IsReady(); + loss_based_bandwidth_estimator_v2_->IsReady(); } } // namespace webrtc diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.h b/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.h index 3a4efc47c7..dd4d25a236 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.h +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.h @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -167,6 +168,7 @@ class SendSideBandwidthEstimation { bool LossBasedBandwidthEstimatorV1ReadyForUse() const; bool LossBasedBandwidthEstimatorV2ReadyForUse() const; + const FieldTrialsView* key_value_config_; RttBasedBackoff rtt_backoff_; LinkCapacityTracker link_capacity_; @@ -208,7 +210,7 @@ class SendSideBandwidthEstimation { float high_loss_threshold_; DataRate bitrate_threshold_; LossBasedBandwidthEstimation loss_based_bandwidth_estimator_v1_; - LossBasedBweV2 loss_based_bandwidth_estimator_v2_; + std::unique_ptr loss_based_bandwidth_estimator_v2_; LossBasedState loss_based_state_; FieldTrialFlag disable_receiver_limit_caps_only_; }; diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bwe_gn/moz.build b/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bwe_gn/moz.build index d83d51f985..08cfdec69b 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bwe_gn/moz.build +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bwe_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True -- cgit v1.2.3