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

Side by Side Diff: webrtc/modules/bitrate_controller/bitrate_controller_impl.cc

Issue 2725433002: Avoid calling TimeUntilNextProcess() from Process() in BitrateControllerImpl (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 int64_t BitrateControllerImpl::TimeUntilNextProcess() { 204 int64_t BitrateControllerImpl::TimeUntilNextProcess() {
205 const int64_t kBitrateControllerUpdateIntervalMs = 25; 205 const int64_t kBitrateControllerUpdateIntervalMs = 25;
206 rtc::CritScope cs(&critsect_); 206 rtc::CritScope cs(&critsect_);
207 int64_t time_since_update_ms = 207 int64_t time_since_update_ms =
208 clock_->TimeInMilliseconds() - last_bitrate_update_ms_; 208 clock_->TimeInMilliseconds() - last_bitrate_update_ms_;
209 return std::max<int64_t>( 209 return std::max<int64_t>(
210 kBitrateControllerUpdateIntervalMs - time_since_update_ms, 0); 210 kBitrateControllerUpdateIntervalMs - time_since_update_ms, 0);
211 } 211 }
212 212
213 void BitrateControllerImpl::Process() { 213 void BitrateControllerImpl::Process() {
214 if (TimeUntilNextProcess() > 0)
215 return;
216 { 214 {
217 rtc::CritScope cs(&critsect_); 215 rtc::CritScope cs(&critsect_);
218 bandwidth_estimation_.UpdateEstimate(clock_->TimeInMilliseconds()); 216 bandwidth_estimation_.UpdateEstimate(clock_->TimeInMilliseconds());
219 } 217 }
220 MaybeTriggerOnNetworkChanged(); 218 MaybeTriggerOnNetworkChanged();
221 last_bitrate_update_ms_ = clock_->TimeInMilliseconds(); 219 last_bitrate_update_ms_ = clock_->TimeInMilliseconds();
222 } 220 }
223 221
224 void BitrateControllerImpl::OnReceivedRtcpReceiverReport( 222 void BitrateControllerImpl::OnReceivedRtcpReceiverReport(
225 uint8_t fraction_loss, 223 uint8_t fraction_loss,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 bandwidth_estimation_.CurrentEstimate(&bitrate, &fraction_loss, &rtt); 284 bandwidth_estimation_.CurrentEstimate(&bitrate, &fraction_loss, &rtt);
287 if (bitrate > 0) { 285 if (bitrate > 0) {
288 bitrate = bitrate - std::min<int>(bitrate, reserved_bitrate_bps_); 286 bitrate = bitrate - std::min<int>(bitrate, reserved_bitrate_bps_);
289 bitrate = std::max(bitrate, bandwidth_estimation_.GetMinBitrate()); 287 bitrate = std::max(bitrate, bandwidth_estimation_.GetMinBitrate());
290 *bandwidth = bitrate; 288 *bandwidth = bitrate;
291 return true; 289 return true;
292 } 290 }
293 return false; 291 return false;
294 } 292 }
295 } // namespace webrtc 293 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698