diff --git a/pc/media_session.cc b/pc/media_session.cc index e764101eef..5f0c1ff1e5 100644 --- a/pc/media_session.cc +++ b/pc/media_session.cc @@ -2255,7 +2255,7 @@ bool MediaSessionDescriptionFactory::AddSctpDataContentForOffer( } desc->AddContent(media_description_options.mid, MediaProtocolType::kSctp, - std::move(data)); + media_description_options.stopped, std::move(data)); if (!AddTransportOffer(media_description_options.mid, media_description_options.transport_options, current_description, desc, ice_credentials)) { diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc index 5ace3e33e4..2e138c4248 100644 --- a/pc/peer_connection.cc +++ b/pc/peer_connection.cc @@ -5128,13 +5128,18 @@ void PeerConnection::GetOptionsForUnifiedPlanOffer( } } else { RTC_CHECK_EQ(cricket::MEDIA_TYPE_DATA, media_type); - RTC_CHECK(GetDataMid()); - if (had_been_rejected || mid != *GetDataMid()) { + if (had_been_rejected) { session_options->media_description_options.push_back( GetMediaDescriptionOptionsForRejectedData(mid)); } else { - session_options->media_description_options.push_back( - GetMediaDescriptionOptionsForActiveData(mid)); + RTC_CHECK(GetDataMid()); + if (mid == *GetDataMid()) { + session_options->media_description_options.push_back( + GetMediaDescriptionOptionsForActiveData(mid)); + } else { + session_options->media_description_options.push_back( + GetMediaDescriptionOptionsForRejectedData(mid)); + } } } } diff --git a/pc/peer_connection_data_channel_unittest.cc b/pc/peer_connection_data_channel_unittest.cc index 61c669b3ed..0a674f462b 100644 --- a/pc/peer_connection_data_channel_unittest.cc +++ b/pc/peer_connection_data_channel_unittest.cc @@ -212,6 +212,13 @@ class PeerConnectionDataChannelTest : PeerConnectionDataChannelBaseTest(GetParam()) {} }; +class PeerConnectionDataChannelUnifiedPlanTest + : public PeerConnectionDataChannelBaseTest { + protected: + PeerConnectionDataChannelUnifiedPlanTest() + : PeerConnectionDataChannelBaseTest(SdpSemantics::kUnifiedPlan) {} +}; + TEST_P(PeerConnectionDataChannelTest, NoSctpTransportCreatedIfRtpDataChannelEnabled) { RTCConfiguration config; @@ -411,4 +418,28 @@ INSTANTIATE_TEST_SUITE_P(PeerConnectionDataChannelTest, Values(SdpSemantics::kPlanB, SdpSemantics::kUnifiedPlan)); +TEST_F(PeerConnectionDataChannelUnifiedPlanTest, + ReOfferAfterPeerRejectsDataChannel) { + auto caller = CreatePeerConnectionWithDataChannel(); + PeerConnectionFactoryInterface::Options options; + options.disable_sctp_data_channels = true; + auto callee = CreatePeerConnection(RTCConfiguration(), options); + + ASSERT_TRUE(caller->ExchangeOfferAnswerWith(callee.get())); + + auto offer = caller->CreateOffer(); + ASSERT_TRUE(offer); + const auto& contents = offer->description()->contents(); + ASSERT_EQ(1u, contents.size()); + EXPECT_TRUE(contents[0].rejected); + + ASSERT_TRUE( + caller->SetLocalDescription(CloneSessionDescription(offer.get()))); + ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); + + auto answer = callee->CreateAnswerAndSetAsLocal(); + ASSERT_TRUE(answer); + EXPECT_TRUE(caller->SetRemoteDescription(std::move(answer))); +} + } // namespace webrtc