public class Component extends Object implements PropertyChangeListener
Modifier and Type | Field and Description |
---|---|
private CandidatePrioritizer |
candidatePrioritizer
A Comparator that we use for sorting Candidates by
their priority.
|
private static Logger |
classLogger
Our class logger.
|
private int |
componentID
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.
|
private ComponentSocket |
componentSocket
The
ComponentSocket instance which, if enabled, will serve as the
single socket instance for this Component , merging received
packets from all of its candidates. |
private LocalCandidate |
defaultCandidate
The default Candidate for this component or in other words, the
candidate that we would have used without ICE.
|
private Candidate<?> |
defaultRemoteCandidate
The default RemoteCandidate for this component or in other
words, the candidate that we would have used to communicate with the
remote peer if we hadn't been using ICE.
|
private Set<CandidatePair> |
keepAlivePairs
The set of pairs which this component wants to keep alive.
|
private KeepAliveStrategy |
keepAliveStrategy
The
KeepAliveStrategy used by this component to select which
pairs are to be kept alive. |
private List<LocalCandidate> |
localCandidates
The list locally gathered candidates for this media stream.
|
private Logger |
logger
|
private IceMediaStream |
parentStream
The IceMediaStream that this Component belongs to.
|
private List<RemoteCandidate> |
remoteCandidates
The list of candidates that the peer agent sent for this stream.
|
private List<RemoteCandidate> |
remoteUpdateCandidates
The list of candidates that the peer agent sent for this stream after
connectivity establishment.
|
static int |
RTCP
The component ID to use with RTCP streams.
|
static int |
RTP
The component ID to use with RTP streams.
|
private CandidatePair |
selectedPair
The pair that has been selected for use by ICE processing
|
private MultiplexingDatagramSocket |
socket
The public view of
componentSocket , wrapped in a
MultiplexingDatagramSocket for the convenience of users of the
library. |
private IceSocketWrapper |
socketWrapper
Deprecated.
|
Modifier | Constructor and Description |
---|---|
protected |
Component(int componentID,
IceMediaStream mediaStream,
KeepAliveStrategy keepAliveStrategy)
Deprecated.
|
protected |
Component(int componentID,
IceMediaStream mediaStream,
KeepAliveStrategy keepAliveStrategy,
boolean useComponentSocket)
Creates a new Component with the specified componentID
as a child of the specified IceMediaStream.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addLocalCandidate(LocalCandidate candidate)
Add a local candidate to this component.
|
void |
addRemoteCandidate(RemoteCandidate candidate)
Adds a remote Candidates to this media-stream
Component.
|
void |
addRemoteCandidates(List<RemoteCandidate> candidates)
Adds a List of remote Candidates as reported by a remote agent.
|
void |
addUpdateRemoteCandidates(RemoteCandidate candidate)
Update the media-stream Component with the specified
Candidates.
|
static Component |
build(int componentID,
IceMediaStream mediaStream)
Use builder pattern to allow creation of immutable Component instances,
from outside the current package.
|
int |
countLocalHostCandidates()
Returns the number of local host candidates currently registered in this
Component.
|
protected void |
eliminateRedundantCandidates()
Deprecated.
redundancies are now being detected upon addition of
candidates and calling this method is no longer necessary.
|
LocalCandidate |
findLocalCandidate(TransportAddress localAddress)
Returns the local LocalCandidate with the specified
localAddress if it belongs to this component or null
if it doesn't.
|
private LocalCandidate |
findRedundant(LocalCandidate cand)
Finds and returns the first candidate that is redundant to cand.
|
RemoteCandidate |
findRemoteCandidate(TransportAddress remoteAddress)
Returns the remote Candidate with the specified
remoteAddress if it belongs to this
Component or
null if it doesn't. |
protected void |
free()
Releases all resources allocated by this Component and its
Candidates like sockets for example.
|
private void |
free(LocalCandidate localCandidate)
Frees a specific LocalCandidate and swallows any
Throwable it throws while freeing itself in order to prevent its
failure to affect the rest of the execution.
|
int |
getComponentID()
Returns the ID of this Component.
|
ComponentSocket |
getComponentSocket() |
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.
|
Candidate<?> |
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.
|
(package private) Set<CandidatePair> |
getKeepAlivePairs() |
int |
getLocalCandidateCount()
Returns the number of all local candidates currently registered in this
Component.
|
List<LocalCandidate> |
getLocalCandidates()
Returns a copy of the list containing all local candidates currently
registered in this component.
|
String |
getName()
Returns a human readable name that can be used in debug logs associated
with this component.
|
IceMediaStream |
getParentStream()
Returns a reference to the IceMediaStream that this
Component belongs to.
|
int |
getRemoteCandidateCount()
Returns the number of all remote candidates currently registered in this
Component.
|
List<RemoteCandidate> |
getRemoteCandidates()
Returns a copy of the list containing all remote candidates currently
registered in this component.
|
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. |
MultiplexingDatagramSocket |
getSocket() |
IceSocketWrapper |
getSocketWrapper()
Deprecated.
Use
getSocket() directly. This is only introduced
to ease the transition of applications which are already written to use
a IceSocketWrapper instance. |
protected void |
prioritizeCandidates()
Deprecated.
candidates are now being prioritized upon addition and
calling this method is no longer necessary.
|
void |
propertyChange(PropertyChangeEvent event) |
protected void |
selectDefaultCandidate()
Selects a Candidate that should be considered as the default
for this Component.
|
void |
setDefaultRemoteCandidate(Candidate<?> candidate)
Sets the Candidate that the remote party has reported as
default for this Component.
|
protected void |
setSelectedPair(CandidatePair pair)
Sets the
CandidatePair selected for use by ICE processing and
that the application would use. |
String |
toShortString()
Returns a short String representation of this
Component.
|
String |
toString()
Returns a String representation of this Component
containing its ID, parent stream name and any existing candidates.
|
void |
updateRemoteCandidates()
Update ICE processing with new Candidates.
|
private static final Logger classLogger
IceMediaStream
, because it doesn't take into account the
per-instance log level.updateRemoteCandidates Instances should use logger
instead.public static final int RTP
public static final int RTCP
private final int componentID
private final IceMediaStream parentStream
private final List<LocalCandidate> localCandidates
private final List<RemoteCandidate> remoteCandidates
private final List<RemoteCandidate> remoteUpdateCandidates
private final CandidatePrioritizer candidatePrioritizer
private LocalCandidate defaultCandidate
private CandidatePair selectedPair
private Candidate<?> defaultRemoteCandidate
private final Logger logger
private final ComponentSocket componentSocket
ComponentSocket
instance which, if enabled, will serve as the
single socket instance for this Component
, merging received
packets from all of its candidates.private final MultiplexingDatagramSocket socket
componentSocket
, wrapped in a
MultiplexingDatagramSocket
for the convenience of users of the
library.
This is the instance which should be used by applications for
reading/writing application data.@Deprecated private final IceSocketWrapper socketWrapper
socket
, kept only to help preserve the old
API (see LocalCandidate.getIceSocketWrapper()
and
CandidatePair.getIceSocketWrapper()
)private final KeepAliveStrategy keepAliveStrategy
KeepAliveStrategy
used by this component to select which
pairs are to be kept alive.private final Set<CandidatePair> keepAlivePairs
protected Component(int componentID, IceMediaStream mediaStream, KeepAliveStrategy keepAliveStrategy)
componentID
- the id of this component.mediaStream
- the IceMediaStream
instance that would be the
parent of this component.protected Component(int componentID, IceMediaStream mediaStream, KeepAliveStrategy keepAliveStrategy, boolean useComponentSocket)
componentID
- the id of this component.mediaStream
- the IceMediaStream
instance that would be the
parent of this component.useComponentSocket
- whether the component socket should be used.public boolean addLocalCandidate(LocalCandidate candidate)
candidate
- the candidate object to be addedpublic List<LocalCandidate> getLocalCandidates()
public int countLocalHostCandidates()
public int getLocalCandidateCount()
public void addRemoteCandidate(RemoteCandidate candidate)
candidate
- the Candidate instance to add.public void addUpdateRemoteCandidates(RemoteCandidate candidate)
candidate
- new Candidate to add.public void updateRemoteCandidates()
public List<RemoteCandidate> getRemoteCandidates()
public void addRemoteCandidates(List<RemoteCandidate> candidates)
candidates
- the List of Candidates reported by
the remote agent for this component.public int getRemoteCandidateCount()
public IceMediaStream getParentStream()
public int getComponentID()
public String toString()
public String toShortString()
@Deprecated protected void prioritizeCandidates()
@Deprecated protected void eliminateRedundantCandidates()
private LocalCandidate findRedundant(LocalCandidate cand)
cand
- the LocalCandidate
that we'd like to check for
redundancies.public LocalCandidate getDefaultCandidate()
public Candidate<?> getDefaultRemoteCandidate()
public void setDefaultRemoteCandidate(Candidate<?> candidate)
candidate
- the Candidate that the remote party has
reported as default for this Component.protected void selectDefaultCandidate()
The ICE specification RECOMMENDEDs that default candidates be chosen based on the likelihood of those candidates to work with the peer that is being contacted. It is RECOMMENDED that the default candidates are the relayed candidates (if relayed candidates are available), server reflexive candidates (if server reflexive candidates are available), and finally host candidates.
protected void free()
private void free(LocalCandidate localCandidate)
localCandidate
- the LocalCandidate to be freedpublic LocalCandidate findLocalCandidate(TransportAddress localAddress)
localAddress
- the TransportAddress
we are looking for.public RemoteCandidate findRemoteCandidate(TransportAddress remoteAddress)
Component
or
null if it doesn't.remoteAddress
- the TransportAddress
we are looking for.protected void setSelectedPair(CandidatePair pair)
CandidatePair
selected for use by ICE processing and
that the application would use.pair
- the CandidatePair
selected for use by ICE processing.public CandidatePair getSelectedPair()
CandidatePair
selected for use by ICE processing or
null if no pair has been selected so far or if ICE processing
has failed.CandidatePair
selected for use by ICE processing or
null if no pair has been selected so far or if ICE processing
has failed.public String getName()
public static Component build(int componentID, IceMediaStream mediaStream)
componentID
- the id of this component.mediaStream
- the IceMediaStream
instance that would be the
parent of this component.public ComponentSocket getComponentSocket()
Component
which should be
used for reading and writing data, if the component socket is enabled
and null
if it is not enabled.
This is for ice4j internal use only! For reading/writing application
data, use getSocket()
.public MultiplexingDatagramSocket getSocket()
Component
, which should be used for
reading/writing application data. If the component socket is not enabled,
this returns null
and users of the library should use the socket
instance from the desired candidate pair instead.public IceSocketWrapper getSocketWrapper()
getSocket()
directly. This is only introduced
to ease the transition of applications which are already written to use
a IceSocketWrapper
instance.IceSocketWrapper
instance wrapping the socket for this
candidate (see getSocket()
).Set<CandidatePair> getKeepAlivePairs()
public void propertyChange(PropertyChangeEvent event)
propertyChange
in interface PropertyChangeListener
Copyright © 2018. All rights reserved.