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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 Observer* observer, | 137 Observer* observer, |
138 RtcEventLog* event_log, | 138 RtcEventLog* event_log, |
139 PacedSender* pacer) | 139 PacedSender* pacer) |
140 : clock_(clock), | 140 : clock_(clock), |
141 observer_(observer), | 141 observer_(observer), |
142 event_log_(event_log), | 142 event_log_(event_log), |
143 pacer_(pacer), | 143 pacer_(pacer), |
144 bitrate_controller_( | 144 bitrate_controller_( |
145 BitrateController::CreateBitrateController(clock_, event_log)), | 145 BitrateController::CreateBitrateController(clock_, event_log)), |
146 acknowledged_bitrate_estimator_( | 146 acknowledged_bitrate_estimator_( |
147 rtc::MakeUnique<AcknowledgedBitrateEstimator>()), | 147 rtc::MakeUnique<AcknowledgedBitrateEstimator>(event_log)), |
148 probe_controller_(new ProbeController(pacer_, clock_)), | 148 probe_controller_(new ProbeController(pacer_, clock_)), |
149 retransmission_rate_limiter_( | 149 retransmission_rate_limiter_( |
150 new RateLimiter(clock, kRetransmitWindowSizeMs)), | 150 new RateLimiter(clock, kRetransmitWindowSizeMs)), |
151 transport_feedback_adapter_(clock_), | 151 transport_feedback_adapter_(clock_), |
152 last_reported_bitrate_bps_(0), | 152 last_reported_bitrate_bps_(0), |
153 last_reported_fraction_loss_(0), | 153 last_reported_fraction_loss_(0), |
154 last_reported_rtt_(0), | 154 last_reported_rtt_(0), |
155 network_state_(kNetworkUp), | 155 network_state_(kNetworkUp), |
156 pause_pacer_(false), | 156 pause_pacer_(false), |
157 pacer_paused_(false), | 157 pacer_paused_(false), |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 uint8_t fraction_loss; | 409 uint8_t fraction_loss; |
410 int64_t rtt; | 410 int64_t rtt; |
411 bool estimate_changed = bitrate_controller_->GetNetworkParameters( | 411 bool estimate_changed = bitrate_controller_->GetNetworkParameters( |
412 &bitrate_bps, &fraction_loss, &rtt); | 412 &bitrate_bps, &fraction_loss, &rtt); |
413 if (estimate_changed) { | 413 if (estimate_changed) { |
414 pacer_->SetEstimatedBitrate(bitrate_bps); | 414 pacer_->SetEstimatedBitrate(bitrate_bps); |
415 probe_controller_->SetEstimatedBitrate(bitrate_bps); | 415 probe_controller_->SetEstimatedBitrate(bitrate_bps); |
416 retransmission_rate_limiter_->SetMaxRate(bitrate_bps); | 416 retransmission_rate_limiter_->SetMaxRate(bitrate_bps); |
417 } | 417 } |
418 | 418 |
419 bitrate_bps = IsNetworkDown() || IsSendQueueFull() ? 0 : bitrate_bps; | 419 // bitrate_bps = IsNetworkDown() || IsSendQueueFull() ? 0 : bitrate_bps; |
| 420 |
| 421 if (IsNetworkDown()) { |
| 422 bitrate_bps = 0; |
| 423 } else { |
| 424 int64_t expected_queue = pacer_->ExpectedQueueTimeMs(); |
| 425 |
| 426 if (expected_queue > 50) { |
| 427 float reduction_rate = |
| 428 std::max<float>(0.0f, 1.0 - expected_queue / 1000.0); |
| 429 if (!reduction_rate_ || *reduction_rate_ > reduction_rate) { |
| 430 reduction_rate_.emplace(reduction_rate); |
| 431 } |
| 432 } |
| 433 |
| 434 if (reduction_rate_) { |
| 435 if (expected_queue == 0) { |
| 436 reduction_rate_.reset(); |
| 437 } else { |
| 438 bitrate_bps *= *reduction_rate_; |
| 439 } |
| 440 } |
| 441 } |
420 | 442 |
421 if (HasNetworkParametersToReportChanged(bitrate_bps, fraction_loss, rtt)) { | 443 if (HasNetworkParametersToReportChanged(bitrate_bps, fraction_loss, rtt)) { |
422 int64_t probing_interval_ms; | 444 int64_t probing_interval_ms; |
423 { | 445 { |
424 rtc::CritScope cs(&bwe_lock_); | 446 rtc::CritScope cs(&bwe_lock_); |
425 probing_interval_ms = delay_based_bwe_->GetExpectedBwePeriodMs(); | 447 probing_interval_ms = delay_based_bwe_->GetExpectedBwePeriodMs(); |
426 } | 448 } |
427 { | 449 { |
428 rtc::CritScope cs(&observer_lock_); | 450 rtc::CritScope cs(&observer_lock_); |
429 if (observer_) { | 451 if (observer_) { |
(...skipping 17 matching lines...) Expand all Loading... |
447 LOG(LS_INFO) << "Bitrate estimate state changed, BWE: " << bitrate_bps | 469 LOG(LS_INFO) << "Bitrate estimate state changed, BWE: " << bitrate_bps |
448 << " bps."; | 470 << " bps."; |
449 } | 471 } |
450 last_reported_bitrate_bps_ = bitrate_bps; | 472 last_reported_bitrate_bps_ = bitrate_bps; |
451 last_reported_fraction_loss_ = fraction_loss; | 473 last_reported_fraction_loss_ = fraction_loss; |
452 last_reported_rtt_ = rtt; | 474 last_reported_rtt_ = rtt; |
453 return changed; | 475 return changed; |
454 } | 476 } |
455 | 477 |
456 bool SendSideCongestionController::IsSendQueueFull() const { | 478 bool SendSideCongestionController::IsSendQueueFull() const { |
457 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; | 479 return pacer_->ExpectedQueueTimeMs() > 2000; |
458 } | 480 } |
459 | 481 |
460 bool SendSideCongestionController::IsNetworkDown() const { | 482 bool SendSideCongestionController::IsNetworkDown() const { |
461 rtc::CritScope cs(&network_state_lock_); | 483 rtc::CritScope cs(&network_state_lock_); |
462 return network_state_ == kNetworkDown; | 484 return network_state_ == kNetworkDown; |
463 } | 485 } |
464 | 486 |
| 487 void SendSideCongestionController::PrintDebugStuff() { |
| 488 print_ = true; |
| 489 } |
| 490 |
465 } // namespace webrtc | 491 } // namespace webrtc |
OLD | NEW |