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:
emcho 2010-03-07 11:36:22 +00:00
parent f279a7dcaa
commit ce7ec76677
3 changed files with 60 additions and 21 deletions

View File

@ -238,10 +238,31 @@ public class Agent
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.
*/
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.
synchronized(checkList)

View File

@ -252,12 +252,12 @@ public class IceMediaStream
*/
protected void createCheckList(List<CandidatePair> checkList)
{
List<Component> componentsList = getComponents();
List<Component> componentsList = getComponents();
for(Component cmp : componentsList)
{
createCheckList(cmp, checkList);
}
for(Component cmp : componentsList)
{
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;
}
}

View File

@ -48,8 +48,7 @@ public class Ice
localAgent.startChecks();
System.out.println("Local audio clist:\n"
+ localAgent.getStream("audio").getCheckList());
System.out.println("Local audio clist:\n" + localAgent.getCheckList());
System.out.println("Total execution time: "
+ (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
* and RTCP components.
* Creates an ICE <tt>Agent</tt> and adds to it an audio and a video stream
* with RTP and RTCP components.
*
* @param rtpPort the port that we should try to bind the RTP component on
* (the RTCP one would automatically go to rtpPort + 1)
@ -164,9 +163,38 @@ public class Ice
agent.addCandidateHarvester(stunHarv);
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();
//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
Component rtpComp = agent.createComponent(
stream, Transport.UDP, rtpPort, rtpPort, rtpPort + 100);
@ -183,7 +211,7 @@ public class Ice
System.out.println("RTCP Component created in "
+ (endTime - startTime) +" ms");
return agent;
return stream;
}
/**