Adds CandidateExtendedType to list the different available methods to discover new Candidates: HOST, UPNP, STUN_PEER_REFLEXIVE, STUN_SERVER_REFLEXIVE, TURN_RELAYED, GOOGLE_TURN_RELAYED, GOOGLE_TCP_TURN_RELAYED and JINGLE_NODE.
This commit is contained in:
parent
e7aafa2e1a
commit
c6f54124d5
134
src/org/ice4j/ice/CandidateExtendedType.java
Normal file
134
src/org/ice4j/ice/CandidateExtendedType.java
Normal file
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* ice4j, the OpenSource Java Solution for NAT and Firewall Traversal.
|
||||
* Maintained by the SIP Communicator community (http://sip-communicator.org).
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package org.ice4j.ice;
|
||||
|
||||
/**
|
||||
* Enumeration which lists the different available methods used to discover new
|
||||
* candidates.
|
||||
*
|
||||
* @author Vincent Lucas
|
||||
*/
|
||||
public enum CandidateExtendedType
|
||||
{
|
||||
/**
|
||||
* There candidate is discovered directly by the host.
|
||||
*/
|
||||
HOST_CANDIDATE("host"),
|
||||
|
||||
/**
|
||||
* There candidate is discovered by using UPNP method.
|
||||
*/
|
||||
UPNP_CANDIDATE("upnp"),
|
||||
|
||||
/**
|
||||
* There candidate is discovered by using STUN peer reflexive method (cf.
|
||||
* RFC5389).
|
||||
*/
|
||||
STUN_PEER_REFLEXIVE_CANDIDATE("stun peer reflexive"),
|
||||
|
||||
/**
|
||||
* There candidate is discovered by using STUN server reflexive method (cf.
|
||||
* RFC5389).
|
||||
*/
|
||||
STUN_SERVER_REFLEXIVE_CANDIDATE("stun server reflexive"),
|
||||
|
||||
/**
|
||||
* There candidate is discovered by using TURN relayed method (cf. RFC5766).
|
||||
*/
|
||||
TURN_RELAYED_CANDIDATE("turn relayed"),
|
||||
|
||||
/**
|
||||
* There candidate is discovered by using TURN relayed method (cf. RFC5766).
|
||||
*/
|
||||
GOOGLE_TURN_RELAYED_CANDIDATE("google turn relayed"),
|
||||
|
||||
/**
|
||||
* There candidate is discovered by using TURN relayed method and using TCP
|
||||
* (cf. RFC5766).
|
||||
*/
|
||||
GOOGLE_TCP_TURN_RELAYED_CANDIDATE("google tcp turn relayed"),
|
||||
|
||||
/**
|
||||
* There candidate is discovered by using JINGLE NODE method (cf. XEP-0278).
|
||||
*/
|
||||
JINGLE_NODE_CANDIDATE("jingle node");
|
||||
|
||||
/**
|
||||
* The name of this <tt>CandidateExtendedType</tt> instance.
|
||||
*/
|
||||
private final String extendedTypeName;
|
||||
|
||||
/**
|
||||
* Creates a <tt>CandidateExtendedType</tt> instance with the specified
|
||||
* name.
|
||||
*
|
||||
* @param extendedTypeName the name of the <tt>CandidateExtendedType</tt>
|
||||
* instance we'd like to create.
|
||||
*/
|
||||
private CandidateExtendedType(String extendedTypeName)
|
||||
{
|
||||
this.extendedTypeName = extendedTypeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of this <tt>CandidateExtendedType</tt> (e.g. "host",
|
||||
* "upnp", "stun peer reflexive", "stun server reflexive", "turn relayed",
|
||||
* "google turn relayed" or "jingle node").
|
||||
*
|
||||
* @return The name of this <tt>CandidateExtendedType</tt> (e.g. "host",
|
||||
* "upnp", "stun peer reflexive", "stun server reflexive", "turn relayed",
|
||||
* "google turn relayed", "google tcp turn relayed" or "jingle node").
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return extendedTypeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a <tt>CandidateExtendedType</tt> instance corresponding to the
|
||||
* specified <tt>extendedTypeName</tt>. For example, for name "host", this
|
||||
* method would return {@link #HOST_CANDIDATE}.
|
||||
*
|
||||
* @param extendedTypeName the name that we'd like to parse.
|
||||
*
|
||||
* @return a <tt>CandidateExtendedType</tt> instance corresponding to the
|
||||
* specified <tt>extendedTypeName</tt>.
|
||||
*
|
||||
* @throws IllegalArgumentException in case <tt>extendedTypeName</tt> is
|
||||
* not a valid or currently supported candidate extended type.
|
||||
*/
|
||||
public static CandidateExtendedType parse(String extendedTypeName)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
if(HOST_CANDIDATE.toString().equals(extendedTypeName))
|
||||
return HOST_CANDIDATE;
|
||||
else if(UPNP_CANDIDATE.toString().equals(extendedTypeName))
|
||||
return UPNP_CANDIDATE;
|
||||
else if(STUN_PEER_REFLEXIVE_CANDIDATE.toString().equals(
|
||||
extendedTypeName))
|
||||
return STUN_PEER_REFLEXIVE_CANDIDATE;
|
||||
else if(STUN_SERVER_REFLEXIVE_CANDIDATE.toString().equals(
|
||||
extendedTypeName))
|
||||
return STUN_SERVER_REFLEXIVE_CANDIDATE;
|
||||
else if(TURN_RELAYED_CANDIDATE.toString().equals(extendedTypeName))
|
||||
return TURN_RELAYED_CANDIDATE;
|
||||
else if(GOOGLE_TURN_RELAYED_CANDIDATE.toString().equals(
|
||||
extendedTypeName))
|
||||
return GOOGLE_TURN_RELAYED_CANDIDATE;
|
||||
else if(GOOGLE_TCP_TURN_RELAYED_CANDIDATE.toString().equals(
|
||||
extendedTypeName))
|
||||
return GOOGLE_TCP_TURN_RELAYED_CANDIDATE;
|
||||
else if(JINGLE_NODE_CANDIDATE.toString().equals(extendedTypeName))
|
||||
return JINGLE_NODE_CANDIDATE;
|
||||
|
||||
throw new IllegalArgumentException(
|
||||
extendedTypeName
|
||||
+ " is not a currently supported CandidateExtendedType");
|
||||
}
|
||||
}
|
||||
@ -80,7 +80,14 @@ public class GoogleRelayedCandidate
|
||||
super(
|
||||
transportAddress,
|
||||
turnCandidateHarvest.hostCandidate.getParentComponent(),
|
||||
CandidateType.RELAYED_CANDIDATE);
|
||||
CandidateType.RELAYED_CANDIDATE,
|
||||
CandidateExtendedType.GOOGLE_TURN_RELAYED_CANDIDATE);
|
||||
|
||||
if(transportAddress.getTransport() == Transport.TCP)
|
||||
{
|
||||
super.setExtendedType(
|
||||
CandidateExtendedType.GOOGLE_TCP_TURN_RELAYED_CANDIDATE);
|
||||
}
|
||||
|
||||
this.turnCandidateHarvest = turnCandidateHarvest;
|
||||
this.username = username;
|
||||
@ -190,4 +197,4 @@ public class GoogleRelayedCandidate
|
||||
}
|
||||
return socket;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,7 +49,8 @@ public class HostCandidate extends LocalCandidate
|
||||
super(new TransportAddress(socket.getLocalAddress(),
|
||||
socket.getLocalPort(), Transport.UDP),
|
||||
parentComponent,
|
||||
CandidateType.HOST_CANDIDATE);
|
||||
CandidateType.HOST_CANDIDATE,
|
||||
CandidateExtendedType.HOST_CANDIDATE);
|
||||
|
||||
this.socket = socket;
|
||||
setBase(this);
|
||||
@ -71,7 +72,8 @@ public class HostCandidate extends LocalCandidate
|
||||
super(new TransportAddress(socket.getLocalAddress(),
|
||||
socket.getLocalPort(), transport),
|
||||
parentComponent,
|
||||
CandidateType.HOST_CANDIDATE);
|
||||
CandidateType.HOST_CANDIDATE,
|
||||
CandidateExtendedType.HOST_CANDIDATE);
|
||||
|
||||
this.socket = socket;
|
||||
setBase(this);
|
||||
|
||||
@ -25,6 +25,13 @@ import org.ice4j.stack.*;
|
||||
public abstract class LocalCandidate
|
||||
extends Candidate
|
||||
{
|
||||
/**
|
||||
* The type of method used to discover this candidate ("host", "upnp", "stun
|
||||
* peer reflexive", "stun server reflexive", "turn relayed", "google turn
|
||||
* relayed", "google tcp turn relayed" or "jingle node").
|
||||
*/
|
||||
private CandidateExtendedType extendedType = null;
|
||||
|
||||
/**
|
||||
* Ufrag for the local candidat
|
||||
*/
|
||||
@ -46,12 +53,18 @@ public abstract class LocalCandidate
|
||||
* @param parentComponent the <tt>Component</tt> that this candidate
|
||||
* belongs to.
|
||||
* @param type the <tt>CandidateType</tt> for this <tt>Candidate</tt>.
|
||||
* @param extendedType The type of method used to discover this candidate
|
||||
* ("host", "upnp", "stun peer reflexive", "stun server reflexive", "turn
|
||||
* relayed", "google turn relayed", "google tcp turn relayed" or "jingle
|
||||
* node").
|
||||
*/
|
||||
public LocalCandidate(TransportAddress transportAddress,
|
||||
Component parentComponent,
|
||||
CandidateType type)
|
||||
CandidateType type,
|
||||
CandidateExtendedType extendedType)
|
||||
{
|
||||
super(transportAddress, parentComponent, type);
|
||||
this.extendedType = extendedType;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -306,4 +319,33 @@ public abstract class LocalCandidate
|
||||
{
|
||||
return ufrag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of method used to discover this candidate ("host",
|
||||
* "upnp", "stun peer reflexive", "stun server reflexive", "turn relayed",
|
||||
* "google turn relayed", "google tcp turn relayed" or "jingle node").
|
||||
*
|
||||
* @return The type of method used to discover this candidate ("host",
|
||||
* "upnp", "stun peer reflexive", "stun server reflexive", "turn relayed",
|
||||
* "google turn relayed", "google tcp turn relayed" or "jingle node").
|
||||
*/
|
||||
public CandidateExtendedType getExtendedType()
|
||||
{
|
||||
return this.extendedType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of method used to discover this candidate ("host", "upnp",
|
||||
* "stun peer reflexive", "stun server reflexive", "turn relayed", "google
|
||||
* turn relayed", "google tcp turn relayed" or "jingle node").
|
||||
*
|
||||
* @param extendedType The type of method used to discover this candidate
|
||||
* ("host", "upnp", "stun peer reflexive", "stun server reflexive", "turn
|
||||
* relayed", "google turn relayed", "google tcp turn relayed" or "jingle
|
||||
* node").
|
||||
*/
|
||||
public void setExtendedType(CandidateExtendedType extendedType)
|
||||
{
|
||||
this.extendedType = extendedType;
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,8 +42,11 @@ public class PeerReflexiveCandidate
|
||||
LocalCandidate base,
|
||||
long priority)
|
||||
{
|
||||
super(transportAddress, parentComponent,
|
||||
CandidateType.PEER_REFLEXIVE_CANDIDATE);
|
||||
super(
|
||||
transportAddress,
|
||||
parentComponent,
|
||||
CandidateType.PEER_REFLEXIVE_CANDIDATE,
|
||||
CandidateExtendedType.STUN_PEER_REFLEXIVE_CANDIDATE);
|
||||
super.setBase(base);
|
||||
super.priority = priority;
|
||||
}
|
||||
|
||||
@ -66,7 +66,8 @@ public class RelayedCandidate
|
||||
super(
|
||||
transportAddress,
|
||||
turnCandidateHarvest.hostCandidate.getParentComponent(),
|
||||
CandidateType.RELAYED_CANDIDATE);
|
||||
CandidateType.RELAYED_CANDIDATE,
|
||||
CandidateExtendedType.TURN_RELAYED_CANDIDATE);
|
||||
|
||||
this.turnCandidateHarvest = turnCandidateHarvest;
|
||||
|
||||
|
||||
@ -42,14 +42,20 @@ public class ServerReflexiveCandidate
|
||||
* candidate was obtained through.
|
||||
* @param stunSrvrAddr the {@link TransportAddress} of the stun server that
|
||||
* reflected this candidate.
|
||||
* @param extendedType The type of method used to discover this candidate
|
||||
* ("host", "upnp", "stun peer reflexive", "stun server reflexive", "turn
|
||||
* relayed", "google turn relayed", "google tcp turn relayed" or "jingle
|
||||
* node").
|
||||
*/
|
||||
public ServerReflexiveCandidate(TransportAddress address,
|
||||
HostCandidate base,
|
||||
TransportAddress stunSrvrAddr)
|
||||
TransportAddress stunSrvrAddr,
|
||||
CandidateExtendedType extendedType)
|
||||
{
|
||||
super(address,
|
||||
base.getParentComponent(),
|
||||
CandidateType.SERVER_REFLEXIVE_CANDIDATE);
|
||||
CandidateType.SERVER_REFLEXIVE_CANDIDATE,
|
||||
extendedType);
|
||||
|
||||
setBase(base);
|
||||
setStunServerAddress(stunSrvrAddr);
|
||||
@ -67,15 +73,21 @@ public class ServerReflexiveCandidate
|
||||
* @param stunSrvrAddr the {@link TransportAddress} of the stun server that
|
||||
* reflected this candidate.
|
||||
* @param stunHarvest the {@link StunCandidateHarvest}
|
||||
* @param extendedType The type of method used to discover this candidate
|
||||
* ("host", "upnp", "stun peer reflexive", "stun server reflexive", "turn
|
||||
* relayed", "google turn relayed", "google tcp turn relayed" or "jingle
|
||||
* node").
|
||||
*/
|
||||
public ServerReflexiveCandidate(TransportAddress address,
|
||||
HostCandidate base,
|
||||
TransportAddress stunSrvrAddr,
|
||||
StunCandidateHarvest stunHarvest)
|
||||
StunCandidateHarvest stunHarvest,
|
||||
CandidateExtendedType extendedType)
|
||||
{
|
||||
super(address,
|
||||
base.getParentComponent(),
|
||||
CandidateType.SERVER_REFLEXIVE_CANDIDATE);
|
||||
CandidateType.SERVER_REFLEXIVE_CANDIDATE,
|
||||
extendedType);
|
||||
|
||||
setBase(base);
|
||||
setStunServerAddress(stunSrvrAddr);
|
||||
|
||||
@ -40,8 +40,11 @@ public class UPNPCandidate
|
||||
LocalCandidate base, Component parentComponent,
|
||||
GatewayDevice device)
|
||||
{
|
||||
super(transportAddress, parentComponent,
|
||||
CandidateType.SERVER_REFLEXIVE_CANDIDATE);
|
||||
super(
|
||||
transportAddress,
|
||||
parentComponent,
|
||||
CandidateType.SERVER_REFLEXIVE_CANDIDATE,
|
||||
CandidateExtendedType.UPNP_CANDIDATE);
|
||||
|
||||
this.setBase(base);
|
||||
this.device = device;
|
||||
|
||||
@ -391,7 +391,8 @@ public class StunCandidateHarvest
|
||||
new ServerReflexiveCandidate(
|
||||
transportAddress,
|
||||
hostCandidate,
|
||||
harvester.stunServer);
|
||||
harvester.stunServer,
|
||||
CandidateExtendedType.STUN_SERVER_REFLEXIVE_CANDIDATE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user