Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: webrtc/modules/congestion_controller/congestion_controller.cc

Issue 2340763004: Add AlrDetector (Closed)
Patch Set: Fix ASAN/TSAN failures Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/congestion_controller.h" 11 #include "webrtc/modules/congestion_controller/include/congestion_controller.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/constructormagic.h" 18 #include "webrtc/base/constructormagic.h"
19 #include "webrtc/base/logging.h" 19 #include "webrtc/base/logging.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/base/thread_annotations.h" 22 #include "webrtc/base/thread_annotations.h"
23 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" 23 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
24 #include "webrtc/modules/congestion_controller/delay_based_bwe.h" 24 #include "webrtc/modules/congestion_controller/delay_based_bwe.h"
25 #include "webrtc/modules/congestion_controller/probe_controller.h" 25 #include "webrtc/modules/congestion_controller/probe_controller.h"
26 #include "webrtc/modules/congestion_controller/alr_detector.h"
26 #include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h" 27 #include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h"
27 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_s end_time.h" 28 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_s end_time.h"
28 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_singl e_stream.h" 29 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_singl e_stream.h"
29 #include "webrtc/modules/utility/include/process_thread.h" 30 #include "webrtc/modules/utility/include/process_thread.h"
30 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 31 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
31 #include "webrtc/video/payload_router.h" 32 #include "webrtc/video/payload_router.h"
32 33
33 namespace webrtc { 34 namespace webrtc {
34 namespace { 35 namespace {
35 36
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } // namespace 156 } // namespace
156 157
157 CongestionController::CongestionController( 158 CongestionController::CongestionController(
158 Clock* clock, 159 Clock* clock,
159 Observer* observer, 160 Observer* observer,
160 RemoteBitrateObserver* remote_bitrate_observer, 161 RemoteBitrateObserver* remote_bitrate_observer,
161 RtcEventLog* event_log) 162 RtcEventLog* event_log)
162 : clock_(clock), 163 : clock_(clock),
163 observer_(observer), 164 observer_(observer),
164 packet_router_(new PacketRouter()), 165 packet_router_(new PacketRouter()),
165 pacer_(new PacedSender(clock_, packet_router_.get())), 166 alr_detector_(new AlrDetector()),
167 pacer_(
168 new PacedSender(clock_, packet_router_.get(), alr_detector_.get())),
166 remote_bitrate_estimator_( 169 remote_bitrate_estimator_(
167 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)), 170 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)),
168 bitrate_controller_( 171 bitrate_controller_(
169 BitrateController::CreateBitrateController(clock_, event_log)), 172 BitrateController::CreateBitrateController(clock_, event_log)),
170 probe_controller_(new ProbeController(pacer_.get(), clock_)), 173 probe_controller_(new ProbeController(pacer_.get(), clock_)),
171 retransmission_rate_limiter_( 174 retransmission_rate_limiter_(
172 new RateLimiter(clock, kRetransmitWindowSizeMs)), 175 new RateLimiter(clock, kRetransmitWindowSizeMs)),
173 remote_estimator_proxy_(clock_, packet_router_.get()), 176 remote_estimator_proxy_(clock_, packet_router_.get()),
174 transport_feedback_adapter_(clock_), 177 transport_feedback_adapter_(clock_),
175 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps), 178 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps),
176 max_bitrate_bps_(0), 179 max_bitrate_bps_(0),
177 last_reported_bitrate_bps_(0), 180 last_reported_bitrate_bps_(0),
178 last_reported_fraction_loss_(0), 181 last_reported_fraction_loss_(0),
179 last_reported_rtt_(0), 182 last_reported_rtt_(0),
180 network_state_(kNetworkUp) { 183 network_state_(kNetworkUp) {
181 Init(); 184 Init();
182 } 185 }
183 186
184 CongestionController::CongestionController( 187 CongestionController::CongestionController(
185 Clock* clock, 188 Clock* clock,
186 Observer* observer, 189 Observer* observer,
187 RemoteBitrateObserver* remote_bitrate_observer, 190 RemoteBitrateObserver* remote_bitrate_observer,
188 RtcEventLog* event_log, 191 RtcEventLog* event_log,
189 std::unique_ptr<PacketRouter> packet_router, 192 std::unique_ptr<PacketRouter> packet_router,
190 std::unique_ptr<PacedSender> pacer) 193 std::unique_ptr<PacedSender> pacer)
191 : clock_(clock), 194 : clock_(clock),
192 observer_(observer), 195 observer_(observer),
193 packet_router_(std::move(packet_router)), 196 packet_router_(std::move(packet_router)),
197 alr_detector_(new AlrDetector()),
194 pacer_(std::move(pacer)), 198 pacer_(std::move(pacer)),
195 remote_bitrate_estimator_( 199 remote_bitrate_estimator_(
196 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)), 200 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)),
197 // Constructed last as this object calls the provided callback on 201 // Constructed last as this object calls the provided callback on
198 // construction. 202 // construction.
199 bitrate_controller_( 203 bitrate_controller_(
200 BitrateController::CreateBitrateController(clock_, event_log)), 204 BitrateController::CreateBitrateController(clock_, event_log)),
201 probe_controller_(new ProbeController(pacer_.get(), clock_)), 205 probe_controller_(new ProbeController(pacer_.get(), clock_)),
202 retransmission_rate_limiter_( 206 retransmission_rate_limiter_(
203 new RateLimiter(clock, kRetransmitWindowSizeMs)), 207 new RateLimiter(clock, kRetransmitWindowSizeMs)),
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 return; 343 return;
340 344
341 uint32_t bitrate_bps; 345 uint32_t bitrate_bps;
342 uint8_t fraction_loss; 346 uint8_t fraction_loss;
343 int64_t rtt; 347 int64_t rtt;
344 bool estimate_changed = bitrate_controller_->GetNetworkParameters( 348 bool estimate_changed = bitrate_controller_->GetNetworkParameters(
345 &bitrate_bps, &fraction_loss, &rtt); 349 &bitrate_bps, &fraction_loss, &rtt);
346 if (estimate_changed) { 350 if (estimate_changed) {
347 pacer_->SetEstimatedBitrate(bitrate_bps); 351 pacer_->SetEstimatedBitrate(bitrate_bps);
348 probe_controller_->SetEstimatedBitrate(bitrate_bps); 352 probe_controller_->SetEstimatedBitrate(bitrate_bps);
353 alr_detector_->SetEstimatedBitrate(bitrate_bps);
349 retransmission_rate_limiter_->SetMaxRate(bitrate_bps); 354 retransmission_rate_limiter_->SetMaxRate(bitrate_bps);
350 } 355 }
351 356
352 bitrate_bps = IsNetworkDown() || IsSendQueueFull() ? 0 : bitrate_bps; 357 bitrate_bps = IsNetworkDown() || IsSendQueueFull() ? 0 : bitrate_bps;
353 358
354 if (HasNetworkParametersToReportChanged(bitrate_bps, fraction_loss, rtt)) { 359 if (HasNetworkParametersToReportChanged(bitrate_bps, fraction_loss, rtt)) {
355 observer_->OnNetworkChanged(bitrate_bps, fraction_loss, rtt); 360 observer_->OnNetworkChanged(bitrate_bps, fraction_loss, rtt);
356 } 361 }
357 } 362 }
358 363
(...skipping 19 matching lines...) Expand all
378 bool CongestionController::IsSendQueueFull() const { 383 bool CongestionController::IsSendQueueFull() const {
379 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; 384 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs;
380 } 385 }
381 386
382 bool CongestionController::IsNetworkDown() const { 387 bool CongestionController::IsNetworkDown() const {
383 rtc::CritScope cs(&critsect_); 388 rtc::CritScope cs(&critsect_);
384 return network_state_ == kNetworkDown; 389 return network_state_ == kNetworkDown;
385 } 390 }
386 391
387 } // namespace webrtc 392 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698