Clean loss based bwe 2.

This is for cleaning loss based bwe v2 implementation according to some comments from https://webrtc-review.googlesource.com/c/src/+/261240.

Bug: webrtc:12707
Change-Id: I2cb278f136cddcd0eeb2c5e4c319a9cc6aab94a0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/262251
Commit-Queue: Diep Bui <diepbp@webrtc.org>
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36875}
This commit is contained in:
Diep Bui
2022-05-13 08:08:07 +00:00
committed by WebRTC LUCI CQ
parent e5fb8512b0
commit d97af7b1b9
3 changed files with 36 additions and 22 deletions

View File

@ -149,13 +149,13 @@ DataRate LossBasedBweV2::GetBandwidthEstimate(
"statistics before it can be used."; "statistics before it can be used.";
} }
} }
return DataRate::PlusInfinity(); return IsValid(delay_based_limit) ? delay_based_limit
: DataRate::PlusInfinity();
} }
if (delay_based_limit.IsFinite()) { if (delay_based_limit.IsFinite()) {
return std::min({current_estimate_.loss_limited_bandwidth, return std::min({current_estimate_.loss_limited_bandwidth,
GetInstantUpperBound(), GetInstantUpperBound(), delay_based_limit});
delay_based_limit * config_->delay_based_limit_factor});
} else { } else {
return std::min(current_estimate_.loss_limited_bandwidth, return std::min(current_estimate_.loss_limited_bandwidth,
GetInstantUpperBound()); GetInstantUpperBound());
@ -221,7 +221,7 @@ void LossBasedBweV2::UpdateBandwidthEstimate(
last_time_estimate_reduced_ = last_send_time_most_recent_observation_; last_time_estimate_reduced_ = last_send_time_most_recent_observation_;
} }
// Bound the estimate increasement if: // Bound the estimate increase if:
// 1. The estimate is limited due to loss, and // 1. The estimate is limited due to loss, and
// 2. The estimate has been increased for less than `delayed_increase_window` // 2. The estimate has been increased for less than `delayed_increase_window`
// ago, and // ago, and
@ -299,9 +299,8 @@ absl::optional<LossBasedBweV2::Config> LossBasedBweV2::CreateConfig(
"BwBackoffLowerBoundFactor", 1.0); "BwBackoffLowerBoundFactor", 1.0);
FieldTrialParameter<bool> trendline_integration_enabled( FieldTrialParameter<bool> trendline_integration_enabled(
"TrendlineIntegrationEnabled", false); "TrendlineIntegrationEnabled", false);
FieldTrialParameter<double> delay_based_limit_factor("DelayBasedLimitFactor", FieldTrialParameter<int> trendline_observations_window_size(
1.0); "TrendlineObservationsWindowSize", 20);
FieldTrialParameter<int> trendline_window_size("TrendlineWindowSize", 20);
FieldTrialParameter<double> max_increase_factor("MaxIncreaseFactor", 1000.0); FieldTrialParameter<double> max_increase_factor("MaxIncreaseFactor", 1000.0);
FieldTrialParameter<TimeDelta> delayed_increase_window( FieldTrialParameter<TimeDelta> delayed_increase_window(
"DelayedIncreaseWindow", TimeDelta::Millis(300)); "DelayedIncreaseWindow", TimeDelta::Millis(300));
@ -333,8 +332,7 @@ absl::optional<LossBasedBweV2::Config> LossBasedBweV2::CreateConfig(
&temporal_weight_factor, &temporal_weight_factor,
&bandwidth_backoff_lower_bound_factor, &bandwidth_backoff_lower_bound_factor,
&trendline_integration_enabled, &trendline_integration_enabled,
&delay_based_limit_factor, &trendline_observations_window_size,
&trendline_window_size,
&max_increase_factor, &max_increase_factor,
&delayed_increase_window, &delayed_increase_window,
&use_acked_bitrate_only_when_overusing}, &use_acked_bitrate_only_when_overusing},
@ -381,8 +379,8 @@ absl::optional<LossBasedBweV2::Config> LossBasedBweV2::CreateConfig(
config->bandwidth_backoff_lower_bound_factor = config->bandwidth_backoff_lower_bound_factor =
bandwidth_backoff_lower_bound_factor.Get(); bandwidth_backoff_lower_bound_factor.Get();
config->trendline_integration_enabled = trendline_integration_enabled.Get(); config->trendline_integration_enabled = trendline_integration_enabled.Get();
config->delay_based_limit_factor = delay_based_limit_factor.Get(); config->trendline_observations_window_size =
config->trendline_window_size = trendline_window_size.Get(); trendline_observations_window_size.Get();
config->max_increase_factor = max_increase_factor.Get(); config->max_increase_factor = max_increase_factor.Get();
config->delayed_increase_window = delayed_increase_window.Get(); config->delayed_increase_window = delayed_increase_window.Get();
config->use_acked_bitrate_only_when_overusing = config->use_acked_bitrate_only_when_overusing =
@ -536,15 +534,9 @@ bool LossBasedBweV2::IsConfigValid() const {
<< config_->bandwidth_backoff_lower_bound_factor; << config_->bandwidth_backoff_lower_bound_factor;
valid = false; valid = false;
} }
if (config_->delay_based_limit_factor < 1.0) { if (config_->trendline_observations_window_size < 2) {
RTC_LOG(LS_WARNING)
<< "The delay based limit factor must not be less than 1: "
<< config_->delay_based_limit_factor;
valid = false;
}
if (config_->trendline_window_size < 2) {
RTC_LOG(LS_WARNING) << "The trendline window size must be at least 2: " RTC_LOG(LS_WARNING) << "The trendline window size must be at least 2: "
<< config_->trendline_window_size; << config_->trendline_observations_window_size;
valid = false; valid = false;
} }
if (config_->max_increase_factor <= 0.0) { if (config_->max_increase_factor <= 0.0) {
@ -861,7 +853,7 @@ bool LossBasedBweV2::PushBackObservation(
BandwidthUsage delay_detector_state) { BandwidthUsage delay_detector_state) {
delay_detector_states_.push_front(delay_detector_state); delay_detector_states_.push_front(delay_detector_state);
if (static_cast<int>(delay_detector_states_.size()) > if (static_cast<int>(delay_detector_states_.size()) >
config_->trendline_window_size) { config_->trendline_observations_window_size) {
delay_detector_states_.pop_back(); delay_detector_states_.pop_back();
} }

View File

@ -85,8 +85,7 @@ class LossBasedBweV2 {
double temporal_weight_factor = 0.0; double temporal_weight_factor = 0.0;
double bandwidth_backoff_lower_bound_factor = 0.0; double bandwidth_backoff_lower_bound_factor = 0.0;
bool trendline_integration_enabled = false; bool trendline_integration_enabled = false;
double delay_based_limit_factor = 1.0; int trendline_observations_window_size = 0;
int trendline_window_size = 0;
double max_increase_factor = 0.0; double max_increase_factor = 0.0;
TimeDelta delayed_increase_window = TimeDelta::Zero(); TimeDelta delayed_increase_window = TimeDelta::Zero();
bool use_acked_bitrate_only_when_overusing = false; bool use_acked_bitrate_only_when_overusing = false;

View File

@ -179,6 +179,29 @@ TEST_P(LossBasedBweV2Test,
EXPECT_FALSE(loss_based_bandwidth_estimator.IsEnabled()); EXPECT_FALSE(loss_based_bandwidth_estimator.IsEnabled());
} }
TEST_P(LossBasedBweV2Test, ReturnsDelayBasedEstimateWhenDisabled) {
ExplicitKeyValueConfig key_value_config(
Config(/*enabled=*/false, /*valid=*/true,
/*trendline_integration_enabled=*/GetParam()));
LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config);
EXPECT_EQ(loss_based_bandwidth_estimator.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::KilobitsPerSec(100)),
DataRate::KilobitsPerSec(100));
}
TEST_P(LossBasedBweV2Test,
ReturnsDelayBasedEstimateWhenWhenGivenNonValidConfigurationValues) {
ExplicitKeyValueConfig key_value_config(
Config(/*enabled=*/true, /*valid=*/false,
/*trendline_integration_enabled=*/GetParam()));
LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config);
EXPECT_EQ(loss_based_bandwidth_estimator.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::KilobitsPerSec(100)),
DataRate::KilobitsPerSec(100));
}
TEST_P(LossBasedBweV2Test, TEST_P(LossBasedBweV2Test,
BandwidthEstimateGivenInitializationAndThenFeedback) { BandwidthEstimateGivenInitializationAndThenFeedback) {
std::vector<PacketResult> enough_feedback = std::vector<PacketResult> enough_feedback =