public class IceMediaStream extends Object
Modifier and Type | Field and Description |
---|---|
private CheckList |
checkList
The CHECK-LIST for this agent described in the ICE specification: There
is one check list per in-use media stream resulting from the offer/answer
exchange.
|
private static Logger |
classLogger
Our class logger
Note that this shouldn't be used directly by instances of
IceMediaStream , because it doesn't take into account the
per-instance log level. |
private Map<Integer,Component> |
components
Returns the list of components that this media stream consists of.
|
private int |
lastComponentID
The id that was last assigned to a component.
|
private Logger |
logger
The
Logger used by IceMediaStream instances. |
private int |
maxCheckListSize
The maximum number of candidate pairs that we should have in our check
list.
|
private String |
name
The name of this media stream.
|
private Agent |
parentAgent
The agent that this media stream belongs to.
|
static String |
PROPERTY_PAIR_CONSENT_FRESHNESS_CHANGED
The property name that we use when delivering events notifying listeners
that the consent freshness of a pair has changed.
|
static String |
PROPERTY_PAIR_NOMINATED
The property name that we use when delivering events notifying listeners
of newly nominated pairs.
|
static String |
PROPERTY_PAIR_STATE_CHANGED
The property name that we use when delivering events notifying listeners
that a pair has changed states.
|
static String |
PROPERTY_PAIR_VALIDATED
The property name that we use when delivering events notifying listeners
of newly validated pairs.
|
private String |
remotePassword
The password that we received from the remote party.
|
private String |
remoteUfrag
The user fragment that we received from the remote party.
|
private List<PropertyChangeListener> |
streamListeners
Contains
PropertyChangeListener s registered with this Agent and following the various events it may be generating. |
private TreeSet<CandidatePair> |
validList
An ordered set of candidate pairs for a media stream that have been
validated by a successful STUN transaction.
|
Modifier | Constructor and Description |
---|---|
protected |
IceMediaStream(Agent parentAgent,
String name)
Initializes a new IceMediaStream object.
|
Modifier and Type | Method and Description |
---|---|
void |
addPairChangeListener(PropertyChangeListener l)
Adds l to the list of listeners registered for property changes
if
CandidatePair s. |
protected void |
addToCheckList(CandidatePair candidatePair)
Adds candidatePair to this stream's check list.
|
protected void |
addToValidList(CandidatePair pair)
Adds pair to the valid list that this stream is
maintaining.
|
protected boolean |
allComponentsAreNominated()
Returns true if there is at least one nominated
CandidatePair in the valid list for every Component of this
stream and false otherwise. |
protected boolean |
allComponentsHaveSelected()
Returns false if there is at least one nominated
CandidatePair who doesn't have a selected address yet, and true
otherwise. |
static IceMediaStream |
build(Agent parentAgent,
String name)
Use builder pattern to provide an immutable IceMediaStream instance.
|
protected int |
countHostCandidates()
Returns the number of host
Candidate s in this stream. |
private void |
createCheckList(Component component,
List<CandidatePair> checkList)
Creates and adds to checkList all the CandidatePairs
in component.
|
protected void |
createCheckList(List<CandidatePair> checkList)
Creates and adds to checkList all the CandidatePairs
in all Components of this stream.
|
protected Component |
createComponent(KeepAliveStrategy keepAliveStrategy,
boolean useComponentSocket)
Creates and adds a component to this media-stream
The component ID is incremented to the next integer value
when creating the component so make sure you keep that in mind in case
assigning a specific component ID is important to you.
|
CandidatePair |
findCandidatePair(String localUFrag,
String remoteUFrag)
Returns the
CandidatePair with the specified remote and local
addresses or null if neither of the CheckList s in this
stream contain such a pair. |
CandidatePair |
findCandidatePair(TransportAddress localAddress,
TransportAddress remoteAddress)
Returns the
CandidatePair with the specified remote and local
addresses or null if neither of the CheckList s in this
stream contain such a pair. |
LocalCandidate |
findLocalCandidate(TransportAddress localAddress)
Returns the local LocalCandidate with the specified
localAddress if it belongs to any of this stream's components
or null otherwise.
|
RemoteCandidate |
findRemoteCandidate(TransportAddress remoteAddress)
Returns the local Candidate with the specified
remoteAddress if it belongs to any of this stream's
Component s or null if it doesn't. |
protected void |
firePairPropertyChange(CandidatePair source,
String propertyName,
Object oldValue,
Object newValue)
Creates a new
PropertyChangeEvent and delivers it to all
currently registered state listeners. |
protected void |
free()
Removes this stream and all Candidates associated with its child
Components.
|
CheckList |
getCheckList()
Returns the list of CandidatePairs to be used in checks for
this stream.
|
Component |
getComponent(int id)
Returns the Component with the specified id or
null if no such component exists in this stream.
|
int |
getComponentCount()
Returns the number of Components currently registered with this
stream.
|
List<Integer> |
getComponentIDs()
Returns the IDs of all Components currently registered with this
stream.
|
List<Component> |
getComponents()
Returns the list of Components currently registered with this
stream.
|
String |
getName()
Returns the name of this IceMediaStream.
|
Agent |
getParentAgent()
Returns a reference to the Agent that this stream belongs to.
|
String |
getRemotePassword()
Returns the password that we received from the remote peer or
null if we haven't received a password from them yet.
|
String |
getRemoteUfrag()
Returns the user name that we received from the remote peer or
null if we haven't received a user name from them yet.
|
protected CandidatePair |
getValidPair(Component component)
Returns the first
CandidatePair stored in this stream's valid
list, that belongs to the specified component. |
protected void |
initCheckList()
Creates, initializes and orders the list of candidate pairs that would
be used for the connectivity checks for all components in this stream.
|
private void |
orderCheckList()
Orders this stream's pair check list in decreasing order of pair
priority.
|
protected void |
pruneCheckList(List<CandidatePair> checkList)
Removes or, as per the ICE spec, "prunes" pairs that we don't need to
run checks for.
|
void |
removeComponent(Component component)
Removes component and all its Candidates from the
this stream and releases all associated resources that they had
allocated (like sockets for example)
|
void |
removePairStateChangeListener(PropertyChangeListener l)
Removes l from the list of listeners registered for property
changes.
|
protected void |
setMaxCheckListSize(int nSize)
Sets the maximum number of pairs that we should have in our check list.
|
void |
setRemotePassword(String remotePassword)
Specifies the password that we received from the remote peer.
|
void |
setRemoteUfrag(String remoteUfrag)
Specifies the user name that we received from the remote peer.
|
String |
toString()
Returns a String representation of this media stream.
|
protected boolean |
validListContainsAllComponents()
Returns true if this stream's valid list contains at least
one
CandidatePair for each Component of the stream and
false otherwise. |
protected boolean |
validListContainsFoundation(String foundation)
Returns true if this stream's validList contains a
pair with the specified foundation and false otherwise.
|
protected boolean |
validListContainsNomineeForComponent(Component component)
Returns true if this stream's validList contains a
pair that is nominated for the specified Component and
false otherwise.
|
private static final Logger classLogger
IceMediaStream
, because it doesn't take into account the
per-instance log level. Instances should use logger
instead.public static final String PROPERTY_PAIR_CONSENT_FRESHNESS_CHANGED
public static final String PROPERTY_PAIR_NOMINATED
public static final String PROPERTY_PAIR_STATE_CHANGED
public static final String PROPERTY_PAIR_VALIDATED
private final String name
private final Map<Integer,Component> components
private final TreeSet<CandidatePair> validList
private int lastComponentID
private final CheckList checkList
private final Agent parentAgent
private final List<PropertyChangeListener> streamListeners
PropertyChangeListener
s registered with this Agent
and following the various events it may be generating.private int maxCheckListSize
private String remoteUfrag
private String remotePassword
private Logger logger
Logger
used by IceMediaStream
instances.public static IceMediaStream build(Agent parentAgent, String name)
name
- the name of the media streamparentAgent
- the agent that is handling the session that this
media stream is a part ofprotected Component createComponent(KeepAliveStrategy keepAliveStrategy, boolean useComponentSocket)
keepAliveStrategy
- the keep-alive strategy, which dictates which
candidates pairs are going to be kept alive.useComponentSocket
- whether the "component socket" should be used
or not. See StackProperties.USE_COMPONENT_SOCKET
.public String getName()
public String toString()
public Component getComponent(int id)
id
- the identifier of the component we are looking for.public List<Component> getComponents()
public int getComponentCount()
public List<Integer> getComponentIDs()
public Agent getParentAgent()
protected void free()
public void removeComponent(Component component)
component
- the Component we'd like to remove and free.protected void initCheckList()
protected void createCheckList(List<CandidatePair> checkList)
checkList
- the list that we need to update with the new pairs.private void createCheckList(Component component, List<CandidatePair> checkList)
component
- the Component whose candidates we need to
pair and extract.checkList
- the list that we need to update with the new pairs.private void orderCheckList()
protected void pruneCheckList(List<CandidatePair> checkList)
checkList
- the checklist to prunepublic CheckList getCheckList()
protected void setMaxCheckListSize(int nSize)
nSize
- the size of our check list.public LocalCandidate findLocalCandidate(TransportAddress localAddress)
localAddress
- the TransportAddress
we are looking for.public RemoteCandidate findRemoteCandidate(TransportAddress remoteAddress)
Component
s or null if it doesn't.remoteAddress
- the TransportAddress
we are looking for.Component
s or null if it doesn't.public CandidatePair findCandidatePair(TransportAddress localAddress, TransportAddress remoteAddress)
CandidatePair
with the specified remote and local
addresses or null if neither of the CheckList
s in this
stream contain such a pair.localAddress
- the local TransportAddress
of the pair we
are looking for.remoteAddress
- the remote TransportAddress
of the pair we
are looking for.CandidatePair
with the specified remote and local
addresses or null if neither of the CheckList
s in this
stream contain such a pair.public CandidatePair findCandidatePair(String localUFrag, String remoteUFrag)
CandidatePair
with the specified remote and local
addresses or null if neither of the CheckList
s in this
stream contain such a pair.localUFrag
- local user fragmentremoteUFrag
- remote user fragmentCandidatePair
with the specified remote and local
addresses or null if neither of the CheckList
s in this
stream contain such a pair.protected int countHostCandidates()
Candidate
s in this stream.Candidate
s in this stream.protected void addToCheckList(CandidatePair candidatePair)
candidatePair
- the pair that we'd like to add to this streams.protected void addToValidList(CandidatePair pair)
pair
- the CandidatePair
to add to our valid list.protected boolean validListContainsFoundation(String foundation)
foundation
- the foundation String we'd like to search our
validList for.protected boolean validListContainsNomineeForComponent(Component component)
component
- the Component we'd like to search our
validList for.protected boolean validListContainsAllComponents()
CandidatePair
for each Component
of the stream and
false otherwise.CandidatePair
for each Component
of the stream and
false otherwise.protected boolean allComponentsAreNominated()
CandidatePair
in the valid list for every Component
of this
stream and false otherwise.CandidatePair
in the valid list for every Component
of this
stream and false otherwise.protected boolean allComponentsHaveSelected()
CandidatePair
who doesn't have a selected address yet, and true
otherwise.CandidatePair
who doesn't have a selected address yet, and true
otherwise.protected CandidatePair getValidPair(Component component)
CandidatePair
stored in this stream's valid
list, that belongs to the specified component.component
- the Component
we'd like to obtain a valid
pair for.CandidatePair
for the specified
component if at least one exists, and null otherwise.public void addPairChangeListener(PropertyChangeListener l)
CandidatePair
s. We add such listeners in the stream, rather
than having them in the candidate pair itself, because we don't want all
pairs to keep lists of references to the same listeners.l
- the listener to register.public void removePairStateChangeListener(PropertyChangeListener l)
l
- the listener to remove.protected void firePairPropertyChange(CandidatePair source, String propertyName, Object oldValue, Object newValue)
PropertyChangeEvent
and delivers it to all
currently registered state listeners.source
- the CandidatePair
whose property has just changed.propertyName
- the name of the property that changed.oldValue
- the old value of the property that changed.newValue
- the new value of the property that changed.public void setRemoteUfrag(String remoteUfrag)
remoteUfrag
- the user name that we received from the remote peer.public String getRemoteUfrag()
public void setRemotePassword(String remotePassword)
remotePassword
- the user name that we received from the remote
peer.public String getRemotePassword()
Copyright © 2018. All rights reserved.