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

Unified Diff: webrtc/media/engine/webrtcvideoengine2_unittest.cc

Issue 2698203003: Update sink wants with ranges for both pixel count and frame rate.
Patch Set: Created 3 years, 10 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
Index: webrtc/media/engine/webrtcvideoengine2_unittest.cc
diff --git a/webrtc/media/engine/webrtcvideoengine2_unittest.cc b/webrtc/media/engine/webrtcvideoengine2_unittest.cc
index f60af340aaf4e2313bd84ff905587c4f789a12c3..327b73151c1ceeada2f7864ac6db6ff48358dfca 100644
--- a/webrtc/media/engine/webrtcvideoengine2_unittest.cc
+++ b/webrtc/media/engine/webrtcvideoengine2_unittest.cc
@@ -14,7 +14,6 @@
#include <vector>
#include "webrtc/base/arraysize.h"
-#include "webrtc/base/gunit.h"
#include "webrtc/base/stringutils.h"
#include "webrtc/call/flexfec_receive_stream.h"
#include "webrtc/common_video/h264/profile_level_id.h"
@@ -29,6 +28,7 @@
#include "webrtc/media/engine/webrtcvideoengine2.h"
#include "webrtc/media/engine/webrtcvoiceengine.h"
#include "webrtc/test/field_trial.h"
+#include "webrtc/test/gtest.h"
#include "webrtc/video_encoder.h"
using webrtc::RtpExtension;
@@ -2100,8 +2100,9 @@ TEST_F(WebRtcVideoChannel2Test, AdaptsOnOveruseAndChangeResolution) {
// Trigger overuse.
rtc::VideoSinkWants wants;
- wants.max_pixel_count = rtc::Optional<int>(
- send_stream->GetLastWidth() * send_stream->GetLastHeight() - 1);
+ wants.pixel_count.emplace(rtc::VideoSinkWants::ValueRange(
+ 0, (send_stream->GetLastWidth() * send_stream->GetLastHeight() * 3) / 5,
+ send_stream->GetLastWidth() * send_stream->GetLastHeight() - 1));
send_stream->InjectVideoSinkWants(wants);
EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420));
EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames());
@@ -2109,8 +2110,9 @@ TEST_F(WebRtcVideoChannel2Test, AdaptsOnOveruseAndChangeResolution) {
EXPECT_EQ(720 * 3 / 4, send_stream->GetLastHeight());
// Trigger overuse again.
- wants.max_pixel_count = rtc::Optional<int>(
- send_stream->GetLastWidth() * send_stream->GetLastHeight() - 1);
+ wants.pixel_count.emplace(rtc::VideoSinkWants::ValueRange(
+ 0, (send_stream->GetLastWidth() * send_stream->GetLastHeight() * 3) / 5,
+ send_stream->GetLastWidth() * send_stream->GetLastHeight() - 1));
send_stream->InjectVideoSinkWants(wants);
EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420));
EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames());
@@ -2128,9 +2130,9 @@ TEST_F(WebRtcVideoChannel2Test, AdaptsOnOveruseAndChangeResolution) {
send_stream->GetLastWidth() * send_stream->GetLastHeight();
// Cap the max to 4x the pixel count (assuming max 1/2 x 1/2 scale downs)
// of the current stream, so we don't take too large steps.
- wants.max_pixel_count = rtc::Optional<int>(current_pixel_count * 4);
// Default step down is 3/5 pixel count, so go up by 5/3.
- wants.target_pixel_count = rtc::Optional<int>((current_pixel_count * 5) / 3);
+ wants.pixel_count.emplace(rtc::VideoSinkWants::ValueRange(
+ 0, (current_pixel_count * 5) / 3, current_pixel_count * 4));
send_stream->InjectVideoSinkWants(wants);
EXPECT_TRUE(capturer.CaptureCustomFrame(1284, 724, cricket::FOURCC_I420));
EXPECT_EQ(5, send_stream->GetNumberOfSwappedFrames());
@@ -2140,8 +2142,8 @@ TEST_F(WebRtcVideoChannel2Test, AdaptsOnOveruseAndChangeResolution) {
// Trigger underuse again, should go back up to full resolution.
current_pixel_count =
send_stream->GetLastWidth() * send_stream->GetLastHeight();
- wants.max_pixel_count = rtc::Optional<int>(current_pixel_count * 4);
- wants.target_pixel_count = rtc::Optional<int>((current_pixel_count * 5) / 3);
+ wants.pixel_count.emplace(rtc::VideoSinkWants::ValueRange(
+ 0, (current_pixel_count * 5) / 3, current_pixel_count * 4));
send_stream->InjectVideoSinkWants(wants);
EXPECT_TRUE(capturer.CaptureCustomFrame(1284, 724, cricket::FOURCC_I420));
EXPECT_EQ(6, send_stream->GetNumberOfSwappedFrames());
@@ -2184,8 +2186,9 @@ TEST_F(WebRtcVideoChannel2Test, PreviousAdaptationDoesNotApplyToScreenshare) {
// Trigger overuse.
rtc::VideoSinkWants wants;
- wants.max_pixel_count = rtc::Optional<int>(
- send_stream->GetLastWidth() * send_stream->GetLastHeight() - 1);
+ wants.pixel_count.emplace(rtc::VideoSinkWants::ValueRange(
+ 0, (send_stream->GetLastWidth() * send_stream->GetLastHeight() * 3) / 5,
+ send_stream->GetLastWidth() * send_stream->GetLastHeight() - 1));
send_stream->InjectVideoSinkWants(wants);
EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420));
EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames());
@@ -2263,8 +2266,9 @@ void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse,
ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
rtc::VideoSinkWants wants;
- wants.max_pixel_count =
- rtc::Optional<int>(capture_format.width * capture_format.height - 1);
+ wants.pixel_count.emplace(rtc::VideoSinkWants::ValueRange(
+ 0, (capture_format.width * capture_format.height * 3) / 5,
+ capture_format.width * capture_format.height - 1));
send_stream->InjectVideoSinkWants(wants);
EXPECT_TRUE(capturer.CaptureFrame());
@@ -2279,8 +2283,8 @@ void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse,
// Trigger underuse which should go back to normal resolution.
int last_pixel_count =
send_stream->GetLastWidth() * send_stream->GetLastHeight();
- wants.max_pixel_count = rtc::Optional<int>(last_pixel_count * 4);
- wants.target_pixel_count = rtc::Optional<int>((last_pixel_count * 5) / 3);
+ wants.pixel_count.emplace(rtc::VideoSinkWants::ValueRange(
+ 0, (last_pixel_count * 5) / 3, last_pixel_count * 4));
send_stream->InjectVideoSinkWants(wants);
EXPECT_TRUE(capturer.CaptureFrame());

Powered by Google App Engine
This is Rietveld 408576698