use implicit rollback (needed to be enabled on libwebrtc)

Daniel Gultsch created

Change summary

src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java |  2 
src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java       | 26 
2 files changed, 1 insertion(+), 27 deletions(-)

Detailed changes

src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java 🔗

@@ -356,8 +356,6 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
                 //We ignore the offer and respond with tie-break. This will clause the responder not to apply the content map
                 return false;
             }
-            //rollback our own local description. should happen automatically but doesn't
-            webRTCWrapper.rollbackLocalDescription().get();
         }
         webRTCWrapper.setRemoteDescription(sdp).get();
         setRemoteContentMap(restartContentMap);

src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java 🔗

@@ -86,7 +86,6 @@ public class WebRTCWrapper {
 
     private final EventCallback eventCallback;
     private final AtomicBoolean readyToReceivedIceCandidates = new AtomicBoolean(false);
-    private final AtomicBoolean ignoreOnRenegotiationNeeded = new AtomicBoolean(false);
     private final Queue<IceCandidate> iceCandidates = new LinkedList<>();
     private final AppRTCAudioManager.AudioManagerEvents audioManagerEvents = new AppRTCAudioManager.AudioManagerEvents() {
         @Override
@@ -163,10 +162,6 @@ public class WebRTCWrapper {
 
         @Override
         public void onRenegotiationNeeded() {
-            if (ignoreOnRenegotiationNeeded.get()) {
-                Log.d(EXTENDED_LOGGING_TAG, "ignoring onRenegotiationNeeded()");
-                return;
-            }
             Log.d(EXTENDED_LOGGING_TAG, "onRenegotiationNeeded()");
             final PeerConnection.PeerConnectionState currentState = peerConnection == null ? null : peerConnection.connectionState();
             if (currentState != null && currentState != PeerConnection.PeerConnectionState.NEW) {
@@ -277,6 +272,7 @@ public class WebRTCWrapper {
         rtcConfig.continualGatheringPolicy = PeerConnection.ContinualGatheringPolicy.GATHER_CONTINUALLY;
         rtcConfig.sdpSemantics = PeerConnection.SdpSemantics.UNIFIED_PLAN;
         rtcConfig.rtcpMuxPolicy = PeerConnection.RtcpMuxPolicy.NEGOTIATE;
+        rtcConfig.enableImplicitRollback = true;
         final PeerConnection peerConnection = peerConnectionFactory.createPeerConnection(rtcConfig, peerConnectionObserver);
         if (peerConnection == null) {
             throw new InitializationException("Unable to create PeerConnection");
@@ -456,26 +452,6 @@ public class WebRTCWrapper {
         }, MoreExecutors.directExecutor());
     }
 
-    public ListenableFuture<Void> rollbackLocalDescription() {
-        final SettableFuture<Void> future = SettableFuture.create();
-        final SessionDescription rollback = new SessionDescription(SessionDescription.Type.ROLLBACK, "");
-        ignoreOnRenegotiationNeeded.set(true);
-        requirePeerConnection().setLocalDescription(new SetSdpObserver() {
-            @Override
-            public void onSetSuccess() {
-                future.set(null);
-                ignoreOnRenegotiationNeeded.set(false);
-            }
-
-            @Override
-            public void onSetFailure(final String message) {
-                future.setException(new FailureToSetDescriptionException(message));
-            }
-        }, rollback);
-        return future;
-    }
-
-
     private static void logDescription(final SessionDescription sessionDescription) {
         for (final String line : sessionDescription.description.split(eu.siacs.conversations.xmpp.jingle.SessionDescription.LINE_DIVIDER)) {
             Log.d(EXTENDED_LOGGING_TAG, line);