Update SCTP status with transport whenever transport changes.

Tested with a Web Platform Test; the test added here is useful, but
does not exercise the bug.

Bug: chromium:959128
Change-Id: Ia2e7f9e015b2345dd02d341b0fe27f58b64aa81e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/135575
Reviewed-by: Guido Urdaneta <guidou@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27889}
This commit is contained in:
Harald Alvestrand 2019-05-08 20:20:59 +02:00 committed by Commit Bot
parent d7dd49ff3d
commit d61f2a726e
2 changed files with 36 additions and 9 deletions

View File

@ -5323,6 +5323,28 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan,
}
}
#ifdef HAVE_SCTP
TEST_F(PeerConnectionIntegrationTestUnifiedPlan,
EndToEndCallWithBundledSctpDataChannel) {
ASSERT_TRUE(CreatePeerConnectionWrappers());
ConnectFakeSignaling();
caller()->CreateDataChannel();
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->SetGeneratedSdpMunger(MakeSpecCompliantSctpOffer);
caller()->CreateAndSetAndSignalOffer();
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
// Ensure that media and data are multiplexed on the same DTLS transport.
// This only works on Unified Plan, because transports are not exposed in plan
// B.
auto sctp_info = caller()->pc()->GetSctpTransport()->Information();
EXPECT_EQ(sctp_info.dtls_transport(),
caller()->pc()->GetSenders()[0]->dtls_transport());
}
#endif // HAVE_SCTP
} // namespace
} // namespace webrtc

View File

@ -77,18 +77,23 @@ void SctpTransport::Clear() {
void SctpTransport::SetDtlsTransport(
rtc::scoped_refptr<DtlsTransport> transport) {
RTC_DCHECK_RUN_ON(owner_thread_);
rtc::CritScope scope(&lock_);
dtls_transport_ = transport;
if (internal_sctp_transport_) {
if (transport) {
internal_sctp_transport_->SetDtlsTransport(transport->internal());
if (info_.state() == SctpTransportState::kNew) {
UpdateInformation(SctpTransportState::kConnecting);
SctpTransportState next_state;
{
rtc::CritScope scope(&lock_);
next_state = info_.state();
dtls_transport_ = transport;
if (internal_sctp_transport_) {
if (transport) {
internal_sctp_transport_->SetDtlsTransport(transport->internal());
if (info_.state() == SctpTransportState::kNew) {
next_state = SctpTransportState::kConnecting;
}
} else {
internal_sctp_transport_->SetDtlsTransport(nullptr);
}
} else {
internal_sctp_transport_->SetDtlsTransport(nullptr);
}
}
UpdateInformation(next_state);
}
void SctpTransport::UpdateInformation(SctpTransportState state) {