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 |
11 #include "webrtc/modules/congestion_controller/include/send_side_congestion_cont
roller.h" | 11 #include "webrtc/modules/congestion_controller/include/send_side_congestion_cont
roller.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <memory> | 14 #include <memory> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | 17 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
18 #include "webrtc/modules/congestion_controller/acknowledge_bitrate_estimator.h" | 18 #include "webrtc/modules/congestion_controller/acknowledged_bitrate_estimator.h" |
19 #include "webrtc/modules/congestion_controller/probe_controller.h" | 19 #include "webrtc/modules/congestion_controller/probe_controller.h" |
| 20 #include "webrtc/modules/pacing/alr_detector.h" |
20 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" | 21 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" |
21 #include "webrtc/rtc_base/checks.h" | 22 #include "webrtc/rtc_base/checks.h" |
22 #include "webrtc/rtc_base/logging.h" | 23 #include "webrtc/rtc_base/logging.h" |
23 #include "webrtc/rtc_base/ptr_util.h" | 24 #include "webrtc/rtc_base/ptr_util.h" |
24 #include "webrtc/rtc_base/rate_limiter.h" | 25 #include "webrtc/rtc_base/rate_limiter.h" |
25 #include "webrtc/rtc_base/socket.h" | 26 #include "webrtc/rtc_base/socket.h" |
| 27 #include "webrtc/rtc_base/timeutils.h" |
26 | 28 |
27 namespace webrtc { | 29 namespace webrtc { |
28 namespace { | 30 namespace { |
29 | 31 |
30 static const int64_t kRetransmitWindowSizeMs = 500; | 32 static const int64_t kRetransmitWindowSizeMs = 500; |
31 | 33 |
32 // Makes sure that the bitrate and the min, max values are in valid range. | 34 // Makes sure that the bitrate and the min, max values are in valid range. |
33 static void ClampBitrates(int* bitrate_bps, | 35 static void ClampBitrates(int* bitrate_bps, |
34 int* min_bitrate_bps, | 36 int* min_bitrate_bps, |
35 int* max_bitrate_bps) { | 37 int* max_bitrate_bps) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 rtc::MakeUnique<AcknowledgedBitrateEstimator>()), | 94 rtc::MakeUnique<AcknowledgedBitrateEstimator>()), |
93 probe_controller_(new ProbeController(pacer_.get(), clock_)), | 95 probe_controller_(new ProbeController(pacer_.get(), clock_)), |
94 retransmission_rate_limiter_( | 96 retransmission_rate_limiter_( |
95 new RateLimiter(clock, kRetransmitWindowSizeMs)), | 97 new RateLimiter(clock, kRetransmitWindowSizeMs)), |
96 transport_feedback_adapter_(clock_), | 98 transport_feedback_adapter_(clock_), |
97 last_reported_bitrate_bps_(0), | 99 last_reported_bitrate_bps_(0), |
98 last_reported_fraction_loss_(0), | 100 last_reported_fraction_loss_(0), |
99 last_reported_rtt_(0), | 101 last_reported_rtt_(0), |
100 network_state_(kNetworkUp), | 102 network_state_(kNetworkUp), |
101 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()), | 103 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()), |
102 delay_based_bwe_(new DelayBasedBwe(event_log_, clock_)) { | 104 delay_based_bwe_(new DelayBasedBwe(event_log_, clock_)), |
| 105 was_in_alr_(0) { |
103 delay_based_bwe_->SetMinBitrate(min_bitrate_bps_); | 106 delay_based_bwe_->SetMinBitrate(min_bitrate_bps_); |
104 } | 107 } |
105 | 108 |
106 SendSideCongestionController::~SendSideCongestionController() {} | 109 SendSideCongestionController::~SendSideCongestionController() {} |
107 | 110 |
108 void SendSideCongestionController::RegisterPacketFeedbackObserver( | 111 void SendSideCongestionController::RegisterPacketFeedbackObserver( |
109 PacketFeedbackObserver* observer) { | 112 PacketFeedbackObserver* observer) { |
110 transport_feedback_adapter_.RegisterPacketFeedbackObserver(observer); | 113 transport_feedback_adapter_.RegisterPacketFeedbackObserver(observer); |
111 } | 114 } |
112 | 115 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 pacing_info); | 273 pacing_info); |
271 } | 274 } |
272 | 275 |
273 void SendSideCongestionController::OnTransportFeedback( | 276 void SendSideCongestionController::OnTransportFeedback( |
274 const rtcp::TransportFeedback& feedback) { | 277 const rtcp::TransportFeedback& feedback) { |
275 RTC_DCHECK_RUNS_SERIALIZED(&worker_race_); | 278 RTC_DCHECK_RUNS_SERIALIZED(&worker_race_); |
276 transport_feedback_adapter_.OnTransportFeedback(feedback); | 279 transport_feedback_adapter_.OnTransportFeedback(feedback); |
277 std::vector<PacketFeedback> feedback_vector = ReceivedPacketFeedbackVector( | 280 std::vector<PacketFeedback> feedback_vector = ReceivedPacketFeedbackVector( |
278 transport_feedback_adapter_.GetTransportFeedbackVector()); | 281 transport_feedback_adapter_.GetTransportFeedbackVector()); |
279 SortPacketFeedbackVector(&feedback_vector); | 282 SortPacketFeedbackVector(&feedback_vector); |
| 283 |
| 284 bool currently_in_alr = |
| 285 pacer_->GetApplicationLimitedRegionStartTime().has_value(); |
| 286 if (!currently_in_alr && was_in_alr_) { |
| 287 acknowledged_bitrate_estimator_->SetAlrEndedTimeMs(rtc::TimeMillis()); |
| 288 } |
| 289 was_in_alr_ = currently_in_alr; |
| 290 |
280 acknowledged_bitrate_estimator_->IncomingPacketFeedbackVector( | 291 acknowledged_bitrate_estimator_->IncomingPacketFeedbackVector( |
281 feedback_vector); | 292 feedback_vector); |
282 DelayBasedBwe::Result result; | 293 DelayBasedBwe::Result result; |
283 { | 294 { |
284 rtc::CritScope cs(&bwe_lock_); | 295 rtc::CritScope cs(&bwe_lock_); |
285 result = delay_based_bwe_->IncomingPacketFeedbackVector( | 296 result = delay_based_bwe_->IncomingPacketFeedbackVector( |
286 feedback_vector, acknowledged_bitrate_estimator_->bitrate_bps()); | 297 feedback_vector, acknowledged_bitrate_estimator_->bitrate_bps()); |
287 } | 298 } |
288 if (result.updated) | 299 if (result.updated) |
289 bitrate_controller_->OnDelayBasedBweResult(result); | 300 bitrate_controller_->OnDelayBasedBweResult(result); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 bool SendSideCongestionController::IsSendQueueFull() const { | 358 bool SendSideCongestionController::IsSendQueueFull() const { |
348 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; | 359 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; |
349 } | 360 } |
350 | 361 |
351 bool SendSideCongestionController::IsNetworkDown() const { | 362 bool SendSideCongestionController::IsNetworkDown() const { |
352 rtc::CritScope cs(&network_state_lock_); | 363 rtc::CritScope cs(&network_state_lock_); |
353 return network_state_ == kNetworkDown; | 364 return network_state_ == kNetworkDown; |
354 } | 365 } |
355 | 366 |
356 } // namespace webrtc | 367 } // namespace webrtc |
OLD | NEW |