Supports for XOR-PEER-ADDRESS attribute for GTalk compatibility mode (as Empathy/libnice uses this attribute instead of MAPPED-ATTRIBUTE).

This commit is contained in:
seb 2011-09-08 11:15:03 +00:00
parent 47c73815a9
commit 03a1a11644
5 changed files with 57 additions and 10 deletions

View File

@ -400,6 +400,12 @@ public abstract class Candidate
priority -= getParentComponent().getComponentID() - 1; priority -= getParentComponent().getComponentID() - 1;
InetAddress addr = getTransportAddress().getAddress();
// IPv6 has better priority than IPv4
if(addr instanceof Inet6Address)
priority += 10;
return priority; return priority;
} }

View File

@ -310,6 +310,20 @@ public class Component
return; return;
List<LocalCandidate> localCnds = getLocalCandidates(); List<LocalCandidate> localCnds = getLocalCandidates();
// remove UPnP base from local candidate
LocalCandidate upnpBase = null;
for(LocalCandidate lc : localCnds)
{
if(lc instanceof UPNPCandidate)
{
upnpBase = lc.getBase();
}
}
if(upnpBase != null)
{
localCnds.remove(upnpBase);
}
checkList = new Vector<CandidatePair>(); checkList = new Vector<CandidatePair>();
for(LocalCandidate localCnd : localCnds) for(LocalCandidate localCnd : localCnds)

View File

@ -394,7 +394,24 @@ class ConnectivityCheckClient
TransportAddress mappedAddress = null; TransportAddress mappedAddress = null;
if(this.parentAgent.getCompatibilityMode() == CompatibilityMode.GTALK) if(this.parentAgent.getCompatibilityMode() == CompatibilityMode.GTALK)
{ {
if(!response.containsAttribute(Attribute.MAPPED_ADDRESS)) if(response.containsAttribute(Attribute.XOR_MAPPED_ADDRESS))
{
XorMappedAddressAttribute mappedAddressAttr
= (XorMappedAddressAttribute)response
.getAttribute(Attribute.XOR_MAPPED_ADDRESS);
mappedAddress = mappedAddressAttr.getAddress(
response.getTransactionID());
}
else if(response.containsAttribute(Attribute.MAPPED_ADDRESS))
{
MappedAddressAttribute mappedAddressAttr
= (MappedAddressAttribute)response
.getAttribute(Attribute.MAPPED_ADDRESS);
mappedAddress = mappedAddressAttr.getAddress();
}
else
{ {
logger.fine("Received a success response with no " logger.fine("Received a success response with no "
+ "MAPPED_ADDRESS attribute."); + "MAPPED_ADDRESS attribute.");
@ -403,12 +420,6 @@ class ConnectivityCheckClient
checkedPair.setStateFailed(); checkedPair.setStateFailed();
return; //malformed error response return; //malformed error response
} }
MappedAddressAttribute mappedAddressAttr
= (MappedAddressAttribute)response
.getAttribute(Attribute.MAPPED_ADDRESS);
mappedAddress = mappedAddressAttr.getAddress();
} }
else else
{ {
@ -586,7 +597,7 @@ class ConnectivityCheckClient
if((parentAgent.isControlling() if((parentAgent.isControlling()
&& (request.containsAttribute(Attribute.USE_CANDIDATE)) || && (request.containsAttribute(Attribute.USE_CANDIDATE)) ||
parentAgent.getCompatibilityMode() == parentAgent.getCompatibilityMode() ==
CompatibilityMode.GTALK)) CompatibilityMode.GTALK) && validPair.isNominated())
{ {
logger.info("Nomination confirmed for pair: " + logger.info("Nomination confirmed for pair: " +
validPair.toShortString()); validPair.toShortString());

View File

@ -174,7 +174,7 @@ public class DefaultNominator
* @param evt the {@link PropertyChangeEvent} containing the pair which * @param evt the {@link PropertyChangeEvent} containing the pair which
* has been validated. * has been validated.
*/ */
private void strategyNominateFirstHostOrReflexiveValid( private synchronized void strategyNominateFirstHostOrReflexiveValid(
PropertyChangeEvent evt) PropertyChangeEvent evt)
{ {
if(IceMediaStream.PROPERTY_PAIR_VALIDATED.equals(evt.getPropertyName())) if(IceMediaStream.PROPERTY_PAIR_VALIDATED.equals(evt.getPropertyName()))
@ -184,7 +184,9 @@ public class DefaultNominator
TimerTask task = validatedCandidates.get( TimerTask task = validatedCandidates.get(
validPair.getParentComponent().toShortString()); validPair.getParentComponent().toShortString());
boolean isRelayed = boolean isRelayed =
validPair.getLocalCandidate() instanceof RelayedCandidate; validPair.getLocalCandidate() instanceof RelayedCandidate ||
validPair.getRemoteCandidate().getType().equals(
CandidateType.RELAYED_CANDIDATE);
if(isRelayed && task == null) if(isRelayed && task == null)
{ {

View File

@ -353,6 +353,20 @@ public class IceMediaStream
List<LocalCandidate> localCnds = component.getLocalCandidates(); List<LocalCandidate> localCnds = component.getLocalCandidates();
List<Candidate> remoteCnds = component.getRemoteCandidates(); List<Candidate> remoteCnds = component.getRemoteCandidates();
// remove UPnP base from local candidate
LocalCandidate upnpBase = null;
for(LocalCandidate lc : localCnds)
{
if(lc instanceof UPNPCandidate)
{
upnpBase = lc.getBase();
}
}
if(upnpBase != null)
{
localCnds.remove(upnpBase);
}
for(LocalCandidate localCnd : localCnds) for(LocalCandidate localCnd : localCnds)
{ {
for(Candidate remoteCnd : remoteCnds) for(Candidate remoteCnd : remoteCnds)