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

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

Issue 2637783003: Move congestion controller processing to the pacer thread. (Closed)
Patch Set: Fixed method call order for AlrDetector. 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.
stefan-webrtc 2017/01/16 15:42:46 I guess the guarantee is here in form of a DCHECK.
nisse-webrtc 2017/01/16 16:14:03 Problem was, this thread reorg made this check cra
39 RTC_DCHECK(estimated_bitrate_bps_); 41 RTC_DCHECK(estimated_bitrate_bps_);
40 42
41 rate_.Update(bytes_sent, now_ms); 43 rate_.Update(bytes_sent, now_ms);
42 rtc::Optional<uint32_t> rate = rate_.Rate(now_ms); 44 rtc::Optional<uint32_t> rate = rate_.Rate(now_ms);
43 if (!rate) 45 if (!rate)
44 return; 46 return;
45 47
46 int percentage = static_cast<int>(*rate) * 100 / estimated_bitrate_bps_; 48 int percentage = static_cast<int>(*rate) * 100 / estimated_bitrate_bps_;
47 if (percentage < kAlrStartUsagePercent && !alr_started_time_ms_) { 49 if (percentage < kAlrStartUsagePercent && !alr_started_time_ms_) {
48 alr_started_time_ms_ = rtc::Optional<int64_t>(now_ms); 50 alr_started_time_ms_ = rtc::Optional<int64_t>(now_ms);
49 } else if (percentage > kAlrEndUsagePercent && alr_started_time_ms_) { 51 } else if (percentage > kAlrEndUsagePercent && alr_started_time_ms_) {
50 alr_started_time_ms_ = rtc::Optional<int64_t>(); 52 alr_started_time_ms_ = rtc::Optional<int64_t>();
51 } 53 }
52 } 54 }
53 55
54 void AlrDetector::SetEstimatedBitrate(int bitrate_bps) { 56 void AlrDetector::SetEstimatedBitrate(int bitrate_bps) {
55 RTC_DCHECK(bitrate_bps); 57 RTC_DCHECK(bitrate_bps);
56 estimated_bitrate_bps_ = bitrate_bps; 58 estimated_bitrate_bps_ = bitrate_bps;
57 } 59 }
58 60
59 rtc::Optional<int64_t> AlrDetector::GetApplicationLimitedRegionStartTime() 61 rtc::Optional<int64_t> AlrDetector::GetApplicationLimitedRegionStartTime()
60 const { 62 const {
61 return alr_started_time_ms_; 63 return alr_started_time_ms_;
62 } 64 }
63 65
64 } // namespace webrtc 66 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698