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
|
||||
* streams or <tt>null</tt> if it doesn't.
|
||||
*/
|
||||
public Candidate findRemoteCandidate(TransportAddress remoteAddress)
|
||||
public RemoteCandidate findRemoteCandidate(TransportAddress remoteAddress)
|
||||
{
|
||||
Collection<IceMediaStream> streamsCollection = mediaStreams.values();
|
||||
|
||||
for( IceMediaStream stream : streamsCollection)
|
||||
{
|
||||
Candidate cnd = stream.findRemoteCandidate(remoteAddress);
|
||||
RemoteCandidate cnd = stream.findRemoteCandidate(remoteAddress);
|
||||
|
||||
if(cnd != null)
|
||||
return cnd;
|
||||
@ -1334,6 +1334,9 @@ public class Agent
|
||||
CandidateType.PEER_REFLEXIVE_CANDIDATE,
|
||||
foundationsRegistry.obtainFoundationForPeerReflexiveCandidate(),
|
||||
priority,
|
||||
// We can not know the related candidate of a remote peer
|
||||
// reflexive candidate. We must set it to "null".
|
||||
null,
|
||||
ufrag);
|
||||
|
||||
CandidatePair triggeredPair
|
||||
|
||||
@ -27,6 +27,7 @@ import org.ice4j.*;
|
||||
* @author Lyubomir Marinov
|
||||
*/
|
||||
public abstract class Candidate
|
||||
<T extends 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
|
||||
* 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
|
||||
@ -103,6 +104,17 @@ public abstract class Candidate
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@ -131,14 +143,23 @@ public abstract class Candidate
|
||||
* @param parentComponent the <tt>Component</tt> that this candidate
|
||||
* belongs to.
|
||||
* @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,
|
||||
Component parentComponent,
|
||||
CandidateType type)
|
||||
CandidateType type,
|
||||
T relatedCandidate)
|
||||
{
|
||||
this.transportAddress = transportAddress;
|
||||
this.parentComponent = parentComponent;
|
||||
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>.
|
||||
*/
|
||||
public LocalCandidate getBase()
|
||||
public T getBase()
|
||||
{
|
||||
return base;
|
||||
}
|
||||
@ -220,7 +241,7 @@ public abstract class Candidate
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
@ -660,22 +681,35 @@ public abstract class Candidate
|
||||
*/
|
||||
public TransportAddress getRelatedAddress()
|
||||
{
|
||||
if(this instanceof RemoteCandidate)
|
||||
return null;
|
||||
|
||||
switch (getType())
|
||||
if(getRelatedCandidate() != null)
|
||||
{
|
||||
case SERVER_REFLEXIVE_CANDIDATE:
|
||||
case PEER_REFLEXIVE_CANDIDATE:
|
||||
return getBase().getTransportAddress();
|
||||
case RELAYED_CANDIDATE:
|
||||
return getMappedAddress();
|
||||
default:
|
||||
//host candidate
|
||||
return null;
|
||||
return getRelatedCandidate().getTransportAddress();
|
||||
}
|
||||
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>
|
||||
* containing its <tt>TransportAddress</tt>, base, foundation, priority and
|
||||
@ -773,4 +807,137 @@ public abstract class Candidate
|
||||
* @return local ufrag
|
||||
*/
|
||||
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>
|
||||
* 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))
|
||||
return remoteCnd;
|
||||
|
||||
@ -89,7 +89,9 @@ public class GoogleRelayedCandidate
|
||||
transportAddress,
|
||||
turnCandidateHarvest.hostCandidate.getParentComponent(),
|
||||
CandidateType.RELAYED_CANDIDATE,
|
||||
CandidateExtendedType.GOOGLE_TURN_RELAYED_CANDIDATE);
|
||||
CandidateExtendedType.GOOGLE_TURN_RELAYED_CANDIDATE,
|
||||
turnCandidateHarvest.hostCandidate.getParentComponent()
|
||||
.findLocalCandidate(mappedAddress));
|
||||
|
||||
if(transportAddress.getTransport() == Transport.TCP)
|
||||
{
|
||||
|
||||
@ -50,7 +50,8 @@ public class HostCandidate extends LocalCandidate
|
||||
socket.getLocalPort(), Transport.UDP),
|
||||
parentComponent,
|
||||
CandidateType.HOST_CANDIDATE,
|
||||
CandidateExtendedType.HOST_CANDIDATE);
|
||||
CandidateExtendedType.HOST_CANDIDATE,
|
||||
null);
|
||||
|
||||
this.socket = socket;
|
||||
setBase(this);
|
||||
@ -73,7 +74,8 @@ public class HostCandidate extends LocalCandidate
|
||||
socket.getLocalPort(), transport),
|
||||
parentComponent,
|
||||
CandidateType.HOST_CANDIDATE,
|
||||
CandidateExtendedType.HOST_CANDIDATE);
|
||||
CandidateExtendedType.HOST_CANDIDATE,
|
||||
null);
|
||||
|
||||
this.socket = socket;
|
||||
setBase(this);
|
||||
|
||||
@ -558,13 +558,13 @@ public class IceMediaStream
|
||||
* 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();
|
||||
|
||||
for( Component cmp : cmpCol)
|
||||
{
|
||||
Candidate cnd = cmp.findRemoteCandidate(remoteAddress);
|
||||
RemoteCandidate cnd = cmp.findRemoteCandidate(remoteAddress);
|
||||
|
||||
if(cnd != null)
|
||||
return cnd;
|
||||
|
||||
@ -23,7 +23,7 @@ import org.ice4j.stack.*;
|
||||
* @author Lyubomir Marinov
|
||||
*/
|
||||
public abstract class LocalCandidate
|
||||
extends Candidate
|
||||
extends Candidate<LocalCandidate>
|
||||
{
|
||||
/**
|
||||
* 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
|
||||
* relayed", "google turn relayed", "google tcp turn relayed" or "jingle
|
||||
* 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,
|
||||
Component parentComponent,
|
||||
CandidateType type,
|
||||
CandidateExtendedType extendedType)
|
||||
CandidateExtendedType extendedType,
|
||||
LocalCandidate relatedCandidate)
|
||||
{
|
||||
super(transportAddress, parentComponent, type);
|
||||
super(transportAddress, parentComponent, type, relatedCandidate);
|
||||
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.
|
||||
*/
|
||||
public TransportAddress getHostAddress()
|
||||
{
|
||||
switch (getType())
|
||||
{
|
||||
case SERVER_REFLEXIVE_CANDIDATE:
|
||||
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.
|
||||
* @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 This candidate reflexive address. Null if this candidate
|
||||
* does not use a peer/server reflexive 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 TransportAddress getReflexiveAddress()
|
||||
protected LocalCandidate findRelatedCandidate(
|
||||
TransportAddress relatedAddress)
|
||||
{
|
||||
switch (getType())
|
||||
{
|
||||
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;
|
||||
}
|
||||
return getParentComponent().findLocalCandidate(relatedAddress);
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,7 +46,8 @@ public class PeerReflexiveCandidate
|
||||
transportAddress,
|
||||
parentComponent,
|
||||
CandidateType.PEER_REFLEXIVE_CANDIDATE,
|
||||
CandidateExtendedType.STUN_PEER_REFLEXIVE_CANDIDATE);
|
||||
CandidateExtendedType.STUN_PEER_REFLEXIVE_CANDIDATE,
|
||||
base);
|
||||
super.setBase(base);
|
||||
super.priority = priority;
|
||||
}
|
||||
|
||||
@ -67,7 +67,9 @@ public class RelayedCandidate
|
||||
transportAddress,
|
||||
turnCandidateHarvest.hostCandidate.getParentComponent(),
|
||||
CandidateType.RELAYED_CANDIDATE,
|
||||
CandidateExtendedType.TURN_RELAYED_CANDIDATE);
|
||||
CandidateExtendedType.TURN_RELAYED_CANDIDATE,
|
||||
turnCandidateHarvest.hostCandidate.getParentComponent()
|
||||
.findLocalCandidate(mappedAddress));
|
||||
|
||||
this.turnCandidateHarvest = turnCandidateHarvest;
|
||||
|
||||
|
||||
@ -17,13 +17,8 @@ import org.ice4j.*;
|
||||
* @author Emil Ivov
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@ -42,13 +37,18 @@ public class RemoteCandidate
|
||||
* by the session description protocol.
|
||||
* @param priority the <tt>RemoteCandidate</tt>'s priority as reported
|
||||
* 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(
|
||||
TransportAddress transportAddress,
|
||||
Component parentComponent,
|
||||
CandidateType type,
|
||||
String foundation,
|
||||
long priority)
|
||||
long priority,
|
||||
RemoteCandidate relatedCandidate)
|
||||
{
|
||||
this(
|
||||
transportAddress,
|
||||
@ -56,6 +56,7 @@ public class RemoteCandidate
|
||||
type,
|
||||
foundation,
|
||||
priority,
|
||||
relatedCandidate,
|
||||
null);
|
||||
}
|
||||
|
||||
@ -72,6 +73,10 @@ public class RemoteCandidate
|
||||
* by the session description protocol.
|
||||
* @param priority the <tt>RemoteCandidate</tt>'s priority as reported
|
||||
* 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
|
||||
*/
|
||||
public RemoteCandidate(
|
||||
@ -80,9 +85,10 @@ public class RemoteCandidate
|
||||
CandidateType type,
|
||||
String foundation,
|
||||
long priority,
|
||||
RemoteCandidate relatedCandidate,
|
||||
String ufrag)
|
||||
{
|
||||
super(transportAddress, parentComponent, type);
|
||||
super(transportAddress, parentComponent, type, relatedCandidate);
|
||||
setFoundation(foundation);
|
||||
setPriority(priority);
|
||||
this.ufrag = ufrag;
|
||||
@ -121,39 +127,6 @@ public class RemoteCandidate
|
||||
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.
|
||||
*
|
||||
@ -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.
|
||||
*/
|
||||
public TransportAddress getHostAddress()
|
||||
{
|
||||
switch (getType())
|
||||
{
|
||||
case SERVER_REFLEXIVE_CANDIDATE:
|
||||
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.
|
||||
* @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 This candidate reflexive address. Null if this candidate
|
||||
* does not use a peer/server reflexive 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 TransportAddress getReflexiveAddress()
|
||||
protected RemoteCandidate findRelatedCandidate(
|
||||
TransportAddress relatedAddress)
|
||||
{
|
||||
switch (getType())
|
||||
{
|
||||
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;
|
||||
}
|
||||
return getParentComponent().findRemoteCandidate(relatedAddress);
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,14 +52,12 @@ public class ServerReflexiveCandidate
|
||||
TransportAddress stunSrvrAddr,
|
||||
CandidateExtendedType extendedType)
|
||||
{
|
||||
super(address,
|
||||
base.getParentComponent(),
|
||||
CandidateType.SERVER_REFLEXIVE_CANDIDATE,
|
||||
extendedType);
|
||||
|
||||
setBase(base);
|
||||
setStunServerAddress(stunSrvrAddr);
|
||||
stunHarvest = null;
|
||||
this(
|
||||
address,
|
||||
base,
|
||||
stunSrvrAddr,
|
||||
null,
|
||||
extendedType);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -87,7 +85,8 @@ public class ServerReflexiveCandidate
|
||||
super(address,
|
||||
base.getParentComponent(),
|
||||
CandidateType.SERVER_REFLEXIVE_CANDIDATE,
|
||||
extendedType);
|
||||
extendedType,
|
||||
base);
|
||||
|
||||
setBase(base);
|
||||
setStunServerAddress(stunSrvrAddr);
|
||||
|
||||
@ -44,7 +44,8 @@ public class UPNPCandidate
|
||||
transportAddress,
|
||||
parentComponent,
|
||||
CandidateType.SERVER_REFLEXIVE_CANDIDATE,
|
||||
CandidateExtendedType.UPNP_CANDIDATE);
|
||||
CandidateExtendedType.UPNP_CANDIDATE,
|
||||
base);
|
||||
|
||||
this.setBase(base);
|
||||
this.device = device;
|
||||
|
||||
@ -245,7 +245,8 @@ public class Ice
|
||||
localComponent,
|
||||
rCand.getType(),
|
||||
rCand.getFoundation(),
|
||||
rCand.getPriority()));
|
||||
rCand.getPriority(),
|
||||
null));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -229,13 +229,9 @@ public class SdpUtils
|
||||
if(component == null)
|
||||
return null;
|
||||
|
||||
RemoteCandidate cand = new RemoteCandidate(transAddr, component, type,
|
||||
foundation, priority);
|
||||
|
||||
component.addRemoteCandidate(cand);
|
||||
|
||||
// check if there's a related address property
|
||||
|
||||
RemoteCandidate relatedCandidate = null;
|
||||
if (tokenizer.countTokens() >= 4)
|
||||
{
|
||||
tokenizer.nextToken(); // skip the raddr element
|
||||
@ -246,9 +242,14 @@ public class SdpUtils
|
||||
TransportAddress raddr = new TransportAddress(
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user