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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 | 42 |
43 // Parameters for linear least squares fit of regression line to noisy data. | 43 // Parameters for linear least squares fit of regression line to noisy data. |
44 constexpr size_t kDefaultTrendlineWindowSize = 15; | 44 constexpr size_t kDefaultTrendlineWindowSize = 15; |
45 constexpr double kDefaultTrendlineSmoothingCoeff = 0.9; | 45 constexpr double kDefaultTrendlineSmoothingCoeff = 0.9; |
46 constexpr double kDefaultTrendlineThresholdGain = 4.0; | 46 constexpr double kDefaultTrendlineThresholdGain = 4.0; |
47 | 47 |
48 // Parameters for Theil-Sen robust fitting of line to noisy data. | 48 // Parameters for Theil-Sen robust fitting of line to noisy data. |
49 constexpr size_t kDefaultMedianSlopeWindowSize = 20; | 49 constexpr size_t kDefaultMedianSlopeWindowSize = 20; |
50 constexpr double kDefaultMedianSlopeThresholdGain = 4.0; | 50 constexpr double kDefaultMedianSlopeThresholdGain = 4.0; |
51 | 51 |
52 constexpr int kMaxConsecutiveFailedLookups = 5; | |
53 | |
52 const char kBitrateEstimateExperiment[] = "WebRTC-ImprovedBitrateEstimate"; | 54 const char kBitrateEstimateExperiment[] = "WebRTC-ImprovedBitrateEstimate"; |
53 const char kBweTrendlineFilterExperiment[] = "WebRTC-BweTrendlineFilter"; | 55 const char kBweTrendlineFilterExperiment[] = "WebRTC-BweTrendlineFilter"; |
54 const char kBweMedianSlopeFilterExperiment[] = "WebRTC-BweMedianSlopeFilter"; | 56 const char kBweMedianSlopeFilterExperiment[] = "WebRTC-BweMedianSlopeFilter"; |
55 | 57 |
56 bool BitrateEstimateExperimentIsEnabled() { | 58 bool BitrateEstimateExperimentIsEnabled() { |
57 return webrtc::field_trial::FindFullName(kBitrateEstimateExperiment) == | 59 return webrtc::field_trial::FindFullName(kBitrateEstimateExperiment) == |
58 "Enabled"; | 60 "Enabled"; |
59 } | 61 } |
60 | 62 |
61 bool TrendlineFilterExperimentIsEnabled() { | 63 bool TrendlineFilterExperimentIsEnabled() { |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 detector_(), | 218 detector_(), |
217 receiver_incoming_bitrate_(), | 219 receiver_incoming_bitrate_(), |
218 last_update_ms_(-1), | 220 last_update_ms_(-1), |
219 last_seen_packet_ms_(-1), | 221 last_seen_packet_ms_(-1), |
220 uma_recorded_(false), | 222 uma_recorded_(false), |
221 trendline_window_size_(kDefaultTrendlineWindowSize), | 223 trendline_window_size_(kDefaultTrendlineWindowSize), |
222 trendline_smoothing_coeff_(kDefaultTrendlineSmoothingCoeff), | 224 trendline_smoothing_coeff_(kDefaultTrendlineSmoothingCoeff), |
223 trendline_threshold_gain_(kDefaultTrendlineThresholdGain), | 225 trendline_threshold_gain_(kDefaultTrendlineThresholdGain), |
224 probing_interval_estimator_(&rate_control_), | 226 probing_interval_estimator_(&rate_control_), |
225 median_slope_window_size_(kDefaultMedianSlopeWindowSize), | 227 median_slope_window_size_(kDefaultMedianSlopeWindowSize), |
226 median_slope_threshold_gain_(kDefaultMedianSlopeThresholdGain) { | 228 median_slope_threshold_gain_(kDefaultMedianSlopeThresholdGain), |
229 consecutive_delayed_feedbacks_(0) { | |
227 if (in_trendline_experiment_) { | 230 if (in_trendline_experiment_) { |
228 ReadTrendlineFilterExperimentParameters(&trendline_window_size_, | 231 ReadTrendlineFilterExperimentParameters(&trendline_window_size_, |
229 &trendline_smoothing_coeff_, | 232 &trendline_smoothing_coeff_, |
230 &trendline_threshold_gain_); | 233 &trendline_threshold_gain_); |
231 LOG(LS_INFO) << "Trendline filter experiment enabled with parameters " | 234 LOG(LS_INFO) << "Trendline filter experiment enabled with parameters " |
232 << trendline_window_size_ << ',' << trendline_smoothing_coeff_ | 235 << trendline_window_size_ << ',' << trendline_smoothing_coeff_ |
233 << ',' << trendline_threshold_gain_; | 236 << ',' << trendline_threshold_gain_; |
234 } | 237 } |
235 if (in_median_slope_experiment_) { | 238 if (in_median_slope_experiment_) { |
236 ReadMedianSlopeFilterExperimentParameters(&median_slope_window_size_, | 239 ReadMedianSlopeFilterExperimentParameters(&median_slope_window_size_, |
(...skipping 12 matching lines...) Expand all Loading... | |
249 DelayBasedBwe::Result DelayBasedBwe::IncomingPacketFeedbackVector( | 252 DelayBasedBwe::Result DelayBasedBwe::IncomingPacketFeedbackVector( |
250 const std::vector<PacketInfo>& packet_feedback_vector) { | 253 const std::vector<PacketInfo>& packet_feedback_vector) { |
251 RTC_DCHECK(network_thread_.CalledOnValidThread()); | 254 RTC_DCHECK(network_thread_.CalledOnValidThread()); |
252 if (!uma_recorded_) { | 255 if (!uma_recorded_) { |
253 RTC_HISTOGRAM_ENUMERATION(kBweTypeHistogram, | 256 RTC_HISTOGRAM_ENUMERATION(kBweTypeHistogram, |
254 BweNames::kSendSideTransportSeqNum, | 257 BweNames::kSendSideTransportSeqNum, |
255 BweNames::kBweNamesMax); | 258 BweNames::kBweNamesMax); |
256 uma_recorded_ = true; | 259 uma_recorded_ = true; |
257 } | 260 } |
258 Result aggregated_result; | 261 Result aggregated_result; |
262 bool delayed_feedback = true; | |
259 for (const auto& packet_info : packet_feedback_vector) { | 263 for (const auto& packet_info : packet_feedback_vector) { |
264 if (packet_info.send_time_ms < 0) | |
265 continue; | |
266 delayed_feedback = false; | |
260 Result result = IncomingPacketInfo(packet_info); | 267 Result result = IncomingPacketInfo(packet_info); |
261 if (result.updated) | 268 if (result.updated) |
262 aggregated_result = result; | 269 aggregated_result = result; |
263 } | 270 } |
271 if (delayed_feedback) { | |
272 ++consecutive_delayed_feedbacks_; | |
273 } else { | |
274 consecutive_delayed_feedbacks_ = 0; | |
275 } | |
276 if (consecutive_delayed_feedbacks_ >= kMaxConsecutiveFailedLookups) { | |
277 aggregated_result = | |
278 OnLongFeedbackDelay(packet_feedback_vector.back().arrival_time_ms); | |
279 } | |
264 return aggregated_result; | 280 return aggregated_result; |
265 } | 281 } |
266 | 282 |
283 DelayBasedBwe::Result DelayBasedBwe::OnLongFeedbackDelay( | |
284 int64_t arrival_time_ms) { | |
285 RTC_DCHECK(rate_control_.ValidEstimate()); | |
terelius
2017/02/10 15:21:12
Is this DCHECK really guaranteed to pass? There ar
stefan-webrtc
2017/02/13 08:22:48
It is guranteed, since we always set the start bit
nisse-webrtc
2017/02/13 09:55:34
What's the alternative? Do nothing if there's no e
stefan-webrtc
2017/02/13 14:41:13
Either that, or to take our estimated acked bitrat
terelius
2017/02/13 14:46:47
Acknowledged.
nisse-webrtc
2017/02/13 14:49:49
If we think RTC_DCHECK is good enough for now, can
stefan-webrtc
2017/02/13 15:35:48
Extended the comment. Thanks
| |
286 rate_control_.SetEstimate(rate_control_.LatestEstimate() / 2, | |
287 arrival_time_ms); | |
288 Result result; | |
289 result.updated = true; | |
290 result.probe = false; | |
291 result.target_bitrate_bps = rate_control_.LatestEstimate(); | |
292 consecutive_delayed_feedbacks_ = 0; | |
293 LOG(LS_WARNING) << "Long feedback delay detected, reducing BWE to " | |
294 << result.target_bitrate_bps; | |
295 return result; | |
296 } | |
297 | |
267 DelayBasedBwe::Result DelayBasedBwe::IncomingPacketInfo( | 298 DelayBasedBwe::Result DelayBasedBwe::IncomingPacketInfo( |
268 const PacketInfo& info) { | 299 const PacketInfo& info) { |
269 int64_t now_ms = clock_->TimeInMilliseconds(); | 300 int64_t now_ms = clock_->TimeInMilliseconds(); |
270 | 301 |
271 receiver_incoming_bitrate_.Update(info.arrival_time_ms, info.payload_size); | 302 receiver_incoming_bitrate_.Update(info.arrival_time_ms, info.payload_size); |
272 Result result; | 303 Result result; |
273 // Reset if the stream has timed out. | 304 // Reset if the stream has timed out. |
274 if (last_seen_packet_ms_ == -1 || | 305 if (last_seen_packet_ms_ == -1 || |
275 now_ms - last_seen_packet_ms_ > kStreamTimeOutMs) { | 306 now_ms - last_seen_packet_ms_ > kStreamTimeOutMs) { |
276 inter_arrival_.reset( | 307 inter_arrival_.reset( |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
400 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) { | 431 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) { |
401 // Called from both the configuration thread and the network thread. Shouldn't | 432 // Called from both the configuration thread and the network thread. Shouldn't |
402 // be called from the network thread in the future. | 433 // be called from the network thread in the future. |
403 rate_control_.SetMinBitrate(min_bitrate_bps); | 434 rate_control_.SetMinBitrate(min_bitrate_bps); |
404 } | 435 } |
405 | 436 |
406 int64_t DelayBasedBwe::GetProbingIntervalMs() const { | 437 int64_t DelayBasedBwe::GetProbingIntervalMs() const { |
407 return probing_interval_estimator_.GetIntervalMs(); | 438 return probing_interval_estimator_.GetIntervalMs(); |
408 } | 439 } |
409 } // namespace webrtc | 440 } // namespace webrtc |
OLD | NEW |