| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 InitiateProbing(clock_->TimeInMilliseconds(), | 114 InitiateProbing(clock_->TimeInMilliseconds(), |
| 115 {3 * start_bitrate_bps_, 6 * start_bitrate_bps_}, | 115 {3 * start_bitrate_bps_, 6 * start_bitrate_bps_}, |
| 116 4 * start_bitrate_bps_); | 116 4 * start_bitrate_bps_); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void ProbeController::SetEstimatedBitrate(int bitrate_bps) { | 119 void ProbeController::SetEstimatedBitrate(int bitrate_bps) { |
| 120 rtc::CritScope cs(&critsect_); | 120 rtc::CritScope cs(&critsect_); |
| 121 int64_t now_ms = clock_->TimeInMilliseconds(); | 121 int64_t now_ms = clock_->TimeInMilliseconds(); |
| 122 | 122 |
| 123 if (state_ == State::kWaitingForProbingResult) { | 123 if (state_ == State::kWaitingForProbingResult) { |
| 124 if ((now_ms - time_last_probing_initiated_ms_) > | 124 // Continue probing if probing results indicate channel has greater |
| 125 kMaxWaitingTimeForProbingResultMs) { | 125 // capacity. |
| 126 LOG(LS_INFO) << "kWaitingForProbingResult: timeout"; | 126 LOG(LS_INFO) << "Measured bitrate: " << bitrate_bps |
| 127 state_ = State::kProbingComplete; | 127 << " Minimum to probe further: " |
| 128 min_bitrate_to_probe_further_bps_ = kExponentialProbingDisabled; | 128 << min_bitrate_to_probe_further_bps_; |
| 129 } else { | 129 if (min_bitrate_to_probe_further_bps_ != kExponentialProbingDisabled && |
| 130 // Continue probing if probing results indicate channel has greater | 130 bitrate_bps > min_bitrate_to_probe_further_bps_) { |
| 131 // capacity. | 131 // Double the probing bitrate and expect a minimum of 25% gain to |
| 132 LOG(LS_INFO) << "Measured bitrate: " << bitrate_bps | 132 // continue probing. |
| 133 << " Minimum to probe further: " | 133 InitiateProbing(now_ms, {2 * bitrate_bps}, |
| 134 << min_bitrate_to_probe_further_bps_; | 134 bitrate_bps * kRepeatedProbeMinPercentage / 100); |
| 135 if (min_bitrate_to_probe_further_bps_ != kExponentialProbingDisabled && | |
| 136 bitrate_bps > min_bitrate_to_probe_further_bps_) { | |
| 137 // Double the probing bitrate and expect a minimum of 25% gain to | |
| 138 // continue probing. | |
| 139 InitiateProbing(now_ms, {2 * bitrate_bps}, | |
| 140 bitrate_bps * kRepeatedProbeMinPercentage / 100); | |
| 141 } else { | |
| 142 // Stop exponential probing. | |
| 143 state_ = State::kProbingComplete; | |
| 144 min_bitrate_to_probe_further_bps_ = kExponentialProbingDisabled; | |
| 145 } | |
| 146 } | 135 } |
| 147 } | 136 } |
| 148 | 137 |
| 149 // Detect a drop in estimated BW when operating in ALR and not already | 138 // Detect a drop in estimated BW when operating in ALR and not already |
| 150 // probing. The current response is to initiate a single probe session at the | 139 // probing. The current response is to initiate a single probe session at the |
| 151 // previous bitrate and immediately use the reported bitrate as the new | 140 // previous bitrate and immediately use the reported bitrate as the new |
| 152 // bitrate. | 141 // bitrate. |
| 153 // | 142 // |
| 154 // If the probe session fails, the assumption is that this drop was a | 143 // If the probe session fails, the assumption is that this drop was a |
| 155 // real one from a competing flow or something else on the network and | 144 // real one from a competing flow or something else on the network and |
| (...skipping 19 matching lines...) Expand all Loading... |
| 175 } | 164 } |
| 176 | 165 |
| 177 void ProbeController::EnablePeriodicAlrProbing(bool enable) { | 166 void ProbeController::EnablePeriodicAlrProbing(bool enable) { |
| 178 rtc::CritScope cs(&critsect_); | 167 rtc::CritScope cs(&critsect_); |
| 179 enable_periodic_alr_probing_ = enable; | 168 enable_periodic_alr_probing_ = enable; |
| 180 } | 169 } |
| 181 | 170 |
| 182 void ProbeController::Process() { | 171 void ProbeController::Process() { |
| 183 rtc::CritScope cs(&critsect_); | 172 rtc::CritScope cs(&critsect_); |
| 184 | 173 |
| 174 int64_t now_ms = clock_->TimeInMilliseconds(); |
| 175 |
| 176 if (state_ == State::kWaitingForProbingResult && |
| 177 (now_ms - time_last_probing_initiated_ms_) > |
| 178 kMaxWaitingTimeForProbingResultMs) { |
| 179 LOG(LS_INFO) << "kWaitingForProbingResult: timeout"; |
| 180 state_ = State::kProbingComplete; |
| 181 min_bitrate_to_probe_further_bps_ = kExponentialProbingDisabled; |
| 182 } |
| 183 |
| 185 if (state_ != State::kProbingComplete || !enable_periodic_alr_probing_) | 184 if (state_ != State::kProbingComplete || !enable_periodic_alr_probing_) |
| 186 return; | 185 return; |
| 187 | 186 |
| 188 // Probe bandwidth periodically when in ALR state. | 187 // Probe bandwidth periodically when in ALR state. |
| 189 rtc::Optional<int64_t> alr_start_time = | 188 rtc::Optional<int64_t> alr_start_time = |
| 190 pacer_->GetApplicationLimitedRegionStartTime(); | 189 pacer_->GetApplicationLimitedRegionStartTime(); |
| 191 if (alr_start_time) { | 190 if (alr_start_time) { |
| 192 int64_t now_ms = clock_->TimeInMilliseconds(); | |
| 193 int64_t next_probe_time_ms = | 191 int64_t next_probe_time_ms = |
| 194 std::max(*alr_start_time, time_last_probing_initiated_ms_) + | 192 std::max(*alr_start_time, time_last_probing_initiated_ms_) + |
| 195 kAlrPeriodicProbingIntervalMs; | 193 kAlrPeriodicProbingIntervalMs; |
| 196 if (now_ms >= next_probe_time_ms) { | 194 if (now_ms >= next_probe_time_ms) { |
| 197 InitiateProbing( | 195 InitiateProbing( |
| 198 now_ms, {estimated_bitrate_bps_ * 2}, | 196 now_ms, {estimated_bitrate_bps_ * 2}, |
| 199 estimated_bitrate_bps_ * kRepeatedProbeMinPercentage / 100); | 197 estimated_bitrate_bps_ * kRepeatedProbeMinPercentage / 100); |
| 200 } | 198 } |
| 201 } | 199 } |
| 202 } | 200 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 219 } | 217 } |
| 220 min_bitrate_to_probe_further_bps_ = min_bitrate_to_probe_further_bps; | 218 min_bitrate_to_probe_further_bps_ = min_bitrate_to_probe_further_bps; |
| 221 time_last_probing_initiated_ms_ = now_ms; | 219 time_last_probing_initiated_ms_ = now_ms; |
| 222 if (min_bitrate_to_probe_further_bps == kExponentialProbingDisabled) | 220 if (min_bitrate_to_probe_further_bps == kExponentialProbingDisabled) |
| 223 state_ = State::kProbingComplete; | 221 state_ = State::kProbingComplete; |
| 224 else | 222 else |
| 225 state_ = State::kWaitingForProbingResult; | 223 state_ = State::kWaitingForProbingResult; |
| 226 } | 224 } |
| 227 | 225 |
| 228 } // namespace webrtc | 226 } // namespace webrtc |
| OLD | NEW |