-
- All Implemented Interfaces:
-
java.beans.PropertyChangeListener
,java.util.EventListener
public class Component implements PropertyChangeListener
A component is a piece of a media stream requiring a single transport address; a media stream may require multiple components, each of which has to work for the media stream as a whole to work. For media streams based on RTP, there are two components per media stream - one for RTP, and one for RTCP.
-
-
Field Summary
Fields Modifier and Type Field Description public final static int
RTP
public final static int
RTCP
private final int
componentID
private final IceMediaStream
parentStream
private final List<LocalCandidate>
localCandidates
private final List<RemoteCandidate>
remoteCandidates
private LocalCandidate
defaultCandidate
private CandidatePair
selectedPair
private Candidate<out Object>
defaultRemoteCandidate
private final Logger
logger
private final ComponentSocket
componentSocket
private final MultiplexingDatagramSocket
socket
private final IceSocketWrapper
socketWrapper
-
Method Summary
Modifier and Type Method Description int
getComponentID()
Returns the ID of this Component. IceMediaStream
getParentStream()
Returns a reference to the IceMediaStream that this Component belongs to. List<LocalCandidate>
getLocalCandidates()
Returns a copy of the list containing all local candidates currently registered in this component. List<RemoteCandidate>
getRemoteCandidates()
Returns a copy of the list containing all remote candidates currently registered in this component. LocalCandidate
getDefaultCandidate()
Returns the Candidate that has been selected as the default for this Component or null if no such Candidate has been selected yet. CandidatePair
getSelectedPair()
Returns the CandidatePair selected for use by ICE processing or null if no pair has been selected so far or if ICE processing has failed. void
setSelectedPair(CandidatePair pair)
Sets the CandidatePair selected for use by ICE processing and that the application would use. Candidate<out Object>
getDefaultRemoteCandidate()
Returns the Candidate that the remote party has reported as default for this Component or null if no such Candidate has been reported yet. void
setDefaultRemoteCandidate(Candidate<out Object> candidate)
Sets the Candidate that the remote party has reported as default for this Component. Logger
getLogger()
ComponentSocket
getComponentSocket()
MultiplexingDatagramSocket
getSocket()
IceSocketWrapper
getSocketWrapper()
boolean
addLocalCandidate(LocalCandidate candidate)
Add a local candidate to this component. int
countLocalHostCandidates()
Returns the number of local host candidates currently registered in this Component. int
getLocalCandidateCount()
Returns the number of all local candidates currently registered in this Component. void
addRemoteCandidate(RemoteCandidate candidate)
Adds a remote Candidates to this media-stream Component. void
addUpdateRemoteCandidates(RemoteCandidate candidate)
Update the media-stream Component with the specified Candidates. void
updateRemoteCandidates()
Update ICE processing with new Candidates. void
addRemoteCandidates(List<RemoteCandidate> candidates)
Adds a List of remote Candidates as reported by a remote agent. int
getRemoteCandidateCount()
Returns the number of all remote candidates currently registered in this Component. String
toString()
Returns a String representation of this Component containing its ID, parent stream name and any existing candidates. String
toShortString()
Returns a short String representation of this Component. LocalCandidate
findLocalCandidate(TransportAddress localAddress)
Returns the local LocalCandidate with the specified localAddress if it belongs to this component or null if it doesn't. LocalCandidate
findLocalCandidate(TransportAddress address, LocalCandidate base)
Returns the local LocalCandidate with the specified address if it belongs to this component or null if it doesn't. RemoteCandidate
findRemoteCandidate(TransportAddress remoteAddress)
Returns the remote Candidate with the specified remoteAddress if it belongs to this Component or null if it doesn't. String
getName()
Returns a human readable name that can be used in debug logs associated with this component. static Component
build(int componentID, IceMediaStream mediaStream, Logger parentLogger)
Use builder pattern to allow creation of immutable Component instances, from outside the current package. void
propertyChange(PropertyChangeEvent event)
Handles events coming from candidate pairs. -
-
Method Detail
-
getComponentID
int getComponentID()
Returns the ID of this Component. For RTP/RTCP flows this would be 1 for RTP and 2 for RTCP.
-
getParentStream
IceMediaStream getParentStream()
Returns a reference to the IceMediaStream that this Component belongs to.
-
getLocalCandidates
List<LocalCandidate> getLocalCandidates()
Returns a copy of the list containing all local candidates currently registered in this component.
-
getRemoteCandidates
List<RemoteCandidate> getRemoteCandidates()
Returns a copy of the list containing all remote candidates currently registered in this component.
-
getDefaultCandidate
LocalCandidate getDefaultCandidate()
Returns the Candidate that has been selected as the default for this Component or null if no such Candidate has been selected yet. A candidate is said to be default if it would be the target of media from a non-ICE peer;
-
getSelectedPair
CandidatePair getSelectedPair()
Returns the CandidatePair selected for use by ICE processing or null if no pair has been selected so far or if ICE processing has failed.
-
setSelectedPair
void setSelectedPair(CandidatePair pair)
Sets the CandidatePair selected for use by ICE processing and that the application would use.
- Parameters:
pair
- the CandidatePair selected for use by ICE processing.
-
getDefaultRemoteCandidate
Candidate<out Object> getDefaultRemoteCandidate()
Returns the Candidate that the remote party has reported as default for this Component or null if no such 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;
-
setDefaultRemoteCandidate
void setDefaultRemoteCandidate(Candidate<out Object> candidate)
Sets the Candidate that the remote party has reported as default for this Component. A candidate is said to be default if it would be the target of media from a non-ICE peer;
- Parameters:
candidate
- the Candidate that the remote party has reported as default for this Component.
-
getLogger
Logger getLogger()
-
getComponentSocket
ComponentSocket getComponentSocket()
-
getSocket
MultiplexingDatagramSocket getSocket()
-
getSocketWrapper
IceSocketWrapper getSocketWrapper()
-
addLocalCandidate
boolean addLocalCandidate(LocalCandidate candidate)
Add a local candidate to this component. The method should only be accessed and local candidates added by the candidate harvesters registered with the agent.
- Parameters:
candidate
- the candidate object to be added
-
countLocalHostCandidates
int countLocalHostCandidates()
Returns the number of local host candidates currently registered in this Component.
-
getLocalCandidateCount
int getLocalCandidateCount()
Returns the number of all local candidates currently registered in this Component.
-
addRemoteCandidate
void addRemoteCandidate(RemoteCandidate candidate)
Adds a remote Candidates to this media-stream Component.
- Parameters:
candidate
- the Candidate instance to add.
-
addUpdateRemoteCandidates
void addUpdateRemoteCandidates(RemoteCandidate candidate)
Update the media-stream Component with the specified Candidates. This would happen when performing trickle ICE.
- Parameters:
candidate
- new Candidate to add.
-
updateRemoteCandidates
void updateRemoteCandidates()
Update ICE processing with new Candidates.
-
addRemoteCandidates
void addRemoteCandidates(List<RemoteCandidate> candidates)
Adds a List of remote Candidates as reported by a remote agent.
- Parameters:
candidates
- the List of Candidates reported by the remote agent for this component.
-
getRemoteCandidateCount
int getRemoteCandidateCount()
Returns the number of all remote candidates currently registered in this Component.
-
toString
String toString()
Returns a String representation of this Component containing its ID, parent stream name and any existing candidates.
-
toShortString
String toShortString()
Returns a short String representation of this Component.
-
findLocalCandidate
LocalCandidate findLocalCandidate(TransportAddress localAddress)
Returns the local LocalCandidate with the specified localAddress if it belongs to this component or null if it doesn't.
- Parameters:
localAddress
- the TransportAddress we are looking for.
-
findLocalCandidate
LocalCandidate findLocalCandidate(TransportAddress address, LocalCandidate base)
Returns the local LocalCandidate with the specified address if it belongs to this component or null if it doesn't. If
base
is also specified, tries to find a candidate whose base matchesbase
.- Parameters:
address
- the TransportAddress we are looking for.base
- an optional base to match.
-
findRemoteCandidate
RemoteCandidate findRemoteCandidate(TransportAddress remoteAddress)
Returns the remote Candidate with the specified remoteAddress if it belongs to this Component or null if it doesn't.
- Parameters:
remoteAddress
- the TransportAddress we are looking for.
-
getName
String getName()
Returns a human readable name that can be used in debug logs associated with this component.
-
build
static Component build(int componentID, IceMediaStream mediaStream, Logger parentLogger)
Use builder pattern to allow creation of immutable Component instances, from outside the current package.
- Parameters:
componentID
- the id of this component.mediaStream
- the IceMediaStream instance that would be the parent of this component.
-
propertyChange
void propertyChange(PropertyChangeEvent event)
Handles events coming from candidate pairs.
-
-
-
-