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

View File

@ -308,7 +308,8 @@ class ConnectivityCheckClient
= (CandidatePair) evt.getTransactionID().getApplicationData();
//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: "
+ checkedPair.toShortString() + ". Failing");
@ -673,7 +674,8 @@ class ConnectivityCheckClient
if((parentAgent.isControlling()
&& request.containsAttribute(Attribute.USE_CANDIDATE)) ||
((parentAgent.getCompatibilityMode() ==
CompatibilityMode.GTALK) && //validPair.isNominated()))
CompatibilityMode.GTALK) &&
//validPair.isNominated()))
checkedPair.useCandidateSent()))
{
if(validPair.getParentComponent().getSelectedPair() == null)
@ -693,7 +695,8 @@ class ConnectivityCheckClient
//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
//the pair learned from the original request.
else if(!parentAgent.isControlling() &&
else if(parentAgent.getCompatibilityMode() ==
CompatibilityMode.RFC5245 && !parentAgent.isControlling() &&
checkedPair.useCandidateReceived() &&
!checkedPair.isNominated())
{

View File

@ -347,8 +347,8 @@ public class IceMediaStream
* pair and extract.
* @param checkList the list that we need to update with the new pairs.
*/
private void createCheckList(Component component,
List<CandidatePair> checkList)
private void createCheckList(final Component component,
final List<CandidatePair> checkList)
{
List<LocalCandidate> localCnds = component.getLocalCandidates();
List<Candidate> remoteCnds = component.getRemoteCandidates();
@ -377,36 +377,53 @@ public class IceMediaStream
parentAgent.getCompatibilityMode() ==
CompatibilityMode.GTALK)
{
/* 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);
final LocalCandidate loc = localCnd;
final Candidate remot = remoteCnd;
sock.connect(new InetSocketAddress(
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)
new Thread()
{
logger.info("Failed to TCP connect to " +
remoteCnd.getTransportAddress());
continue;
}
public void run()
{
/* 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);
}
}