diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc index 2ae2602568..7d7edd2207 100644 --- a/pc/sdp_offer_answer.cc +++ b/pc/sdp_offer_answer.cc @@ -417,14 +417,18 @@ RTCError ValidateBundledPayloadTypes( for (const cricket::ContentGroup* bundle_group : bundle_groups) { std::map payload_to_codec_parameters; for (const std::string& content_name : bundle_group->content_names()) { - const cricket::MediaContentDescription* media_description = - description.GetContentDescriptionByName(content_name); - if (!media_description) { + const ContentInfo* content_description = + description.GetContentByName(content_name); + if (!content_description) { LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, "A BUNDLE group contains a MID='" + content_name + "' matching no m= section."); } - if (!media_description->has_codecs()) { + const cricket::MediaContentDescription* media_description = + content_description->media_description(); + RTC_DCHECK(media_description); + if (content_description->rejected || !media_description || + !media_description->has_codecs()) { continue; } const auto type = media_description->type(); @@ -480,13 +484,21 @@ RTCError ValidateBundledRtpHeaderExtensions( for (const cricket::ContentGroup* bundle_group : bundle_groups) { std::map id_to_extension; for (const std::string& content_name : bundle_group->content_names()) { - const cricket::MediaContentDescription* media_description = - description.GetContentDescriptionByName(content_name); - if (!media_description) { + const ContentInfo* content_description = + description.GetContentByName(content_name); + if (!content_description) { LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, "A BUNDLE group contains a MID='" + content_name + "' matching no m= section."); } + const cricket::MediaContentDescription* media_description = + content_description->media_description(); + RTC_DCHECK(media_description); + if (content_description->rejected || !media_description || + !media_description->has_codecs()) { + continue; + } + for (const auto& extension : media_description->rtp_header_extensions()) { auto error = FindDuplicateHeaderExtensionIds(extension, id_to_extension); @@ -502,7 +514,7 @@ RTCError ValidateBundledRtpHeaderExtensions( RTCError ValidateRtpHeaderExtensionsForSpecSimulcast( const cricket::SessionDescription& description) { for (const ContentInfo& content : description.contents()) { - if (content.type != MediaProtocolType::kRtp) { + if (content.type != MediaProtocolType::kRtp || content.rejected) { continue; } const auto media_description = content.media_description(); diff --git a/pc/sdp_offer_answer_unittest.cc b/pc/sdp_offer_answer_unittest.cc index 3e250c208a..5cbf79bd50 100644 --- a/pc/sdp_offer_answer_unittest.cc +++ b/pc/sdp_offer_answer_unittest.cc @@ -165,10 +165,22 @@ TEST_F(SdpOfferAnswerTest, BundleRejectsCodecCollisionsAudioVideo) { ASSERT_NE(desc, nullptr); RTCError error; pc->SetRemoteDescription(std::move(desc), &error); + // There is no error yet but the metrics counter will increase. EXPECT_TRUE(error.ok()); EXPECT_METRIC_EQ( 1, webrtc::metrics::NumEvents( "WebRTC.PeerConnection.ValidBundledPayloadTypes", false)); + + // Tolerate codec collisions in rejected m-lines. + pc = CreatePeerConnection(); + auto rejected_offer = CreateSessionDescription( + SdpType::kOffer, + absl::StrReplaceAll(sdp, {{"m=video 9 ", "m=video 0 "}})); + pc->SetRemoteDescription(std::move(rejected_offer), &error); + EXPECT_TRUE(error.ok()); + EXPECT_METRIC_EQ(1, + webrtc::metrics::NumEvents( + "WebRTC.PeerConnection.ValidBundledPayloadTypes", true)); } TEST_F(SdpOfferAnswerTest, BundleRejectsCodecCollisionsVideoFmtp) { @@ -598,6 +610,13 @@ TEST_F(SdpOfferAnswerTest, SimulcastAnswerWithNoRidsIsRejected) { auto answer_with_extensions = CreateSessionDescription(SdpType::kAnswer, sdp + extensions); EXPECT_TRUE(pc->SetRemoteDescription(std::move(answer_with_extensions))); + + // Tolerate the lack of mid/rid extensions in rejected m-lines. + EXPECT_TRUE(pc->CreateOfferAndSetAsLocal()); + auto rejected_answer = CreateSessionDescription( + SdpType::kAnswer, + absl::StrReplaceAll(sdp, {{"m=video 9 ", "m=video 0 "}})); + EXPECT_TRUE(pc->SetRemoteDescription(std::move(rejected_answer))); } TEST_F(SdpOfferAnswerTest, ExpectAllSsrcsSpecifiedInSsrcGroupFid) {