Search the candidate pair with local and remote frag rather than local and remote address for Google ICE. Handles the TCP connect in separate threads in order to not block the start of ICE.

This commit is contained in:
seb 2011-10-07 15:23:49 +00:00
parent 169e56c22f
commit 3cc3c94b63
3 changed files with 62 additions and 35 deletions

View File

@ -1244,7 +1244,6 @@ public class Agent
} }
Component parentComponent = localCandidate.getParentComponent(); Component parentComponent = localCandidate.getParentComponent();
RemoteCandidate remoteCandidate = null; RemoteCandidate remoteCandidate = null;
// we need to find the username for the couple // we need to find the username for the couple
@ -1281,7 +1280,6 @@ public class Agent
CandidatePair triggeredPair CandidatePair triggeredPair
= new CandidatePair(localCandidate, remoteCandidate); = new CandidatePair(localCandidate, remoteCandidate);
logger.info("set use-candidate " + useCandidate + " for pair " + logger.info("set use-candidate " + useCandidate + " for pair " +
triggeredPair.toShortString()); triggeredPair.toShortString());
if(useCandidate) if(useCandidate)
@ -1322,9 +1320,17 @@ public class Agent
{ {
//first check whether we already know about the remote address in case //first check whether we already know about the remote address in case
//we've just discovered a peer-reflexive candidate. //we've just discovered a peer-reflexive candidate.
CandidatePair knownPair = this.findCandidatePair( CandidatePair knownPair = null;
if(compatibilityMode == CompatibilityMode.RFC5245)
knownPair = this.findCandidatePair(
triggerPair.getLocalCandidate().getTransportAddress(), triggerPair.getLocalCandidate().getTransportAddress(),
triggerPair.getRemoteCandidate().getTransportAddress()); triggerPair.getRemoteCandidate().getTransportAddress());
else
knownPair = findCandidatePair(
((RemoteCandidate)triggerPair.getRemoteCandidate()).
getUfrag(),
triggerPair.getLocalCandidate().getUfrag());
IceMediaStream parentStream = triggerPair.getLocalCandidate() IceMediaStream parentStream = triggerPair.getLocalCandidate()
.getParentComponent().getParentStream(); .getParentComponent().getParentStream();
@ -1364,7 +1370,8 @@ public class Agent
//ICE processing state. //ICE processing state.
checkListStatesUpdated(); checkListStatesUpdated();
} }
else if(!isControlling()) else if(compatibilityMode != CompatibilityMode.RFC5245 &&
!isControlling())
{ {
//next time we will see a request it will be considered as //next time we will see a request it will be considered as
// having USE-CANDIDATE // having USE-CANDIDATE

View File

@ -308,7 +308,8 @@ class ConnectivityCheckClient
= (CandidatePair) evt.getTransactionID().getApplicationData(); = (CandidatePair) evt.getTransactionID().getApplicationData();
//make sure that the response came from the right place. //make sure that the response came from the right place.
if (!checkSymmetricAddresses(evt)) if (parentAgent.getCompatibilityMode() == CompatibilityMode.RFC5245 &&
!checkSymmetricAddresses(evt))
{ {
logger.fine("Received a non-symmetric response for pair: " logger.fine("Received a non-symmetric response for pair: "
+ checkedPair.toShortString() + ". Failing"); + checkedPair.toShortString() + ". Failing");
@ -673,7 +674,8 @@ class ConnectivityCheckClient
if((parentAgent.isControlling() if((parentAgent.isControlling()
&& request.containsAttribute(Attribute.USE_CANDIDATE)) || && request.containsAttribute(Attribute.USE_CANDIDATE)) ||
((parentAgent.getCompatibilityMode() == ((parentAgent.getCompatibilityMode() ==
CompatibilityMode.GTALK) && //validPair.isNominated())) CompatibilityMode.GTALK) &&
//validPair.isNominated()))
checkedPair.useCandidateSent())) checkedPair.useCandidateSent()))
{ {
if(validPair.getParentComponent().getSelectedPair() == null) if(validPair.getParentComponent().getSelectedPair() == null)
@ -693,7 +695,8 @@ class ConnectivityCheckClient
//itself had the USE-CANDIDATE attribute. This case is described in //itself had the USE-CANDIDATE attribute. This case is described in
//Section 7.2.1.5, and may now result in setting the nominated flag for //Section 7.2.1.5, and may now result in setting the nominated flag for
//the pair learned from the original request. //the pair learned from the original request.
else if(!parentAgent.isControlling() && else if(parentAgent.getCompatibilityMode() ==
CompatibilityMode.RFC5245 && !parentAgent.isControlling() &&
checkedPair.useCandidateReceived() && checkedPair.useCandidateReceived() &&
!checkedPair.isNominated()) !checkedPair.isNominated())
{ {

View File

@ -347,8 +347,8 @@ public class IceMediaStream
* pair and extract. * pair and extract.
* @param checkList the list that we need to update with the new pairs. * @param checkList the list that we need to update with the new pairs.
*/ */
private void createCheckList(Component component, private void createCheckList(final Component component,
List<CandidatePair> checkList) final List<CandidatePair> checkList)
{ {
List<LocalCandidate> localCnds = component.getLocalCandidates(); List<LocalCandidate> localCnds = component.getLocalCandidates();
List<Candidate> remoteCnds = component.getRemoteCandidates(); List<Candidate> remoteCnds = component.getRemoteCandidates();
@ -377,36 +377,53 @@ public class IceMediaStream
parentAgent.getCompatibilityMode() == parentAgent.getCompatibilityMode() ==
CompatibilityMode.GTALK) CompatibilityMode.GTALK)
{ {
/* for TCP, create a new Candidate (a new connection) final LocalCandidate loc = localCnd;
* to each of remote TCP candidates final Candidate remot = remoteCnd;
*/
try
{
Socket sock = new MultiplexingSocket();
int timeout = sock.getSoTimeout();
sock.setSoTimeout(1000);
sock.connect(new InetSocketAddress( new Thread()
remoteCnd.getTransportAddress().getAddress(),
remoteCnd.getTransportAddress().getPort()),
1000);
sock.setSoTimeout(timeout);
LocalCandidate tmp =
new HostCandidate(new IceTcpSocketWrapper(sock),
component);
tmp.setUfrag(localCnd.getUfrag());
localCnd = tmp;
}
catch (IOException e)
{ {
logger.info("Failed to TCP connect to " + public void run()
remoteCnd.getTransportAddress()); {
continue; /* for TCP, create a new Candidate (a new
} * connection) to each of remote TCP candidates
*/
try
{
Socket sock = new MultiplexingSocket();
int timeout = sock.getSoTimeout();
sock.setSoTimeout(1000);
sock.connect(new InetSocketAddress(
remot.getTransportAddress().
getAddress(),
remot.getTransportAddress().
getPort()),
1000);
sock.setSoTimeout(timeout);
LocalCandidate tmp =
new HostCandidate(
new IceTcpSocketWrapper(sock),
component);
tmp.setUfrag(loc.getUfrag());
CandidatePair pair = new CandidatePair(tmp,
remot);
checkList.add(pair);
}
catch (IOException e)
{
logger.info("Failed to TCP connect to " +
remot.getTransportAddress());
return;
}
}
}.start();
return;
} }
CandidatePair pair = new CandidatePair(localCnd, remoteCnd);
CandidatePair pair = new CandidatePair(localCnd,
remoteCnd);
checkList.add(pair); checkList.add(pair);
} }
} }