diff --git a/src/org/ice4j/ice/Agent.java b/src/org/ice4j/ice/Agent.java index 410ac1f..911e384 100644 --- a/src/org/ice4j/ice/Agent.java +++ b/src/org/ice4j/ice/Agent.java @@ -1013,12 +1013,16 @@ public class Agent */ protected void validatePair(CandidatePair validPair) { - IceMediaStream parentStream - = validPair.getParentComponent().getParentStream(); + Component parentComponent = validPair.getParentComponent(); + IceMediaStream parentStream = parentComponent.getParentStream(); + CheckList checkList = parentStream.getCheckList(); parentStream.addValidPair(validPair); - if(!validPair.isNominated()) + //If the pair is not already nominated and if its parent component + //does not already contain a nominated pair - nominate it. + if(!validPair.isNominated() + && !checkList.containsNomineeForComponent(parentComponent)) { validPair.nominate(); validPair.getParentComponent().getParentStream() @@ -1077,7 +1081,8 @@ public class Agent allListsEnded = false; break; } - else if(stream.getCheckList().getState() == CheckListState.COMPLETED) + else if(stream.getCheckList().getState() + == CheckListState.COMPLETED) { atLeastOneListSucceeded = true; } diff --git a/src/org/ice4j/ice/CheckList.java b/src/org/ice4j/ice/CheckList.java index 346583c..683571f 100644 --- a/src/org/ice4j/ice/CheckList.java +++ b/src/org/ice4j/ice/CheckList.java @@ -364,4 +364,28 @@ public class CheckList { return name; } + + /** + * Returns true if this CheckList already contains a + * nominated {@link CandidatePair} for the specified component + * and false otherwise. + * + * @param componennt the {@link Component} that we'd whose nominees we are + * interested in. + * + * @return true if this CheckList already contains a + * nominated {@link CandidatePair} for the specified component + * and false otherwise. + */ + public synchronized boolean containsNomineeForComponent( + Component componennt) + { + for (CandidatePair pair : this) + { + if (pair.isNominated() && pair.getParentComponent() == componennt) + return true; + } + + return false; + } } diff --git a/test/test/Ice.java b/test/test/Ice.java index 4d15446..703bf3c 100644 --- a/test/test/Ice.java +++ b/test/test/Ice.java @@ -116,12 +116,20 @@ public class Ice System.out.println(cmpName + ": " + cmp.getSelectedPair()); } + } + System.out.println("Printing the check lists:"); + for(IceMediaStream stream : streams) + { + String streamName = stream.getName(); + System.out.println("Check list for stream: " + + streamName); + //uncomment for a more verbose output + System.out.println(stream.getCheckList()); } } else if(evt.getNewValue() == IceProcessingState.TERMINATED) { - System.out.println("ICE Agent was terminated."); System.exit(0); } } @@ -233,8 +241,8 @@ public class Ice new TransportAddress("ipv6.sip-communicator.net", 3478, Transport.UDP)); - //agent.addCandidateHarvester(stunHarv); - //agent.addCandidateHarvester(stun6Harv); + agent.addCandidateHarvester(stunHarv); + agent.addCandidateHarvester(stun6Harv); createStream(rtpPort, "audio", agent); //createStream(rtpPort + 2, "video", agent);