OLD | NEW |
---|---|
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 Loading... | |
25 #include "webrtc/rtc_base/ptr_util.h" | 25 #include "webrtc/rtc_base/ptr_util.h" |
26 #include "webrtc/rtc_base/rate_limiter.h" | 26 #include "webrtc/rtc_base/rate_limiter.h" |
27 #include "webrtc/rtc_base/socket.h" | 27 #include "webrtc/rtc_base/socket.h" |
28 #include "webrtc/rtc_base/timeutils.h" | 28 #include "webrtc/rtc_base/timeutils.h" |
29 #include "webrtc/system_wrappers/include/field_trial.h" | 29 #include "webrtc/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 |
45 bool PacerPushbackExperimentEnabled() { | |
46 std::string experiment_string = | |
47 webrtc::field_trial::FindFullName(kPacerPushbackExperiment); | |
48 // The experiment is enabled iff the field trial string begins with "Enabled". | |
49 return experiment_string.find("Enabled") == 0; | |
50 } | |
stefan-webrtc
2017/08/29 12:17:20
Replace with:
webrtc::field_trial::IsEnabled(kPace
philipel
2017/08/29 15:14:18
Done.
| |
51 | |
44 bool ReadCwndExperimentParameter(int64_t* accepted_queue_ms) { | 52 bool ReadCwndExperimentParameter(int64_t* accepted_queue_ms) { |
45 RTC_DCHECK(accepted_queue_ms); | 53 RTC_DCHECK(accepted_queue_ms); |
46 std::string experiment_string = | 54 std::string experiment_string = |
47 webrtc::field_trial::FindFullName(kCwndExperiment); | 55 webrtc::field_trial::FindFullName(kCwndExperiment); |
48 int parsed_values = | 56 int parsed_values = |
49 sscanf(experiment_string.c_str(), "Enabled-%" PRId64, accepted_queue_ms); | 57 sscanf(experiment_string.c_str(), "Enabled-%" PRId64, accepted_queue_ms); |
50 if (parsed_values == 1) { | 58 if (parsed_values == 1) { |
51 RTC_CHECK_GE(*accepted_queue_ms, 0) | 59 RTC_CHECK_GE(*accepted_queue_ms, 0) |
52 << "Accepted must be greater than or equal to 0."; | 60 << "Accepted must be greater than or equal to 0."; |
53 return true; | 61 return true; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 last_reported_bitrate_bps_(0), | 123 last_reported_bitrate_bps_(0), |
116 last_reported_fraction_loss_(0), | 124 last_reported_fraction_loss_(0), |
117 last_reported_rtt_(0), | 125 last_reported_rtt_(0), |
118 network_state_(kNetworkUp), | 126 network_state_(kNetworkUp), |
119 pause_pacer_(false), | 127 pause_pacer_(false), |
120 pacer_paused_(false), | 128 pacer_paused_(false), |
121 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()), | 129 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()), |
122 delay_based_bwe_(new DelayBasedBwe(event_log_, clock_)), | 130 delay_based_bwe_(new DelayBasedBwe(event_log_, clock_)), |
123 in_cwnd_experiment_(CwndExperimentEnabled()), | 131 in_cwnd_experiment_(CwndExperimentEnabled()), |
124 accepted_queue_ms_(kDefaultAcceptedQueueMs), | 132 accepted_queue_ms_(kDefaultAcceptedQueueMs), |
125 was_in_alr_(0) { | 133 was_in_alr_(false), |
134 pacer_pushback_experiment_(PacerPushbackExperimentEnabled()) { | |
126 delay_based_bwe_->SetMinBitrate(min_bitrate_bps_); | 135 delay_based_bwe_->SetMinBitrate(min_bitrate_bps_); |
127 if (in_cwnd_experiment_ && | 136 if (in_cwnd_experiment_ && |
128 !ReadCwndExperimentParameter(&accepted_queue_ms_)) { | 137 !ReadCwndExperimentParameter(&accepted_queue_ms_)) { |
129 LOG(LS_WARNING) << "Failed to parse parameters for CwndExperiment " | 138 LOG(LS_WARNING) << "Failed to parse parameters for CwndExperiment " |
130 "from field trial string. Experiment disabled."; | 139 "from field trial string. Experiment disabled."; |
131 in_cwnd_experiment_ = false; | 140 in_cwnd_experiment_ = false; |
132 } | 141 } |
133 } | 142 } |
134 | 143 |
135 SendSideCongestionController::SendSideCongestionController( | 144 SendSideCongestionController::SendSideCongestionController( |
(...skipping 16 matching lines...) Expand all Loading... | |
152 last_reported_bitrate_bps_(0), | 161 last_reported_bitrate_bps_(0), |
153 last_reported_fraction_loss_(0), | 162 last_reported_fraction_loss_(0), |
154 last_reported_rtt_(0), | 163 last_reported_rtt_(0), |
155 network_state_(kNetworkUp), | 164 network_state_(kNetworkUp), |
156 pause_pacer_(false), | 165 pause_pacer_(false), |
157 pacer_paused_(false), | 166 pacer_paused_(false), |
158 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()), | 167 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()), |
159 delay_based_bwe_(new DelayBasedBwe(event_log_, clock_)), | 168 delay_based_bwe_(new DelayBasedBwe(event_log_, clock_)), |
160 in_cwnd_experiment_(CwndExperimentEnabled()), | 169 in_cwnd_experiment_(CwndExperimentEnabled()), |
161 accepted_queue_ms_(kDefaultAcceptedQueueMs), | 170 accepted_queue_ms_(kDefaultAcceptedQueueMs), |
162 was_in_alr_(0) { | 171 was_in_alr_(false), |
172 pacer_pushback_experiment_(PacerPushbackExperimentEnabled()) { | |
163 delay_based_bwe_->SetMinBitrate(min_bitrate_bps_); | 173 delay_based_bwe_->SetMinBitrate(min_bitrate_bps_); |
164 if (in_cwnd_experiment_ && | 174 if (in_cwnd_experiment_ && |
165 !ReadCwndExperimentParameter(&accepted_queue_ms_)) { | 175 !ReadCwndExperimentParameter(&accepted_queue_ms_)) { |
166 LOG(LS_WARNING) << "Failed to parse parameters for CwndExperiment " | 176 LOG(LS_WARNING) << "Failed to parse parameters for CwndExperiment " |
167 "from field trial string. Experiment disabled."; | 177 "from field trial string. Experiment disabled."; |
168 in_cwnd_experiment_ = false; | 178 in_cwnd_experiment_ = false; |
169 } | 179 } |
170 } | 180 } |
171 | 181 |
172 SendSideCongestionController::~SendSideCongestionController() {} | 182 SendSideCongestionController::~SendSideCongestionController() {} |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
409 uint8_t fraction_loss; | 419 uint8_t fraction_loss; |
410 int64_t rtt; | 420 int64_t rtt; |
411 bool estimate_changed = bitrate_controller_->GetNetworkParameters( | 421 bool estimate_changed = bitrate_controller_->GetNetworkParameters( |
412 &bitrate_bps, &fraction_loss, &rtt); | 422 &bitrate_bps, &fraction_loss, &rtt); |
413 if (estimate_changed) { | 423 if (estimate_changed) { |
414 pacer_->SetEstimatedBitrate(bitrate_bps); | 424 pacer_->SetEstimatedBitrate(bitrate_bps); |
415 probe_controller_->SetEstimatedBitrate(bitrate_bps); | 425 probe_controller_->SetEstimatedBitrate(bitrate_bps); |
416 retransmission_rate_limiter_->SetMaxRate(bitrate_bps); | 426 retransmission_rate_limiter_->SetMaxRate(bitrate_bps); |
417 } | 427 } |
418 | 428 |
419 bitrate_bps = IsNetworkDown() || IsSendQueueFull() ? 0 : bitrate_bps; | 429 if (!pacer_pushback_experiment_) { |
430 bitrate_bps = IsNetworkDown() || IsSendQueueFull() ? 0 : bitrate_bps; | |
431 } else { | |
432 if (IsNetworkDown()) { | |
433 bitrate_bps = 0; | |
434 } else { | |
435 int64_t queue_length_ms = pacer_->ExpectedQueueTimeMs(); | |
436 | |
437 if (queue_length_ms == 0) { | |
438 encoding_rate_ = 1.0; | |
439 } else if (queue_length_ms > 50) { | |
stefan-webrtc
2017/08/29 12:17:20
50 ms dead zone sounds pretty small. WDYT of incre
philipel
2017/08/29 15:14:18
I got better results using 50 ms rather than 100,
| |
440 float encoding_rate = 1.0 - queue_length_ms / 1000.0; | |
stefan-webrtc
2017/08/29 12:17:20
Should this be something like this, so that we hav
philipel
2017/08/29 15:14:18
The idea is to drain the queue completely, so I th
| |
441 encoding_rate_ = std::min(encoding_rate_, encoding_rate); | |
442 encoding_rate_ = std::max(encoding_rate_, 0.0f); | |
443 } | |
444 | |
445 bitrate_bps *= encoding_rate_; | |
446 } | |
447 } | |
420 | 448 |
421 if (HasNetworkParametersToReportChanged(bitrate_bps, fraction_loss, rtt)) { | 449 if (HasNetworkParametersToReportChanged(bitrate_bps, fraction_loss, rtt)) { |
422 int64_t probing_interval_ms; | 450 int64_t probing_interval_ms; |
423 { | 451 { |
424 rtc::CritScope cs(&bwe_lock_); | 452 rtc::CritScope cs(&bwe_lock_); |
425 probing_interval_ms = delay_based_bwe_->GetExpectedBwePeriodMs(); | 453 probing_interval_ms = delay_based_bwe_->GetExpectedBwePeriodMs(); |
426 } | 454 } |
427 { | 455 { |
428 rtc::CritScope cs(&observer_lock_); | 456 rtc::CritScope cs(&observer_lock_); |
429 if (observer_) { | 457 if (observer_) { |
(...skipping 26 matching lines...) Expand all Loading... | |
456 bool SendSideCongestionController::IsSendQueueFull() const { | 484 bool SendSideCongestionController::IsSendQueueFull() const { |
457 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; | 485 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; |
458 } | 486 } |
459 | 487 |
460 bool SendSideCongestionController::IsNetworkDown() const { | 488 bool SendSideCongestionController::IsNetworkDown() const { |
461 rtc::CritScope cs(&network_state_lock_); | 489 rtc::CritScope cs(&network_state_lock_); |
462 return network_state_ == kNetworkDown; | 490 return network_state_ == kNetworkDown; |
463 } | 491 } |
464 | 492 |
465 } // namespace webrtc | 493 } // namespace webrtc |
OLD | NEW |