terminated rtp connection do not count as busy

This commit is contained in:
Daniel Gultsch 2020-04-24 09:41:54 +02:00
parent c0036b4ca6
commit 4f5415ecba
2 changed files with 17 additions and 10 deletions

View file

@ -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);

View file

@ -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> media, final SessionDescription offer, final List<PeerConnection.IceServer> 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> media, final State targetState, final List<PeerConnection.IceServer> 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<VideoTrack> geLocalVideoTrack() {
return webRTCWrapper.getLocalVideoTrack();
}