| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 probe_bitrate_estimator_.FetchAndResetLastEstimatedBitrateBps(); | 197 probe_bitrate_estimator_.FetchAndResetLastEstimatedBitrateBps(); |
| 198 // Currently overusing the bandwidth. | 198 // Currently overusing the bandwidth. |
| 199 if (overusing) { | 199 if (overusing) { |
| 200 if (acked_bitrate_bps && | 200 if (acked_bitrate_bps && |
| 201 rate_control_.TimeToReduceFurther(now_ms, *acked_bitrate_bps)) { | 201 rate_control_.TimeToReduceFurther(now_ms, *acked_bitrate_bps)) { |
| 202 result.updated = UpdateEstimate(now_ms, acked_bitrate_bps, overusing, | 202 result.updated = UpdateEstimate(now_ms, acked_bitrate_bps, overusing, |
| 203 &result.target_bitrate_bps); | 203 &result.target_bitrate_bps); |
| 204 } | 204 } |
| 205 } else { | 205 } else { |
| 206 if (probe_bitrate_bps) { | 206 if (probe_bitrate_bps) { |
| 207 result.probe = true; |
| 208 result.updated = true; |
| 209 result.target_bitrate_bps = *probe_bitrate_bps; |
| 207 rate_control_.SetEstimate(*probe_bitrate_bps, now_ms); | 210 rate_control_.SetEstimate(*probe_bitrate_bps, now_ms); |
| 208 result.probe = true; | 211 } else { |
| 212 result.updated = UpdateEstimate(now_ms, acked_bitrate_bps, overusing, |
| 213 &result.target_bitrate_bps); |
| 209 } | 214 } |
| 210 result.updated = UpdateEstimate(now_ms, acked_bitrate_bps, overusing, | |
| 211 &result.target_bitrate_bps); | |
| 212 } | 215 } |
| 213 if (result.updated) { | 216 if (result.updated) { |
| 214 BWE_TEST_LOGGING_PLOT(1, "target_bitrate_bps", now_ms, | 217 BWE_TEST_LOGGING_PLOT(1, "target_bitrate_bps", now_ms, |
| 215 result.target_bitrate_bps); | 218 result.target_bitrate_bps); |
| 216 if (event_log_ && (result.target_bitrate_bps != last_logged_bitrate_ || | 219 if (event_log_ && (result.target_bitrate_bps != last_logged_bitrate_ || |
| 217 detector_.State() != last_logged_state_)) { | 220 detector_.State() != last_logged_state_)) { |
| 218 event_log_->LogDelayBasedBweUpdate(result.target_bitrate_bps, | 221 event_log_->LogDelayBasedBweUpdate(result.target_bitrate_bps, |
| 219 detector_.State()); | 222 detector_.State()); |
| 220 last_logged_bitrate_ = result.target_bitrate_bps; | 223 last_logged_bitrate_ = result.target_bitrate_bps; |
| 221 last_logged_state_ = detector_.State(); | 224 last_logged_state_ = detector_.State(); |
| 222 } | 225 } |
| 223 } | 226 } |
| 224 return result; | 227 return result; |
| 225 } | 228 } |
| 226 | 229 |
| 227 bool DelayBasedBwe::UpdateEstimate(int64_t now_ms, | 230 bool DelayBasedBwe::UpdateEstimate(int64_t now_ms, |
| 228 rtc::Optional<uint32_t> acked_bitrate_bps, | 231 rtc::Optional<uint32_t> acked_bitrate_bps, |
| 229 bool overusing, | 232 bool overusing, |
| 230 uint32_t* target_bitrate_bps) { | 233 uint32_t* target_bitrate_bps) { |
| 231 // TODO(terelius): RateControlInput::noise_var is deprecated and will be | 234 // TODO(terelius): RateControlInput::noise_var is deprecated and will be |
| 232 // removed. In the meantime, we set it to zero. | 235 // removed. In the meantime, we set it to zero. |
| 233 const RateControlInput input( | 236 const RateControlInput input( |
| 234 overusing ? BandwidthUsage::kBwOverusing : detector_.State(), | 237 overusing ? BandwidthUsage::kBwOverusing : detector_.State(), |
| 235 acked_bitrate_bps, 0); | 238 acked_bitrate_bps, 0); |
| 239 uint32_t prev_target_bitrate_bps = rate_control_.LatestEstimate(); |
| 236 *target_bitrate_bps = rate_control_.Update(&input, now_ms); | 240 *target_bitrate_bps = rate_control_.Update(&input, now_ms); |
| 237 return rate_control_.ValidEstimate(); | 241 return rate_control_.ValidEstimate() && |
| 242 prev_target_bitrate_bps != *target_bitrate_bps; |
| 238 } | 243 } |
| 239 | 244 |
| 240 void DelayBasedBwe::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { | 245 void DelayBasedBwe::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { |
| 241 rate_control_.SetRtt(avg_rtt_ms); | 246 rate_control_.SetRtt(avg_rtt_ms); |
| 242 } | 247 } |
| 243 | 248 |
| 244 bool DelayBasedBwe::LatestEstimate(std::vector<uint32_t>* ssrcs, | 249 bool DelayBasedBwe::LatestEstimate(std::vector<uint32_t>* ssrcs, |
| 245 uint32_t* bitrate_bps) const { | 250 uint32_t* bitrate_bps) const { |
| 246 // Currently accessed from both the process thread (see | 251 // Currently accessed from both the process thread (see |
| 247 // ModuleRtpRtcpImpl::Process()) and the configuration thread (see | 252 // ModuleRtpRtcpImpl::Process()) and the configuration thread (see |
| (...skipping 17 matching lines...) Expand all Loading... |
| 265 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) { | 270 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) { |
| 266 // Called from both the configuration thread and the network thread. Shouldn't | 271 // Called from both the configuration thread and the network thread. Shouldn't |
| 267 // be called from the network thread in the future. | 272 // be called from the network thread in the future. |
| 268 rate_control_.SetMinBitrate(min_bitrate_bps); | 273 rate_control_.SetMinBitrate(min_bitrate_bps); |
| 269 } | 274 } |
| 270 | 275 |
| 271 int64_t DelayBasedBwe::GetExpectedBwePeriodMs() const { | 276 int64_t DelayBasedBwe::GetExpectedBwePeriodMs() const { |
| 272 return rate_control_.GetExpectedBandwidthPeriodMs(); | 277 return rate_control_.GetExpectedBandwidthPeriodMs(); |
| 273 } | 278 } |
| 274 } // namespace webrtc | 279 } // namespace webrtc |
| OLD | NEW |