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) {
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) {

View File

@ -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<CapturerChoice> 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<CapturerChoice> 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<CapturerChoice> 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");
}