| 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 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 // Minimum probe bitrate percentage to probe further for repeated probes, | 42 // Minimum probe bitrate percentage to probe further for repeated probes, |
| 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), clock_(clock), enable_periodic_alr_probing_(false) { |
| 52 clock_(clock), | 52 Reset(); |
| 53 network_state_(kNetworkUp), | 53 } |
| 54 state_(State::kInit), | |
| 55 min_bitrate_to_probe_further_bps_(kExponentialProbingDisabled), | |
| 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 | 54 |
| 64 void ProbeController::SetBitrates(int64_t min_bitrate_bps, | 55 void ProbeController::SetBitrates(int64_t min_bitrate_bps, |
| 65 int64_t start_bitrate_bps, | 56 int64_t start_bitrate_bps, |
| 66 int64_t max_bitrate_bps) { | 57 int64_t max_bitrate_bps) { |
| 67 rtc::CritScope cs(&critsect_); | 58 rtc::CritScope cs(&critsect_); |
| 68 | 59 |
| 69 if (start_bitrate_bps > 0) { | 60 if (start_bitrate_bps > 0) { |
| 70 start_bitrate_bps_ = start_bitrate_bps; | 61 start_bitrate_bps_ = start_bitrate_bps; |
| 71 } else if (start_bitrate_bps_ == 0) { | 62 } else if (start_bitrate_bps_ == 0) { |
| 72 start_bitrate_bps_ = min_bitrate_bps; | 63 start_bitrate_bps_ = min_bitrate_bps; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 } | 170 } |
| 180 | 171 |
| 181 estimated_bitrate_bps_ = bitrate_bps; | 172 estimated_bitrate_bps_ = bitrate_bps; |
| 182 } | 173 } |
| 183 | 174 |
| 184 void ProbeController::EnablePeriodicAlrProbing(bool enable) { | 175 void ProbeController::EnablePeriodicAlrProbing(bool enable) { |
| 185 rtc::CritScope cs(&critsect_); | 176 rtc::CritScope cs(&critsect_); |
| 186 enable_periodic_alr_probing_ = enable; | 177 enable_periodic_alr_probing_ = enable; |
| 187 } | 178 } |
| 188 | 179 |
| 180 void ProbeController::Reset() { |
| 181 rtc::CritScope cs(&critsect_); |
| 182 network_state_ = kNetworkUp; |
| 183 state_ = State::kInit; |
| 184 min_bitrate_to_probe_further_bps_ = kExponentialProbingDisabled; |
| 185 time_last_probing_initiated_ms_ = 0; |
| 186 estimated_bitrate_bps_ = 0; |
| 187 start_bitrate_bps_ = 0; |
| 188 max_bitrate_bps_ = 0; |
| 189 last_alr_probing_time_ = clock_->TimeInMilliseconds(); |
| 190 mid_call_probing_waiting_for_result_ = false; |
| 191 } |
| 192 |
| 189 void ProbeController::Process() { | 193 void ProbeController::Process() { |
| 190 rtc::CritScope cs(&critsect_); | 194 rtc::CritScope cs(&critsect_); |
| 191 | 195 |
| 192 int64_t now_ms = clock_->TimeInMilliseconds(); | 196 int64_t now_ms = clock_->TimeInMilliseconds(); |
| 193 | 197 |
| 194 if (now_ms - time_last_probing_initiated_ms_ > | 198 if (now_ms - time_last_probing_initiated_ms_ > |
| 195 kMaxWaitingTimeForProbingResultMs) { | 199 kMaxWaitingTimeForProbingResultMs) { |
| 196 mid_call_probing_waiting_for_result_ = false; | 200 mid_call_probing_waiting_for_result_ = false; |
| 197 | 201 |
| 198 if (state_ == State::kWaitingForProbingResult) { | 202 if (state_ == State::kWaitingForProbingResult) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 state_ = State::kWaitingForProbingResult; | 240 state_ = State::kWaitingForProbingResult; |
| 237 min_bitrate_to_probe_further_bps_ = | 241 min_bitrate_to_probe_further_bps_ = |
| 238 (*(bitrates_to_probe.end() - 1)) * kRepeatedProbeMinPercentage / 100; | 242 (*(bitrates_to_probe.end() - 1)) * kRepeatedProbeMinPercentage / 100; |
| 239 } else { | 243 } else { |
| 240 state_ = State::kProbingComplete; | 244 state_ = State::kProbingComplete; |
| 241 min_bitrate_to_probe_further_bps_ = kExponentialProbingDisabled; | 245 min_bitrate_to_probe_further_bps_ = kExponentialProbingDisabled; |
| 242 } | 246 } |
| 243 } | 247 } |
| 244 | 248 |
| 245 } // namespace webrtc | 249 } // namespace webrtc |
| OLD | NEW |