Remove most usage of MediaContentDescription::as_audio()/as_video()
and unify algorithms a bit more. BUG=webrtc:15214 Change-Id: Ie9903f3e56d25b1dc026367e8ae6817275faa07b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/328442 Reviewed-by: Florent Castelli <orphis@webrtc.org> Commit-Queue: Philipp Hancke <phancke@microsoft.com> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#41244}
This commit is contained in:
parent
1a5d474825
commit
d0f0f38f72
@ -79,7 +79,7 @@ struct StreamFinder {
|
||||
} // namespace
|
||||
|
||||
void MediaChannelParametersFromMediaDescription(
|
||||
const RtpMediaContentDescription* desc,
|
||||
const MediaContentDescription* desc,
|
||||
const RtpHeaderExtensions& extensions,
|
||||
bool is_stream_active,
|
||||
MediaChannelParameters* params) {
|
||||
@ -97,7 +97,7 @@ void MediaChannelParametersFromMediaDescription(
|
||||
}
|
||||
|
||||
void RtpSendParametersFromMediaDescription(
|
||||
const RtpMediaContentDescription* desc,
|
||||
const MediaContentDescription* desc,
|
||||
webrtc::RtpExtension::Filter extensions_filter,
|
||||
SenderParameters* send_params) {
|
||||
RtpHeaderExtensions extensions =
|
||||
@ -875,7 +875,7 @@ bool VoiceChannel::SetLocalContent_w(const MediaContentDescription* content,
|
||||
|
||||
AudioReceiverParameters recv_params = last_recv_params_;
|
||||
MediaChannelParametersFromMediaDescription(
|
||||
content->as_audio(), header_extensions,
|
||||
content, header_extensions,
|
||||
webrtc::RtpTransceiverDirectionHasRecv(content->direction()),
|
||||
&recv_params);
|
||||
|
||||
@ -927,8 +927,8 @@ bool VoiceChannel::SetRemoteContent_w(const MediaContentDescription* content,
|
||||
RTC_LOG(LS_INFO) << "Setting remote voice description for " << ToString();
|
||||
|
||||
AudioSenderParameter send_params = last_send_params_;
|
||||
RtpSendParametersFromMediaDescription(content->as_audio(),
|
||||
extensions_filter(), &send_params);
|
||||
RtpSendParametersFromMediaDescription(content, extensions_filter(),
|
||||
&send_params);
|
||||
send_params.mid = mid();
|
||||
|
||||
bool parameters_applied =
|
||||
@ -1016,7 +1016,7 @@ bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content,
|
||||
VideoReceiverParameters recv_params = last_recv_params_;
|
||||
|
||||
MediaChannelParametersFromMediaDescription(
|
||||
content->as_video(), header_extensions,
|
||||
content, header_extensions,
|
||||
webrtc::RtpTransceiverDirectionHasRecv(content->direction()),
|
||||
&recv_params);
|
||||
|
||||
@ -1100,7 +1100,7 @@ bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content,
|
||||
last_send_params_ = send_params;
|
||||
}
|
||||
|
||||
if (!UpdateLocalStreams_w(content->as_video()->streams(), type, error_desc)) {
|
||||
if (!UpdateLocalStreams_w(content->streams(), type, error_desc)) {
|
||||
RTC_DCHECK(!error_desc.empty());
|
||||
return false;
|
||||
}
|
||||
@ -1128,13 +1128,11 @@ bool VideoChannel::SetRemoteContent_w(const MediaContentDescription* content,
|
||||
TRACE_EVENT0("webrtc", "VideoChannel::SetRemoteContent_w");
|
||||
RTC_LOG(LS_INFO) << "Setting remote video description for " << ToString();
|
||||
|
||||
const VideoContentDescription* video = content->as_video();
|
||||
|
||||
VideoSenderParameters send_params = last_send_params_;
|
||||
RtpSendParametersFromMediaDescription(video, extensions_filter(),
|
||||
RtpSendParametersFromMediaDescription(content, extensions_filter(),
|
||||
&send_params);
|
||||
send_params.mid = mid();
|
||||
send_params.conference_mode = video->conference_mode();
|
||||
send_params.conference_mode = content->conference_mode();
|
||||
|
||||
VideoReceiverParameters recv_params = last_recv_params_;
|
||||
|
||||
@ -1145,15 +1143,15 @@ bool VideoChannel::SetRemoteContent_w(const MediaContentDescription* content,
|
||||
// instead.
|
||||
bool needs_recv_params_update = false;
|
||||
if (type == SdpType::kAnswer || type == SdpType::kPrAnswer) {
|
||||
webrtc::flat_set<const VideoCodec*> matched_codecs;
|
||||
for (VideoCodec& recv_codec : recv_params.codecs) {
|
||||
if (absl::c_any_of(matched_codecs, [&](const VideoCodec* c) {
|
||||
webrtc::flat_set<const Codec*> matched_codecs;
|
||||
for (Codec& recv_codec : recv_params.codecs) {
|
||||
if (absl::c_any_of(matched_codecs, [&](const Codec* c) {
|
||||
return recv_codec.MatchesWithoutPacketization(*c);
|
||||
})) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::vector<const VideoCodec*> send_codecs =
|
||||
std::vector<const Codec*> send_codecs =
|
||||
FindAllMatchingCodecs(send_params.codecs, recv_codec);
|
||||
if (send_codecs.empty()) {
|
||||
continue;
|
||||
@ -1161,7 +1159,7 @@ bool VideoChannel::SetRemoteContent_w(const MediaContentDescription* content,
|
||||
|
||||
bool may_ignore_packetization = false;
|
||||
bool has_matching_packetization = false;
|
||||
for (const VideoCodec* send_codec : send_codecs) {
|
||||
for (const Codec* send_codec : send_codecs) {
|
||||
if (!send_codec->packetization.has_value() &&
|
||||
recv_codec.packetization.has_value()) {
|
||||
may_ignore_packetization = true;
|
||||
|
||||
@ -683,8 +683,8 @@ class MediaSessionDescriptionFactoryTest : public testing::Test {
|
||||
ASSERT_TRUE(vc);
|
||||
EXPECT_EQ(MediaProtocolType::kRtp, ac->type);
|
||||
EXPECT_EQ(MediaProtocolType::kRtp, vc->type);
|
||||
const AudioContentDescription* acd = ac->media_description()->as_audio();
|
||||
const VideoContentDescription* vcd = vc->media_description()->as_video();
|
||||
const MediaContentDescription* acd = ac->media_description();
|
||||
const MediaContentDescription* vcd = vc->media_description();
|
||||
EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type());
|
||||
EXPECT_THAT(acd->codecs(), ElementsAreArray(kAudioCodecsAnswer));
|
||||
EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw
|
||||
@ -781,7 +781,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioOffer) {
|
||||
ASSERT_TRUE(ac);
|
||||
EXPECT_FALSE(vc);
|
||||
EXPECT_EQ(MediaProtocolType::kRtp, ac->type);
|
||||
const AudioContentDescription* acd = ac->media_description()->as_audio();
|
||||
const MediaContentDescription* acd = ac->media_description();
|
||||
EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type());
|
||||
EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs());
|
||||
EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached.
|
||||
@ -814,7 +814,7 @@ TEST_F(MediaSessionDescriptionFactoryTest,
|
||||
ASSERT_TRUE(ac != NULL);
|
||||
ASSERT_TRUE(vc == NULL);
|
||||
EXPECT_EQ(MediaProtocolType::kRtp, ac->type);
|
||||
const AudioContentDescription* acd = ac->media_description()->as_audio();
|
||||
const MediaContentDescription* acd = ac->media_description();
|
||||
EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type());
|
||||
EXPECT_EQ(2U, acd->codecs().size());
|
||||
EXPECT_EQ("opus", acd->codecs()[0].name);
|
||||
@ -843,7 +843,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioOfferWithRedForOpus) {
|
||||
ASSERT_TRUE(ac != NULL);
|
||||
ASSERT_TRUE(vc == NULL);
|
||||
EXPECT_EQ(MediaProtocolType::kRtp, ac->type);
|
||||
const AudioContentDescription* acd = ac->media_description()->as_audio();
|
||||
const MediaContentDescription* acd = ac->media_description();
|
||||
EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type());
|
||||
EXPECT_EQ(2U, acd->codecs().size());
|
||||
EXPECT_EQ("red", acd->codecs()[0].name);
|
||||
@ -864,8 +864,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoOffer) {
|
||||
ASSERT_TRUE(vc);
|
||||
EXPECT_EQ(MediaProtocolType::kRtp, ac->type);
|
||||
EXPECT_EQ(MediaProtocolType::kRtp, vc->type);
|
||||
const AudioContentDescription* acd = ac->media_description()->as_audio();
|
||||
const VideoContentDescription* vcd = vc->media_description()->as_video();
|
||||
const MediaContentDescription* acd = ac->media_description();
|
||||
const MediaContentDescription* vcd = vc->media_description();
|
||||
EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type());
|
||||
EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs());
|
||||
EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached
|
||||
@ -1228,8 +1228,8 @@ TEST_F(MediaSessionDescriptionFactoryTest,
|
||||
const ContentInfo* vc = offer->GetContentByName("video");
|
||||
ASSERT_TRUE(ac);
|
||||
ASSERT_TRUE(vc);
|
||||
const AudioContentDescription* acd = ac->media_description()->as_audio();
|
||||
const VideoContentDescription* vcd = vc->media_description()->as_video();
|
||||
const MediaContentDescription* acd = ac->media_description();
|
||||
const MediaContentDescription* vcd = vc->media_description();
|
||||
|
||||
EXPECT_FALSE(vcd->has_ssrcs()); // No StreamParams.
|
||||
EXPECT_FALSE(acd->has_ssrcs()); // No StreamParams.
|
||||
@ -1306,7 +1306,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswer) {
|
||||
ASSERT_TRUE(ac);
|
||||
EXPECT_FALSE(vc);
|
||||
EXPECT_EQ(MediaProtocolType::kRtp, ac->type);
|
||||
const AudioContentDescription* acd = ac->media_description()->as_audio();
|
||||
const MediaContentDescription* acd = ac->media_description();
|
||||
EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type());
|
||||
EXPECT_THAT(acd->codecs(), ElementsAreArray(kAudioCodecsAnswer));
|
||||
EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached
|
||||
@ -1337,7 +1337,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswerGcm) {
|
||||
ASSERT_TRUE(ac);
|
||||
EXPECT_FALSE(vc);
|
||||
EXPECT_EQ(MediaProtocolType::kRtp, ac->type);
|
||||
const AudioContentDescription* acd = ac->media_description()->as_audio();
|
||||
const MediaContentDescription* acd = ac->media_description();
|
||||
EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type());
|
||||
EXPECT_THAT(acd->codecs(), ElementsAreArray(kAudioCodecsAnswer));
|
||||
EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached
|
||||
@ -1386,8 +1386,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswer) {
|
||||
ASSERT_TRUE(vc);
|
||||
EXPECT_EQ(MediaProtocolType::kRtp, ac->type);
|
||||
EXPECT_EQ(MediaProtocolType::kRtp, vc->type);
|
||||
const AudioContentDescription* acd = ac->media_description()->as_audio();
|
||||
const VideoContentDescription* vcd = vc->media_description()->as_video();
|
||||
const MediaContentDescription* acd = ac->media_description();
|
||||
const MediaContentDescription* vcd = vc->media_description();
|
||||
EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type());
|
||||
EXPECT_THAT(acd->codecs(), ElementsAreArray(kAudioCodecsAnswer));
|
||||
EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw
|
||||
@ -2215,8 +2215,8 @@ TEST_F(MediaSessionDescriptionFactoryTest,
|
||||
const ContentInfo* vc = answer->GetContentByName("video");
|
||||
ASSERT_TRUE(ac);
|
||||
ASSERT_TRUE(vc);
|
||||
const AudioContentDescription* acd = ac->media_description()->as_audio();
|
||||
const VideoContentDescription* vcd = vc->media_description()->as_video();
|
||||
const MediaContentDescription* acd = ac->media_description();
|
||||
const MediaContentDescription* vcd = vc->media_description();
|
||||
|
||||
EXPECT_FALSE(acd->has_ssrcs()); // No StreamParams.
|
||||
EXPECT_FALSE(vcd->has_ssrcs()); // No StreamParams.
|
||||
@ -2481,8 +2481,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoOffer) {
|
||||
const ContentInfo* vc = offer->GetContentByName("video");
|
||||
ASSERT_TRUE(ac);
|
||||
ASSERT_TRUE(vc);
|
||||
const AudioContentDescription* acd = ac->media_description()->as_audio();
|
||||
const VideoContentDescription* vcd = vc->media_description()->as_video();
|
||||
const MediaContentDescription* acd = ac->media_description();
|
||||
const MediaContentDescription* vcd = vc->media_description();
|
||||
EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type());
|
||||
EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs());
|
||||
|
||||
@ -2526,10 +2526,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoOffer) {
|
||||
vc = updated_offer->GetContentByName("video");
|
||||
ASSERT_TRUE(ac);
|
||||
ASSERT_TRUE(vc);
|
||||
const AudioContentDescription* updated_acd =
|
||||
ac->media_description()->as_audio();
|
||||
const VideoContentDescription* updated_vcd =
|
||||
vc->media_description()->as_video();
|
||||
const MediaContentDescription* updated_acd = ac->media_description();
|
||||
const MediaContentDescription* updated_vcd = vc->media_description();
|
||||
|
||||
EXPECT_EQ(acd->type(), updated_acd->type());
|
||||
EXPECT_EQ(acd->codecs(), updated_acd->codecs());
|
||||
@ -2574,7 +2572,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSimulcastVideoOffer) {
|
||||
ASSERT_TRUE(offer.get());
|
||||
const ContentInfo* vc = offer->GetContentByName("video");
|
||||
ASSERT_TRUE(vc);
|
||||
const VideoContentDescription* vcd = vc->media_description()->as_video();
|
||||
const MediaContentDescription* vcd = vc->media_description();
|
||||
|
||||
const StreamParamsVec& video_streams = vcd->streams();
|
||||
ASSERT_EQ(1U, video_streams.size());
|
||||
@ -2786,8 +2784,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoAnswer) {
|
||||
const ContentInfo* vc = answer->GetContentByName("video");
|
||||
ASSERT_TRUE(ac);
|
||||
ASSERT_TRUE(vc);
|
||||
const AudioContentDescription* acd = ac->media_description()->as_audio();
|
||||
const VideoContentDescription* vcd = vc->media_description()->as_video();
|
||||
const MediaContentDescription* acd = ac->media_description();
|
||||
const MediaContentDescription* vcd = vc->media_description();
|
||||
ASSERT_CRYPTO(acd, 1U, kDefaultSrtpCryptoSuite);
|
||||
ASSERT_CRYPTO(vcd, 1U, kDefaultSrtpCryptoSuite);
|
||||
|
||||
@ -2831,10 +2829,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoAnswer) {
|
||||
vc = updated_answer->GetContentByName("video");
|
||||
ASSERT_TRUE(ac);
|
||||
ASSERT_TRUE(vc);
|
||||
const AudioContentDescription* updated_acd =
|
||||
ac->media_description()->as_audio();
|
||||
const VideoContentDescription* updated_vcd =
|
||||
vc->media_description()->as_video();
|
||||
const MediaContentDescription* updated_acd = ac->media_description();
|
||||
const MediaContentDescription* updated_vcd = vc->media_description();
|
||||
|
||||
ASSERT_CRYPTO(updated_acd, 1U, kDefaultSrtpCryptoSuite);
|
||||
EXPECT_TRUE(CompareCryptoParams(acd->cryptos(), updated_acd->cryptos()));
|
||||
@ -3260,14 +3256,13 @@ TEST_F(MediaSessionDescriptionFactoryTest, RtxWithoutApt) {
|
||||
MediaContentDescription* media_desc =
|
||||
offer->GetContentDescriptionByName(CN_VIDEO);
|
||||
ASSERT_TRUE(media_desc);
|
||||
VideoContentDescription* desc = media_desc->as_video();
|
||||
std::vector<VideoCodec> codecs = desc->codecs();
|
||||
for (VideoCodec& codec : codecs) {
|
||||
std::vector<Codec> codecs = media_desc->codecs();
|
||||
for (Codec& codec : codecs) {
|
||||
if (absl::StartsWith(codec.name, kRtxCodecName)) {
|
||||
codec.params.clear();
|
||||
}
|
||||
}
|
||||
desc->set_codecs(codecs);
|
||||
media_desc->set_codecs(codecs);
|
||||
|
||||
std::unique_ptr<SessionDescription> answer =
|
||||
f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue();
|
||||
@ -3404,8 +3399,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateMultipleRtxSsrcs) {
|
||||
MediaContentDescription* media_desc =
|
||||
offer->GetContentDescriptionByName(CN_VIDEO);
|
||||
ASSERT_TRUE(media_desc);
|
||||
VideoContentDescription* desc = media_desc->as_video();
|
||||
const StreamParamsVec& streams = desc->streams();
|
||||
const StreamParamsVec& streams = media_desc->streams();
|
||||
// Single stream.
|
||||
ASSERT_EQ(1u, streams.size());
|
||||
// Stream should have 6 ssrcs: 3 for video, 3 for RTX.
|
||||
@ -3449,8 +3443,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, GenerateFlexfecSsrc) {
|
||||
MediaContentDescription* media_desc =
|
||||
offer->GetContentDescriptionByName(CN_VIDEO);
|
||||
ASSERT_TRUE(media_desc);
|
||||
VideoContentDescription* desc = media_desc->as_video();
|
||||
const StreamParamsVec& streams = desc->streams();
|
||||
const StreamParamsVec& streams = media_desc->streams();
|
||||
// Single stream.
|
||||
ASSERT_EQ(1u, streams.size());
|
||||
// Stream should have 2 ssrcs: 1 for video, 1 for FlexFEC.
|
||||
@ -3493,8 +3486,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateNoFlexfecSsrcs) {
|
||||
MediaContentDescription* media_desc =
|
||||
offer->GetContentDescriptionByName(CN_VIDEO);
|
||||
ASSERT_TRUE(media_desc);
|
||||
VideoContentDescription* desc = media_desc->as_video();
|
||||
const StreamParamsVec& streams = desc->streams();
|
||||
const StreamParamsVec& streams = media_desc->streams();
|
||||
// Single stream.
|
||||
ASSERT_EQ(1u, streams.size());
|
||||
// Stream should have 3 ssrcs: 3 for video, 0 for FlexFEC.
|
||||
@ -3663,12 +3655,12 @@ TEST(MediaSessionDescription, CopySessionDescription) {
|
||||
ASSERT_TRUE(ac);
|
||||
ASSERT_TRUE(vc);
|
||||
EXPECT_EQ(MediaProtocolType::kRtp, ac->type);
|
||||
const AudioContentDescription* acd_copy = ac->media_description()->as_audio();
|
||||
const MediaContentDescription* acd_copy = ac->media_description();
|
||||
EXPECT_EQ(acd->codecs(), acd_copy->codecs());
|
||||
EXPECT_EQ(1u, acd->first_ssrc());
|
||||
|
||||
EXPECT_EQ(MediaProtocolType::kRtp, vc->type);
|
||||
const VideoContentDescription* vcd_copy = vc->media_description()->as_video();
|
||||
const MediaContentDescription* vcd_copy = vc->media_description();
|
||||
EXPECT_EQ(vcd->codecs(), vcd_copy->codecs());
|
||||
EXPECT_EQ(2u, vcd->first_ssrc());
|
||||
}
|
||||
@ -3812,8 +3804,8 @@ TEST_F(MediaSessionDescriptionFactoryTest,
|
||||
ASSERT_TRUE(offer.get());
|
||||
ContentInfo* offer_content = offer->GetContentByName("audio");
|
||||
ASSERT_TRUE(offer_content);
|
||||
AudioContentDescription* offer_audio_desc =
|
||||
offer_content->media_description()->as_audio();
|
||||
MediaContentDescription* offer_audio_desc =
|
||||
offer_content->media_description();
|
||||
offer_audio_desc->set_protocol(kMediaProtocolDtlsSavpf);
|
||||
|
||||
std::unique_ptr<SessionDescription> answer =
|
||||
@ -3839,8 +3831,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestOfferDtlsSavpfCreateAnswer) {
|
||||
ASSERT_TRUE(offer.get());
|
||||
ContentInfo* offer_content = offer->GetContentByName("audio");
|
||||
ASSERT_TRUE(offer_content);
|
||||
AudioContentDescription* offer_audio_desc =
|
||||
offer_content->media_description()->as_audio();
|
||||
MediaContentDescription* offer_audio_desc =
|
||||
offer_content->media_description();
|
||||
offer_audio_desc->set_protocol(kMediaProtocolDtlsSavpf);
|
||||
|
||||
std::unique_ptr<SessionDescription> answer =
|
||||
@ -3852,8 +3844,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestOfferDtlsSavpfCreateAnswer) {
|
||||
ASSERT_TRUE(answer_content);
|
||||
ASSERT_FALSE(answer_content->rejected);
|
||||
|
||||
const AudioContentDescription* answer_audio_desc =
|
||||
answer_content->media_description()->as_audio();
|
||||
const MediaContentDescription* answer_audio_desc =
|
||||
answer_content->media_description();
|
||||
EXPECT_EQ(kMediaProtocolDtlsSavpf, answer_audio_desc->protocol());
|
||||
}
|
||||
|
||||
@ -4094,27 +4086,25 @@ TEST_F(MediaSessionDescriptionFactoryTest,
|
||||
|
||||
ASSERT_EQ(4u, offer->contents().size());
|
||||
EXPECT_FALSE(offer->contents()[0].rejected);
|
||||
const AudioContentDescription* acd =
|
||||
offer->contents()[0].media_description()->as_audio();
|
||||
const MediaContentDescription* acd = offer->contents()[0].media_description();
|
||||
ASSERT_EQ(1u, acd->streams().size());
|
||||
EXPECT_EQ(kAudioTrack1, acd->streams()[0].id);
|
||||
EXPECT_EQ(RtpTransceiverDirection::kSendRecv, acd->direction());
|
||||
|
||||
EXPECT_FALSE(offer->contents()[1].rejected);
|
||||
const VideoContentDescription* vcd =
|
||||
offer->contents()[1].media_description()->as_video();
|
||||
const MediaContentDescription* vcd = offer->contents()[1].media_description();
|
||||
ASSERT_EQ(1u, vcd->streams().size());
|
||||
EXPECT_EQ(kVideoTrack1, vcd->streams()[0].id);
|
||||
EXPECT_EQ(RtpTransceiverDirection::kSendRecv, vcd->direction());
|
||||
|
||||
EXPECT_FALSE(offer->contents()[2].rejected);
|
||||
acd = offer->contents()[2].media_description()->as_audio();
|
||||
acd = offer->contents()[2].media_description();
|
||||
ASSERT_EQ(1u, acd->streams().size());
|
||||
EXPECT_EQ(kAudioTrack2, acd->streams()[0].id);
|
||||
EXPECT_EQ(RtpTransceiverDirection::kSendRecv, acd->direction());
|
||||
|
||||
EXPECT_FALSE(offer->contents()[3].rejected);
|
||||
vcd = offer->contents()[3].media_description()->as_video();
|
||||
vcd = offer->contents()[3].media_description();
|
||||
ASSERT_EQ(1u, vcd->streams().size());
|
||||
EXPECT_EQ(kVideoTrack2, vcd->streams()[0].id);
|
||||
EXPECT_EQ(RtpTransceiverDirection::kSendRecv, vcd->direction());
|
||||
@ -4157,27 +4147,27 @@ TEST_F(MediaSessionDescriptionFactoryTest,
|
||||
|
||||
ASSERT_EQ(4u, answer->contents().size());
|
||||
EXPECT_FALSE(answer->contents()[0].rejected);
|
||||
const AudioContentDescription* acd =
|
||||
answer->contents()[0].media_description()->as_audio();
|
||||
const MediaContentDescription* acd =
|
||||
answer->contents()[0].media_description();
|
||||
ASSERT_EQ(1u, acd->streams().size());
|
||||
EXPECT_EQ(kAudioTrack1, acd->streams()[0].id);
|
||||
EXPECT_EQ(RtpTransceiverDirection::kSendRecv, acd->direction());
|
||||
|
||||
EXPECT_FALSE(answer->contents()[1].rejected);
|
||||
const VideoContentDescription* vcd =
|
||||
answer->contents()[1].media_description()->as_video();
|
||||
const MediaContentDescription* vcd =
|
||||
answer->contents()[1].media_description();
|
||||
ASSERT_EQ(1u, vcd->streams().size());
|
||||
EXPECT_EQ(kVideoTrack1, vcd->streams()[0].id);
|
||||
EXPECT_EQ(RtpTransceiverDirection::kSendRecv, vcd->direction());
|
||||
|
||||
EXPECT_FALSE(answer->contents()[2].rejected);
|
||||
acd = answer->contents()[2].media_description()->as_audio();
|
||||
acd = answer->contents()[2].media_description();
|
||||
ASSERT_EQ(1u, acd->streams().size());
|
||||
EXPECT_EQ(kAudioTrack2, acd->streams()[0].id);
|
||||
EXPECT_EQ(RtpTransceiverDirection::kSendRecv, acd->direction());
|
||||
|
||||
EXPECT_FALSE(answer->contents()[3].rejected);
|
||||
vcd = answer->contents()[3].media_description()->as_video();
|
||||
vcd = answer->contents()[3].media_description();
|
||||
ASSERT_EQ(1u, vcd->streams().size());
|
||||
EXPECT_EQ(kVideoTrack2, vcd->streams()[0].id);
|
||||
EXPECT_EQ(RtpTransceiverDirection::kSendRecv, vcd->direction());
|
||||
@ -4313,10 +4303,10 @@ TEST_F(MediaSessionDescriptionFactoryTest,
|
||||
f1_.CreateOfferOrError(opts, nullptr).MoveValue();
|
||||
ASSERT_TRUE(offer);
|
||||
ASSERT_EQ(2u, offer->contents().size());
|
||||
const VideoContentDescription* vcd1 =
|
||||
offer->contents()[0].media_description()->as_video();
|
||||
const VideoContentDescription* vcd2 =
|
||||
offer->contents()[1].media_description()->as_video();
|
||||
const MediaContentDescription* vcd1 =
|
||||
offer->contents()[0].media_description();
|
||||
const MediaContentDescription* vcd2 =
|
||||
offer->contents()[1].media_description();
|
||||
EXPECT_EQ(vcd1->codecs().size(), vcd2->codecs().size());
|
||||
ASSERT_EQ(2u, vcd1->codecs().size());
|
||||
EXPECT_EQ(vcd1->codecs()[0].name, vcd2->codecs()[0].name);
|
||||
@ -4329,8 +4319,8 @@ TEST_F(MediaSessionDescriptionFactoryTest,
|
||||
f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue();
|
||||
ASSERT_TRUE(answer);
|
||||
ASSERT_EQ(2u, answer->contents().size());
|
||||
vcd1 = answer->contents()[0].media_description()->as_video();
|
||||
vcd2 = answer->contents()[1].media_description()->as_video();
|
||||
vcd1 = answer->contents()[0].media_description();
|
||||
vcd2 = answer->contents()[1].media_description();
|
||||
EXPECT_EQ(vcd1->codecs().size(), vcd2->codecs().size());
|
||||
ASSERT_EQ(1u, vcd1->codecs().size());
|
||||
EXPECT_EQ(vcd1->codecs()[0].name, vcd2->codecs()[0].name);
|
||||
@ -4353,15 +4343,14 @@ TEST_F(MediaSessionDescriptionFactoryTest,
|
||||
std::unique_ptr<SessionDescription> offer =
|
||||
f1_.CreateOfferOrError(opts, nullptr).MoveValue();
|
||||
ASSERT_THAT(offer, NotNull());
|
||||
VideoContentDescription& video =
|
||||
*offer->contents()[0].media_description()->as_video();
|
||||
MediaContentDescription& video = *offer->contents()[0].media_description();
|
||||
video.set_codecs({vp8, vp8_raw});
|
||||
std::unique_ptr<SessionDescription> updated_offer =
|
||||
f1_.CreateOfferOrError(opts, offer.get()).MoveValue();
|
||||
ASSERT_THAT(updated_offer, NotNull());
|
||||
|
||||
VideoContentDescription& updated_video =
|
||||
*updated_offer->contents()[0].media_description()->as_video();
|
||||
MediaContentDescription& updated_video =
|
||||
*updated_offer->contents()[0].media_description();
|
||||
EXPECT_THAT(
|
||||
updated_video.codecs(),
|
||||
ElementsAre(AllOf(Field(&cricket::Codec::name, "VP8"),
|
||||
@ -4398,8 +4387,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, PacketizationIsEqual) {
|
||||
f1_.CreateOfferOrError(opts, nullptr).MoveValue();
|
||||
ASSERT_TRUE(offer);
|
||||
ASSERT_EQ(1u, offer->contents().size());
|
||||
const VideoContentDescription* vcd1 =
|
||||
offer->contents()[0].media_description()->as_video();
|
||||
const MediaContentDescription* vcd1 =
|
||||
offer->contents()[0].media_description();
|
||||
ASSERT_EQ(1u, vcd1->codecs().size());
|
||||
EXPECT_EQ(vcd1->codecs()[0].packetization, "raw");
|
||||
|
||||
@ -4408,7 +4397,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, PacketizationIsEqual) {
|
||||
f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue();
|
||||
ASSERT_TRUE(answer);
|
||||
ASSERT_EQ(1u, answer->contents().size());
|
||||
vcd1 = answer->contents()[0].media_description()->as_video();
|
||||
vcd1 = answer->contents()[0].media_description();
|
||||
ASSERT_EQ(1u, vcd1->codecs().size());
|
||||
EXPECT_EQ(vcd1->codecs()[0].packetization, "raw");
|
||||
}
|
||||
@ -4429,10 +4418,9 @@ TEST_F(MediaSessionDescriptionFactoryTest,
|
||||
f1_.CreateOfferOrError(opts, nullptr).MoveValue();
|
||||
ASSERT_TRUE(offer);
|
||||
ASSERT_EQ(2u, offer->contents().size());
|
||||
VideoContentDescription* vcd1 =
|
||||
offer->contents()[0].media_description()->as_video();
|
||||
const VideoContentDescription* vcd2 =
|
||||
offer->contents()[1].media_description()->as_video();
|
||||
MediaContentDescription* vcd1 = offer->contents()[0].media_description();
|
||||
const MediaContentDescription* vcd2 =
|
||||
offer->contents()[1].media_description();
|
||||
auto video_codecs = MAKE_VECTOR(kVideoCodecs1);
|
||||
EXPECT_EQ(video_codecs, vcd1->codecs());
|
||||
EXPECT_EQ(video_codecs, vcd2->codecs());
|
||||
@ -4443,8 +4431,8 @@ TEST_F(MediaSessionDescriptionFactoryTest,
|
||||
vcd1->set_codecs(video_codecs_reverse);
|
||||
std::unique_ptr<SessionDescription> updated_offer(
|
||||
f1_.CreateOfferOrError(opts, offer.get()).MoveValue());
|
||||
vcd1 = updated_offer->contents()[0].media_description()->as_video();
|
||||
vcd2 = updated_offer->contents()[1].media_description()->as_video();
|
||||
vcd1 = updated_offer->contents()[0].media_description();
|
||||
vcd2 = updated_offer->contents()[1].media_description();
|
||||
// The video codec preference order should be respected.
|
||||
EXPECT_EQ(video_codecs_reverse, vcd1->codecs());
|
||||
EXPECT_EQ(video_codecs, vcd2->codecs());
|
||||
@ -4466,10 +4454,9 @@ TEST_F(MediaSessionDescriptionFactoryTest,
|
||||
f1_.CreateOfferOrError(opts, nullptr).MoveValue();
|
||||
ASSERT_TRUE(offer);
|
||||
ASSERT_EQ(2u, offer->contents().size());
|
||||
VideoContentDescription* vcd1 =
|
||||
offer->contents()[0].media_description()->as_video();
|
||||
const VideoContentDescription* vcd2 =
|
||||
offer->contents()[1].media_description()->as_video();
|
||||
MediaContentDescription* vcd1 = offer->contents()[0].media_description();
|
||||
const MediaContentDescription* vcd2 =
|
||||
offer->contents()[1].media_description();
|
||||
auto video_codecs = MAKE_VECTOR(kVideoCodecs1);
|
||||
EXPECT_EQ(video_codecs, vcd1->codecs());
|
||||
EXPECT_EQ(video_codecs, vcd2->codecs());
|
||||
@ -4480,8 +4467,8 @@ TEST_F(MediaSessionDescriptionFactoryTest,
|
||||
vcd1->set_codecs(video_codecs_reverse);
|
||||
std::unique_ptr<SessionDescription> answer =
|
||||
f1_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue();
|
||||
vcd1 = answer->contents()[0].media_description()->as_video();
|
||||
vcd2 = answer->contents()[1].media_description()->as_video();
|
||||
vcd1 = answer->contents()[0].media_description();
|
||||
vcd2 = answer->contents()[1].media_description();
|
||||
// The video codec preference order should be respected.
|
||||
EXPECT_EQ(video_codecs_reverse, vcd1->codecs());
|
||||
EXPECT_EQ(video_codecs, vcd2->codecs());
|
||||
@ -4524,8 +4511,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, CreateAnswerWithLocalCodecParams) {
|
||||
std::unique_ptr<SessionDescription> offer =
|
||||
f1_.CreateOfferOrError(opts, nullptr).MoveValue();
|
||||
ASSERT_TRUE(offer);
|
||||
auto offer_acd = offer->contents()[0].media_description()->as_audio();
|
||||
auto offer_vcd = offer->contents()[1].media_description()->as_video();
|
||||
auto offer_acd = offer->contents()[0].media_description();
|
||||
auto offer_vcd = offer->contents()[1].media_description();
|
||||
std::string value;
|
||||
EXPECT_TRUE(offer_acd->codecs()[0].GetParam(audio_param_name, &value));
|
||||
EXPECT_EQ(audio_value1, value);
|
||||
@ -4535,8 +4522,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, CreateAnswerWithLocalCodecParams) {
|
||||
std::unique_ptr<SessionDescription> answer =
|
||||
f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue();
|
||||
ASSERT_TRUE(answer);
|
||||
auto answer_acd = answer->contents()[0].media_description()->as_audio();
|
||||
auto answer_vcd = answer->contents()[1].media_description()->as_video();
|
||||
auto answer_acd = answer->contents()[0].media_description();
|
||||
auto answer_vcd = answer->contents()[1].media_description();
|
||||
// Use the parameters from the local codecs.
|
||||
EXPECT_TRUE(answer_acd->codecs()[0].GetParam(audio_param_name, &value));
|
||||
EXPECT_EQ(audio_value2, value);
|
||||
@ -4581,7 +4568,7 @@ TEST_F(MediaSessionDescriptionFactoryTest,
|
||||
// Answer should have one negotiated codec with packetization-mode=1 using the
|
||||
// offered payload type.
|
||||
ASSERT_EQ(1u, answer->contents().size());
|
||||
auto answer_vcd = answer->contents()[0].media_description()->as_video();
|
||||
auto answer_vcd = answer->contents()[0].media_description();
|
||||
ASSERT_EQ(1u, answer_vcd->codecs().size());
|
||||
auto answer_codec = answer_vcd->codecs()[0];
|
||||
EXPECT_EQ(h264_pm1.id, answer_codec.id);
|
||||
@ -4640,8 +4627,8 @@ TEST_P(MediaProtocolTest, TestAudioVideoAcceptance) {
|
||||
ASSERT_TRUE(vc);
|
||||
EXPECT_FALSE(ac->rejected); // the offer is accepted
|
||||
EXPECT_FALSE(vc->rejected);
|
||||
const AudioContentDescription* acd = ac->media_description()->as_audio();
|
||||
const VideoContentDescription* vcd = vc->media_description()->as_video();
|
||||
const MediaContentDescription* acd = ac->media_description();
|
||||
const MediaContentDescription* vcd = vc->media_description();
|
||||
EXPECT_EQ(GetParam(), acd->protocol());
|
||||
EXPECT_EQ(GetParam(), vcd->protocol());
|
||||
}
|
||||
@ -4753,7 +4740,7 @@ void TestAudioCodecsOffer(RtpTransceiverDirection direction) {
|
||||
// send nor receive audio. The checks are still in place if at some point
|
||||
// we'd instead create an inactive stream.
|
||||
if (ac) {
|
||||
AudioContentDescription* acd = ac->media_description()->as_audio();
|
||||
MediaContentDescription* acd = ac->media_description();
|
||||
// sendrecv and inactive should both present lists as if the channel was
|
||||
// to be used for sending and receiving. Inactive essentially means it
|
||||
// might eventually be used anything, but we don't know more at this
|
||||
@ -4872,7 +4859,7 @@ void TestAudioCodecsAnswer(RtpTransceiverDirection offer_direction,
|
||||
// we'd instead create an inactive stream.
|
||||
if (ac) {
|
||||
ASSERT_EQ(MEDIA_TYPE_AUDIO, ac->media_description()->type());
|
||||
const AudioContentDescription* acd = ac->media_description()->as_audio();
|
||||
const MediaContentDescription* acd = ac->media_description();
|
||||
|
||||
std::vector<AudioCodec> target_codecs;
|
||||
// For offers with sendrecv or inactive, we should never reply with more
|
||||
|
||||
@ -1086,11 +1086,7 @@ void ModifyPayloadTypesAndRemoveMidExtension(
|
||||
}),
|
||||
extensions.end());
|
||||
media->set_rtp_header_extensions(extensions);
|
||||
cricket::VideoContentDescription* video = media->as_video();
|
||||
ASSERT_TRUE(video != nullptr);
|
||||
std::vector<cricket::VideoCodec> codecs = {
|
||||
cricket::CreateVideoCodec(pt++, "VP8")};
|
||||
video->set_codecs(codecs);
|
||||
media->set_codecs({cricket::CreateVideoCodec(pt++, "VP8")});
|
||||
}
|
||||
}
|
||||
|
||||
@ -3757,11 +3753,10 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan,
|
||||
// codecs.
|
||||
caller()->SetGeneratedSdpMunger([](cricket::SessionDescription* desc) {
|
||||
for (ContentInfo& content : desc->contents()) {
|
||||
cricket::AudioContentDescription* media =
|
||||
content.media_description()->as_audio();
|
||||
std::vector<cricket::AudioCodec> codecs = media->codecs();
|
||||
std::vector<cricket::AudioCodec> codecs_out;
|
||||
for (cricket::AudioCodec codec : codecs) {
|
||||
cricket::MediaContentDescription* media = content.media_description();
|
||||
std::vector<cricket::Codec> codecs = media->codecs();
|
||||
std::vector<cricket::Codec> codecs_out;
|
||||
for (cricket::Codec codec : codecs) {
|
||||
if (codec.name == "opus") {
|
||||
codec.AddFeedbackParam(cricket::FeedbackParam(
|
||||
cricket::kRtcpFbParamNack, cricket::kParamValueEmpty));
|
||||
@ -3808,11 +3803,10 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, VideoPacketLossCausesNack) {
|
||||
// codecs.
|
||||
caller()->SetGeneratedSdpMunger([](cricket::SessionDescription* desc) {
|
||||
for (ContentInfo& content : desc->contents()) {
|
||||
cricket::VideoContentDescription* media =
|
||||
content.media_description()->as_video();
|
||||
std::vector<cricket::VideoCodec> codecs = media->codecs();
|
||||
std::vector<cricket::VideoCodec> codecs_out;
|
||||
for (cricket::VideoCodec codec : codecs) {
|
||||
cricket::MediaContentDescription* media = content.media_description();
|
||||
std::vector<cricket::Codec> codecs = media->codecs();
|
||||
std::vector<cricket::Codec> codecs_out;
|
||||
for (cricket::Codec codec : codecs) {
|
||||
if (codec.name == "VP8") {
|
||||
ASSERT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam(
|
||||
cricket::kRtcpFbParamNack, cricket::kParamValueEmpty)));
|
||||
|
||||
@ -1227,8 +1227,7 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test {
|
||||
bool HasCNCodecs(const cricket::ContentInfo* content) {
|
||||
RTC_DCHECK(content);
|
||||
RTC_DCHECK(content->media_description());
|
||||
for (const cricket::AudioCodec& codec :
|
||||
content->media_description()->as_audio()->codecs()) {
|
||||
for (const cricket::Codec& codec : content->media_description()->codecs()) {
|
||||
if (codec.name == "CN") {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1638,7 +1638,6 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, SetCodecPreferencesAllAudioCodecs) {
|
||||
auto codecs = offer->description()
|
||||
->contents()[0]
|
||||
.media_description()
|
||||
->as_audio()
|
||||
->codecs();
|
||||
EXPECT_TRUE(CompareCodecs(sender_audio_codecs, codecs));
|
||||
}
|
||||
@ -1661,7 +1660,6 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan,
|
||||
auto codecs = offer->description()
|
||||
->contents()[0]
|
||||
.media_description()
|
||||
->as_audio()
|
||||
->codecs();
|
||||
EXPECT_TRUE(CompareCodecs(sender_audio_codecs, codecs));
|
||||
}
|
||||
@ -1733,7 +1731,6 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, SetCodecPreferencesAllVideoCodecs) {
|
||||
auto codecs = offer->description()
|
||||
->contents()[0]
|
||||
.media_description()
|
||||
->as_video()
|
||||
->codecs();
|
||||
EXPECT_TRUE(CompareCodecs(sender_video_codecs, codecs));
|
||||
}
|
||||
@ -1757,7 +1754,6 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan,
|
||||
auto codecs = offer->description()
|
||||
->contents()[0]
|
||||
.media_description()
|
||||
->as_video()
|
||||
->codecs();
|
||||
EXPECT_TRUE(CompareCodecs(sender_video_codecs, codecs));
|
||||
}
|
||||
@ -1786,7 +1782,6 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan,
|
||||
auto codecs = offer->description()
|
||||
->contents()[0]
|
||||
.media_description()
|
||||
->as_video()
|
||||
->codecs();
|
||||
EXPECT_TRUE(CompareCodecs(single_codec, codecs));
|
||||
}
|
||||
@ -1831,7 +1826,6 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, SetCodecPreferencesVideoWithRtx) {
|
||||
auto codecs = offer->description()
|
||||
->contents()[0]
|
||||
.media_description()
|
||||
->as_video()
|
||||
->codecs();
|
||||
|
||||
EXPECT_TRUE(CompareCodecs(video_codecs_vpx_rtx, codecs));
|
||||
@ -1878,7 +1872,6 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan,
|
||||
auto codecs = offer->description()
|
||||
->contents()[0]
|
||||
.media_description()
|
||||
->as_video()
|
||||
->codecs();
|
||||
|
||||
EXPECT_EQ(codecs.size(), 2u); // VP8, VP9
|
||||
@ -1903,7 +1896,6 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan,
|
||||
auto recv_codecs = answer->description()
|
||||
->contents()[0]
|
||||
.media_description()
|
||||
->as_video()
|
||||
->codecs();
|
||||
EXPECT_EQ(recv_codecs.size(), 1u); // VP8
|
||||
}
|
||||
@ -1951,7 +1943,6 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan,
|
||||
auto codecs = offer->description()
|
||||
->contents()[0]
|
||||
.media_description()
|
||||
->as_video()
|
||||
->codecs();
|
||||
EXPECT_EQ(codecs.size(), 2u); // VP9, VP8
|
||||
EXPECT_TRUE(CompareCodecs(video_codecs_vpx, codecs));
|
||||
@ -1966,7 +1957,6 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan,
|
||||
auto recv_codecs = answer->description()
|
||||
->contents()[0]
|
||||
.media_description()
|
||||
->as_video()
|
||||
->codecs();
|
||||
|
||||
EXPECT_TRUE(CompareCodecs(video_codecs_vpx_reverse, recv_codecs));
|
||||
|
||||
@ -984,13 +984,10 @@ TEST_P(PeerConnectionSignalingTest, ReceiveFlexFec) {
|
||||
|
||||
auto answer = caller->CreateAnswer();
|
||||
ASSERT_EQ(answer->description()->contents().size(), 1u);
|
||||
ASSERT_NE(
|
||||
answer->description()->contents()[0].media_description()->as_video(),
|
||||
nullptr);
|
||||
ASSERT_NE(answer->description()->contents()[0].media_description(), nullptr);
|
||||
auto codecs = answer->description()
|
||||
->contents()[0]
|
||||
.media_description()
|
||||
->as_video()
|
||||
->codecs();
|
||||
ASSERT_EQ(codecs.size(), 2u);
|
||||
EXPECT_EQ(codecs[1].name, "flexfec-03");
|
||||
@ -1040,13 +1037,10 @@ TEST_P(PeerConnectionSignalingTest, ReceiveFlexFecReoffer) {
|
||||
|
||||
auto answer = caller->CreateAnswer();
|
||||
ASSERT_EQ(answer->description()->contents().size(), 1u);
|
||||
ASSERT_NE(
|
||||
answer->description()->contents()[0].media_description()->as_video(),
|
||||
nullptr);
|
||||
ASSERT_NE(answer->description()->contents()[0].media_description(), nullptr);
|
||||
auto codecs = answer->description()
|
||||
->contents()[0]
|
||||
.media_description()
|
||||
->as_video()
|
||||
->codecs();
|
||||
ASSERT_EQ(codecs.size(), 2u);
|
||||
EXPECT_EQ(codecs[1].name, "flexfec-03");
|
||||
@ -1059,7 +1053,6 @@ TEST_P(PeerConnectionSignalingTest, ReceiveFlexFecReoffer) {
|
||||
auto offer_codecs = offer->description()
|
||||
->contents()[0]
|
||||
.media_description()
|
||||
->as_video()
|
||||
->codecs();
|
||||
auto flexfec_it = std::find_if(
|
||||
offer_codecs.begin(), offer_codecs.end(),
|
||||
@ -1353,7 +1346,6 @@ TEST_F(PeerConnectionSignalingUnifiedPlanTest, RtxReofferApt) {
|
||||
auto codecs = reoffer->description()
|
||||
->contents()[0]
|
||||
.media_description()
|
||||
->as_video()
|
||||
->codecs();
|
||||
ASSERT_GT(codecs.size(), 2u);
|
||||
EXPECT_EQ(codecs[0].name, "VP8");
|
||||
|
||||
@ -565,22 +565,9 @@ RTCError ValidatePayloadTypes(const cricket::SessionDescription& description) {
|
||||
continue;
|
||||
}
|
||||
const auto type = media_description->type();
|
||||
if (type == cricket::MEDIA_TYPE_AUDIO) {
|
||||
RTC_DCHECK(media_description->as_audio());
|
||||
for (const auto& codec : media_description->as_audio()->codecs()) {
|
||||
if (!cricket::UsedPayloadTypes::IsIdValid(
|
||||
codec, media_description->rtcp_mux())) {
|
||||
LOG_AND_RETURN_ERROR(
|
||||
RTCErrorType::INVALID_PARAMETER,
|
||||
"The media section with MID='" + content.mid() +
|
||||
"' used an invalid payload type " + rtc::ToString(codec.id) +
|
||||
" for codec '" + codec.name + ", rtcp-mux:" +
|
||||
(media_description->rtcp_mux() ? "enabled" : "disabled"));
|
||||
}
|
||||
}
|
||||
} else if (type == cricket::MEDIA_TYPE_VIDEO) {
|
||||
RTC_DCHECK(media_description->as_video());
|
||||
for (const auto& codec : media_description->as_video()->codecs()) {
|
||||
if (type == cricket::MEDIA_TYPE_AUDIO ||
|
||||
type == cricket::MEDIA_TYPE_VIDEO) {
|
||||
for (const auto& codec : media_description->codecs()) {
|
||||
if (!cricket::UsedPayloadTypes::IsIdValid(
|
||||
codec, media_description->rtcp_mux())) {
|
||||
LOG_AND_RETURN_ERROR(
|
||||
@ -1887,8 +1874,8 @@ RTCError SdpOfferAnswerHandler::ApplyLocalDescription(
|
||||
if (audio_content->rejected) {
|
||||
RemoveSenders(cricket::MEDIA_TYPE_AUDIO);
|
||||
} else {
|
||||
const cricket::AudioContentDescription* audio_desc =
|
||||
audio_content->media_description()->as_audio();
|
||||
const cricket::MediaContentDescription* audio_desc =
|
||||
audio_content->media_description();
|
||||
UpdateLocalSenders(audio_desc->streams(), audio_desc->type());
|
||||
}
|
||||
}
|
||||
@ -1899,8 +1886,8 @@ RTCError SdpOfferAnswerHandler::ApplyLocalDescription(
|
||||
if (video_content->rejected) {
|
||||
RemoveSenders(cricket::MEDIA_TYPE_VIDEO);
|
||||
} else {
|
||||
const cricket::VideoContentDescription* video_desc =
|
||||
video_content->media_description()->as_video();
|
||||
const cricket::MediaContentDescription* video_desc =
|
||||
video_content->media_description();
|
||||
UpdateLocalSenders(video_desc->streams(), video_desc->type());
|
||||
}
|
||||
}
|
||||
@ -5365,44 +5352,40 @@ bool SdpOfferAnswerHandler::UpdatePayloadTypeDemuxingState(
|
||||
// Ignore transceivers that are not receiving.
|
||||
continue;
|
||||
}
|
||||
switch (content_info.media_description()->type()) {
|
||||
case cricket::MediaType::MEDIA_TYPE_AUDIO: {
|
||||
if (!mid_header_extension_missing_audio) {
|
||||
mid_header_extension_missing_audio =
|
||||
!ContentHasHeaderExtension(content_info, RtpExtension::kMidUri);
|
||||
}
|
||||
const cricket::AudioContentDescription* audio_desc =
|
||||
content_info.media_description()->as_audio();
|
||||
for (const cricket::AudioCodec& audio : audio_desc->codecs()) {
|
||||
if (payload_types->audio_payload_types.count(audio.id)) {
|
||||
const cricket::MediaType media_type =
|
||||
content_info.media_description()->type();
|
||||
if (media_type == cricket::MediaType::MEDIA_TYPE_AUDIO ||
|
||||
media_type == cricket::MediaType::MEDIA_TYPE_VIDEO) {
|
||||
if (media_type == cricket::MediaType::MEDIA_TYPE_AUDIO &&
|
||||
!mid_header_extension_missing_audio) {
|
||||
mid_header_extension_missing_audio =
|
||||
!ContentHasHeaderExtension(content_info, RtpExtension::kMidUri);
|
||||
} else if (media_type == cricket::MEDIA_TYPE_VIDEO &&
|
||||
!mid_header_extension_missing_video) {
|
||||
mid_header_extension_missing_video =
|
||||
!ContentHasHeaderExtension(content_info, RtpExtension::kMidUri);
|
||||
}
|
||||
const cricket::MediaContentDescription* media_desc =
|
||||
content_info.media_description();
|
||||
for (const cricket::Codec& codec : media_desc->codecs()) {
|
||||
if (media_type == cricket::MediaType::MEDIA_TYPE_AUDIO) {
|
||||
if (payload_types->audio_payload_types.count(codec.id)) {
|
||||
// Two m= sections are using the same payload type, thus demuxing
|
||||
// by payload type is not possible.
|
||||
payload_types->pt_demuxing_possible_audio = false;
|
||||
if (media_type == cricket::MediaType::MEDIA_TYPE_AUDIO) {
|
||||
payload_types->pt_demuxing_possible_audio = false;
|
||||
}
|
||||
}
|
||||
payload_types->audio_payload_types.insert(audio.id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case cricket::MediaType::MEDIA_TYPE_VIDEO: {
|
||||
if (!mid_header_extension_missing_video) {
|
||||
mid_header_extension_missing_video =
|
||||
!ContentHasHeaderExtension(content_info, RtpExtension::kMidUri);
|
||||
}
|
||||
const cricket::VideoContentDescription* video_desc =
|
||||
content_info.media_description()->as_video();
|
||||
for (const cricket::VideoCodec& video : video_desc->codecs()) {
|
||||
if (payload_types->video_payload_types.count(video.id)) {
|
||||
payload_types->audio_payload_types.insert(codec.id);
|
||||
} else if (media_type == cricket::MEDIA_TYPE_VIDEO) {
|
||||
if (payload_types->video_payload_types.count(codec.id)) {
|
||||
// Two m= sections are using the same payload type, thus demuxing
|
||||
// by payload type is not possible.
|
||||
payload_types->pt_demuxing_possible_video = false;
|
||||
}
|
||||
payload_types->video_payload_types.insert(video.id);
|
||||
payload_types->video_payload_types.insert(codec.id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// Ignore data channels.
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -990,8 +990,7 @@ TEST_F(SdpOfferAnswerTest, SdpMungingWithInvalidPayloadTypeIsRejected) {
|
||||
|
||||
auto offer = pc->CreateOffer();
|
||||
ASSERT_EQ(offer->description()->contents().size(), 1u);
|
||||
auto* audio =
|
||||
offer->description()->contents()[0].media_description()->as_audio();
|
||||
auto* audio = offer->description()->contents()[0].media_description();
|
||||
ASSERT_GT(audio->codecs().size(), 0u);
|
||||
EXPECT_TRUE(audio->rtcp_mux());
|
||||
auto codecs = audio->codecs();
|
||||
|
||||
@ -1316,8 +1316,9 @@ class WebRtcSdpTest : public ::testing::Test {
|
||||
return video;
|
||||
}
|
||||
|
||||
template <class MCD>
|
||||
void CompareMediaContentDescription(const MCD* cd1, const MCD* cd2) {
|
||||
void CompareMediaContentDescription(
|
||||
const cricket::MediaContentDescription* cd1,
|
||||
const cricket::MediaContentDescription* cd2) {
|
||||
// type
|
||||
EXPECT_EQ(cd1->type(), cd2->type());
|
||||
|
||||
@ -1427,20 +1428,14 @@ class WebRtcSdpTest : public ::testing::Test {
|
||||
|
||||
ASSERT_EQ(IsAudioContent(&c1), IsAudioContent(&c2));
|
||||
if (IsAudioContent(&c1)) {
|
||||
const AudioContentDescription* acd1 =
|
||||
c1.media_description()->as_audio();
|
||||
const AudioContentDescription* acd2 =
|
||||
c2.media_description()->as_audio();
|
||||
CompareMediaContentDescription<AudioContentDescription>(acd1, acd2);
|
||||
CompareMediaContentDescription(c1.media_description(),
|
||||
c2.media_description());
|
||||
}
|
||||
|
||||
ASSERT_EQ(IsVideoContent(&c1), IsVideoContent(&c2));
|
||||
if (IsVideoContent(&c1)) {
|
||||
const VideoContentDescription* vcd1 =
|
||||
c1.media_description()->as_video();
|
||||
const VideoContentDescription* vcd2 =
|
||||
c2.media_description()->as_video();
|
||||
CompareMediaContentDescription<VideoContentDescription>(vcd1, vcd2);
|
||||
CompareMediaContentDescription(c1.media_description(),
|
||||
c2.media_description());
|
||||
}
|
||||
|
||||
ASSERT_EQ(IsDataContent(&c1), IsDataContent(&c2));
|
||||
@ -5015,7 +5010,7 @@ TEST_F(WebRtcSdpTest, ParseSessionLevelExtmapAttributes) {
|
||||
EXPECT_TRUE(SdpDeserialize(sdp, &jdesc));
|
||||
ASSERT_EQ(1u, jdesc.description()->contents().size());
|
||||
const auto content = jdesc.description()->contents()[0];
|
||||
const auto* audio_description = content.media_description()->as_audio();
|
||||
const auto* audio_description = content.media_description();
|
||||
ASSERT_NE(audio_description, nullptr);
|
||||
const auto& extensions = audio_description->rtp_header_extensions();
|
||||
ASSERT_EQ(1u, extensions.size());
|
||||
|
||||
@ -177,17 +177,8 @@ void ScenarioIceConnectionImpl::SetRemoteSdp(SdpType type,
|
||||
RTC_CHECK(res.ok()) << res.message();
|
||||
RtpDemuxerCriteria criteria;
|
||||
for (const auto& content : remote_description_->description()->contents()) {
|
||||
if (content.media_description()->as_audio()) {
|
||||
for (const auto& codec :
|
||||
content.media_description()->as_audio()->codecs()) {
|
||||
criteria.payload_types().insert(codec.id);
|
||||
}
|
||||
}
|
||||
if (content.media_description()->as_video()) {
|
||||
for (const auto& codec :
|
||||
content.media_description()->as_video()->codecs()) {
|
||||
criteria.payload_types().insert(codec.id);
|
||||
}
|
||||
for (const auto& codec : content.media_description()->codecs()) {
|
||||
criteria.payload_types().insert(codec.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user