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

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

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

Powered by Google App Engine
This is Rietveld 408576698