OLD | NEW |
---|---|
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 Loading... | |
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_ = 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_ = 0; |
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_ == 0 | |
62 ? rtc::Optional<int64_t>() | |
stefan-webrtc
2016/11/28 13:27:13
I would have made alr_started_time_ms_ an rtc::Opt
Sergey Ulanov
2016/11/28 20:39:00
Done.
| |
63 : rtc::Optional<int64_t>(alr_started_time_ms_); | |
61 } | 64 } |
62 | 65 |
63 } // namespace webrtc | 66 } // namespace webrtc |
OLD | NEW |