Find the GTalk CandidatePair based on its local and remote username.

This commit is contained in:
seb 2011-06-09 14:16:32 +00:00
parent b687bdb9eb
commit 16617e7234
3 changed files with 72 additions and 2 deletions

View File

@ -1116,6 +1116,38 @@ public class Agent
return null;
}
/**
* Returns the {@link CandidatePair} with the specified remote and local
* addresses or <tt>null</tt> 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 <tt>null</tt> 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<IceMediaStream> 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 <tt>localAddress</tt> 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 <tt>remoteAddress</tt>.
* @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;
}

View File

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

View File

@ -538,6 +538,38 @@ public class IceMediaStream
return null;
}
/**
* Returns the {@link CandidatePair} with the specified remote and local
* addresses or <tt>null</tt> 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 <tt>null</tt> 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.
*