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 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 max_bitrate_bps_(0), |
| 175 initial_probing_triggered_(false), |
175 last_reported_bitrate_bps_(0), | 176 last_reported_bitrate_bps_(0), |
176 last_reported_fraction_loss_(0), | 177 last_reported_fraction_loss_(0), |
177 last_reported_rtt_(0), | 178 last_reported_rtt_(0), |
178 network_state_(kNetworkUp) { | 179 network_state_(kNetworkUp) { |
179 Init(); | 180 Init(); |
180 } | 181 } |
181 | 182 |
182 CongestionController::CongestionController( | 183 CongestionController::CongestionController( |
183 Clock* clock, | 184 Clock* clock, |
184 Observer* observer, | 185 Observer* observer, |
(...skipping 10 matching lines...) Expand all Loading... |
195 // Constructed last as this object calls the provided callback on | 196 // Constructed last as this object calls the provided callback on |
196 // construction. | 197 // construction. |
197 bitrate_controller_( | 198 bitrate_controller_( |
198 BitrateController::CreateBitrateController(clock_, event_log)), | 199 BitrateController::CreateBitrateController(clock_, event_log)), |
199 retransmission_rate_limiter_( | 200 retransmission_rate_limiter_( |
200 new RateLimiter(clock, kRetransmitWindowSizeMs)), | 201 new RateLimiter(clock, kRetransmitWindowSizeMs)), |
201 remote_estimator_proxy_(clock_, packet_router_.get()), | 202 remote_estimator_proxy_(clock_, packet_router_.get()), |
202 transport_feedback_adapter_(bitrate_controller_.get(), clock_), | 203 transport_feedback_adapter_(bitrate_controller_.get(), clock_), |
203 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps), | 204 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps), |
204 max_bitrate_bps_(0), | 205 max_bitrate_bps_(0), |
| 206 initial_probing_triggered_(false), |
205 last_reported_bitrate_bps_(0), | 207 last_reported_bitrate_bps_(0), |
206 last_reported_fraction_loss_(0), | 208 last_reported_fraction_loss_(0), |
207 last_reported_rtt_(0), | 209 last_reported_rtt_(0), |
208 network_state_(kNetworkUp) { | 210 network_state_(kNetworkUp) { |
209 Init(); | 211 Init(); |
210 } | 212 } |
211 | 213 |
212 CongestionController::~CongestionController() {} | 214 CongestionController::~CongestionController() {} |
213 | 215 |
214 void CongestionController::Init() { | 216 void CongestionController::Init() { |
215 transport_feedback_adapter_.SetBitrateEstimator( | 217 transport_feedback_adapter_.SetBitrateEstimator( |
216 new DelayBasedBwe(&transport_feedback_adapter_, clock_)); | 218 new DelayBasedBwe(&transport_feedback_adapter_, clock_)); |
217 transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate( | 219 transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate( |
218 min_bitrate_bps_); | 220 min_bitrate_bps_); |
219 pacer_->CreateProbeCluster(900000, 6); | |
220 pacer_->CreateProbeCluster(1800000, 5); | |
221 } | 221 } |
222 | 222 |
223 void CongestionController::SetBweBitrates(int min_bitrate_bps, | 223 void CongestionController::SetBweBitrates(int min_bitrate_bps, |
224 int start_bitrate_bps, | 224 int start_bitrate_bps, |
225 int max_bitrate_bps) { | 225 int max_bitrate_bps) { |
226 ClampBitrates(&start_bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); | 226 ClampBitrates(&start_bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); |
227 bitrate_controller_->SetBitrates(start_bitrate_bps, | 227 bitrate_controller_->SetBitrates(start_bitrate_bps, |
228 min_bitrate_bps, | 228 min_bitrate_bps, |
229 max_bitrate_bps); | 229 max_bitrate_bps); |
230 | 230 |
231 { | 231 { |
| 232 rtc::CritScope cs(&critsect_); |
| 233 if (!initial_probing_triggered_) { |
| 234 pacer_->CreateProbeCluster(start_bitrate_bps * 3, 6); |
| 235 pacer_->CreateProbeCluster(start_bitrate_bps * 6, 5); |
| 236 initial_probing_triggered_ = true; |
| 237 } |
| 238 |
232 // Only do probing if: | 239 // Only do probing if: |
233 // - we are mid-call, which we consider to be if | 240 // - we are mid-call, which we consider to be if |
234 // |last_reported_bitrate_bps_| != 0, and | 241 // |last_reported_bitrate_bps_| != 0, and |
235 // - the current bitrate is lower than the new |max_bitrate_bps|, and | 242 // - the current bitrate is lower than the new |max_bitrate_bps|, and |
236 // - we actually want to increase the |max_bitrate_bps_|. | 243 // - we actually want to increase the |max_bitrate_bps_|. |
237 rtc::CritScope cs(&critsect_); | |
238 if (last_reported_bitrate_bps_ != 0 && | 244 if (last_reported_bitrate_bps_ != 0 && |
239 last_reported_bitrate_bps_ < static_cast<uint32_t>(max_bitrate_bps) && | 245 last_reported_bitrate_bps_ < static_cast<uint32_t>(max_bitrate_bps) && |
240 max_bitrate_bps > max_bitrate_bps_) { | 246 max_bitrate_bps > max_bitrate_bps_) { |
241 pacer_->CreateProbeCluster(max_bitrate_bps, 5); | 247 pacer_->CreateProbeCluster(max_bitrate_bps, 5); |
242 } | 248 } |
243 } | 249 } |
244 max_bitrate_bps_ = max_bitrate_bps; | 250 max_bitrate_bps_ = max_bitrate_bps; |
245 | 251 |
246 if (remote_bitrate_estimator_) | 252 if (remote_bitrate_estimator_) |
247 remote_bitrate_estimator_->SetMinBitrate(min_bitrate_bps); | 253 remote_bitrate_estimator_->SetMinBitrate(min_bitrate_bps); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 bool CongestionController::IsSendQueueFull() const { | 393 bool CongestionController::IsSendQueueFull() const { |
388 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; | 394 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; |
389 } | 395 } |
390 | 396 |
391 bool CongestionController::IsNetworkDown() const { | 397 bool CongestionController::IsNetworkDown() const { |
392 rtc::CritScope cs(&critsect_); | 398 rtc::CritScope cs(&critsect_); |
393 return network_state_ == kNetworkDown; | 399 return network_state_ == kNetworkDown; |
394 } | 400 } |
395 | 401 |
396 } // namespace webrtc | 402 } // namespace webrtc |
OLD | NEW |