| 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 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 void SetStartBitrate(int start_bitrate_bps); | 32 void SetStartBitrate(int start_bitrate_bps); |
| 33 void SetMinBitrate(int min_bitrate_bps); | 33 void SetMinBitrate(int min_bitrate_bps); |
| 34 int64_t GetFeedbackInterval() const; | 34 int64_t GetFeedbackInterval() const; |
| 35 // Returns true if the bitrate estimate hasn't been changed for more than | 35 // Returns true if the bitrate estimate hasn't been changed for more than |
| 36 // an RTT, or if the incoming_bitrate is less than half of the current | 36 // an RTT, or if the incoming_bitrate is less than half of the current |
| 37 // estimate. Should be used to decide if we should reduce the rate further | 37 // estimate. Should be used to decide if we should reduce the rate further |
| 38 // when over-using. | 38 // when over-using. |
| 39 bool TimeToReduceFurther(int64_t time_now, | 39 bool TimeToReduceFurther(int64_t time_now, |
| 40 uint32_t incoming_bitrate_bps) const; | 40 uint32_t incoming_bitrate_bps) const; |
| 41 uint32_t LatestEstimate() const; | 41 uint32_t LatestEstimate() const; |
| 42 uint32_t UpdateBandwidthEstimate(int64_t now_ms); | |
| 43 void SetRtt(int64_t rtt); | 42 void SetRtt(int64_t rtt); |
| 44 void Update(const RateControlInput* input, int64_t now_ms); | 43 uint32_t Update(const RateControlInput* input, int64_t now_ms); |
| 45 void SetEstimate(int bitrate_bps, int64_t now_ms); | 44 void SetEstimate(int bitrate_bps, int64_t now_ms); |
| 46 | 45 |
| 47 // Returns the increase rate which is used when used bandwidth is near the | 46 // Returns the increase rate which is used when used bandwidth is near the |
| 48 // maximal available bandwidth. | 47 // maximal available bandwidth. |
| 49 virtual int GetNearMaxIncreaseRateBps() const; | 48 virtual int GetNearMaxIncreaseRateBps() const; |
| 50 | 49 |
| 51 virtual rtc::Optional<int> GetLastBitrateDecreaseBps() const; | 50 virtual rtc::Optional<int> GetLastBitrateDecreaseBps() const; |
| 52 | 51 |
| 53 private: | 52 private: |
| 54 // Update the target bitrate according based on, among other things, | 53 // Update the target bitrate according based on, among other things, |
| 55 // the current rate control state, the current target bitrate and the incoming | 54 // the current rate control state, the current target bitrate and the incoming |
| 56 // bitrate. When in the "increase" state the bitrate will be increased either | 55 // bitrate. When in the "increase" state the bitrate will be increased either |
| 57 // additively or multiplicatively depending on the rate control region. When | 56 // additively or multiplicatively depending on the rate control region. When |
| 58 // in the "decrease" state the bitrate will be decreased to slightly below the | 57 // in the "decrease" state the bitrate will be decreased to slightly below the |
| 59 // incoming bitrate. When in the "hold" state the bitrate will be kept | 58 // incoming bitrate. When in the "hold" state the bitrate will be kept |
| 60 // constant to allow built up queues to drain. | 59 // constant to allow built up queues to drain. |
| 61 uint32_t ChangeBitrate(uint32_t current_bitrate, | 60 uint32_t ChangeBitrate(uint32_t current_bitrate, |
| 62 uint32_t incoming_bitrate, | 61 const RateControlInput& input, |
| 63 int64_t now_ms); | 62 int64_t now_ms); |
| 64 // Clamps new_bitrate_bps to within the configured min bitrate and a linear | 63 // Clamps new_bitrate_bps to within the configured min bitrate and a linear |
| 65 // function of the incoming bitrate, so that the new bitrate can't grow too | 64 // function of the incoming bitrate, so that the new bitrate can't grow too |
| 66 // large compared to the bitrate actually being received by the other end. | 65 // large compared to the bitrate actually being received by the other end. |
| 67 uint32_t ClampBitrate(uint32_t new_bitrate_bps, | 66 uint32_t ClampBitrate(uint32_t new_bitrate_bps, |
| 68 uint32_t incoming_bitrate_bps) const; | 67 uint32_t incoming_bitrate_bps) const; |
| 69 uint32_t MultiplicativeRateIncrease(int64_t now_ms, int64_t last_ms, | 68 uint32_t MultiplicativeRateIncrease(int64_t now_ms, int64_t last_ms, |
| 70 uint32_t current_bitrate_bps) const; | 69 uint32_t current_bitrate_bps) const; |
| 71 uint32_t AdditiveRateIncrease(int64_t now_ms, int64_t last_ms) const; | 70 uint32_t AdditiveRateIncrease(int64_t now_ms, int64_t last_ms) const; |
| 72 void UpdateChangePeriod(int64_t now_ms); | 71 void UpdateChangePeriod(int64_t now_ms); |
| 73 void UpdateMaxBitRateEstimate(float incoming_bit_rate_kbps); | 72 void UpdateMaxBitRateEstimate(float incoming_bit_rate_kbps); |
| 74 void ChangeState(const RateControlInput& input, int64_t now_ms); | 73 void ChangeState(const RateControlInput& input, int64_t now_ms); |
| 75 void ChangeState(RateControlState new_state); | |
| 76 void ChangeRegion(RateControlRegion region); | 74 void ChangeRegion(RateControlRegion region); |
| 77 | 75 |
| 78 uint32_t min_configured_bitrate_bps_; | 76 uint32_t min_configured_bitrate_bps_; |
| 79 uint32_t max_configured_bitrate_bps_; | 77 uint32_t max_configured_bitrate_bps_; |
| 80 uint32_t current_bitrate_bps_; | 78 uint32_t current_bitrate_bps_; |
| 81 float avg_max_bitrate_kbps_; | 79 float avg_max_bitrate_kbps_; |
| 82 float var_max_bitrate_kbps_; | 80 float var_max_bitrate_kbps_; |
| 83 RateControlState rate_control_state_; | 81 RateControlState rate_control_state_; |
| 84 RateControlRegion rate_control_region_; | 82 RateControlRegion rate_control_region_; |
| 85 int64_t time_last_bitrate_change_; | 83 int64_t time_last_bitrate_change_; |
| 86 RateControlInput current_input_; | |
| 87 bool updated_; | |
| 88 int64_t time_first_incoming_estimate_; | 84 int64_t time_first_incoming_estimate_; |
| 89 bool bitrate_is_initialized_; | 85 bool bitrate_is_initialized_; |
| 90 float beta_; | 86 float beta_; |
| 91 int64_t rtt_; | 87 int64_t rtt_; |
| 92 bool in_experiment_; | 88 bool in_experiment_; |
| 93 rtc::Optional<int> last_decrease_; | 89 rtc::Optional<int> last_decrease_; |
| 94 }; | 90 }; |
| 95 } // namespace webrtc | 91 } // namespace webrtc |
| 96 | 92 |
| 97 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_AIMD_RATE_CONTROL_H_ | 93 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_AIMD_RATE_CONTROL_H_ |
| OLD | NEW |