Adds a few methods necessary for adding remote candidates to stream components

This commit is contained in:
emcho 2010-02-28 16:14:31 +00:00
parent 60d6f4ebc1
commit 96c9a972f7
7 changed files with 64 additions and 30 deletions

View File

@ -322,4 +322,30 @@ public class Agent
return mediaStreams.size();
}
}
/**
* Returns a <tt>String</tt> representation of this agent.
*
* @return a <tt>String</tt> representation of this agent.
*/
@Override
public String toString()
{
StringBuffer buff = new StringBuffer("ICE Agent (stream-count=");
buff.append(getStreamCount()).append(" ice-pwd:").append(getPassword());
buff.append(getStreamCount()).append(" ice-ufrag:")
.append(getUserName());
buff.append("):\n");
List<IceMediaStream> streams = getStreams();
for(IceMediaStream stream : streams)
{
buff.append(stream.toString()).append("\n");
}
return buff.toString();
}
}

View File

@ -141,14 +141,6 @@ public abstract class Candidate
this.candidateType = type;
}
/**
* Gets the <tt>DatagramSocket</tt> associated with this <tt>Candidate</tt>.
*
* @return the <tt>DatagramSocket</tt> associated with this
* <tt>Candidate</tt>
*/
public abstract DatagramSocket getSocket();
/**
* Returns the type of this candidate which should be an instance of the
* {@link CandidateType} enumeration.

View File

@ -108,13 +108,13 @@ public class Component
}
/**
* Add a local candidate to this component. The method has package access
* because local candidates can only be created and added by the candidate
* harvesters registered with the agent.
* 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.
*
* @param candidate the candidate object to be added
*/
protected void addLocalCandidate(Candidate candidate)
public void addLocalCandidate(Candidate candidate)
{
synchronized(localCandidates)
{

View File

@ -25,7 +25,7 @@ import org.ice4j.*;
*
* @author Emil Ivov
*/
public class HostCandidate extends Candidate
public class HostCandidate extends LocalCandidate
{
/**
@ -59,7 +59,7 @@ public class HostCandidate extends Candidate
*
* @return the <tt>DatagramSocket</tt> associated with this
* <tt>Candidate</tt>
* @see Candidate#getSocket()
* @see LocalCandidate#getSocket()
*/
public DatagramSocket getSocket()
{

View File

@ -108,7 +108,20 @@ public class IceMediaStream
*/
public String toString()
{
return "media stream:" + getName();
StringBuffer buff = new StringBuffer( "media stream:")
.append(getName());
buff.append(" (component count=").append(getComponentCount())
.append(")");
List<Component> components = getComponents();
for (Component cmp : components)
{
buff.append("Component ").append(cmp.getComponentID())
.append(" :\n");
buff.append(cmp);
}
return buff.toString();
}
/**
@ -143,6 +156,21 @@ public class IceMediaStream
}
}
/**
* 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 getComponentCount()
{
synchronized(components)
{
return components.size();
}
}
/**
* Returns the IDs of all <tt>Component</tt>s currently registered with this
* stream.

View File

@ -38,16 +38,4 @@ public class RemoteCandidate
{
super(transportAddress, parentComponent, type);
}
/**
* Always returns null since remote candidates do not have a
* <tt>DatagramSocket</tt> associated with them.
*
* @return <tt>null</tt>
*/
public DatagramSocket getSocket()
{
return null;
}
}

View File

@ -24,7 +24,7 @@ import org.ice4j.*;
*
* @author Emil Ivov
*/
public class ServerReflexiveCandidate extends Candidate
public class ServerReflexiveCandidate extends LocalCandidate
{
/**
@ -55,10 +55,10 @@ public class ServerReflexiveCandidate extends Candidate
*
* @return the <tt>DatagramSocket</tt> associated with this
* <tt>Candidate</tt>
* @see Candidate#getSocket()
* @see LocalCandidate#getSocket()
*/
public DatagramSocket getSocket()
{
return getBase().getSocket();
return ((HostCandidate)getBase()).getSocket();
}
}