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 <initializer_list> | 14 #include <initializer_list> |
14 | 15 |
15 #include "webrtc/base/logging.h" | 16 #include "webrtc/base/logging.h" |
16 | 17 |
17 namespace webrtc { | 18 namespace webrtc { |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 // Number of deltas between probes per cluster. On the very first cluster, | 22 // Number of deltas between probes per cluster. On the very first cluster, |
22 // we will need kProbeDeltasPerCluster + 1 probes, but on a cluster following | 23 // we will need kProbeDeltasPerCluster + 1 probes, but on a cluster following |
23 // another, we need kProbeDeltasPerCluster probes. | 24 // another, we need kProbeDeltasPerCluster probes. |
24 constexpr int kProbeDeltasPerCluster = 5; | 25 constexpr int kProbeDeltasPerCluster = 5; |
25 | 26 |
26 // Maximum waiting time from the time of initiating probing to getting | 27 // Maximum waiting time from the time of initiating probing to getting |
27 // the measured results back. | 28 // the measured results back. |
28 constexpr int64_t kMaxWaitingTimeForProbingResultMs = 1000; | 29 constexpr int64_t kMaxWaitingTimeForProbingResultMs = 1000; |
29 | 30 |
30 // Value of |min_bitrate_to_probe_further_bps_| that indicates | 31 // Value of |min_bitrate_to_probe_further_bps_| that indicates |
31 // further probing is disabled. | 32 // further probing is disabled. |
32 constexpr int kExponentialProbingDisabled = 0; | 33 constexpr int kExponentialProbingDisabled = 0; |
33 | 34 |
| 35 // A limit to prevent probing at excessive bitrates. |
| 36 constexpr int kMaxProbingBitrateBps = 10000000; |
| 37 |
34 } // namespace | 38 } // namespace |
35 | 39 |
36 ProbeController::ProbeController(PacedSender* pacer, Clock* clock) | 40 ProbeController::ProbeController(PacedSender* pacer, Clock* clock) |
37 : pacer_(pacer), | 41 : pacer_(pacer), |
38 clock_(clock), | 42 clock_(clock), |
39 state_(State::kInit), | 43 state_(State::kInit), |
40 min_bitrate_to_probe_further_bps_(kExponentialProbingDisabled), | 44 min_bitrate_to_probe_further_bps_(kExponentialProbingDisabled), |
41 time_last_probing_initiated_ms_(0), | 45 time_last_probing_initiated_ms_(0), |
42 estimated_bitrate_bps_(0), | 46 estimated_bitrate_bps_(0), |
43 max_bitrate_bps_(0) {} | 47 max_bitrate_bps_(0) {} |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 94 } |
91 } | 95 } |
92 estimated_bitrate_bps_ = bitrate_bps; | 96 estimated_bitrate_bps_ = bitrate_bps; |
93 } | 97 } |
94 | 98 |
95 void ProbeController::InitiateProbing( | 99 void ProbeController::InitiateProbing( |
96 std::initializer_list<int> bitrates_to_probe, | 100 std::initializer_list<int> bitrates_to_probe, |
97 int min_bitrate_to_probe_further_bps) { | 101 int min_bitrate_to_probe_further_bps) { |
98 bool first_cluster = true; | 102 bool first_cluster = true; |
99 for (int bitrate : bitrates_to_probe) { | 103 for (int bitrate : bitrates_to_probe) { |
| 104 bitrate = std::min(bitrate, kMaxProbingBitrateBps); |
100 if (first_cluster) { | 105 if (first_cluster) { |
101 pacer_->CreateProbeCluster(bitrate, kProbeDeltasPerCluster + 1); | 106 pacer_->CreateProbeCluster(bitrate, kProbeDeltasPerCluster + 1); |
102 first_cluster = false; | 107 first_cluster = false; |
103 } else { | 108 } else { |
104 pacer_->CreateProbeCluster(bitrate, kProbeDeltasPerCluster); | 109 pacer_->CreateProbeCluster(bitrate, kProbeDeltasPerCluster); |
105 } | 110 } |
106 } | 111 } |
107 min_bitrate_to_probe_further_bps_ = min_bitrate_to_probe_further_bps; | 112 min_bitrate_to_probe_further_bps_ = min_bitrate_to_probe_further_bps; |
108 time_last_probing_initiated_ms_ = clock_->TimeInMilliseconds(); | 113 time_last_probing_initiated_ms_ = clock_->TimeInMilliseconds(); |
109 if (min_bitrate_to_probe_further_bps == kExponentialProbingDisabled) | 114 if (min_bitrate_to_probe_further_bps == kExponentialProbingDisabled) |
110 state_ = State::kProbingComplete; | 115 state_ = State::kProbingComplete; |
111 else | 116 else |
112 state_ = State::kWaitingForProbingResult; | 117 state_ = State::kWaitingForProbingResult; |
113 } | 118 } |
114 | 119 |
115 } // namespace webrtc | 120 } // namespace webrtc |
OLD | NEW |