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

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

Issue 2246403002: CongestionController::SetBweBitrates may now trigger probing. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Don't set probing state to active in the case of no clusters. Created 4 years, 4 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
« no previous file with comments | « no previous file | webrtc/modules/congestion_controller/include/congestion_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 pacer_(new PacedSender(clock_, packet_router_.get())), 164 pacer_(new PacedSender(clock_, packet_router_.get())),
165 remote_bitrate_estimator_( 165 remote_bitrate_estimator_(
166 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)), 166 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)),
167 bitrate_controller_( 167 bitrate_controller_(
168 BitrateController::CreateBitrateController(clock_, event_log)), 168 BitrateController::CreateBitrateController(clock_, event_log)),
169 retransmission_rate_limiter_( 169 retransmission_rate_limiter_(
170 new RateLimiter(clock, kRetransmitWindowSizeMs)), 170 new RateLimiter(clock, kRetransmitWindowSizeMs)),
171 remote_estimator_proxy_(clock_, packet_router_.get()), 171 remote_estimator_proxy_(clock_, packet_router_.get()),
172 transport_feedback_adapter_(bitrate_controller_.get(), clock_), 172 transport_feedback_adapter_(bitrate_controller_.get(), clock_),
173 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps), 173 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps),
174 max_bitrate_bps_(0),
174 last_reported_bitrate_bps_(0), 175 last_reported_bitrate_bps_(0),
175 last_reported_fraction_loss_(0), 176 last_reported_fraction_loss_(0),
176 last_reported_rtt_(0), 177 last_reported_rtt_(0),
177 network_state_(kNetworkUp) { 178 network_state_(kNetworkUp) {
178 Init(); 179 Init();
179 } 180 }
180 181
181 CongestionController::CongestionController( 182 CongestionController::CongestionController(
182 Clock* clock, 183 Clock* clock,
183 Observer* observer, 184 Observer* observer,
184 RemoteBitrateObserver* remote_bitrate_observer, 185 RemoteBitrateObserver* remote_bitrate_observer,
185 RtcEventLog* event_log, 186 RtcEventLog* event_log,
186 std::unique_ptr<PacketRouter> packet_router, 187 std::unique_ptr<PacketRouter> packet_router,
187 std::unique_ptr<PacedSender> pacer) 188 std::unique_ptr<PacedSender> pacer)
188 : clock_(clock), 189 : clock_(clock),
189 observer_(observer), 190 observer_(observer),
190 packet_router_(std::move(packet_router)), 191 packet_router_(std::move(packet_router)),
191 pacer_(std::move(pacer)), 192 pacer_(std::move(pacer)),
192 remote_bitrate_estimator_( 193 remote_bitrate_estimator_(
193 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)), 194 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)),
194 // Constructed last as this object calls the provided callback on 195 // Constructed last as this object calls the provided callback on
195 // construction. 196 // construction.
196 bitrate_controller_( 197 bitrate_controller_(
197 BitrateController::CreateBitrateController(clock_, event_log)), 198 BitrateController::CreateBitrateController(clock_, event_log)),
198 retransmission_rate_limiter_( 199 retransmission_rate_limiter_(
199 new RateLimiter(clock, kRetransmitWindowSizeMs)), 200 new RateLimiter(clock, kRetransmitWindowSizeMs)),
200 remote_estimator_proxy_(clock_, packet_router_.get()), 201 remote_estimator_proxy_(clock_, packet_router_.get()),
201 transport_feedback_adapter_(bitrate_controller_.get(), clock_), 202 transport_feedback_adapter_(bitrate_controller_.get(), clock_),
202 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps), 203 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps),
204 max_bitrate_bps_(0),
203 last_reported_bitrate_bps_(0), 205 last_reported_bitrate_bps_(0),
204 last_reported_fraction_loss_(0), 206 last_reported_fraction_loss_(0),
205 last_reported_rtt_(0), 207 last_reported_rtt_(0),
206 network_state_(kNetworkUp) { 208 network_state_(kNetworkUp) {
207 Init(); 209 Init();
208 } 210 }
209 211
210 CongestionController::~CongestionController() {} 212 CongestionController::~CongestionController() {}
211 213
212 void CongestionController::Init() { 214 void CongestionController::Init() {
213 transport_feedback_adapter_.SetBitrateEstimator( 215 transport_feedback_adapter_.SetBitrateEstimator(
214 new DelayBasedBwe(&transport_feedback_adapter_, clock_)); 216 new DelayBasedBwe(&transport_feedback_adapter_, clock_));
215 transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate( 217 transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate(
216 min_bitrate_bps_); 218 min_bitrate_bps_);
219 pacer_->CreateProbeCluster(900000, 6);
220 pacer_->CreateProbeCluster(1800000, 5);
217 } 221 }
218 222
219 void CongestionController::SetBweBitrates(int min_bitrate_bps, 223 void CongestionController::SetBweBitrates(int min_bitrate_bps,
220 int start_bitrate_bps, 224 int start_bitrate_bps,
221 int max_bitrate_bps) { 225 int max_bitrate_bps) {
222 ClampBitrates(&start_bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); 226 ClampBitrates(&start_bitrate_bps, &min_bitrate_bps, &max_bitrate_bps);
223 bitrate_controller_->SetBitrates(start_bitrate_bps, 227 bitrate_controller_->SetBitrates(start_bitrate_bps,
224 min_bitrate_bps, 228 min_bitrate_bps,
225 max_bitrate_bps); 229 max_bitrate_bps);
226 230
231 {
232 // Only do probing if:
233 // - we are mid-call, which we consider to be if
234 // |last_reported_bitrate_bps_| != 0, and
235 // - the current bitrate is lower than the new |max_bitrate_bps|, and
236 // - we actually want to increase the |max_bitrate_bps_|.
237 rtc::CritScope cs(&critsect_);
238 if (last_reported_bitrate_bps_ != 0 &&
239 last_reported_bitrate_bps_ < static_cast<uint32_t>(max_bitrate_bps) &&
240 max_bitrate_bps > max_bitrate_bps_) {
241 pacer_->CreateProbeCluster(max_bitrate_bps, 5);
242 }
243 }
244 max_bitrate_bps_ = max_bitrate_bps;
245
227 if (remote_bitrate_estimator_) 246 if (remote_bitrate_estimator_)
228 remote_bitrate_estimator_->SetMinBitrate(min_bitrate_bps); 247 remote_bitrate_estimator_->SetMinBitrate(min_bitrate_bps);
229 min_bitrate_bps_ = min_bitrate_bps; 248 min_bitrate_bps_ = min_bitrate_bps;
230 transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate( 249 transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate(
231 min_bitrate_bps_); 250 min_bitrate_bps_);
232 MaybeTriggerOnNetworkChanged(); 251 MaybeTriggerOnNetworkChanged();
233 } 252 }
234 253
235 void CongestionController::ResetBweAndBitrates(int bitrate_bps, 254 void CongestionController::ResetBweAndBitrates(int bitrate_bps,
236 int min_bitrate_bps, 255 int min_bitrate_bps,
237 int max_bitrate_bps) { 256 int max_bitrate_bps) {
238 ClampBitrates(&bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); 257 ClampBitrates(&bitrate_bps, &min_bitrate_bps, &max_bitrate_bps);
239 // TODO(honghaiz): Recreate this object once the bitrate controller is 258 // TODO(honghaiz): Recreate this object once the bitrate controller is
240 // no longer exposed outside CongestionController. 259 // no longer exposed outside CongestionController.
241 bitrate_controller_->ResetBitrates(bitrate_bps, min_bitrate_bps, 260 bitrate_controller_->ResetBitrates(bitrate_bps, min_bitrate_bps,
242 max_bitrate_bps); 261 max_bitrate_bps);
243 min_bitrate_bps_ = min_bitrate_bps; 262 min_bitrate_bps_ = min_bitrate_bps;
263 max_bitrate_bps_ = max_bitrate_bps;
244 // TODO(honghaiz): Recreate this object once the remote bitrate estimator is 264 // TODO(honghaiz): Recreate this object once the remote bitrate estimator is
245 // no longer exposed outside CongestionController. 265 // no longer exposed outside CongestionController.
246 if (remote_bitrate_estimator_) 266 if (remote_bitrate_estimator_)
247 remote_bitrate_estimator_->SetMinBitrate(min_bitrate_bps); 267 remote_bitrate_estimator_->SetMinBitrate(min_bitrate_bps);
248 268
249 RemoteBitrateEstimator* rbe = new DelayBasedBwe( 269 RemoteBitrateEstimator* rbe = new DelayBasedBwe(
250 &transport_feedback_adapter_, clock_); 270 &transport_feedback_adapter_, clock_);
251 transport_feedback_adapter_.SetBitrateEstimator(rbe); 271 transport_feedback_adapter_.SetBitrateEstimator(rbe);
252 rbe->SetMinBitrate(min_bitrate_bps); 272 rbe->SetMinBitrate(min_bitrate_bps);
253 // TODO(holmer): Trigger a new probe once mid-call probing is implemented. 273 // TODO(holmer): Trigger a new probe once mid-call probing is implemented.
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 bool CongestionController::IsSendQueueFull() const { 387 bool CongestionController::IsSendQueueFull() const {
368 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; 388 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs;
369 } 389 }
370 390
371 bool CongestionController::IsNetworkDown() const { 391 bool CongestionController::IsNetworkDown() const {
372 rtc::CritScope cs(&critsect_); 392 rtc::CritScope cs(&critsect_);
373 return network_state_ == kNetworkDown; 393 return network_state_ == kNetworkDown;
374 } 394 }
375 395
376 } // namespace webrtc 396 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/congestion_controller/include/congestion_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698