Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(486)

Unified Diff: webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc

Issue 2684353004: Reduce the BWE with 50% when feedback is received too late. (Closed)
Patch Set: rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 fdee6df86762160adb9a9122668b85e4b94694c7..15371438c8949b3378a8e640a4b3b47677b24a47 100644
--- a/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc
+++ b/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc
@@ -133,7 +133,8 @@ void AimdRateControl::Update(const RateControlInput* input, int64_t now_ms) {
void AimdRateControl::SetEstimate(int bitrate_bps, int64_t now_ms) {
updated_ = true;
bitrate_is_initialized_ = true;
- current_bitrate_bps_ = ChangeBitrate(bitrate_bps, bitrate_bps, now_ms);
+ current_bitrate_bps_ = ClampBitrate(bitrate_bps, bitrate_bps);
+ time_last_bitrate_change_ = now_ms;
}
int AimdRateControl::GetNearMaxIncreaseRateBps() const {
@@ -198,35 +199,31 @@ uint32_t AimdRateControl::ChangeBitrate(uint32_t current_bitrate_bps,
case kRcDecrease:
bitrate_is_initialized_ = true;
- if (incoming_bitrate_bps < min_configured_bitrate_bps_) {
- current_bitrate_bps = min_configured_bitrate_bps_;
- } else {
- // Set bit rate to something slightly lower than max
- // to get rid of any self-induced delay.
- current_bitrate_bps = static_cast<uint32_t>(beta_ *
- incoming_bitrate_bps + 0.5);
- if (current_bitrate_bps > current_bitrate_bps_) {
- // Avoid increasing the rate when over-using.
- if (rate_control_region_ != kRcMaxUnknown) {
- current_bitrate_bps = static_cast<uint32_t>(
- beta_ * avg_max_bitrate_kbps_ * 1000 + 0.5f);
- }
- current_bitrate_bps = std::min(current_bitrate_bps,
- current_bitrate_bps_);
- }
- ChangeRegion(kRcNearMax);
-
- if (incoming_bitrate_bps < current_bitrate_bps_) {
- last_decrease_ =
- rtc::Optional<int>(current_bitrate_bps_ - current_bitrate_bps);
- }
- if (incoming_bitrate_kbps < avg_max_bitrate_kbps_ -
- 3 * std_max_bit_rate) {
- avg_max_bitrate_kbps_ = -1.0f;
+ // Set bit rate to something slightly lower than max
+ // to get rid of any self-induced delay.
+ current_bitrate_bps =
terelius 2017/02/10 15:21:12 Maybe rename current_bitrate_bps to new_bitrate_bp
stefan-webrtc 2017/02/13 08:22:48 Yes, great suggestion
+ static_cast<uint32_t>(beta_ * incoming_bitrate_bps + 0.5);
+ if (current_bitrate_bps > current_bitrate_bps_) {
+ // Avoid increasing the rate when over-using.
+ if (rate_control_region_ != kRcMaxUnknown) {
+ current_bitrate_bps = static_cast<uint32_t>(
+ beta_ * avg_max_bitrate_kbps_ * 1000 + 0.5f);
}
+ current_bitrate_bps =
+ std::min(current_bitrate_bps, current_bitrate_bps_);
+ }
+ ChangeRegion(kRcNearMax);
- UpdateMaxBitRateEstimate(incoming_bitrate_kbps);
+ if (incoming_bitrate_bps < current_bitrate_bps_) {
+ last_decrease_ =
+ rtc::Optional<int>(current_bitrate_bps_ - current_bitrate_bps);
}
+ if (incoming_bitrate_kbps <
+ avg_max_bitrate_kbps_ - 3 * std_max_bit_rate) {
+ avg_max_bitrate_kbps_ = -1.0f;
+ }
+
+ UpdateMaxBitRateEstimate(incoming_bitrate_kbps);
// Stay on hold until the pipes are cleared.
ChangeState(kRcHold);
time_last_bitrate_change_ = now_ms;
@@ -235,17 +232,22 @@ uint32_t AimdRateControl::ChangeBitrate(uint32_t current_bitrate_bps,
default:
assert(false);
}
+ return ClampBitrate(current_bitrate_bps, incoming_bitrate_bps);
+}
+
+uint32_t AimdRateControl::ClampBitrate(uint32_t new_bitrate_bps,
+ uint32_t incoming_bitrate_bps) const {
// Don't change the bit rate if the send side is too far off.
// We allow a bit more lag at very low rates to not too easily get stuck if
// the encoder produces uneven outputs.
const uint32_t max_bitrate_bps =
static_cast<uint32_t>(1.5f * incoming_bitrate_bps) + 10000;
- if (current_bitrate_bps > current_bitrate_bps_ &&
- current_bitrate_bps > max_bitrate_bps) {
- current_bitrate_bps = std::max(current_bitrate_bps_, max_bitrate_bps);
- time_last_bitrate_change_ = now_ms;
+ if (new_bitrate_bps > current_bitrate_bps_ &&
+ new_bitrate_bps > max_bitrate_bps) {
+ new_bitrate_bps = std::max(current_bitrate_bps_, max_bitrate_bps);
}
- return current_bitrate_bps;
+ new_bitrate_bps = std::max(new_bitrate_bps, min_configured_bitrate_bps_);
+ return new_bitrate_bps;
}
uint32_t AimdRateControl::MultiplicativeRateIncrease(

Powered by Google App Engine
This is Rietveld 408576698