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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 bool BweSparseUpdateExperimentIsEnabled() { | 51 bool BweSparseUpdateExperimentIsEnabled() { |
52 std::string experiment_string = | 52 std::string experiment_string = |
53 webrtc::field_trial::FindFullName(kBweSparseUpdateExperiment); | 53 webrtc::field_trial::FindFullName(kBweSparseUpdateExperiment); |
54 return experiment_string == "Enabled"; | 54 return experiment_string == "Enabled"; |
55 } | 55 } |
56 } // namespace | 56 } // namespace |
57 | 57 |
58 namespace webrtc { | 58 namespace webrtc { |
59 | 59 |
| 60 DelayBasedBwe::Result::Result() |
| 61 : updated(false), |
| 62 probe(false), |
| 63 target_bitrate_bps(0), |
| 64 recovered_from_overuse(false) {} |
| 65 |
| 66 DelayBasedBwe::Result::Result(bool probe, uint32_t target_bitrate_bps) |
| 67 : updated(true), |
| 68 probe(probe), |
| 69 target_bitrate_bps(target_bitrate_bps), |
| 70 recovered_from_overuse(false) {} |
| 71 |
| 72 DelayBasedBwe::Result::~Result() {} |
| 73 |
60 DelayBasedBwe::DelayBasedBwe(RtcEventLog* event_log, const Clock* clock) | 74 DelayBasedBwe::DelayBasedBwe(RtcEventLog* event_log, const Clock* clock) |
61 : event_log_(event_log), | 75 : event_log_(event_log), |
62 clock_(clock), | 76 clock_(clock), |
63 inter_arrival_(), | 77 inter_arrival_(), |
64 trendline_estimator_(), | 78 trendline_estimator_(), |
65 detector_(), | 79 detector_(), |
66 last_seen_packet_ms_(-1), | 80 last_seen_packet_ms_(-1), |
67 uma_recorded_(false), | 81 uma_recorded_(false), |
68 probe_bitrate_estimator_(event_log), | 82 probe_bitrate_estimator_(event_log), |
69 trendline_window_size_(kDefaultTrendlineWindowSize), | 83 trendline_window_size_(kDefaultTrendlineWindowSize), |
(...skipping 25 matching lines...) Expand all Loading... |
95 } | 109 } |
96 | 110 |
97 if (!uma_recorded_) { | 111 if (!uma_recorded_) { |
98 RTC_HISTOGRAM_ENUMERATION(kBweTypeHistogram, | 112 RTC_HISTOGRAM_ENUMERATION(kBweTypeHistogram, |
99 BweNames::kSendSideTransportSeqNum, | 113 BweNames::kSendSideTransportSeqNum, |
100 BweNames::kBweNamesMax); | 114 BweNames::kBweNamesMax); |
101 uma_recorded_ = true; | 115 uma_recorded_ = true; |
102 } | 116 } |
103 bool overusing = false; | 117 bool overusing = false; |
104 bool delayed_feedback = true; | 118 bool delayed_feedback = true; |
| 119 bool recovered_from_overuse = false; |
| 120 BandwidthUsage prev_detector_state = detector_.State(); |
105 for (const auto& packet_feedback : packet_feedback_vector) { | 121 for (const auto& packet_feedback : packet_feedback_vector) { |
106 if (packet_feedback.send_time_ms < 0) | 122 if (packet_feedback.send_time_ms < 0) |
107 continue; | 123 continue; |
108 delayed_feedback = false; | 124 delayed_feedback = false; |
109 IncomingPacketFeedback(packet_feedback); | 125 IncomingPacketFeedback(packet_feedback); |
110 if (!in_sparse_update_experiment_) | 126 if (!in_sparse_update_experiment_) |
111 overusing |= (detector_.State() == BandwidthUsage::kBwOverusing); | 127 overusing |= (detector_.State() == BandwidthUsage::kBwOverusing); |
| 128 if (prev_detector_state == BandwidthUsage::kBwUnderusing && |
| 129 detector_.State() == BandwidthUsage::kBwNormal) { |
| 130 recovered_from_overuse = true; |
| 131 } |
| 132 prev_detector_state = detector_.State(); |
112 } | 133 } |
113 if (in_sparse_update_experiment_) | 134 if (in_sparse_update_experiment_) |
114 overusing = (detector_.State() == BandwidthUsage::kBwOverusing); | 135 overusing = (detector_.State() == BandwidthUsage::kBwOverusing); |
| 136 |
115 if (delayed_feedback) { | 137 if (delayed_feedback) { |
116 ++consecutive_delayed_feedbacks_; | 138 ++consecutive_delayed_feedbacks_; |
117 if (consecutive_delayed_feedbacks_ >= kMaxConsecutiveFailedLookups) { | 139 if (consecutive_delayed_feedbacks_ >= kMaxConsecutiveFailedLookups) { |
118 consecutive_delayed_feedbacks_ = 0; | 140 consecutive_delayed_feedbacks_ = 0; |
119 return OnLongFeedbackDelay(packet_feedback_vector.back().arrival_time_ms); | 141 return OnLongFeedbackDelay(packet_feedback_vector.back().arrival_time_ms); |
120 } | 142 } |
121 } else { | 143 } else { |
122 consecutive_delayed_feedbacks_ = 0; | 144 consecutive_delayed_feedbacks_ = 0; |
123 return MaybeUpdateEstimate(overusing, acked_bitrate_bps); | 145 return MaybeUpdateEstimate(overusing, acked_bitrate_bps, |
| 146 recovered_from_overuse); |
124 } | 147 } |
125 return Result(); | 148 return Result(); |
126 } | 149 } |
127 | 150 |
128 DelayBasedBwe::Result DelayBasedBwe::OnLongFeedbackDelay( | 151 DelayBasedBwe::Result DelayBasedBwe::OnLongFeedbackDelay( |
129 int64_t arrival_time_ms) { | 152 int64_t arrival_time_ms) { |
130 // Estimate should always be valid since a start bitrate always is set in the | 153 // Estimate should always be valid since a start bitrate always is set in the |
131 // Call constructor. An alternative would be to return an empty Result here, | 154 // Call constructor. An alternative would be to return an empty Result here, |
132 // or to estimate the throughput based on the feedback we received. | 155 // or to estimate the throughput based on the feedback we received. |
133 RTC_DCHECK(rate_control_.ValidEstimate()); | 156 RTC_DCHECK(rate_control_.ValidEstimate()); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 packet_feedback.arrival_time_ms); | 205 packet_feedback.arrival_time_ms); |
183 } | 206 } |
184 if (packet_feedback.pacing_info.probe_cluster_id != | 207 if (packet_feedback.pacing_info.probe_cluster_id != |
185 PacedPacketInfo::kNotAProbe) { | 208 PacedPacketInfo::kNotAProbe) { |
186 probe_bitrate_estimator_.HandleProbeAndEstimateBitrate(packet_feedback); | 209 probe_bitrate_estimator_.HandleProbeAndEstimateBitrate(packet_feedback); |
187 } | 210 } |
188 } | 211 } |
189 | 212 |
190 DelayBasedBwe::Result DelayBasedBwe::MaybeUpdateEstimate( | 213 DelayBasedBwe::Result DelayBasedBwe::MaybeUpdateEstimate( |
191 bool overusing, | 214 bool overusing, |
192 rtc::Optional<uint32_t> acked_bitrate_bps) { | 215 rtc::Optional<uint32_t> acked_bitrate_bps, |
| 216 bool recovered_from_overuse) { |
193 Result result; | 217 Result result; |
194 int64_t now_ms = clock_->TimeInMilliseconds(); | 218 int64_t now_ms = clock_->TimeInMilliseconds(); |
195 | 219 |
196 rtc::Optional<int> probe_bitrate_bps = | 220 rtc::Optional<int> probe_bitrate_bps = |
197 probe_bitrate_estimator_.FetchAndResetLastEstimatedBitrateBps(); | 221 probe_bitrate_estimator_.FetchAndResetLastEstimatedBitrateBps(); |
198 // Currently overusing the bandwidth. | 222 // Currently overusing the bandwidth. |
199 if (overusing) { | 223 if (overusing) { |
200 if (acked_bitrate_bps && | 224 if (acked_bitrate_bps && |
201 rate_control_.TimeToReduceFurther(now_ms, *acked_bitrate_bps)) { | 225 rate_control_.TimeToReduceFurther(now_ms, *acked_bitrate_bps)) { |
202 result.updated = UpdateEstimate(now_ms, acked_bitrate_bps, overusing, | 226 result.updated = UpdateEstimate(now_ms, acked_bitrate_bps, overusing, |
(...skipping 13 matching lines...) Expand all Loading... |
216 } | 240 } |
217 } else { | 241 } else { |
218 if (probe_bitrate_bps) { | 242 if (probe_bitrate_bps) { |
219 result.probe = true; | 243 result.probe = true; |
220 result.updated = true; | 244 result.updated = true; |
221 result.target_bitrate_bps = *probe_bitrate_bps; | 245 result.target_bitrate_bps = *probe_bitrate_bps; |
222 rate_control_.SetEstimate(*probe_bitrate_bps, now_ms); | 246 rate_control_.SetEstimate(*probe_bitrate_bps, now_ms); |
223 } else { | 247 } else { |
224 result.updated = UpdateEstimate(now_ms, acked_bitrate_bps, overusing, | 248 result.updated = UpdateEstimate(now_ms, acked_bitrate_bps, overusing, |
225 &result.target_bitrate_bps); | 249 &result.target_bitrate_bps); |
| 250 result.recovered_from_overuse = recovered_from_overuse; |
226 } | 251 } |
227 } | 252 } |
228 if (result.updated) { | 253 if (result.updated) { |
229 BWE_TEST_LOGGING_PLOT(1, "target_bitrate_bps", now_ms, | 254 BWE_TEST_LOGGING_PLOT(1, "target_bitrate_bps", now_ms, |
230 result.target_bitrate_bps); | 255 result.target_bitrate_bps); |
231 if (event_log_ && (result.target_bitrate_bps != last_logged_bitrate_ || | 256 if (event_log_ && (result.target_bitrate_bps != last_logged_bitrate_ || |
232 detector_.State() != last_logged_state_)) { | 257 detector_.State() != last_logged_state_)) { |
233 event_log_->LogDelayBasedBweUpdate(result.target_bitrate_bps, | 258 event_log_->LogDelayBasedBweUpdate(result.target_bitrate_bps, |
234 detector_.State()); | 259 detector_.State()); |
235 last_logged_bitrate_ = result.target_bitrate_bps; | 260 last_logged_bitrate_ = result.target_bitrate_bps; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) { | 307 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) { |
283 // Called from both the configuration thread and the network thread. Shouldn't | 308 // Called from both the configuration thread and the network thread. Shouldn't |
284 // be called from the network thread in the future. | 309 // be called from the network thread in the future. |
285 rate_control_.SetMinBitrate(min_bitrate_bps); | 310 rate_control_.SetMinBitrate(min_bitrate_bps); |
286 } | 311 } |
287 | 312 |
288 int64_t DelayBasedBwe::GetExpectedBwePeriodMs() const { | 313 int64_t DelayBasedBwe::GetExpectedBwePeriodMs() const { |
289 return rate_control_.GetExpectedBandwidthPeriodMs(); | 314 return rate_control_.GetExpectedBandwidthPeriodMs(); |
290 } | 315 } |
291 } // namespace webrtc | 316 } // namespace webrtc |
OLD | NEW |