Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h" | 11 #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h" |
| 12 | 12 |
| 13 #include <algorithm> | 13 #include <algorithm> |
| 14 #include <cassert> | 14 #include <cassert> |
| 15 #include <cmath> | 15 #include <cmath> |
| 16 | 16 |
| 17 #include "webrtc/base/checks.h" | 17 #include "webrtc/base/checks.h" |
| 18 | 18 |
| 19 #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h" | 19 #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h" |
| 20 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" | 20 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" |
| 21 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat or.h" | 21 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat or.h" |
| 22 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" | 22 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" |
| 23 | 23 |
| 24 namespace webrtc { | 24 namespace webrtc { |
| 25 | 25 |
| 26 static const int64_t kDefaultRttMs = 200; | 26 static const int64_t kDefaultRttMs = 200; |
| 27 static const double kWithinIncomingBitrateHysteresis = 1.05; | |
| 28 static const int64_t kMaxFeedbackIntervalMs = 1000; | 27 static const int64_t kMaxFeedbackIntervalMs = 1000; |
| 29 | 28 |
| 30 AimdRateControl::AimdRateControl() | 29 AimdRateControl::AimdRateControl() |
| 31 : min_configured_bitrate_bps_(congestion_controller::GetMinBitrateBps()), | 30 : min_configured_bitrate_bps_(congestion_controller::GetMinBitrateBps()), |
| 32 max_configured_bitrate_bps_(30000000), | 31 max_configured_bitrate_bps_(30000000), |
| 33 current_bitrate_bps_(max_configured_bitrate_bps_), | 32 current_bitrate_bps_(max_configured_bitrate_bps_), |
| 34 avg_max_bitrate_kbps_(-1.0f), | 33 avg_max_bitrate_kbps_(-1.0f), |
| 35 var_max_bitrate_kbps_(0.4f), | 34 var_max_bitrate_kbps_(0.4f), |
| 36 rate_control_state_(kRcHold), | 35 rate_control_state_(kRcHold), |
| 37 rate_control_region_(kRcMaxUnknown), | 36 rate_control_region_(kRcMaxUnknown), |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 65 } | 64 } |
| 66 | 65 |
| 67 bool AimdRateControl::TimeToReduceFurther(int64_t time_now, | 66 bool AimdRateControl::TimeToReduceFurther(int64_t time_now, |
| 68 uint32_t incoming_bitrate_bps) const { | 67 uint32_t incoming_bitrate_bps) const { |
| 69 const int64_t bitrate_reduction_interval = | 68 const int64_t bitrate_reduction_interval = |
| 70 std::max<int64_t>(std::min<int64_t>(rtt_, 200), 10); | 69 std::max<int64_t>(std::min<int64_t>(rtt_, 200), 10); |
| 71 if (time_now - time_last_bitrate_change_ >= bitrate_reduction_interval) { | 70 if (time_now - time_last_bitrate_change_ >= bitrate_reduction_interval) { |
| 72 return true; | 71 return true; |
| 73 } | 72 } |
| 74 if (ValidEstimate()) { | 73 if (ValidEstimate()) { |
| 75 const int threshold = static_cast<int>(kWithinIncomingBitrateHysteresis * | 74 // TODO(terelius/holmer): Investigate consequences of increasing |
| 76 incoming_bitrate_bps); | 75 // the threshold to 0.95 * LatestEstimate(). |
| 77 const int bitrate_difference = LatestEstimate() - incoming_bitrate_bps; | 76 const uint32_t threshold = static_cast<uint32_t> (0.5 * LatestEstimate()); |
|
stefan-webrtc
2016/12/02 09:15:38
remove space between > and (
| |
| 78 return bitrate_difference > threshold; | 77 return incoming_bitrate_bps < threshold; |
| 79 } | 78 } |
| 80 return false; | 79 return false; |
| 81 } | 80 } |
| 82 | 81 |
| 83 uint32_t AimdRateControl::LatestEstimate() const { | 82 uint32_t AimdRateControl::LatestEstimate() const { |
| 84 return current_bitrate_bps_; | 83 return current_bitrate_bps_; |
| 85 } | 84 } |
| 86 | 85 |
| 87 uint32_t AimdRateControl::UpdateBandwidthEstimate(int64_t now_ms) { | 86 uint32_t AimdRateControl::UpdateBandwidthEstimate(int64_t now_ms) { |
| 88 current_bitrate_bps_ = ChangeBitrate( | 87 current_bitrate_bps_ = ChangeBitrate( |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 } | 304 } |
| 306 | 305 |
| 307 void AimdRateControl::ChangeRegion(RateControlRegion region) { | 306 void AimdRateControl::ChangeRegion(RateControlRegion region) { |
| 308 rate_control_region_ = region; | 307 rate_control_region_ = region; |
| 309 } | 308 } |
| 310 | 309 |
| 311 void AimdRateControl::ChangeState(RateControlState new_state) { | 310 void AimdRateControl::ChangeState(RateControlState new_state) { |
| 312 rate_control_state_ = new_state; | 311 rate_control_state_ = new_state; |
| 313 } | 312 } |
| 314 } // namespace webrtc | 313 } // namespace webrtc |
| OLD | NEW |