From 79d8df021cbee7bff6c4114e76763535e28d92ac Mon Sep 17 00:00:00 2001 From: Philipp Hancke Date: Mon, 21 Sep 2020 20:12:08 +0200 Subject: [PATCH] android: add rollback RTCSdpType MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BUG=webrtc:11796,webrtc:11970 Change-Id: I0047c7a050c344ef58735d9d0d6534b1ddf6c4d6 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/184263 Reviewed-by: Taylor Reviewed-by: Sami Kalliomäki Commit-Queue: Philipp Hancke Cr-Commit-Position: refs/heads/master@{#32243} --- .../api/org/webrtc/SessionDescription.java | 3 +- .../webrtc/PeerConnectionEndToEndTest.java | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/sdk/android/api/org/webrtc/SessionDescription.java b/sdk/android/api/org/webrtc/SessionDescription.java index 62601f0bf2..be89599a5f 100644 --- a/sdk/android/api/org/webrtc/SessionDescription.java +++ b/sdk/android/api/org/webrtc/SessionDescription.java @@ -22,7 +22,8 @@ public class SessionDescription { public static enum Type { OFFER, PRANSWER, - ANSWER; + ANSWER, + ROLLBACK; public String canonicalForm() { return name().toLowerCase(Locale.US); diff --git a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionEndToEndTest.java b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionEndToEndTest.java index 88be833504..c380310b83 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionEndToEndTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionEndToEndTest.java @@ -1488,6 +1488,38 @@ public class PeerConnectionEndToEndTest { factory.dispose(); } + @Test + @SmallTest + public void testRollback() throws Exception { + PeerConnectionFactory factory = PeerConnectionFactory.builder().createPeerConnectionFactory(); + PeerConnection.RTCConfiguration config = new PeerConnection.RTCConfiguration(Arrays.asList()); + config.sdpSemantics = PeerConnection.SdpSemantics.UNIFIED_PLAN; + + ObserverExpectations offeringExpectations = new ObserverExpectations("PCTest:offerer"); + PeerConnection pc = factory.createPeerConnection(config, offeringExpectations); + + SdpObserverLatch sdpLatch = new SdpObserverLatch(); + pc.createOffer(sdpLatch, new MediaConstraints()); + assertTrue(sdpLatch.await()); + SessionDescription offer = sdpLatch.getSdp(); + + sdpLatch = new SdpObserverLatch(); + offeringExpectations.expectSignalingChange(SignalingState.HAVE_LOCAL_OFFER); + pc.setLocalDescription(sdpLatch, offer); + assertTrue(sdpLatch.await()); + + SessionDescription rollback = new SessionDescription(SessionDescription.Type.ROLLBACK, ""); + sdpLatch = new SdpObserverLatch(); + offeringExpectations.expectSignalingChange(SignalingState.STABLE); + // TODO(bugs.webrtc.org/11970): determine if triggering ONN (twice even) is correct. + offeringExpectations.expectRenegotiationNeeded(); + offeringExpectations.expectRenegotiationNeeded(); + pc.setLocalDescription(sdpLatch, rollback); + assertTrue(sdpLatch.await()); + + assertTrue(offeringExpectations.waitForAllExpectationsToBeSatisfied(DEFAULT_TIMEOUT_SECONDS)); + } + private static void negotiate(PeerConnection offeringPC, ObserverExpectations offeringExpectations, PeerConnection answeringPC, ObserverExpectations answeringExpectations) {