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

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

Issue 2644603003: Revert of Move congestion controller processing to the pacer thread. (Closed)
Patch Set: Created 3 years, 11 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) 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 18 matching lines...) Expand all
29 } // namespace 29 } // namespace
30 30
31 namespace webrtc { 31 namespace webrtc {
32 32
33 AlrDetector::AlrDetector() 33 AlrDetector::AlrDetector()
34 : rate_(kMeasurementPeriodMs, RateStatistics::kBpsScale) {} 34 : rate_(kMeasurementPeriodMs, RateStatistics::kBpsScale) {}
35 35
36 AlrDetector::~AlrDetector() {} 36 AlrDetector::~AlrDetector() {}
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 // TODO(nisse): It's unclear what guarantees there are that this
40 // function isn't called before SetEstimatedBitrate. Document that
41 // guarantee, if it exists. Or else, remove the DCHECK and tolerate
42 // that current estimate is zero, e.g., by just returning false.
43 RTC_DCHECK(estimated_bitrate_bps_); 39 RTC_DCHECK(estimated_bitrate_bps_);
44 40
45 rate_.Update(bytes_sent, now_ms); 41 rate_.Update(bytes_sent, now_ms);
46 rtc::Optional<uint32_t> rate = rate_.Rate(now_ms); 42 rtc::Optional<uint32_t> rate = rate_.Rate(now_ms);
47 if (!rate) 43 if (!rate)
48 return; 44 return;
49 45
50 int percentage = static_cast<int>(*rate) * 100 / estimated_bitrate_bps_; 46 int percentage = static_cast<int>(*rate) * 100 / estimated_bitrate_bps_;
51 if (percentage < kAlrStartUsagePercent && !alr_started_time_ms_) { 47 if (percentage < kAlrStartUsagePercent && !alr_started_time_ms_) {
52 alr_started_time_ms_ = rtc::Optional<int64_t>(now_ms); 48 alr_started_time_ms_ = rtc::Optional<int64_t>(now_ms);
53 } else if (percentage > kAlrEndUsagePercent && alr_started_time_ms_) { 49 } else if (percentage > kAlrEndUsagePercent && alr_started_time_ms_) {
54 alr_started_time_ms_ = rtc::Optional<int64_t>(); 50 alr_started_time_ms_ = rtc::Optional<int64_t>();
55 } 51 }
56 } 52 }
57 53
58 void AlrDetector::SetEstimatedBitrate(int bitrate_bps) { 54 void AlrDetector::SetEstimatedBitrate(int bitrate_bps) {
59 RTC_DCHECK(bitrate_bps); 55 RTC_DCHECK(bitrate_bps);
60 estimated_bitrate_bps_ = bitrate_bps; 56 estimated_bitrate_bps_ = bitrate_bps;
61 } 57 }
62 58
63 rtc::Optional<int64_t> AlrDetector::GetApplicationLimitedRegionStartTime() 59 rtc::Optional<int64_t> AlrDetector::GetApplicationLimitedRegionStartTime()
64 const { 60 const {
65 return alr_started_time_ms_; 61 return alr_started_time_ms_;
66 } 62 }
67 63
68 } // namespace webrtc 64 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/congestion_controller/congestion_controller.cc ('k') | webrtc/modules/pacing/paced_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698