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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 new_bitrate_bps = std::max(current_bitrate_bps_, max_bitrate_bps); | 231 new_bitrate_bps = std::max(current_bitrate_bps_, max_bitrate_bps); |
231 } | 232 } |
232 new_bitrate_bps = std::max(new_bitrate_bps, min_configured_bitrate_bps_); | 233 new_bitrate_bps = std::max(new_bitrate_bps, min_configured_bitrate_bps_); |
233 return new_bitrate_bps; | 234 return new_bitrate_bps; |
234 } | 235 } |
235 | 236 |
236 uint32_t AimdRateControl::MultiplicativeRateIncrease( | 237 uint32_t AimdRateControl::MultiplicativeRateIncrease( |
237 int64_t now_ms, int64_t last_ms, uint32_t current_bitrate_bps) const { | 238 int64_t now_ms, int64_t last_ms, uint32_t current_bitrate_bps) const { |
238 double alpha = 1.08; | 239 double alpha = 1.08; |
239 if (last_ms > -1) { | 240 if (last_ms > -1) { |
240 int time_since_last_update_ms = std::min(static_cast<int>(now_ms - last_ms), | 241 auto time_since_last_update_ms = |
241 1000); | 242 rtc::SafeMin<double>(now_ms - last_ms, 1000); |
242 alpha = pow(alpha, time_since_last_update_ms / 1000.0); | 243 alpha = pow(alpha, time_since_last_update_ms / 1000.0); |
243 } | 244 } |
244 uint32_t multiplicative_increase_bps = std::max( | 245 uint32_t multiplicative_increase_bps = std::max( |
245 current_bitrate_bps * (alpha - 1.0), 1000.0); | 246 current_bitrate_bps * (alpha - 1.0), 1000.0); |
246 return multiplicative_increase_bps; | 247 return multiplicative_increase_bps; |
247 } | 248 } |
248 | 249 |
249 uint32_t AimdRateControl::AdditiveRateIncrease(int64_t now_ms, | 250 uint32_t AimdRateControl::AdditiveRateIncrease(int64_t now_ms, |
250 int64_t last_ms) const { | 251 int64_t last_ms) const { |
251 return static_cast<uint32_t>((now_ms - last_ms) * | 252 return static_cast<uint32_t>((now_ms - last_ms) * |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 default: | 297 default: |
297 assert(false); | 298 assert(false); |
298 } | 299 } |
299 } | 300 } |
300 | 301 |
301 void AimdRateControl::ChangeRegion(RateControlRegion region) { | 302 void AimdRateControl::ChangeRegion(RateControlRegion region) { |
302 rate_control_region_ = region; | 303 rate_control_region_ = region; |
303 } | 304 } |
304 | 305 |
305 } // namespace webrtc | 306 } // namespace webrtc |
OLD | NEW |