Chromium Code Reviews| Index: webrtc/media/engine/webrtcvideoengine2_unittest.cc |
| diff --git a/webrtc/media/engine/webrtcvideoengine2_unittest.cc b/webrtc/media/engine/webrtcvideoengine2_unittest.cc |
| index 19b7d644cd8942ea702158e08efef53adccf5e3f..e33a2c36ade1af8d4b0fb2e55053749948bb994a 100644 |
| --- a/webrtc/media/engine/webrtcvideoengine2_unittest.cc |
| +++ b/webrtc/media/engine/webrtcvideoengine2_unittest.cc |
| @@ -39,12 +39,14 @@ static const cricket::VideoCodec kH264Codec(102, "H264"); |
| static const cricket::VideoCodec kRedCodec(116, "red"); |
| static const cricket::VideoCodec kUlpfecCodec(117, "ulpfec"); |
| +static const cricket::VideoCodec kFlexfecCodec(118, "flexfec-03"); |
| static const uint8_t kRedRtxPayloadType = 125; |
| static const uint32_t kSsrcs1[] = {1}; |
| static const uint32_t kSsrcs3[] = {1, 2, 3}; |
| static const uint32_t kRtxSsrcs1[] = {4}; |
| +static const uint32_t kFlexfecSsrc = 5; |
| static const uint32_t kIncomingUnsignalledSsrc = 0xC0FFEE; |
| static const char kUnsupportedExtensionName[] = |
| "urn:ietf:params:rtp-hdrext:unsupported"; |
| @@ -118,6 +120,8 @@ class WebRtcVideoEngine2Test : public ::testing::Test { |
| default_red_codec_ = engine_codecs[i]; |
| } else if (engine_codecs[i].name == "ulpfec") { |
| default_ulpfec_codec_ = engine_codecs[i]; |
| + } else if (engine_codecs[i].name == "flexfec-03") { |
| + default_flexfec_codec_ = engine_codecs[i]; |
| } else if (engine_codecs[i].name == "rtx") { |
| int associated_payload_type; |
| if (engine_codecs[i].GetParam(kCodecParamAssociatedPayloadType, |
| @@ -153,6 +157,7 @@ class WebRtcVideoEngine2Test : public ::testing::Test { |
| VideoCodec default_codec_; |
| VideoCodec default_red_codec_; |
| VideoCodec default_ulpfec_codec_; |
| + VideoCodec default_flexfec_codec_; |
| std::map<int, int> default_apt_rtx_types_; |
| }; |
| @@ -1125,6 +1130,15 @@ class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test { |
| uint32_t last_ssrc_; |
| }; |
| +// TODO(brandtr): When FlexFEC is no longer behind a field trial, merge all |
| +// tests that use this test fixture into the corresponding "non-field trial" |
| +// tests. |
| +class WebRtcVideoChannel2FlexfecTest : public WebRtcVideoChannel2Test { |
|
stefan-webrtc
2016/11/17 12:48:59
Move this down to where it's used.
brandtr
2016/11/17 13:23:36
Done.
|
| + public: |
| + WebRtcVideoChannel2FlexfecTest() |
| + : WebRtcVideoChannel2Test("WebRTC-FlexFEC-03/Enabled/") {} |
| +}; |
| + |
| TEST_F(WebRtcVideoChannel2Test, SetsSyncGroupFromSyncLabel) { |
| const uint32_t kVideoSsrc = 123; |
| const std::string kSyncLabel = "AvSyncLabel"; |
| @@ -1921,7 +1935,7 @@ TEST_F(Vp9SettingsTest, VerifyVp9SpecificSettings) { |
| class Vp9SettingsTestWithFieldTrial : public Vp9SettingsTest { |
| public: |
| - Vp9SettingsTestWithFieldTrial(const char* field_trials) |
| + explicit Vp9SettingsTestWithFieldTrial(const char* field_trials) |
| : Vp9SettingsTest(field_trials) {} |
| protected: |
| @@ -2269,6 +2283,44 @@ TEST_F(WebRtcVideoChannel2Test, SetDefaultSendCodecs) { |
| // TODO(juberti): Check RTCP, PLI, TMMBR. |
| } |
| +// TODO(brandtr): Remove when FlexFEC _is_ exposed by default. |
| +TEST_F(WebRtcVideoChannel2Test, FlexfecCodecWithoutSsrcNotExposedByDefault) { |
| + FakeVideoSendStream* stream = AddSendStream(); |
| + webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); |
| + |
| + EXPECT_EQ(-1, config.rtp.flexfec.flexfec_payload_type); |
| +} |
| + |
| +// TODO(brandtr): Remove when FlexFEC _is_ exposed by default. |
| +TEST_F(WebRtcVideoChannel2Test, FlexfecCodecWithSsrcNotExposedByDefault) { |
| + FakeVideoSendStream* stream = AddSendStream( |
| + CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); |
| + webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); |
| + |
| + EXPECT_EQ(-1, config.rtp.flexfec.flexfec_payload_type); |
| +} |
| + |
| +// TODO(brandtr): Merge into "non-field trial" test when FlexFEC is enabled |
| +// by default. |
| +TEST_F(WebRtcVideoChannel2FlexfecTest, SetDefaultSendCodecsWithoutSsrc) { |
| + FakeVideoSendStream* stream = AddSendStream(); |
| + webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); |
| + |
| + EXPECT_EQ(default_flexfec_codec_.id, config.rtp.flexfec.flexfec_payload_type); |
| + EXPECT_FALSE(config.rtp.flexfec.IsValid()); |
| +} |
| + |
| +// TODO(brandtr): Merge into "non-field trial" test when FlexFEC is enabled |
| +// by default. |
| +TEST_F(WebRtcVideoChannel2FlexfecTest, SetDefaultSendCodecsWithSsrc) { |
| + FakeVideoSendStream* stream = AddSendStream( |
| + CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); |
| + webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); |
| + |
| + EXPECT_EQ(default_flexfec_codec_.id, config.rtp.flexfec.flexfec_payload_type); |
| + EXPECT_TRUE(config.rtp.flexfec.IsValid()); |
| +} |
| + |
| TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFec) { |
| cricket::VideoSendParameters parameters; |
| parameters.codecs.push_back(kVp8Codec); |
| @@ -2281,6 +2333,19 @@ TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFec) { |
| EXPECT_EQ(-1, config.rtp.ulpfec.red_payload_type); |
| } |
| +// TODO(brandtr): Merge into "non-field trial" test when FlexFEC is enabled |
| +// by default. |
| +TEST_F(WebRtcVideoChannel2FlexfecTest, SetSendCodecsWithoutFec) { |
| + cricket::VideoSendParameters parameters; |
| + parameters.codecs.push_back(kVp8Codec); |
| + ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
| + |
| + FakeVideoSendStream* stream = AddSendStream(); |
| + webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); |
| + |
| + EXPECT_EQ(-1, config.rtp.flexfec.flexfec_payload_type); |
| +} |
| + |
| TEST_F(WebRtcVideoChannel2Test, |
| SetSendCodecRejectsRtxWithoutAssociatedPayloadType) { |
| cricket::VideoSendParameters parameters; |
| @@ -2321,10 +2386,36 @@ TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFecDisablesFec) { |
| parameters.codecs.pop_back(); |
| ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
| stream = fake_call_->GetVideoSendStreams()[0]; |
| - ASSERT_TRUE(stream != NULL); |
| + ASSERT_TRUE(stream != nullptr); |
| config = stream->GetConfig().Copy(); |
| EXPECT_EQ(-1, config.rtp.ulpfec.ulpfec_payload_type) |
| - << "SetSendCodec without FEC should disable current FEC."; |
| + << "SetSendCodec without ULPFEC should disable current ULPFEC."; |
| +} |
| + |
| +// TODO(brandtr): Merge into "non-field trial" test when FlexFEC is enabled |
| +// by default. |
| +TEST_F(WebRtcVideoChannel2FlexfecTest, SetSendCodecsWithoutFecDisablesFec) { |
| + cricket::VideoSendParameters parameters; |
| + parameters.codecs.push_back(kVp8Codec); |
| + parameters.codecs.push_back(kFlexfecCodec); |
| + ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
| + |
| + FakeVideoSendStream* stream = AddSendStream( |
| + CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); |
| + webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); |
| + |
| + EXPECT_EQ(kFlexfecCodec.id, config.rtp.flexfec.flexfec_payload_type); |
| + EXPECT_EQ(kFlexfecSsrc, config.rtp.flexfec.flexfec_ssrc); |
| + ASSERT_EQ(1U, config.rtp.flexfec.protected_media_ssrcs.size()); |
| + EXPECT_EQ(kSsrcs1[0], config.rtp.flexfec.protected_media_ssrcs[0]); |
| + |
| + parameters.codecs.pop_back(); |
| + ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
| + stream = fake_call_->GetVideoSendStreams()[0]; |
| + ASSERT_TRUE(stream != nullptr); |
| + config = stream->GetConfig().Copy(); |
| + EXPECT_EQ(-1, config.rtp.flexfec.flexfec_payload_type) |
| + << "SetSendCodec without FlexFEC should disable current FlexFEC."; |
| } |
| TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) { |
| @@ -2666,9 +2757,35 @@ TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithoutFecDisablesFec) { |
| recv_parameters.codecs.push_back(kVp8Codec); |
| ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters)); |
| stream = fake_call_->GetVideoReceiveStreams()[0]; |
| - ASSERT_TRUE(stream != NULL); |
| + ASSERT_TRUE(stream != nullptr); |
| EXPECT_EQ(-1, stream->GetConfig().rtp.ulpfec.ulpfec_payload_type) |
| - << "SetSendCodec without FEC should disable current FEC."; |
| + << "SetSendCodec without ULPFEC should disable current ULPFEC."; |
| +} |
| + |
| +// TODO(brandtr): Merge into "non-field trial" test when FlexFEC is enabled |
| +// by default. |
| +TEST_F(WebRtcVideoChannel2FlexfecTest, SetRecvParamsWithoutFecDisablesFec) { |
| + cricket::VideoSendParameters send_parameters; |
| + send_parameters.codecs.push_back(kVp8Codec); |
| + send_parameters.codecs.push_back(kFlexfecCodec); |
| + ASSERT_TRUE(channel_->SetSendParameters(send_parameters)); |
| + |
| + AddRecvStream( |
| + CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); |
| + const std::vector<FakeFlexfecReceiveStream*>& streams = |
| + fake_call_->GetFlexfecReceiveStreams(); |
| + |
| + EXPECT_EQ(1U, streams.size()); |
| + EXPECT_EQ(kFlexfecCodec.id, streams[0]->GetConfig().flexfec_payload_type); |
| + EXPECT_EQ(kFlexfecSsrc, streams[0]->GetConfig().flexfec_ssrc); |
| + ASSERT_EQ(1U, streams[0]->GetConfig().protected_media_ssrcs.size()); |
| + EXPECT_EQ(kSsrcs1[0], streams[0]->GetConfig().protected_media_ssrcs[0]); |
| + |
| + cricket::VideoRecvParameters recv_parameters; |
| + recv_parameters.codecs.push_back(kVp8Codec); |
| + ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters)); |
| + EXPECT_TRUE(streams.empty()) |
| + << "SetSendCodec without FlexFEC should disable current FlexFEC."; |
| } |
| TEST_F(WebRtcVideoChannel2Test, SetSendParamsWithFecEnablesFec) { |
| @@ -2682,9 +2799,9 @@ TEST_F(WebRtcVideoChannel2Test, SetSendParamsWithFecEnablesFec) { |
| recv_parameters.codecs.push_back(kUlpfecCodec); |
| ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters)); |
| stream = fake_call_->GetVideoReceiveStreams()[0]; |
| - ASSERT_TRUE(stream != NULL); |
| + ASSERT_TRUE(stream != nullptr); |
| EXPECT_EQ(kUlpfecCodec.id, stream->GetConfig().rtp.ulpfec.ulpfec_payload_type) |
| - << "FEC should be enabled on the receive stream."; |
| + << "ULPFEC should be enabled on the receive stream."; |
| cricket::VideoSendParameters send_parameters; |
| send_parameters.codecs.push_back(kVp8Codec); |
| @@ -2693,7 +2810,35 @@ TEST_F(WebRtcVideoChannel2Test, SetSendParamsWithFecEnablesFec) { |
| ASSERT_TRUE(channel_->SetSendParameters(send_parameters)); |
| stream = fake_call_->GetVideoReceiveStreams()[0]; |
| EXPECT_EQ(kUlpfecCodec.id, stream->GetConfig().rtp.ulpfec.ulpfec_payload_type) |
| - << "FEC should be enabled on the receive stream."; |
| + << "ULPFEC should be enabled on the receive stream."; |
| +} |
| + |
| +// TODO(brandtr): Merge into "non-field trial" test when FlexFEC is enabled |
| +// by default. |
| +TEST_F(WebRtcVideoChannel2FlexfecTest, SetSendParamsWithFecEnablesFec) { |
| + AddRecvStream( |
| + CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); |
| + const std::vector<FakeFlexfecReceiveStream*>& streams = |
| + fake_call_->GetFlexfecReceiveStreams(); |
| + |
| + cricket::VideoRecvParameters recv_parameters; |
| + recv_parameters.codecs.push_back(kVp8Codec); |
| + recv_parameters.codecs.push_back(kFlexfecCodec); |
| + ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters)); |
| + EXPECT_EQ(1U, streams.size()); |
| + EXPECT_EQ(kFlexfecCodec.id, streams[0]->GetConfig().flexfec_payload_type); |
| + EXPECT_EQ(kFlexfecSsrc, streams[0]->GetConfig().flexfec_ssrc); |
| + EXPECT_EQ(1U, streams[0]->GetConfig().protected_media_ssrcs.size()); |
| + EXPECT_EQ(kSsrcs1[0], streams[0]->GetConfig().protected_media_ssrcs[0]); |
| + |
| + cricket::VideoSendParameters send_parameters; |
| + send_parameters.codecs.push_back(kVp8Codec); |
| + send_parameters.codecs.push_back(kFlexfecCodec); |
| + EXPECT_EQ(1U, streams.size()); |
| + EXPECT_EQ(kFlexfecCodec.id, streams[0]->GetConfig().flexfec_payload_type); |
| + EXPECT_EQ(kFlexfecSsrc, streams[0]->GetConfig().flexfec_ssrc); |
| + EXPECT_EQ(1U, streams[0]->GetConfig().protected_media_ssrcs.size()); |
| + EXPECT_EQ(kSsrcs1[0], streams[0]->GetConfig().protected_media_ssrcs[0]); |
| } |
| TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectDuplicateFecPayloads) { |
| @@ -2704,6 +2849,17 @@ TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectDuplicateFecPayloads) { |
| EXPECT_FALSE(channel_->SetRecvParameters(parameters)); |
| } |
| +// TODO(brandtr): Merge into "non-field trial" test when FlexFEC is enabled |
| +// by default. |
| +TEST_F(WebRtcVideoChannel2FlexfecTest, |
| + SetSendCodecsRejectDuplicateFecPayloads) { |
| + cricket::VideoRecvParameters parameters; |
| + parameters.codecs.push_back(kVp8Codec); |
| + parameters.codecs.push_back(kFlexfecCodec); |
| + parameters.codecs[1].id = parameters.codecs[0].id; |
| + EXPECT_FALSE(channel_->SetRecvParameters(parameters)); |
| +} |
| + |
| TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectDuplicateCodecPayloads) { |
| cricket::VideoRecvParameters parameters; |
| parameters.codecs.push_back(kVp8Codec); |
| @@ -3334,6 +3490,13 @@ TEST_F(WebRtcVideoChannel2Test, UlpfecPacketDoesntCreateUnsignalledStream) { |
| TestReceiveUnsignalledSsrcPacket(kDefaultUlpfecType, false); |
| } |
| +// TODO(brandtr): Change to "non-field trial" test when FlexFEC is enabled |
| +// by default. |
| +TEST_F(WebRtcVideoChannel2FlexfecTest, |
| + FlexfecPacketDoesntCreateUnsignalledStream) { |
| + TestReceiveUnsignalledSsrcPacket(kDefaultFlexfecPlType, false); |
| +} |
| + |
| TEST_F(WebRtcVideoChannel2Test, RedRtxPacketDoesntCreateUnsignalledStream) { |
| TestReceiveUnsignalledSsrcPacket(kRedRtxPayloadType, false); |
| } |
| @@ -3352,7 +3515,7 @@ TEST_F(WebRtcVideoChannel2Test, CanSentMaxBitrateForExistingStream) { |
| capturer.CaptureFrame(); |
| int default_encoder_bitrate = GetMaxEncoderBitrate(); |
| - EXPECT_TRUE(default_encoder_bitrate > 1000); |
| + EXPECT_GT(default_encoder_bitrate, 1000); |
| // TODO(skvlad): Resolve the inconsistency between the interpretation |
| // of the global bitrate limit for audio and video: |