| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 constexpr size_t kDefaultTrendlineWindowSize = 15; | 45 constexpr size_t kDefaultTrendlineWindowSize = 15; |
| 46 constexpr double kDefaultTrendlineSmoothingCoeff = 0.9; | 46 constexpr double kDefaultTrendlineSmoothingCoeff = 0.9; |
| 47 constexpr double kDefaultTrendlineThresholdGain = 4.0; | 47 constexpr double kDefaultTrendlineThresholdGain = 4.0; |
| 48 | 48 |
| 49 // Parameters for Theil-Sen robust fitting of line to noisy data. | 49 // Parameters for Theil-Sen robust fitting of line to noisy data. |
| 50 constexpr size_t kDefaultMedianSlopeWindowSize = 20; | 50 constexpr size_t kDefaultMedianSlopeWindowSize = 20; |
| 51 constexpr double kDefaultMedianSlopeThresholdGain = 4.0; | 51 constexpr double kDefaultMedianSlopeThresholdGain = 4.0; |
| 52 | 52 |
| 53 constexpr int kMaxConsecutiveFailedLookups = 5; | 53 constexpr int kMaxConsecutiveFailedLookups = 5; |
| 54 | 54 |
| 55 const char kBitrateEstimateExperiment[] = "WebRTC-ImprovedBitrateEstimate"; | |
| 56 const char kBweTrendlineFilterExperiment[] = "WebRTC-BweTrendlineFilter"; | 55 const char kBweTrendlineFilterExperiment[] = "WebRTC-BweTrendlineFilter"; |
| 57 const char kBweMedianSlopeFilterExperiment[] = "WebRTC-BweMedianSlopeFilter"; | 56 const char kBweMedianSlopeFilterExperiment[] = "WebRTC-BweMedianSlopeFilter"; |
| 58 | 57 |
| 59 bool BitrateEstimateExperimentIsEnabled() { | |
| 60 return webrtc::field_trial::IsEnabled(kBitrateEstimateExperiment); | |
| 61 } | |
| 62 | |
| 63 bool TrendlineFilterExperimentIsEnabled() { | 58 bool TrendlineFilterExperimentIsEnabled() { |
| 64 std::string experiment_string = | 59 std::string experiment_string = |
| 65 webrtc::field_trial::FindFullName(kBweTrendlineFilterExperiment); | 60 webrtc::field_trial::FindFullName(kBweTrendlineFilterExperiment); |
| 66 // The experiment is enabled iff the field trial string begins with "Enabled". | 61 // The experiment is enabled iff the field trial string begins with "Enabled". |
| 67 return experiment_string.find("Enabled") == 0; | 62 return experiment_string.find("Enabled") == 0; |
| 68 } | 63 } |
| 69 | 64 |
| 70 bool MedianSlopeFilterExperimentIsEnabled() { | 65 bool MedianSlopeFilterExperimentIsEnabled() { |
| 71 std::string experiment_string = | 66 std::string experiment_string = |
| 72 webrtc::field_trial::FindFullName(kBweMedianSlopeFilterExperiment); | 67 webrtc::field_trial::FindFullName(kBweMedianSlopeFilterExperiment); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 } | 141 } |
| 147 } // namespace | 142 } // namespace |
| 148 | 143 |
| 149 namespace webrtc { | 144 namespace webrtc { |
| 150 | 145 |
| 151 DelayBasedBwe::BitrateEstimator::BitrateEstimator() | 146 DelayBasedBwe::BitrateEstimator::BitrateEstimator() |
| 152 : sum_(0), | 147 : sum_(0), |
| 153 current_win_ms_(0), | 148 current_win_ms_(0), |
| 154 prev_time_ms_(-1), | 149 prev_time_ms_(-1), |
| 155 bitrate_estimate_(-1.0f), | 150 bitrate_estimate_(-1.0f), |
| 156 bitrate_estimate_var_(50.0f), | 151 bitrate_estimate_var_(50.0f) {} |
| 157 old_estimator_(kBitrateWindowMs, 8000), | |
| 158 in_experiment_(BitrateEstimateExperimentIsEnabled()) {} | |
| 159 | 152 |
| 160 void DelayBasedBwe::BitrateEstimator::Update(int64_t now_ms, int bytes) { | 153 void DelayBasedBwe::BitrateEstimator::Update(int64_t now_ms, int bytes) { |
| 161 if (!in_experiment_) { | |
| 162 old_estimator_.Update(bytes, now_ms); | |
| 163 rtc::Optional<uint32_t> rate = old_estimator_.Rate(now_ms); | |
| 164 bitrate_estimate_ = -1.0f; | |
| 165 if (rate) | |
| 166 bitrate_estimate_ = *rate / 1000.0f; | |
| 167 return; | |
| 168 } | |
| 169 int rate_window_ms = kRateWindowMs; | 154 int rate_window_ms = kRateWindowMs; |
| 170 // We use a larger window at the beginning to get a more stable sample that | 155 // We use a larger window at the beginning to get a more stable sample that |
| 171 // we can use to initialize the estimate. | 156 // we can use to initialize the estimate. |
| 172 if (bitrate_estimate_ < 0.f) | 157 if (bitrate_estimate_ < 0.f) |
| 173 rate_window_ms = kInitialRateWindowMs; | 158 rate_window_ms = kInitialRateWindowMs; |
| 174 float bitrate_sample = UpdateWindow(now_ms, bytes, rate_window_ms); | 159 float bitrate_sample = UpdateWindow(now_ms, bytes, rate_window_ms); |
| 175 if (bitrate_sample < 0.0f) | 160 if (bitrate_sample < 0.0f) |
| 176 return; | 161 return; |
| 177 if (bitrate_estimate_ < 0.0f) { | 162 if (bitrate_estimate_ < 0.0f) { |
| 178 // This is the very first sample we get. Use it to initialize the estimate. | 163 // This is the very first sample we get. Use it to initialize the estimate. |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) { | 464 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) { |
| 480 // Called from both the configuration thread and the network thread. Shouldn't | 465 // Called from both the configuration thread and the network thread. Shouldn't |
| 481 // be called from the network thread in the future. | 466 // be called from the network thread in the future. |
| 482 rate_control_.SetMinBitrate(min_bitrate_bps); | 467 rate_control_.SetMinBitrate(min_bitrate_bps); |
| 483 } | 468 } |
| 484 | 469 |
| 485 int64_t DelayBasedBwe::GetProbingIntervalMs() const { | 470 int64_t DelayBasedBwe::GetProbingIntervalMs() const { |
| 486 return probing_interval_estimator_.GetIntervalMs(); | 471 return probing_interval_estimator_.GetIntervalMs(); |
| 487 } | 472 } |
| 488 } // namespace webrtc | 473 } // namespace webrtc |
| OLD | NEW |