diff --git a/src/org/ice4j/ice/Agent.java b/src/org/ice4j/ice/Agent.java index b0d48e9..634510b 100644 --- a/src/org/ice4j/ice/Agent.java +++ b/src/org/ice4j/ice/Agent.java @@ -238,10 +238,31 @@ public class Agent component.selectDefaultCandidate(); } + /** + * Returns the list of CandidatePairs to be used in checks for + * this agent. + * + * @return the list of CandidatePairs to be used in checks for + * this agent. + */ + public List 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) diff --git a/src/org/ice4j/ice/IceMediaStream.java b/src/org/ice4j/ice/IceMediaStream.java index 1c54113..f8be55c 100644 --- a/src/org/ice4j/ice/IceMediaStream.java +++ b/src/org/ice4j/ice/IceMediaStream.java @@ -252,12 +252,12 @@ public class IceMediaStream */ protected void createCheckList(List checkList) { - List componentsList = getComponents(); + List 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 CandidatePairs for this stream. - * - * @return the list of CandidatePairs for this stream. - */ - public List getCheckList() - { - return checkList; - } } diff --git a/test/test/Ice.java b/test/test/Ice.java index 35c2bcb..fc79631 100644 --- a/test/test/Ice.java +++ b/test/test/Ice.java @@ -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 Agent and adds to it an audio stream with RTP - * and RTCP components. + * Creates an ICE Agent 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 IceMediaStrean 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 Agent that should create the stream. + * + *@return the newly created IceMediaStream. + * @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; } /**