add timeout to ICE gathering
This commit is contained in:
parent
5728cf13ea
commit
c72a86a0a4
|
@ -1528,11 +1528,10 @@ public class JingleRtpConnection extends AbstractJingleConnection
|
||||||
+ candidates.size()
|
+ candidates.size()
|
||||||
+ " candidates in session accept");
|
+ " candidates in session accept");
|
||||||
sendSessionAccept(outgoingContentMap.withCandidates(candidates));
|
sendSessionAccept(outgoingContentMap.withCandidates(candidates));
|
||||||
webRTCWrapper.resetPendingCandidates();
|
|
||||||
} else {
|
} else {
|
||||||
sendSessionAccept(outgoingContentMap);
|
sendSessionAccept(outgoingContentMap);
|
||||||
webRTCWrapper.setIsReadyToReceiveIceCandidates(true);
|
|
||||||
}
|
}
|
||||||
|
webRTCWrapper.setIsReadyToReceiveIceCandidates(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1994,11 +1993,10 @@ public class JingleRtpConnection extends AbstractJingleConnection
|
||||||
+ " candidates in session initiate");
|
+ " candidates in session initiate");
|
||||||
sendSessionInitiate(
|
sendSessionInitiate(
|
||||||
outgoingContentMap.withCandidates(candidates), targetState);
|
outgoingContentMap.withCandidates(candidates), targetState);
|
||||||
webRTCWrapper.resetPendingCandidates();
|
|
||||||
} else {
|
} else {
|
||||||
sendSessionInitiate(outgoingContentMap, targetState);
|
sendSessionInitiate(outgoingContentMap, targetState);
|
||||||
webRTCWrapper.setIsReadyToReceiveIceCandidates(true);
|
|
||||||
}
|
}
|
||||||
|
webRTCWrapper.setIsReadyToReceiveIceCandidates(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -44,6 +44,8 @@ import java.util.Queue;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
@ -456,11 +458,6 @@ public class WebRTCWrapper {
|
||||||
"setIsReadyToReceiveCandidates(" + ready + ") was=" + was + " is=" + is);
|
"setIsReadyToReceiveCandidates(" + ready + ") was=" + was + " is=" + is);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetPendingCandidates() {
|
|
||||||
this.readyToReceivedIceCandidates.set(true);
|
|
||||||
this.iceCandidates.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized void close() {
|
synchronized void close() {
|
||||||
final PeerConnection peerConnection = this.peerConnection;
|
final PeerConnection peerConnection = this.peerConnection;
|
||||||
final PeerConnectionFactory peerConnectionFactory = this.peerConnectionFactory;
|
final PeerConnectionFactory peerConnectionFactory = this.peerConnectionFactory;
|
||||||
|
@ -579,7 +576,8 @@ public class WebRTCWrapper {
|
||||||
throw new IllegalStateException("Local video track does not exist");
|
throw new IllegalStateException("Local video track does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized ListenableFuture<SessionDescription> setLocalDescription(final boolean waitForCandidates) {
|
synchronized ListenableFuture<SessionDescription> setLocalDescription(
|
||||||
|
final boolean waitForCandidates) {
|
||||||
this.setIsReadyToReceiveIceCandidates(false);
|
this.setIsReadyToReceiveIceCandidates(false);
|
||||||
return Futures.transformAsync(
|
return Futures.transformAsync(
|
||||||
getPeerConnectionFuture(),
|
getPeerConnectionFuture(),
|
||||||
|
@ -593,16 +591,20 @@ public class WebRTCWrapper {
|
||||||
new SetSdpObserver() {
|
new SetSdpObserver() {
|
||||||
@Override
|
@Override
|
||||||
public void onSetSuccess() {
|
public void onSetSuccess() {
|
||||||
final var delay =
|
if (waitForCandidates) {
|
||||||
waitForCandidates
|
final var delay = getIceGatheringCompleteOrTimeout();
|
||||||
? iceGatheringComplete
|
|
||||||
: Futures.immediateVoidFuture();
|
|
||||||
final var delayedSessionDescription =
|
final var delayedSessionDescription =
|
||||||
Futures.transformAsync(
|
Futures.transformAsync(
|
||||||
delay,
|
delay,
|
||||||
v -> getLocalDescriptionFuture(),
|
v -> {
|
||||||
|
iceCandidates.clear();
|
||||||
|
return getLocalDescriptionFuture();
|
||||||
|
},
|
||||||
MoreExecutors.directExecutor());
|
MoreExecutors.directExecutor());
|
||||||
future.setFuture(delayedSessionDescription);
|
future.setFuture(delayedSessionDescription);
|
||||||
|
} else {
|
||||||
|
future.setFuture(getLocalDescriptionFuture());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -616,6 +618,23 @@ public class WebRTCWrapper {
|
||||||
MoreExecutors.directExecutor());
|
MoreExecutors.directExecutor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ListenableFuture<Void> getIceGatheringCompleteOrTimeout() {
|
||||||
|
return Futures.catching(
|
||||||
|
Futures.withTimeout(
|
||||||
|
iceGatheringComplete,
|
||||||
|
2,
|
||||||
|
TimeUnit.SECONDS,
|
||||||
|
JingleConnectionManager.SCHEDULED_EXECUTOR_SERVICE),
|
||||||
|
TimeoutException.class,
|
||||||
|
ex -> {
|
||||||
|
Log.d(
|
||||||
|
EXTENDED_LOGGING_TAG,
|
||||||
|
"timeout while waiting for ICE gathering to complete");
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
MoreExecutors.directExecutor());
|
||||||
|
}
|
||||||
|
|
||||||
private ListenableFuture<SessionDescription> getLocalDescriptionFuture() {
|
private ListenableFuture<SessionDescription> getLocalDescriptionFuture() {
|
||||||
return Futures.submit(
|
return Futures.submit(
|
||||||
() -> {
|
() -> {
|
||||||
|
|
Loading…
Reference in a new issue