parse turns and stuns (regression from earlier commit)

This commit is contained in:
Daniel Gultsch 2020-04-17 14:16:39 +02:00
parent ab2681640a
commit 16d34c2ba0
2 changed files with 15 additions and 12 deletions

View file

@ -1018,7 +1018,11 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
if (port < 0 || port > 65535) { if (port < 0 || port > 65535) {
continue; 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 //TODO wrap ipv6 addresses
PeerConnection.IceServer.Builder iceServerBuilder = PeerConnection.IceServer.builder(String.format("%s:%s:%s?transport=%s", type, host, port, transport)); PeerConnection.IceServer.Builder iceServerBuilder = PeerConnection.IceServer.builder(String.format("%s:%s:%s?transport=%s", type, host, port, transport));
if (username != null && password != null) { if (username != null && password != null) {

View file

@ -39,7 +39,6 @@ import org.webrtc.VideoTrack;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -146,7 +145,7 @@ public class WebRTCWrapper {
private AppRTCAudioManager appRTCAudioManager = null; private AppRTCAudioManager appRTCAudioManager = null;
private Context context = null; private Context context = null;
private EglBase eglBase = null; private EglBase eglBase = null;
private Optional<CapturerChoice> optionalCapturer; private CapturerChoice capturerChoice;
public WebRTCWrapper(final EventCallback eventCallback) { public WebRTCWrapper(final EventCallback eventCallback) {
this.eventCallback = eventCallback; this.eventCallback = eventCallback;
@ -177,16 +176,16 @@ public class WebRTCWrapper {
final MediaStream stream = peerConnectionFactory.createLocalMediaStream("my-media-stream"); final MediaStream stream = peerConnectionFactory.createLocalMediaStream("my-media-stream");
this.optionalCapturer = media.contains(Media.VIDEO) ? getVideoCapturer() : Optional.absent(); final Optional<CapturerChoice> optionalCapturerChoice = media.contains(Media.VIDEO) ? getVideoCapturer() : Optional.absent();
if (this.optionalCapturer.isPresent()) { if (optionalCapturerChoice.isPresent()) {
final CapturerChoice choice = this.optionalCapturer.get(); this.capturerChoice = optionalCapturerChoice.get();
final CameraVideoCapturer capturer = choice.cameraVideoCapturer; final CameraVideoCapturer capturer = this.capturerChoice.cameraVideoCapturer;
final VideoSource videoSource = peerConnectionFactory.createVideoSource(false); final VideoSource videoSource = peerConnectionFactory.createVideoSource(false);
SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.create("webrtc", eglBase.getEglBaseContext()); SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.create("webrtc", eglBase.getEglBaseContext());
capturer.initialize(surfaceTextureHelper, requireContext(), videoSource.getCapturerObserver()); 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())); Log.d(Config.LOGTAG, String.format("start capturing at %dx%d@%d", capturerChoice.captureFormat.width, capturerChoice.captureFormat.height, capturerChoice.getFrameRate()));
capturer.startCapture(choice.captureFormat.width, choice.captureFormat.height, choice.getFrameRate()); capturer.startCapture(capturerChoice.captureFormat.width, capturerChoice.captureFormat.height, capturerChoice.getFrameRate());
this.localVideoTrack = peerConnectionFactory.createVideoTrack("my-video-track", videoSource); this.localVideoTrack = peerConnectionFactory.createVideoTrack("my-video-track", videoSource);
@ -214,7 +213,7 @@ public class WebRTCWrapper {
public void close() { public void close() {
final PeerConnection peerConnection = this.peerConnection; final PeerConnection peerConnection = this.peerConnection;
final Optional<CapturerChoice> optionalCapturer = this.optionalCapturer; final CapturerChoice capturerChoice = this.capturerChoice;
final AppRTCAudioManager audioManager = this.appRTCAudioManager; final AppRTCAudioManager audioManager = this.appRTCAudioManager;
final EglBase eglBase = this.eglBase; final EglBase eglBase = this.eglBase;
if (peerConnection != null) { if (peerConnection != null) {
@ -225,9 +224,9 @@ public class WebRTCWrapper {
} }
this.localVideoTrack = null; this.localVideoTrack = null;
this.remoteVideoTrack = null; this.remoteVideoTrack = null;
if (optionalCapturer != null && optionalCapturer.isPresent()) { if (capturerChoice != null) {
try { try {
optionalCapturer.get().cameraVideoCapturer.stopCapture(); capturerChoice.cameraVideoCapturer.stopCapture();
} catch (InterruptedException e) { } catch (InterruptedException e) {
Log.e(Config.LOGTAG, "unable to stop capturing"); Log.e(Config.LOGTAG, "unable to stop capturing");
} }