Chromium Code Reviews| 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 28 matching lines...) Expand all Loading... | |
| 39 if (*max_bitrate_bps > 0) | 39 if (*max_bitrate_bps > 0) |
| 40 *max_bitrate_bps = std::max(*min_bitrate_bps, *max_bitrate_bps); | 40 *max_bitrate_bps = std::max(*min_bitrate_bps, *max_bitrate_bps); |
| 41 if (*bitrate_bps > 0) | 41 if (*bitrate_bps > 0) |
| 42 *bitrate_bps = std::max(*min_bitrate_bps, *bitrate_bps); | 42 *bitrate_bps = std::max(*min_bitrate_bps, *bitrate_bps); |
| 43 } | 43 } |
| 44 | 44 |
| 45 } // namespace | 45 } // namespace |
| 46 | 46 |
| 47 SendSideCongestionController::SendSideCongestionController( | 47 SendSideCongestionController::SendSideCongestionController( |
| 48 const Clock* clock, | 48 const Clock* clock, |
| 49 Observer* observer, | 49 Observer* observer, |
|
terelius
2017/04/03 09:48:04
Going forward, will we deprecate passing an observ
nisse-webrtc
2017/04/03 09:54:42
Hmm. Maybe.
The CongestionController class (old
terelius
2017/04/03 10:55:28
Agree about not spending time on changing somethin
| |
| 50 RtcEventLog* event_log, | 50 RtcEventLog* event_log, |
| 51 PacketRouter* packet_router) | 51 PacketRouter* packet_router) |
| 52 : SendSideCongestionController( | 52 : SendSideCongestionController( |
| 53 clock, | 53 clock, |
| 54 observer, | 54 observer, |
| 55 event_log, | 55 event_log, |
| 56 std::unique_ptr<PacedSender>( | 56 std::unique_ptr<PacedSender>( |
| 57 new PacedSender(clock, packet_router, event_log))) {} | 57 new PacedSender(clock, packet_router, event_log))) {} |
| 58 | 58 |
| 59 SendSideCongestionController::SendSideCongestionController( | 59 SendSideCongestionController::SendSideCongestionController( |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 86 void SendSideCongestionController::RegisterPacketFeedbackObserver( | 86 void SendSideCongestionController::RegisterPacketFeedbackObserver( |
| 87 PacketFeedbackObserver* observer) { | 87 PacketFeedbackObserver* observer) { |
| 88 transport_feedback_adapter_.RegisterPacketFeedbackObserver(observer); | 88 transport_feedback_adapter_.RegisterPacketFeedbackObserver(observer); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void SendSideCongestionController::DeRegisterPacketFeedbackObserver( | 91 void SendSideCongestionController::DeRegisterPacketFeedbackObserver( |
| 92 PacketFeedbackObserver* observer) { | 92 PacketFeedbackObserver* observer) { |
| 93 transport_feedback_adapter_.DeRegisterPacketFeedbackObserver(observer); | 93 transport_feedback_adapter_.DeRegisterPacketFeedbackObserver(observer); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void SendSideCongestionController::RegisterNetworkObserver(Observer* observer) { | |
| 97 rtc::CritScope cs(&observer_lock_); | |
| 98 RTC_DCHECK(observer_ == nullptr); | |
| 99 observer_ = observer; | |
| 100 } | |
| 101 | |
| 102 void SendSideCongestionController::DeRegisterNetworkObserver( | |
| 103 Observer* observer) { | |
| 104 rtc::CritScope cs(&observer_lock_); | |
| 105 RTC_DCHECK_EQ(observer_, observer); | |
| 106 observer_ = nullptr; | |
| 107 } | |
| 108 | |
| 96 void SendSideCongestionController::SetBweBitrates(int min_bitrate_bps, | 109 void SendSideCongestionController::SetBweBitrates(int min_bitrate_bps, |
| 97 int start_bitrate_bps, | 110 int start_bitrate_bps, |
| 98 int max_bitrate_bps) { | 111 int max_bitrate_bps) { |
| 99 ClampBitrates(&start_bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); | 112 ClampBitrates(&start_bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); |
| 100 bitrate_controller_->SetBitrates(start_bitrate_bps, min_bitrate_bps, | 113 bitrate_controller_->SetBitrates(start_bitrate_bps, min_bitrate_bps, |
| 101 max_bitrate_bps); | 114 max_bitrate_bps); |
| 102 | 115 |
| 103 probe_controller_->SetBitrates(min_bitrate_bps, start_bitrate_bps, | 116 probe_controller_->SetBitrates(min_bitrate_bps, start_bitrate_bps, |
| 104 max_bitrate_bps); | 117 max_bitrate_bps); |
| 105 | 118 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 bitrate_controller_->OnDelayBasedBweResult(result); | 251 bitrate_controller_->OnDelayBasedBweResult(result); |
| 239 } | 252 } |
| 240 | 253 |
| 241 std::vector<PacketFeedback> | 254 std::vector<PacketFeedback> |
| 242 SendSideCongestionController::GetTransportFeedbackVector() const { | 255 SendSideCongestionController::GetTransportFeedbackVector() const { |
| 243 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 256 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 244 return transport_feedback_adapter_.GetTransportFeedbackVector(); | 257 return transport_feedback_adapter_.GetTransportFeedbackVector(); |
| 245 } | 258 } |
| 246 | 259 |
| 247 void SendSideCongestionController::MaybeTriggerOnNetworkChanged() { | 260 void SendSideCongestionController::MaybeTriggerOnNetworkChanged() { |
| 248 // TODO(perkj): |observer_| can be nullptr if the ctor that accepts a | |
| 249 // BitrateObserver is used. Remove this check once the ctor is removed. | |
| 250 if (!observer_) | |
| 251 return; | |
| 252 | |
| 253 uint32_t bitrate_bps; | 261 uint32_t bitrate_bps; |
| 254 uint8_t fraction_loss; | 262 uint8_t fraction_loss; |
| 255 int64_t rtt; | 263 int64_t rtt; |
| 256 bool estimate_changed = bitrate_controller_->GetNetworkParameters( | 264 bool estimate_changed = bitrate_controller_->GetNetworkParameters( |
| 257 &bitrate_bps, &fraction_loss, &rtt); | 265 &bitrate_bps, &fraction_loss, &rtt); |
| 258 if (estimate_changed) { | 266 if (estimate_changed) { |
| 259 pacer_->SetEstimatedBitrate(bitrate_bps); | 267 pacer_->SetEstimatedBitrate(bitrate_bps); |
| 260 probe_controller_->SetEstimatedBitrate(bitrate_bps); | 268 probe_controller_->SetEstimatedBitrate(bitrate_bps); |
| 261 retransmission_rate_limiter_->SetMaxRate(bitrate_bps); | 269 retransmission_rate_limiter_->SetMaxRate(bitrate_bps); |
| 262 } | 270 } |
| 263 | 271 |
| 264 bitrate_bps = IsNetworkDown() || IsSendQueueFull() ? 0 : bitrate_bps; | 272 bitrate_bps = IsNetworkDown() || IsSendQueueFull() ? 0 : bitrate_bps; |
| 265 | 273 |
| 266 if (HasNetworkParametersToReportChanged(bitrate_bps, fraction_loss, rtt)) { | 274 if (HasNetworkParametersToReportChanged(bitrate_bps, fraction_loss, rtt)) { |
| 267 int64_t probing_interval_ms; | 275 int64_t probing_interval_ms; |
| 268 { | 276 { |
| 269 rtc::CritScope cs(&bwe_lock_); | 277 rtc::CritScope cs(&bwe_lock_); |
| 270 probing_interval_ms = delay_based_bwe_->GetProbingIntervalMs(); | 278 probing_interval_ms = delay_based_bwe_->GetProbingIntervalMs(); |
| 271 } | 279 } |
| 272 observer_->OnNetworkChanged(bitrate_bps, fraction_loss, rtt, | 280 { |
| 273 probing_interval_ms); | 281 rtc::CritScope cs(&observer_lock_); |
| 282 if (observer_) { | |
| 283 observer_->OnNetworkChanged(bitrate_bps, fraction_loss, rtt, | |
| 284 probing_interval_ms); | |
| 285 } | |
| 286 } | |
| 274 } | 287 } |
| 275 } | 288 } |
| 276 | 289 |
| 277 bool SendSideCongestionController::HasNetworkParametersToReportChanged( | 290 bool SendSideCongestionController::HasNetworkParametersToReportChanged( |
| 278 uint32_t bitrate_bps, | 291 uint32_t bitrate_bps, |
| 279 uint8_t fraction_loss, | 292 uint8_t fraction_loss, |
| 280 int64_t rtt) { | 293 int64_t rtt) { |
| 281 rtc::CritScope cs(&network_state_lock_); | 294 rtc::CritScope cs(&network_state_lock_); |
| 282 bool changed = | 295 bool changed = |
| 283 last_reported_bitrate_bps_ != bitrate_bps || | 296 last_reported_bitrate_bps_ != bitrate_bps || |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 296 bool SendSideCongestionController::IsSendQueueFull() const { | 309 bool SendSideCongestionController::IsSendQueueFull() const { |
| 297 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; | 310 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; |
| 298 } | 311 } |
| 299 | 312 |
| 300 bool SendSideCongestionController::IsNetworkDown() const { | 313 bool SendSideCongestionController::IsNetworkDown() const { |
| 301 rtc::CritScope cs(&network_state_lock_); | 314 rtc::CritScope cs(&network_state_lock_); |
| 302 return network_state_ == kNetworkDown; | 315 return network_state_ == kNetworkDown; |
| 303 } | 316 } |
| 304 | 317 |
| 305 } // namespace webrtc | 318 } // namespace webrtc |
| OLD | NEW |