diff options
Diffstat (limited to 'pc/channel_unittest.cc')
-rw-r--r-- | pc/channel_unittest.cc | 80 |
1 files changed, 27 insertions, 53 deletions
diff --git a/pc/channel_unittest.cc b/pc/channel_unittest.cc index 7d60376141..98a61ea673 100644 --- a/pc/channel_unittest.cc +++ b/pc/channel_unittest.cc @@ -62,15 +62,14 @@ using ::testing::Field; using ::webrtc::RtpTransceiverDirection; using ::webrtc::SdpType; -const cricket::AudioCodec kPcmuCodec = +const cricket::Codec kPcmuCodec = cricket::CreateAudioCodec(0, "PCMU", 64000, 1); -const cricket::AudioCodec kPcmaCodec = +const cricket::Codec kPcmaCodec = cricket::CreateAudioCodec(8, "PCMA", 64000, 1); -const cricket::AudioCodec kIsacCodec = +const cricket::Codec kIsacCodec = cricket::CreateAudioCodec(103, "ISAC", 40000, 1); -const cricket::VideoCodec kH264Codec = cricket::CreateVideoCodec(97, "H264"); -const cricket::VideoCodec kH264SvcCodec = - cricket::CreateVideoCodec(99, "H264-SVC"); +const cricket::Codec kH264Codec = cricket::CreateVideoCodec(97, "H264"); +const cricket::Codec kH264SvcCodec = cricket::CreateVideoCodec(99, "H264-SVC"); const uint32_t kSsrc1 = 0x1111; const uint32_t kSsrc2 = 0x2222; const uint32_t kSsrc3 = 0x3333; @@ -86,7 +85,6 @@ template <class ChannelT, class MediaSendChannelInterfaceT, class MediaReceiveChannelInterfaceT, class ContentT, - class CodecT, class MediaInfoT, class OptionsT> class Traits { @@ -97,7 +95,6 @@ class Traits { typedef MediaSendChannelInterfaceT MediaSendChannelInterface; typedef MediaReceiveChannelInterfaceT MediaReceiveChannelInterface; typedef ContentT Content; - typedef CodecT Codec; typedef MediaInfoT MediaInfo; typedef OptionsT Options; }; @@ -108,7 +105,6 @@ class VoiceTraits : public Traits<cricket::VoiceChannel, cricket::VoiceMediaSendChannelInterface, cricket::VoiceMediaReceiveChannelInterface, cricket::AudioContentDescription, - cricket::AudioCodec, cricket::VoiceMediaInfo, cricket::AudioOptions> {}; @@ -118,7 +114,6 @@ class VideoTraits : public Traits<cricket::VideoChannel, cricket::VideoMediaSendChannelInterface, cricket::VideoMediaReceiveChannelInterface, cricket::VideoContentDescription, - cricket::VideoCodec, cricket::VideoMediaInfo, cricket::VideoOptions> {}; @@ -507,8 +502,8 @@ class ChannelTest : public ::testing::Test, public sigslot::has_slots<> { bool CheckNoRtp2() { return media_send_channel2_impl()->CheckNoRtp(); } void CreateContent(int flags, - const cricket::AudioCodec& audio_codec, - const cricket::VideoCodec& video_codec, + const cricket::Codec& audio_codec, + const cricket::Codec& video_codec, typename T::Content* content) { // overridden in specialized classes } @@ -544,10 +539,6 @@ class ChannelTest : public ::testing::Test, public sigslot::has_slots<> { std::unique_ptr<rtc::Thread> thread_; }; - bool CodecMatches(const typename T::Codec& c1, const typename T::Codec& c2) { - return false; // overridden in specialized classes - } - cricket::CandidatePairInterface* last_selected_candidate_pair() { return last_selected_candidate_pair_; } @@ -613,8 +604,8 @@ class ChannelTest : public ::testing::Test, public sigslot::has_slots<> { EXPECT_EQ(0U, media_send_channel1_impl()->send_codecs().size()); EXPECT_TRUE(channel1_->SetRemoteContent(&content, SdpType::kAnswer, err)); ASSERT_EQ(1U, media_send_channel1_impl()->send_codecs().size()); - EXPECT_TRUE(CodecMatches(content.codecs()[0], - media_send_channel1_impl()->send_codecs()[0])); + EXPECT_EQ(content.codecs()[0], + media_send_channel1_impl()->send_codecs()[0]); } // Test that SetLocalContent and SetRemoteContent properly configure @@ -661,8 +652,8 @@ class ChannelTest : public ::testing::Test, public sigslot::has_slots<> { EXPECT_EQ(0U, media_send_channel1_impl()->send_codecs().size()); EXPECT_TRUE(channel1_->SetRemoteContent(&content, SdpType::kAnswer, err)); ASSERT_EQ(1U, media_send_channel1_impl()->send_codecs().size()); - EXPECT_TRUE(CodecMatches(content.codecs()[0], - media_send_channel1_impl()->send_codecs()[0])); + EXPECT_EQ(content.codecs()[0], + media_send_channel1_impl()->send_codecs()[0]); } // Test that SetLocalContent and SetRemoteContent properly set RTCP @@ -1562,8 +1553,8 @@ std::unique_ptr<cricket::VoiceChannel> ChannelTest<VoiceTraits>::CreateChannel( template <> void ChannelTest<VoiceTraits>::CreateContent( int flags, - const cricket::AudioCodec& audio_codec, - const cricket::VideoCodec& video_codec, + const cricket::Codec& audio_codec, + const cricket::Codec& video_codec, cricket::AudioContentDescription* audio) { audio->AddCodec(audio_codec); audio->set_rtcp_mux((flags & RTCP_MUX) != 0); @@ -1577,13 +1568,6 @@ void ChannelTest<VoiceTraits>::CopyContent( } template <> -bool ChannelTest<VoiceTraits>::CodecMatches(const cricket::AudioCodec& c1, - const cricket::AudioCodec& c2) { - return c1.name == c2.name && c1.clockrate == c2.clockrate && - c1.bitrate == c2.bitrate && c1.channels == c2.channels; -} - -template <> void ChannelTest<VoiceTraits>::AddLegacyStreamInContent( uint32_t ssrc, int flags, @@ -1649,8 +1633,8 @@ std::unique_ptr<cricket::VideoChannel> ChannelTest<VideoTraits>::CreateChannel( template <> void ChannelTest<VideoTraits>::CreateContent( int flags, - const cricket::AudioCodec& audio_codec, - const cricket::VideoCodec& video_codec, + const cricket::Codec& audio_codec, + const cricket::Codec& video_codec, cricket::VideoContentDescription* video) { video->AddCodec(video_codec); video->set_rtcp_mux((flags & RTCP_MUX) != 0); @@ -1664,12 +1648,6 @@ void ChannelTest<VideoTraits>::CopyContent( } template <> -bool ChannelTest<VideoTraits>::CodecMatches(const cricket::VideoCodec& c1, - const cricket::VideoCodec& c2) { - return c1.name == c2.name; -} - -template <> void ChannelTest<VideoTraits>::AddLegacyStreamInContent( uint32_t ssrc, int flags, @@ -2116,12 +2094,12 @@ TEST_F(VideoChannelSingleThreadTest, TestSetLocalOfferWithPacketization) { EXPECT_TRUE(channel1_->SetLocalContent(&video, SdpType::kOffer, err)); EXPECT_THAT(media_send_channel1_impl()->send_codecs(), testing::IsEmpty()); ASSERT_THAT(media_receive_channel1_impl()->recv_codecs(), testing::SizeIs(2)); - EXPECT_TRUE(media_receive_channel1_impl()->recv_codecs()[0].Matches( - kVp8Codec, &field_trials_)); + EXPECT_TRUE( + media_receive_channel1_impl()->recv_codecs()[0].Matches(kVp8Codec)); EXPECT_EQ(media_receive_channel1_impl()->recv_codecs()[0].packetization, absl::nullopt); - EXPECT_TRUE(media_receive_channel1_impl()->recv_codecs()[1].Matches( - vp9_codec, &field_trials_)); + EXPECT_TRUE( + media_receive_channel1_impl()->recv_codecs()[1].Matches(vp9_codec)); EXPECT_EQ(media_receive_channel1_impl()->recv_codecs()[1].packetization, cricket::kPacketizationParamRaw); } @@ -2140,12 +2118,10 @@ TEST_F(VideoChannelSingleThreadTest, TestSetRemoteOfferWithPacketization) { EXPECT_TRUE(err.empty()); EXPECT_THAT(media_receive_channel1_impl()->recv_codecs(), testing::IsEmpty()); ASSERT_THAT(media_send_channel1_impl()->send_codecs(), testing::SizeIs(2)); - EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[0].Matches( - kVp8Codec, &field_trials_)); + EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[0].Matches(kVp8Codec)); EXPECT_EQ(media_send_channel1_impl()->send_codecs()[0].packetization, absl::nullopt); - EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[1].Matches( - vp9_codec, &field_trials_)); + EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[1].Matches(vp9_codec)); EXPECT_EQ(media_send_channel1_impl()->send_codecs()[1].packetization, cricket::kPacketizationParamRaw); } @@ -2165,21 +2141,19 @@ TEST_F(VideoChannelSingleThreadTest, TestSetAnswerWithPacketization) { EXPECT_TRUE(channel1_->SetRemoteContent(&video, SdpType::kAnswer, err)); EXPECT_TRUE(err.empty()); ASSERT_THAT(media_receive_channel1_impl()->recv_codecs(), testing::SizeIs(2)); - EXPECT_TRUE(media_receive_channel1_impl()->recv_codecs()[0].Matches( - kVp8Codec, &field_trials_)); + EXPECT_TRUE( + media_receive_channel1_impl()->recv_codecs()[0].Matches(kVp8Codec)); EXPECT_EQ(media_receive_channel1_impl()->recv_codecs()[0].packetization, absl::nullopt); - EXPECT_TRUE(media_receive_channel1_impl()->recv_codecs()[1].Matches( - vp9_codec, &field_trials_)); + EXPECT_TRUE( + media_receive_channel1_impl()->recv_codecs()[1].Matches(vp9_codec)); EXPECT_EQ(media_receive_channel1_impl()->recv_codecs()[1].packetization, cricket::kPacketizationParamRaw); EXPECT_THAT(media_send_channel1_impl()->send_codecs(), testing::SizeIs(2)); - EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[0].Matches( - kVp8Codec, &field_trials_)); + EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[0].Matches(kVp8Codec)); EXPECT_EQ(media_send_channel1_impl()->send_codecs()[0].packetization, absl::nullopt); - EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[1].Matches( - vp9_codec, &field_trials_)); + EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[1].Matches(vp9_codec)); EXPECT_EQ(media_send_channel1_impl()->send_codecs()[1].packetization, cricket::kPacketizationParamRaw); } |