Bug 1502899: Allow provisional transceiver level assignments to be recovered by rollback. r=jib,mjf
authorByron Campen [:bwc] <docfaraday@gmail.com>
Fri, 11 Jan 2019 22:42:20 +0000
changeset 453575 03f596ee16831b96c02c2c42d6e2efab9405f76f
parent 453574 487a0df75166e4bd2a4cc29d6a6e20c49997f1e9
child 453576 0e27ee5b44f8f576cb0f97fabaf8136cacc61786
push id35360
push usernbeleuzu@mozilla.com
push dateSat, 12 Jan 2019 09:39:47 +0000
treeherdermozilla-central@cb35977ae7a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib, mjf
bugs1502899
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1502899: Allow provisional transceiver level assignments to be recovered by rollback. r=jib,mjf Bug 1502899: Allow provisional transceiver level assignments to be recovered by rollback. Differential Revision: https://phabricator.services.mozilla.com/D10290
media/webrtc/signaling/src/jsep/JsepSessionImpl.cpp
media/webrtc/signaling/src/jsep/JsepTransceiver.h
testing/web-platform/tests/webrtc/RTCPeerConnection-setRemoteDescription-rollback.html
--- a/media/webrtc/signaling/src/jsep/JsepSessionImpl.cpp
+++ b/media/webrtc/signaling/src/jsep/JsepSessionImpl.cpp
@@ -903,22 +903,22 @@ nsresult JsepSessionImpl::SetRemoteDescr
           SdpAttribute::kIceOptionsAttribute)) {
     iceOptions = parsed->GetAttributeList().GetIceOptions().mValues;
   }
 
   // Save in case we need to rollback.
   if (type == kJsepSdpOffer) {
     mOldTransceivers.clear();
     for (const auto& transceiver : mTransceivers) {
+      mOldTransceivers.push_back(new JsepTransceiver(*transceiver));
       if (!transceiver->IsNegotiated()) {
         // We chose a level for this transceiver, but never negotiated it.
         // Discard this state.
         transceiver->ClearLevel();
       }
-      mOldTransceivers.push_back(new JsepTransceiver(*transceiver));
     }
   }
 
   // TODO(bug 1095780): Note that we create remote tracks even when
   // They contain only codecs we can't negotiate or other craziness.
   rv = UpdateTransceiversFromRemoteDescription(*parsed);
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/media/webrtc/signaling/src/jsep/JsepTransceiver.h
+++ b/media/webrtc/signaling/src/jsep/JsepTransceiver.h
@@ -52,17 +52,17 @@ class JsepTransceiver {
         mStopped(orig.mStopped),
         mRemoved(orig.mRemoved),
         mNegotiated(orig.mNegotiated) {}
 
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(JsepTransceiver);
 
   void Rollback(JsepTransceiver& oldTransceiver) {
     MOZ_ASSERT(oldTransceiver.GetMediaType() == GetMediaType());
-    MOZ_ASSERT(!oldTransceiver.HasLevel() ||
+    MOZ_ASSERT(!oldTransceiver.HasLevel() || !HasLevel() ||
                oldTransceiver.GetLevel() == GetLevel());
     mTransport = oldTransceiver.mTransport;
     mLevel = oldTransceiver.mLevel;
     mBundleLevel = oldTransceiver.mBundleLevel;
     mRecvTrack = oldTransceiver.mRecvTrack;
 
     // stop() caused by a disabled m-section in a remote offer cannot be
     // rolled back.
--- a/testing/web-platform/tests/webrtc/RTCPeerConnection-setRemoteDescription-rollback.html
+++ b/testing/web-platform/tests/webrtc/RTCPeerConnection-setRemoteDescription-rollback.html
@@ -109,9 +109,27 @@
     return generateAudioReceiveOnlyOffer(pc)
     .then(offer => pc.setRemoteDescription(offer))
     .then(() => pc.setRemoteDescription({
       type: 'rollback',
       sdp: '!<Invalid SDP Content>;'
     }));
   }, `setRemoteDescription(rollback) should ignore invalid sdp content and succeed`);
 
+  promise_test(async t => {
+    const pc1 = new RTCPeerConnection();
+    const pc2 = new RTCPeerConnection();
+    t.add_cleanup(() => pc1.close());
+    t.add_cleanup(() => pc2.close());
+
+    // We don't use this right away
+    const offer1 = await pc1.createOffer({offerToReceiveAudio: true});
+
+    // Create offer from pc2, apply and rollback on pc1
+    const offer2 = await pc2.createOffer({offerToReceiveAudio: true});
+    await pc1.setRemoteDescription(offer2);
+    await pc1.setRemoteDescription({type: "rollback"});
+
+    // Then try applying pc1's old offer
+    await pc1.setLocalDescription(offer1);
+  }, `local offer created before setRemoteDescription(remote offer) then rollback should still be usable`);
+
 </script>