Updates rel-addr/rel-port management.
This commit is contained in:
parent
672a43c017
commit
9d94eba147
@ -1171,13 +1171,13 @@ public class Agent
|
|||||||
* <tt>remoteAddress</tt> if it belongs to any of this {@link Agent}'s
|
* <tt>remoteAddress</tt> if it belongs to any of this {@link Agent}'s
|
||||||
* streams or <tt>null</tt> if it doesn't.
|
* streams or <tt>null</tt> if it doesn't.
|
||||||
*/
|
*/
|
||||||
public Candidate findRemoteCandidate(TransportAddress remoteAddress)
|
public RemoteCandidate findRemoteCandidate(TransportAddress remoteAddress)
|
||||||
{
|
{
|
||||||
Collection<IceMediaStream> streamsCollection = mediaStreams.values();
|
Collection<IceMediaStream> streamsCollection = mediaStreams.values();
|
||||||
|
|
||||||
for( IceMediaStream stream : streamsCollection)
|
for( IceMediaStream stream : streamsCollection)
|
||||||
{
|
{
|
||||||
Candidate cnd = stream.findRemoteCandidate(remoteAddress);
|
RemoteCandidate cnd = stream.findRemoteCandidate(remoteAddress);
|
||||||
|
|
||||||
if(cnd != null)
|
if(cnd != null)
|
||||||
return cnd;
|
return cnd;
|
||||||
@ -1334,6 +1334,9 @@ public class Agent
|
|||||||
CandidateType.PEER_REFLEXIVE_CANDIDATE,
|
CandidateType.PEER_REFLEXIVE_CANDIDATE,
|
||||||
foundationsRegistry.obtainFoundationForPeerReflexiveCandidate(),
|
foundationsRegistry.obtainFoundationForPeerReflexiveCandidate(),
|
||||||
priority,
|
priority,
|
||||||
|
// We can not know the related candidate of a remote peer
|
||||||
|
// reflexive candidate. We must set it to "null".
|
||||||
|
null,
|
||||||
ufrag);
|
ufrag);
|
||||||
|
|
||||||
CandidatePair triggeredPair
|
CandidatePair triggeredPair
|
||||||
|
|||||||
@ -27,6 +27,7 @@ import org.ice4j.*;
|
|||||||
* @author Lyubomir Marinov
|
* @author Lyubomir Marinov
|
||||||
*/
|
*/
|
||||||
public abstract class Candidate
|
public abstract class Candidate
|
||||||
|
<T extends Candidate>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The transport address represented by this candidate.
|
* The transport address represented by this candidate.
|
||||||
@ -57,7 +58,7 @@ public abstract class Candidate
|
|||||||
* a base, equal to that candidate itself. Similarly, the base of a
|
* a base, equal to that candidate itself. Similarly, the base of a
|
||||||
* relayed candidate is that candidate itself.
|
* relayed candidate is that candidate itself.
|
||||||
*/
|
*/
|
||||||
private LocalCandidate base = null;
|
private T base = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A unique priority number that MUST be a positive integer between 1 and
|
* A unique priority number that MUST be a positive integer between 1 and
|
||||||
@ -103,6 +104,17 @@ public abstract class Candidate
|
|||||||
*/
|
*/
|
||||||
private TransportAddress mappedAddress = null;
|
private TransportAddress mappedAddress = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The related candidate:
|
||||||
|
* - null for a host candidate,
|
||||||
|
* - the base address (host candidate) for a reflexive candidate,
|
||||||
|
* - the mapped address (the mapped address of the TURN allocate response)
|
||||||
|
* for a relayed candidate.
|
||||||
|
* - null for a peer reflexive candidate : there is no way to know the
|
||||||
|
* related address.
|
||||||
|
*/
|
||||||
|
private T relatedCandidate = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum value for a candidate's type preference.
|
* The maximum value for a candidate's type preference.
|
||||||
*/
|
*/
|
||||||
@ -131,14 +143,23 @@ public abstract class Candidate
|
|||||||
* @param parentComponent the <tt>Component</tt> that this candidate
|
* @param parentComponent the <tt>Component</tt> that this candidate
|
||||||
* belongs to.
|
* belongs to.
|
||||||
* @param type the <tt>CandidateType</tt> for this <tt>Candidate</tt>.
|
* @param type the <tt>CandidateType</tt> for this <tt>Candidate</tt>.
|
||||||
|
* @param relatedCandidate The related candidate:
|
||||||
|
* - null for a host candidate,
|
||||||
|
* - the base address (host candidate) for a reflexive candidate,
|
||||||
|
* - the mapped address (the mapped address of the TURN allocate response)
|
||||||
|
* for a relayed candidate.
|
||||||
|
* - null for a peer reflexive candidate : there is no way to know the
|
||||||
|
* related address.
|
||||||
*/
|
*/
|
||||||
public Candidate(TransportAddress transportAddress,
|
public Candidate(TransportAddress transportAddress,
|
||||||
Component parentComponent,
|
Component parentComponent,
|
||||||
CandidateType type)
|
CandidateType type,
|
||||||
|
T relatedCandidate)
|
||||||
{
|
{
|
||||||
this.transportAddress = transportAddress;
|
this.transportAddress = transportAddress;
|
||||||
this.parentComponent = parentComponent;
|
this.parentComponent = parentComponent;
|
||||||
this.candidateType = type;
|
this.candidateType = type;
|
||||||
|
this.relatedCandidate = relatedCandidate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -206,7 +227,7 @@ public abstract class Candidate
|
|||||||
*
|
*
|
||||||
* @return the base <tt>Candidate</tt> for this <tt>Candidate</tt>.
|
* @return the base <tt>Candidate</tt> for this <tt>Candidate</tt>.
|
||||||
*/
|
*/
|
||||||
public LocalCandidate getBase()
|
public T getBase()
|
||||||
{
|
{
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
@ -220,7 +241,7 @@ public abstract class Candidate
|
|||||||
*
|
*
|
||||||
* @param base the base <tt>Candidate</tt> of this <tt>Candidate</tt>.
|
* @param base the base <tt>Candidate</tt> of this <tt>Candidate</tt>.
|
||||||
*/
|
*/
|
||||||
public void setBase(LocalCandidate base)
|
public void setBase(T base)
|
||||||
{
|
{
|
||||||
this.base = base;
|
this.base = base;
|
||||||
}
|
}
|
||||||
@ -660,22 +681,35 @@ public abstract class Candidate
|
|||||||
*/
|
*/
|
||||||
public TransportAddress getRelatedAddress()
|
public TransportAddress getRelatedAddress()
|
||||||
{
|
{
|
||||||
if(this instanceof RemoteCandidate)
|
if(getRelatedCandidate() != null)
|
||||||
return null;
|
|
||||||
|
|
||||||
switch (getType())
|
|
||||||
{
|
{
|
||||||
case SERVER_REFLEXIVE_CANDIDATE:
|
return getRelatedCandidate().getTransportAddress();
|
||||||
case PEER_REFLEXIVE_CANDIDATE:
|
|
||||||
return getBase().getTransportAddress();
|
|
||||||
case RELAYED_CANDIDATE:
|
|
||||||
return getMappedAddress();
|
|
||||||
default:
|
|
||||||
//host candidate
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the candidate corresponding to the address given in parameter.
|
||||||
|
*
|
||||||
|
* @param relatedAddress The related address:
|
||||||
|
* - null for a host candidate,
|
||||||
|
* - the base address (host candidate) for a reflexive candidate,
|
||||||
|
* - the mapped address (the mapped address of the TURN allocate response)
|
||||||
|
* for a relayed candidate.
|
||||||
|
* - null for a peer reflexive candidate : there is no way to know the
|
||||||
|
* related address.
|
||||||
|
*
|
||||||
|
* @return The related candidate corresponding to the address given in
|
||||||
|
* parameter:
|
||||||
|
* - null for a host candidate,
|
||||||
|
* - the base address (host candidate) for a reflexive candidate,
|
||||||
|
* - the mapped address (the mapped address of the TURN allocate response)
|
||||||
|
* for a relayed candidate.
|
||||||
|
* - null for a peer reflexive candidate : there is no way to know the
|
||||||
|
* related address.
|
||||||
|
*/
|
||||||
|
protected abstract T findRelatedCandidate(TransportAddress relatedAddress);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a <tt>String</tt> representation of this <tt>Candidate</tt>
|
* Returns a <tt>String</tt> representation of this <tt>Candidate</tt>
|
||||||
* containing its <tt>TransportAddress</tt>, base, foundation, priority and
|
* containing its <tt>TransportAddress</tt>, base, foundation, priority and
|
||||||
@ -773,4 +807,137 @@ public abstract class Candidate
|
|||||||
* @return local ufrag
|
* @return local ufrag
|
||||||
*/
|
*/
|
||||||
public abstract String getUfrag();
|
public abstract String getUfrag();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns this candidate host address.
|
||||||
|
*
|
||||||
|
* @return This candidate host address.
|
||||||
|
*/
|
||||||
|
public TransportAddress getHostAddress()
|
||||||
|
{
|
||||||
|
switch (getType())
|
||||||
|
{
|
||||||
|
case SERVER_REFLEXIVE_CANDIDATE:
|
||||||
|
if(getBase() != null)
|
||||||
|
{
|
||||||
|
return getBase().getHostAddress();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PEER_REFLEXIVE_CANDIDATE:
|
||||||
|
if(getBase() != null)
|
||||||
|
{
|
||||||
|
return getBase().getHostAddress();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case RELAYED_CANDIDATE:
|
||||||
|
if(getRelatedCandidate() != null)
|
||||||
|
{
|
||||||
|
return getRelatedCandidate().getHostAddress();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default: //host candidate
|
||||||
|
return getTransportAddress();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns this candidate reflexive address.
|
||||||
|
*
|
||||||
|
* @return This candidate reflexive address. Null if this candidate
|
||||||
|
* does not use a peer/server reflexive address.
|
||||||
|
*/
|
||||||
|
public TransportAddress getReflexiveAddress()
|
||||||
|
{
|
||||||
|
switch (getType())
|
||||||
|
{
|
||||||
|
case SERVER_REFLEXIVE_CANDIDATE:
|
||||||
|
return getTransportAddress();
|
||||||
|
case PEER_REFLEXIVE_CANDIDATE:
|
||||||
|
return getTransportAddress();
|
||||||
|
case RELAYED_CANDIDATE:
|
||||||
|
// Corresponding to getMappedAddress();
|
||||||
|
if(getRelatedCandidate() != null)
|
||||||
|
{
|
||||||
|
return getRelatedCandidate().getReflexiveAddress();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default: //host candidate
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns this candidate relayed address.
|
||||||
|
*
|
||||||
|
* @return This candidate relayed address. Null if this candidate
|
||||||
|
* does not use a relay.
|
||||||
|
*/
|
||||||
|
public TransportAddress getRelayedAddress()
|
||||||
|
{
|
||||||
|
switch (getType())
|
||||||
|
{
|
||||||
|
case SERVER_REFLEXIVE_CANDIDATE:
|
||||||
|
return null;
|
||||||
|
case PEER_REFLEXIVE_CANDIDATE:
|
||||||
|
return null;
|
||||||
|
case RELAYED_CANDIDATE:
|
||||||
|
return getTransportAddress();
|
||||||
|
default: //host candidate
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the related candidate corresponding to the address given in
|
||||||
|
* parameter:
|
||||||
|
* - null for a host candidate,
|
||||||
|
* - the base address (host candidate) for a reflexive candidate,
|
||||||
|
* - the mapped address (the mapped address of the TURN allocate response)
|
||||||
|
* for a relayed candidate.
|
||||||
|
* - null for a peer reflexive candidate : there is no way to know the
|
||||||
|
* related address.
|
||||||
|
*
|
||||||
|
* @return The related candidate corresponding to the address given in
|
||||||
|
* parameter:
|
||||||
|
* - null for a host candidate,
|
||||||
|
* - the base address (host candidate) for a reflexive candidate,
|
||||||
|
* - the mapped address (the mapped address of the TURN allocate response)
|
||||||
|
* for a relayed candidate.
|
||||||
|
* - null for a peer reflexive candidate : there is no way to know the
|
||||||
|
* related address.
|
||||||
|
*/
|
||||||
|
public T getRelatedCandidate()
|
||||||
|
{
|
||||||
|
if(this.relatedCandidate == null)
|
||||||
|
{
|
||||||
|
TransportAddress relatedAddress = null;
|
||||||
|
switch (getType())
|
||||||
|
{
|
||||||
|
case SERVER_REFLEXIVE_CANDIDATE:
|
||||||
|
if(getBase() != null)
|
||||||
|
{
|
||||||
|
relatedAddress = getBase().getTransportAddress();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PEER_REFLEXIVE_CANDIDATE:
|
||||||
|
if(getBase() != null)
|
||||||
|
{
|
||||||
|
relatedAddress = getBase().getTransportAddress();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case RELAYED_CANDIDATE:
|
||||||
|
relatedAddress = getMappedAddress();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//host candidate
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// Update the related candidate conforming to the related address.
|
||||||
|
this.relatedCandidate = findRelatedCandidate(relatedAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.relatedCandidate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -912,9 +912,9 @@ public class Component
|
|||||||
* <tt>localAddress</tt> if it belongs to this component or <tt>null</tt>
|
* <tt>localAddress</tt> if it belongs to this component or <tt>null</tt>
|
||||||
* if it doesn't.
|
* if it doesn't.
|
||||||
*/
|
*/
|
||||||
public Candidate findRemoteCandidate(TransportAddress remoteAddress)
|
public RemoteCandidate findRemoteCandidate(TransportAddress remoteAddress)
|
||||||
{
|
{
|
||||||
for( Candidate remoteCnd : localCandidates)
|
for(RemoteCandidate remoteCnd : remoteCandidates)
|
||||||
{
|
{
|
||||||
if(remoteCnd.getTransportAddress().equals(remoteAddress))
|
if(remoteCnd.getTransportAddress().equals(remoteAddress))
|
||||||
return remoteCnd;
|
return remoteCnd;
|
||||||
|
|||||||
@ -89,7 +89,9 @@ public class GoogleRelayedCandidate
|
|||||||
transportAddress,
|
transportAddress,
|
||||||
turnCandidateHarvest.hostCandidate.getParentComponent(),
|
turnCandidateHarvest.hostCandidate.getParentComponent(),
|
||||||
CandidateType.RELAYED_CANDIDATE,
|
CandidateType.RELAYED_CANDIDATE,
|
||||||
CandidateExtendedType.GOOGLE_TURN_RELAYED_CANDIDATE);
|
CandidateExtendedType.GOOGLE_TURN_RELAYED_CANDIDATE,
|
||||||
|
turnCandidateHarvest.hostCandidate.getParentComponent()
|
||||||
|
.findLocalCandidate(mappedAddress));
|
||||||
|
|
||||||
if(transportAddress.getTransport() == Transport.TCP)
|
if(transportAddress.getTransport() == Transport.TCP)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -50,7 +50,8 @@ public class HostCandidate extends LocalCandidate
|
|||||||
socket.getLocalPort(), Transport.UDP),
|
socket.getLocalPort(), Transport.UDP),
|
||||||
parentComponent,
|
parentComponent,
|
||||||
CandidateType.HOST_CANDIDATE,
|
CandidateType.HOST_CANDIDATE,
|
||||||
CandidateExtendedType.HOST_CANDIDATE);
|
CandidateExtendedType.HOST_CANDIDATE,
|
||||||
|
null);
|
||||||
|
|
||||||
this.socket = socket;
|
this.socket = socket;
|
||||||
setBase(this);
|
setBase(this);
|
||||||
@ -73,7 +74,8 @@ public class HostCandidate extends LocalCandidate
|
|||||||
socket.getLocalPort(), transport),
|
socket.getLocalPort(), transport),
|
||||||
parentComponent,
|
parentComponent,
|
||||||
CandidateType.HOST_CANDIDATE,
|
CandidateType.HOST_CANDIDATE,
|
||||||
CandidateExtendedType.HOST_CANDIDATE);
|
CandidateExtendedType.HOST_CANDIDATE,
|
||||||
|
null);
|
||||||
|
|
||||||
this.socket = socket;
|
this.socket = socket;
|
||||||
setBase(this);
|
setBase(this);
|
||||||
|
|||||||
@ -558,13 +558,13 @@ public class IceMediaStream
|
|||||||
* Component}s or <tt>null</tt> if it doesn't.
|
* Component}s or <tt>null</tt> if it doesn't.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Candidate findRemoteCandidate(TransportAddress remoteAddress)
|
public RemoteCandidate findRemoteCandidate(TransportAddress remoteAddress)
|
||||||
{
|
{
|
||||||
Collection<Component> cmpCol = components.values();
|
Collection<Component> cmpCol = components.values();
|
||||||
|
|
||||||
for( Component cmp : cmpCol)
|
for( Component cmp : cmpCol)
|
||||||
{
|
{
|
||||||
Candidate cnd = cmp.findRemoteCandidate(remoteAddress);
|
RemoteCandidate cnd = cmp.findRemoteCandidate(remoteAddress);
|
||||||
|
|
||||||
if(cnd != null)
|
if(cnd != null)
|
||||||
return cnd;
|
return cnd;
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import org.ice4j.stack.*;
|
|||||||
* @author Lyubomir Marinov
|
* @author Lyubomir Marinov
|
||||||
*/
|
*/
|
||||||
public abstract class LocalCandidate
|
public abstract class LocalCandidate
|
||||||
extends Candidate
|
extends Candidate<LocalCandidate>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The type of method used to discover this candidate ("host", "upnp", "stun
|
* The type of method used to discover this candidate ("host", "upnp", "stun
|
||||||
@ -57,13 +57,18 @@ public abstract class LocalCandidate
|
|||||||
* ("host", "upnp", "stun peer reflexive", "stun server reflexive", "turn
|
* ("host", "upnp", "stun peer reflexive", "stun server reflexive", "turn
|
||||||
* relayed", "google turn relayed", "google tcp turn relayed" or "jingle
|
* relayed", "google turn relayed", "google tcp turn relayed" or "jingle
|
||||||
* node").
|
* node").
|
||||||
|
* @param relatedCandidate the relatedCandidate: null for a host candidate,
|
||||||
|
* the base address (host candidate) for a reflexive candidate, the mapped
|
||||||
|
* address (the mapped address of the TURN allocate response) for a relayed
|
||||||
|
* candidate.
|
||||||
*/
|
*/
|
||||||
public LocalCandidate(TransportAddress transportAddress,
|
public LocalCandidate(TransportAddress transportAddress,
|
||||||
Component parentComponent,
|
Component parentComponent,
|
||||||
CandidateType type,
|
CandidateType type,
|
||||||
CandidateExtendedType extendedType)
|
CandidateExtendedType extendedType,
|
||||||
|
LocalCandidate relatedCandidate)
|
||||||
{
|
{
|
||||||
super(transportAddress, parentComponent, type);
|
super(transportAddress, parentComponent, type, relatedCandidate);
|
||||||
this.extendedType = extendedType;
|
this.extendedType = extendedType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,76 +355,28 @@ public abstract class LocalCandidate
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns this candidate host address.
|
* Find the candidate corresponding to the address given in parameter.
|
||||||
*
|
*
|
||||||
* @return This candidate host address.
|
* @param relatedAddress The related address:
|
||||||
*/
|
* - null for a host candidate,
|
||||||
public TransportAddress getHostAddress()
|
* - the base address (host candidate) for a reflexive candidate,
|
||||||
{
|
* - the mapped address (the mapped address of the TURN allocate response)
|
||||||
switch (getType())
|
* for a relayed candidate.
|
||||||
{
|
* - null for a peer reflexive candidate : there is no way to know the
|
||||||
case SERVER_REFLEXIVE_CANDIDATE:
|
* related address.
|
||||||
if(getBase() != null)
|
|
||||||
{
|
|
||||||
return getBase().getTransportAddress();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
case PEER_REFLEXIVE_CANDIDATE:
|
|
||||||
if(getBase() != null)
|
|
||||||
{
|
|
||||||
return getBase().getTransportAddress();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
case RELAYED_CANDIDATE:
|
|
||||||
if(getBase() != null)
|
|
||||||
{
|
|
||||||
return getBase().getTransportAddress();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
default: //host candidate
|
|
||||||
return getTransportAddress();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns this candidate reflexive address.
|
|
||||||
*
|
*
|
||||||
* @return This candidate reflexive address. Null if this candidate
|
* @return The related candidate corresponding to the address given in
|
||||||
* does not use a peer/server reflexive address.
|
* parameter:
|
||||||
|
* - null for a host candidate,
|
||||||
|
* - the base address (host candidate) for a reflexive candidate,
|
||||||
|
* - the mapped address (the mapped address of the TURN allocate response)
|
||||||
|
* for a relayed candidate.
|
||||||
|
* - null for a peer reflexive candidate : there is no way to know the
|
||||||
|
* related address.
|
||||||
*/
|
*/
|
||||||
public TransportAddress getReflexiveAddress()
|
protected LocalCandidate findRelatedCandidate(
|
||||||
|
TransportAddress relatedAddress)
|
||||||
{
|
{
|
||||||
switch (getType())
|
return getParentComponent().findLocalCandidate(relatedAddress);
|
||||||
{
|
|
||||||
case SERVER_REFLEXIVE_CANDIDATE:
|
|
||||||
return getTransportAddress();
|
|
||||||
case PEER_REFLEXIVE_CANDIDATE:
|
|
||||||
return getTransportAddress();
|
|
||||||
case RELAYED_CANDIDATE:
|
|
||||||
return getMappedAddress();
|
|
||||||
default: //host candidate
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns this candidate relayed address.
|
|
||||||
*
|
|
||||||
* @return This candidate relayed address. Null if this candidate
|
|
||||||
* does not use a relay.
|
|
||||||
*/
|
|
||||||
public TransportAddress getRelayedAddress()
|
|
||||||
{
|
|
||||||
switch (getType())
|
|
||||||
{
|
|
||||||
case SERVER_REFLEXIVE_CANDIDATE:
|
|
||||||
return null;
|
|
||||||
case PEER_REFLEXIVE_CANDIDATE:
|
|
||||||
return null;
|
|
||||||
case RELAYED_CANDIDATE:
|
|
||||||
return getTransportAddress();
|
|
||||||
default: //host candidate
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,7 +46,8 @@ public class PeerReflexiveCandidate
|
|||||||
transportAddress,
|
transportAddress,
|
||||||
parentComponent,
|
parentComponent,
|
||||||
CandidateType.PEER_REFLEXIVE_CANDIDATE,
|
CandidateType.PEER_REFLEXIVE_CANDIDATE,
|
||||||
CandidateExtendedType.STUN_PEER_REFLEXIVE_CANDIDATE);
|
CandidateExtendedType.STUN_PEER_REFLEXIVE_CANDIDATE,
|
||||||
|
base);
|
||||||
super.setBase(base);
|
super.setBase(base);
|
||||||
super.priority = priority;
|
super.priority = priority;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,7 +67,9 @@ public class RelayedCandidate
|
|||||||
transportAddress,
|
transportAddress,
|
||||||
turnCandidateHarvest.hostCandidate.getParentComponent(),
|
turnCandidateHarvest.hostCandidate.getParentComponent(),
|
||||||
CandidateType.RELAYED_CANDIDATE,
|
CandidateType.RELAYED_CANDIDATE,
|
||||||
CandidateExtendedType.TURN_RELAYED_CANDIDATE);
|
CandidateExtendedType.TURN_RELAYED_CANDIDATE,
|
||||||
|
turnCandidateHarvest.hostCandidate.getParentComponent()
|
||||||
|
.findLocalCandidate(mappedAddress));
|
||||||
|
|
||||||
this.turnCandidateHarvest = turnCandidateHarvest;
|
this.turnCandidateHarvest = turnCandidateHarvest;
|
||||||
|
|
||||||
|
|||||||
@ -17,13 +17,8 @@ import org.ice4j.*;
|
|||||||
* @author Emil Ivov
|
* @author Emil Ivov
|
||||||
*/
|
*/
|
||||||
public class RemoteCandidate
|
public class RemoteCandidate
|
||||||
extends Candidate
|
extends Candidate<RemoteCandidate>
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The related address that the remote party sent in SDP, if it did.
|
|
||||||
*/
|
|
||||||
private TransportAddress raddr;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ufrag for the Google Talk candidate.
|
* Ufrag for the Google Talk candidate.
|
||||||
*/
|
*/
|
||||||
@ -42,13 +37,18 @@ public class RemoteCandidate
|
|||||||
* by the session description protocol.
|
* by the session description protocol.
|
||||||
* @param priority the <tt>RemoteCandidate</tt>'s priority as reported
|
* @param priority the <tt>RemoteCandidate</tt>'s priority as reported
|
||||||
* by the session description protocol.
|
* by the session description protocol.
|
||||||
|
* @param relatedCandidate the relatedCandidate: null for a host candidate,
|
||||||
|
* the base address (host candidate) for a reflexive candidate, the mapped
|
||||||
|
* address (the mapped address of the TURN allocate response) for a relayed
|
||||||
|
* candidate.
|
||||||
*/
|
*/
|
||||||
public RemoteCandidate(
|
public RemoteCandidate(
|
||||||
TransportAddress transportAddress,
|
TransportAddress transportAddress,
|
||||||
Component parentComponent,
|
Component parentComponent,
|
||||||
CandidateType type,
|
CandidateType type,
|
||||||
String foundation,
|
String foundation,
|
||||||
long priority)
|
long priority,
|
||||||
|
RemoteCandidate relatedCandidate)
|
||||||
{
|
{
|
||||||
this(
|
this(
|
||||||
transportAddress,
|
transportAddress,
|
||||||
@ -56,6 +56,7 @@ public class RemoteCandidate
|
|||||||
type,
|
type,
|
||||||
foundation,
|
foundation,
|
||||||
priority,
|
priority,
|
||||||
|
relatedCandidate,
|
||||||
null);
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +73,10 @@ public class RemoteCandidate
|
|||||||
* by the session description protocol.
|
* by the session description protocol.
|
||||||
* @param priority the <tt>RemoteCandidate</tt>'s priority as reported
|
* @param priority the <tt>RemoteCandidate</tt>'s priority as reported
|
||||||
* by the session description protocol.
|
* by the session description protocol.
|
||||||
|
* @param relatedCandidate the relatedCandidate: null for a host candidate,
|
||||||
|
* the base address (host candidate) for a reflexive candidate, the mapped
|
||||||
|
* address (the mapped address of the TURN allocate response) for a relayed
|
||||||
|
* candidate.
|
||||||
* @param ufrag ufrag for the remote candidate
|
* @param ufrag ufrag for the remote candidate
|
||||||
*/
|
*/
|
||||||
public RemoteCandidate(
|
public RemoteCandidate(
|
||||||
@ -80,9 +85,10 @@ public class RemoteCandidate
|
|||||||
CandidateType type,
|
CandidateType type,
|
||||||
String foundation,
|
String foundation,
|
||||||
long priority,
|
long priority,
|
||||||
|
RemoteCandidate relatedCandidate,
|
||||||
String ufrag)
|
String ufrag)
|
||||||
{
|
{
|
||||||
super(transportAddress, parentComponent, type);
|
super(transportAddress, parentComponent, type, relatedCandidate);
|
||||||
setFoundation(foundation);
|
setFoundation(foundation);
|
||||||
setPriority(priority);
|
setPriority(priority);
|
||||||
this.ufrag = ufrag;
|
this.ufrag = ufrag;
|
||||||
@ -121,39 +127,6 @@ public class RemoteCandidate
|
|||||||
return equals(parentCmp.getDefaultRemoteCandidate());
|
return equals(parentCmp.getDefaultRemoteCandidate());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the <tt>TransportAddress</tt> that the remote party indicated
|
|
||||||
* as "related" for this <tt>Candidate</tt>.
|
|
||||||
* <p>
|
|
||||||
* Related addresses are present for server reflexive, peer reflexive and
|
|
||||||
* relayed candidates. If a candidate is server or peer reflexive,
|
|
||||||
* the related address is equal to the base of this <tt>Candidate</tt>.
|
|
||||||
* If the candidate is relayed, the returned address is equal to the mapped
|
|
||||||
* address. If the candidate is a host candidate then the method returns
|
|
||||||
* <tt>null</tt>.
|
|
||||||
*
|
|
||||||
* @return the <tt>TransportAddress</tt> that the remote party indicated
|
|
||||||
* as "related" for this <tt>Candidate</tt> or <tt>null</tt> if they didn't
|
|
||||||
* include it in SDP.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public TransportAddress getRelatedAddress()
|
|
||||||
{
|
|
||||||
return raddr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies the <tt>TransportAddress</tt> that the remote party indicated
|
|
||||||
* as "related" for this <tt>Candidate</tt>.
|
|
||||||
*
|
|
||||||
* @param relatedAddr the <tt>TransportAddress</tt> that the remote party
|
|
||||||
* indicated as "related" for this <tt>Candidate</tt>.
|
|
||||||
*/
|
|
||||||
public void setRelatedAddress(TransportAddress relatedAddr)
|
|
||||||
{
|
|
||||||
this.raddr = relatedAddr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the remote ufrag.
|
* Get the remote ufrag.
|
||||||
*
|
*
|
||||||
@ -165,76 +138,28 @@ public class RemoteCandidate
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns this candidate host address.
|
* Find the candidate corresponding to the address given in parameter.
|
||||||
*
|
*
|
||||||
* @return This candidate host address.
|
* @param relatedAddress The related address:
|
||||||
*/
|
* - null for a host candidate,
|
||||||
public TransportAddress getHostAddress()
|
* - the base address (host candidate) for a reflexive candidate,
|
||||||
{
|
* - the mapped address (the mapped address of the TURN allocate response)
|
||||||
switch (getType())
|
* for a relayed candidate.
|
||||||
{
|
* - null for a peer reflexive candidate : there is no way to know the
|
||||||
case SERVER_REFLEXIVE_CANDIDATE:
|
* related address.
|
||||||
if(getBase() != null)
|
|
||||||
{
|
|
||||||
return getBase().getTransportAddress();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
case PEER_REFLEXIVE_CANDIDATE:
|
|
||||||
if(getBase() != null)
|
|
||||||
{
|
|
||||||
return getBase().getTransportAddress();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
case RELAYED_CANDIDATE:
|
|
||||||
// If we are able to find the base address of the mapped
|
|
||||||
// address, it will be a great enhancement.
|
|
||||||
// i.e. but not working
|
|
||||||
// getMappedAddress().getBase().getTransportAddress();
|
|
||||||
return null;
|
|
||||||
default: //host candidate
|
|
||||||
return getTransportAddress();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns this candidate reflexive address.
|
|
||||||
*
|
*
|
||||||
* @return This candidate reflexive address. Null if this candidate
|
* @return The related candidate corresponding to the address given in
|
||||||
* does not use a peer/server reflexive address.
|
* parameter:
|
||||||
|
* - null for a host candidate,
|
||||||
|
* - the base address (host candidate) for a reflexive candidate,
|
||||||
|
* - the mapped address (the mapped address of the TURN allocate response)
|
||||||
|
* for a relayed candidate.
|
||||||
|
* - null for a peer reflexive candidate : there is no way to know the
|
||||||
|
* related address.
|
||||||
*/
|
*/
|
||||||
public TransportAddress getReflexiveAddress()
|
protected RemoteCandidate findRelatedCandidate(
|
||||||
|
TransportAddress relatedAddress)
|
||||||
{
|
{
|
||||||
switch (getType())
|
return getParentComponent().findRemoteCandidate(relatedAddress);
|
||||||
{
|
|
||||||
case SERVER_REFLEXIVE_CANDIDATE:
|
|
||||||
return getTransportAddress();
|
|
||||||
case PEER_REFLEXIVE_CANDIDATE:
|
|
||||||
return getTransportAddress();
|
|
||||||
case RELAYED_CANDIDATE:
|
|
||||||
return getMappedAddress();
|
|
||||||
default: //host candidate
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns this candidate relayed address.
|
|
||||||
*
|
|
||||||
* @return This candidate relayed address. Null if this candidate
|
|
||||||
* does not use a relay.
|
|
||||||
*/
|
|
||||||
public TransportAddress getRelayedAddress()
|
|
||||||
{
|
|
||||||
switch (getType())
|
|
||||||
{
|
|
||||||
case SERVER_REFLEXIVE_CANDIDATE:
|
|
||||||
return null;
|
|
||||||
case PEER_REFLEXIVE_CANDIDATE:
|
|
||||||
return null;
|
|
||||||
case RELAYED_CANDIDATE:
|
|
||||||
return getTransportAddress();
|
|
||||||
default: //host candidate
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,14 +52,12 @@ public class ServerReflexiveCandidate
|
|||||||
TransportAddress stunSrvrAddr,
|
TransportAddress stunSrvrAddr,
|
||||||
CandidateExtendedType extendedType)
|
CandidateExtendedType extendedType)
|
||||||
{
|
{
|
||||||
super(address,
|
this(
|
||||||
base.getParentComponent(),
|
address,
|
||||||
CandidateType.SERVER_REFLEXIVE_CANDIDATE,
|
base,
|
||||||
extendedType);
|
stunSrvrAddr,
|
||||||
|
null,
|
||||||
setBase(base);
|
extendedType);
|
||||||
setStunServerAddress(stunSrvrAddr);
|
|
||||||
stunHarvest = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87,7 +85,8 @@ public class ServerReflexiveCandidate
|
|||||||
super(address,
|
super(address,
|
||||||
base.getParentComponent(),
|
base.getParentComponent(),
|
||||||
CandidateType.SERVER_REFLEXIVE_CANDIDATE,
|
CandidateType.SERVER_REFLEXIVE_CANDIDATE,
|
||||||
extendedType);
|
extendedType,
|
||||||
|
base);
|
||||||
|
|
||||||
setBase(base);
|
setBase(base);
|
||||||
setStunServerAddress(stunSrvrAddr);
|
setStunServerAddress(stunSrvrAddr);
|
||||||
|
|||||||
@ -44,7 +44,8 @@ public class UPNPCandidate
|
|||||||
transportAddress,
|
transportAddress,
|
||||||
parentComponent,
|
parentComponent,
|
||||||
CandidateType.SERVER_REFLEXIVE_CANDIDATE,
|
CandidateType.SERVER_REFLEXIVE_CANDIDATE,
|
||||||
CandidateExtendedType.UPNP_CANDIDATE);
|
CandidateExtendedType.UPNP_CANDIDATE,
|
||||||
|
base);
|
||||||
|
|
||||||
this.setBase(base);
|
this.setBase(base);
|
||||||
this.device = device;
|
this.device = device;
|
||||||
|
|||||||
@ -245,7 +245,8 @@ public class Ice
|
|||||||
localComponent,
|
localComponent,
|
||||||
rCand.getType(),
|
rCand.getType(),
|
||||||
rCand.getFoundation(),
|
rCand.getFoundation(),
|
||||||
rCand.getPriority()));
|
rCand.getPriority(),
|
||||||
|
null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -229,13 +229,9 @@ public class SdpUtils
|
|||||||
if(component == null)
|
if(component == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
RemoteCandidate cand = new RemoteCandidate(transAddr, component, type,
|
|
||||||
foundation, priority);
|
|
||||||
|
|
||||||
component.addRemoteCandidate(cand);
|
|
||||||
|
|
||||||
// check if there's a related address property
|
// check if there's a related address property
|
||||||
|
|
||||||
|
RemoteCandidate relatedCandidate = null;
|
||||||
if (tokenizer.countTokens() >= 4)
|
if (tokenizer.countTokens() >= 4)
|
||||||
{
|
{
|
||||||
tokenizer.nextToken(); // skip the raddr element
|
tokenizer.nextToken(); // skip the raddr element
|
||||||
@ -246,9 +242,14 @@ public class SdpUtils
|
|||||||
TransportAddress raddr = new TransportAddress(
|
TransportAddress raddr = new TransportAddress(
|
||||||
relatedAddr, relatedPort, Transport.UDP);
|
relatedAddr, relatedPort, Transport.UDP);
|
||||||
|
|
||||||
cand.setRelatedAddress(raddr);
|
relatedCandidate = component.findRemoteCandidate(raddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RemoteCandidate cand = new RemoteCandidate(transAddr, component, type,
|
||||||
|
foundation, priority, relatedCandidate);
|
||||||
|
|
||||||
|
component.addRemoteCandidate(cand);
|
||||||
|
|
||||||
return cand;
|
return cand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user