Bug 1654399 - pt3 - add rollback support for RTCDtlsTransports. r=bwc

Differential Revision: https://phabricator.services.mozilla.com/D85204
This commit is contained in:
Michael Froman 2020-08-31 23:45:21 +00:00
parent 04b04a1e20
commit d587d72625
5 changed files with 39 additions and 12 deletions

View File

@ -2167,12 +2167,17 @@ void PeerConnectionImpl::OnSetDescriptionSuccess(JsepSdpType sdpType,
if (HasMedia()) {
// Section 4.4.1.5 Set the RTCSessionDescription:
// - step 4.5.9.1 when remote is false, type not rollback
// - step 4.5.9.2.13 when remote is true, type answer or pranswer
// More simply: never for rollback, and not for remote offers.
if (sdpType != mozilla::kJsepSdpRollback &&
!(remote && sdpType == mozilla::kJsepSdpOffer)) {
mMedia->UpdateRTCDtlsTransports();
if (sdpType == mozilla::kJsepSdpRollback) {
// - step 4.5.10, type is rollback
mMedia->RollbackRTCDtlsTransports();
} else if (!(remote && sdpType == mozilla::kJsepSdpOffer)) {
// - step 4.5.9 type is not rollback
// - step 4.5.9.1 when remote is false
// - step 4.5.9.2.13 when remote is true, type answer or pranswer
// More simply: not rollback, and not for remote offers.
bool markAsStable = sdpType == kJsepSdpOffer &&
mSignalingState == RTCSignalingState::Stable;
mMedia->UpdateRTCDtlsTransports(markAsStable);
}
}

View File

@ -184,7 +184,7 @@ void PeerConnectionMedia::EnsureTransports(const JsepSession& aSession) {
GatherIfReady();
}
void PeerConnectionMedia::UpdateRTCDtlsTransports() {
void PeerConnectionMedia::UpdateRTCDtlsTransports(bool aMarkAsStable) {
for (auto& transceiver : mTransceivers) {
std::string transportId = transceiver->GetTransportId();
if (transportId.empty()) {
@ -195,7 +195,14 @@ void PeerConnectionMedia::UpdateRTCDtlsTransports() {
transportId, new RTCDtlsTransport(transceiver->GetParentObject()));
}
transceiver->SetDtlsTransport(mTransportIdToRTCDtlsTransport[transportId]);
transceiver->SetDtlsTransport(mTransportIdToRTCDtlsTransport[transportId],
aMarkAsStable);
}
}
void PeerConnectionMedia::RollbackRTCDtlsTransports() {
for (auto& transceiver : mTransceivers) {
transceiver->RollbackToStableDtlsTransport();
}
}

View File

@ -58,7 +58,8 @@ class PeerConnectionMedia : public sigslot::has_slots<> {
// Ensure ICE transports exist that we might need when offer/answer concludes
void EnsureTransports(const JsepSession& aSession);
void UpdateRTCDtlsTransports();
void UpdateRTCDtlsTransports(bool aMarkAsStable);
void RollbackRTCDtlsTransports();
void RemoveRTCDtlsTransportsExcept(
const std::set<std::string>& aTransportIds);

View File

@ -39,7 +39,8 @@ MOZ_MTLOG_MODULE("transceiverimpl")
using LocalDirection = MediaSessionConduitLocalDirection;
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(TransceiverImpl, mWindow, mSendTrack,
mReceiver, mDtmf, mDtlsTransport)
mReceiver, mDtmf, mDtlsTransport,
mLastStableDtlsTransport)
NS_IMPL_CYCLE_COLLECTING_ADDREF(TransceiverImpl)
NS_IMPL_CYCLE_COLLECTING_RELEASE(TransceiverImpl)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TransceiverImpl)
@ -97,8 +98,16 @@ TransceiverImpl::TransceiverImpl(
TransceiverImpl::~TransceiverImpl() = default;
void TransceiverImpl::SetDtlsTransport(dom::RTCDtlsTransport* aDtlsTransport) {
void TransceiverImpl::SetDtlsTransport(dom::RTCDtlsTransport* aDtlsTransport,
bool aStable) {
mDtlsTransport = aDtlsTransport;
if (aStable) {
mLastStableDtlsTransport = mDtlsTransport;
}
}
void TransceiverImpl::RollbackToStableDtlsTransport() {
mDtlsTransport = mLastStableDtlsTransport;
}
void TransceiverImpl::UpdateDtlsTransportState(const std::string& aTransportId,

View File

@ -108,7 +108,8 @@ class TransceiverImpl : public nsISupports,
void UpdateDtlsTransportState(const std::string& aTransportId,
TransportLayer::State aState);
void SetDtlsTransport(dom::RTCDtlsTransport* aDtlsTransport);
void SetDtlsTransport(dom::RTCDtlsTransport* aDtlsTransport, bool aStable);
void RollbackToStableDtlsTransport();
std::string GetTransportId() const {
return mJsepTransceiver->mTransport.mTransportId;
@ -170,6 +171,10 @@ class TransceiverImpl : public nsISupports,
// an RTCDtlsTransport. They are always the same, so we'll store it
// here.
RefPtr<dom::RTCDtlsTransport> mDtlsTransport;
// The spec says both RTCRtpReceiver and RTCRtpSender have a slot for
// a last stable state RTCDtlsTransport. They are always the same, so
// we'll store it here.
RefPtr<dom::RTCDtlsTransport> mLastStableDtlsTransport;
RefPtr<dom::RTCRtpReceiver> mReceiver;
// TODO(bug 1616937): Move this to RTCRtpSender
RefPtr<dom::RTCDTMFSender> mDtmf;