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

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

Issue 2637783003: Move congestion controller processing to the pacer thread. (Closed)
Patch Set: Reorder calls in CongestionController::Process. 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.
39 RTC_DCHECK(estimated_bitrate_bps_); 43 RTC_DCHECK(estimated_bitrate_bps_);
40 44
41 rate_.Update(bytes_sent, now_ms); 45 rate_.Update(bytes_sent, now_ms);
42 rtc::Optional<uint32_t> rate = rate_.Rate(now_ms); 46 rtc::Optional<uint32_t> rate = rate_.Rate(now_ms);
43 if (!rate) 47 if (!rate)
44 return; 48 return;
45 49
46 int percentage = static_cast<int>(*rate) * 100 / estimated_bitrate_bps_; 50 int percentage = static_cast<int>(*rate) * 100 / estimated_bitrate_bps_;
47 if (percentage < kAlrStartUsagePercent && !alr_started_time_ms_) { 51 if (percentage < kAlrStartUsagePercent && !alr_started_time_ms_) {
48 alr_started_time_ms_ = rtc::Optional<int64_t>(now_ms); 52 alr_started_time_ms_ = rtc::Optional<int64_t>(now_ms);
49 } else if (percentage > kAlrEndUsagePercent && alr_started_time_ms_) { 53 } else if (percentage > kAlrEndUsagePercent && alr_started_time_ms_) {
50 alr_started_time_ms_ = rtc::Optional<int64_t>(); 54 alr_started_time_ms_ = rtc::Optional<int64_t>();
51 } 55 }
52 } 56 }
53 57
54 void AlrDetector::SetEstimatedBitrate(int bitrate_bps) { 58 void AlrDetector::SetEstimatedBitrate(int bitrate_bps) {
55 RTC_DCHECK(bitrate_bps); 59 RTC_DCHECK(bitrate_bps);
56 estimated_bitrate_bps_ = bitrate_bps; 60 estimated_bitrate_bps_ = bitrate_bps;
57 } 61 }
58 62
59 rtc::Optional<int64_t> AlrDetector::GetApplicationLimitedRegionStartTime() 63 rtc::Optional<int64_t> AlrDetector::GetApplicationLimitedRegionStartTime()
60 const { 64 const {
61 return alr_started_time_ms_; 65 return alr_started_time_ms_;
62 } 66 }
63 67
64 } // namespace webrtc 68 } // 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