Index: webrtc/media/engine/webrtcvideoengine2_unittest.cc |
diff --git a/webrtc/media/engine/webrtcvideoengine2_unittest.cc b/webrtc/media/engine/webrtcvideoengine2_unittest.cc |
index a4479560b51bdd612290be81f57cac87245317a8..0e1e372a31b66b67ece355446a287880539a913a 100644 |
--- a/webrtc/media/engine/webrtcvideoengine2_unittest.cc |
+++ b/webrtc/media/engine/webrtcvideoengine2_unittest.cc |
@@ -32,18 +32,13 @@ using webrtc::RtpExtension; |
namespace { |
static const int kDefaultQpMax = 56; |
-static const int kDefaultFramerate = 30; |
-static const cricket::VideoCodec kVp8Codec720p(100, "VP8", 1280, 720, 30); |
-static const cricket::VideoCodec kVp8Codec360p(100, "VP8", 640, 360, 30); |
-static const cricket::VideoCodec kVp8Codec270p(100, "VP8", 480, 270, 30); |
+static const cricket::VideoCodec kVp8Codec(100, "VP8"); |
+static const cricket::VideoCodec kVp9Codec(101, "VP9"); |
+static const cricket::VideoCodec kH264Codec(102, "H264"); |
-static const cricket::VideoCodec kVp8Codec(100, "VP8", 640, 400, 30); |
-static const cricket::VideoCodec kVp9Codec(101, "VP9", 640, 400, 30); |
-static const cricket::VideoCodec kH264Codec(102, "H264", 640, 400, 30); |
- |
-static const cricket::VideoCodec kRedCodec(116, "red", 0, 0, 0); |
-static const cricket::VideoCodec kUlpfecCodec(117, "ulpfec", 0, 0, 0); |
+static const cricket::VideoCodec kRedCodec(116, "red"); |
+static const cricket::VideoCodec kUlpfecCodec(117, "ulpfec"); |
static const uint8_t kRedRtxPayloadType = 125; |
@@ -834,34 +829,20 @@ WEBRTC_BASE_TEST(RemoveCapturerWithoutAdd); |
WEBRTC_BASE_TEST(AddRemoveCapturerMultipleSources); |
-// TODO(pbos): Figure out why this fails so often. |
-WEBRTC_DISABLED_BASE_TEST(HighAspectHighHeightCapturer); |
- |
WEBRTC_BASE_TEST(RejectEmptyStreamParams); |
-WEBRTC_BASE_TEST(AdaptResolution16x10); |
- |
-WEBRTC_BASE_TEST(AdaptResolution4x3); |
- |
-// TODO(juberti): Restore this test once we support sending 0 fps. |
-WEBRTC_DISABLED_BASE_TEST(AdaptDropAllFrames); |
-// TODO(juberti): Understand why we get decode errors on this test. |
-WEBRTC_DISABLED_BASE_TEST(AdaptFramerate); |
- |
-WEBRTC_BASE_TEST(SendsLowerResolutionOnSmallerFrames); |
- |
WEBRTC_BASE_TEST(MultipleSendStreams); |
TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8Vga) { |
- SendAndReceive(cricket::VideoCodec(100, "VP8", 640, 400, 30)); |
+ SendAndReceive(cricket::VideoCodec(100, "VP8")); |
} |
TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8Qvga) { |
- SendAndReceive(cricket::VideoCodec(100, "VP8", 320, 200, 30)); |
+ SendAndReceive(cricket::VideoCodec(100, "VP8")); |
} |
TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8SvcQqvga) { |
- SendAndReceive(cricket::VideoCodec(100, "VP8", 160, 100, 30)); |
+ SendAndReceive(cricket::VideoCodec(100, "VP8")); |
} |
TEST_F(WebRtcVideoChannel2BaseTest, TwoStreamsSendAndReceive) { |
@@ -1509,7 +1490,7 @@ TEST_F(WebRtcVideoChannel2Test, NackCanBeEnabledAndDisabled) { |
// earlier. |
TEST_F(WebRtcVideoChannel2Test, ReconfiguresEncodersWhenNotSending) { |
cricket::VideoSendParameters parameters; |
- parameters.codecs.push_back(kVp8Codec720p); |
+ parameters.codecs.push_back(kVp8Codec); |
ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
channel_->SetSend(false); |
@@ -1522,21 +1503,21 @@ TEST_F(WebRtcVideoChannel2Test, ReconfiguresEncodersWhenNotSending) { |
cricket::FakeVideoCapturer capturer; |
EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer)); |
- EXPECT_EQ(cricket::CS_RUNNING, |
- capturer.Start(capturer.GetSupportedFormats()->front())); |
+ VideoFormat capture_format = capturer.GetSupportedFormats()->front(); |
+ EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format)); |
EXPECT_TRUE(capturer.CaptureFrame()); |
// Frame entered, should be reconfigured to new dimensions. |
streams = stream->GetVideoStreams(); |
- EXPECT_EQ(kVp8Codec720p.width, streams[0].width); |
- EXPECT_EQ(kVp8Codec720p.height, streams[0].height); |
+ EXPECT_EQ(capture_format.width, streams[0].width); |
+ EXPECT_EQ(capture_format.height, streams[0].height); |
EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); |
} |
TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) { |
static const int kScreenshareMinBitrateKbps = 800; |
- cricket::VideoCodec codec = kVp8Codec360p; |
+ cricket::VideoCodec codec = kVp8Codec; |
cricket::VideoSendParameters parameters; |
parameters.codecs.push_back(codec); |
EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
@@ -1725,7 +1706,7 @@ TEST_F(WebRtcVideoChannel2Test, Vp8DenoisingEnabledByDefault) { |
TEST_F(WebRtcVideoChannel2Test, VerifyVp8SpecificSettings) { |
cricket::VideoSendParameters parameters; |
- parameters.codecs.push_back(kVp8Codec720p); |
+ parameters.codecs.push_back(kVp8Codec); |
ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
// Single-stream settings should apply with RTX as well (verifies that we |
@@ -1806,7 +1787,7 @@ TEST_F(WebRtcVideoChannel2Test, SetIdenticalOptionsDoesntReconfigureEncoder) { |
EXPECT_EQ(cricket::CS_RUNNING, |
capturer.Start(capturer.GetSupportedFormats()->front())); |
cricket::VideoSendParameters parameters; |
- parameters.codecs.push_back(kVp8Codec720p); |
+ parameters.codecs.push_back(kVp8Codec); |
ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); |
@@ -1986,7 +1967,7 @@ TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenScreensharing) { |
} |
TEST_F(WebRtcVideoChannel2Test, AdaptsOnOveruseAndChangeResolution) { |
- cricket::VideoCodec codec = kVp8Codec720p; |
+ cricket::VideoCodec codec = kVp8Codec; |
cricket::VideoSendParameters parameters; |
parameters.codecs.push_back(codec); |
@@ -2060,7 +2041,7 @@ TEST_F(WebRtcVideoChannel2Test, AdaptsOnOveruseAndChangeResolution) { |
} |
TEST_F(WebRtcVideoChannel2Test, PreviousAdaptationDoesNotApplyToScreenshare) { |
- cricket::VideoCodec codec = kVp8Codec720p; |
+ cricket::VideoCodec codec = kVp8Codec; |
cricket::VideoSendParameters parameters; |
parameters.codecs.push_back(codec); |
@@ -2123,7 +2104,7 @@ TEST_F(WebRtcVideoChannel2Test, PreviousAdaptationDoesNotApplyToScreenshare) { |
void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, |
bool is_screenshare) { |
- cricket::VideoCodec codec = kVp8Codec720p; |
+ cricket::VideoCodec codec = kVp8Codec; |
cricket::VideoSendParameters parameters; |
parameters.codecs.push_back(codec); |
@@ -2142,8 +2123,8 @@ void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, |
VideoOptions options; |
options.is_screencast = rtc::Optional<bool>(is_screenshare); |
EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); |
- EXPECT_EQ(cricket::CS_RUNNING, |
- capturer.Start(capturer.GetSupportedFormats()->front())); |
+ cricket::VideoFormat capture_format = capturer.GetSupportedFormats()->front(); |
+ EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format)); |
EXPECT_TRUE(channel_->SetSend(true)); |
@@ -2159,8 +2140,8 @@ void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, |
EXPECT_TRUE(capturer.CaptureFrame()); |
EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); |
- EXPECT_EQ(codec.width, send_stream->GetLastWidth()); |
- EXPECT_EQ(codec.height, send_stream->GetLastHeight()); |
+ EXPECT_EQ(capture_format.width, send_stream->GetLastWidth()); |
+ EXPECT_EQ(capture_format.height, send_stream->GetLastHeight()); |
EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); |
return; |
@@ -2176,11 +2157,11 @@ void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, |
if (is_screenshare) { |
// Do not adapt screen share. |
- EXPECT_EQ(codec.width, send_stream->GetLastWidth()); |
- EXPECT_EQ(codec.height, send_stream->GetLastHeight()); |
+ EXPECT_EQ(capture_format.width, send_stream->GetLastWidth()); |
+ EXPECT_EQ(capture_format.height, send_stream->GetLastHeight()); |
} else { |
- EXPECT_LT(send_stream->GetLastWidth(), codec.width); |
- EXPECT_LT(send_stream->GetLastHeight(), codec.height); |
+ EXPECT_LT(send_stream->GetLastWidth(), capture_format.width); |
+ EXPECT_LT(send_stream->GetLastHeight(), capture_format.height); |
} |
// Trigger underuse which should go back to normal resolution. |
@@ -2188,8 +2169,8 @@ void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, |
EXPECT_TRUE(capturer.CaptureFrame()); |
EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames()); |
- EXPECT_EQ(codec.width, send_stream->GetLastWidth()); |
- EXPECT_EQ(codec.height, send_stream->GetLastHeight()); |
+ EXPECT_EQ(capture_format.width, send_stream->GetLastWidth()); |
+ EXPECT_EQ(capture_format.height, send_stream->GetLastHeight()); |
EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); |
} |
@@ -2270,7 +2251,7 @@ TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFec) { |
TEST_F(WebRtcVideoChannel2Test, |
SetSendCodecRejectsRtxWithoutAssociatedPayloadType) { |
cricket::VideoSendParameters parameters; |
- cricket::VideoCodec rtx_codec(96, "rtx", 0, 0, 0); |
+ cricket::VideoCodec rtx_codec(96, "rtx"); |
parameters.codecs.push_back(rtx_codec); |
EXPECT_FALSE(channel_->SetSendParameters(parameters)) |
<< "RTX codec without associated payload type should be rejected."; |
@@ -2315,9 +2296,9 @@ TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFecDisablesFec) { |
TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) { |
cricket::VideoSendParameters parameters; |
- cricket::VideoCodec codec720p(100, "VP8", 1280, 720, 30); |
- codec720p.SetParam(kCodecParamMaxQuantization, kDefaultQpMax); |
- parameters.codecs.push_back(codec720p); |
+ cricket::VideoCodec codec(100, "VP8"); |
+ codec.SetParam(kCodecParamMaxQuantization, kDefaultQpMax); |
+ parameters.codecs.push_back(codec); |
ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
channel_->SetSend(true); |
@@ -2330,8 +2311,8 @@ TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) { |
EXPECT_EQ(kDefaultQpMax, streams[0].max_qp); |
parameters.codecs.clear(); |
- codec720p.SetParam(kCodecParamMaxQuantization, kDefaultQpMax + 1); |
- parameters.codecs.push_back(codec720p); |
+ codec.SetParam(kCodecParamMaxQuantization, kDefaultQpMax + 1); |
+ parameters.codecs.push_back(codec); |
ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams(); |
EXPECT_EQ(kDefaultQpMax + 1, streams[0].max_qp); |
@@ -2447,7 +2428,7 @@ TEST_F(WebRtcVideoChannel2Test, SetMaxSendBandwidthAndAddSendStream) { |
TEST_F(WebRtcVideoChannel2Test, SetMaxSendBitrateCanIncreaseSenderBitrate) { |
cricket::VideoSendParameters parameters; |
- parameters.codecs.push_back(kVp8Codec720p); |
+ parameters.codecs.push_back(kVp8Codec); |
ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
channel_->SetSend(true); |
@@ -2474,7 +2455,7 @@ TEST_F(WebRtcVideoChannel2Test, SetMaxSendBitrateCanIncreaseSenderBitrate) { |
TEST_F(WebRtcVideoChannel2Test, |
SetMaxSendBitrateCanIncreaseSimulcastSenderBitrate) { |
cricket::VideoSendParameters parameters; |
- parameters.codecs.push_back(kVp8Codec720p); |
+ parameters.codecs.push_back(kVp8Codec); |
ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
channel_->SetSend(true); |
@@ -2519,20 +2500,6 @@ TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithMaxQuantization) { |
EXPECT_EQ(kMaxQuantization, codec.params[kCodecParamMaxQuantization]); |
} |
-TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectBadDimensions) { |
- cricket::VideoSendParameters parameters; |
- parameters.codecs.push_back(kVp8Codec); |
- |
- parameters.codecs[0].width = 0; |
- EXPECT_FALSE(channel_->SetSendParameters(parameters)) |
- << "Codec set though codec width is zero."; |
- |
- parameters.codecs[0].width = kVp8Codec.width; |
- parameters.codecs[0].height = 0; |
- EXPECT_FALSE(channel_->SetSendParameters(parameters)) |
- << "Codec set though codec height is zero."; |
-} |
- |
TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectBadPayloadTypes) { |
// TODO(pbos): Should we only allow the dynamic range? |
static const int kIncorrectPayloads[] = {-2, -1, 128, 129}; |
@@ -2585,7 +2552,7 @@ TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithOnlyVp8) { |
TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithRtx) { |
cricket::VideoRecvParameters parameters; |
parameters.codecs.push_back(kVp8Codec); |
- cricket::VideoCodec rtx_codec(96, "rtx", 0, 0, 0); |
+ cricket::VideoCodec rtx_codec(96, "rtx"); |
parameters.codecs.push_back(rtx_codec); |
EXPECT_FALSE(channel_->SetRecvParameters(parameters)) |
<< "RTX codec without associated payload should be rejected."; |
@@ -2597,7 +2564,7 @@ TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithRtx) { |
parameters.codecs[1].SetParam("apt", kVp8Codec.id); |
EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
- cricket::VideoCodec rtx_codec2(97, "rtx", 0, 0, 0); |
+ cricket::VideoCodec rtx_codec2(97, "rtx"); |
rtx_codec2.SetParam("apt", rtx_codec.id); |
parameters.codecs.push_back(rtx_codec2); |
@@ -2627,7 +2594,7 @@ TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsAcceptDefaultCodecs) { |
TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectUnsupportedCodec) { |
cricket::VideoRecvParameters parameters; |
parameters.codecs.push_back(kVp8Codec); |
- parameters.codecs.push_back(VideoCodec(101, "WTF3", 640, 400, 30)); |
+ parameters.codecs.push_back(VideoCodec(101, "WTF3")); |
EXPECT_FALSE(channel_->SetRecvParameters(parameters)); |
} |
@@ -2938,7 +2905,7 @@ TEST_F(WebRtcVideoChannel2Test, GetStatsTracksAdaptationStats) { |
channel_->SetVideoSend(kSsrcs3[0], true, nullptr, &video_capturer_vga)); |
EXPECT_TRUE(video_capturer_vga.CaptureFrame()); |
- cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30); |
+ cricket::VideoCodec send_codec(100, "VP8"); |
cricket::VideoSendParameters parameters; |
parameters.codecs.push_back(send_codec); |
EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
@@ -3013,7 +2980,7 @@ TEST_F(WebRtcVideoChannel2Test, GetStatsTracksAdaptationAndBandwidthStats) { |
channel_->SetVideoSend(kSsrcs3[0], true, nullptr, &video_capturer_vga)); |
EXPECT_TRUE(video_capturer_vga.CaptureFrame()); |
- cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30); |
+ cricket::VideoCodec send_codec(100, "VP8"); |
cricket::VideoSendParameters parameters; |
parameters.codecs.push_back(send_codec); |
EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
@@ -3608,10 +3575,10 @@ TEST_F(WebRtcVideoChannel2Test, GetRtpReceiveFmtpSprop) { |
TEST_F(WebRtcVideoChannel2Test, DISABLED_GetRtpReceiveFmtpSprop) { |
#endif |
cricket::VideoRecvParameters parameters; |
- cricket::VideoCodec kH264sprop1(101, "H264", 640, 400, 15); |
+ cricket::VideoCodec kH264sprop1(101, "H264"); |
kH264sprop1.SetParam("sprop-parameter-sets", "uvw"); |
parameters.codecs.push_back(kH264sprop1); |
- cricket::VideoCodec kH264sprop2(102, "H264", 640, 400, 15); |
+ cricket::VideoCodec kH264sprop2(102, "H264"); |
kH264sprop2.SetParam("sprop-parameter-sets", "xyz"); |
parameters.codecs.push_back(kH264sprop2); |
EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
@@ -3737,6 +3704,8 @@ class WebRtcVideoChannel2SimulcastTest : public testing::Test { |
protected: |
void VerifySimulcastSettings(const VideoCodec& codec, |
+ int capture_width, |
+ int capture_height, |
size_t num_configured_streams, |
size_t expected_num_streams) { |
cricket::VideoSendParameters parameters; |
@@ -3755,7 +3724,7 @@ class WebRtcVideoChannel2SimulcastTest : public testing::Test { |
EXPECT_TRUE( |
channel_->SetVideoSend(ssrcs.front(), true, nullptr, &capturer)); |
EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(cricket::VideoFormat( |
- codec.width, codec.height, |
+ capture_width, capture_height, |
cricket::VideoFormat::FpsToInterval(30), |
cricket::FOURCC_I420))); |
channel_->SetSend(true); |
@@ -3765,8 +3734,8 @@ class WebRtcVideoChannel2SimulcastTest : public testing::Test { |
ASSERT_EQ(expected_num_streams, video_streams.size()); |
std::vector<webrtc::VideoStream> expected_streams = GetSimulcastConfig( |
- num_configured_streams, codec.width, codec.height, 0, kDefaultQpMax, |
- codec.framerate != 0 ? codec.framerate : kDefaultFramerate); |
+ num_configured_streams, capture_width, capture_height, 0, kDefaultQpMax, |
+ kDefaultVideoMaxFramerate); |
ASSERT_EQ(expected_streams.size(), video_streams.size()); |
@@ -3849,18 +3818,16 @@ class WebRtcVideoChannel2SimulcastTest : public testing::Test { |
}; |
TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith2SimulcastStreams) { |
- VerifySimulcastSettings(kVp8Codec, 2, 2); |
+ VerifySimulcastSettings(kVp8Codec, 640, 360, 2, 2); |
} |
TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) { |
- VerifySimulcastSettings(kVp8Codec720p, 3, 3); |
+ VerifySimulcastSettings(kVp8Codec, 1280, 720, 3, 3); |
} |
// Test that we normalize send codec format size in simulcast. |
TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { |
- cricket::VideoCodec codec(kVp8Codec270p); |
- codec.width += 1; |
- codec.height += 1; |
- VerifySimulcastSettings(codec, 2, 2); |
+ cricket::VideoCodec codec(kVp8Codec); |
+ VerifySimulcastSettings(codec, 541, 271, 2, 2); |
} |
} // namespace cricket |