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/networkroute.h" | |
17 #include "webrtc/system_wrappers/include/metrics.h" | 18 #include "webrtc/system_wrappers/include/metrics.h" |
18 | 19 |
19 namespace webrtc { | 20 namespace webrtc { |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 // Number of deltas between probes per cluster. On the very first cluster, | 24 // Number of deltas between probes per cluster. On the very first cluster, |
24 // we will need kProbeDeltasPerCluster + 1 probes, but on a cluster following | 25 // we will need kProbeDeltasPerCluster + 1 probes, but on a cluster following |
25 // another, we need kProbeDeltasPerCluster probes. | 26 // another, we need kProbeDeltasPerCluster probes. |
26 constexpr int kProbeDeltasPerCluster = 5; | 27 constexpr int kProbeDeltasPerCluster = 5; |
(...skipping 15 matching lines...) Expand all Loading... | |
42 | 43 |
43 } // namespace | 44 } // namespace |
44 | 45 |
45 ProbeController::ProbeController(PacedSender* pacer, Clock* clock) | 46 ProbeController::ProbeController(PacedSender* pacer, Clock* clock) |
46 : pacer_(pacer), | 47 : pacer_(pacer), |
47 clock_(clock), | 48 clock_(clock), |
48 state_(State::kInit), | 49 state_(State::kInit), |
49 min_bitrate_to_probe_further_bps_(kExponentialProbingDisabled), | 50 min_bitrate_to_probe_further_bps_(kExponentialProbingDisabled), |
50 time_last_probing_initiated_ms_(0), | 51 time_last_probing_initiated_ms_(0), |
51 estimated_bitrate_bps_(0), | 52 estimated_bitrate_bps_(0), |
53 start_bitrate_bps_(0), | |
52 max_bitrate_bps_(0), | 54 max_bitrate_bps_(0), |
53 last_alr_probing_time_(clock_->TimeInMilliseconds()) {} | 55 last_alr_probing_time_(clock_->TimeInMilliseconds()) {} |
54 | 56 |
55 void ProbeController::SetBitrates(int min_bitrate_bps, | 57 void ProbeController::SetBitrates(int start_bitrate_bps, |
56 int start_bitrate_bps, | 58 int min_bitrate_bps, |
57 int max_bitrate_bps) { | 59 int max_bitrate_bps) { |
58 rtc::CritScope cs(&critsect_); | 60 rtc::CritScope cs(&critsect_); |
59 if (state_ == State::kInit) { | 61 |
60 // When probing at 1.8 Mbps ( 6x 300), this represents a threshold of | 62 start_bitrate_bps_ = |
61 // 1.2 Mbps to continue probing. | 63 start_bitrate_bps > 0 ? start_bitrate_bps : min_bitrate_bps; |
62 InitiateProbing({3 * start_bitrate_bps, 6 * start_bitrate_bps}, | |
63 4 * start_bitrate_bps); | |
64 } | |
65 | 64 |
66 // Only do probing if: | 65 // Only do probing if: |
67 // we are mid-call, which we consider to be if | 66 // we are mid-call, which we consider to be if |
68 // exponential probing is not active and | 67 // exponential probing is not active and |
69 // |estimated_bitrate_bps_| is valid (> 0) and | 68 // |estimated_bitrate_bps_| is valid (> 0) and |
70 // the current bitrate is lower than the new |max_bitrate_bps|, and | 69 // the current bitrate is lower than the new |max_bitrate_bps|, and |
71 // we actually want to increase the |max_bitrate_bps_|. | 70 // we actually want to increase the |max_bitrate_bps_|. |
72 if (state_ != State::kWaitingForProbingResult && | 71 if (state_ == State::kProbingComplete && |
stefan-webrtc
2016/10/31 10:58:27
Could you comment on this change?
Sergey Ulanov
2016/10/31 18:07:27
We don't want to start probing here when the netwo
stefan-webrtc
2016/11/02 13:27:17
Acknowledged.
| |
73 estimated_bitrate_bps_ != 0 && estimated_bitrate_bps_ < max_bitrate_bps && | 72 estimated_bitrate_bps_ != 0 && estimated_bitrate_bps_ < max_bitrate_bps && |
philipel
2016/11/02 16:15:03
In order for probing to start before we have a net
Sergey Ulanov
2016/11/02 21:12:43
Previously probing was started by InitiateProbing(
philipel
2016/11/08 09:48:18
Ah, right :)
| |
74 max_bitrate_bps > max_bitrate_bps_) { | 73 max_bitrate_bps > max_bitrate_bps_) { |
75 InitiateProbing({max_bitrate_bps}, kExponentialProbingDisabled); | 74 InitiateProbing({max_bitrate_bps}, kExponentialProbingDisabled); |
76 } | 75 } |
77 max_bitrate_bps_ = max_bitrate_bps; | 76 max_bitrate_bps_ = max_bitrate_bps; |
78 } | 77 } |
79 | 78 |
79 void ProbeController::OnNetworkRouteChanged(const rtc::NetworkRoute& route) { | |
80 rtc::CritScope cs(&critsect_); | |
81 if (route.connected && state_ == State::kInit) { | |
philipel
2016/11/02 16:15:03
I think if we add a bool, something like |is_midca
Sergey Ulanov
2016/11/02 21:12:43
I'd like to work on mid-call probing later, in a s
philipel
2016/11/08 09:48:18
Acknowledged.
| |
82 // When probing at 1.8 Mbps ( 6x 300), this represents a threshold of | |
83 // 1.2 Mbps to continue probing. | |
84 InitiateProbing({3 * start_bitrate_bps_, 6 * start_bitrate_bps_}, | |
85 4 * start_bitrate_bps_); | |
86 } | |
87 } | |
88 | |
80 void ProbeController::SetEstimatedBitrate(int bitrate_bps) { | 89 void ProbeController::SetEstimatedBitrate(int bitrate_bps) { |
81 rtc::CritScope cs(&critsect_); | 90 rtc::CritScope cs(&critsect_); |
82 if (state_ == State::kWaitingForProbingResult) { | 91 if (state_ == State::kWaitingForProbingResult) { |
83 if ((clock_->TimeInMilliseconds() - time_last_probing_initiated_ms_) > | 92 if ((clock_->TimeInMilliseconds() - time_last_probing_initiated_ms_) > |
84 kMaxWaitingTimeForProbingResultMs) { | 93 kMaxWaitingTimeForProbingResultMs) { |
85 LOG(LS_INFO) << "kWaitingForProbingResult: timeout"; | 94 LOG(LS_INFO) << "kWaitingForProbingResult: timeout"; |
86 state_ = State::kProbingComplete; | 95 state_ = State::kProbingComplete; |
87 min_bitrate_to_probe_further_bps_ = kExponentialProbingDisabled; | 96 min_bitrate_to_probe_further_bps_ = kExponentialProbingDisabled; |
88 } else { | 97 } else { |
89 // Continue probing if probing results indicate channel has greater | 98 // Continue probing if probing results indicate channel has greater |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 } | 150 } |
142 min_bitrate_to_probe_further_bps_ = min_bitrate_to_probe_further_bps; | 151 min_bitrate_to_probe_further_bps_ = min_bitrate_to_probe_further_bps; |
143 time_last_probing_initiated_ms_ = clock_->TimeInMilliseconds(); | 152 time_last_probing_initiated_ms_ = clock_->TimeInMilliseconds(); |
144 if (min_bitrate_to_probe_further_bps == kExponentialProbingDisabled) | 153 if (min_bitrate_to_probe_further_bps == kExponentialProbingDisabled) |
145 state_ = State::kProbingComplete; | 154 state_ = State::kProbingComplete; |
146 else | 155 else |
147 state_ = State::kWaitingForProbingResult; | 156 state_ = State::kWaitingForProbingResult; |
148 } | 157 } |
149 | 158 |
150 } // namespace webrtc | 159 } // namespace webrtc |
OLD | NEW |