Index: webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc |
diff --git a/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc b/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc |
index 81ab97367bb5ce322fb6e74368120bf9f1136ca4..bcb71d6db891db222bdfbee7e43fef629598ff85 100644 |
--- a/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc |
+++ b/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc |
@@ -14,6 +14,7 @@ |
#include <cassert> |
#include <cmath> |
+#include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h" |
#include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" |
namespace webrtc { |
@@ -27,20 +28,20 @@ AimdRateControl::AimdRateControl(uint32_t min_bitrate_bps) |
: min_configured_bitrate_bps_(min_bitrate_bps), |
max_configured_bitrate_bps_(30000000), |
current_bitrate_bps_(max_configured_bitrate_bps_), |
- max_hold_rate_bps_(0), |
avg_max_bitrate_kbps_(-1.0f), |
var_max_bitrate_kbps_(0.4f), |
rate_control_state_(kRcHold), |
- came_from_state_(kRcDecrease), |
rate_control_region_(kRcMaxUnknown), |
time_last_bitrate_change_(-1), |
current_input_(kBwNormal, 0, 1.0), |
updated_(false), |
time_first_incoming_estimate_(-1), |
bitrate_is_initialized_(false), |
- beta_(0.9f), |
+ beta_(0.85f), |
rtt_(kDefaultRttMs), |
- time_of_last_log_(-1) {} |
+ time_of_last_log_(-1), |
+ in_experiment_(AdaptiveThresholdExperimentIsEnabled()) { |
+} |
uint32_t AimdRateControl::GetMinBitrate() const { |
return min_configured_bitrate_bps_; |
@@ -95,8 +96,7 @@ void AimdRateControl::SetRtt(int64_t rtt) { |
rtt_ = rtt; |
} |
-RateControlRegion AimdRateControl::Update(const RateControlInput* input, |
- int64_t now_ms) { |
+void AimdRateControl::Update(const RateControlInput* input, int64_t now_ms) { |
assert(input); |
// Set the initial bit rate value to what we're receiving the first half |
@@ -122,7 +122,6 @@ RateControlRegion AimdRateControl::Update(const RateControlInput* input, |
updated_ = true; |
current_input_ = *input; |
} |
- return rate_control_region_; |
} |
void AimdRateControl::SetEstimate(int bitrate_bps, int64_t now_ms) { |
@@ -145,22 +144,16 @@ uint32_t AimdRateControl::ChangeBitrate(uint32_t current_bitrate_bps, |
// variance and the current incoming bit rate. |
const float std_max_bit_rate = sqrt(var_max_bitrate_kbps_ * |
avg_max_bitrate_kbps_); |
- bool fast_recovery_after_hold = false; |
switch (rate_control_state_) { |
- case kRcHold: { |
- max_hold_rate_bps_ = std::max(max_hold_rate_bps_, incoming_bitrate_bps); |
+ case kRcHold: |
break; |
- } |
- case kRcIncrease: { |
- if (avg_max_bitrate_kbps_ >= 0) { |
- if (incoming_bitrate_kbps > avg_max_bitrate_kbps_ + |
- 3 * std_max_bit_rate) { |
- ChangeRegion(kRcMaxUnknown); |
- avg_max_bitrate_kbps_ = -1.0; |
- } else if (incoming_bitrate_kbps > avg_max_bitrate_kbps_ + |
- 2.5 * std_max_bit_rate) { |
- ChangeRegion(kRcAboveMax); |
- } |
+ |
+ case kRcIncrease: |
+ if (avg_max_bitrate_kbps_ >= 0 && |
+ incoming_bitrate_kbps > |
+ avg_max_bitrate_kbps_ + 3 * std_max_bit_rate) { |
+ ChangeRegion(kRcMaxUnknown); |
+ avg_max_bitrate_kbps_ = -1.0; |
} |
if (rate_control_region_ == kRcNearMax) { |
// Approximate the over-use estimator delay to 100 ms. |
@@ -175,18 +168,10 @@ uint32_t AimdRateControl::ChangeBitrate(uint32_t current_bitrate_bps, |
current_bitrate_bps += multiplicative_increase_bps; |
} |
- if (max_hold_rate_bps_ > 0 && |
- beta_ * max_hold_rate_bps_ > current_bitrate_bps) { |
- current_bitrate_bps = static_cast<uint32_t>(beta_ * max_hold_rate_bps_); |
- avg_max_bitrate_kbps_ = beta_ * max_hold_rate_bps_ / 1000.0f; |
- ChangeRegion(kRcNearMax); |
- fast_recovery_after_hold = true; |
- } |
- max_hold_rate_bps_ = 0; |
time_last_bitrate_change_ = now_ms; |
break; |
- } |
- case kRcDecrease: { |
+ |
+ case kRcDecrease: |
if (incoming_bitrate_bps < min_configured_bitrate_bps_) { |
current_bitrate_bps = min_configured_bitrate_bps_; |
} else { |
@@ -216,12 +201,11 @@ uint32_t AimdRateControl::ChangeBitrate(uint32_t current_bitrate_bps, |
ChangeState(kRcHold); |
time_last_bitrate_change_ = now_ms; |
break; |
- } |
+ |
default: |
assert(false); |
} |
- if (!fast_recovery_after_hold && (incoming_bitrate_bps > 100000 || |
- current_bitrate_bps > 150000) && |
+ if ((incoming_bitrate_bps > 100000 || current_bitrate_bps > 150000) && |
current_bitrate_bps > 1.5 * incoming_bitrate_bps) { |
// Allow changing the bit rate if we are operating at very low rates |
// Don't change the bit rate if the send side is too far off |
@@ -249,8 +233,10 @@ uint32_t AimdRateControl::AdditiveRateIncrease( |
assert(response_time_ms > 0); |
double beta = 0.0; |
if (last_ms > 0) { |
- beta = std::min((now_ms - last_ms) / |
- static_cast<double>(response_time_ms), 1.0); |
+ beta = std::min((now_ms - last_ms) / static_cast<double>(response_time_ms), |
+ 1.0); |
+ if (in_experiment_) |
+ beta /= 2.0; |
} |
double bits_per_frame = static_cast<double>(current_bitrate_bps_) / 30.0; |
double packets_per_frame = std::ceil(bits_per_frame / (8.0 * 1200.0)); |
@@ -308,21 +294,9 @@ void AimdRateControl::ChangeState(const RateControlInput& input, |
void AimdRateControl::ChangeRegion(RateControlRegion region) { |
rate_control_region_ = region; |
- switch (rate_control_region_) { |
- case kRcAboveMax: |
- case kRcMaxUnknown: |
- beta_ = 0.9f; |
- break; |
- case kRcNearMax: |
- beta_ = 0.95f; |
- break; |
- default: |
- assert(false); |
- } |
} |
void AimdRateControl::ChangeState(RateControlState new_state) { |
- came_from_state_ = rate_control_state_; |
rate_control_state_ = new_state; |
} |
} // namespace webrtc |