diff --git a/src/org/ice4j/ice/Agent.java b/src/org/ice4j/ice/Agent.java
index e219016..8a89e3d 100644
--- a/src/org/ice4j/ice/Agent.java
+++ b/src/org/ice4j/ice/Agent.java
@@ -1116,6 +1116,38 @@ public class Agent
return null;
}
+ /**
+ * Returns the {@link CandidatePair} with the specified remote and local
+ * addresses or null if neither of the {@link CheckList}s in this
+ * {@link Agent}'s streams contain such a pair.
+ *
+ * @param localUFrag local user fragment
+ * @param remoteUFrag remote user fragment
+ * @return the {@link CandidatePair} with the specified remote and local
+ * addresses or null if neither of the {@link CheckList}s in this
+ * {@link Agent}'s streams contain such a pair.
+ */
+ public CandidatePair findCandidatePair(String localUFrag,
+ String remoteUFrag)
+ {
+ synchronized(mediaStreams)
+ {
+ Collection streamsCollection
+ = mediaStreams.values();
+
+ for (IceMediaStream stream : streamsCollection)
+ {
+ CandidatePair pair
+ = stream.findCandidatePair(localUFrag, remoteUFrag);
+
+ if( pair != null )
+ return pair;
+ }
+ }
+
+ return null;
+ }
+
/**
* Notifies the implementation that the {@link ConnectivityCheckServer} has
* just received a message on localAddress originating at
@@ -1130,6 +1162,7 @@ public class Agent
* @param priority the priority that the remote party assigned to
* @param remoteUFrag the user fragment that we should be using when and if
* we decide to send a check to remoteAddress.
+ * @param localUFrag local user fragment
* @param useCandidate indicates whether the incoming check
* {@link org.ice4j.message.Request} contained the USE-CANDIDATE ICE
* attribute.
@@ -1138,6 +1171,7 @@ public class Agent
TransportAddress localAddress,
long priority,
String remoteUFrag,
+ String localUFrag,
boolean useCandidate)
{
LocalCandidate localCandidate = findLocalCandidate(localAddress);
@@ -1156,9 +1190,10 @@ public class Agent
// we need to find the username for the couple
if(compatibilityMode == CompatibilityMode.GTALK)
{
- CandidatePair pair = findCandidatePair(localAddress, remoteAddress);
+ CandidatePair pair = findCandidatePair(localUFrag, remoteUFrag);
if(pair == null)
{
+ logger.info("No GTalk CandidatePair that match Lufrag/Rufrag");
return;
}
diff --git a/src/org/ice4j/ice/ConnectivityCheckServer.java b/src/org/ice4j/ice/ConnectivityCheckServer.java
index f43674e..89f17f1 100644
--- a/src/org/ice4j/ice/ConnectivityCheckServer.java
+++ b/src/org/ice4j/ice/ConnectivityCheckServer.java
@@ -114,6 +114,7 @@ class ConnectivityCheckServer
String username = new String(uname.getUsername());
//caller gave us the entire username.
String remoteUfrag = null;
+ String localUFrag = null;
if(parentAgent.getCompatibilityMode() == CompatibilityMode.GTALK)
{
@@ -132,6 +133,7 @@ class ConnectivityCheckServer
/* Google Talk uses username of length 16 for local and remote */
remoteUfrag = username.substring(0, 16);
+ localUFrag = username.substring(16, 32);
}
else
{
@@ -142,7 +144,8 @@ class ConnectivityCheckServer
//tell our address handler we saw a new remote address;
parentAgent.incomingCheckReceived(evt.getRemoteAddress(),
- evt.getLocalAddress(), priority, remoteUfrag, useCandidate);
+ evt.getLocalAddress(), priority, remoteUfrag, localUFrag,
+ useCandidate);
Response response = MessageFactory.createBindingResponse(
request, evt.getRemoteAddress());
diff --git a/src/org/ice4j/ice/IceMediaStream.java b/src/org/ice4j/ice/IceMediaStream.java
index b8445dd..98b2953 100644
--- a/src/org/ice4j/ice/IceMediaStream.java
+++ b/src/org/ice4j/ice/IceMediaStream.java
@@ -538,6 +538,38 @@ public class IceMediaStream
return null;
}
+ /**
+ * Returns the {@link CandidatePair} with the specified remote and local
+ * addresses or null if neither of the {@link CheckList}s in this
+ * stream contain such a pair.
+ *
+ * @param localUFrag local user fragment
+ * @param remoteUFrag remote user fragment
+ * @return the {@link CandidatePair} with the specified remote and local
+ * addresses or null if neither of the {@link CheckList}s in this
+ * stream contain such a pair.
+ */
+ public CandidatePair findCandidatePair(String localUFrag,
+ String remoteUFrag)
+ {
+ synchronized(checkList)
+ {
+ for( CandidatePair pair : checkList)
+ {
+ LocalCandidate local = pair.getLocalCandidate();
+ RemoteCandidate remote =
+ (RemoteCandidate)pair.getRemoteCandidate();
+
+ if(local.getUfrag().equals(remoteUFrag) &&
+ remote.getUfrag().equals(localUFrag))
+ {
+ return pair;
+ }
+ }
+ }
+ return null;
+ }
+
/**
* Returns the number of host {@link Candidate}s in this stream.
*