From 4f5415ecbae26f9aa52c08c84720ab8fd5cb62d6 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 24 Apr 2020 09:41:54 +0200 Subject: [PATCH] terminated rtp connection do not count as busy --- .../xmpp/jingle/JingleConnectionManager.java | 7 +++++-- .../xmpp/jingle/JingleRtpConnection.java | 20 +++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java index eff4f7edb..4c410a5be 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java @@ -122,6 +122,9 @@ public class JingleConnectionManager extends AbstractConnectionManager { public boolean isBusy() { for (AbstractJingleConnection connection : this.connections.values()) { if (connection instanceof JingleRtpConnection) { + if (((JingleRtpConnection) connection).isTerminated()) { + continue; + } return true; } } @@ -139,11 +142,11 @@ public class JingleConnectionManager extends AbstractConnectionManager { return !contact.showInContactList(); } - public ScheduledFuture schedule(final Runnable runnable, final long delay, final TimeUnit timeUnit) { + ScheduledFuture schedule(final Runnable runnable, final long delay, final TimeUnit timeUnit) { return this.scheduledExecutorService.schedule(runnable, delay, timeUnit); } - public void respondWithJingleError(final Account account, final IqPacket original, String jingleCondition, String condition, String conditionType) { + void respondWithJingleError(final Account account, final IqPacket original, String jingleCondition, String condition, String conditionType) { final IqPacket response = original.generateResponse(IqPacket.TYPE.ERROR); final Element error = response.addChild("error"); error.setAttribute("type", conditionType); 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 aaa77a937..0052228b1 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java @@ -185,7 +185,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web @Override synchronized void notifyRebound() { - if (TERMINATED.contains(this.state)) { + if (isTerminated()) { return; } webRTCWrapper.close(); @@ -398,7 +398,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web } private synchronized void sendSessionAccept(final Set media, final SessionDescription offer, final List iceServers) { - if (TERMINATED.contains(this.state)) { + if (isTerminated()) { Log.w(Config.LOGTAG, id.account.getJid().asBareJid() + ": ICE servers got discovered when session was already terminated. nothing to do."); return; } @@ -617,7 +617,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web } private synchronized void sendSessionInitiate(final Set media, final State targetState, final List iceServers) { - if (TERMINATED.contains(this.state)) { + if (isTerminated()) { Log.w(Config.LOGTAG, id.account.getJid().asBareJid() + ": ICE servers got discovered when session was already terminated. nothing to do."); return; } @@ -689,7 +689,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web if (response.getType() == IqPacket.TYPE.ERROR) { final String errorCondition = response.getErrorCondition(); Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": received IQ-error from " + response.getFrom() + " in RTP session. " + errorCondition); - if (TERMINATED.contains(this.state)) { + if (isTerminated()) { Log.i(Config.LOGTAG, id.account.getJid().asBareJid() + ": ignoring error because session was already terminated"); return; } @@ -709,7 +709,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web this.finish(); } else if (response.getType() == IqPacket.TYPE.TIMEOUT) { Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": received IQ timeout in RTP session with " + id.with + ". terminating with connectivity error"); - if (TERMINATED.contains(this.state)) { + if (isTerminated()) { Log.i(Config.LOGTAG, id.account.getJid().asBareJid() + ": ignoring error because session was already terminated"); return; } @@ -839,7 +839,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web } public synchronized void endCall() { - if (TERMINATED.contains(this.state)) { + if (isTerminated()) { Log.w(Config.LOGTAG, id.account.getJid().asBareJid() + ": received endCall() when session has already been terminated. nothing to do"); return; } @@ -977,7 +977,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web //TODO exact syntax is yet to be determined but transport-replace sounds like the most reasonable //as there is no content-replace if (Arrays.asList(PeerConnection.PeerConnectionState.FAILED, PeerConnection.PeerConnectionState.DISCONNECTED).contains(newState)) { - if (TERMINATED.contains(this.state)) { + if (isTerminated()) { Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": not sending session-terminate after connectivity error because session is already in state " + this.state); return; } @@ -990,7 +990,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web private void closeWebRTCSessionAfterFailedConnection() { this.webRTCWrapper.close(); synchronized (this) { - if (TERMINATED.contains(state)) { + if (isTerminated()) { Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": no need to send session-terminate after failed connection. Other party already did"); return; } @@ -1136,6 +1136,10 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web return this.state; } + public boolean isTerminated() { + return TERMINATED.contains(this.state); + } + public Optional geLocalVideoTrack() { return webRTCWrapper.getLocalVideoTrack(); }