 Chromium Code Reviews
 Chromium Code Reviews Issue 2781433002:
  Reland of Add framerate to VideoSinkWants and ability to signal on overuse  (Closed)
    
  
    Issue 2781433002:
  Reland of Add framerate to VideoSinkWants and ability to signal on overuse  (Closed) 
  | Index: webrtc/call/call_perf_tests.cc | 
| diff --git a/webrtc/call/call_perf_tests.cc b/webrtc/call/call_perf_tests.cc | 
| index a421c24d56558fd29880f0074338b938b3a94a6e..24b290ee0e142e15d304885ddedf54de4f925f1a 100644 | 
| --- a/webrtc/call/call_perf_tests.cc | 
| +++ b/webrtc/call/call_perf_tests.cc | 
| @@ -477,7 +477,7 @@ TEST_F(CallPerfTest, ReceivesCpuOveruseAndUnderuse) { | 
| public: | 
| LoadObserver() | 
| : SendTest(kLongTimeoutMs), | 
| - expect_lower_resolution_wants_(true), | 
| + test_phase_(TestPhase::kStart), | 
| encoder_(Clock::GetRealTimeClock(), 60 /* delay_ms */) {} | 
| void OnFrameGeneratorCapturerCreated( | 
| @@ -489,24 +489,44 @@ TEST_F(CallPerfTest, ReceivesCpuOveruseAndUnderuse) { | 
| // OnSinkWantsChanged is called when FrameGeneratorCapturer::AddOrUpdateSink | 
| // is called. | 
| + // TODO(sprang): Add integration test for maintain-framerate mode? | 
| void OnSinkWantsChanged(rtc::VideoSinkInterface<VideoFrame>* sink, | 
| const rtc::VideoSinkWants& wants) override { | 
| // 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. | 
| - EXPECT_TRUE(expect_lower_resolution_wants_); | 
| - expect_lower_resolution_wants_ = false; | 
| - encoder_.SetDelay(2); | 
| + switch (test_phase_) { | 
| 
ilnik
2017/03/27 10:11:10
In some tests there were 2 AdaptDown requests, bef
 
sprang_webrtc
2017/03/27 11:18:38
I set it to 150%, as that seems to be a common tes
 | 
| + case TestPhase::kStart: | 
| + if (wants.max_pixel_count < std::numeric_limits<int>::max()) { | 
| + // On adapting down, ViEEncoder::VideoSourceProxy will set only the | 
| + // max pixel count, leaving the target unset. | 
| + test_phase_ = TestPhase::kAdaptedDown; | 
| + encoder_.SetDelay(2); | 
| + } else { | 
| + ADD_FAILURE() << "Got unexpected adaptation request, max res = " | 
| + << wants.max_pixel_count << ", target res = " | 
| + << wants.target_pixel_count.value_or(-1) | 
| + << ", max fps = " << wants.max_framerate_fps; | 
| + } | 
| + break; | 
| + case TestPhase::kAdaptedDown: | 
| + // On adapting up, the adaptation counter will again be at zero, and | 
| + // so all constraints will be reset. | 
| + if (wants.max_pixel_count == std::numeric_limits<int>::max() && | 
| + !wants.target_pixel_count) { | 
| + test_phase_ = TestPhase::kAdaptedUp; | 
| + observation_complete_.Set(); | 
| + } else { | 
| + ADD_FAILURE() << "Got unexpected adaptation request, max res = " | 
| + << wants.max_pixel_count << ", target res = " | 
| + << wants.target_pixel_count.value_or(-1) | 
| + << ", max fps = " << wants.max_framerate_fps; | 
| + } | 
| + break; | 
| + case TestPhase::kAdaptedUp: | 
| + ADD_FAILURE() << "Got unexpected adaptation request, max res = " | 
| + << wants.max_pixel_count << ", target res = " | 
| + << wants.target_pixel_count.value_or(-1) | 
| + << ", max fps = " << wants.max_framerate_fps; | 
| } | 
| } | 
| @@ -521,7 +541,7 @@ TEST_F(CallPerfTest, ReceivesCpuOveruseAndUnderuse) { | 
| EXPECT_TRUE(Wait()) << "Timed out before receiving an overuse callback."; | 
| } | 
| - bool expect_lower_resolution_wants_; | 
| + enum class TestPhase { kStart, kAdaptedDown, kAdaptedUp } test_phase_; | 
| test::DelayedEncoder encoder_; | 
| } test; |