From c20c40a80726a83325509c30daf0feec7ae951c2 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 18 Apr 2020 20:57:15 +0200 Subject: [PATCH] ensure webrtc connection gets closed after connection failure --- .../conversations/xmpp/jingle/JingleRtpConnection.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 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 d6e950692..1c30ee9a5 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java @@ -119,7 +119,6 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web private RtpContentMap responderRtpContentMap; private long rtpConnectionStarted = 0; //time of 'connected' - JingleRtpConnection(JingleConnectionManager jingleConnectionManager, Id id, Jid initiator) { super(jingleConnectionManager, id, initiator); final Conversation conversation = jingleConnectionManager.getXmppConnectionService().findOrCreateConversation( @@ -847,6 +846,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web } private void setupWebRTC(final Set media, final List iceServers) throws WebRTCWrapper.InitializationException { + //TODO ensure registered with connection manager final AppRTCAudioManager.SpeakerPhonePreference speakerPhonePreference; if (media.contains(Media.VIDEO)) { speakerPhonePreference = AppRTCAudioManager.SpeakerPhonePreference.SPEAKER; @@ -950,13 +950,17 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": not sending session-terminate after connectivity error because session is already in state " + this.state); return; } - //we need to call close - sendSessionTerminate(Reason.CONNECTIVITY_ERROR); + new Thread(this::closeWebRTCSessionAfterFailedConnection).start(); } else { updateEndUserState(); } } + private void closeWebRTCSessionAfterFailedConnection() { + this.webRTCWrapper.close(); + sendSessionTerminate(Reason.CONNECTIVITY_ERROR); + } + public AppRTCAudioManager getAudioManager() { return webRTCWrapper.getAudioManager(); }