diff --git a/src/org/ice4j/ice/Agent.java b/src/org/ice4j/ice/Agent.java index 4614e8d..8c98a35 100644 --- a/src/org/ice4j/ice/Agent.java +++ b/src/org/ice4j/ice/Agent.java @@ -399,7 +399,7 @@ public class Agent * @param minPort the port number where we should first try to bind before * moving to the next one (i.e. minPort + 1) * @param maxPort the maximum port number where we should try binding - * before giving up and throwinG an exception. + * before giving up and throwing an exception. * * @throws IllegalArgumentException if either minPort or * maxPort is not a valid port number or if minPort > @@ -1071,6 +1071,37 @@ public class Agent return null; } + /** + * Returns the local LocalCandidate with the specified + * localAddress if it belongs to any of this {@link Agent}'s + * streams or null if it doesn't. + * + * @param localAddress the {@link TransportAddress} we are looking for. + * @param ufrag local ufrag + * @return the local LocalCandidate with the specified + * localAddress if it belongs to any of this {@link Agent}'s + * streams or null if it doesn't. + */ + public LocalCandidate findLocalCandidate(TransportAddress localAddress, + String ufrag) + { + Collection streamsCollection = mediaStreams.values(); + + for(IceMediaStream stream : streamsCollection) + { + for(Component c : stream.getComponents()) + { + for(LocalCandidate cnd : c.getLocalCandidates()) + { + if(cnd != null && cnd.getUfrag().equals(ufrag)) + return cnd; + } + } + } + + return null; + } + /** * Returns the remote Candidate with the specified * remoteAddress if it belongs to any of this {@link Agent}'s @@ -1190,7 +1221,17 @@ public class Agent String localUFrag, boolean useCandidate) { - LocalCandidate localCandidate = findLocalCandidate(localAddress); + LocalCandidate localCandidate = null; + + if(compatibilityMode == CompatibilityMode.GTALK) + { + localCandidate = findLocalCandidate(localAddress, + remoteUFrag); + } + else + { + localCandidate = findLocalCandidate(localAddress); + } if(localCandidate == null) { diff --git a/src/org/ice4j/ice/ConnectivityCheckClient.java b/src/org/ice4j/ice/ConnectivityCheckClient.java index 1d693de..05c5fbe 100644 --- a/src/org/ice4j/ice/ConnectivityCheckClient.java +++ b/src/org/ice4j/ice/ConnectivityCheckClient.java @@ -437,6 +437,7 @@ class ConnectivityCheckClient LocalCandidate validLocalCandidate = parentAgent .findLocalCandidate(mappedAddress); + // XXX GTALK, find local candidate with ufrag rather than mapped address Candidate validRemoteCandidate = checkedPair.getRemoteCandidate(); // RFC 5245: The agent checks the mapped address from the STUN diff --git a/src/org/ice4j/stack/Connector.java b/src/org/ice4j/stack/Connector.java index b5d476b..88334af 100644 --- a/src/org/ice4j/stack/Connector.java +++ b/src/org/ice4j/stack/Connector.java @@ -129,6 +129,7 @@ class Connector * account including after it gets changed. */ int receiveBufferSize = 1500; + /* if(localSock.getTCPSocket() != null) { receiveBufferSize = localSock.getTCPSocket(). @@ -139,6 +140,7 @@ class Connector receiveBufferSize = localSock.getUDPSocket(). getReceiveBufferSize(); } + */ if (packet == null) {