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 consecutive_delayed_feedbacks_ = 0; |
| 280 } |
264 return aggregated_result; | 281 return aggregated_result; |
265 } | 282 } |
266 | 283 |
| 284 DelayBasedBwe::Result DelayBasedBwe::OnLongFeedbackDelay( |
| 285 int64_t arrival_time_ms) { |
| 286 // Estimate should always be valid since a start bitrate always is set in the |
| 287 // Call constructor. An alternative would be to return an empty Result here, |
| 288 // or to estimate the throughput based on the feedback we received. |
| 289 RTC_DCHECK(rate_control_.ValidEstimate()); |
| 290 rate_control_.SetEstimate(rate_control_.LatestEstimate() / 2, |
| 291 arrival_time_ms); |
| 292 Result result; |
| 293 result.updated = true; |
| 294 result.probe = false; |
| 295 result.target_bitrate_bps = rate_control_.LatestEstimate(); |
| 296 LOG(LS_WARNING) << "Long feedback delay detected, reducing BWE to " |
| 297 << result.target_bitrate_bps; |
| 298 return result; |
| 299 } |
| 300 |
267 DelayBasedBwe::Result DelayBasedBwe::IncomingPacketInfo( | 301 DelayBasedBwe::Result DelayBasedBwe::IncomingPacketInfo( |
268 const PacketInfo& info) { | 302 const PacketInfo& info) { |
269 int64_t now_ms = clock_->TimeInMilliseconds(); | 303 int64_t now_ms = clock_->TimeInMilliseconds(); |
270 | 304 |
271 receiver_incoming_bitrate_.Update(info.arrival_time_ms, info.payload_size); | 305 receiver_incoming_bitrate_.Update(info.arrival_time_ms, info.payload_size); |
272 Result result; | 306 Result result; |
273 // Reset if the stream has timed out. | 307 // Reset if the stream has timed out. |
274 if (last_seen_packet_ms_ == -1 || | 308 if (last_seen_packet_ms_ == -1 || |
275 now_ms - last_seen_packet_ms_ > kStreamTimeOutMs) { | 309 now_ms - last_seen_packet_ms_ > kStreamTimeOutMs) { |
276 inter_arrival_.reset( | 310 inter_arrival_.reset( |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) { | 434 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) { |
401 // Called from both the configuration thread and the network thread. Shouldn't | 435 // Called from both the configuration thread and the network thread. Shouldn't |
402 // be called from the network thread in the future. | 436 // be called from the network thread in the future. |
403 rate_control_.SetMinBitrate(min_bitrate_bps); | 437 rate_control_.SetMinBitrate(min_bitrate_bps); |
404 } | 438 } |
405 | 439 |
406 int64_t DelayBasedBwe::GetProbingIntervalMs() const { | 440 int64_t DelayBasedBwe::GetProbingIntervalMs() const { |
407 return probing_interval_estimator_.GetIntervalMs(); | 441 return probing_interval_estimator_.GetIntervalMs(); |
408 } | 442 } |
409 } // namespace webrtc | 443 } // namespace webrtc |
OLD | NEW |