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