Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: webrtc/modules/congestion_controller/delay_based_bwe.cc

Issue 2997883002: Video/Screenshare loopback tool.
Patch Set: Rebase Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 } 210 }
211 211
212 DelayBasedBwe::Result DelayBasedBwe::MaybeUpdateEstimate( 212 DelayBasedBwe::Result DelayBasedBwe::MaybeUpdateEstimate(
213 bool overusing, 213 bool overusing,
214 rtc::Optional<uint32_t> acked_bitrate_bps, 214 rtc::Optional<uint32_t> acked_bitrate_bps,
215 bool recovered_from_overuse) { 215 bool recovered_from_overuse) {
216 Result result; 216 Result result;
217 int64_t now_ms = clock_->TimeInMilliseconds(); 217 int64_t now_ms = clock_->TimeInMilliseconds();
218 218
219 rtc::Optional<int> probe_bitrate_bps = 219 rtc::Optional<int> probe_bitrate_bps =
220 probe_bitrate_estimator_.FetchAndResetLastEstimatedBitrateBps(); 220 probe_bitrate_estimator_.FetchAndResetLastEstimatedBitrateBps(50);
221 // Currently overusing the bandwidth. 221 // Currently overusing the bandwidth.
222 if (overusing) { 222 if (overusing) {
223 if (acked_bitrate_bps && 223 if (acked_bitrate_bps &&
224 rate_control_.TimeToReduceFurther(now_ms, *acked_bitrate_bps)) { 224 rate_control_.TimeToReduceFurther(now_ms, *acked_bitrate_bps)) {
225 result.updated = UpdateEstimate(now_ms, acked_bitrate_bps, overusing, 225 result.updated = UpdateEstimate(now_ms, acked_bitrate_bps, overusing,
226 &result.target_bitrate_bps); 226 &result.target_bitrate_bps);
227 } else if (!acked_bitrate_bps && rate_control_.ValidEstimate() && 227 } else if (!acked_bitrate_bps && rate_control_.ValidEstimate() &&
228 rate_control_.TimeToReduceFurther( 228 rate_control_.TimeToReduceFurther(
229 now_ms, rate_control_.LatestEstimate() / 2 - 1)) { 229 now_ms, rate_control_.LatestEstimate() / 2 - 1)) {
230 // Overusing before we have a measured acknowledged bitrate. We check 230 // Overusing before we have a measured acknowledged bitrate. We check
(...skipping 11 matching lines...) Expand all
242 result.probe = true; 242 result.probe = true;
243 result.updated = true; 243 result.updated = true;
244 result.target_bitrate_bps = *probe_bitrate_bps; 244 result.target_bitrate_bps = *probe_bitrate_bps;
245 rate_control_.SetEstimate(*probe_bitrate_bps, now_ms); 245 rate_control_.SetEstimate(*probe_bitrate_bps, now_ms);
246 } else { 246 } else {
247 result.updated = UpdateEstimate(now_ms, acked_bitrate_bps, overusing, 247 result.updated = UpdateEstimate(now_ms, acked_bitrate_bps, overusing,
248 &result.target_bitrate_bps); 248 &result.target_bitrate_bps);
249 result.recovered_from_overuse = recovered_from_overuse; 249 result.recovered_from_overuse = recovered_from_overuse;
250 } 250 }
251 } 251 }
252 if (result.updated) { 252 if (result.updated || detector_.State() != last_logged_state_) {
253 BWE_TEST_LOGGING_PLOT(1, "target_bitrate_bps", now_ms, 253 BWE_TEST_LOGGING_PLOT(1, "target_bitrate_bps", now_ms,
254 result.target_bitrate_bps); 254 result.target_bitrate_bps);
255 if (event_log_ && (result.target_bitrate_bps != last_logged_bitrate_ || 255 if (event_log_ && (result.target_bitrate_bps != last_logged_bitrate_ ||
256 detector_.State() != last_logged_state_)) { 256 detector_.State() != last_logged_state_)) {
257 event_log_->LogDelayBasedBweUpdate(result.target_bitrate_bps, 257 uint32_t bitrate_bps =
258 detector_.State()); 258 result.updated ? result.target_bitrate_bps : last_logged_bitrate_;
259 last_logged_bitrate_ = result.target_bitrate_bps; 259 event_log_->LogDelayBasedBweUpdate(bitrate_bps, detector_.State());
260 if (result.target_bitrate_bps > 0)
261 last_logged_bitrate_ = result.target_bitrate_bps;
260 last_logged_state_ = detector_.State(); 262 last_logged_state_ = detector_.State();
261 } 263 }
262 } 264 }
263 return result; 265 return result;
264 } 266 }
265 267
266 bool DelayBasedBwe::UpdateEstimate(int64_t now_ms, 268 bool DelayBasedBwe::UpdateEstimate(int64_t now_ms,
267 rtc::Optional<uint32_t> acked_bitrate_bps, 269 rtc::Optional<uint32_t> acked_bitrate_bps,
268 bool overusing, 270 bool overusing,
269 uint32_t* target_bitrate_bps) { 271 uint32_t* target_bitrate_bps) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) { 308 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) {
307 // Called from both the configuration thread and the network thread. Shouldn't 309 // Called from both the configuration thread and the network thread. Shouldn't
308 // be called from the network thread in the future. 310 // be called from the network thread in the future.
309 rate_control_.SetMinBitrate(min_bitrate_bps); 311 rate_control_.SetMinBitrate(min_bitrate_bps);
310 } 312 }
311 313
312 int64_t DelayBasedBwe::GetExpectedBwePeriodMs() const { 314 int64_t DelayBasedBwe::GetExpectedBwePeriodMs() const {
313 return rate_control_.GetExpectedBandwidthPeriodMs(); 315 return rate_control_.GetExpectedBandwidthPeriodMs();
314 } 316 }
315 } // namespace webrtc 317 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698