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

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

Issue 2800633004: Resolve dependency between rtc_event_log_api and remote_bitrate_estimator (Closed)
Patch Set: Rebased Created 3 years, 8 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 140
141 uint32_t AimdRateControl::ChangeBitrate(uint32_t new_bitrate_bps, 141 uint32_t AimdRateControl::ChangeBitrate(uint32_t new_bitrate_bps,
142 const RateControlInput& input, 142 const RateControlInput& input,
143 int64_t now_ms) { 143 int64_t now_ms) {
144 uint32_t incoming_bitrate_bps = 144 uint32_t incoming_bitrate_bps =
145 input.incoming_bitrate.value_or(current_bitrate_bps_); 145 input.incoming_bitrate.value_or(current_bitrate_bps_);
146 146
147 // An over-use should always trigger us to reduce the bitrate, even though 147 // An over-use should always trigger us to reduce the bitrate, even though
148 // we have not yet established our first estimate. By acting on the over-use, 148 // we have not yet established our first estimate. By acting on the over-use,
149 // we will end up with a valid estimate. 149 // we will end up with a valid estimate.
150 if (!bitrate_is_initialized_ && input.bw_state != kBwOverusing) 150 if (!bitrate_is_initialized_ &&
151 input.bw_state != BandwidthUsage::kBwOverusing)
151 return current_bitrate_bps_; 152 return current_bitrate_bps_;
152 153
153 ChangeState(input, now_ms); 154 ChangeState(input, now_ms);
154 // Calculated here because it's used in multiple places. 155 // Calculated here because it's used in multiple places.
155 const float incoming_bitrate_kbps = incoming_bitrate_bps / 1000.0f; 156 const float incoming_bitrate_kbps = incoming_bitrate_bps / 1000.0f;
156 // Calculate the max bit rate std dev given the normalized 157 // Calculate the max bit rate std dev given the normalized
157 // variance and the current incoming bit rate. 158 // variance and the current incoming bit rate.
158 const float std_max_bit_rate = sqrt(var_max_bitrate_kbps_ * 159 const float std_max_bit_rate = sqrt(var_max_bitrate_kbps_ *
159 avg_max_bitrate_kbps_); 160 avg_max_bitrate_kbps_);
160 switch (rate_control_state_) { 161 switch (rate_control_state_) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 } 273 }
273 // 2.5f ~= 35 kbit/s at 500 kbit/s 274 // 2.5f ~= 35 kbit/s at 500 kbit/s
274 if (var_max_bitrate_kbps_ > 2.5f) { 275 if (var_max_bitrate_kbps_ > 2.5f) {
275 var_max_bitrate_kbps_ = 2.5f; 276 var_max_bitrate_kbps_ = 2.5f;
276 } 277 }
277 } 278 }
278 279
279 void AimdRateControl::ChangeState(const RateControlInput& input, 280 void AimdRateControl::ChangeState(const RateControlInput& input,
280 int64_t now_ms) { 281 int64_t now_ms) {
281 switch (input.bw_state) { 282 switch (input.bw_state) {
282 case kBwNormal: 283 case BandwidthUsage::kBwNormal:
283 if (rate_control_state_ == kRcHold) { 284 if (rate_control_state_ == kRcHold) {
284 time_last_bitrate_change_ = now_ms; 285 time_last_bitrate_change_ = now_ms;
285 rate_control_state_ = kRcIncrease; 286 rate_control_state_ = kRcIncrease;
286 } 287 }
287 break; 288 break;
288 case kBwOverusing: 289 case BandwidthUsage::kBwOverusing:
289 if (rate_control_state_ != kRcDecrease) { 290 if (rate_control_state_ != kRcDecrease) {
290 rate_control_state_ = kRcDecrease; 291 rate_control_state_ = kRcDecrease;
291 } 292 }
292 break; 293 break;
293 case kBwUnderusing: 294 case BandwidthUsage::kBwUnderusing:
294 rate_control_state_ = kRcHold; 295 rate_control_state_ = kRcHold;
295 break; 296 break;
296 default: 297 default:
297 assert(false); 298 assert(false);
298 } 299 }
299 } 300 }
300 301
301 void AimdRateControl::ChangeRegion(RateControlRegion region) { 302 void AimdRateControl::ChangeRegion(RateControlRegion region) {
302 rate_control_region_ = region; 303 rate_control_region_ = region;
303 } 304 }
304 305
305 } // namespace webrtc 306 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698