From 3baacf8862d22fe8b0a03d333d7c25cca1e28b63 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 16 Mar 2021 15:21:01 +0100 Subject: [PATCH] switch to unified plan --- .../xmpp/jingle/WebRTCWrapper.java | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java index 454bb7a73..640776122 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java @@ -208,6 +208,14 @@ public class WebRTCWrapper { return null; } + private static boolean isFrontFacing(final CameraEnumerator cameraEnumerator, final String deviceName) { + try { + return cameraEnumerator.isFrontFacing(deviceName); + } catch (final NullPointerException e) { + return false; + } + } + public void setup(final XmppConnectionService service, final AppRTCAudioManager.SpeakerPhonePreference speakerPhonePreference) throws InitializationException { try { PeerConnectionFactory.initialize( @@ -247,7 +255,14 @@ public class WebRTCWrapper { .createPeerConnectionFactory(); - final MediaStream stream = peerConnectionFactory.createLocalMediaStream("my-media-stream"); + final PeerConnection.RTCConfiguration rtcConfig = new PeerConnection.RTCConfiguration(iceServers); + rtcConfig.tcpCandidatePolicy = PeerConnection.TcpCandidatePolicy.DISABLED; //XEP-0176 doesn't support tcp + rtcConfig.continualGatheringPolicy = PeerConnection.ContinualGatheringPolicy.GATHER_CONTINUALLY; + rtcConfig.sdpSemantics = PeerConnection.SdpSemantics.UNIFIED_PLAN; + final PeerConnection peerConnection = peerConnectionFactory.createPeerConnection(rtcConfig, peerConnectionObserver); + if (peerConnection == null) { + throw new InitializationException("Unable to create PeerConnection"); + } final Optional optionalCapturerChoice = media.contains(Media.VIDEO) ? getVideoCapturer() : Optional.absent(); @@ -262,7 +277,7 @@ public class WebRTCWrapper { this.localVideoTrack = peerConnectionFactory.createVideoTrack("my-video-track", videoSource); - stream.addTrack(this.localVideoTrack); + peerConnection.addTrack(this.localVideoTrack); } @@ -270,18 +285,8 @@ public class WebRTCWrapper { //set up audio track final AudioSource audioSource = peerConnectionFactory.createAudioSource(new MediaConstraints()); this.localAudioTrack = peerConnectionFactory.createAudioTrack("my-audio-track", audioSource); - stream.addTrack(this.localAudioTrack); + peerConnection.addTrack(this.localAudioTrack); } - - - final PeerConnection.RTCConfiguration rtcConfig = new PeerConnection.RTCConfiguration(iceServers); - rtcConfig.tcpCandidatePolicy = PeerConnection.TcpCandidatePolicy.DISABLED; //XEP-0176 doesn't support tcp - rtcConfig.continualGatheringPolicy = PeerConnection.ContinualGatheringPolicy.GATHER_CONTINUALLY; - final PeerConnection peerConnection = peerConnectionFactory.createPeerConnection(rtcConfig, peerConnectionObserver); - if (peerConnection == null) { - throw new InitializationException("Unable to create PeerConnection"); - } - peerConnection.addStream(stream); peerConnection.setAudioPlayout(true); peerConnection.setAudioRecording(true); this.peerConnection = peerConnection; @@ -525,14 +530,6 @@ public class WebRTCWrapper { } } - private static boolean isFrontFacing(final CameraEnumerator cameraEnumerator, final String deviceName) { - try { - return cameraEnumerator.isFrontFacing(deviceName); - } catch (final NullPointerException e) { - return false; - } - } - public PeerConnection.PeerConnectionState getState() { return requirePeerConnection().connectionState(); }