| Index: webrtc/call/call_perf_tests.cc
|
| diff --git a/webrtc/call/call_perf_tests.cc b/webrtc/call/call_perf_tests.cc
|
| index 56c6ba3535742e0ace64843f4ff8a15cea776128..224fb62a98a8fd29622760eee3fbfc5262dc62b8 100644
|
| --- a/webrtc/call/call_perf_tests.cc
|
| +++ b/webrtc/call/call_perf_tests.cc
|
| @@ -471,13 +471,17 @@ TEST_F(CallPerfTest, CaptureNtpTimeWithNetworkJitter) {
|
| #define ReceivesCpuOveruseAndUnderuse DISABLED_ReceivesCpuOveruseAndUnderuse
|
| #endif
|
| TEST_F(CallPerfTest, ReceivesCpuOveruseAndUnderuse) {
|
| + static const int kFrameRateFps = 30;
|
| +
|
| class LoadObserver : public test::SendTest,
|
| public test::FrameGeneratorCapturer::SinkWantsObserver {
|
| public:
|
| LoadObserver()
|
| : SendTest(kLongTimeoutMs),
|
| expect_lower_resolution_wants_(true),
|
| - encoder_(Clock::GetRealTimeClock(), 35 /* delay_ms */) {}
|
| + encoder_(Clock::GetRealTimeClock(),
|
| + 2 * (1000 / kFrameRateFps) /* delay = 200% utilization */),
|
| + start_pixel_count_(0) {}
|
|
|
| void OnFrameGeneratorCapturerCreated(
|
| test::FrameGeneratorCapturer* frame_generator_capturer) override {
|
| @@ -488,22 +492,26 @@ TEST_F(CallPerfTest, ReceivesCpuOveruseAndUnderuse) {
|
| // is called.
|
| void OnSinkWantsChanged(rtc::VideoSinkInterface<VideoFrame>* sink,
|
| const rtc::VideoSinkWants& wants) override {
|
| + RTC_DCHECK_GT(start_pixel_count_, 0);
|
| // First expect CPU overuse. Then expect CPU underuse when the encoder
|
| // delay has been decreased.
|
| - if (wants.target_pixel_count &&
|
| - *wants.target_pixel_count <
|
| - wants.max_pixel_count.value_or(std::numeric_limits<int>::max())) {
|
| - // On adapting up, ViEEncoder::VideoSourceProxy will set the target
|
| - // pixel count to a step up from the current and the max value to
|
| - // something higher than the target.
|
| - EXPECT_FALSE(expect_lower_resolution_wants_);
|
| - observation_complete_.Set();
|
| - } else if (wants.max_pixel_count) {
|
| - // On adapting down, ViEEncoder::VideoSourceProxy will set only the max
|
| - // pixel count, leaving the target unset.
|
| + if (wants.pixel_count &&
|
| + wants.pixel_count->max ==
|
| + static_cast<uint32_t>(start_pixel_count_ - 1)) {
|
| + // On adapting down, ViEEncoder::VideoSourceProxy will set the max one
|
| + // step below the current resolution.
|
| EXPECT_TRUE(expect_lower_resolution_wants_);
|
| expect_lower_resolution_wants_ = false;
|
| - encoder_.SetDelay(2);
|
| + encoder_.SetDelay(2); // Reduce fake high utilization.
|
| + } else if (wants.pixel_count &&
|
| + wants.pixel_count->min ==
|
| + static_cast<uint32_t>(start_pixel_count_ + 1)) {
|
| + // On adapting up, ViEEncoder::VideoSourceProxy will set the min pixel
|
| + // count one step higher than the current. Since this test doesn't
|
| + // include an adapter to actually scale down the input, this will still
|
| + // be the start resolution.
|
| + EXPECT_FALSE(expect_lower_resolution_wants_);
|
| + observation_complete_.Set();
|
| }
|
| }
|
|
|
| @@ -514,12 +522,21 @@ TEST_F(CallPerfTest, ReceivesCpuOveruseAndUnderuse) {
|
| send_config->encoder_settings.encoder = &encoder_;
|
| }
|
|
|
| + void ModifyVideoCaptureStartResolution(int* width,
|
| + int* heigt,
|
| + int* frame_rate) override {
|
| + RTC_DCHECK_EQ(0, start_pixel_count_);
|
| + start_pixel_count_ = *width * *heigt;
|
| + *frame_rate = kFrameRateFps;
|
| + }
|
| +
|
| void PerformTest() override {
|
| EXPECT_TRUE(Wait()) << "Timed out before receiving an overuse callback.";
|
| }
|
|
|
| bool expect_lower_resolution_wants_;
|
| test::DelayedEncoder encoder_;
|
| + int start_pixel_count_;
|
| } test;
|
|
|
| RunBaseTest(&test);
|
|
|