Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1671)

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc

Issue 2029593002: Update RateStatistics to handle too-little-data case. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed comment Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 19 matching lines...) Expand all
30 AimdRateControl::AimdRateControl() 30 AimdRateControl::AimdRateControl()
31 : min_configured_bitrate_bps_( 31 : min_configured_bitrate_bps_(
32 RemoteBitrateEstimator::kDefaultMinBitrateBps), 32 RemoteBitrateEstimator::kDefaultMinBitrateBps),
33 max_configured_bitrate_bps_(30000000), 33 max_configured_bitrate_bps_(30000000),
34 current_bitrate_bps_(max_configured_bitrate_bps_), 34 current_bitrate_bps_(max_configured_bitrate_bps_),
35 avg_max_bitrate_kbps_(-1.0f), 35 avg_max_bitrate_kbps_(-1.0f),
36 var_max_bitrate_kbps_(0.4f), 36 var_max_bitrate_kbps_(0.4f),
37 rate_control_state_(kRcHold), 37 rate_control_state_(kRcHold),
38 rate_control_region_(kRcMaxUnknown), 38 rate_control_region_(kRcMaxUnknown),
39 time_last_bitrate_change_(-1), 39 time_last_bitrate_change_(-1),
40 current_input_(kBwNormal, 0, 1.0), 40 current_input_(kBwNormal, rtc::Optional<uint32_t>(), 1.0),
41 updated_(false), 41 updated_(false),
42 time_first_incoming_estimate_(-1), 42 time_first_incoming_estimate_(-1),
43 bitrate_is_initialized_(false), 43 bitrate_is_initialized_(false),
44 beta_(0.85f), 44 beta_(0.85f),
45 rtt_(kDefaultRttMs), 45 rtt_(kDefaultRttMs),
46 time_of_last_log_(-1), 46 time_of_last_log_(-1),
47 in_experiment_(!AdaptiveThresholdExperimentIsDisabled()) {} 47 in_experiment_(!AdaptiveThresholdExperimentIsDisabled()) {}
48 48
49 void AimdRateControl::SetMinBitrate(int min_bitrate_bps) { 49 void AimdRateControl::SetMinBitrate(int min_bitrate_bps) {
50 min_configured_bitrate_bps_ = min_bitrate_bps; 50 min_configured_bitrate_bps_ = min_bitrate_bps;
(...skipping 29 matching lines...) Expand all
80 return bitrate_difference > threshold; 80 return bitrate_difference > threshold;
81 } 81 }
82 return false; 82 return false;
83 } 83 }
84 84
85 uint32_t AimdRateControl::LatestEstimate() const { 85 uint32_t AimdRateControl::LatestEstimate() const {
86 return current_bitrate_bps_; 86 return current_bitrate_bps_;
87 } 87 }
88 88
89 uint32_t AimdRateControl::UpdateBandwidthEstimate(int64_t now_ms) { 89 uint32_t AimdRateControl::UpdateBandwidthEstimate(int64_t now_ms) {
90 current_bitrate_bps_ = ChangeBitrate(current_bitrate_bps_, 90 current_bitrate_bps_ = ChangeBitrate(
91 current_input_.incoming_bitrate, now_ms); 91 current_bitrate_bps_,
92 current_input_.incoming_bitrate.value_or(current_bitrate_bps_), now_ms);
92 if (now_ms - time_of_last_log_ > kLogIntervalMs) { 93 if (now_ms - time_of_last_log_ > kLogIntervalMs) {
93 time_of_last_log_ = now_ms; 94 time_of_last_log_ = now_ms;
94 } 95 }
95 return current_bitrate_bps_; 96 return current_bitrate_bps_;
96 } 97 }
97 98
98 void AimdRateControl::SetRtt(int64_t rtt) { 99 void AimdRateControl::SetRtt(int64_t rtt) {
99 rtt_ = rtt; 100 rtt_ = rtt;
100 } 101 }
101 102
102 void AimdRateControl::Update(const RateControlInput* input, int64_t now_ms) { 103 void AimdRateControl::Update(const RateControlInput* input, int64_t now_ms) {
103 assert(input); 104 RTC_CHECK(input);
104 105
105 // Set the initial bit rate value to what we're receiving the first half 106 // Set the initial bit rate value to what we're receiving the first half
106 // second. 107 // second.
107 if (!bitrate_is_initialized_) { 108 if (!bitrate_is_initialized_) {
108 const int64_t kInitializationTimeMs = 5000; 109 const int64_t kInitializationTimeMs = 5000;
109 RTC_DCHECK_LE(kBitrateWindowMs, kInitializationTimeMs); 110 RTC_DCHECK_LE(kBitrateWindowMs, kInitializationTimeMs);
110 if (time_first_incoming_estimate_ < 0) { 111 if (time_first_incoming_estimate_ < 0) {
111 if (input->incoming_bitrate > 0) { 112 if (input->incoming_bitrate)
112 time_first_incoming_estimate_ = now_ms; 113 time_first_incoming_estimate_ = now_ms;
113 }
114 } else if (now_ms - time_first_incoming_estimate_ > kInitializationTimeMs && 114 } else if (now_ms - time_first_incoming_estimate_ > kInitializationTimeMs &&
115 input->incoming_bitrate > 0) { 115 input->incoming_bitrate) {
116 current_bitrate_bps_ = input->incoming_bitrate; 116 current_bitrate_bps_ = *input->incoming_bitrate;
117 bitrate_is_initialized_ = true; 117 bitrate_is_initialized_ = true;
118 } 118 }
119 } 119 }
120 120
121 if (updated_ && current_input_.bw_state == kBwOverusing) { 121 if (updated_ && current_input_.bw_state == kBwOverusing) {
122 // Only update delay factor and incoming bit rate. We always want to react 122 // Only update delay factor and incoming bit rate. We always want to react
123 // on an over-use. 123 // on an over-use.
124 current_input_.noise_var = input->noise_var; 124 current_input_.noise_var = input->noise_var;
125 current_input_.incoming_bitrate = input->incoming_bitrate; 125 current_input_.incoming_bitrate = input->incoming_bitrate;
126 } else { 126 } else {
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 304 }
305 305
306 void AimdRateControl::ChangeRegion(RateControlRegion region) { 306 void AimdRateControl::ChangeRegion(RateControlRegion region) {
307 rate_control_region_ = region; 307 rate_control_region_ = region;
308 } 308 }
309 309
310 void AimdRateControl::ChangeState(RateControlState new_state) { 310 void AimdRateControl::ChangeState(RateControlState new_state) {
311 rate_control_state_ = new_state; 311 rate_control_state_ = new_state;
312 } 312 }
313 } // namespace webrtc 313 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698