diff --git a/src/org/ice4j/ice/Agent.java b/src/org/ice4j/ice/Agent.java
index 670e5b8..b636694 100644
--- a/src/org/ice4j/ice/Agent.java
+++ b/src/org/ice4j/ice/Agent.java
@@ -269,9 +269,12 @@ public class Agent
* null if no such stream has been registered with this
* Agent yet.
*/
- public IceMediaStream getMediaStream(String name)
+ public IceMediaStream getStream(String name)
{
- return mediaStreams.get(name);
+ synchronized(mediaStreams)
+ {
+ return mediaStreams.get(name);
+ }
}
/**
@@ -281,9 +284,12 @@ public class Agent
* @return a List containing the names of all currently registered
* media streams.
*/
- public List getMediaStreamNames()
+ public List getStreamNames()
{
- return new LinkedList(mediaStreams.keySet());
+ synchronized(mediaStreams)
+ {
+ return new LinkedList(mediaStreams.keySet());
+ }
}
/**
@@ -293,8 +299,27 @@ public class Agent
* @return a List containing all IceMediaStreams currently
* registered with this agent.
*/
- public List getMediaStreams()
+ public List getStreams()
{
- return new LinkedList(mediaStreams.values());
+ synchronized(mediaStreams)
+ {
+ return new LinkedList(mediaStreams.values());
+ }
+ }
+
+ /**
+ * Returns the number of IceMediaStreams currently registered with
+ * this agent.
+ *
+ * @return the number of IceMediaStreams currently registered with
+ * this agent.
+ *
+ */
+ public int getStreamCount()
+ {
+ synchronized(mediaStreams)
+ {
+ return mediaStreams.size();
+ }
}
}
diff --git a/src/org/ice4j/ice/Component.java b/src/org/ice4j/ice/Component.java
index a12b995..0cd99d1 100644
--- a/src/org/ice4j/ice/Component.java
+++ b/src/org/ice4j/ice/Component.java
@@ -169,7 +169,7 @@ public class Component
* @return the number of all local candidates currently registered in this
* Component.
*/
- public int countLocalCandidates()
+ public int getLocalCandidateCount()
{
synchronized(localCandidates)
{
@@ -240,7 +240,7 @@ public class Component
* @return the number of all remote candidates currently registered in this
* Component.
*/
- public int countRemoteCandidates()
+ public int getRemoteCandidateCount()
{
synchronized(remoteCandidates)
{
@@ -297,7 +297,7 @@ public class Component
buff.append(" parent stream=" + getParentStream().getName());
//local candidates
- int localCandidatesCount = countLocalCandidates();
+ int localCandidatesCount = getLocalCandidateCount();
if(localCandidatesCount > 0)
{
@@ -319,7 +319,7 @@ public class Component
}
//remote candidates
- int remoteCandidatesCount = countRemoteCandidates();
+ int remoteCandidatesCount = getRemoteCandidateCount();
if(remoteCandidatesCount > 0)
{
diff --git a/src/org/ice4j/ice/IceMediaStream.java b/src/org/ice4j/ice/IceMediaStream.java
index 68f9aa7..c7e25e3 100644
--- a/src/org/ice4j/ice/IceMediaStream.java
+++ b/src/org/ice4j/ice/IceMediaStream.java
@@ -81,8 +81,12 @@ public class IceMediaStream
{
lastComponentID ++;
- Component component = new Component(lastComponentID, transport, this);
- components.put(new Integer(lastComponentID), component);
+ Component component;
+ synchronized( components )
+ {
+ component = new Component(lastComponentID, transport, this);
+ components.put(new Integer(lastComponentID), component);
+ }
return component;
}
@@ -118,7 +122,10 @@ public class IceMediaStream
*/
public Component getComponnet(int id)
{
- return components.get(id);
+ synchronized(components)
+ {
+ return components.get(id);
+ }
}
/**
@@ -130,7 +137,10 @@ public class IceMediaStream
*/
public List getComponents()
{
- return new LinkedList(components.values());
+ synchronized(components)
+ {
+ return new LinkedList(components.values());
+ }
}
/**
@@ -142,6 +152,24 @@ public class IceMediaStream
*/
public List getComponentIDs()
{
- return new LinkedList(components.keySet());
+ synchronized(components)
+ {
+ return new LinkedList(components.keySet());
+ }
+ }
+
+ /**
+ * Returns the number of Components currently registered with this
+ * stream.
+ *
+ * @return the number of Components currently registered with this
+ * stream.
+ */
+ public int getStreamCount()
+ {
+ synchronized(components)
+ {
+ return components.size();
+ }
}
}