Don't crash when renegotiating after the peer rejects data channels
Bug: webrtc:11320 Change-Id: I5a58d550574a4e0702fc6f05b7fb663fbc23d0b4 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168200 Commit-Queue: Steve Anton <steveanton@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30463}
This commit is contained in:
parent
cf2b382322
commit
c8ff1600d3
@ -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)) {
|
||||
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user