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

Side by Side Diff: modules/congestion_controller/send_side_congestion_controller.cc

Issue 3004783002: Push back on the video encoder to avoid building queues in the pacer. (Closed)
Patch Set: Rebase Created 3 years, 2 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 14 matching lines...) Expand all
25 #include "rtc_base/ptr_util.h" 25 #include "rtc_base/ptr_util.h"
26 #include "rtc_base/rate_limiter.h" 26 #include "rtc_base/rate_limiter.h"
27 #include "rtc_base/socket.h" 27 #include "rtc_base/socket.h"
28 #include "rtc_base/timeutils.h" 28 #include "rtc_base/timeutils.h"
29 #include "system_wrappers/include/field_trial.h" 29 #include "system_wrappers/include/field_trial.h"
30 30
31 namespace webrtc { 31 namespace webrtc {
32 namespace { 32 namespace {
33 33
34 const char kCwndExperiment[] = "WebRTC-CwndExperiment"; 34 const char kCwndExperiment[] = "WebRTC-CwndExperiment";
35 const char kPacerPushbackExperiment[] = "WebRTC-PacerPushbackExperiment";
35 const int64_t kDefaultAcceptedQueueMs = 250; 36 const int64_t kDefaultAcceptedQueueMs = 250;
36 37
37 bool CwndExperimentEnabled() { 38 bool CwndExperimentEnabled() {
38 std::string experiment_string = 39 std::string experiment_string =
39 webrtc::field_trial::FindFullName(kCwndExperiment); 40 webrtc::field_trial::FindFullName(kCwndExperiment);
40 // The experiment is enabled iff the field trial string begins with "Enabled". 41 // The experiment is enabled iff the field trial string begins with "Enabled".
41 return experiment_string.find("Enabled") == 0; 42 return experiment_string.find("Enabled") == 0;
42 } 43 }
43 44
44 bool ReadCwndExperimentParameter(int64_t* accepted_queue_ms) { 45 bool ReadCwndExperimentParameter(int64_t* accepted_queue_ms) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 last_reported_bitrate_bps_(0), 116 last_reported_bitrate_bps_(0),
116 last_reported_fraction_loss_(0), 117 last_reported_fraction_loss_(0),
117 last_reported_rtt_(0), 118 last_reported_rtt_(0),
118 network_state_(kNetworkUp), 119 network_state_(kNetworkUp),
119 pause_pacer_(false), 120 pause_pacer_(false),
120 pacer_paused_(false), 121 pacer_paused_(false),
121 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()), 122 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()),
122 delay_based_bwe_(new DelayBasedBwe(event_log_, clock_)), 123 delay_based_bwe_(new DelayBasedBwe(event_log_, clock_)),
123 in_cwnd_experiment_(CwndExperimentEnabled()), 124 in_cwnd_experiment_(CwndExperimentEnabled()),
124 accepted_queue_ms_(kDefaultAcceptedQueueMs), 125 accepted_queue_ms_(kDefaultAcceptedQueueMs),
125 was_in_alr_(0) { 126 was_in_alr_(false),
127 pacer_pushback_experiment_(
128 webrtc::field_trial::IsEnabled(kPacerPushbackExperiment)) {
126 delay_based_bwe_->SetMinBitrate(min_bitrate_bps_); 129 delay_based_bwe_->SetMinBitrate(min_bitrate_bps_);
127 if (in_cwnd_experiment_ && 130 if (in_cwnd_experiment_ &&
128 !ReadCwndExperimentParameter(&accepted_queue_ms_)) { 131 !ReadCwndExperimentParameter(&accepted_queue_ms_)) {
129 LOG(LS_WARNING) << "Failed to parse parameters for CwndExperiment " 132 LOG(LS_WARNING) << "Failed to parse parameters for CwndExperiment "
130 "from field trial string. Experiment disabled."; 133 "from field trial string. Experiment disabled.";
131 in_cwnd_experiment_ = false; 134 in_cwnd_experiment_ = false;
132 } 135 }
133 } 136 }
134 137
135 SendSideCongestionController::SendSideCongestionController( 138 SendSideCongestionController::SendSideCongestionController(
(...skipping 16 matching lines...) Expand all
152 last_reported_bitrate_bps_(0), 155 last_reported_bitrate_bps_(0),
153 last_reported_fraction_loss_(0), 156 last_reported_fraction_loss_(0),
154 last_reported_rtt_(0), 157 last_reported_rtt_(0),
155 network_state_(kNetworkUp), 158 network_state_(kNetworkUp),
156 pause_pacer_(false), 159 pause_pacer_(false),
157 pacer_paused_(false), 160 pacer_paused_(false),
158 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()), 161 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()),
159 delay_based_bwe_(new DelayBasedBwe(event_log_, clock_)), 162 delay_based_bwe_(new DelayBasedBwe(event_log_, clock_)),
160 in_cwnd_experiment_(CwndExperimentEnabled()), 163 in_cwnd_experiment_(CwndExperimentEnabled()),
161 accepted_queue_ms_(kDefaultAcceptedQueueMs), 164 accepted_queue_ms_(kDefaultAcceptedQueueMs),
162 was_in_alr_(0) { 165 was_in_alr_(false),
166 pacer_pushback_experiment_(
167 webrtc::field_trial::IsEnabled(kPacerPushbackExperiment)) {
163 delay_based_bwe_->SetMinBitrate(min_bitrate_bps_); 168 delay_based_bwe_->SetMinBitrate(min_bitrate_bps_);
164 if (in_cwnd_experiment_ && 169 if (in_cwnd_experiment_ &&
165 !ReadCwndExperimentParameter(&accepted_queue_ms_)) { 170 !ReadCwndExperimentParameter(&accepted_queue_ms_)) {
166 LOG(LS_WARNING) << "Failed to parse parameters for CwndExperiment " 171 LOG(LS_WARNING) << "Failed to parse parameters for CwndExperiment "
167 "from field trial string. Experiment disabled."; 172 "from field trial string. Experiment disabled.";
168 in_cwnd_experiment_ = false; 173 in_cwnd_experiment_ = false;
169 } 174 }
170 } 175 }
171 176
172 SendSideCongestionController::~SendSideCongestionController() {} 177 SendSideCongestionController::~SendSideCongestionController() {}
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 uint8_t fraction_loss; 414 uint8_t fraction_loss;
410 int64_t rtt; 415 int64_t rtt;
411 bool estimate_changed = bitrate_controller_->GetNetworkParameters( 416 bool estimate_changed = bitrate_controller_->GetNetworkParameters(
412 &bitrate_bps, &fraction_loss, &rtt); 417 &bitrate_bps, &fraction_loss, &rtt);
413 if (estimate_changed) { 418 if (estimate_changed) {
414 pacer_->SetEstimatedBitrate(bitrate_bps); 419 pacer_->SetEstimatedBitrate(bitrate_bps);
415 probe_controller_->SetEstimatedBitrate(bitrate_bps); 420 probe_controller_->SetEstimatedBitrate(bitrate_bps);
416 retransmission_rate_limiter_->SetMaxRate(bitrate_bps); 421 retransmission_rate_limiter_->SetMaxRate(bitrate_bps);
417 } 422 }
418 423
419 bitrate_bps = IsNetworkDown() || IsSendQueueFull() ? 0 : bitrate_bps; 424 if (!pacer_pushback_experiment_) {
425 bitrate_bps = IsNetworkDown() || IsSendQueueFull() ? 0 : bitrate_bps;
426 } else {
427 if (IsNetworkDown()) {
428 bitrate_bps = 0;
429 } else {
430 int64_t queue_length_ms = pacer_->ExpectedQueueTimeMs();
431
432 if (queue_length_ms == 0) {
433 encoding_rate_ = 1.0;
434 } else if (queue_length_ms > 50) {
435 float encoding_rate = 1.0 - queue_length_ms / 1000.0;
436 encoding_rate_ = std::min(encoding_rate_, encoding_rate);
437 encoding_rate_ = std::max(encoding_rate_, 0.0f);
438 }
439
440 bitrate_bps *= encoding_rate_;
441 bitrate_bps = bitrate_bps < 50000 ? 0 : bitrate_bps;
442 }
443 }
420 444
421 if (HasNetworkParametersToReportChanged(bitrate_bps, fraction_loss, rtt)) { 445 if (HasNetworkParametersToReportChanged(bitrate_bps, fraction_loss, rtt)) {
422 int64_t probing_interval_ms; 446 int64_t probing_interval_ms;
423 { 447 {
424 rtc::CritScope cs(&bwe_lock_); 448 rtc::CritScope cs(&bwe_lock_);
425 probing_interval_ms = delay_based_bwe_->GetExpectedBwePeriodMs(); 449 probing_interval_ms = delay_based_bwe_->GetExpectedBwePeriodMs();
426 } 450 }
427 { 451 {
428 rtc::CritScope cs(&observer_lock_); 452 rtc::CritScope cs(&observer_lock_);
429 if (observer_) { 453 if (observer_) {
(...skipping 26 matching lines...) Expand all
456 bool SendSideCongestionController::IsSendQueueFull() const { 480 bool SendSideCongestionController::IsSendQueueFull() const {
457 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; 481 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs;
458 } 482 }
459 483
460 bool SendSideCongestionController::IsNetworkDown() const { 484 bool SendSideCongestionController::IsNetworkDown() const {
461 rtc::CritScope cs(&network_state_lock_); 485 rtc::CritScope cs(&network_state_lock_);
462 return network_state_ == kNetworkDown; 486 return network_state_ == kNetworkDown;
463 } 487 }
464 488
465 } // namespace webrtc 489 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698