Moves check list management to the Agent rather than the media stream since checks need to be managed in a global way.
This commit is contained in:
parent
f279a7dcaa
commit
ce7ec76677
@ -238,10 +238,31 @@ public class Agent
|
|||||||
component.selectDefaultCandidate();
|
component.selectDefaultCandidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the list of <tt>CandidatePair</tt>s to be used in checks for
|
||||||
|
* this agent.
|
||||||
|
*
|
||||||
|
* @return the list of <tt>CandidatePair</tt>s to be used in checks for
|
||||||
|
* this agent.
|
||||||
|
*/
|
||||||
|
public List<CandidatePair> getCheckList()
|
||||||
|
{
|
||||||
|
return checkList;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes all stream check lists and begins the checks.
|
* Initializes all stream check lists and begins the checks.
|
||||||
*/
|
*/
|
||||||
public void startChecks()
|
public void startChecks()
|
||||||
|
{
|
||||||
|
initCheckList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates, initializes and orders the list of candidate pairs that would
|
||||||
|
* be used for the connectivity checks for all components in this stream.
|
||||||
|
*/
|
||||||
|
protected void initCheckList()
|
||||||
{
|
{
|
||||||
//first init the check list.
|
//first init the check list.
|
||||||
synchronized(checkList)
|
synchronized(checkList)
|
||||||
|
|||||||
@ -252,12 +252,12 @@ public class IceMediaStream
|
|||||||
*/
|
*/
|
||||||
protected void createCheckList(List<CandidatePair> checkList)
|
protected void createCheckList(List<CandidatePair> checkList)
|
||||||
{
|
{
|
||||||
List<Component> componentsList = getComponents();
|
List<Component> componentsList = getComponents();
|
||||||
|
|
||||||
for(Component cmp : componentsList)
|
for(Component cmp : componentsList)
|
||||||
{
|
{
|
||||||
createCheckList(cmp, checkList);
|
createCheckList(cmp, checkList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -287,14 +287,4 @@ public class IceMediaStream
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the list of <tt>CandidatePair</tt>s for this stream.
|
|
||||||
*
|
|
||||||
* @return the list of <tt>CandidatePair</tt>s for this stream.
|
|
||||||
*/
|
|
||||||
public List<CandidatePair> getCheckList()
|
|
||||||
{
|
|
||||||
return checkList;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,8 +48,7 @@ public class Ice
|
|||||||
|
|
||||||
localAgent.startChecks();
|
localAgent.startChecks();
|
||||||
|
|
||||||
System.out.println("Local audio clist:\n"
|
System.out.println("Local audio clist:\n" + localAgent.getCheckList());
|
||||||
+ localAgent.getStream("audio").getCheckList());
|
|
||||||
|
|
||||||
System.out.println("Total execution time: "
|
System.out.println("Total execution time: "
|
||||||
+ (endTime - startTime) + "ms");
|
+ (endTime - startTime) + "ms");
|
||||||
@ -140,8 +139,8 @@ public class Ice
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an ICE <tt>Agent</tt> and adds to it an audio stream with RTP
|
* Creates an ICE <tt>Agent</tt> and adds to it an audio and a video stream
|
||||||
* and RTCP components.
|
* with RTP and RTCP components.
|
||||||
*
|
*
|
||||||
* @param rtpPort the port that we should try to bind the RTP component on
|
* @param rtpPort the port that we should try to bind the RTP component on
|
||||||
* (the RTCP one would automatically go to rtpPort + 1)
|
* (the RTCP one would automatically go to rtpPort + 1)
|
||||||
@ -164,9 +163,38 @@ public class Ice
|
|||||||
agent.addCandidateHarvester(stunHarv);
|
agent.addCandidateHarvester(stunHarv);
|
||||||
agent.addCandidateHarvester(stun6Harv);
|
agent.addCandidateHarvester(stun6Harv);
|
||||||
|
|
||||||
IceMediaStream stream = agent.createMediaStream("audio");
|
createStream(rtpPort, "audio", agent);
|
||||||
|
createStream(rtpPort + 2, "video", agent);
|
||||||
|
|
||||||
|
return agent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an <tt>IceMediaStrean</tt> and adds to it an RTP and and RTCP
|
||||||
|
* component.
|
||||||
|
*
|
||||||
|
* @param rtpPort the port that we should try to bind the RTP component on
|
||||||
|
* (the RTCP one would automatically go to rtpPort + 1)
|
||||||
|
* @param streamName the name of the stream to create
|
||||||
|
* @param agent the <tt>Agent</tt> that should create the stream.
|
||||||
|
*
|
||||||
|
*@return the newly created <tt>IceMediaStream</tt>.
|
||||||
|
* @throws Throwable if anything goes wrong.
|
||||||
|
*/
|
||||||
|
private static IceMediaStream createStream(int rtpPort,
|
||||||
|
String streamName,
|
||||||
|
Agent agent)
|
||||||
|
throws Throwable
|
||||||
|
{
|
||||||
|
IceMediaStream stream = agent.createMediaStream(streamName);
|
||||||
|
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
//TODO: component creation should probably be part of the library. it
|
||||||
|
//should also be started after we've defined all components to be
|
||||||
|
//created so that we could run the harvesting for everyone of them
|
||||||
|
//simultaneously with the others.
|
||||||
|
|
||||||
//rtp
|
//rtp
|
||||||
Component rtpComp = agent.createComponent(
|
Component rtpComp = agent.createComponent(
|
||||||
stream, Transport.UDP, rtpPort, rtpPort, rtpPort + 100);
|
stream, Transport.UDP, rtpPort, rtpPort, rtpPort + 100);
|
||||||
@ -183,7 +211,7 @@ public class Ice
|
|||||||
System.out.println("RTCP Component created in "
|
System.out.println("RTCP Component created in "
|
||||||
+ (endTime - startTime) +" ms");
|
+ (endTime - startTime) +" ms");
|
||||||
|
|
||||||
return agent;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user