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 #ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_AIMD_RATE_CONTROL_H_ | 11 #ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_AIMD_RATE_CONTROL_H_ |
12 #define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_AIMD_RATE_CONTROL_H_ | 12 #define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_AIMD_RATE_CONTROL_H_ |
13 | 13 |
| 14 #include "webrtc/base/constructormagic.h" |
14 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" | 15 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" |
15 #include "webrtc/modules/remote_bitrate_estimator/remote_rate_control.h" | |
16 | 16 |
17 namespace webrtc { | 17 namespace webrtc { |
18 | 18 |
19 // A RemoteRateControl implementation based on additive increases of | 19 // A RemoteRateControl implementation based on additive increases of |
20 // bitrate when no over-use is detected and multiplicative decreases when | 20 // bitrate when no over-use is detected and multiplicative decreases when |
21 // over-uses are detected. When we think the available bandwidth has changes or | 21 // over-uses are detected. When we think the available bandwidth has changes or |
22 // is unknown, we will switch to a "slow-start mode" where we increase | 22 // is unknown, we will switch to a "slow-start mode" where we increase |
23 // multiplicatively. | 23 // multiplicatively. |
24 class AimdRateControl : public RemoteRateControl { | 24 class AimdRateControl { |
25 public: | 25 public: |
26 explicit AimdRateControl(uint32_t min_bitrate_bps); | 26 explicit AimdRateControl(uint32_t min_bitrate_bps); |
27 virtual ~AimdRateControl() {} | 27 virtual ~AimdRateControl() {} |
28 | 28 |
29 // Implements RemoteRateControl. | 29 // Implements RemoteRateControl. |
30 bool ValidEstimate() const override; | 30 bool ValidEstimate() const; |
31 RateControlType GetControlType() const override; | 31 uint32_t GetMinBitrate() const; |
32 uint32_t GetMinBitrate() const override; | 32 int64_t GetFeedbackInterval() const; |
33 int64_t GetFeedbackInterval() const override; | |
34 // Returns true if the bitrate estimate hasn't been changed for more than | 33 // Returns true if the bitrate estimate hasn't been changed for more than |
35 // an RTT, or if the incoming_bitrate is more than 5% above the current | 34 // an RTT, or if the incoming_bitrate is more than 5% above the current |
36 // estimate. Should be used to decide if we should reduce the rate further | 35 // estimate. Should be used to decide if we should reduce the rate further |
37 // when over-using. | 36 // when over-using. |
38 bool TimeToReduceFurther(int64_t time_now, | 37 bool TimeToReduceFurther(int64_t time_now, |
39 uint32_t incoming_bitrate_bps) const override; | 38 uint32_t incoming_bitrate_bps) const; |
40 uint32_t LatestEstimate() const override; | 39 uint32_t LatestEstimate() const; |
41 uint32_t UpdateBandwidthEstimate(int64_t now_ms) override; | 40 uint32_t UpdateBandwidthEstimate(int64_t now_ms); |
42 void SetRtt(int64_t rtt) override; | 41 void SetRtt(int64_t rtt); |
43 RateControlRegion Update(const RateControlInput* input, | 42 RateControlRegion Update(const RateControlInput* input, int64_t now_ms); |
44 int64_t now_ms) override; | 43 void SetEstimate(int bitrate_bps, int64_t now_ms); |
45 void SetEstimate(int bitrate_bps, int64_t now_ms) override; | |
46 | 44 |
47 private: | 45 private: |
48 // Update the target bitrate according based on, among other things, | 46 // Update the target bitrate according based on, among other things, |
49 // the current rate control state, the current target bitrate and the incoming | 47 // the current rate control state, the current target bitrate and the incoming |
50 // bitrate. When in the "increase" state the bitrate will be increased either | 48 // bitrate. When in the "increase" state the bitrate will be increased either |
51 // additively or multiplicatively depending on the rate control region. When | 49 // additively or multiplicatively depending on the rate control region. When |
52 // in the "decrease" state the bitrate will be decreased to slightly below the | 50 // in the "decrease" state the bitrate will be decreased to slightly below the |
53 // incoming bitrate. When in the "hold" state the bitrate will be kept | 51 // incoming bitrate. When in the "hold" state the bitrate will be kept |
54 // constant to allow built up queues to drain. | 52 // constant to allow built up queues to drain. |
55 uint32_t ChangeBitrate(uint32_t current_bit_rate, | 53 uint32_t ChangeBitrate(uint32_t current_bit_rate, |
(...skipping 25 matching lines...) Expand all Loading... |
81 bool bitrate_is_initialized_; | 79 bool bitrate_is_initialized_; |
82 float beta_; | 80 float beta_; |
83 int64_t rtt_; | 81 int64_t rtt_; |
84 int64_t time_of_last_log_; | 82 int64_t time_of_last_log_; |
85 | 83 |
86 DISALLOW_IMPLICIT_CONSTRUCTORS(AimdRateControl); | 84 DISALLOW_IMPLICIT_CONSTRUCTORS(AimdRateControl); |
87 }; | 85 }; |
88 } // namespace webrtc | 86 } // namespace webrtc |
89 | 87 |
90 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_AIMD_RATE_CONTROL_H_ | 88 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_AIMD_RATE_CONTROL_H_ |
OLD | NEW |