Chromium Code Reviews| 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 f83cddc617862b56ca50131895e97921084178b2..38a31be4eed647179328a7994c8aad839595feae 100644 |
| --- a/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc |
| +++ b/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc |
| @@ -130,6 +130,14 @@ void AimdRateControl::SetEstimate(int bitrate_bps, int64_t now_ms) { |
| current_bitrate_bps_ = ChangeBitrate(bitrate_bps, bitrate_bps, now_ms); |
| } |
| +rtc::Optional<int> AimdRateControl::GetNearMaxIncreaseRate() const { |
| + return near_max_increase_rate_bps_; |
| +} |
| + |
| +rtc::Optional<int> AimdRateControl::GetLastDecrease() const { |
| + return last_decrease_; |
| +} |
| + |
| uint32_t AimdRateControl::ChangeBitrate(uint32_t current_bitrate_bps, |
| uint32_t incoming_bitrate_bps, |
| int64_t now_ms) { |
| @@ -165,9 +173,15 @@ uint32_t AimdRateControl::ChangeBitrate(uint32_t current_bitrate_bps, |
| const int64_t response_time = rtt_ + 100; |
| uint32_t additive_increase_bps = AdditiveRateIncrease( |
| now_ms, time_last_bitrate_change_, response_time); |
| + if (last_near_max_increase_rate_update_) { |
| + near_max_increase_rate_bps_ = rtc::Optional<int>( |
| + additive_increase_bps * 1000.0 / |
| + (now_ms - *last_near_max_increase_rate_update_)); |
|
stefan-webrtc
2016/10/26 14:30:06
An alternative to this would be to do something li
michaelt
2016/10/31 11:10:22
I taught a little what would be the best solution.
|
| + } |
| current_bitrate_bps += additive_increase_bps; |
| - |
| + last_near_max_increase_rate_update_ = rtc::Optional<int64_t>(now_ms); |
| } else { |
| + last_near_max_increase_rate_update_ = rtc::Optional<int64_t>(); |
| uint32_t multiplicative_increase_bps = MultiplicativeRateIncrease( |
| now_ms, time_last_bitrate_change_, current_bitrate_bps); |
| current_bitrate_bps += multiplicative_increase_bps; |
| @@ -177,6 +191,7 @@ uint32_t AimdRateControl::ChangeBitrate(uint32_t current_bitrate_bps, |
| break; |
| case kRcDecrease: |
| + last_near_max_increase_rate_update_ = rtc::Optional<int64_t>(); |
| bitrate_is_initialized_ = true; |
| if (incoming_bitrate_bps < min_configured_bitrate_bps_) { |
| current_bitrate_bps = min_configured_bitrate_bps_; |
| @@ -196,6 +211,9 @@ uint32_t AimdRateControl::ChangeBitrate(uint32_t 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; |