| 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 #include "webrtc/base/safe_minmax.h" |
| 18 | 19 |
| 19 #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h" | 20 #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h" |
| 20 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" | 21 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" |
| 21 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.h" | 22 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.h" |
| 22 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" | 23 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" |
| 23 | 24 |
| 24 namespace webrtc { | 25 namespace webrtc { |
| 25 | 26 |
| 26 static const int64_t kDefaultRttMs = 200; | 27 static const int64_t kDefaultRttMs = 200; |
| 27 static const int64_t kMaxFeedbackIntervalMs = 1000; | 28 static const int64_t kMaxFeedbackIntervalMs = 1000; |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 new_bitrate_bps = std::max(current_bitrate_bps_, max_bitrate_bps); | 232 new_bitrate_bps = std::max(current_bitrate_bps_, max_bitrate_bps); |
| 232 } | 233 } |
| 233 new_bitrate_bps = std::max(new_bitrate_bps, min_configured_bitrate_bps_); | 234 new_bitrate_bps = std::max(new_bitrate_bps, min_configured_bitrate_bps_); |
| 234 return new_bitrate_bps; | 235 return new_bitrate_bps; |
| 235 } | 236 } |
| 236 | 237 |
| 237 uint32_t AimdRateControl::MultiplicativeRateIncrease( | 238 uint32_t AimdRateControl::MultiplicativeRateIncrease( |
| 238 int64_t now_ms, int64_t last_ms, uint32_t current_bitrate_bps) const { | 239 int64_t now_ms, int64_t last_ms, uint32_t current_bitrate_bps) const { |
| 239 double alpha = 1.08; | 240 double alpha = 1.08; |
| 240 if (last_ms > -1) { | 241 if (last_ms > -1) { |
| 241 int time_since_last_update_ms = std::min(static_cast<int>(now_ms - last_ms), | 242 auto time_since_last_update_ms = |
| 242 1000); | 243 rtc::SafeMin<int64_t>(now_ms - last_ms, 1000); |
| 243 alpha = pow(alpha, time_since_last_update_ms / 1000.0); | 244 alpha = pow(alpha, time_since_last_update_ms / 1000.0); |
| 244 } | 245 } |
| 245 uint32_t multiplicative_increase_bps = std::max( | 246 uint32_t multiplicative_increase_bps = std::max( |
| 246 current_bitrate_bps * (alpha - 1.0), 1000.0); | 247 current_bitrate_bps * (alpha - 1.0), 1000.0); |
| 247 return multiplicative_increase_bps; | 248 return multiplicative_increase_bps; |
| 248 } | 249 } |
| 249 | 250 |
| 250 uint32_t AimdRateControl::AdditiveRateIncrease(int64_t now_ms, | 251 uint32_t AimdRateControl::AdditiveRateIncrease(int64_t now_ms, |
| 251 int64_t last_ms) const { | 252 int64_t last_ms) const { |
| 252 return static_cast<uint32_t>((now_ms - last_ms) * | 253 return static_cast<uint32_t>((now_ms - last_ms) * |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 default: | 298 default: |
| 298 assert(false); | 299 assert(false); |
| 299 } | 300 } |
| 300 } | 301 } |
| 301 | 302 |
| 302 void AimdRateControl::ChangeRegion(RateControlRegion region) { | 303 void AimdRateControl::ChangeRegion(RateControlRegion region) { |
| 303 rate_control_region_ = region; | 304 rate_control_region_ = region; |
| 304 } | 305 } |
| 305 | 306 |
| 306 } // namespace webrtc | 307 } // namespace webrtc |
| OLD | NEW |