OLD | NEW |
---|---|
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 // relative to the previous probe. For example, if 1Mbps probe results in | 43 // relative to the previous probe. For example, if 1Mbps probe results in |
44 // 80kbps, then we'll probe again at 1.6Mbps. In that case second probe won't be | 44 // 80kbps, then we'll probe again at 1.6Mbps. In that case second probe won't be |
45 // sent if we get 600kbps from the first one. | 45 // sent if we get 600kbps from the first one. |
46 constexpr int kRepeatedProbeMinPercentage = 70; | 46 constexpr int kRepeatedProbeMinPercentage = 70; |
47 | 47 |
48 } // namespace | 48 } // namespace |
49 | 49 |
50 ProbeController::ProbeController(PacedSender* pacer, Clock* clock) | 50 ProbeController::ProbeController(PacedSender* pacer, Clock* clock) |
51 : pacer_(pacer), | 51 : pacer_(pacer), |
52 clock_(clock), | 52 clock_(clock), |
53 network_state_(kNetworkUp), | 53 enable_periodic_alr_probing_(false) { |
54 state_(State::kInit), | 54 Reset(); |
stefan-webrtc
2017/03/07 12:16:55
I think indentation is wrong here.
| |
55 min_bitrate_to_probe_further_bps_(kExponentialProbingDisabled), | 55 } |
56 time_last_probing_initiated_ms_(0), | |
57 estimated_bitrate_bps_(0), | |
58 start_bitrate_bps_(0), | |
59 max_bitrate_bps_(0), | |
60 last_alr_probing_time_(clock_->TimeInMilliseconds()), | |
61 enable_periodic_alr_probing_(false), | |
62 mid_call_probing_waiting_for_result_(false) {} | |
63 | 56 |
64 void ProbeController::SetBitrates(int64_t min_bitrate_bps, | 57 void ProbeController::SetBitrates(int64_t min_bitrate_bps, |
65 int64_t start_bitrate_bps, | 58 int64_t start_bitrate_bps, |
66 int64_t max_bitrate_bps) { | 59 int64_t max_bitrate_bps) { |
67 rtc::CritScope cs(&critsect_); | 60 rtc::CritScope cs(&critsect_); |
68 | 61 |
69 if (start_bitrate_bps > 0) { | 62 if (start_bitrate_bps > 0) { |
70 start_bitrate_bps_ = start_bitrate_bps; | 63 start_bitrate_bps_ = start_bitrate_bps; |
71 } else if (start_bitrate_bps_ == 0) { | 64 } else if (start_bitrate_bps_ == 0) { |
72 start_bitrate_bps_ = min_bitrate_bps; | 65 start_bitrate_bps_ = min_bitrate_bps; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 } | 172 } |
180 | 173 |
181 estimated_bitrate_bps_ = bitrate_bps; | 174 estimated_bitrate_bps_ = bitrate_bps; |
182 } | 175 } |
183 | 176 |
184 void ProbeController::EnablePeriodicAlrProbing(bool enable) { | 177 void ProbeController::EnablePeriodicAlrProbing(bool enable) { |
185 rtc::CritScope cs(&critsect_); | 178 rtc::CritScope cs(&critsect_); |
186 enable_periodic_alr_probing_ = enable; | 179 enable_periodic_alr_probing_ = enable; |
187 } | 180 } |
188 | 181 |
182 void ProbeController::Reset() { | |
183 rtc::CritScope cs(&critsect_); | |
184 network_state_ = kNetworkUp; | |
185 state_ = State::kInit; | |
186 min_bitrate_to_probe_further_bps_ = kExponentialProbingDisabled; | |
187 time_last_probing_initiated_ms_ = 0; | |
188 estimated_bitrate_bps_ = 0; | |
189 start_bitrate_bps_ = 0; | |
190 max_bitrate_bps_ = 0; | |
191 last_alr_probing_time_ = clock_->TimeInMilliseconds(); | |
192 mid_call_probing_waiting_for_result_ = false; | |
stefan-webrtc
2017/03/07 12:16:55
Can we do something like this instead:
*this = Pro
philipel
2017/03/07 13:09:13
I can see two problems with that. First, what will
stefan-webrtc
2017/03/07 13:11:25
Agree, that seems very risky. :)
| |
193 } | |
194 | |
189 void ProbeController::Process() { | 195 void ProbeController::Process() { |
190 rtc::CritScope cs(&critsect_); | 196 rtc::CritScope cs(&critsect_); |
191 | 197 |
192 int64_t now_ms = clock_->TimeInMilliseconds(); | 198 int64_t now_ms = clock_->TimeInMilliseconds(); |
193 | 199 |
194 if (now_ms - time_last_probing_initiated_ms_ > | 200 if (now_ms - time_last_probing_initiated_ms_ > |
195 kMaxWaitingTimeForProbingResultMs) { | 201 kMaxWaitingTimeForProbingResultMs) { |
196 mid_call_probing_waiting_for_result_ = false; | 202 mid_call_probing_waiting_for_result_ = false; |
197 | 203 |
198 if (state_ == State::kWaitingForProbingResult) { | 204 if (state_ == State::kWaitingForProbingResult) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 state_ = State::kWaitingForProbingResult; | 242 state_ = State::kWaitingForProbingResult; |
237 min_bitrate_to_probe_further_bps_ = | 243 min_bitrate_to_probe_further_bps_ = |
238 (*(bitrates_to_probe.end() - 1)) * kRepeatedProbeMinPercentage / 100; | 244 (*(bitrates_to_probe.end() - 1)) * kRepeatedProbeMinPercentage / 100; |
239 } else { | 245 } else { |
240 state_ = State::kProbingComplete; | 246 state_ = State::kProbingComplete; |
241 min_bitrate_to_probe_further_bps_ = kExponentialProbingDisabled; | 247 min_bitrate_to_probe_further_bps_ = kExponentialProbingDisabled; |
242 } | 248 } |
243 } | 249 } |
244 | 250 |
245 } // namespace webrtc | 251 } // namespace webrtc |
OLD | NEW |