| 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 #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/remote_bitrate_estimat
or.h" |
| 19 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" | 21 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" |
| 20 | 22 |
| 21 namespace webrtc { | 23 namespace webrtc { |
| 22 | 24 |
| 23 static const int64_t kDefaultRttMs = 200; | 25 static const int64_t kDefaultRttMs = 200; |
| 24 static const int64_t kLogIntervalMs = 1000; | 26 static const int64_t kLogIntervalMs = 1000; |
| 25 static const double kWithinIncomingBitrateHysteresis = 1.05; | 27 static const double kWithinIncomingBitrateHysteresis = 1.05; |
| 26 static const int64_t kMaxFeedbackIntervalMs = 1000; | 28 static const int64_t kMaxFeedbackIntervalMs = 1000; |
| 27 | 29 |
| 28 AimdRateControl::AimdRateControl(uint32_t min_bitrate_bps) | 30 AimdRateControl::AimdRateControl() |
| 29 : min_configured_bitrate_bps_(min_bitrate_bps), | 31 : min_configured_bitrate_bps_( |
| 32 RemoteBitrateEstimator::kDefaultMinBitrateBps), |
| 30 max_configured_bitrate_bps_(30000000), | 33 max_configured_bitrate_bps_(30000000), |
| 31 current_bitrate_bps_(max_configured_bitrate_bps_), | 34 current_bitrate_bps_(max_configured_bitrate_bps_), |
| 32 avg_max_bitrate_kbps_(-1.0f), | 35 avg_max_bitrate_kbps_(-1.0f), |
| 33 var_max_bitrate_kbps_(0.4f), | 36 var_max_bitrate_kbps_(0.4f), |
| 34 rate_control_state_(kRcHold), | 37 rate_control_state_(kRcHold), |
| 35 rate_control_region_(kRcMaxUnknown), | 38 rate_control_region_(kRcMaxUnknown), |
| 36 time_last_bitrate_change_(-1), | 39 time_last_bitrate_change_(-1), |
| 37 current_input_(kBwNormal, 0, 1.0), | 40 current_input_(kBwNormal, 0, 1.0), |
| 38 updated_(false), | 41 updated_(false), |
| 39 time_first_incoming_estimate_(-1), | 42 time_first_incoming_estimate_(-1), |
| 40 bitrate_is_initialized_(false), | 43 bitrate_is_initialized_(false), |
| 41 beta_(0.85f), | 44 beta_(0.85f), |
| 42 rtt_(kDefaultRttMs), | 45 rtt_(kDefaultRttMs), |
| 43 time_of_last_log_(-1), | 46 time_of_last_log_(-1), |
| 44 in_experiment_(AdaptiveThresholdExperimentIsEnabled()) { | 47 in_experiment_(AdaptiveThresholdExperimentIsEnabled()) {} |
| 45 } | |
| 46 | 48 |
| 47 uint32_t AimdRateControl::GetMinBitrate() const { | 49 void AimdRateControl::SetMinBitrate(int min_bitrate_bps) { |
| 48 return min_configured_bitrate_bps_; | 50 min_configured_bitrate_bps_ = min_bitrate_bps; |
| 51 current_bitrate_bps_ = std::max<int>(min_bitrate_bps, current_bitrate_bps_); |
| 49 } | 52 } |
| 50 | 53 |
| 51 bool AimdRateControl::ValidEstimate() const { | 54 bool AimdRateControl::ValidEstimate() const { |
| 52 return bitrate_is_initialized_; | 55 return bitrate_is_initialized_; |
| 53 } | 56 } |
| 54 | 57 |
| 55 int64_t AimdRateControl::GetFeedbackInterval() const { | 58 int64_t AimdRateControl::GetFeedbackInterval() const { |
| 56 // Estimate how often we can send RTCP if we allocate up to 5% of bandwidth | 59 // Estimate how often we can send RTCP if we allocate up to 5% of bandwidth |
| 57 // to feedback. | 60 // to feedback. |
| 58 static const int kRtcpSize = 80; | 61 static const int kRtcpSize = 80; |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 } | 305 } |
| 303 | 306 |
| 304 void AimdRateControl::ChangeRegion(RateControlRegion region) { | 307 void AimdRateControl::ChangeRegion(RateControlRegion region) { |
| 305 rate_control_region_ = region; | 308 rate_control_region_ = region; |
| 306 } | 309 } |
| 307 | 310 |
| 308 void AimdRateControl::ChangeState(RateControlState new_state) { | 311 void AimdRateControl::ChangeState(RateControlState new_state) { |
| 309 rate_control_state_ = new_state; | 312 rate_control_state_ = new_state; |
| 310 } | 313 } |
| 311 } // namespace webrtc | 314 } // namespace webrtc |
| OLD | NEW |