Adds to IceMediaStream several access methods that allow retrieving available components

This commit is contained in:
emcho 2010-02-28 16:13:55 +00:00
parent 296a88021a
commit 60d6f4ebc1
3 changed files with 68 additions and 15 deletions

View File

@ -269,10 +269,13 @@ public class Agent
* <tt>null</tt> if no such stream has been registered with this * <tt>null</tt> if no such stream has been registered with this
* <tt>Agent</tt> yet. * <tt>Agent</tt> yet.
*/ */
public IceMediaStream getMediaStream(String name) public IceMediaStream getStream(String name)
{
synchronized(mediaStreams)
{ {
return mediaStreams.get(name); return mediaStreams.get(name);
} }
}
/** /**
* Returns a <tt>List</tt> containing the names of all currently registered * Returns a <tt>List</tt> containing the names of all currently registered
@ -281,10 +284,13 @@ public class Agent
* @return a <tt>List</tt> containing the names of all currently registered * @return a <tt>List</tt> containing the names of all currently registered
* media streams. * media streams.
*/ */
public List<String> getMediaStreamNames() public List<String> getStreamNames()
{
synchronized(mediaStreams)
{ {
return new LinkedList<String>(mediaStreams.keySet()); return new LinkedList<String>(mediaStreams.keySet());
} }
}
/** /**
* Returns a <tt>List</tt> containing all <tt>IceMediaStream</tt>s currently * Returns a <tt>List</tt> containing all <tt>IceMediaStream</tt>s currently
@ -293,8 +299,27 @@ public class Agent
* @return a <tt>List</tt> containing all <tt>IceMediaStream</tt>s currently * @return a <tt>List</tt> containing all <tt>IceMediaStream</tt>s currently
* registered with this agent. * registered with this agent.
*/ */
public List<IceMediaStream> getMediaStreams() public List<IceMediaStream> getStreams()
{
synchronized(mediaStreams)
{ {
return new LinkedList<IceMediaStream>(mediaStreams.values()); return new LinkedList<IceMediaStream>(mediaStreams.values());
} }
}
/**
* Returns the number of <tt>IceMediaStream</tt>s currently registered with
* this agent.
*
* @return the number of <tt>IceMediaStream</tt>s currently registered with
* this agent.
*
*/
public int getStreamCount()
{
synchronized(mediaStreams)
{
return mediaStreams.size();
}
}
} }

View File

@ -169,7 +169,7 @@ public class Component
* @return the number of all local candidates currently registered in this * @return the number of all local candidates currently registered in this
* <tt>Component</tt>. * <tt>Component</tt>.
*/ */
public int countLocalCandidates() public int getLocalCandidateCount()
{ {
synchronized(localCandidates) synchronized(localCandidates)
{ {
@ -240,7 +240,7 @@ public class Component
* @return the number of all remote candidates currently registered in this * @return the number of all remote candidates currently registered in this
* <tt>Component</tt>. * <tt>Component</tt>.
*/ */
public int countRemoteCandidates() public int getRemoteCandidateCount()
{ {
synchronized(remoteCandidates) synchronized(remoteCandidates)
{ {
@ -297,7 +297,7 @@ public class Component
buff.append(" parent stream=" + getParentStream().getName()); buff.append(" parent stream=" + getParentStream().getName());
//local candidates //local candidates
int localCandidatesCount = countLocalCandidates(); int localCandidatesCount = getLocalCandidateCount();
if(localCandidatesCount > 0) if(localCandidatesCount > 0)
{ {
@ -319,7 +319,7 @@ public class Component
} }
//remote candidates //remote candidates
int remoteCandidatesCount = countRemoteCandidates(); int remoteCandidatesCount = getRemoteCandidateCount();
if(remoteCandidatesCount > 0) if(remoteCandidatesCount > 0)
{ {

View File

@ -81,8 +81,12 @@ public class IceMediaStream
{ {
lastComponentID ++; lastComponentID ++;
Component component = new Component(lastComponentID, transport, this); Component component;
synchronized( components )
{
component = new Component(lastComponentID, transport, this);
components.put(new Integer(lastComponentID), component); components.put(new Integer(lastComponentID), component);
}
return component; return component;
} }
@ -117,9 +121,12 @@ public class IceMediaStream
* <tt>null</tt> if no such component exists in this stream. * <tt>null</tt> if no such component exists in this stream.
*/ */
public Component getComponnet(int id) public Component getComponnet(int id)
{
synchronized(components)
{ {
return components.get(id); return components.get(id);
} }
}
/** /**
* Returns the list of <tt>Component</tt>s currently registered with this * Returns the list of <tt>Component</tt>s currently registered with this
@ -129,9 +136,12 @@ public class IceMediaStream
* this stream. * this stream.
*/ */
public List<Component> getComponents() public List<Component> getComponents()
{
synchronized(components)
{ {
return new LinkedList<Component>(components.values()); return new LinkedList<Component>(components.values());
} }
}
/** /**
* Returns the IDs of all <tt>Component</tt>s currently registered with this * Returns the IDs of all <tt>Component</tt>s currently registered with this
@ -141,7 +151,25 @@ public class IceMediaStream
* currently registered with this stream. * currently registered with this stream.
*/ */
public List<Integer> getComponentIDs() public List<Integer> getComponentIDs()
{
synchronized(components)
{ {
return new LinkedList<Integer>(components.keySet()); return new LinkedList<Integer>(components.keySet());
} }
}
/**
* Returns the number of <tt>Component</tt>s currently registered with this
* stream.
*
* @return the number of <tt>Component</tt>s currently registered with this
* stream.
*/
public int getStreamCount()
{
synchronized(components)
{
return components.size();
}
}
} }