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 { |
30 | |
28 namespace { | 31 namespace { |
29 | 32 |
30 static const int64_t kRetransmitWindowSizeMs = 500; | 33 static const int64_t kRetransmitWindowSizeMs = 500; |
31 | 34 |
32 // Makes sure that the bitrate and the min, max values are in valid range. | 35 // Makes sure that the bitrate and the min, max values are in valid range. |
33 static void ClampBitrates(int* bitrate_bps, | 36 static void ClampBitrates(int* bitrate_bps, |
34 int* min_bitrate_bps, | 37 int* min_bitrate_bps, |
35 int* max_bitrate_bps) { | 38 int* max_bitrate_bps) { |
36 // TODO(holmer): We should make sure the default bitrates are set to 10 kbps, | 39 // TODO(holmer): We should make sure the default bitrates are set to 10 kbps, |
37 // and that we don't try to set the min bitrate to 0 from any applications. | 40 // and that we don't try to set the min bitrate to 0 from any applications. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 rtc::MakeUnique<AcknowledgedBitrateEstimator>()), | 95 rtc::MakeUnique<AcknowledgedBitrateEstimator>()), |
93 probe_controller_(new ProbeController(pacer_.get(), clock_)), | 96 probe_controller_(new ProbeController(pacer_.get(), clock_)), |
94 retransmission_rate_limiter_( | 97 retransmission_rate_limiter_( |
95 new RateLimiter(clock, kRetransmitWindowSizeMs)), | 98 new RateLimiter(clock, kRetransmitWindowSizeMs)), |
96 transport_feedback_adapter_(clock_), | 99 transport_feedback_adapter_(clock_), |
97 last_reported_bitrate_bps_(0), | 100 last_reported_bitrate_bps_(0), |
98 last_reported_fraction_loss_(0), | 101 last_reported_fraction_loss_(0), |
99 last_reported_rtt_(0), | 102 last_reported_rtt_(0), |
100 network_state_(kNetworkUp), | 103 network_state_(kNetworkUp), |
101 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()), | 104 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()), |
102 delay_based_bwe_(new DelayBasedBwe(event_log_, clock_)) { | 105 delay_based_bwe_(new DelayBasedBwe(event_log_, clock_)), |
106 alr_state_(rtc::MakeUnique<AlrState>()) { | |
103 delay_based_bwe_->SetMinBitrate(min_bitrate_bps_); | 107 delay_based_bwe_->SetMinBitrate(min_bitrate_bps_); |
104 } | 108 } |
105 | 109 |
106 SendSideCongestionController::~SendSideCongestionController() {} | 110 SendSideCongestionController::~SendSideCongestionController() {} |
107 | 111 |
108 void SendSideCongestionController::RegisterPacketFeedbackObserver( | 112 void SendSideCongestionController::RegisterPacketFeedbackObserver( |
109 PacketFeedbackObserver* observer) { | 113 PacketFeedbackObserver* observer) { |
110 transport_feedback_adapter_.RegisterPacketFeedbackObserver(observer); | 114 transport_feedback_adapter_.RegisterPacketFeedbackObserver(observer); |
111 } | 115 } |
112 | 116 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 pacing_info); | 274 pacing_info); |
271 } | 275 } |
272 | 276 |
273 void SendSideCongestionController::OnTransportFeedback( | 277 void SendSideCongestionController::OnTransportFeedback( |
274 const rtcp::TransportFeedback& feedback) { | 278 const rtcp::TransportFeedback& feedback) { |
275 RTC_DCHECK_RUNS_SERIALIZED(&worker_race_); | 279 RTC_DCHECK_RUNS_SERIALIZED(&worker_race_); |
276 transport_feedback_adapter_.OnTransportFeedback(feedback); | 280 transport_feedback_adapter_.OnTransportFeedback(feedback); |
277 std::vector<PacketFeedback> feedback_vector = ReceivedPacketFeedbackVector( | 281 std::vector<PacketFeedback> feedback_vector = ReceivedPacketFeedbackVector( |
278 transport_feedback_adapter_.GetTransportFeedbackVector()); | 282 transport_feedback_adapter_.GetTransportFeedbackVector()); |
279 SortPacketFeedbackVector(&feedback_vector); | 283 SortPacketFeedbackVector(&feedback_vector); |
284 if (alr_state_->ChangeWhenAlrStartTimeIs( | |
terelius
2017/07/13 10:46:01
I don't like this name. Is is unclear whether you
tschumi
2017/07/13 11:54:35
Done.
| |
285 pacer_->GetApplicationLimitedRegionStartTime()) == | |
286 AlrState::Change::kEnded) { | |
287 acknowledged_bitrate_estimator_->SetAlrEndedTimeMs(rtc::TimeMillis()); | |
288 } | |
289 | |
280 acknowledged_bitrate_estimator_->IncomingPacketFeedbackVector( | 290 acknowledged_bitrate_estimator_->IncomingPacketFeedbackVector( |
281 feedback_vector); | 291 feedback_vector); |
282 DelayBasedBwe::Result result; | 292 DelayBasedBwe::Result result; |
283 { | 293 { |
284 rtc::CritScope cs(&bwe_lock_); | 294 rtc::CritScope cs(&bwe_lock_); |
285 result = delay_based_bwe_->IncomingPacketFeedbackVector( | 295 result = delay_based_bwe_->IncomingPacketFeedbackVector( |
286 feedback_vector, acknowledged_bitrate_estimator_->bitrate_bps()); | 296 feedback_vector, acknowledged_bitrate_estimator_->bitrate_bps()); |
287 } | 297 } |
288 if (result.updated) | 298 if (result.updated) |
289 bitrate_controller_->OnDelayBasedBweResult(result); | 299 bitrate_controller_->OnDelayBasedBweResult(result); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
347 bool SendSideCongestionController::IsSendQueueFull() const { | 357 bool SendSideCongestionController::IsSendQueueFull() const { |
348 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; | 358 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; |
349 } | 359 } |
350 | 360 |
351 bool SendSideCongestionController::IsNetworkDown() const { | 361 bool SendSideCongestionController::IsNetworkDown() const { |
352 rtc::CritScope cs(&network_state_lock_); | 362 rtc::CritScope cs(&network_state_lock_); |
353 return network_state_ == kNetworkDown; | 363 return network_state_ == kNetworkDown; |
354 } | 364 } |
355 | 365 |
356 } // namespace webrtc | 366 } // namespace webrtc |
OLD | NEW |