mflodman@webrtc.org | e6168f5 | 2013-06-26 11:23:01 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
kwiberg | 27f982b | 2016-03-01 11:52:33 -0800 | [diff] [blame] | 11 | #include <memory> |
| 12 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 13 | #include "api/video/i420_buffer.h" |
| 14 | #include "common_video/include/video_frame.h" |
| 15 | #include "modules/video_coding/utility/quality_scaler.h" |
| 16 | #include "rtc_base/event.h" |
| 17 | #include "rtc_base/fakeclock.h" |
Niels Möller | e541be7 | 2017-12-13 13:03:10 +0100 | [diff] [blame] | 18 | #include "rtc_base/random.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 19 | #include "test/gmock.h" |
| 20 | #include "test/gtest.h" |
| 21 | #include "video/overuse_frame_detector.h" |
mflodman@webrtc.org | e6168f5 | 2013-06-26 11:23:01 +0000 | [diff] [blame] | 22 | |
mflodman@webrtc.org | e6168f5 | 2013-06-26 11:23:01 +0000 | [diff] [blame] | 23 | namespace webrtc { |
perkj | d52063f | 2016-09-07 06:32:18 -0700 | [diff] [blame] | 24 | |
kthelgason | 876222f | 2016-11-29 01:44:11 -0800 | [diff] [blame] | 25 | using ::testing::InvokeWithoutArgs; |
Niels Möller | e541be7 | 2017-12-13 13:03:10 +0100 | [diff] [blame] | 26 | using ::testing::_; |
perkj | d52063f | 2016-09-07 06:32:18 -0700 | [diff] [blame] | 27 | |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 28 | namespace { |
| 29 | const int kWidth = 640; |
| 30 | const int kHeight = 480; |
Niels Möller | 83dbeac | 2017-12-14 16:39:44 +0100 | [diff] [blame^] | 31 | // Corresponds to load of 15% |
nisse | e0e3bdf | 2017-01-18 02:16:20 -0800 | [diff] [blame] | 32 | const int kFrameIntervalUs = 33 * rtc::kNumMicrosecsPerMillisec; |
| 33 | const int kProcessTimeUs = 5 * rtc::kNumMicrosecsPerMillisec; |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 34 | } // namespace |
mflodman@webrtc.org | e6168f5 | 2013-06-26 11:23:01 +0000 | [diff] [blame] | 35 | |
sprang | b1ca073 | 2017-02-01 08:38:12 -0800 | [diff] [blame] | 36 | class MockCpuOveruseObserver : public AdaptationObserverInterface { |
mflodman@webrtc.org | e6168f5 | 2013-06-26 11:23:01 +0000 | [diff] [blame] | 37 | public: |
mflodman@webrtc.org | 6879c8a | 2013-07-23 11:35:00 +0000 | [diff] [blame] | 38 | MockCpuOveruseObserver() {} |
| 39 | virtual ~MockCpuOveruseObserver() {} |
mflodman@webrtc.org | e6168f5 | 2013-06-26 11:23:01 +0000 | [diff] [blame] | 40 | |
sprang | b1ca073 | 2017-02-01 08:38:12 -0800 | [diff] [blame] | 41 | MOCK_METHOD1(AdaptUp, void(AdaptReason)); |
| 42 | MOCK_METHOD1(AdaptDown, void(AdaptReason)); |
mflodman@webrtc.org | e6168f5 | 2013-06-26 11:23:01 +0000 | [diff] [blame] | 43 | }; |
| 44 | |
sprang | b1ca073 | 2017-02-01 08:38:12 -0800 | [diff] [blame] | 45 | class CpuOveruseObserverImpl : public AdaptationObserverInterface { |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 46 | public: |
| 47 | CpuOveruseObserverImpl() : |
| 48 | overuse_(0), |
| 49 | normaluse_(0) {} |
| 50 | virtual ~CpuOveruseObserverImpl() {} |
| 51 | |
sprang | b1ca073 | 2017-02-01 08:38:12 -0800 | [diff] [blame] | 52 | void AdaptDown(AdaptReason) { ++overuse_; } |
| 53 | void AdaptUp(AdaptReason) { ++normaluse_; } |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 54 | |
| 55 | int overuse_; |
| 56 | int normaluse_; |
| 57 | }; |
| 58 | |
perkj | d52063f | 2016-09-07 06:32:18 -0700 | [diff] [blame] | 59 | class OveruseFrameDetectorUnderTest : public OveruseFrameDetector { |
| 60 | public: |
nisse | e0e3bdf | 2017-01-18 02:16:20 -0800 | [diff] [blame] | 61 | OveruseFrameDetectorUnderTest(const CpuOveruseOptions& options, |
sprang | b1ca073 | 2017-02-01 08:38:12 -0800 | [diff] [blame] | 62 | AdaptationObserverInterface* overuse_observer, |
perkj | d52063f | 2016-09-07 06:32:18 -0700 | [diff] [blame] | 63 | CpuOveruseMetricsObserver* metrics_observer) |
nisse | e0e3bdf | 2017-01-18 02:16:20 -0800 | [diff] [blame] | 64 | : OveruseFrameDetector(options, |
perkj | d52063f | 2016-09-07 06:32:18 -0700 | [diff] [blame] | 65 | overuse_observer, |
perkj | d52063f | 2016-09-07 06:32:18 -0700 | [diff] [blame] | 66 | metrics_observer) {} |
| 67 | ~OveruseFrameDetectorUnderTest() {} |
| 68 | |
| 69 | using OveruseFrameDetector::CheckForOveruse; |
| 70 | }; |
| 71 | |
pbos@webrtc.org | 3e6e271 | 2015-02-26 12:19:31 +0000 | [diff] [blame] | 72 | class OveruseFrameDetectorTest : public ::testing::Test, |
| 73 | public CpuOveruseMetricsObserver { |
mflodman@webrtc.org | e6168f5 | 2013-06-26 11:23:01 +0000 | [diff] [blame] | 74 | protected: |
nisse | ef8b61e | 2016-04-29 06:09:15 -0700 | [diff] [blame] | 75 | void SetUp() override { |
mflodman@webrtc.org | 6879c8a | 2013-07-23 11:35:00 +0000 | [diff] [blame] | 76 | observer_.reset(new MockCpuOveruseObserver()); |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 77 | options_.min_process_count = 0; |
Peter Boström | 4b91bd0 | 2015-06-26 06:58:16 +0200 | [diff] [blame] | 78 | ReinitializeOveruseDetector(); |
| 79 | } |
| 80 | |
| 81 | void ReinitializeOveruseDetector() { |
perkj | d52063f | 2016-09-07 06:32:18 -0700 | [diff] [blame] | 82 | overuse_detector_.reset(new OveruseFrameDetectorUnderTest( |
Niels Möller | 6b642f7 | 2017-12-08 14:11:14 +0100 | [diff] [blame] | 83 | options_, observer_.get(), this)); |
mflodman@webrtc.org | e6168f5 | 2013-06-26 11:23:01 +0000 | [diff] [blame] | 84 | } |
mflodman@webrtc.org | d4412fe | 2013-07-31 16:42:21 +0000 | [diff] [blame] | 85 | |
Peter Boström | e449915 | 2016-02-05 11:13:28 +0100 | [diff] [blame] | 86 | void OnEncodedFrameTimeMeasured(int encode_time_ms, |
| 87 | const CpuOveruseMetrics& metrics) override { |
pbos@webrtc.org | 3e6e271 | 2015-02-26 12:19:31 +0000 | [diff] [blame] | 88 | metrics_ = metrics; |
| 89 | } |
| 90 | |
asapersson@webrtc.org | 9aed002 | 2014-10-16 06:57:12 +0000 | [diff] [blame] | 91 | int InitialUsage() { |
asapersson@webrtc.org | ce12f1f | 2014-03-24 21:59:16 +0000 | [diff] [blame] | 92 | return ((options_.low_encode_usage_threshold_percent + |
| 93 | options_.high_encode_usage_threshold_percent) / 2.0f) + 0.5; |
| 94 | } |
| 95 | |
Niels Möller | 83dbeac | 2017-12-14 16:39:44 +0100 | [diff] [blame^] | 96 | virtual void InsertAndSendFramesWithInterval(int num_frames, |
| 97 | int interval_us, |
| 98 | int width, |
| 99 | int height, |
| 100 | int delay_us) { |
Niels Möller | 7dc26b7 | 2017-12-06 10:27:48 +0100 | [diff] [blame] | 101 | VideoFrame frame(I420Buffer::Create(width, height), |
| 102 | webrtc::kVideoRotation_0, 0); |
| 103 | uint32_t timestamp = 0; |
asapersson@webrtc.org | ce12f1f | 2014-03-24 21:59:16 +0000 | [diff] [blame] | 104 | while (num_frames-- > 0) { |
Niels Möller | 7dc26b7 | 2017-12-06 10:27:48 +0100 | [diff] [blame] | 105 | frame.set_timestamp(timestamp); |
Niels Möller | 83dbeac | 2017-12-14 16:39:44 +0100 | [diff] [blame^] | 106 | int64_t capture_time_us = rtc::TimeMicros(); |
| 107 | overuse_detector_->FrameCaptured(frame, capture_time_us); |
Niels Möller | 7dc26b7 | 2017-12-06 10:27:48 +0100 | [diff] [blame] | 108 | clock_.AdvanceTimeMicros(delay_us); |
Niels Möller | 83dbeac | 2017-12-14 16:39:44 +0100 | [diff] [blame^] | 109 | overuse_detector_->FrameSent(timestamp, rtc::TimeMicros(), |
| 110 | capture_time_us, delay_us); |
Niels Möller | 7dc26b7 | 2017-12-06 10:27:48 +0100 | [diff] [blame] | 111 | clock_.AdvanceTimeMicros(interval_us - delay_us); |
| 112 | timestamp += interval_us * 90 / 1000; |
asapersson@webrtc.org | ce12f1f | 2014-03-24 21:59:16 +0000 | [diff] [blame] | 113 | } |
| 114 | } |
| 115 | |
Niels Möller | 83dbeac | 2017-12-14 16:39:44 +0100 | [diff] [blame^] | 116 | virtual void InsertAndSendFramesWithRandomInterval(int num_frames, |
| 117 | int min_interval_us, |
| 118 | int max_interval_us, |
| 119 | int width, |
| 120 | int height, |
| 121 | int delay_us) { |
Niels Möller | e541be7 | 2017-12-13 13:03:10 +0100 | [diff] [blame] | 122 | webrtc::Random random(17); |
| 123 | |
| 124 | VideoFrame frame(I420Buffer::Create(width, height), |
| 125 | webrtc::kVideoRotation_0, 0); |
| 126 | uint32_t timestamp = 0; |
| 127 | while (num_frames-- > 0) { |
| 128 | frame.set_timestamp(timestamp); |
| 129 | int interval_us = random.Rand(min_interval_us, max_interval_us); |
Niels Möller | 83dbeac | 2017-12-14 16:39:44 +0100 | [diff] [blame^] | 130 | int64_t capture_time_us = rtc::TimeMicros(); |
| 131 | overuse_detector_->FrameCaptured(frame, capture_time_us); |
Niels Möller | e541be7 | 2017-12-13 13:03:10 +0100 | [diff] [blame] | 132 | clock_.AdvanceTimeMicros(delay_us); |
Niels Möller | 83dbeac | 2017-12-14 16:39:44 +0100 | [diff] [blame^] | 133 | overuse_detector_->FrameSent(timestamp, rtc::TimeMicros(), |
| 134 | capture_time_us, |
| 135 | rtc::Optional<int>(delay_us)); |
Niels Möller | e541be7 | 2017-12-13 13:03:10 +0100 | [diff] [blame] | 136 | |
| 137 | overuse_detector_->CheckForOveruse(); |
| 138 | // Avoid turning clock backwards. |
| 139 | if (interval_us > delay_us) |
| 140 | clock_.AdvanceTimeMicros(interval_us - delay_us); |
| 141 | |
| 142 | timestamp += interval_us * 90 / 1000; |
| 143 | } |
| 144 | } |
| 145 | |
Niels Möller | 83dbeac | 2017-12-14 16:39:44 +0100 | [diff] [blame^] | 146 | virtual void ForceUpdate(int width, int height) { |
Niels Möller | 7dc26b7 | 2017-12-06 10:27:48 +0100 | [diff] [blame] | 147 | // Insert one frame, wait a second and then put in another to force update |
| 148 | // the usage. From the tests where these are used, adding another sample |
| 149 | // doesn't affect the expected outcome (this is mainly to check initial |
| 150 | // values and whether the overuse detector has been reset or not). |
| 151 | InsertAndSendFramesWithInterval(2, rtc::kNumMicrosecsPerSec, |
| 152 | width, height, kFrameIntervalUs); |
Peter Boström | e449915 | 2016-02-05 11:13:28 +0100 | [diff] [blame] | 153 | } |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 154 | void TriggerOveruse(int num_times) { |
nisse | e0e3bdf | 2017-01-18 02:16:20 -0800 | [diff] [blame] | 155 | const int kDelayUs = 32 * rtc::kNumMicrosecsPerMillisec; |
asapersson@webrtc.org | ce12f1f | 2014-03-24 21:59:16 +0000 | [diff] [blame] | 156 | for (int i = 0; i < num_times; ++i) { |
asapersson@webrtc.org | 9aed002 | 2014-10-16 06:57:12 +0000 | [diff] [blame] | 157 | InsertAndSendFramesWithInterval( |
nisse | e0e3bdf | 2017-01-18 02:16:20 -0800 | [diff] [blame] | 158 | 1000, kFrameIntervalUs, kWidth, kHeight, kDelayUs); |
perkj | d52063f | 2016-09-07 06:32:18 -0700 | [diff] [blame] | 159 | overuse_detector_->CheckForOveruse(); |
asapersson@webrtc.org | ce12f1f | 2014-03-24 21:59:16 +0000 | [diff] [blame] | 160 | } |
| 161 | } |
| 162 | |
Åsa Persson | 746210f | 2015-09-08 10:52:42 +0200 | [diff] [blame] | 163 | void TriggerUnderuse() { |
nisse | e0e3bdf | 2017-01-18 02:16:20 -0800 | [diff] [blame] | 164 | const int kDelayUs1 = 5000; |
| 165 | const int kDelayUs2 = 6000; |
asapersson@webrtc.org | 9aed002 | 2014-10-16 06:57:12 +0000 | [diff] [blame] | 166 | InsertAndSendFramesWithInterval( |
nisse | e0e3bdf | 2017-01-18 02:16:20 -0800 | [diff] [blame] | 167 | 1300, kFrameIntervalUs, kWidth, kHeight, kDelayUs1); |
asapersson@webrtc.org | 9aed002 | 2014-10-16 06:57:12 +0000 | [diff] [blame] | 168 | InsertAndSendFramesWithInterval( |
nisse | e0e3bdf | 2017-01-18 02:16:20 -0800 | [diff] [blame] | 169 | 1, kFrameIntervalUs, kWidth, kHeight, kDelayUs2); |
perkj | d52063f | 2016-09-07 06:32:18 -0700 | [diff] [blame] | 170 | overuse_detector_->CheckForOveruse(); |
asapersson@webrtc.org | ce12f1f | 2014-03-24 21:59:16 +0000 | [diff] [blame] | 171 | } |
| 172 | |
pbos@webrtc.org | 3e6e271 | 2015-02-26 12:19:31 +0000 | [diff] [blame] | 173 | int UsagePercent() { return metrics_.encode_usage_percent; } |
asapersson@webrtc.org | ab6bf4f | 2014-05-27 07:43:15 +0000 | [diff] [blame] | 174 | |
sprang | fda496a | 2017-06-15 04:21:07 -0700 | [diff] [blame] | 175 | int64_t OveruseProcessingTimeLimitForFramerate(int fps) const { |
| 176 | int64_t frame_interval = rtc::kNumMicrosecsPerSec / fps; |
| 177 | int64_t max_processing_time_us = |
| 178 | (frame_interval * options_.high_encode_usage_threshold_percent) / 100; |
| 179 | return max_processing_time_us; |
| 180 | } |
| 181 | |
| 182 | int64_t UnderuseProcessingTimeLimitForFramerate(int fps) const { |
| 183 | int64_t frame_interval = rtc::kNumMicrosecsPerSec / fps; |
| 184 | int64_t max_processing_time_us = |
| 185 | (frame_interval * options_.low_encode_usage_threshold_percent) / 100; |
| 186 | return max_processing_time_us; |
| 187 | } |
| 188 | |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 189 | CpuOveruseOptions options_; |
nisse | e0e3bdf | 2017-01-18 02:16:20 -0800 | [diff] [blame] | 190 | rtc::ScopedFakeClock clock_; |
kwiberg | 27f982b | 2016-03-01 11:52:33 -0800 | [diff] [blame] | 191 | std::unique_ptr<MockCpuOveruseObserver> observer_; |
perkj | d52063f | 2016-09-07 06:32:18 -0700 | [diff] [blame] | 192 | std::unique_ptr<OveruseFrameDetectorUnderTest> overuse_detector_; |
pbos@webrtc.org | 3e6e271 | 2015-02-26 12:19:31 +0000 | [diff] [blame] | 193 | CpuOveruseMetrics metrics_; |
kthelgason | 876222f | 2016-11-29 01:44:11 -0800 | [diff] [blame] | 194 | |
sprang | b1ca073 | 2017-02-01 08:38:12 -0800 | [diff] [blame] | 195 | static const auto reason_ = AdaptationObserverInterface::AdaptReason::kCpu; |
mflodman@webrtc.org | e6168f5 | 2013-06-26 11:23:01 +0000 | [diff] [blame] | 196 | }; |
| 197 | |
Åsa Persson | 746210f | 2015-09-08 10:52:42 +0200 | [diff] [blame] | 198 | |
Åsa Persson | 746210f | 2015-09-08 10:52:42 +0200 | [diff] [blame] | 199 | // UsagePercent() > high_encode_usage_threshold_percent => overuse. |
| 200 | // UsagePercent() < low_encode_usage_threshold_percent => underuse. |
mflodman@webrtc.org | e6168f5 | 2013-06-26 11:23:01 +0000 | [diff] [blame] | 201 | TEST_F(OveruseFrameDetectorTest, TriggerOveruse) { |
Åsa Persson | 746210f | 2015-09-08 10:52:42 +0200 | [diff] [blame] | 202 | // usage > high => overuse |
sprang | b1ca073 | 2017-02-01 08:38:12 -0800 | [diff] [blame] | 203 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)).Times(1); |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 204 | TriggerOveruse(options_.high_threshold_consecutive_count); |
mflodman@webrtc.org | d4412fe | 2013-07-31 16:42:21 +0000 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | TEST_F(OveruseFrameDetectorTest, OveruseAndRecover) { |
Åsa Persson | 746210f | 2015-09-08 10:52:42 +0200 | [diff] [blame] | 208 | // usage > high => overuse |
sprang | b1ca073 | 2017-02-01 08:38:12 -0800 | [diff] [blame] | 209 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)).Times(1); |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 210 | TriggerOveruse(options_.high_threshold_consecutive_count); |
Åsa Persson | 746210f | 2015-09-08 10:52:42 +0200 | [diff] [blame] | 211 | // usage < low => underuse |
sprang | b1ca073 | 2017-02-01 08:38:12 -0800 | [diff] [blame] | 212 | EXPECT_CALL(*(observer_.get()), AdaptUp(reason_)).Times(testing::AtLeast(1)); |
asapersson@webrtc.org | 9aed002 | 2014-10-16 06:57:12 +0000 | [diff] [blame] | 213 | TriggerUnderuse(); |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 214 | } |
| 215 | |
asapersson@webrtc.org | 2881ab1 | 2014-06-12 08:46:46 +0000 | [diff] [blame] | 216 | TEST_F(OveruseFrameDetectorTest, OveruseAndRecoverWithNoObserver) { |
perkj | d52063f | 2016-09-07 06:32:18 -0700 | [diff] [blame] | 217 | overuse_detector_.reset(new OveruseFrameDetectorUnderTest( |
Niels Möller | 6b642f7 | 2017-12-08 14:11:14 +0100 | [diff] [blame] | 218 | options_, nullptr, this)); |
sprang | b1ca073 | 2017-02-01 08:38:12 -0800 | [diff] [blame] | 219 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)).Times(0); |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 220 | TriggerOveruse(options_.high_threshold_consecutive_count); |
sprang | b1ca073 | 2017-02-01 08:38:12 -0800 | [diff] [blame] | 221 | EXPECT_CALL(*(observer_.get()), AdaptUp(reason_)).Times(0); |
asapersson@webrtc.org | 9aed002 | 2014-10-16 06:57:12 +0000 | [diff] [blame] | 222 | TriggerUnderuse(); |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 223 | } |
| 224 | |
mflodman@webrtc.org | d4412fe | 2013-07-31 16:42:21 +0000 | [diff] [blame] | 225 | TEST_F(OveruseFrameDetectorTest, DoubleOveruseAndRecover) { |
sprang | b1ca073 | 2017-02-01 08:38:12 -0800 | [diff] [blame] | 226 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)).Times(2); |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 227 | TriggerOveruse(options_.high_threshold_consecutive_count); |
| 228 | TriggerOveruse(options_.high_threshold_consecutive_count); |
sprang | b1ca073 | 2017-02-01 08:38:12 -0800 | [diff] [blame] | 229 | EXPECT_CALL(*(observer_.get()), AdaptUp(reason_)).Times(testing::AtLeast(1)); |
asapersson@webrtc.org | 9aed002 | 2014-10-16 06:57:12 +0000 | [diff] [blame] | 230 | TriggerUnderuse(); |
pbos@webrtc.org | a957570 | 2013-08-30 17:16:32 +0000 | [diff] [blame] | 231 | } |
mflodman@webrtc.org | d4412fe | 2013-07-31 16:42:21 +0000 | [diff] [blame] | 232 | |
asapersson@webrtc.org | 9aed002 | 2014-10-16 06:57:12 +0000 | [diff] [blame] | 233 | TEST_F(OveruseFrameDetectorTest, TriggerUnderuseWithMinProcessCount) { |
nisse | e0e3bdf | 2017-01-18 02:16:20 -0800 | [diff] [blame] | 234 | const int kProcessIntervalUs = 5 * rtc::kNumMicrosecsPerSec; |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 235 | options_.min_process_count = 1; |
Peter Boström | 4b91bd0 | 2015-06-26 06:58:16 +0200 | [diff] [blame] | 236 | CpuOveruseObserverImpl overuse_observer; |
perkj | d52063f | 2016-09-07 06:32:18 -0700 | [diff] [blame] | 237 | overuse_detector_.reset(new OveruseFrameDetectorUnderTest( |
Niels Möller | 6b642f7 | 2017-12-08 14:11:14 +0100 | [diff] [blame] | 238 | options_, &overuse_observer, this)); |
Åsa Persson | 746210f | 2015-09-08 10:52:42 +0200 | [diff] [blame] | 239 | InsertAndSendFramesWithInterval( |
nisse | e0e3bdf | 2017-01-18 02:16:20 -0800 | [diff] [blame] | 240 | 1200, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); |
perkj | d52063f | 2016-09-07 06:32:18 -0700 | [diff] [blame] | 241 | overuse_detector_->CheckForOveruse(); |
Peter Boström | 4b91bd0 | 2015-06-26 06:58:16 +0200 | [diff] [blame] | 242 | EXPECT_EQ(0, overuse_observer.normaluse_); |
nisse | e0e3bdf | 2017-01-18 02:16:20 -0800 | [diff] [blame] | 243 | clock_.AdvanceTimeMicros(kProcessIntervalUs); |
perkj | d52063f | 2016-09-07 06:32:18 -0700 | [diff] [blame] | 244 | overuse_detector_->CheckForOveruse(); |
Peter Boström | 4b91bd0 | 2015-06-26 06:58:16 +0200 | [diff] [blame] | 245 | EXPECT_EQ(1, overuse_observer.normaluse_); |
asapersson@webrtc.org | b60346e | 2014-02-17 19:02:15 +0000 | [diff] [blame] | 246 | } |
| 247 | |
pbos@webrtc.org | a957570 | 2013-08-30 17:16:32 +0000 | [diff] [blame] | 248 | TEST_F(OveruseFrameDetectorTest, ConstantOveruseGivesNoNormalUsage) { |
sprang | b1ca073 | 2017-02-01 08:38:12 -0800 | [diff] [blame] | 249 | EXPECT_CALL(*(observer_.get()), AdaptUp(reason_)).Times(0); |
| 250 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)).Times(64); |
kjellander@webrtc.org | 0fcaf99 | 2015-11-26 15:24:52 +0100 | [diff] [blame] | 251 | for (size_t i = 0; i < 64; ++i) { |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 252 | TriggerOveruse(options_.high_threshold_consecutive_count); |
| 253 | } |
mflodman@webrtc.org | d4412fe | 2013-07-31 16:42:21 +0000 | [diff] [blame] | 254 | } |
| 255 | |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 256 | TEST_F(OveruseFrameDetectorTest, ConsecutiveCountTriggersOveruse) { |
sprang | b1ca073 | 2017-02-01 08:38:12 -0800 | [diff] [blame] | 257 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)).Times(1); |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 258 | options_.high_threshold_consecutive_count = 2; |
Peter Boström | 4b91bd0 | 2015-06-26 06:58:16 +0200 | [diff] [blame] | 259 | ReinitializeOveruseDetector(); |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 260 | TriggerOveruse(2); |
| 261 | } |
| 262 | |
| 263 | TEST_F(OveruseFrameDetectorTest, IncorrectConsecutiveCountTriggersNoOveruse) { |
sprang | b1ca073 | 2017-02-01 08:38:12 -0800 | [diff] [blame] | 264 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)).Times(0); |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 265 | options_.high_threshold_consecutive_count = 2; |
Peter Boström | 4b91bd0 | 2015-06-26 06:58:16 +0200 | [diff] [blame] | 266 | ReinitializeOveruseDetector(); |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 267 | TriggerOveruse(1); |
| 268 | } |
| 269 | |
Åsa Persson | 746210f | 2015-09-08 10:52:42 +0200 | [diff] [blame] | 270 | TEST_F(OveruseFrameDetectorTest, ProcessingUsage) { |
| 271 | InsertAndSendFramesWithInterval( |
nisse | e0e3bdf | 2017-01-18 02:16:20 -0800 | [diff] [blame] | 272 | 1000, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); |
| 273 | EXPECT_EQ(kProcessTimeUs * 100 / kFrameIntervalUs, UsagePercent()); |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 274 | } |
| 275 | |
Åsa Persson | 746210f | 2015-09-08 10:52:42 +0200 | [diff] [blame] | 276 | TEST_F(OveruseFrameDetectorTest, ResetAfterResolutionChange) { |
Peter Boström | e449915 | 2016-02-05 11:13:28 +0100 | [diff] [blame] | 277 | ForceUpdate(kWidth, kHeight); |
Åsa Persson | 746210f | 2015-09-08 10:52:42 +0200 | [diff] [blame] | 278 | EXPECT_EQ(InitialUsage(), UsagePercent()); |
| 279 | InsertAndSendFramesWithInterval( |
nisse | e0e3bdf | 2017-01-18 02:16:20 -0800 | [diff] [blame] | 280 | 1000, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); |
Åsa Persson | 746210f | 2015-09-08 10:52:42 +0200 | [diff] [blame] | 281 | EXPECT_NE(InitialUsage(), UsagePercent()); |
Peter Boström | e449915 | 2016-02-05 11:13:28 +0100 | [diff] [blame] | 282 | // Verify reset (with new width/height). |
| 283 | ForceUpdate(kWidth, kHeight + 1); |
Åsa Persson | 746210f | 2015-09-08 10:52:42 +0200 | [diff] [blame] | 284 | EXPECT_EQ(InitialUsage(), UsagePercent()); |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 285 | } |
| 286 | |
Åsa Persson | 746210f | 2015-09-08 10:52:42 +0200 | [diff] [blame] | 287 | TEST_F(OveruseFrameDetectorTest, ResetAfterFrameTimeout) { |
Peter Boström | e449915 | 2016-02-05 11:13:28 +0100 | [diff] [blame] | 288 | ForceUpdate(kWidth, kHeight); |
Åsa Persson | 746210f | 2015-09-08 10:52:42 +0200 | [diff] [blame] | 289 | EXPECT_EQ(InitialUsage(), UsagePercent()); |
| 290 | InsertAndSendFramesWithInterval( |
nisse | e0e3bdf | 2017-01-18 02:16:20 -0800 | [diff] [blame] | 291 | 1000, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); |
Åsa Persson | 746210f | 2015-09-08 10:52:42 +0200 | [diff] [blame] | 292 | EXPECT_NE(InitialUsage(), UsagePercent()); |
| 293 | InsertAndSendFramesWithInterval( |
nisse | e0e3bdf | 2017-01-18 02:16:20 -0800 | [diff] [blame] | 294 | 2, options_.frame_timeout_interval_ms * |
| 295 | rtc::kNumMicrosecsPerMillisec, kWidth, kHeight, kProcessTimeUs); |
Åsa Persson | 746210f | 2015-09-08 10:52:42 +0200 | [diff] [blame] | 296 | EXPECT_NE(InitialUsage(), UsagePercent()); |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 297 | // Verify reset. |
Åsa Persson | 746210f | 2015-09-08 10:52:42 +0200 | [diff] [blame] | 298 | InsertAndSendFramesWithInterval( |
nisse | e0e3bdf | 2017-01-18 02:16:20 -0800 | [diff] [blame] | 299 | 2, (options_.frame_timeout_interval_ms + 1) * |
| 300 | rtc::kNumMicrosecsPerMillisec, kWidth, kHeight, kProcessTimeUs); |
Peter Boström | e449915 | 2016-02-05 11:13:28 +0100 | [diff] [blame] | 301 | ForceUpdate(kWidth, kHeight); |
Åsa Persson | 746210f | 2015-09-08 10:52:42 +0200 | [diff] [blame] | 302 | EXPECT_EQ(InitialUsage(), UsagePercent()); |
asapersson@webrtc.org | 8a8c3ef | 2014-03-20 13:15:01 +0000 | [diff] [blame] | 303 | } |
| 304 | |
Niels Möller | 7dc26b7 | 2017-12-06 10:27:48 +0100 | [diff] [blame] | 305 | TEST_F(OveruseFrameDetectorTest, MinFrameSamplesBeforeUpdating) { |
| 306 | options_.min_frame_samples = 40; |
| 307 | ReinitializeOveruseDetector(); |
| 308 | InsertAndSendFramesWithInterval( |
| 309 | 40, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); |
| 310 | EXPECT_EQ(InitialUsage(), UsagePercent()); |
| 311 | // Pass time far enough to digest all previous samples. |
| 312 | clock_.AdvanceTimeMicros(rtc::kNumMicrosecsPerSec); |
| 313 | InsertAndSendFramesWithInterval(1, kFrameIntervalUs, kWidth, kHeight, |
| 314 | kProcessTimeUs); |
| 315 | // The last sample has not been processed here. |
| 316 | EXPECT_EQ(InitialUsage(), UsagePercent()); |
| 317 | |
| 318 | // Pass time far enough to digest all previous samples, 41 in total. |
| 319 | clock_.AdvanceTimeMicros(rtc::kNumMicrosecsPerSec); |
| 320 | InsertAndSendFramesWithInterval( |
| 321 | 1, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); |
| 322 | EXPECT_NE(InitialUsage(), UsagePercent()); |
| 323 | } |
| 324 | |
Åsa Persson | 746210f | 2015-09-08 10:52:42 +0200 | [diff] [blame] | 325 | TEST_F(OveruseFrameDetectorTest, InitialProcessingUsage) { |
Peter Boström | e449915 | 2016-02-05 11:13:28 +0100 | [diff] [blame] | 326 | ForceUpdate(kWidth, kHeight); |
Åsa Persson | 746210f | 2015-09-08 10:52:42 +0200 | [diff] [blame] | 327 | EXPECT_EQ(InitialUsage(), UsagePercent()); |
asapersson@webrtc.org | b24d335 | 2013-11-20 13:51:40 +0000 | [diff] [blame] | 328 | } |
| 329 | |
Niels Möller | 7dc26b7 | 2017-12-06 10:27:48 +0100 | [diff] [blame] | 330 | TEST_F(OveruseFrameDetectorTest, MeasuresMultipleConcurrentSamples) { |
| 331 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)) |
| 332 | .Times(testing::AtLeast(1)); |
| 333 | static const int kIntervalUs = 33 * rtc::kNumMicrosecsPerMillisec; |
| 334 | static const size_t kNumFramesEncodingDelay = 3; |
| 335 | VideoFrame frame(I420Buffer::Create(kWidth, kHeight), |
| 336 | webrtc::kVideoRotation_0, 0); |
| 337 | for (size_t i = 0; i < 1000; ++i) { |
| 338 | // Unique timestamps. |
| 339 | frame.set_timestamp(static_cast<uint32_t>(i)); |
Niels Möller | 83dbeac | 2017-12-14 16:39:44 +0100 | [diff] [blame^] | 340 | int64_t capture_time_us = rtc::TimeMicros(); |
| 341 | overuse_detector_->FrameCaptured(frame, capture_time_us); |
Niels Möller | 7dc26b7 | 2017-12-06 10:27:48 +0100 | [diff] [blame] | 342 | clock_.AdvanceTimeMicros(kIntervalUs); |
| 343 | if (i > kNumFramesEncodingDelay) { |
| 344 | overuse_detector_->FrameSent( |
Niels Möller | 83dbeac | 2017-12-14 16:39:44 +0100 | [diff] [blame^] | 345 | static_cast<uint32_t>(i - kNumFramesEncodingDelay), rtc::TimeMicros(), |
| 346 | capture_time_us, kIntervalUs); |
Niels Möller | 7dc26b7 | 2017-12-06 10:27:48 +0100 | [diff] [blame] | 347 | } |
| 348 | overuse_detector_->CheckForOveruse(); |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | TEST_F(OveruseFrameDetectorTest, UpdatesExistingSamples) { |
| 353 | // >85% encoding time should trigger overuse. |
| 354 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)) |
| 355 | .Times(testing::AtLeast(1)); |
| 356 | static const int kIntervalUs = 33 * rtc::kNumMicrosecsPerMillisec; |
| 357 | static const int kDelayUs = 30 * rtc::kNumMicrosecsPerMillisec; |
| 358 | VideoFrame frame(I420Buffer::Create(kWidth, kHeight), |
| 359 | webrtc::kVideoRotation_0, 0); |
| 360 | uint32_t timestamp = 0; |
| 361 | for (size_t i = 0; i < 1000; ++i) { |
| 362 | frame.set_timestamp(timestamp); |
Niels Möller | 83dbeac | 2017-12-14 16:39:44 +0100 | [diff] [blame^] | 363 | int64_t capture_time_us = rtc::TimeMicros(); |
| 364 | overuse_detector_->FrameCaptured(frame, capture_time_us); |
Niels Möller | 7dc26b7 | 2017-12-06 10:27:48 +0100 | [diff] [blame] | 365 | // Encode and send first parts almost instantly. |
| 366 | clock_.AdvanceTimeMicros(rtc::kNumMicrosecsPerMillisec); |
Niels Möller | 83dbeac | 2017-12-14 16:39:44 +0100 | [diff] [blame^] | 367 | overuse_detector_->FrameSent(timestamp, rtc::TimeMicros(), capture_time_us, |
| 368 | rtc::kNumMicrosecsPerMillisec); |
Niels Möller | 7dc26b7 | 2017-12-06 10:27:48 +0100 | [diff] [blame] | 369 | // Encode heavier part, resulting in >85% usage total. |
| 370 | clock_.AdvanceTimeMicros(kDelayUs - rtc::kNumMicrosecsPerMillisec); |
Niels Möller | 83dbeac | 2017-12-14 16:39:44 +0100 | [diff] [blame^] | 371 | overuse_detector_->FrameSent(timestamp, rtc::TimeMicros(), capture_time_us, |
| 372 | kDelayUs); |
Niels Möller | 7dc26b7 | 2017-12-06 10:27:48 +0100 | [diff] [blame] | 373 | clock_.AdvanceTimeMicros(kIntervalUs - kDelayUs); |
| 374 | timestamp += kIntervalUs * 90 / 1000; |
| 375 | overuse_detector_->CheckForOveruse(); |
| 376 | } |
| 377 | } |
| 378 | |
perkj | d52063f | 2016-09-07 06:32:18 -0700 | [diff] [blame] | 379 | TEST_F(OveruseFrameDetectorTest, RunOnTqNormalUsage) { |
| 380 | rtc::TaskQueue queue("OveruseFrameDetectorTestQueue"); |
| 381 | |
| 382 | rtc::Event event(false, false); |
| 383 | queue.PostTask([this, &event] { |
| 384 | overuse_detector_->StartCheckForOveruse(); |
| 385 | event.Set(); |
| 386 | }); |
| 387 | event.Wait(rtc::Event::kForever); |
| 388 | |
| 389 | // Expect NormalUsage(). When called, stop the |overuse_detector_| and then |
| 390 | // set |event| to end the test. |
sprang | b1ca073 | 2017-02-01 08:38:12 -0800 | [diff] [blame] | 391 | EXPECT_CALL(*(observer_.get()), AdaptUp(reason_)) |
kthelgason | 876222f | 2016-11-29 01:44:11 -0800 | [diff] [blame] | 392 | .WillOnce(InvokeWithoutArgs([this, &event] { |
perkj | d52063f | 2016-09-07 06:32:18 -0700 | [diff] [blame] | 393 | overuse_detector_->StopCheckForOveruse(); |
| 394 | event.Set(); |
| 395 | })); |
| 396 | |
eladalon | 1cc5fc3 | 2017-08-23 04:15:18 -0700 | [diff] [blame] | 397 | queue.PostTask([this] { |
nisse | e0e3bdf | 2017-01-18 02:16:20 -0800 | [diff] [blame] | 398 | const int kDelayUs1 = 5 * rtc::kNumMicrosecsPerMillisec; |
| 399 | const int kDelayUs2 = 6 * rtc::kNumMicrosecsPerMillisec; |
| 400 | InsertAndSendFramesWithInterval(1300, kFrameIntervalUs, kWidth, kHeight, |
| 401 | kDelayUs1); |
| 402 | InsertAndSendFramesWithInterval(1, kFrameIntervalUs, kWidth, kHeight, |
| 403 | kDelayUs2); |
perkj | d52063f | 2016-09-07 06:32:18 -0700 | [diff] [blame] | 404 | }); |
| 405 | |
| 406 | EXPECT_TRUE(event.Wait(10000)); |
| 407 | } |
| 408 | |
Niels Möller | 7dc26b7 | 2017-12-06 10:27:48 +0100 | [diff] [blame] | 409 | TEST_F(OveruseFrameDetectorTest, MaxIntervalScalesWithFramerate) { |
| 410 | const int kCapturerMaxFrameRate = 30; |
| 411 | const int kEncodeMaxFrameRate = 20; // Maximum fps the encoder can sustain. |
sprang | fda496a | 2017-06-15 04:21:07 -0700 | [diff] [blame] | 412 | |
Niels Möller | 7dc26b7 | 2017-12-06 10:27:48 +0100 | [diff] [blame] | 413 | // Trigger overuse. |
| 414 | int64_t frame_interval_us = rtc::kNumMicrosecsPerSec / kCapturerMaxFrameRate; |
| 415 | // Processing time just below over use limit given kEncodeMaxFrameRate. |
| 416 | int64_t processing_time_us = |
| 417 | (98 * OveruseProcessingTimeLimitForFramerate(kEncodeMaxFrameRate)) / 100; |
| 418 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)).Times(1); |
| 419 | for (int i = 0; i < options_.high_threshold_consecutive_count; ++i) { |
| 420 | InsertAndSendFramesWithInterval(1200, frame_interval_us, kWidth, kHeight, |
| 421 | processing_time_us); |
sprang | fda496a | 2017-06-15 04:21:07 -0700 | [diff] [blame] | 422 | overuse_detector_->CheckForOveruse(); |
| 423 | } |
Niels Möller | 7dc26b7 | 2017-12-06 10:27:48 +0100 | [diff] [blame] | 424 | |
| 425 | // Simulate frame rate reduction and normal usage. |
| 426 | frame_interval_us = rtc::kNumMicrosecsPerSec / kEncodeMaxFrameRate; |
| 427 | overuse_detector_->OnTargetFramerateUpdated(kEncodeMaxFrameRate); |
| 428 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)).Times(0); |
| 429 | for (int i = 0; i < options_.high_threshold_consecutive_count; ++i) { |
| 430 | InsertAndSendFramesWithInterval(1200, frame_interval_us, kWidth, kHeight, |
| 431 | processing_time_us); |
| 432 | overuse_detector_->CheckForOveruse(); |
| 433 | } |
| 434 | |
| 435 | // Reduce processing time to trigger underuse. |
| 436 | processing_time_us = |
| 437 | (98 * UnderuseProcessingTimeLimitForFramerate(kEncodeMaxFrameRate)) / 100; |
| 438 | EXPECT_CALL(*(observer_.get()), AdaptUp(reason_)).Times(1); |
| 439 | InsertAndSendFramesWithInterval(1200, frame_interval_us, kWidth, kHeight, |
| 440 | processing_time_us); |
| 441 | overuse_detector_->CheckForOveruse(); |
sprang | fda496a | 2017-06-15 04:21:07 -0700 | [diff] [blame] | 442 | } |
| 443 | |
Niels Möller | 7dc26b7 | 2017-12-06 10:27:48 +0100 | [diff] [blame] | 444 | TEST_F(OveruseFrameDetectorTest, RespectsMinFramerate) { |
| 445 | const int kMinFrameRate = 7; // Minimum fps allowed by current detector impl. |
| 446 | overuse_detector_->OnTargetFramerateUpdated(kMinFrameRate); |
sprang | fda496a | 2017-06-15 04:21:07 -0700 | [diff] [blame] | 447 | |
Niels Möller | 7dc26b7 | 2017-12-06 10:27:48 +0100 | [diff] [blame] | 448 | // Normal usage just at the limit. |
| 449 | int64_t frame_interval_us = rtc::kNumMicrosecsPerSec / kMinFrameRate; |
| 450 | // Processing time just below over use limit given kEncodeMaxFrameRate. |
| 451 | int64_t processing_time_us = |
| 452 | (98 * OveruseProcessingTimeLimitForFramerate(kMinFrameRate)) / 100; |
| 453 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)).Times(0); |
| 454 | for (int i = 0; i < options_.high_threshold_consecutive_count; ++i) { |
| 455 | InsertAndSendFramesWithInterval(1200, frame_interval_us, kWidth, kHeight, |
| 456 | processing_time_us); |
sprang | fda496a | 2017-06-15 04:21:07 -0700 | [diff] [blame] | 457 | overuse_detector_->CheckForOveruse(); |
| 458 | } |
Niels Möller | 7dc26b7 | 2017-12-06 10:27:48 +0100 | [diff] [blame] | 459 | |
| 460 | // Over the limit to overuse. |
| 461 | processing_time_us = |
| 462 | (102 * OveruseProcessingTimeLimitForFramerate(kMinFrameRate)) / 100; |
| 463 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)).Times(1); |
| 464 | for (int i = 0; i < options_.high_threshold_consecutive_count; ++i) { |
| 465 | InsertAndSendFramesWithInterval(1200, frame_interval_us, kWidth, kHeight, |
| 466 | processing_time_us); |
| 467 | overuse_detector_->CheckForOveruse(); |
| 468 | } |
| 469 | |
| 470 | // Reduce input frame rate. Should still trigger overuse. |
| 471 | overuse_detector_->OnTargetFramerateUpdated(kMinFrameRate - 1); |
| 472 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)).Times(1); |
| 473 | for (int i = 0; i < options_.high_threshold_consecutive_count; ++i) { |
| 474 | InsertAndSendFramesWithInterval(1200, frame_interval_us, kWidth, kHeight, |
| 475 | processing_time_us); |
| 476 | overuse_detector_->CheckForOveruse(); |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | TEST_F(OveruseFrameDetectorTest, LimitsMaxFrameInterval) { |
| 481 | const int kMaxFrameRate = 20; |
| 482 | overuse_detector_->OnTargetFramerateUpdated(kMaxFrameRate); |
| 483 | int64_t frame_interval_us = rtc::kNumMicrosecsPerSec / kMaxFrameRate; |
| 484 | // Maximum frame interval allowed is 35% above ideal. |
| 485 | int64_t max_frame_interval_us = (135 * frame_interval_us) / 100; |
| 486 | // Maximum processing time, without triggering overuse, allowed with the above |
| 487 | // frame interval. |
| 488 | int64_t max_processing_time_us = |
| 489 | (max_frame_interval_us * options_.high_encode_usage_threshold_percent) / |
| 490 | 100; |
| 491 | |
| 492 | // Processing time just below overuse limit given kMaxFrameRate. |
| 493 | int64_t processing_time_us = (98 * max_processing_time_us) / 100; |
| 494 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)).Times(0); |
| 495 | for (int i = 0; i < options_.high_threshold_consecutive_count; ++i) { |
| 496 | InsertAndSendFramesWithInterval(1200, max_frame_interval_us, kWidth, |
| 497 | kHeight, processing_time_us); |
| 498 | overuse_detector_->CheckForOveruse(); |
| 499 | } |
| 500 | |
| 501 | // Go above limit, trigger overuse. |
| 502 | processing_time_us = (102 * max_processing_time_us) / 100; |
| 503 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)).Times(1); |
| 504 | for (int i = 0; i < options_.high_threshold_consecutive_count; ++i) { |
| 505 | InsertAndSendFramesWithInterval(1200, max_frame_interval_us, kWidth, |
| 506 | kHeight, processing_time_us); |
| 507 | overuse_detector_->CheckForOveruse(); |
| 508 | } |
| 509 | |
| 510 | // Increase frame interval, should still trigger overuse. |
| 511 | max_frame_interval_us *= 2; |
| 512 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)).Times(1); |
| 513 | for (int i = 0; i < options_.high_threshold_consecutive_count; ++i) { |
| 514 | InsertAndSendFramesWithInterval(1200, max_frame_interval_us, kWidth, |
| 515 | kHeight, processing_time_us); |
| 516 | overuse_detector_->CheckForOveruse(); |
| 517 | } |
sprang | fda496a | 2017-06-15 04:21:07 -0700 | [diff] [blame] | 518 | } |
| 519 | |
Niels Möller | e541be7 | 2017-12-13 13:03:10 +0100 | [diff] [blame] | 520 | // Models screencast, with irregular arrival of frames which are heavy |
| 521 | // to encode. |
| 522 | TEST_F(OveruseFrameDetectorTest, NoOveruseForLargeRandomFrameInterval) { |
| 523 | // TODO(bugs.webrtc.org/8504): When new estimator is relanded, |
| 524 | // behavior is improved in this scenario, with only AdaptUp events, |
| 525 | // and estimated load closer to the true average. |
| 526 | |
| 527 | // EXPECT_CALL(*(observer_.get()), AdaptDown(_)).Times(0); |
| 528 | // EXPECT_CALL(*(observer_.get()), AdaptUp(reason_)) |
| 529 | // .Times(testing::AtLeast(1)); |
| 530 | |
| 531 | const int kNumFrames = 500; |
| 532 | const int kEncodeTimeUs = 100 * rtc::kNumMicrosecsPerMillisec; |
| 533 | |
| 534 | const int kMinIntervalUs = 30 * rtc::kNumMicrosecsPerMillisec; |
| 535 | const int kMaxIntervalUs = 1000 * rtc::kNumMicrosecsPerMillisec; |
| 536 | |
| 537 | const int kTargetFramerate = 5; |
| 538 | |
| 539 | overuse_detector_->OnTargetFramerateUpdated(kTargetFramerate); |
| 540 | |
| 541 | InsertAndSendFramesWithRandomInterval(kNumFrames, |
| 542 | kMinIntervalUs, kMaxIntervalUs, |
| 543 | kWidth, kHeight, kEncodeTimeUs); |
| 544 | // Average usage 19%. Check that estimate is in the right ball park. |
| 545 | // EXPECT_NEAR(UsagePercent(), 20, 10); |
| 546 | EXPECT_NEAR(UsagePercent(), 20, 35); |
| 547 | } |
| 548 | |
| 549 | // Models screencast, with irregular arrival of frames, often |
| 550 | // exceeding the timeout interval. |
| 551 | TEST_F(OveruseFrameDetectorTest, NoOveruseForRandomFrameIntervalWithReset) { |
| 552 | // TODO(bugs.webrtc.org/8504): When new estimator is relanded, |
| 553 | // behavior is improved in this scenario, and we get AdaptUp events. |
| 554 | EXPECT_CALL(*(observer_.get()), AdaptDown(_)).Times(0); |
| 555 | // EXPECT_CALL(*(observer_.get()), AdaptUp(reason_)) |
| 556 | // .Times(testing::AtLeast(1)); |
| 557 | |
| 558 | const int kNumFrames = 500; |
| 559 | const int kEncodeTimeUs = 100 * rtc::kNumMicrosecsPerMillisec; |
| 560 | |
| 561 | const int kMinIntervalUs = 30 * rtc::kNumMicrosecsPerMillisec; |
| 562 | const int kMaxIntervalUs = 3000 * rtc::kNumMicrosecsPerMillisec; |
| 563 | |
| 564 | const int kTargetFramerate = 5; |
| 565 | |
| 566 | overuse_detector_->OnTargetFramerateUpdated(kTargetFramerate); |
| 567 | |
| 568 | InsertAndSendFramesWithRandomInterval(kNumFrames, |
| 569 | kMinIntervalUs, kMaxIntervalUs, |
| 570 | kWidth, kHeight, kEncodeTimeUs); |
| 571 | |
| 572 | // Average usage 6.6%, but since the frame_timeout_interval_ms is |
| 573 | // only 1500 ms, we often reset the estimate to the initial value. |
| 574 | // Check that estimate is in the right ball park. |
| 575 | EXPECT_GE(UsagePercent(), 1); |
| 576 | EXPECT_LE(UsagePercent(), InitialUsage() + 5); |
| 577 | } |
| 578 | |
Niels Möller | 83dbeac | 2017-12-14 16:39:44 +0100 | [diff] [blame^] | 579 | // Tests using new cpu load estimator |
| 580 | class OveruseFrameDetectorTest2 : public OveruseFrameDetectorTest { |
| 581 | protected: |
| 582 | void SetUp() override { |
| 583 | options_.filter_time_ms = 5 * rtc::kNumMillisecsPerSec; |
| 584 | OveruseFrameDetectorTest::SetUp(); |
| 585 | } |
| 586 | |
| 587 | void InsertAndSendFramesWithInterval(int num_frames, |
| 588 | int interval_us, |
| 589 | int width, |
| 590 | int height, |
| 591 | int delay_us) override { |
| 592 | VideoFrame frame(I420Buffer::Create(width, height), |
| 593 | webrtc::kVideoRotation_0, 0); |
| 594 | while (num_frames-- > 0) { |
| 595 | int64_t capture_time_us = rtc::TimeMicros(); |
| 596 | overuse_detector_->FrameCaptured(frame, capture_time_us /* ignored */); |
| 597 | overuse_detector_->FrameSent(0 /* ignored timestamp */, |
| 598 | 0 /* ignored send_time_us */, |
| 599 | capture_time_us, delay_us); |
| 600 | clock_.AdvanceTimeMicros(interval_us); |
| 601 | } |
| 602 | } |
| 603 | |
| 604 | void InsertAndSendFramesWithRandomInterval(int num_frames, |
| 605 | int min_interval_us, |
| 606 | int max_interval_us, |
| 607 | int width, |
| 608 | int height, |
| 609 | int delay_us) override { |
| 610 | webrtc::Random random(17); |
| 611 | |
| 612 | VideoFrame frame(I420Buffer::Create(width, height), |
| 613 | webrtc::kVideoRotation_0, 0); |
| 614 | for (int i = 0; i < num_frames; i++) { |
| 615 | int interval_us = random.Rand(min_interval_us, max_interval_us); |
| 616 | int64_t capture_time_us = rtc::TimeMicros(); |
| 617 | overuse_detector_->FrameCaptured(frame, capture_time_us); |
| 618 | overuse_detector_->FrameSent(0 /* ignored timestamp */, |
| 619 | 0 /* ignored send_time_us */, |
| 620 | capture_time_us, delay_us); |
| 621 | |
| 622 | overuse_detector_->CheckForOveruse(); |
| 623 | clock_.AdvanceTimeMicros(interval_us); |
| 624 | } |
| 625 | } |
| 626 | |
| 627 | void ForceUpdate(int width, int height) override { |
| 628 | // This is mainly to check initial values and whether the overuse |
| 629 | // detector has been reset or not. |
| 630 | InsertAndSendFramesWithInterval(1, rtc::kNumMicrosecsPerSec, width, height, |
| 631 | kFrameIntervalUs); |
| 632 | } |
| 633 | }; |
| 634 | |
| 635 | // UsagePercent() > high_encode_usage_threshold_percent => overuse. |
| 636 | // UsagePercent() < low_encode_usage_threshold_percent => underuse. |
| 637 | TEST_F(OveruseFrameDetectorTest2, TriggerOveruse) { |
| 638 | // usage > high => overuse |
| 639 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)).Times(1); |
| 640 | TriggerOveruse(options_.high_threshold_consecutive_count); |
| 641 | } |
| 642 | |
| 643 | TEST_F(OveruseFrameDetectorTest2, OveruseAndRecover) { |
| 644 | // usage > high => overuse |
| 645 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)).Times(1); |
| 646 | TriggerOveruse(options_.high_threshold_consecutive_count); |
| 647 | // usage < low => underuse |
| 648 | EXPECT_CALL(*(observer_.get()), AdaptUp(reason_)).Times(testing::AtLeast(1)); |
| 649 | TriggerUnderuse(); |
| 650 | } |
| 651 | |
| 652 | TEST_F(OveruseFrameDetectorTest2, OveruseAndRecoverWithNoObserver) { |
| 653 | overuse_detector_.reset(new OveruseFrameDetectorUnderTest( |
| 654 | options_, nullptr, this)); |
| 655 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)).Times(0); |
| 656 | TriggerOveruse(options_.high_threshold_consecutive_count); |
| 657 | EXPECT_CALL(*(observer_.get()), AdaptUp(reason_)).Times(0); |
| 658 | TriggerUnderuse(); |
| 659 | } |
| 660 | |
| 661 | TEST_F(OveruseFrameDetectorTest2, DoubleOveruseAndRecover) { |
| 662 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)).Times(2); |
| 663 | TriggerOveruse(options_.high_threshold_consecutive_count); |
| 664 | TriggerOveruse(options_.high_threshold_consecutive_count); |
| 665 | EXPECT_CALL(*(observer_.get()), AdaptUp(reason_)).Times(testing::AtLeast(1)); |
| 666 | TriggerUnderuse(); |
| 667 | } |
| 668 | |
| 669 | TEST_F(OveruseFrameDetectorTest2, TriggerUnderuseWithMinProcessCount) { |
| 670 | const int kProcessIntervalUs = 5 * rtc::kNumMicrosecsPerSec; |
| 671 | options_.min_process_count = 1; |
| 672 | CpuOveruseObserverImpl overuse_observer; |
| 673 | overuse_detector_.reset(new OveruseFrameDetectorUnderTest( |
| 674 | options_, &overuse_observer, this)); |
| 675 | InsertAndSendFramesWithInterval( |
| 676 | 1200, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); |
| 677 | overuse_detector_->CheckForOveruse(); |
| 678 | EXPECT_EQ(0, overuse_observer.normaluse_); |
| 679 | clock_.AdvanceTimeMicros(kProcessIntervalUs); |
| 680 | overuse_detector_->CheckForOveruse(); |
| 681 | EXPECT_EQ(1, overuse_observer.normaluse_); |
| 682 | } |
| 683 | |
| 684 | TEST_F(OveruseFrameDetectorTest2, ConstantOveruseGivesNoNormalUsage) { |
| 685 | EXPECT_CALL(*(observer_.get()), AdaptUp(reason_)).Times(0); |
| 686 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)).Times(64); |
| 687 | for (size_t i = 0; i < 64; ++i) { |
| 688 | TriggerOveruse(options_.high_threshold_consecutive_count); |
| 689 | } |
| 690 | } |
| 691 | |
| 692 | TEST_F(OveruseFrameDetectorTest2, ConsecutiveCountTriggersOveruse) { |
| 693 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)).Times(1); |
| 694 | options_.high_threshold_consecutive_count = 2; |
| 695 | ReinitializeOveruseDetector(); |
| 696 | TriggerOveruse(2); |
| 697 | } |
| 698 | |
| 699 | TEST_F(OveruseFrameDetectorTest2, IncorrectConsecutiveCountTriggersNoOveruse) { |
| 700 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)).Times(0); |
| 701 | options_.high_threshold_consecutive_count = 2; |
| 702 | ReinitializeOveruseDetector(); |
| 703 | TriggerOveruse(1); |
| 704 | } |
| 705 | |
| 706 | TEST_F(OveruseFrameDetectorTest2, ProcessingUsage) { |
| 707 | InsertAndSendFramesWithInterval( |
| 708 | 1000, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); |
| 709 | EXPECT_EQ(kProcessTimeUs * 100 / kFrameIntervalUs, UsagePercent()); |
| 710 | } |
| 711 | |
| 712 | TEST_F(OveruseFrameDetectorTest2, ResetAfterResolutionChange) { |
| 713 | ForceUpdate(kWidth, kHeight); |
| 714 | EXPECT_EQ(InitialUsage(), UsagePercent()); |
| 715 | InsertAndSendFramesWithInterval( |
| 716 | 1000, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); |
| 717 | EXPECT_NE(InitialUsage(), UsagePercent()); |
| 718 | // Verify reset (with new width/height). |
| 719 | ForceUpdate(kWidth, kHeight + 1); |
| 720 | EXPECT_EQ(InitialUsage(), UsagePercent()); |
| 721 | } |
| 722 | |
| 723 | TEST_F(OveruseFrameDetectorTest2, ResetAfterFrameTimeout) { |
| 724 | ForceUpdate(kWidth, kHeight); |
| 725 | EXPECT_EQ(InitialUsage(), UsagePercent()); |
| 726 | InsertAndSendFramesWithInterval( |
| 727 | 1000, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); |
| 728 | EXPECT_NE(InitialUsage(), UsagePercent()); |
| 729 | InsertAndSendFramesWithInterval( |
| 730 | 2, options_.frame_timeout_interval_ms * |
| 731 | rtc::kNumMicrosecsPerMillisec, kWidth, kHeight, kProcessTimeUs); |
| 732 | EXPECT_NE(InitialUsage(), UsagePercent()); |
| 733 | // Verify reset. |
| 734 | InsertAndSendFramesWithInterval( |
| 735 | 2, (options_.frame_timeout_interval_ms + 1) * |
| 736 | rtc::kNumMicrosecsPerMillisec, kWidth, kHeight, kProcessTimeUs); |
| 737 | ForceUpdate(kWidth, kHeight); |
| 738 | EXPECT_EQ(InitialUsage(), UsagePercent()); |
| 739 | } |
| 740 | |
| 741 | TEST_F(OveruseFrameDetectorTest2, ConvergesSlowly) { |
| 742 | InsertAndSendFramesWithInterval(1, kFrameIntervalUs, kWidth, kHeight, |
| 743 | kProcessTimeUs); |
| 744 | // No update for the first sample. |
| 745 | EXPECT_EQ(InitialUsage(), UsagePercent()); |
| 746 | |
| 747 | // Total time approximately 40 * 33ms = 1.3s, significantly less |
| 748 | // than the 5s time constant. |
| 749 | InsertAndSendFramesWithInterval( |
| 750 | 40, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); |
| 751 | |
| 752 | // Should have started to approach correct load of 15%, but not very far. |
| 753 | EXPECT_LT(UsagePercent(), InitialUsage()); |
| 754 | EXPECT_GT(UsagePercent(), (InitialUsage() * 3 + 15) / 4); |
| 755 | |
| 756 | // Run for roughly 10s more, should now be closer. |
| 757 | InsertAndSendFramesWithInterval( |
| 758 | 300, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); |
| 759 | EXPECT_NEAR(UsagePercent(), 20, 5); |
| 760 | } |
| 761 | |
| 762 | TEST_F(OveruseFrameDetectorTest2, InitialProcessingUsage) { |
| 763 | ForceUpdate(kWidth, kHeight); |
| 764 | EXPECT_EQ(InitialUsage(), UsagePercent()); |
| 765 | } |
| 766 | |
| 767 | TEST_F(OveruseFrameDetectorTest2, MeasuresMultipleConcurrentSamples) { |
| 768 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)) |
| 769 | .Times(testing::AtLeast(1)); |
| 770 | static const int kIntervalUs = 33 * rtc::kNumMicrosecsPerMillisec; |
| 771 | static const size_t kNumFramesEncodingDelay = 3; |
| 772 | VideoFrame frame(I420Buffer::Create(kWidth, kHeight), |
| 773 | webrtc::kVideoRotation_0, 0); |
| 774 | for (size_t i = 0; i < 1000; ++i) { |
| 775 | // Unique timestamps. |
| 776 | frame.set_timestamp(static_cast<uint32_t>(i)); |
| 777 | int64_t capture_time_us = rtc::TimeMicros(); |
| 778 | overuse_detector_->FrameCaptured(frame, capture_time_us); |
| 779 | clock_.AdvanceTimeMicros(kIntervalUs); |
| 780 | if (i > kNumFramesEncodingDelay) { |
| 781 | overuse_detector_->FrameSent( |
| 782 | static_cast<uint32_t>(i - kNumFramesEncodingDelay), rtc::TimeMicros(), |
| 783 | capture_time_us, kIntervalUs); |
| 784 | } |
| 785 | overuse_detector_->CheckForOveruse(); |
| 786 | } |
| 787 | } |
| 788 | |
| 789 | TEST_F(OveruseFrameDetectorTest2, UpdatesExistingSamples) { |
| 790 | // >85% encoding time should trigger overuse. |
| 791 | EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)) |
| 792 | .Times(testing::AtLeast(1)); |
| 793 | static const int kIntervalUs = 33 * rtc::kNumMicrosecsPerMillisec; |
| 794 | static const int kDelayUs = 30 * rtc::kNumMicrosecsPerMillisec; |
| 795 | VideoFrame frame(I420Buffer::Create(kWidth, kHeight), |
| 796 | webrtc::kVideoRotation_0, 0); |
| 797 | uint32_t timestamp = 0; |
| 798 | for (size_t i = 0; i < 1000; ++i) { |
| 799 | frame.set_timestamp(timestamp); |
| 800 | int64_t capture_time_us = rtc::TimeMicros(); |
| 801 | overuse_detector_->FrameCaptured(frame, capture_time_us); |
| 802 | // Encode and send first parts almost instantly. |
| 803 | clock_.AdvanceTimeMicros(rtc::kNumMicrosecsPerMillisec); |
| 804 | overuse_detector_->FrameSent(timestamp, rtc::TimeMicros(), capture_time_us, |
| 805 | rtc::kNumMicrosecsPerMillisec); |
| 806 | // Encode heavier part, resulting in >85% usage total. |
| 807 | clock_.AdvanceTimeMicros(kDelayUs - rtc::kNumMicrosecsPerMillisec); |
| 808 | overuse_detector_->FrameSent(timestamp, rtc::TimeMicros(), capture_time_us, |
| 809 | kDelayUs); |
| 810 | clock_.AdvanceTimeMicros(kIntervalUs - kDelayUs); |
| 811 | timestamp += kIntervalUs * 90 / 1000; |
| 812 | overuse_detector_->CheckForOveruse(); |
| 813 | } |
| 814 | } |
| 815 | |
| 816 | TEST_F(OveruseFrameDetectorTest2, RunOnTqNormalUsage) { |
| 817 | rtc::TaskQueue queue("OveruseFrameDetectorTestQueue"); |
| 818 | |
| 819 | rtc::Event event(false, false); |
| 820 | queue.PostTask([this, &event] { |
| 821 | overuse_detector_->StartCheckForOveruse(); |
| 822 | event.Set(); |
| 823 | }); |
| 824 | event.Wait(rtc::Event::kForever); |
| 825 | |
| 826 | // Expect NormalUsage(). When called, stop the |overuse_detector_| and then |
| 827 | // set |event| to end the test. |
| 828 | EXPECT_CALL(*(observer_.get()), AdaptUp(reason_)) |
| 829 | .WillOnce(InvokeWithoutArgs([this, &event] { |
| 830 | overuse_detector_->StopCheckForOveruse(); |
| 831 | event.Set(); |
| 832 | })); |
| 833 | |
| 834 | queue.PostTask([this] { |
| 835 | const int kDelayUs1 = 5 * rtc::kNumMicrosecsPerMillisec; |
| 836 | const int kDelayUs2 = 6 * rtc::kNumMicrosecsPerMillisec; |
| 837 | InsertAndSendFramesWithInterval(1300, kFrameIntervalUs, kWidth, kHeight, |
| 838 | kDelayUs1); |
| 839 | InsertAndSendFramesWithInterval(1, kFrameIntervalUs, kWidth, kHeight, |
| 840 | kDelayUs2); |
| 841 | }); |
| 842 | |
| 843 | EXPECT_TRUE(event.Wait(10000)); |
| 844 | } |
| 845 | |
| 846 | // Models screencast, with irregular arrival of frames which are heavy |
| 847 | // to encode. |
| 848 | TEST_F(OveruseFrameDetectorTest2, NoOveruseForLargeRandomFrameInterval) { |
| 849 | EXPECT_CALL(*(observer_.get()), AdaptDown(_)).Times(0); |
| 850 | EXPECT_CALL(*(observer_.get()), AdaptUp(reason_)) |
| 851 | .Times(testing::AtLeast(1)); |
| 852 | |
| 853 | const int kNumFrames = 500; |
| 854 | const int kEncodeTimeUs = 100 * rtc::kNumMicrosecsPerMillisec; |
| 855 | |
| 856 | const int kMinIntervalUs = 30 * rtc::kNumMicrosecsPerMillisec; |
| 857 | const int kMaxIntervalUs = 1000 * rtc::kNumMicrosecsPerMillisec; |
| 858 | |
| 859 | InsertAndSendFramesWithRandomInterval(kNumFrames, |
| 860 | kMinIntervalUs, kMaxIntervalUs, |
| 861 | kWidth, kHeight, kEncodeTimeUs); |
| 862 | // Average usage 19%. Check that estimate is in the right ball park. |
| 863 | EXPECT_NEAR(UsagePercent(), 20, 10); |
| 864 | } |
| 865 | |
| 866 | // Models screencast, with irregular arrival of frames, often |
| 867 | // exceeding the timeout interval. |
| 868 | TEST_F(OveruseFrameDetectorTest2, NoOveruseForRandomFrameIntervalWithReset) { |
| 869 | EXPECT_CALL(*(observer_.get()), AdaptDown(_)).Times(0); |
| 870 | EXPECT_CALL(*(observer_.get()), AdaptUp(reason_)) |
| 871 | .Times(testing::AtLeast(1)); |
| 872 | |
| 873 | const int kNumFrames = 500; |
| 874 | const int kEncodeTimeUs = 100 * rtc::kNumMicrosecsPerMillisec; |
| 875 | |
| 876 | const int kMinIntervalUs = 30 * rtc::kNumMicrosecsPerMillisec; |
| 877 | const int kMaxIntervalUs = 3000 * rtc::kNumMicrosecsPerMillisec; |
| 878 | |
| 879 | InsertAndSendFramesWithRandomInterval(kNumFrames, |
| 880 | kMinIntervalUs, kMaxIntervalUs, |
| 881 | kWidth, kHeight, kEncodeTimeUs); |
| 882 | |
| 883 | // Average usage 6.6%, but since the frame_timeout_interval_ms is |
| 884 | // only 1500 ms, we often reset the estimate to the initial value. |
| 885 | // Check that estimate is in the right ball park. |
| 886 | EXPECT_GE(UsagePercent(), 1); |
| 887 | EXPECT_LE(UsagePercent(), InitialUsage() + 5); |
| 888 | } |
| 889 | |
mflodman@webrtc.org | e6168f5 | 2013-06-26 11:23:01 +0000 | [diff] [blame] | 890 | } // namespace webrtc |