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/modules/remote_bitrate_estimator/test/bwe_test_logging.h" | 17 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" |
18 | 18 |
19 namespace webrtc { | 19 namespace webrtc { |
20 | 20 |
21 static const int64_t kDefaultRttMs = 200; | 21 static const int64_t kDefaultRttMs = 200; |
22 static const int64_t kLogIntervalMs = 1000; | 22 static const int64_t kLogIntervalMs = 1000; |
23 static const double kWithinIncomingBitrateHysteresis = 1.05; | 23 static const double kWithinIncomingBitrateHysteresis = 1.05; |
| 24 static const int64_t kMaxFeedbackIntervalMs = 1000; |
24 | 25 |
25 AimdRateControl::AimdRateControl(uint32_t min_bitrate_bps) | 26 AimdRateControl::AimdRateControl(uint32_t min_bitrate_bps) |
26 : min_configured_bitrate_bps_(min_bitrate_bps), | 27 : min_configured_bitrate_bps_(min_bitrate_bps), |
27 max_configured_bitrate_bps_(30000000), | 28 max_configured_bitrate_bps_(30000000), |
28 current_bitrate_bps_(max_configured_bitrate_bps_), | 29 current_bitrate_bps_(max_configured_bitrate_bps_), |
29 max_hold_rate_bps_(0), | 30 max_hold_rate_bps_(0), |
30 avg_max_bitrate_kbps_(-1.0f), | 31 avg_max_bitrate_kbps_(-1.0f), |
31 var_max_bitrate_kbps_(0.4f), | 32 var_max_bitrate_kbps_(0.4f), |
32 rate_control_state_(kRcHold), | 33 rate_control_state_(kRcHold), |
33 came_from_state_(kRcDecrease), | 34 came_from_state_(kRcDecrease), |
34 rate_control_region_(kRcMaxUnknown), | 35 rate_control_region_(kRcMaxUnknown), |
35 time_last_bitrate_change_(-1), | 36 time_last_bitrate_change_(-1), |
36 current_input_(kBwNormal, 0, 1.0), | 37 current_input_(kBwNormal, 0, 1.0), |
37 updated_(false), | 38 updated_(false), |
38 time_first_incoming_estimate_(-1), | 39 time_first_incoming_estimate_(-1), |
39 bitrate_is_initialized_(false), | 40 bitrate_is_initialized_(false), |
40 beta_(0.9f), | 41 beta_(0.9f), |
41 rtt_(kDefaultRttMs), | 42 rtt_(kDefaultRttMs), |
42 time_of_last_log_(-1) {} | 43 time_of_last_log_(-1) {} |
43 | 44 |
44 RateControlType AimdRateControl::GetControlType() const { | |
45 return kAimdControl; | |
46 } | |
47 | |
48 uint32_t AimdRateControl::GetMinBitrate() const { | 45 uint32_t AimdRateControl::GetMinBitrate() const { |
49 return min_configured_bitrate_bps_; | 46 return min_configured_bitrate_bps_; |
50 } | 47 } |
51 | 48 |
52 bool AimdRateControl::ValidEstimate() const { | 49 bool AimdRateControl::ValidEstimate() const { |
53 return bitrate_is_initialized_; | 50 return bitrate_is_initialized_; |
54 } | 51 } |
55 | 52 |
56 int64_t AimdRateControl::GetFeedbackInterval() const { | 53 int64_t AimdRateControl::GetFeedbackInterval() const { |
57 // Estimate how often we can send RTCP if we allocate up to 5% of bandwidth | 54 // Estimate how often we can send RTCP if we allocate up to 5% of bandwidth |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 default: | 319 default: |
323 assert(false); | 320 assert(false); |
324 } | 321 } |
325 } | 322 } |
326 | 323 |
327 void AimdRateControl::ChangeState(RateControlState new_state) { | 324 void AimdRateControl::ChangeState(RateControlState new_state) { |
328 came_from_state_ = rate_control_state_; | 325 came_from_state_ = rate_control_state_; |
329 rate_control_state_ = new_state; | 326 rate_control_state_ = new_state; |
330 } | 327 } |
331 } // namespace webrtc | 328 } // namespace webrtc |
OLD | NEW |