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 28 matching lines...) Expand all Loading... | |
39 | 39 |
40 // This is a limit on how often probing can be done when there is a BW | 40 // This is a limit on how often probing can be done when there is a BW |
41 // drop detected in ALR region. | 41 // drop detected in ALR region. |
42 constexpr int kAlrProbingIntervalLimitMs = 5000; | 42 constexpr int kAlrProbingIntervalLimitMs = 5000; |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 ProbeController::ProbeController(PacedSender* pacer, Clock* clock) | 46 ProbeController::ProbeController(PacedSender* pacer, Clock* clock) |
47 : pacer_(pacer), | 47 : pacer_(pacer), |
48 clock_(clock), | 48 clock_(clock), |
49 network_state_(kNetworkUp), | |
49 state_(State::kInit), | 50 state_(State::kInit), |
50 min_bitrate_to_probe_further_bps_(kExponentialProbingDisabled), | 51 min_bitrate_to_probe_further_bps_(kExponentialProbingDisabled), |
51 time_last_probing_initiated_ms_(0), | 52 time_last_probing_initiated_ms_(0), |
52 estimated_bitrate_bps_(0), | 53 estimated_bitrate_bps_(0), |
54 start_bitrate_bps_(0), | |
53 max_bitrate_bps_(0), | 55 max_bitrate_bps_(0), |
54 last_alr_probing_time_(clock_->TimeInMilliseconds()) {} | 56 last_alr_probing_time_(clock_->TimeInMilliseconds()) {} |
55 | 57 |
56 void ProbeController::SetBitrates(int min_bitrate_bps, | 58 void ProbeController::SetBitrates(int min_bitrate_bps, |
57 int start_bitrate_bps, | 59 int start_bitrate_bps, |
58 int max_bitrate_bps) { | 60 int max_bitrate_bps) { |
59 rtc::CritScope cs(&critsect_); | 61 rtc::CritScope cs(&critsect_); |
60 if (state_ == State::kInit) { | 62 |
61 // When probing at 1.8 Mbps ( 6x 300), this represents a threshold of | 63 start_bitrate_bps_ = |
62 // 1.2 Mbps to continue probing. | 64 start_bitrate_bps > 0 ? start_bitrate_bps : min_bitrate_bps; |
63 InitiateProbing({3 * start_bitrate_bps, 6 * start_bitrate_bps}, | |
64 4 * start_bitrate_bps); | |
65 } | |
66 | 65 |
67 int old_max_bitrate_bps = max_bitrate_bps_; | 66 int old_max_bitrate_bps = max_bitrate_bps_; |
68 max_bitrate_bps_ = max_bitrate_bps; | 67 max_bitrate_bps_ = max_bitrate_bps; |
69 | 68 |
70 // Only do probing if: | 69 // Only do probing if: |
71 // we are mid-call, which we consider to be if | 70 // we are mid-call, which we consider to be if |
72 // exponential probing is not active and | 71 // exponential probing is not active and |
73 // |estimated_bitrate_bps_| is valid (> 0) and | 72 // |estimated_bitrate_bps_| is valid (> 0) and |
74 // the current bitrate is lower than the new |max_bitrate_bps|, and | 73 // the current bitrate is lower than the new |max_bitrate_bps|, and |
75 // |max_bitrate_bps_| was increased. | 74 // |max_bitrate_bps_| was increased. |
76 if (state_ != State::kWaitingForProbingResult && | 75 if (state_ == State::kProbingComplete && |
77 estimated_bitrate_bps_ != 0 && | 76 estimated_bitrate_bps_ != 0 && |
78 estimated_bitrate_bps_ < old_max_bitrate_bps && | 77 estimated_bitrate_bps_ < old_max_bitrate_bps && |
79 max_bitrate_bps_ > old_max_bitrate_bps) { | 78 max_bitrate_bps_ > old_max_bitrate_bps) { |
80 InitiateProbing({max_bitrate_bps}, kExponentialProbingDisabled); | 79 InitiateProbing({max_bitrate_bps}, kExponentialProbingDisabled); |
81 } | 80 } |
81 | |
82 MaybeInitiateProbing(); | |
honghaiz3
2016/11/07 23:31:41
It is a little strange here that you may have call
Sergey Ulanov
2016/11/08 00:10:57
Replaced MaybeIntiiateProbing() with InitiateExpon
| |
83 } | |
84 | |
85 void ProbeController::OnNetworkStateChanged(NetworkState state) { | |
86 rtc::CritScope cs(&critsect_); | |
87 network_state_ = state; | |
88 MaybeInitiateProbing(); | |
89 } | |
90 | |
91 void ProbeController::MaybeInitiateProbing() { | |
92 if (network_state_ == kNetworkUp && state_ == State::kInit) { | |
93 RTC_DCHECK_GT(start_bitrate_bps_, 0); | |
94 // When probing at 1.8 Mbps ( 6x 300), this represents a threshold of | |
95 // 1.2 Mbps to continue probing. | |
96 InitiateProbing({3 * start_bitrate_bps_, 6 * start_bitrate_bps_}, | |
97 4 * start_bitrate_bps_); | |
98 } | |
82 } | 99 } |
83 | 100 |
84 void ProbeController::SetEstimatedBitrate(int bitrate_bps) { | 101 void ProbeController::SetEstimatedBitrate(int bitrate_bps) { |
85 rtc::CritScope cs(&critsect_); | 102 rtc::CritScope cs(&critsect_); |
86 if (state_ == State::kWaitingForProbingResult) { | 103 if (state_ == State::kWaitingForProbingResult) { |
87 if ((clock_->TimeInMilliseconds() - time_last_probing_initiated_ms_) > | 104 if ((clock_->TimeInMilliseconds() - time_last_probing_initiated_ms_) > |
88 kMaxWaitingTimeForProbingResultMs) { | 105 kMaxWaitingTimeForProbingResultMs) { |
89 LOG(LS_INFO) << "kWaitingForProbingResult: timeout"; | 106 LOG(LS_INFO) << "kWaitingForProbingResult: timeout"; |
90 state_ = State::kProbingComplete; | 107 state_ = State::kProbingComplete; |
91 min_bitrate_to_probe_further_bps_ = kExponentialProbingDisabled; | 108 min_bitrate_to_probe_further_bps_ = kExponentialProbingDisabled; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 } | 164 } |
148 min_bitrate_to_probe_further_bps_ = min_bitrate_to_probe_further_bps; | 165 min_bitrate_to_probe_further_bps_ = min_bitrate_to_probe_further_bps; |
149 time_last_probing_initiated_ms_ = clock_->TimeInMilliseconds(); | 166 time_last_probing_initiated_ms_ = clock_->TimeInMilliseconds(); |
150 if (min_bitrate_to_probe_further_bps == kExponentialProbingDisabled) | 167 if (min_bitrate_to_probe_further_bps == kExponentialProbingDisabled) |
151 state_ = State::kProbingComplete; | 168 state_ = State::kProbingComplete; |
152 else | 169 else |
153 state_ = State::kWaitingForProbingResult; | 170 state_ = State::kWaitingForProbingResult; |
154 } | 171 } |
155 | 172 |
156 } // namespace webrtc | 173 } // namespace webrtc |
OLD | NEW |