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

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

Issue 2458863002: Start probes only after network is connected. (Closed)
Patch Set: sync 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) 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 28 matching lines...) Expand all
39 39
40 // This is a limit on how often probing can be done when there is a BW 40 // This is a limit on how often probing can be done when there is a BW
41 // drop detected in ALR region. 41 // drop detected in ALR region.
42 constexpr int kAlrProbingIntervalLimitMs = 5000; 42 constexpr int kAlrProbingIntervalLimitMs = 5000;
43 43
44 } // namespace 44 } // namespace
45 45
46 ProbeController::ProbeController(PacedSender* pacer, Clock* clock) 46 ProbeController::ProbeController(PacedSender* pacer, Clock* clock)
47 : pacer_(pacer), 47 : pacer_(pacer),
48 clock_(clock), 48 clock_(clock),
49 network_state_(kNetworkUp),
49 state_(State::kInit), 50 state_(State::kInit),
50 min_bitrate_to_probe_further_bps_(kExponentialProbingDisabled), 51 min_bitrate_to_probe_further_bps_(kExponentialProbingDisabled),
51 time_last_probing_initiated_ms_(0), 52 time_last_probing_initiated_ms_(0),
52 estimated_bitrate_bps_(0), 53 estimated_bitrate_bps_(0),
54 start_bitrate_bps_(0),
53 max_bitrate_bps_(0), 55 max_bitrate_bps_(0),
54 last_alr_probing_time_(clock_->TimeInMilliseconds()) {} 56 last_alr_probing_time_(clock_->TimeInMilliseconds()) {}
55 57
56 void ProbeController::SetBitrates(int min_bitrate_bps, 58 void ProbeController::SetBitrates(int min_bitrate_bps,
57 int start_bitrate_bps, 59 int start_bitrate_bps,
58 int max_bitrate_bps) { 60 int max_bitrate_bps) {
59 rtc::CritScope cs(&critsect_); 61 rtc::CritScope cs(&critsect_);
60 if (state_ == State::kInit) { 62
61 // When probing at 1.8 Mbps ( 6x 300), this represents a threshold of 63 if (start_bitrate_bps > 0) {
62 // 1.2 Mbps to continue probing. 64 start_bitrate_bps_ = start_bitrate_bps;
63 InitiateProbing({3 * start_bitrate_bps, 6 * start_bitrate_bps}, 65 } else if (start_bitrate_bps_ == 0) {
64 4 * start_bitrate_bps); 66 start_bitrate_bps_ = min_bitrate_bps;
65 } 67 }
66 68
67 int old_max_bitrate_bps = max_bitrate_bps_; 69 int old_max_bitrate_bps = max_bitrate_bps_;
68 max_bitrate_bps_ = max_bitrate_bps; 70 max_bitrate_bps_ = max_bitrate_bps;
69 71
70 // Only do probing if: 72 switch (state_) {
71 // we are mid-call, which we consider to be if 73 case State::kInit:
72 // exponential probing is not active and 74 if (network_state_ == kNetworkUp)
73 // |estimated_bitrate_bps_| is valid (> 0) and 75 InitiateExponentialProbing();
74 // the current bitrate is lower than the new |max_bitrate_bps|, and 76 break;
75 // |max_bitrate_bps_| was increased. 77
76 if (state_ != State::kWaitingForProbingResult && 78 case State::kWaitingForProbingResult:
77 estimated_bitrate_bps_ != 0 && 79 break;
78 estimated_bitrate_bps_ < old_max_bitrate_bps && 80
79 max_bitrate_bps_ > old_max_bitrate_bps) { 81 case State::kProbingComplete:
80 InitiateProbing({max_bitrate_bps}, kExponentialProbingDisabled); 82 // Initiate probing when |max_bitrate_| was increased mid-call.
83 if (estimated_bitrate_bps_ != 0 &&
84 estimated_bitrate_bps_ < old_max_bitrate_bps &&
85 max_bitrate_bps_ > old_max_bitrate_bps) {
86 InitiateProbing({max_bitrate_bps}, kExponentialProbingDisabled);
87 }
88 break;
81 } 89 }
82 } 90 }
83 91
92 void ProbeController::OnNetworkStateChanged(NetworkState network_state) {
93 rtc::CritScope cs(&critsect_);
94 network_state_ = network_state;
95 if (network_state_ == kNetworkUp && state_ == State::kInit)
96 InitiateExponentialProbing();
97 }
98
99 void ProbeController::InitiateExponentialProbing() {
100 RTC_DCHECK(network_state_ == kNetworkUp);
101 RTC_DCHECK(state_ == State::kInit);
102 RTC_DCHECK_GT(start_bitrate_bps_, 0);
103
104 // When probing at 1.8 Mbps ( 6x 300), this represents a threshold of
105 // 1.2 Mbps to continue probing.
106 InitiateProbing({3 * start_bitrate_bps_, 6 * start_bitrate_bps_},
107 4 * start_bitrate_bps_);
108 }
109
84 void ProbeController::SetEstimatedBitrate(int bitrate_bps) { 110 void ProbeController::SetEstimatedBitrate(int bitrate_bps) {
85 rtc::CritScope cs(&critsect_); 111 rtc::CritScope cs(&critsect_);
86 if (state_ == State::kWaitingForProbingResult) { 112 if (state_ == State::kWaitingForProbingResult) {
87 if ((clock_->TimeInMilliseconds() - time_last_probing_initiated_ms_) > 113 if ((clock_->TimeInMilliseconds() - time_last_probing_initiated_ms_) >
88 kMaxWaitingTimeForProbingResultMs) { 114 kMaxWaitingTimeForProbingResultMs) {
89 LOG(LS_INFO) << "kWaitingForProbingResult: timeout"; 115 LOG(LS_INFO) << "kWaitingForProbingResult: timeout";
90 state_ = State::kProbingComplete; 116 state_ = State::kProbingComplete;
91 min_bitrate_to_probe_further_bps_ = kExponentialProbingDisabled; 117 min_bitrate_to_probe_further_bps_ = kExponentialProbingDisabled;
92 } else { 118 } else {
93 // Continue probing if probing results indicate channel has greater 119 // Continue probing if probing results indicate channel has greater
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 173 }
148 min_bitrate_to_probe_further_bps_ = min_bitrate_to_probe_further_bps; 174 min_bitrate_to_probe_further_bps_ = min_bitrate_to_probe_further_bps;
149 time_last_probing_initiated_ms_ = clock_->TimeInMilliseconds(); 175 time_last_probing_initiated_ms_ = clock_->TimeInMilliseconds();
150 if (min_bitrate_to_probe_further_bps == kExponentialProbingDisabled) 176 if (min_bitrate_to_probe_further_bps == kExponentialProbingDisabled)
151 state_ = State::kProbingComplete; 177 state_ = State::kProbingComplete;
152 else 178 else
153 state_ = State::kWaitingForProbingResult; 179 state_ = State::kWaitingForProbingResult;
154 } 180 }
155 181
156 } // namespace webrtc 182 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698