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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 double avg_packet_size_bits = bits_per_frame / packets_per_frame; | 129 double avg_packet_size_bits = bits_per_frame / packets_per_frame; |
130 | 130 |
131 // Approximate the over-use estimator delay to 100 ms. | 131 // Approximate the over-use estimator delay to 100 ms. |
132 const int64_t response_time = in_experiment_ ? (rtt_ + 100) * 2 : rtt_ + 100; | 132 const int64_t response_time = in_experiment_ ? (rtt_ + 100) * 2 : rtt_ + 100; |
133 constexpr double kMinIncreaseRateBps = 4000; | 133 constexpr double kMinIncreaseRateBps = 4000; |
134 return static_cast<int>(std::max( | 134 return static_cast<int>(std::max( |
135 kMinIncreaseRateBps, (avg_packet_size_bits * 1000) / response_time)); | 135 kMinIncreaseRateBps, (avg_packet_size_bits * 1000) / response_time)); |
136 } | 136 } |
137 | 137 |
138 int AimdRateControl::GetExpectedBandwidthPeriodMs() const { | 138 int AimdRateControl::GetExpectedBandwidthPeriodMs() const { |
139 constexpr int kMinPeriodMs = 500; | 139 constexpr int kMinPeriodMs = 2000; |
| 140 constexpr int kDefaultPeriodMs = 3000; |
140 constexpr int kMaxPeriodMs = 50000; | 141 constexpr int kMaxPeriodMs = 50000; |
141 | 142 |
142 int increase_rate = GetNearMaxIncreaseRateBps(); | 143 int increase_rate = GetNearMaxIncreaseRateBps(); |
143 if (!last_decrease_) | 144 if (!last_decrease_) |
144 return kMinPeriodMs; | 145 return kDefaultPeriodMs; |
145 | 146 |
146 return std::min(kMaxPeriodMs, | 147 return std::min(kMaxPeriodMs, |
147 std::max<int>(1000 * static_cast<int64_t>(*last_decrease_) / | 148 std::max<int>(1000 * static_cast<int64_t>(*last_decrease_) / |
148 increase_rate, | 149 increase_rate, |
149 kMinPeriodMs)); | 150 kMinPeriodMs)); |
150 } | 151 } |
151 | 152 |
152 uint32_t AimdRateControl::ChangeBitrate(uint32_t new_bitrate_bps, | 153 uint32_t AimdRateControl::ChangeBitrate(uint32_t new_bitrate_bps, |
153 const RateControlInput& input, | 154 const RateControlInput& input, |
154 int64_t now_ms) { | 155 int64_t now_ms) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 if (rate_control_region_ != kRcMaxUnknown) { | 204 if (rate_control_region_ != kRcMaxUnknown) { |
204 new_bitrate_bps = static_cast<uint32_t>( | 205 new_bitrate_bps = static_cast<uint32_t>( |
205 beta_ * avg_max_bitrate_kbps_ * 1000 + 0.5f); | 206 beta_ * avg_max_bitrate_kbps_ * 1000 + 0.5f); |
206 } | 207 } |
207 new_bitrate_bps = std::min(new_bitrate_bps, current_bitrate_bps_); | 208 new_bitrate_bps = std::min(new_bitrate_bps, current_bitrate_bps_); |
208 } | 209 } |
209 ChangeRegion(kRcNearMax); | 210 ChangeRegion(kRcNearMax); |
210 | 211 |
211 if (bitrate_is_initialized_ && | 212 if (bitrate_is_initialized_ && |
212 incoming_bitrate_bps < current_bitrate_bps_) { | 213 incoming_bitrate_bps < current_bitrate_bps_) { |
213 constexpr float kDegradationFactor = 0.9f; | 214 last_decrease_ = |
214 if (new_bitrate_bps < | 215 rtc::Optional<int>(current_bitrate_bps_ - new_bitrate_bps); |
215 kDegradationFactor * beta_ * current_bitrate_bps_) { | |
216 // If bitrate decreases more than a normal back off after overuse, it | |
217 // indicates a real network degradation. We do not let such a decrease | |
218 // to determine the bandwidth estimation period. | |
219 last_decrease_ = rtc::Optional<int>(); | |
220 } else { | |
221 last_decrease_ = rtc::Optional<int>( | |
222 current_bitrate_bps_ - new_bitrate_bps); | |
223 } | |
224 } | 216 } |
225 if (incoming_bitrate_kbps < | 217 if (incoming_bitrate_kbps < |
226 avg_max_bitrate_kbps_ - 3 * std_max_bit_rate) { | 218 avg_max_bitrate_kbps_ - 3 * std_max_bit_rate) { |
227 avg_max_bitrate_kbps_ = -1.0f; | 219 avg_max_bitrate_kbps_ = -1.0f; |
228 } | 220 } |
229 | 221 |
230 bitrate_is_initialized_ = true; | 222 bitrate_is_initialized_ = true; |
231 UpdateMaxBitRateEstimate(incoming_bitrate_kbps); | 223 UpdateMaxBitRateEstimate(incoming_bitrate_kbps); |
232 // Stay on hold until the pipes are cleared. | 224 // Stay on hold until the pipes are cleared. |
233 rate_control_state_ = kRcHold; | 225 rate_control_state_ = kRcHold; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 default: | 310 default: |
319 assert(false); | 311 assert(false); |
320 } | 312 } |
321 } | 313 } |
322 | 314 |
323 void AimdRateControl::ChangeRegion(RateControlRegion region) { | 315 void AimdRateControl::ChangeRegion(RateControlRegion region) { |
324 rate_control_region_ = region; | 316 rate_control_region_ = region; |
325 } | 317 } |
326 | 318 |
327 } // namespace webrtc | 319 } // namespace webrtc |
OLD | NEW |