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

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

Issue 2580843002: Change return type of CongestionController::pacer() method.
Patch Set: Created 4 years 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/logging.h" 18 #include "webrtc/base/logging.h"
19 #include "webrtc/base/rate_limiter.h" 19 #include "webrtc/base/rate_limiter.h"
20 #include "webrtc/base/socket.h" 20 #include "webrtc/base/socket.h"
21 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" 21 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
22 #include "webrtc/modules/congestion_controller/probe_controller.h" 22 #include "webrtc/modules/congestion_controller/probe_controller.h"
23 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" 23 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h"
24 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_s end_time.h" 24 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_s end_time.h"
25 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_singl e_stream.h" 25 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_singl e_stream.h"
26 #include "webrtc/modules/utility/include/process_thread.h"
26 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 27 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
27 28
28 namespace webrtc { 29 namespace webrtc {
29 namespace { 30 namespace {
30 31
31 static const uint32_t kTimeOffsetSwitchThreshold = 30; 32 static const uint32_t kTimeOffsetSwitchThreshold = 30;
32 static const int64_t kRetransmitWindowSizeMs = 500; 33 static const int64_t kRetransmitWindowSizeMs = 500;
33 34
34 // 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.
35 static void ClampBitrates(int* bitrate_bps, 36 static void ClampBitrates(int* bitrate_bps,
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 CongestionController::CongestionController( 167 CongestionController::CongestionController(
167 Clock* clock, 168 Clock* clock,
168 Observer* observer, 169 Observer* observer,
169 RemoteBitrateObserver* remote_bitrate_observer, 170 RemoteBitrateObserver* remote_bitrate_observer,
170 RtcEventLog* event_log, 171 RtcEventLog* event_log,
171 PacketRouter* packet_router, 172 PacketRouter* packet_router,
172 std::unique_ptr<PacedSender> pacer) 173 std::unique_ptr<PacedSender> pacer)
173 : clock_(clock), 174 : clock_(clock),
174 observer_(observer), 175 observer_(observer),
175 packet_router_(packet_router), 176 packet_router_(packet_router),
177 pacer_thread_(ProcessThread::Create("PacerThread")),
perkj_webrtc 2017/01/02 09:18:58 There are upstreams projects that use CongestionCo
nisse-webrtc 2017/01/09 13:43:46 I can try moving it to the pacer itself. One obvio
176 pacer_(std::move(pacer)), 178 pacer_(std::move(pacer)),
177 remote_bitrate_estimator_( 179 remote_bitrate_estimator_(
178 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)), 180 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)),
179 // Constructed last as this object calls the provided callback on 181 // Constructed last as this object calls the provided callback on
180 // construction. 182 // construction.
181 bitrate_controller_( 183 bitrate_controller_(
182 BitrateController::CreateBitrateController(clock_, event_log)), 184 BitrateController::CreateBitrateController(clock_, event_log)),
183 probe_controller_(new ProbeController(pacer_.get(), clock_)), 185 probe_controller_(new ProbeController(pacer_.get(), clock_)),
184 retransmission_rate_limiter_( 186 retransmission_rate_limiter_(
185 new RateLimiter(clock, kRetransmitWindowSizeMs)), 187 new RateLimiter(clock, kRetransmitWindowSizeMs)),
186 remote_estimator_proxy_(clock_, packet_router_), 188 remote_estimator_proxy_(clock_, packet_router_),
187 transport_feedback_adapter_(clock_, bitrate_controller_.get()), 189 transport_feedback_adapter_(clock_, bitrate_controller_.get()),
188 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()), 190 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()),
189 max_bitrate_bps_(0), 191 max_bitrate_bps_(0),
190 last_reported_bitrate_bps_(0), 192 last_reported_bitrate_bps_(0),
191 last_reported_fraction_loss_(0), 193 last_reported_fraction_loss_(0),
192 last_reported_rtt_(0), 194 last_reported_rtt_(0),
193 network_state_(kNetworkUp) { 195 network_state_(kNetworkUp) {
194 transport_feedback_adapter_.InitBwe(); 196 transport_feedback_adapter_.InitBwe();
195 transport_feedback_adapter_.SetMinBitrate(min_bitrate_bps_); 197 transport_feedback_adapter_.SetMinBitrate(min_bitrate_bps_);
198
199 pacer_thread_->RegisterModule(pacer_.get());
200 pacer_thread_->RegisterModule(&remote_estimator_proxy_);
201 pacer_thread_->Start();
202
196 } 203 }
197 204
198 CongestionController::~CongestionController() {} 205 CongestionController::~CongestionController() {
206 pacer_thread_->Stop();
207 pacer_thread_->DeRegisterModule(pacer_.get());
208 pacer_thread_->DeRegisterModule(&remote_estimator_proxy_);
209 }
199 210
200 void CongestionController::SetBweBitrates(int min_bitrate_bps, 211 void CongestionController::SetBweBitrates(int min_bitrate_bps,
201 int start_bitrate_bps, 212 int start_bitrate_bps,
202 int max_bitrate_bps) { 213 int max_bitrate_bps) {
203 ClampBitrates(&start_bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); 214 ClampBitrates(&start_bitrate_bps, &min_bitrate_bps, &max_bitrate_bps);
204 bitrate_controller_->SetBitrates(start_bitrate_bps, 215 bitrate_controller_->SetBitrates(start_bitrate_bps,
205 min_bitrate_bps, 216 min_bitrate_bps,
206 max_bitrate_bps); 217 max_bitrate_bps);
207 218
208 probe_controller_->SetBitrates(min_bitrate_bps, start_bitrate_bps, 219 probe_controller_->SetBitrates(min_bitrate_bps, start_bitrate_bps,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 bool CongestionController::IsSendQueueFull() const { 371 bool CongestionController::IsSendQueueFull() const {
361 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; 372 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs;
362 } 373 }
363 374
364 bool CongestionController::IsNetworkDown() const { 375 bool CongestionController::IsNetworkDown() const {
365 rtc::CritScope cs(&critsect_); 376 rtc::CritScope cs(&critsect_);
366 return network_state_ == kNetworkDown; 377 return network_state_ == kNetworkDown;
367 } 378 }
368 379
369 } // namespace webrtc 380 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698