Fixes issues with ICE processing in a basic use case

This commit is contained in:
emcho 2010-05-08 21:39:56 +00:00
parent ef7a75fcc4
commit 795e0f0fd1
3 changed files with 44 additions and 7 deletions

View File

@ -1013,12 +1013,16 @@ public class Agent
*/ */
protected void validatePair(CandidatePair validPair) protected void validatePair(CandidatePair validPair)
{ {
IceMediaStream parentStream Component parentComponent = validPair.getParentComponent();
= validPair.getParentComponent().getParentStream(); IceMediaStream parentStream = parentComponent.getParentStream();
CheckList checkList = parentStream.getCheckList();
parentStream.addValidPair(validPair); 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.nominate();
validPair.getParentComponent().getParentStream() validPair.getParentComponent().getParentStream()
@ -1077,7 +1081,8 @@ public class Agent
allListsEnded = false; allListsEnded = false;
break; break;
} }
else if(stream.getCheckList().getState() == CheckListState.COMPLETED) else if(stream.getCheckList().getState()
== CheckListState.COMPLETED)
{ {
atLeastOneListSucceeded = true; atLeastOneListSucceeded = true;
} }

View File

@ -364,4 +364,28 @@ public class CheckList
{ {
return name; return name;
} }
/**
* Returns <tt>true</tt> if this <tt>CheckList</tt> already contains a
* nominated {@link CandidatePair} for the specified <tt>component</tt>
* and <tt>false</tt> otherwise.
*
* @param componennt the {@link Component} that we'd whose nominees we are
* interested in.
*
* @return <tt>true</tt> if this <tt>CheckList</tt> already contains a
* nominated {@link CandidatePair} for the specified <tt>component</tt>
* and <tt>false</tt> otherwise.
*/
public synchronized boolean containsNomineeForComponent(
Component componennt)
{
for (CandidatePair pair : this)
{
if (pair.isNominated() && pair.getParentComponent() == componennt)
return true;
}
return false;
}
} }

View File

@ -116,12 +116,20 @@ public class Ice
System.out.println(cmpName + ": " System.out.println(cmpName + ": "
+ cmp.getSelectedPair()); + 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) else if(evt.getNewValue() == IceProcessingState.TERMINATED)
{ {
System.out.println("ICE Agent was terminated.");
System.exit(0); System.exit(0);
} }
} }
@ -233,8 +241,8 @@ public class Ice
new TransportAddress("ipv6.sip-communicator.net", new TransportAddress("ipv6.sip-communicator.net",
3478, Transport.UDP)); 3478, Transport.UDP));
//agent.addCandidateHarvester(stunHarv); agent.addCandidateHarvester(stunHarv);
//agent.addCandidateHarvester(stun6Harv); agent.addCandidateHarvester(stun6Harv);
createStream(rtpPort, "audio", agent); createStream(rtpPort, "audio", agent);
//createStream(rtpPort + 2, "video", agent); //createStream(rtpPort + 2, "video", agent);