| 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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 } | 288 } |
| 289 | 289 |
| 290 void SendSideCongestionController::OnSentPacket( | 290 void SendSideCongestionController::OnSentPacket( |
| 291 const rtc::SentPacket& sent_packet) { | 291 const rtc::SentPacket& sent_packet) { |
| 292 // We're not interested in packets without an id, which may be stun packets, | 292 // We're not interested in packets without an id, which may be stun packets, |
| 293 // etc, sent on the same transport. | 293 // etc, sent on the same transport. |
| 294 if (sent_packet.packet_id == -1) | 294 if (sent_packet.packet_id == -1) |
| 295 return; | 295 return; |
| 296 transport_feedback_adapter_.OnSentPacket(sent_packet.packet_id, | 296 transport_feedback_adapter_.OnSentPacket(sent_packet.packet_id, |
| 297 sent_packet.send_time_ms); | 297 sent_packet.send_time_ms); |
| 298 LimitOutstandingBytes(transport_feedback_adapter_.GetOutstandingBytes()); | 298 if (in_cwnd_experiment_) |
| 299 LimitOutstandingBytes(transport_feedback_adapter_.GetOutstandingBytes()); |
| 299 } | 300 } |
| 300 | 301 |
| 301 void SendSideCongestionController::OnRttUpdate(int64_t avg_rtt_ms, | 302 void SendSideCongestionController::OnRttUpdate(int64_t avg_rtt_ms, |
| 302 int64_t max_rtt_ms) { | 303 int64_t max_rtt_ms) { |
| 303 rtc::CritScope cs(&bwe_lock_); | 304 rtc::CritScope cs(&bwe_lock_); |
| 304 delay_based_bwe_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); | 305 delay_based_bwe_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); |
| 305 } | 306 } |
| 306 | 307 |
| 307 int64_t SendSideCongestionController::TimeUntilNextProcess() { | 308 int64_t SendSideCongestionController::TimeUntilNextProcess() { |
| 308 return bitrate_controller_->TimeUntilNextProcess(); | 309 return bitrate_controller_->TimeUntilNextProcess(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 result = delay_based_bwe_->IncomingPacketFeedbackVector( | 363 result = delay_based_bwe_->IncomingPacketFeedbackVector( |
| 363 feedback_vector, acknowledged_bitrate_estimator_->bitrate_bps()); | 364 feedback_vector, acknowledged_bitrate_estimator_->bitrate_bps()); |
| 364 } | 365 } |
| 365 if (result.updated) { | 366 if (result.updated) { |
| 366 bitrate_controller_->OnDelayBasedBweResult(result); | 367 bitrate_controller_->OnDelayBasedBweResult(result); |
| 367 // Update the estimate in the ProbeController, in case we want to probe. | 368 // Update the estimate in the ProbeController, in case we want to probe. |
| 368 MaybeTriggerOnNetworkChanged(); | 369 MaybeTriggerOnNetworkChanged(); |
| 369 } | 370 } |
| 370 if (result.recovered_from_overuse) | 371 if (result.recovered_from_overuse) |
| 371 probe_controller_->RequestProbe(); | 372 probe_controller_->RequestProbe(); |
| 372 LimitOutstandingBytes(transport_feedback_adapter_.GetOutstandingBytes()); | 373 if (in_cwnd_experiment_) |
| 374 LimitOutstandingBytes(transport_feedback_adapter_.GetOutstandingBytes()); |
| 373 } | 375 } |
| 374 | 376 |
| 375 void SendSideCongestionController::LimitOutstandingBytes( | 377 void SendSideCongestionController::LimitOutstandingBytes( |
| 376 size_t num_outstanding_bytes) { | 378 size_t num_outstanding_bytes) { |
| 377 if (!in_cwnd_experiment_) | 379 RTC_DCHECK(in_cwnd_experiment_); |
| 380 rtc::CritScope lock(&network_state_lock_); |
| 381 rtc::Optional<int64_t> min_rtt_ms = |
| 382 transport_feedback_adapter_.GetMinFeedbackLoopRtt(); |
| 383 // No valid RTT. Could be because send-side BWE isn't used, in which case |
| 384 // we don't try to limit the outstanding packets. |
| 385 if (!min_rtt_ms) |
| 378 return; | 386 return; |
| 379 { | 387 const size_t kMinCwndBytes = 2 * 1500; |
| 380 rtc::CritScope lock(&network_state_lock_); | 388 size_t max_outstanding_bytes = |
| 381 rtc::Optional<int64_t> min_rtt_ms = | 389 std::max<size_t>((*min_rtt_ms + accepted_queue_ms_) * |
| 382 transport_feedback_adapter_.GetMinFeedbackLoopRtt(); | 390 last_reported_bitrate_bps_ / 1000 / 8, |
| 383 // No valid RTT. Could be because send-side BWE isn't used, in which case | 391 kMinCwndBytes); |
| 384 // we don't try to limit the outstanding packets. | 392 LOG(LS_INFO) << clock_->TimeInMilliseconds() |
| 385 if (!min_rtt_ms) | 393 << " Outstanding bytes: " << num_outstanding_bytes |
| 386 return; | 394 << " pacer queue: " << pacer_->QueueInMs() |
| 387 const size_t kMinCwndBytes = 2 * 1500; | 395 << " max outstanding: " << max_outstanding_bytes; |
| 388 size_t max_outstanding_bytes = | 396 LOG(LS_INFO) << "Feedback rtt: " << *min_rtt_ms |
| 389 std::max<size_t>((*min_rtt_ms + accepted_queue_ms_) * | 397 << " Bitrate: " << last_reported_bitrate_bps_; |
| 390 last_reported_bitrate_bps_ / 1000 / 8, | 398 pause_pacer_ = num_outstanding_bytes > max_outstanding_bytes; |
| 391 kMinCwndBytes); | |
| 392 LOG(LS_INFO) << clock_->TimeInMilliseconds() | |
| 393 << " Outstanding bytes: " << num_outstanding_bytes | |
| 394 << " pacer queue: " << pacer_->QueueInMs() | |
| 395 << " max outstanding: " << max_outstanding_bytes; | |
| 396 LOG(LS_INFO) << "Feedback rtt: " << *min_rtt_ms | |
| 397 << " Bitrate: " << last_reported_bitrate_bps_; | |
| 398 pause_pacer_ = num_outstanding_bytes > max_outstanding_bytes; | |
| 399 } | |
| 400 } | 399 } |
| 401 | 400 |
| 402 std::vector<PacketFeedback> | 401 std::vector<PacketFeedback> |
| 403 SendSideCongestionController::GetTransportFeedbackVector() const { | 402 SendSideCongestionController::GetTransportFeedbackVector() const { |
| 404 RTC_DCHECK_RUNS_SERIALIZED(&worker_race_); | 403 RTC_DCHECK_RUNS_SERIALIZED(&worker_race_); |
| 405 return transport_feedback_adapter_.GetTransportFeedbackVector(); | 404 return transport_feedback_adapter_.GetTransportFeedbackVector(); |
| 406 } | 405 } |
| 407 | 406 |
| 408 void SendSideCongestionController::MaybeTriggerOnNetworkChanged() { | 407 void SendSideCongestionController::MaybeTriggerOnNetworkChanged() { |
| 409 uint32_t bitrate_bps; | 408 uint32_t bitrate_bps; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 bool SendSideCongestionController::IsSendQueueFull() const { | 456 bool SendSideCongestionController::IsSendQueueFull() const { |
| 458 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; | 457 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; |
| 459 } | 458 } |
| 460 | 459 |
| 461 bool SendSideCongestionController::IsNetworkDown() const { | 460 bool SendSideCongestionController::IsNetworkDown() const { |
| 462 rtc::CritScope cs(&network_state_lock_); | 461 rtc::CritScope cs(&network_state_lock_); |
| 463 return network_state_ == kNetworkDown; | 462 return network_state_ == kNetworkDown; |
| 464 } | 463 } |
| 465 | 464 |
| 466 } // namespace webrtc | 465 } // namespace webrtc |
| OLD | NEW |