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/base/checks.h" | 17 #include "webrtc/base/checks.h" |
18 #include "webrtc/base/logging.h" | 18 #include "webrtc/base/logging.h" |
19 #include "webrtc/base/ptr_util.h" | 19 #include "webrtc/base/ptr_util.h" |
20 #include "webrtc/base/rate_limiter.h" | 20 #include "webrtc/base/rate_limiter.h" |
21 #include "webrtc/base/socket.h" | 21 #include "webrtc/base/socket.h" |
22 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | 22 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
23 #include "webrtc/modules/congestion_controller/acknowledge_bitrate_estimator.h" | 23 #include "webrtc/modules/congestion_controller/acknowledged_bitrate_estimator.h" |
24 #include "webrtc/modules/congestion_controller/probe_controller.h" | 24 #include "webrtc/modules/congestion_controller/probe_controller.h" |
25 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" | 25 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" |
26 | 26 |
27 namespace webrtc { | 27 namespace webrtc { |
28 namespace { | 28 namespace { |
29 | 29 |
30 static const int64_t kRetransmitWindowSizeMs = 500; | 30 static const int64_t kRetransmitWindowSizeMs = 500; |
31 | 31 |
32 // Makes sure that the bitrate and the min, max values are in valid range. | 32 // Makes sure that the bitrate and the min, max values are in valid range. |
33 static void ClampBitrates(int* bitrate_bps, | 33 static void ClampBitrates(int* bitrate_bps, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 Observer* observer, | 82 Observer* observer, |
83 RtcEventLog* event_log, | 83 RtcEventLog* event_log, |
84 std::unique_ptr<PacedSender> pacer) | 84 std::unique_ptr<PacedSender> pacer) |
85 : clock_(clock), | 85 : clock_(clock), |
86 observer_(observer), | 86 observer_(observer), |
87 event_log_(event_log), | 87 event_log_(event_log), |
88 pacer_(std::move(pacer)), | 88 pacer_(std::move(pacer)), |
89 bitrate_controller_( | 89 bitrate_controller_( |
90 BitrateController::CreateBitrateController(clock_, event_log)), | 90 BitrateController::CreateBitrateController(clock_, event_log)), |
91 acknowledged_bitrate_estimator_( | 91 acknowledged_bitrate_estimator_( |
92 rtc::MakeUnique<AcknowledgedBitrateEstimator>()), | 92 rtc::MakeUnique<AcknowledgedBitrateEstimator>( |
| 93 rtc::MakeUnique<BitrateEstimatorCreator>())), |
93 probe_controller_(new ProbeController(pacer_.get(), clock_)), | 94 probe_controller_(new ProbeController(pacer_.get(), clock_)), |
94 retransmission_rate_limiter_( | 95 retransmission_rate_limiter_( |
95 new RateLimiter(clock, kRetransmitWindowSizeMs)), | 96 new RateLimiter(clock, kRetransmitWindowSizeMs)), |
96 transport_feedback_adapter_(clock_), | 97 transport_feedback_adapter_(clock_), |
97 last_reported_bitrate_bps_(0), | 98 last_reported_bitrate_bps_(0), |
98 last_reported_fraction_loss_(0), | 99 last_reported_fraction_loss_(0), |
99 last_reported_rtt_(0), | 100 last_reported_rtt_(0), |
100 network_state_(kNetworkUp), | 101 network_state_(kNetworkUp), |
101 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()), | 102 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()), |
102 delay_based_bwe_(new DelayBasedBwe(event_log_, clock_)) { | 103 delay_based_bwe_(new DelayBasedBwe(event_log_, clock_)) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // no longer exposed outside SendSideCongestionController. | 162 // no longer exposed outside SendSideCongestionController. |
162 bitrate_controller_->ResetBitrates(bitrate_bps, min_bitrate_bps, | 163 bitrate_controller_->ResetBitrates(bitrate_bps, min_bitrate_bps, |
163 max_bitrate_bps); | 164 max_bitrate_bps); |
164 | 165 |
165 transport_feedback_adapter_.SetNetworkIds(network_route.local_network_id, | 166 transport_feedback_adapter_.SetNetworkIds(network_route.local_network_id, |
166 network_route.remote_network_id); | 167 network_route.remote_network_id); |
167 { | 168 { |
168 rtc::CritScope cs(&bwe_lock_); | 169 rtc::CritScope cs(&bwe_lock_); |
169 min_bitrate_bps_ = min_bitrate_bps; | 170 min_bitrate_bps_ = min_bitrate_bps; |
170 delay_based_bwe_.reset(new DelayBasedBwe(event_log_, clock_)); | 171 delay_based_bwe_.reset(new DelayBasedBwe(event_log_, clock_)); |
171 acknowledged_bitrate_estimator_.reset(new AcknowledgedBitrateEstimator()); | 172 acknowledged_bitrate_estimator_.reset(new AcknowledgedBitrateEstimator( |
| 173 rtc::MakeUnique<BitrateEstimatorCreator>())); |
172 delay_based_bwe_->SetStartBitrate(bitrate_bps); | 174 delay_based_bwe_->SetStartBitrate(bitrate_bps); |
173 delay_based_bwe_->SetMinBitrate(min_bitrate_bps); | 175 delay_based_bwe_->SetMinBitrate(min_bitrate_bps); |
174 } | 176 } |
175 | 177 |
176 probe_controller_->Reset(); | 178 probe_controller_->Reset(); |
177 probe_controller_->SetBitrates(min_bitrate_bps, bitrate_bps, max_bitrate_bps); | 179 probe_controller_->SetBitrates(min_bitrate_bps, bitrate_bps, max_bitrate_bps); |
178 | 180 |
179 MaybeTriggerOnNetworkChanged(); | 181 MaybeTriggerOnNetworkChanged(); |
180 } | 182 } |
181 | 183 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 } | 274 } |
273 | 275 |
274 void SendSideCongestionController::OnTransportFeedback( | 276 void SendSideCongestionController::OnTransportFeedback( |
275 const rtcp::TransportFeedback& feedback) { | 277 const rtcp::TransportFeedback& feedback) { |
276 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 278 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
277 transport_feedback_adapter_.OnTransportFeedback(feedback); | 279 transport_feedback_adapter_.OnTransportFeedback(feedback); |
278 std::vector<PacketFeedback> feedback_vector = ReceivedPacketFeedbackVector( | 280 std::vector<PacketFeedback> feedback_vector = ReceivedPacketFeedbackVector( |
279 transport_feedback_adapter_.GetTransportFeedbackVector()); | 281 transport_feedback_adapter_.GetTransportFeedbackVector()); |
280 SortPacketFeedbackVector(&feedback_vector); | 282 SortPacketFeedbackVector(&feedback_vector); |
281 acknowledged_bitrate_estimator_->IncomingPacketFeedbackVector( | 283 acknowledged_bitrate_estimator_->IncomingPacketFeedbackVector( |
282 feedback_vector); | 284 feedback_vector, |
| 285 static_cast<bool>(pacer_->GetApplicationLimitedRegionStartTime())); |
283 DelayBasedBwe::Result result; | 286 DelayBasedBwe::Result result; |
284 { | 287 { |
285 rtc::CritScope cs(&bwe_lock_); | 288 rtc::CritScope cs(&bwe_lock_); |
286 result = delay_based_bwe_->IncomingPacketFeedbackVector( | 289 result = delay_based_bwe_->IncomingPacketFeedbackVector( |
287 feedback_vector, acknowledged_bitrate_estimator_->bitrate_bps()); | 290 feedback_vector, acknowledged_bitrate_estimator_->bitrate_bps()); |
288 } | 291 } |
289 if (result.updated) | 292 if (result.updated) |
290 bitrate_controller_->OnDelayBasedBweResult(result); | 293 bitrate_controller_->OnDelayBasedBweResult(result); |
291 } | 294 } |
292 | 295 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 bool SendSideCongestionController::IsSendQueueFull() const { | 351 bool SendSideCongestionController::IsSendQueueFull() const { |
349 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; | 352 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; |
350 } | 353 } |
351 | 354 |
352 bool SendSideCongestionController::IsNetworkDown() const { | 355 bool SendSideCongestionController::IsNetworkDown() const { |
353 rtc::CritScope cs(&network_state_lock_); | 356 rtc::CritScope cs(&network_state_lock_); |
354 return network_state_ == kNetworkDown; | 357 return network_state_ == kNetworkDown; |
355 } | 358 } |
356 | 359 |
357 } // namespace webrtc | 360 } // namespace webrtc |
OLD | NEW |