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

Side by Side Diff: webrtc/modules/pacing/alr_detector.cc

Issue 2504023002: Implement periodic bandwidth probing in application-limited region. (Closed)
Patch Set: address feedback Created 4 years 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 | « webrtc/modules/pacing/alr_detector.h ('k') | webrtc/modules/pacing/alr_detector_unittest.cc » ('j') | 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) 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 26 matching lines...) Expand all
37 37
38 void AlrDetector::OnBytesSent(size_t bytes_sent, int64_t now_ms) { 38 void AlrDetector::OnBytesSent(size_t bytes_sent, int64_t now_ms) {
39 RTC_DCHECK(estimated_bitrate_bps_); 39 RTC_DCHECK(estimated_bitrate_bps_);
40 40
41 rate_.Update(bytes_sent, now_ms); 41 rate_.Update(bytes_sent, now_ms);
42 rtc::Optional<uint32_t> rate = rate_.Rate(now_ms); 42 rtc::Optional<uint32_t> rate = rate_.Rate(now_ms);
43 if (!rate) 43 if (!rate)
44 return; 44 return;
45 45
46 int percentage = static_cast<int>(*rate) * 100 / estimated_bitrate_bps_; 46 int percentage = static_cast<int>(*rate) * 100 / estimated_bitrate_bps_;
47 if (percentage < kAlrStartUsagePercent && !application_limited_) { 47 if (percentage < kAlrStartUsagePercent && !alr_started_time_ms_) {
48 application_limited_ = true; 48 alr_started_time_ms_ = rtc::Optional<int64_t>(now_ms);
49 } else if (percentage > kAlrEndUsagePercent && application_limited_) { 49 } else if (percentage > kAlrEndUsagePercent && alr_started_time_ms_) {
50 application_limited_ = false; 50 alr_started_time_ms_ = rtc::Optional<int64_t>();
51 } 51 }
52 } 52 }
53 53
54 void AlrDetector::SetEstimatedBitrate(int bitrate_bps) { 54 void AlrDetector::SetEstimatedBitrate(int bitrate_bps) {
55 RTC_DCHECK(bitrate_bps); 55 RTC_DCHECK(bitrate_bps);
56 estimated_bitrate_bps_ = bitrate_bps; 56 estimated_bitrate_bps_ = bitrate_bps;
57 } 57 }
58 58
59 bool AlrDetector::InApplicationLimitedRegion() const { 59 rtc::Optional<int64_t> AlrDetector::GetApplicationLimitedRegionStartTime()
60 return application_limited_; 60 const {
61 return alr_started_time_ms_;
61 } 62 }
62 63
63 } // namespace webrtc 64 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/pacing/alr_detector.h ('k') | webrtc/modules/pacing/alr_detector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698