Adds Stream accessor methods to our ICE Agent
This commit is contained in:
parent
152eb6282b
commit
81d887f468
@ -257,4 +257,44 @@ public class Agent
|
|||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the <tt>IceMediaStream</tt> with the specified <tt>name</tt> or
|
||||||
|
* <tt>null</tt> if no such stream has been registered with this
|
||||||
|
* <tt>Agent</tt> yet.
|
||||||
|
*
|
||||||
|
* @param name the name of the stream that we'd like to obtain a reference
|
||||||
|
* to.
|
||||||
|
*
|
||||||
|
* @return the <tt>IceMediaStream</tt> with the specified <tt>name</tt> or
|
||||||
|
* <tt>null</tt> if no such stream has been registered with this
|
||||||
|
* <tt>Agent</tt> yet.
|
||||||
|
*/
|
||||||
|
public IceMediaStream getMediaStream(String name)
|
||||||
|
{
|
||||||
|
return mediaStreams.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a <tt>List</tt> containing the names of all currently registered
|
||||||
|
* media streams.
|
||||||
|
*
|
||||||
|
* @return a <tt>List</tt> containing the names of all currently registered
|
||||||
|
* media streams.
|
||||||
|
*/
|
||||||
|
public List<String> getMediaStreamNames()
|
||||||
|
{
|
||||||
|
return new LinkedList<String>(mediaStreams.keySet());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a <tt>List</tt> containing all <tt>IceMediaStream</tt>s currently
|
||||||
|
* registered with this agent.
|
||||||
|
*
|
||||||
|
* @return a <tt>List</tt> containing all <tt>IceMediaStream</tt>s currently
|
||||||
|
* registered with this agent.
|
||||||
|
*/
|
||||||
|
public List<IceMediaStream> getMediaStreams()
|
||||||
|
{
|
||||||
|
return new LinkedList<IceMediaStream>(mediaStreams.values());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -108,11 +108,13 @@ public class Component
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a local candidate to this 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.
|
||||||
*
|
*
|
||||||
* @param candidate the candidate object to be added
|
* @param candidate the candidate object to be added
|
||||||
*/
|
*/
|
||||||
public void addLocalCandidate(Candidate candidate)
|
protected void addLocalCandidate(Candidate candidate)
|
||||||
{
|
{
|
||||||
synchronized(localCandidates)
|
synchronized(localCandidates)
|
||||||
{
|
{
|
||||||
|
|||||||
53
src/org/ice4j/ice/RemoteCandidate.java
Normal file
53
src/org/ice4j/ice/RemoteCandidate.java
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* ice4j, the OpenSource Java Solution for NAT and Firewall Traversal.
|
||||||
|
* Maintained by the SIP Communicator community (http://sip-communicator.org).
|
||||||
|
*
|
||||||
|
* Distributable under LGPL license.
|
||||||
|
* See terms of license at gnu.org.
|
||||||
|
*/
|
||||||
|
package org.ice4j.ice;
|
||||||
|
|
||||||
|
import java.net.*;
|
||||||
|
|
||||||
|
import org.ice4j.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <tt>RemoteCandidate</tt>s are candidates that an agent received in an offer
|
||||||
|
* or an answer from its peer, and that it would use to form candidate pairs
|
||||||
|
* after combining them with its local candidates.
|
||||||
|
*
|
||||||
|
* @author Emil Ivov
|
||||||
|
*/
|
||||||
|
public class RemoteCandidate
|
||||||
|
extends Candidate
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a <tt>RemoteCandidate</tt> instance for the specified transport
|
||||||
|
* address and properties.
|
||||||
|
*
|
||||||
|
* @param transportAddress the transport address that this candidate is
|
||||||
|
* encapsulating.
|
||||||
|
* @param parentComponent the <tt>Component</tt> that this candidate
|
||||||
|
* belongs to.
|
||||||
|
* @param type the <tt>CandidateType</tt> for this <tt>Candidate</tt>.
|
||||||
|
*/
|
||||||
|
public RemoteCandidate(TransportAddress transportAddress,
|
||||||
|
Component parentComponent,
|
||||||
|
CandidateType type)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -24,11 +24,17 @@ public class Ice
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Runs the test
|
* Runs the test
|
||||||
* @param args cmd line args
|
* @param args command line arguments
|
||||||
*
|
*
|
||||||
* @throws Throwable if bad stuff happens.
|
* @throws Throwable if bad stuff happens.
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) throws Throwable
|
public static void main(String[] args) throws Throwable
|
||||||
|
{
|
||||||
|
Agent agent1 = createAgent(9090);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Agent createAgent(int rtpPort)
|
||||||
|
throws Throwable
|
||||||
{
|
{
|
||||||
Agent agent = new Agent();
|
Agent agent = new Agent();
|
||||||
|
|
||||||
@ -49,7 +55,7 @@ public class Ice
|
|||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
//rtp
|
//rtp
|
||||||
Component rtpComp = agent.createComponent(
|
Component rtpComp = agent.createComponent(
|
||||||
stream, Transport.UDP, 9090, 9090, 10000);
|
stream, Transport.UDP, rtpPort, rtpPort, rtpPort + 100);
|
||||||
System.out.println("rtpComp:" + rtpComp);
|
System.out.println("rtpComp:" + rtpComp);
|
||||||
long endTime = System.currentTimeMillis();
|
long endTime = System.currentTimeMillis();
|
||||||
System.out.println("Component created in "
|
System.out.println("Component created in "
|
||||||
@ -57,12 +63,14 @@ public class Ice
|
|||||||
startTime = endTime;
|
startTime = endTime;
|
||||||
//rtcpComp
|
//rtcpComp
|
||||||
Component rtcpComp = agent.createComponent(
|
Component rtcpComp = agent.createComponent(
|
||||||
stream, Transport.UDP, 9091, 9090, 10000);
|
stream, Transport.UDP, rtpPort + 1, rtpPort + 1, rtpPort + 101);
|
||||||
|
|
||||||
System.out.println("rtcpComp:" + rtcpComp);
|
System.out.println("rtcpComp:" + rtcpComp);
|
||||||
endTime = System.currentTimeMillis();
|
endTime = System.currentTimeMillis();
|
||||||
System.out.println("Component created in "
|
System.out.println("Component created in "
|
||||||
+ (endTime - startTime) +" ms\n");
|
+ (endTime - startTime) +" ms\n");
|
||||||
|
|
||||||
|
return agent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user