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

Unified Diff: webrtc/call/call_perf_tests.cc

Issue 2789823002: Reland of Add framerate to VideoSinkWants and ability to signal on overuse (Closed)
Patch Set: Rebase fix Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/call/bitrate_estimator_tests.cc ('k') | webrtc/media/base/adaptedvideotracksource.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/call/call_perf_tests.cc
diff --git a/webrtc/call/call_perf_tests.cc b/webrtc/call/call_perf_tests.cc
index 0bbb7d49efa0490c55abe1cc7bb0ba26f478783d..a31cb23922e4aecd82a96a7f71a0b2c971de0238 100644
--- a/webrtc/call/call_perf_tests.cc
+++ b/webrtc/call/call_perf_tests.cc
@@ -30,6 +30,7 @@
#include "webrtc/test/fake_audio_device.h"
#include "webrtc/test/fake_decoder.h"
#include "webrtc/test/fake_encoder.h"
+#include "webrtc/test/field_trial.h"
#include "webrtc/test/frame_generator.h"
#include "webrtc/test/frame_generator_capturer.h"
#include "webrtc/test/gtest.h"
@@ -477,13 +478,15 @@ TEST_F(CallPerfTest, CaptureNtpTimeWithNetworkJitter) {
}
TEST_F(CallPerfTest, ReceivesCpuOveruseAndUnderuse) {
+ // Minimal normal usage at the start, then 30s overuse to allow filter to
+ // settle, and then 80s underuse to allow plenty of time for rampup again.
+ test::ScopedFieldTrials fake_overuse_settings(
+ "WebRTC-ForceSimulatedOveruseIntervalMs/1-30000-80000/");
+
class LoadObserver : public test::SendTest,
public test::FrameGeneratorCapturer::SinkWantsObserver {
public:
- LoadObserver()
- : SendTest(kLongTimeoutMs),
- expect_lower_resolution_wants_(true),
- encoder_(Clock::GetRealTimeClock(), 60 /* delay_ms */) {}
+ LoadObserver() : SendTest(kLongTimeoutMs), test_phase_(TestPhase::kStart) {}
void OnFrameGeneratorCapturerCreated(
test::FrameGeneratorCapturer* frame_generator_capturer) override {
@@ -494,24 +497,43 @@ 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_) {
+ 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;
+ } 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;
}
}
@@ -519,15 +541,13 @@ TEST_F(CallPerfTest, ReceivesCpuOveruseAndUnderuse) {
VideoSendStream::Config* send_config,
std::vector<VideoReceiveStream::Config>* receive_configs,
VideoEncoderConfig* encoder_config) override {
- send_config->encoder_settings.encoder = &encoder_;
}
void PerformTest() override {
EXPECT_TRUE(Wait()) << "Timed out before receiving an overuse callback.";
}
- bool expect_lower_resolution_wants_;
- test::DelayedEncoder encoder_;
+ enum class TestPhase { kStart, kAdaptedDown, kAdaptedUp } test_phase_;
} test;
RunBaseTest(&test);
« no previous file with comments | « webrtc/call/bitrate_estimator_tests.cc ('k') | webrtc/media/base/adaptedvideotracksource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698