Fixes issues with ICE processing in a basic use case
This commit is contained in:
parent
7da2ab5222
commit
ef7a75fcc4
@ -1018,10 +1018,12 @@ public class Agent
|
||||
|
||||
parentStream.addValidPair(validPair);
|
||||
|
||||
System.out.println("valid pair was nominated " + validPair);
|
||||
validPair.nominate();
|
||||
validPair.getParentComponent().getParentStream()
|
||||
if(!validPair.isNominated())
|
||||
{
|
||||
validPair.nominate();
|
||||
validPair.getParentComponent().getParentStream()
|
||||
.getCheckList().scheduleTriggeredCheck(validPair);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1029,19 +1031,19 @@ System.out.println("valid pair was nominated " + validPair);
|
||||
* contained the <tt>USE-CANDIDATE</tt> attribute or was triggered by an
|
||||
* incoming request that did.
|
||||
*
|
||||
* @param pairToNominate the {@link CandidatePair} whose nomination has
|
||||
* @param nominatedPair the {@link CandidatePair} whose nomination has
|
||||
* just been confirmed.
|
||||
*/
|
||||
protected void nominationConfirmed(CandidatePair pairToNominate)
|
||||
protected void nominationConfirmed(CandidatePair nominatedPair)
|
||||
{
|
||||
pairToNominate.nominate();
|
||||
System.out.println("pair nomination confirmed");
|
||||
Component parentComponent = pairToNominate.getParentComponent();
|
||||
nominatedPair.nominate();
|
||||
|
||||
Component parentComponent = nominatedPair.getParentComponent();
|
||||
IceMediaStream parentStream = parentComponent.getParentStream();
|
||||
CheckList checkList = parentStream.getCheckList();
|
||||
|
||||
if( checkList.getState() == CheckListState.RUNNING )
|
||||
checkList.handleNomination(pairToNominate);
|
||||
checkList.handleNomination(nominatedPair);
|
||||
|
||||
//Once there is at least one nominated pair in the valid list for
|
||||
//every component of the media stream and the state of the
|
||||
@ -1052,7 +1054,6 @@ System.out.println("pair nomination confirmed");
|
||||
//The agent MUST change the state of processing for its check
|
||||
//list for that media stream to Completed.
|
||||
checkList.setState(CheckListState.COMPLETED);
|
||||
System.out.println("checklist " + checkList.getName() + " became " + checkList.getState());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1241,9 +1242,10 @@ System.out.println("checklist " + checkList.getName() + " became " + checkList.g
|
||||
private void scheduleTermination()
|
||||
{
|
||||
if (terminationThread == null)
|
||||
{
|
||||
terminationThread = new TerminationThread(this);
|
||||
|
||||
terminationThread.start();
|
||||
terminationThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1280,7 +1282,7 @@ System.out.println("checklist " + checkList.getName() + " became " + checkList.g
|
||||
* interval the user has specified) and then moves this <tt>Agent</tt>
|
||||
* into the terminated state and frees all non-nominated candidates.
|
||||
*/
|
||||
public void run()
|
||||
public synchronized void run()
|
||||
{
|
||||
long waitFor = Integer.getInteger(
|
||||
StackProperties.TERMINATION_DELAY,
|
||||
@ -1289,11 +1291,12 @@ System.out.println("checklist " + checkList.getName() + " became " + checkList.g
|
||||
try
|
||||
{
|
||||
wait(waitFor);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.log(Level.FINEST,
|
||||
"Interrupted while waiting. Will speed up termination", e);
|
||||
logger.log(Level.FINEST, "Interrupted while waiting. Will "
|
||||
+"speed up termination", e);
|
||||
}
|
||||
|
||||
parentAgent.terminate();
|
||||
@ -1308,6 +1311,8 @@ System.out.println("checklist " + checkList.getName() + " became " + checkList.g
|
||||
{
|
||||
// free candidates
|
||||
// stop listening for checks
|
||||
connCheckClient.stop();
|
||||
connCheckServer.stop();
|
||||
|
||||
setState(IceProcessingState.TERMINATED);
|
||||
}
|
||||
|
||||
@ -316,6 +316,9 @@ public class CheckList
|
||||
protected synchronized void handleNomination(CandidatePair nominatedPair)
|
||||
{
|
||||
Component cmp = nominatedPair.getParentComponent();
|
||||
|
||||
cmp.setSelectedPair(nominatedPair);
|
||||
|
||||
Iterator<CandidatePair> pairsIter = iterator();
|
||||
while(pairsIter.hasNext())
|
||||
{
|
||||
|
||||
@ -648,6 +648,17 @@ public class Component
|
||||
return num;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link CandidatePair} selected for use by ICE processing and
|
||||
* that the application would use.
|
||||
*
|
||||
* @param pair the {@link CandidatePair} selected for use by ICE processing.
|
||||
*/
|
||||
protected void setSelectedPair(CandidatePair pair)
|
||||
{
|
||||
this.selectedPair = pair;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link CandidatePair} selected for use by ICE processing or
|
||||
* <tt>null</tt> if no pair has been selected so far or if ICE processing
|
||||
@ -661,4 +672,21 @@ public class Component
|
||||
{
|
||||
return selectedPair;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a human readable name that can be used in debug logs associated
|
||||
* with this component.
|
||||
*
|
||||
* @return "RTP" if the component ID is 1, "RTCP" if the component id is 2
|
||||
* and the compoent id itself otherwise.
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
if (componentID == RTP)
|
||||
return "RTP";
|
||||
else if(componentID == RTCP)
|
||||
return "RTCP";
|
||||
else
|
||||
return Integer.toString(componentID);
|
||||
}
|
||||
}
|
||||
|
||||
@ -372,7 +372,8 @@ class ConnectivityCheckClient
|
||||
validRemoteCandidate);
|
||||
}
|
||||
|
||||
parentAgent.validatePair(validPair);
|
||||
if(! validPair.isValid())
|
||||
parentAgent.validatePair(validPair);
|
||||
|
||||
//The agent sets the state of the pair that *generated* the check to
|
||||
//Succeeded. Note that, the pair which *generated* the check may be
|
||||
@ -532,9 +533,8 @@ class ConnectivityCheckClient
|
||||
CandidatePair pair = ((CandidatePair)event.getTransactionID()
|
||||
.getApplicationData());
|
||||
logger.fine("timeout for pair=" + pair);
|
||||
System.out.println("timeout for pair=" + pair);
|
||||
pair.setStateFailed();
|
||||
|
||||
pair.setStateFailed();
|
||||
updateCheckListAndTimerStates(pair);
|
||||
}
|
||||
|
||||
@ -611,7 +611,6 @@ System.out.println("timeout for pair=" + pair);
|
||||
while(isRunning)
|
||||
{
|
||||
long waitFor = getNextWaitInterval();
|
||||
System.out.println("will wait for " + waitFor + " active clist cound="+parentClient.parentAgent.getActiveCheckListCount());
|
||||
|
||||
if(waitFor > 0)
|
||||
{
|
||||
@ -636,32 +635,20 @@ System.out.println("will wait for " + waitFor + " active clist cound="+parentCli
|
||||
//if there are no triggered checks, go for an ordinary one.
|
||||
if(pairToCheck == null)
|
||||
{
|
||||
System.out.println("checklist " + checkList.getName() + " did not return triggered check");
|
||||
pairToCheck = checkList.getNextOrdinaryPairToCheck();
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("checklist " + checkList.getName() + " returned triggered check");
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(pairToCheck != null)
|
||||
{
|
||||
System.out.println("checklist " + checkList.getName() + " returned regular check in state " + pairToCheck.getState());
|
||||
transactionID = parentClient.startCheckForPair(pairToCheck);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.fine("checklist " + checkList.getName() + " ran out of checks");
|
||||
//we are done sending checks for this list. we'll set its
|
||||
//final state in either the processResponse()
|
||||
//processTimeout() or processFailure() method.
|
||||
|
||||
logger.finest("finished a checklist");
|
||||
//maybe do this if the list is in the completed state.
|
||||
//isRunning = false;
|
||||
//break;
|
||||
logger.finest("will skip a check beat.");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -675,4 +662,28 @@ logger.fine("checklist " + checkList.getName() + " ran out of checks");
|
||||
parentClient.paceMakers.remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops and removes all PaceMakers.
|
||||
*/
|
||||
public void stop()
|
||||
{
|
||||
synchronized (paceMakers)
|
||||
{
|
||||
Iterator<PaceMaker> paceMakersIter = paceMakers.iterator();
|
||||
while(paceMakersIter.hasNext())
|
||||
{
|
||||
PaceMaker paceMaker = paceMakersIter.next();
|
||||
|
||||
paceMaker.isRunning = false;
|
||||
synchronized(paceMaker)
|
||||
{
|
||||
|
||||
paceMaker.notify();
|
||||
}
|
||||
|
||||
paceMakersIter.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -354,4 +354,12 @@ class ConnectivityCheckServer
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops this server.
|
||||
*/
|
||||
public void stop()
|
||||
{
|
||||
StunStack.getInstance().removeRequestListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -557,7 +557,8 @@ public class IceMediaStream
|
||||
synchronized (validList)
|
||||
{
|
||||
pair.validate();
|
||||
validList.add(pair);
|
||||
if(!validList.contains(pair))
|
||||
validList.add(pair);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -28,11 +28,6 @@ public class Ice
|
||||
*/
|
||||
static long startTime;
|
||||
|
||||
/**
|
||||
* Our local agent.
|
||||
*/
|
||||
static Agent localAgent;
|
||||
|
||||
/**
|
||||
* Runs the test
|
||||
* @param args command line arguments
|
||||
@ -43,7 +38,7 @@ public class Ice
|
||||
{
|
||||
startTime = System.currentTimeMillis();
|
||||
|
||||
localAgent = createAgent(9090);
|
||||
Agent localAgent = createAgent(9090);
|
||||
Agent remotePeer = createAgent(6060);
|
||||
|
||||
localAgent.addStateChangeListener(new IceProcessingListener());
|
||||
@ -103,9 +98,30 @@ public class Ice
|
||||
if(evt.getNewValue() == IceProcessingState.COMPLETED
|
||||
|| evt.getNewValue() == IceProcessingState.FAILED)
|
||||
{
|
||||
System.out.println("Total execution time: "
|
||||
System.out.println("Total ICE processing time: "
|
||||
+ (processingEndTime - startTime) + "ms");
|
||||
//IceMediaStream mediaStream = localAgent.
|
||||
Agent agent = (Agent)evt.getSource();
|
||||
List<IceMediaStream> streams = agent.getStreams();
|
||||
|
||||
for(IceMediaStream stream : streams)
|
||||
{
|
||||
String streamName = stream.getName();
|
||||
System.out.println("Pairs selected for stream: "
|
||||
+ streamName);
|
||||
List<Component> components = stream.getComponents();
|
||||
|
||||
for(Component cmp : components)
|
||||
{
|
||||
String cmpName = cmp.getName();
|
||||
System.out.println(cmpName + ": "
|
||||
+ cmp.getSelectedPair());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if(evt.getNewValue() == IceProcessingState.TERMINATED)
|
||||
{
|
||||
System.out.println("ICE Agent was terminated.");
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user