From 595727b4061fcc503c940a552c89802b5ffa663a Mon Sep 17 00:00:00 2001 From: boris Date: Fri, 29 Aug 2014 08:27:03 +0000 Subject: [PATCH] Removes the 'transport' field from Component, because an ICE component might have candidates with different protocols. Removes a duplicate method. --- src/org/ice4j/ice/Agent.java | 2 +- src/org/ice4j/ice/Component.java | 74 ++++++--------------------- src/org/ice4j/ice/IceMediaStream.java | 8 ++- 3 files changed, 21 insertions(+), 63 deletions(-) diff --git a/src/org/ice4j/ice/Agent.java b/src/org/ice4j/ice/Agent.java index 1d79b67..70f363c 100644 --- a/src/org/ice4j/ice/Agent.java +++ b/src/org/ice4j/ice/Agent.java @@ -352,7 +352,7 @@ public class Agent + transport); } - Component component = stream.createComponent(transport); + Component component = stream.createComponent(); gatherCandidates(component, preferredPort, minPort, maxPort); diff --git a/src/org/ice4j/ice/Component.java b/src/org/ice4j/ice/Component.java index f5b7013..36d3a7e 100644 --- a/src/org/ice4j/ice/Component.java +++ b/src/org/ice4j/ice/Component.java @@ -26,6 +26,7 @@ import org.ice4j.socket.*; * * @author Emil Ivov * @author Sebastien Vincent + * @author Boris Grozev */ public class Component { @@ -35,19 +36,6 @@ public class Component private static final Logger logger = 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. */ @@ -59,9 +47,17 @@ public class Component 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 IceMediaStream that this Component belongs to. @@ -77,14 +73,14 @@ public class Component /** * The list of candidates that the peer agent sent for this stream. */ - private List remoteCandidates + private final List remoteCandidates = new LinkedList(); /** * The list of candidates that the peer agent sent for this stream after * connectivity establishment. */ - private List remoteUpdateCandidates = + private final List remoteUpdateCandidates = new LinkedList(); /** @@ -114,21 +110,17 @@ public class Component /** * Creates a new Component with the specified componentID - * as a child of the specified MediaStream. + * as a child of the specified IceMediaStream. * * @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 * parent of this component. */ protected Component(int componentID, - Transport transport, IceMediaStream mediaStream) { // the max value for componentID is 256 this.componentID = componentID; - this.transport = transport; this.parentStream = mediaStream; } @@ -478,17 +470,6 @@ public class Component return componentID; } - /** - * Returns the transport protocol of this component - * - * @return a {@link Transport} instance representing the the transport - * protocol that this media stream Component uses. - */ - public Transport getTransport() - { - return transport; - } - /** * Returns a String representation of this Component * containing its ID, parent stream name and any existing candidates. @@ -683,7 +664,6 @@ public class Component return null; } - /** * Returns the Candidate that has been selected as the default * for this Component or null if no such @@ -702,7 +682,7 @@ public class Component /** * Returns the Candidate that the remote party has reported as * default for this Component or null if no such - * Candidate has reported yet. A candidate is said to be + * Candidate has been reported yet. A candidate is said to be * default if it would be the target of media from a non-ICE peer; * * @return the Candidate that the remote party has reported as @@ -877,8 +857,8 @@ public class Component * * @param remoteAddress the {@link TransportAddress} we are looking for. * - * @return the local LocalCandidate with the specified - * localAddress if it belongs to this component or null + * @return the remote RemoteCandidate with the specified + * remoteAddress if it belongs to this component or null * if it doesn't. */ public RemoteCandidate findRemoteCandidate(TransportAddress remoteAddress) @@ -892,26 +872,6 @@ public class Component return null; } - /** - * Returns the number of host {@link Candidate}s in this Component. - * - * @return the number of host {@link Candidate}s in this Component. - */ - 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 * that the application would use. diff --git a/src/org/ice4j/ice/IceMediaStream.java b/src/org/ice4j/ice/IceMediaStream.java index 8ab668f..d63e677 100644 --- a/src/org/ice4j/ice/IceMediaStream.java +++ b/src/org/ice4j/ice/IceMediaStream.java @@ -143,18 +143,16 @@ public class IceMediaStream * when creating the component so make sure you keep that in mind in case * assigning a specific component ID is important to you. * - * @param transport the transport protocol used by the component - * * @return the newly created stream Component after adding it to * the stream first. */ - protected Component createComponent(Transport transport) + protected Component createComponent() { Component component; synchronized (components) { - component = new Component(++lastComponentID, transport, this); + component = new Component(++lastComponentID, this); components.put( Integer.valueOf(component.getComponentID()), component); @@ -609,7 +607,7 @@ public class IceMediaStream synchronized (components) { for(Component cmp : components.values()) - num += cmp.coundHostCandidates(); + num += cmp.countLocalHostCandidates(); } return num;