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

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

Issue 2861673006: Don't initiate perodic probing if we don't have a bandwidth estimate. (Closed)
Patch Set: Feedback Created 3 years, 7 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/probe_controller_unittest.cc » ('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) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 Reset(); 52 Reset();
53 } 53 }
54 54
55 void ProbeController::SetBitrates(int64_t min_bitrate_bps, 55 void ProbeController::SetBitrates(int64_t min_bitrate_bps,
56 int64_t start_bitrate_bps, 56 int64_t start_bitrate_bps,
57 int64_t max_bitrate_bps) { 57 int64_t max_bitrate_bps) {
58 rtc::CritScope cs(&critsect_); 58 rtc::CritScope cs(&critsect_);
59 59
60 if (start_bitrate_bps > 0) { 60 if (start_bitrate_bps > 0) {
61 start_bitrate_bps_ = start_bitrate_bps; 61 start_bitrate_bps_ = start_bitrate_bps;
62 estimated_bitrate_bps_ = start_bitrate_bps;
62 } else if (start_bitrate_bps_ == 0) { 63 } else if (start_bitrate_bps_ == 0) {
63 start_bitrate_bps_ = min_bitrate_bps; 64 start_bitrate_bps_ = min_bitrate_bps;
64 } 65 }
65 66
66 // The reason we use the variable |old_max_bitrate_pbs| is because we 67 // The reason we use the variable |old_max_bitrate_pbs| is because we
67 // need to set |max_bitrate_bps_| before we call InitiateProbing. 68 // need to set |max_bitrate_bps_| before we call InitiateProbing.
68 int64_t old_max_bitrate_bps = max_bitrate_bps_; 69 int64_t old_max_bitrate_bps = max_bitrate_bps_;
69 max_bitrate_bps_ = max_bitrate_bps; 70 max_bitrate_bps_ = max_bitrate_bps;
70 71
71 switch (state_) { 72 switch (state_) {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 min_bitrate_to_probe_further_bps_ = kExponentialProbingDisabled; 206 min_bitrate_to_probe_further_bps_ = kExponentialProbingDisabled;
206 } 207 }
207 } 208 }
208 209
209 if (state_ != State::kProbingComplete || !enable_periodic_alr_probing_) 210 if (state_ != State::kProbingComplete || !enable_periodic_alr_probing_)
210 return; 211 return;
211 212
212 // Probe bandwidth periodically when in ALR state. 213 // Probe bandwidth periodically when in ALR state.
213 rtc::Optional<int64_t> alr_start_time = 214 rtc::Optional<int64_t> alr_start_time =
214 pacer_->GetApplicationLimitedRegionStartTime(); 215 pacer_->GetApplicationLimitedRegionStartTime();
215 if (alr_start_time) { 216 if (alr_start_time && estimated_bitrate_bps_ > 0) {
216 int64_t next_probe_time_ms = 217 int64_t next_probe_time_ms =
217 std::max(*alr_start_time, time_last_probing_initiated_ms_) + 218 std::max(*alr_start_time, time_last_probing_initiated_ms_) +
218 kAlrPeriodicProbingIntervalMs; 219 kAlrPeriodicProbingIntervalMs;
219 if (now_ms >= next_probe_time_ms) { 220 if (now_ms >= next_probe_time_ms) {
220 InitiateProbing(now_ms, {estimated_bitrate_bps_ * 2}, true); 221 InitiateProbing(now_ms, {estimated_bitrate_bps_ * 2}, true);
221 } 222 }
222 } 223 }
223 } 224 }
224 225
225 void ProbeController::InitiateProbing( 226 void ProbeController::InitiateProbing(
226 int64_t now_ms, 227 int64_t now_ms,
227 std::initializer_list<int64_t> bitrates_to_probe, 228 std::initializer_list<int64_t> bitrates_to_probe,
228 bool probe_further) { 229 bool probe_further) {
229 for (int64_t bitrate : bitrates_to_probe) { 230 for (int64_t bitrate : bitrates_to_probe) {
231 RTC_DCHECK_GT(bitrate, 0);
230 int64_t max_probe_bitrate_bps = 232 int64_t max_probe_bitrate_bps =
231 max_bitrate_bps_ > 0 ? max_bitrate_bps_ : kDefaultMaxProbingBitrateBps; 233 max_bitrate_bps_ > 0 ? max_bitrate_bps_ : kDefaultMaxProbingBitrateBps;
232 if (bitrate > max_probe_bitrate_bps) { 234 if (bitrate > max_probe_bitrate_bps) {
233 bitrate = max_probe_bitrate_bps; 235 bitrate = max_probe_bitrate_bps;
234 probe_further = false; 236 probe_further = false;
235 } 237 }
236 pacer_->CreateProbeCluster(rtc::dchecked_cast<int>(bitrate)); 238 pacer_->CreateProbeCluster(rtc::dchecked_cast<int>(bitrate));
237 } 239 }
238 time_last_probing_initiated_ms_ = now_ms; 240 time_last_probing_initiated_ms_ = now_ms;
239 if (probe_further) { 241 if (probe_further) {
240 state_ = State::kWaitingForProbingResult; 242 state_ = State::kWaitingForProbingResult;
241 min_bitrate_to_probe_further_bps_ = 243 min_bitrate_to_probe_further_bps_ =
242 (*(bitrates_to_probe.end() - 1)) * kRepeatedProbeMinPercentage / 100; 244 (*(bitrates_to_probe.end() - 1)) * kRepeatedProbeMinPercentage / 100;
243 } else { 245 } else {
244 state_ = State::kProbingComplete; 246 state_ = State::kProbingComplete;
245 min_bitrate_to_probe_further_bps_ = kExponentialProbingDisabled; 247 min_bitrate_to_probe_further_bps_ = kExponentialProbingDisabled;
246 } 248 }
247 } 249 }
248 250
249 } // namespace webrtc 251 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/congestion_controller/probe_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698