From 16d34c2ba06835fe339dca8a8957a136103969b6 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 17 Apr 2020 14:16:39 +0200 Subject: [PATCH] parse turns and stuns (regression from earlier commit) --- .../xmpp/jingle/JingleRtpConnection.java | 6 +++++- .../xmpp/jingle/WebRTCWrapper.java | 21 +++++++++---------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java index 64da8bc35..f47eb8f4f 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java @@ -1018,7 +1018,11 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web if (port < 0 || port > 65535) { continue; } - if (Arrays.asList("stun", "turn").contains(type) && Arrays.asList("udp", "tcp").contains(transport)) { + if (Arrays.asList("stun", "stuns", "turn", "turns").contains(type) && Arrays.asList("udp", "tcp").contains(transport)) { + if (Arrays.asList("stuns","turns").contains(type) && "udp".equals(transport)) { + Log.d(Config.LOGTAG,id.account.getJid().asBareJid()+": skipping invalid combination of udp/tls in external services"); + continue; + } //TODO wrap ipv6 addresses PeerConnection.IceServer.Builder iceServerBuilder = PeerConnection.IceServer.builder(String.format("%s:%s:%s?transport=%s", type, host, port, transport)); if (username != null && password != null) { 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 5bb05675e..28d0d8fa4 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java @@ -39,7 +39,6 @@ import org.webrtc.VideoTrack; import java.util.ArrayList; import java.util.Collections; -import java.util.Comparator; import java.util.List; import java.util.Set; @@ -146,7 +145,7 @@ public class WebRTCWrapper { private AppRTCAudioManager appRTCAudioManager = null; private Context context = null; private EglBase eglBase = null; - private Optional optionalCapturer; + private CapturerChoice capturerChoice; public WebRTCWrapper(final EventCallback eventCallback) { this.eventCallback = eventCallback; @@ -177,16 +176,16 @@ public class WebRTCWrapper { final MediaStream stream = peerConnectionFactory.createLocalMediaStream("my-media-stream"); - this.optionalCapturer = media.contains(Media.VIDEO) ? getVideoCapturer() : Optional.absent(); + final Optional optionalCapturerChoice = media.contains(Media.VIDEO) ? getVideoCapturer() : Optional.absent(); - if (this.optionalCapturer.isPresent()) { - final CapturerChoice choice = this.optionalCapturer.get(); - final CameraVideoCapturer capturer = choice.cameraVideoCapturer; + if (optionalCapturerChoice.isPresent()) { + this.capturerChoice = optionalCapturerChoice.get(); + final CameraVideoCapturer capturer = this.capturerChoice.cameraVideoCapturer; final VideoSource videoSource = peerConnectionFactory.createVideoSource(false); SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.create("webrtc", eglBase.getEglBaseContext()); capturer.initialize(surfaceTextureHelper, requireContext(), videoSource.getCapturerObserver()); - Log.d(Config.LOGTAG, String.format("start capturing at %dx%d@%d", choice.captureFormat.width, choice.captureFormat.height, choice.getFrameRate())); - capturer.startCapture(choice.captureFormat.width, choice.captureFormat.height, choice.getFrameRate()); + Log.d(Config.LOGTAG, String.format("start capturing at %dx%d@%d", capturerChoice.captureFormat.width, capturerChoice.captureFormat.height, capturerChoice.getFrameRate())); + capturer.startCapture(capturerChoice.captureFormat.width, capturerChoice.captureFormat.height, capturerChoice.getFrameRate()); this.localVideoTrack = peerConnectionFactory.createVideoTrack("my-video-track", videoSource); @@ -214,7 +213,7 @@ public class WebRTCWrapper { public void close() { final PeerConnection peerConnection = this.peerConnection; - final Optional optionalCapturer = this.optionalCapturer; + final CapturerChoice capturerChoice = this.capturerChoice; final AppRTCAudioManager audioManager = this.appRTCAudioManager; final EglBase eglBase = this.eglBase; if (peerConnection != null) { @@ -225,9 +224,9 @@ public class WebRTCWrapper { } this.localVideoTrack = null; this.remoteVideoTrack = null; - if (optionalCapturer != null && optionalCapturer.isPresent()) { + if (capturerChoice != null) { try { - optionalCapturer.get().cameraVideoCapturer.stopCapture(); + capturerChoice.cameraVideoCapturer.stopCapture(); } catch (InterruptedException e) { Log.e(Config.LOGTAG, "unable to stop capturing"); }