| 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 | 
| 11 #include "webrtc/modules/congestion_controller/delay_based_bwe.h" | 11 #include "webrtc/modules/congestion_controller/delay_based_bwe.h" | 
| 12 | 12 | 
| 13 #include <algorithm> | 13 #include <algorithm> | 
| 14 #include <cmath> | 14 #include <cmath> | 
| 15 #include <string> | 15 #include <string> | 
| 16 | 16 | 
| 17 #include "webrtc/base/checks.h" | 17 #include "webrtc/base/checks.h" | 
| 18 #include "webrtc/base/constructormagic.h" | 18 #include "webrtc/base/constructormagic.h" | 
| 19 #include "webrtc/base/logging.h" | 19 #include "webrtc/base/logging.h" | 
| 20 #include "webrtc/base/thread_annotations.h" | 20 #include "webrtc/base/thread_annotations.h" | 
|  | 21 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 
| 21 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" | 22 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" | 
| 22 #include "webrtc/modules/pacing/paced_sender.h" | 23 #include "webrtc/modules/pacing/paced_sender.h" | 
| 23 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
     or.h" | 24 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
     or.h" | 
| 24 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" | 25 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" | 
| 25 #include "webrtc/system_wrappers/include/field_trial.h" | 26 #include "webrtc/system_wrappers/include/field_trial.h" | 
| 26 #include "webrtc/system_wrappers/include/metrics.h" | 27 #include "webrtc/system_wrappers/include/metrics.h" | 
| 27 #include "webrtc/typedefs.h" | 28 #include "webrtc/typedefs.h" | 
| 28 | 29 | 
| 29 namespace { | 30 namespace { | 
| 30 constexpr int kTimestampGroupLengthMs = 5; | 31 constexpr int kTimestampGroupLengthMs = 5; | 
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 201   sum_ += bytes; | 202   sum_ += bytes; | 
| 202   return bitrate_sample; | 203   return bitrate_sample; | 
| 203 } | 204 } | 
| 204 | 205 | 
| 205 rtc::Optional<uint32_t> DelayBasedBwe::BitrateEstimator::bitrate_bps() const { | 206 rtc::Optional<uint32_t> DelayBasedBwe::BitrateEstimator::bitrate_bps() const { | 
| 206   if (bitrate_estimate_ < 0.f) | 207   if (bitrate_estimate_ < 0.f) | 
| 207     return rtc::Optional<uint32_t>(); | 208     return rtc::Optional<uint32_t>(); | 
| 208   return rtc::Optional<uint32_t>(bitrate_estimate_ * 1000); | 209   return rtc::Optional<uint32_t>(bitrate_estimate_ * 1000); | 
| 209 } | 210 } | 
| 210 | 211 | 
| 211 DelayBasedBwe::DelayBasedBwe(Clock* clock) | 212 DelayBasedBwe::DelayBasedBwe(RtcEventLog* event_log, Clock* clock) | 
| 212     : in_trendline_experiment_(TrendlineFilterExperimentIsEnabled()), | 213     : in_trendline_experiment_(TrendlineFilterExperimentIsEnabled()), | 
| 213       in_median_slope_experiment_(MedianSlopeFilterExperimentIsEnabled()), | 214       in_median_slope_experiment_(MedianSlopeFilterExperimentIsEnabled()), | 
|  | 215       event_log_(event_log), | 
| 214       clock_(clock), | 216       clock_(clock), | 
| 215       inter_arrival_(), | 217       inter_arrival_(), | 
| 216       kalman_estimator_(), | 218       kalman_estimator_(), | 
| 217       trendline_estimator_(), | 219       trendline_estimator_(), | 
| 218       detector_(), | 220       detector_(), | 
| 219       receiver_incoming_bitrate_(), | 221       receiver_incoming_bitrate_(), | 
| 220       last_update_ms_(-1), | 222       last_update_ms_(-1), | 
| 221       last_seen_packet_ms_(-1), | 223       last_seen_packet_ms_(-1), | 
| 222       uma_recorded_(false), | 224       uma_recorded_(false), | 
| 223       trendline_window_size_(kDefaultTrendlineWindowSize), | 225       trendline_window_size_(kDefaultTrendlineWindowSize), | 
| 224       trendline_smoothing_coeff_(kDefaultTrendlineSmoothingCoeff), | 226       trendline_smoothing_coeff_(kDefaultTrendlineSmoothingCoeff), | 
| 225       trendline_threshold_gain_(kDefaultTrendlineThresholdGain), | 227       trendline_threshold_gain_(kDefaultTrendlineThresholdGain), | 
| 226       probing_interval_estimator_(&rate_control_), | 228       probing_interval_estimator_(&rate_control_), | 
| 227       median_slope_window_size_(kDefaultMedianSlopeWindowSize), | 229       median_slope_window_size_(kDefaultMedianSlopeWindowSize), | 
| 228       median_slope_threshold_gain_(kDefaultMedianSlopeThresholdGain), | 230       median_slope_threshold_gain_(kDefaultMedianSlopeThresholdGain), | 
| 229       consecutive_delayed_feedbacks_(0) { | 231       consecutive_delayed_feedbacks_(0), | 
|  | 232       last_logged_bitrate_(0), | 
|  | 233       last_logged_state_(kBwNormal) { | 
| 230   if (in_trendline_experiment_) { | 234   if (in_trendline_experiment_) { | 
| 231     ReadTrendlineFilterExperimentParameters(&trendline_window_size_, | 235     ReadTrendlineFilterExperimentParameters(&trendline_window_size_, | 
| 232                                             &trendline_smoothing_coeff_, | 236                                             &trendline_smoothing_coeff_, | 
| 233                                             &trendline_threshold_gain_); | 237                                             &trendline_threshold_gain_); | 
| 234     LOG(LS_INFO) << "Trendline filter experiment enabled with parameters " | 238     LOG(LS_INFO) << "Trendline filter experiment enabled with parameters " | 
| 235                  << trendline_window_size_ << ',' << trendline_smoothing_coeff_ | 239                  << trendline_window_size_ << ',' << trendline_smoothing_coeff_ | 
| 236                  << ',' << trendline_threshold_gain_; | 240                  << ',' << trendline_threshold_gain_; | 
| 237   } | 241   } | 
| 238   if (in_median_slope_experiment_) { | 242   if (in_median_slope_experiment_) { | 
| 239     ReadMedianSlopeFilterExperimentParameters(&median_slope_window_size_, | 243     ReadMedianSlopeFilterExperimentParameters(&median_slope_window_size_, | 
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 382       (last_update_ms_ == -1 || | 386       (last_update_ms_ == -1 || | 
| 383        now_ms - last_update_ms_ > rate_control_.GetFeedbackInterval())) { | 387        now_ms - last_update_ms_ > rate_control_.GetFeedbackInterval())) { | 
| 384     result.updated = | 388     result.updated = | 
| 385         UpdateEstimate(info.arrival_time_ms, now_ms, acked_bitrate_bps, | 389         UpdateEstimate(info.arrival_time_ms, now_ms, acked_bitrate_bps, | 
| 386                        &result.target_bitrate_bps); | 390                        &result.target_bitrate_bps); | 
| 387   } | 391   } | 
| 388   if (result.updated) { | 392   if (result.updated) { | 
| 389     last_update_ms_ = now_ms; | 393     last_update_ms_ = now_ms; | 
| 390     BWE_TEST_LOGGING_PLOT(1, "target_bitrate_bps", now_ms, | 394     BWE_TEST_LOGGING_PLOT(1, "target_bitrate_bps", now_ms, | 
| 391                           result.target_bitrate_bps); | 395                           result.target_bitrate_bps); | 
|  | 396     if (event_log_ && (result.target_bitrate_bps != last_logged_bitrate_ || | 
|  | 397                        detector_.State() != last_logged_state_)) { | 
|  | 398       event_log_->LogDelayBasedBweUpdate(result.target_bitrate_bps, | 
|  | 399                                          detector_.State()); | 
|  | 400       last_logged_bitrate_ = result.target_bitrate_bps; | 
|  | 401       last_logged_state_ = detector_.State(); | 
|  | 402     } | 
| 392   } | 403   } | 
| 393 | 404 | 
| 394   return result; | 405   return result; | 
| 395 } | 406 } | 
| 396 | 407 | 
| 397 bool DelayBasedBwe::UpdateEstimate(int64_t arrival_time_ms, | 408 bool DelayBasedBwe::UpdateEstimate(int64_t arrival_time_ms, | 
| 398                                    int64_t now_ms, | 409                                    int64_t now_ms, | 
| 399                                    rtc::Optional<uint32_t> acked_bitrate_bps, | 410                                    rtc::Optional<uint32_t> acked_bitrate_bps, | 
| 400                                    uint32_t* target_bitrate_bps) { | 411                                    uint32_t* target_bitrate_bps) { | 
| 401   // TODO(terelius): RateControlInput::noise_var is deprecated and will be | 412   // TODO(terelius): RateControlInput::noise_var is deprecated and will be | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 434 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) { | 445 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) { | 
| 435   // Called from both the configuration thread and the network thread. Shouldn't | 446   // Called from both the configuration thread and the network thread. Shouldn't | 
| 436   // be called from the network thread in the future. | 447   // be called from the network thread in the future. | 
| 437   rate_control_.SetMinBitrate(min_bitrate_bps); | 448   rate_control_.SetMinBitrate(min_bitrate_bps); | 
| 438 } | 449 } | 
| 439 | 450 | 
| 440 int64_t DelayBasedBwe::GetProbingIntervalMs() const { | 451 int64_t DelayBasedBwe::GetProbingIntervalMs() const { | 
| 441   return probing_interval_estimator_.GetIntervalMs(); | 452   return probing_interval_estimator_.GetIntervalMs(); | 
| 442 } | 453 } | 
| 443 }  // namespace webrtc | 454 }  // namespace webrtc | 
| OLD | NEW | 
|---|