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 |
11 #include "webrtc/modules/congestion_controller/probe_controller.h" | 11 #include "webrtc/modules/congestion_controller/probe_controller.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <initializer_list> | 14 #include <initializer_list> |
15 | 15 |
16 #include "webrtc/base/logging.h" | 16 #include "webrtc/base/logging.h" |
17 #include "webrtc/base/safe_conversions.h" | 17 #include "webrtc/base/safe_conversions.h" |
18 #include "webrtc/system_wrappers/include/metrics.h" | 18 #include "webrtc/system_wrappers/include/metrics.h" |
19 | 19 |
20 namespace webrtc { | 20 namespace webrtc { |
21 | 21 |
22 namespace { | 22 namespace { |
23 | |
24 // Number of deltas between probes per cluster. On the very first cluster, | |
25 // we will need kProbeDeltasPerCluster + 1 probes, but on a cluster following | |
26 // another, we need kProbeDeltasPerCluster probes. | |
27 constexpr int kProbeDeltasPerCluster = 5; | |
28 | |
29 // Maximum waiting time from the time of initiating probing to getting | 23 // Maximum waiting time from the time of initiating probing to getting |
30 // the measured results back. | 24 // the measured results back. |
31 constexpr int64_t kMaxWaitingTimeForProbingResultMs = 1000; | 25 constexpr int64_t kMaxWaitingTimeForProbingResultMs = 1000; |
32 | 26 |
33 // Value of |min_bitrate_to_probe_further_bps_| that indicates | 27 // Value of |min_bitrate_to_probe_further_bps_| that indicates |
34 // further probing is disabled. | 28 // further probing is disabled. |
35 constexpr int kExponentialProbingDisabled = 0; | 29 constexpr int kExponentialProbingDisabled = 0; |
36 | 30 |
37 // Default probing bitrate limit. Applied only when the application didn't | 31 // Default probing bitrate limit. Applied only when the application didn't |
38 // specify max bitrate. | 32 // specify max bitrate. |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 if (now_ms >= next_probe_time_ms) { | 187 if (now_ms >= next_probe_time_ms) { |
194 InitiateProbing(now_ms, {estimated_bitrate_bps_ * 2}, true); | 188 InitiateProbing(now_ms, {estimated_bitrate_bps_ * 2}, true); |
195 } | 189 } |
196 } | 190 } |
197 } | 191 } |
198 | 192 |
199 void ProbeController::InitiateProbing( | 193 void ProbeController::InitiateProbing( |
200 int64_t now_ms, | 194 int64_t now_ms, |
201 std::initializer_list<int64_t> bitrates_to_probe, | 195 std::initializer_list<int64_t> bitrates_to_probe, |
202 bool probe_further) { | 196 bool probe_further) { |
203 bool first_cluster = true; | |
204 for (int64_t bitrate : bitrates_to_probe) { | 197 for (int64_t bitrate : bitrates_to_probe) { |
205 int64_t max_probe_bitrate_bps = | 198 int64_t max_probe_bitrate_bps = |
206 max_bitrate_bps_ > 0 ? max_bitrate_bps_ : kDefaultMaxProbingBitrateBps; | 199 max_bitrate_bps_ > 0 ? max_bitrate_bps_ : kDefaultMaxProbingBitrateBps; |
207 if (bitrate > max_probe_bitrate_bps) { | 200 if (bitrate > max_probe_bitrate_bps) { |
208 bitrate = max_probe_bitrate_bps; | 201 bitrate = max_probe_bitrate_bps; |
209 probe_further = false; | 202 probe_further = false; |
210 } | 203 } |
211 if (first_cluster) { | 204 pacer_->CreateProbeCluster(rtc::checked_cast<int>(bitrate)); |
212 pacer_->CreateProbeCluster(rtc::checked_cast<int>(bitrate), | |
213 kProbeDeltasPerCluster + 1); | |
214 first_cluster = false; | |
215 } else { | |
216 pacer_->CreateProbeCluster(rtc::checked_cast<int>(bitrate), | |
217 kProbeDeltasPerCluster); | |
218 } | |
219 } | 205 } |
220 time_last_probing_initiated_ms_ = now_ms; | 206 time_last_probing_initiated_ms_ = now_ms; |
221 if (probe_further) { | 207 if (probe_further) { |
222 state_ = State::kWaitingForProbingResult; | 208 state_ = State::kWaitingForProbingResult; |
223 min_bitrate_to_probe_further_bps_ = | 209 min_bitrate_to_probe_further_bps_ = |
224 (*(bitrates_to_probe.end() - 1)) * kRepeatedProbeMinPercentage / 100; | 210 (*(bitrates_to_probe.end() - 1)) * kRepeatedProbeMinPercentage / 100; |
225 } else { | 211 } else { |
226 state_ = State::kProbingComplete; | 212 state_ = State::kProbingComplete; |
227 min_bitrate_to_probe_further_bps_ = kExponentialProbingDisabled; | 213 min_bitrate_to_probe_further_bps_ = kExponentialProbingDisabled; |
228 } | 214 } |
229 } | 215 } |
230 | 216 |
231 } // namespace webrtc | 217 } // namespace webrtc |
OLD | NEW |