ensure webrtc connection gets closed after connection failure

This commit is contained in:
Daniel Gultsch 2020-04-18 20:57:15 +02:00
parent 7dfd47a5c4
commit c20c40a807

View file

@ -119,7 +119,6 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
private RtpContentMap responderRtpContentMap; private RtpContentMap responderRtpContentMap;
private long rtpConnectionStarted = 0; //time of 'connected' private long rtpConnectionStarted = 0; //time of 'connected'
JingleRtpConnection(JingleConnectionManager jingleConnectionManager, Id id, Jid initiator) { JingleRtpConnection(JingleConnectionManager jingleConnectionManager, Id id, Jid initiator) {
super(jingleConnectionManager, id, initiator); super(jingleConnectionManager, id, initiator);
final Conversation conversation = jingleConnectionManager.getXmppConnectionService().findOrCreateConversation( final Conversation conversation = jingleConnectionManager.getXmppConnectionService().findOrCreateConversation(
@ -847,6 +846,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
} }
private void setupWebRTC(final Set<Media> media, final List<PeerConnection.IceServer> iceServers) throws WebRTCWrapper.InitializationException { private void setupWebRTC(final Set<Media> media, final List<PeerConnection.IceServer> iceServers) throws WebRTCWrapper.InitializationException {
//TODO ensure registered with connection manager
final AppRTCAudioManager.SpeakerPhonePreference speakerPhonePreference; final AppRTCAudioManager.SpeakerPhonePreference speakerPhonePreference;
if (media.contains(Media.VIDEO)) { if (media.contains(Media.VIDEO)) {
speakerPhonePreference = AppRTCAudioManager.SpeakerPhonePreference.SPEAKER; 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); Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": not sending session-terminate after connectivity error because session is already in state " + this.state);
return; return;
} }
//we need to call close new Thread(this::closeWebRTCSessionAfterFailedConnection).start();
sendSessionTerminate(Reason.CONNECTIVITY_ERROR);
} else { } else {
updateEndUserState(); updateEndUserState();
} }
} }
private void closeWebRTCSessionAfterFailedConnection() {
this.webRTCWrapper.close();
sendSessionTerminate(Reason.CONNECTIVITY_ERROR);
}
public AppRTCAudioManager getAudioManager() { public AppRTCAudioManager getAudioManager() {
return webRTCWrapper.getAudioManager(); return webRTCWrapper.getAudioManager();
} }