properly close WebRTCWrapper even when init failed

Daniel Gultsch created

Change summary

src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java | 9 
1 file changed, 7 insertions(+), 2 deletions(-)

Detailed changes

src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java 🔗

@@ -415,7 +415,9 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
         }
         try {
             setupWebRTC(media, iceServers);
-        } catch (WebRTCWrapper.InitializationException e) {
+        } catch (final WebRTCWrapper.InitializationException e) {
+            Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": unable to initialize WebRTC");
+            webRTCWrapper.close();
             sendSessionTerminate(Reason.FAILED_APPLICATION);
             return;
         }
@@ -636,7 +638,10 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
         try {
             setupWebRTC(media, iceServers);
         } catch (WebRTCWrapper.InitializationException e) {
-            Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": unable to initialize webrtc");
+            Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": unable to initialize WebRTC");
+            webRTCWrapper.close();
+            //todo we haven’t actually initiated the session yet; so sending sessionTerminate makes no sense
+            //todo either we don’t ring ever at all or maybe we should send a retract or something
             transitionOrThrow(State.TERMINATED_APPLICATION_FAILURE);
             return;
         }