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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 UpdateMaxBitRateEstimate(incoming_bitrate_kbps); | 221 UpdateMaxBitRateEstimate(incoming_bitrate_kbps); |
222 } | 222 } |
223 // Stay on hold until the pipes are cleared. | 223 // Stay on hold until the pipes are cleared. |
224 ChangeState(kRcHold); | 224 ChangeState(kRcHold); |
225 time_last_bitrate_change_ = now_ms; | 225 time_last_bitrate_change_ = now_ms; |
226 break; | 226 break; |
227 | 227 |
228 default: | 228 default: |
229 assert(false); | 229 assert(false); |
230 } | 230 } |
231 if ((incoming_bitrate_bps > 100000 || current_bitrate_bps > 150000) && | 231 // Don't change the bit rate if the send side is too far off. |
232 current_bitrate_bps > 1.5 * incoming_bitrate_bps) { | 232 // We allow a bit more lag at very low rates to not too easily get stuck if |
233 // Allow changing the bit rate if we are operating at very low rates | 233 // the encoder produces uneven outputs. |
234 // Don't change the bit rate if the send side is too far off | 234 const uint32_t max_bitrate_bps = |
235 current_bitrate_bps = current_bitrate_bps_; | 235 static_cast<uint32_t>(1.5f * incoming_bitrate_bps) + 10000; |
| 236 if (current_bitrate_bps > current_bitrate_bps_ && |
| 237 current_bitrate_bps > max_bitrate_bps) { |
| 238 current_bitrate_bps = std::max(current_bitrate_bps_, max_bitrate_bps); |
236 time_last_bitrate_change_ = now_ms; | 239 time_last_bitrate_change_ = now_ms; |
237 } | 240 } |
238 return current_bitrate_bps; | 241 return current_bitrate_bps; |
239 } | 242 } |
240 | 243 |
241 uint32_t AimdRateControl::MultiplicativeRateIncrease( | 244 uint32_t AimdRateControl::MultiplicativeRateIncrease( |
242 int64_t now_ms, int64_t last_ms, uint32_t current_bitrate_bps) const { | 245 int64_t now_ms, int64_t last_ms, uint32_t current_bitrate_bps) const { |
243 double alpha = 1.08; | 246 double alpha = 1.08; |
244 if (last_ms > -1) { | 247 if (last_ms > -1) { |
245 int time_since_last_update_ms = std::min(static_cast<int>(now_ms - last_ms), | 248 int time_since_last_update_ms = std::min(static_cast<int>(now_ms - last_ms), |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 } | 307 } |
305 | 308 |
306 void AimdRateControl::ChangeRegion(RateControlRegion region) { | 309 void AimdRateControl::ChangeRegion(RateControlRegion region) { |
307 rate_control_region_ = region; | 310 rate_control_region_ = region; |
308 } | 311 } |
309 | 312 |
310 void AimdRateControl::ChangeState(RateControlState new_state) { | 313 void AimdRateControl::ChangeState(RateControlState new_state) { |
311 rate_control_state_ = new_state; | 314 rate_control_state_ = new_state; |
312 } | 315 } |
313 } // namespace webrtc | 316 } // namespace webrtc |
OLD | NEW |