From 269605ce450545c565a77719e0167024a7d3643c Mon Sep 17 00:00:00 2001 From: "pbos@webrtc.org" Date: Thu, 26 Jun 2014 08:49:03 +0000 Subject: [PATCH] Implement SetSendCodecs() unit tests for WebRtcVideoChannel2. BUG= R=pbos@webrtc.org, wu@webrtc.org Review URL: https://webrtc-codereview.appspot.com/12829004 Patch from Changbin Shao . git-svn-id: http://webrtc.googlecode.com/svn/trunk@6543 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../webrtc/webrtcvideoengine2_unittest.cc | 55 +++++++++++++++---- 1 file changed, 45 insertions(+), 10 deletions(-) diff --git a/talk/media/webrtc/webrtcvideoengine2_unittest.cc b/talk/media/webrtc/webrtcvideoengine2_unittest.cc index 6886300234..618ffc4947 100644 --- a/talk/media/webrtc/webrtcvideoengine2_unittest.cc +++ b/talk/media/webrtc/webrtcvideoengine2_unittest.cc @@ -1003,9 +1003,9 @@ TEST_F(WebRtcVideoChannel2Test, SetDefaultSendCodecs) { EXPECT_EQ(1000, config.rtp.nack.rtp_history_ms); EXPECT_EQ(default_ulpfec_codec_.id, config.rtp.fec.ulpfec_payload_type); EXPECT_EQ(default_red_codec_.id, config.rtp.fec.red_payload_type); - // TODO(pbos): Verify that the rtx ssrc is set, correct, not taken by anything - // else. - // ASSERT_EQ(1u, config.rtp.rtx.ssrcs.size()); + + EXPECT_EQ(1u, config.rtp.rtx.ssrcs.size()); + EXPECT_EQ(kRtxSsrcs1[0], config.rtp.rtx.ssrcs[0]); EXPECT_EQ(static_cast(default_rtx_codec_.id), config.rtp.rtx.payload_type); // TODO(juberti): Check RTCP, PLI, TMMBR. @@ -1024,18 +1024,49 @@ TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFec) { } TEST_F(WebRtcVideoChannel2Test, - DISABLED_SetSendCodecRejectsRtxWithoutAssociatedPayloadType) { - FAIL() << "Not implemented."; // TODO(pbos): Implement. + SetSendCodecRejectsRtxWithoutAssociatedPayloadType) { + std::vector codecs; + cricket::VideoCodec rtx_codec(96, "rtx", 0, 0, 0, 0); + codecs.push_back(rtx_codec); + EXPECT_FALSE(channel_->SetSendCodecs(codecs)) + << "RTX codec without associated payload type should be rejected."; } TEST_F(WebRtcVideoChannel2Test, - DISABLED_SetSendCodecRejectsRtxWithoutMatchingVideoCodec) { - FAIL() << "Not implemented."; // TODO(pbos): Implement. + SetSendCodecRejectsRtxWithoutMatchingVideoCodec) { + std::vector codecs; + cricket::VideoCodec rtx_codec = + cricket::VideoCodec::CreateRtxCodec(96, kVp8Codec.id); + codecs.push_back(kVp8Codec); + codecs.push_back(rtx_codec); + ASSERT_TRUE(channel_->SetSendCodecs(codecs)); + + cricket::VideoCodec rtx_codec2 = + cricket::VideoCodec::CreateRtxCodec(96, kVp8Codec.id + 1); + codecs.pop_back(); + codecs.push_back(rtx_codec2); + EXPECT_FALSE(channel_->SetSendCodecs(codecs)) + << "RTX without matching video codec should be rejected."; } -TEST_F(WebRtcVideoChannel2Test, - DISABLED_SetCodecsWithoutFecDisablesCurrentFec) { - FAIL() << "Not implemented."; // TODO(pbos): Implement. +TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFecDisablesFec) { + std::vector codecs; + codecs.push_back(kVp8Codec); + codecs.push_back(kUlpfecCodec); + ASSERT_TRUE(channel_->SetSendCodecs(codecs)); + + FakeVideoSendStream* stream = AddSendStream(); + webrtc::VideoSendStream::Config config = stream->GetConfig(); + + EXPECT_EQ(kUlpfecCodec.id, config.rtp.fec.ulpfec_payload_type); + + codecs.pop_back(); + ASSERT_TRUE(channel_->SetSendCodecs(codecs)); + stream = fake_channel_->GetFakeCall()->GetVideoSendStreams()[0]; + ASSERT_TRUE(stream != NULL); + config = stream->GetConfig(); + EXPECT_EQ(-1, config.rtp.fec.ulpfec_payload_type) + << "SetSendCodec without FEC should disable current FEC."; } TEST_F(WebRtcVideoChannel2Test, DISABLED_SetSendCodecsChangesExistingStreams) { @@ -1189,6 +1220,10 @@ TEST_F(WebRtcVideoChannel2Test, FAIL(); // TODO(pbos): Verify that the FEC parameters are set for all codecs. } +TEST_F(WebRtcVideoChannel2Test, DISABLED_SetRecvCodecsWithoutFecDisablesFec) { + FAIL() << "Not implemented."; // TODO(pbos): Implement. +} + TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectDuplicateFecPayloads) { std::vector codecs; codecs.push_back(kVp8Codec);