Removes the 'transport' field from Component, because an ICE component

might have candidates with different protocols. Removes a duplicate
method.
This commit is contained in:
boris 2014-08-29 08:27:03 +00:00
parent 9b9fbb71d0
commit 595727b406
3 changed files with 21 additions and 63 deletions

View File

@ -352,7 +352,7 @@ public class Agent
+ transport); + transport);
} }
Component component = stream.createComponent(transport); Component component = stream.createComponent();
gatherCandidates(component, preferredPort, minPort, maxPort); gatherCandidates(component, preferredPort, minPort, maxPort);

View File

@ -26,6 +26,7 @@ import org.ice4j.socket.*;
* *
* @author Emil Ivov * @author Emil Ivov
* @author Sebastien Vincent * @author Sebastien Vincent
* @author Boris Grozev
*/ */
public class Component public class Component
{ {
@ -35,19 +36,6 @@ public class Component
private static final Logger logger private static final Logger logger
= Logger.getLogger(Component.class.getName()); = Logger.getLogger(Component.class.getName());
/**
* A component id is a positive integer between 1 and 256 which identifies
* the specific component of the media stream for which this is a candidate.
* It MUST start at 1 and MUST increment by 1 for each component of a
* particular candidate. For media streams based on RTP, candidates for the
* actual RTP media MUST have a component ID of 1, and candidates for RTCP
* MUST have a component ID of 2. Other types of media streams which
* require multiple components MUST develop specifications which define the
* mapping of components to component IDs. See Section 14 for additional
* discussion on extending ICE to new media streams.
*/
private final int componentID;
/** /**
* The component ID to use with RTP streams. * The component ID to use with RTP streams.
*/ */
@ -59,9 +47,17 @@ public class Component
public static final int RTCP = 2; public static final int RTCP = 2;
/** /**
* The transport that this component is using. * A component id is a positive integer between 1 and 256 which identifies
* the specific component of the media stream for which this is a candidate.
* It MUST start at 1 and MUST increment by 1 for each component of a
* particular candidate. For media streams based on RTP, candidates for the
* actual RTP media MUST have a component ID of 1, and candidates for RTCP
* MUST have a component ID of 2. Other types of media streams which
* require multiple components MUST develop specifications which define the
* mapping of components to component IDs. See Section 14 of RFC5245 for
* additional discussion on extending ICE to new media streams.
*/ */
private final Transport transport; private final int componentID;
/** /**
* The <tt>IceMediaStream</tt> that this <tt>Component</tt> belongs to. * The <tt>IceMediaStream</tt> that this <tt>Component</tt> belongs to.
@ -77,14 +73,14 @@ public class Component
/** /**
* The list of candidates that the peer agent sent for this stream. * The list of candidates that the peer agent sent for this stream.
*/ */
private List<RemoteCandidate> remoteCandidates private final List<RemoteCandidate> remoteCandidates
= new LinkedList<RemoteCandidate>(); = new LinkedList<RemoteCandidate>();
/** /**
* The list of candidates that the peer agent sent for this stream after * The list of candidates that the peer agent sent for this stream after
* connectivity establishment. * connectivity establishment.
*/ */
private List<RemoteCandidate> remoteUpdateCandidates = private final List<RemoteCandidate> remoteUpdateCandidates =
new LinkedList<RemoteCandidate>(); new LinkedList<RemoteCandidate>();
/** /**
@ -114,21 +110,17 @@ public class Component
/** /**
* Creates a new <tt>Component</tt> with the specified <tt>componentID</tt> * Creates a new <tt>Component</tt> with the specified <tt>componentID</tt>
* as a child of the specified <tt>MediaStream</tt>. * as a child of the specified <tt>IceMediaStream</tt>.
* *
* @param componentID the id of this component. * @param componentID the id of this component.
* @param transport the protocol that this component will be using (e.g.
* TCP/UDP/TLS/DTLS).
* @param mediaStream the {@link IceMediaStream} instance that would be the * @param mediaStream the {@link IceMediaStream} instance that would be the
* parent of this component. * parent of this component.
*/ */
protected Component(int componentID, protected Component(int componentID,
Transport transport,
IceMediaStream mediaStream) IceMediaStream mediaStream)
{ {
// the max value for componentID is 256 // the max value for componentID is 256
this.componentID = componentID; this.componentID = componentID;
this.transport = transport;
this.parentStream = mediaStream; this.parentStream = mediaStream;
} }
@ -478,17 +470,6 @@ public class Component
return componentID; return componentID;
} }
/**
* Returns the transport protocol of this component
*
* @return a {@link Transport} instance representing the the transport
* protocol that this media stream <tt>Component</tt> uses.
*/
public Transport getTransport()
{
return transport;
}
/** /**
* Returns a <tt>String</tt> representation of this <tt>Component</tt> * Returns a <tt>String</tt> representation of this <tt>Component</tt>
* containing its ID, parent stream name and any existing candidates. * containing its ID, parent stream name and any existing candidates.
@ -683,7 +664,6 @@ public class Component
return null; return null;
} }
/** /**
* Returns the <tt>Candidate</tt> that has been selected as the default * Returns the <tt>Candidate</tt> that has been selected as the default
* for this <tt>Component</tt> or <tt>null</tt> if no such * for this <tt>Component</tt> or <tt>null</tt> if no such
@ -702,7 +682,7 @@ public class Component
/** /**
* Returns the <tt>Candidate</tt> that the remote party has reported as * Returns the <tt>Candidate</tt> that the remote party has reported as
* default for this <tt>Component</tt> or <tt>null</tt> if no such * default for this <tt>Component</tt> or <tt>null</tt> if no such
* <tt>Candidate</tt> has reported yet. A candidate is said to be * <tt>Candidate</tt> has been reported yet. A candidate is said to be
* default if it would be the target of media from a non-ICE peer; * default if it would be the target of media from a non-ICE peer;
* *
* @return the <tt>Candidate</tt> that the remote party has reported as * @return the <tt>Candidate</tt> that the remote party has reported as
@ -877,8 +857,8 @@ public class Component
* *
* @param remoteAddress the {@link TransportAddress} we are looking for. * @param remoteAddress the {@link TransportAddress} we are looking for.
* *
* @return the local <tt>LocalCandidate</tt> with the specified * @return the remote <tt>RemoteCandidate</tt> with the specified
* <tt>localAddress</tt> if it belongs to this component or <tt>null</tt> * <tt>remoteAddress</tt> if it belongs to this component or <tt>null</tt>
* if it doesn't. * if it doesn't.
*/ */
public RemoteCandidate findRemoteCandidate(TransportAddress remoteAddress) public RemoteCandidate findRemoteCandidate(TransportAddress remoteAddress)
@ -892,26 +872,6 @@ public class Component
return null; return null;
} }
/**
* Returns the number of host {@link Candidate}s in this <tt>Component</tt>.
*
* @return the number of host {@link Candidate}s in this <tt>Component</tt>.
*/
protected int coundHostCandidates()
{
int num = 0;
synchronized (localCandidates)
{
for(LocalCandidate cand : localCandidates)
{
if (cand.getType() == CandidateType.HOST_CANDIDATE)
num++;
}
}
return num;
}
/** /**
* Sets the {@link CandidatePair} selected for use by ICE processing and * Sets the {@link CandidatePair} selected for use by ICE processing and
* that the application would use. * that the application would use.

View File

@ -143,18 +143,16 @@ public class IceMediaStream
* when creating the component so make sure you keep that in mind in case * when creating the component so make sure you keep that in mind in case
* assigning a specific component ID is important to you. * assigning a specific component ID is important to you.
* *
* @param transport the transport protocol used by the component
*
* @return the newly created stream <tt>Component</tt> after adding it to * @return the newly created stream <tt>Component</tt> after adding it to
* the stream first. * the stream first.
*/ */
protected Component createComponent(Transport transport) protected Component createComponent()
{ {
Component component; Component component;
synchronized (components) synchronized (components)
{ {
component = new Component(++lastComponentID, transport, this); component = new Component(++lastComponentID, this);
components.put( components.put(
Integer.valueOf(component.getComponentID()), Integer.valueOf(component.getComponentID()),
component); component);
@ -609,7 +607,7 @@ public class IceMediaStream
synchronized (components) synchronized (components)
{ {
for(Component cmp : components.values()) for(Component cmp : components.values())
num += cmp.coundHostCandidates(); num += cmp.countLocalHostCandidates();
} }
return num; return num;