Commits work on pair nomination (Section 8.1.1). Work in progress

This commit is contained in:
emcho 2010-05-08 21:37:45 +00:00
parent 6ae8daa23d
commit d30aa3b96f
6 changed files with 225 additions and 25 deletions

View File

@ -851,14 +851,17 @@ public class Agent
//7.2.1.5. Updating the Nominated Flag
if (!isControlling() && triggerPair.useCandidateReceived())
{
//If the state of this pair is Succeeded, it means that a
//previous check generated by this pair produced a
//successful response. This would have caused the agent to
//construct a valid pair when that success response was
//received. The agent now sets the nominated flag in the
//valid pair to true.
if( triggerPair.getState() == CandidatePairState.SUCCEEDED )
nominatePair( triggerPair );
// If the Binding request received by the agent had the
// USE-CANDIDATE attribute set, and the agent is in the
// controlled role, the agent looks at the state of the
// pair ....
// If the state of this pair is Succeeded, it means that a
// previous check generated by this pair produced a
// successful response. This would have caused the agent to
// construct a valid pair when that success response was
// received. The agent now sets the nominated flag in the
// valid pair to true.
nominationConfirmed( triggerPair );
}
return;
@ -895,18 +898,88 @@ public class Agent
}
/**
* Looks for the specified {@link CandidatePair} with in the valid lists
* of the media streams and sets its nominated flag to <tt>true</tt>. This
* may end ICE processing for this media stream as per Section 8 in RFC
* 5245. The method has no effect if <tt>pairToNominate</tt> is not on any
* valid list.
* Adds <tt>pair</tt> to that list of valid candidates for its parent
* stream.
*
* @param pairToNominate the pair that we'd like to nominate in case it's on
* a valid list somewhere.
* @param validPair the {@link CandidatePair} we'd like to validate.
*/
public void nominatePair(CandidatePair pairToNominate)
public void validatePair(CandidatePair validPair)
{
//implement todo !!!
validPair.getParentComponent().getParentStream()
.addValidPair(validPair);
}
/**
* Indicates that we have received a response to a request that either
* contained the <tt>USE-CANDIDATE</tt> attribute or was triggered by an
* incoming request that did.
*
* @param pairToNominate the {@link CandidatePair} whose nomination has
* just been confirmed.
*/
public void nominationConfirmed(CandidatePair pairToNominate)
{
pairToNominate.nominate();
//For both controlling and controlled agents, the state of ICE
//processing depends on the presence of nominated candidate pairs in
//the valid list and on the state of the check list. Note that, at any
//time, more than one of the following cases can apply:
// If there is at least one nominated pair in the valid list for a
// media stream and the state of the check list is Running:
Component parentComponent = pairToNominate.getParentComponent();
IceMediaStream parentStream = parentComponent.getParentStream();
CheckList checkList = parentStream.getCheckList();
if( checkList.getState() == CheckListState.RUNNING )
{
//The agent MUST remove all Waiting and Frozen pairs in the check
//list and triggered check queue for the same component as the
//nominated pairs for that media stream.
checkList.removeNonStartedPairsForComponent(parentComponent);
/*
*
* If an In-Progress pair in the check list is for the same
component as a nominated pair, the agent SHOULD cease
retransmissions for its check if its pair priority is lower
than the lowest-priority nominated pair for that component.*/
}
/*
o Once there is at least one nominated pair in the valid list for
every component of at least one media stream and the state of the
check list is Running:
* The agent MUST change the state of processing for its check
list for that media stream to Completed.
* The agent MUST continue to respond to any checks it may still
receive for that media stream, and MUST perform triggered
checks if required by the processing of Section 7.2.
* The agent MUST continue retransmitting any In-Progress checks
for that check list.
* The agent MAY begin transmitting media for this media stream as
described in Section 11.1.
o Once the state of each check list is Completed:
* The agent sets the state of ICE processing overall to
Completed.
* If an agent is controlling, it examines the highest-priority
nominated candidate pair for each component of each media
stream. If any of those candidate pairs differ from the
*/
}
/**

View File

@ -45,6 +45,18 @@ public class CandidatePair
*/
private boolean useCandidate = false;
/**
* Indicates whether this <tt>CandidatePair</tt> is on any of this agent's
* valid pair lists.
*/
private boolean isValid = false;
/**
* If a valid candidate pair has its nominated flag set, it means that it
* may be selected by ICE for sending and receiving media.
*/
private boolean isNominated = false;
/**
* A <tt>Comparator</tt> using the <tt>compareTo</tt> method of the
* <tt>CandidatePair</tt>.
@ -502,4 +514,47 @@ public class CandidatePair
{
return useCandidate;
}
/**
* Sets this pair's nominated flag to <tt>true</tt>. If a valid candidate
* pair has its nominated flag set, it means that it may be selected by ICE
* for sending and receiving media.
*/
public void nominate()
{
this.isNominated = true;
}
/**
* Returns the value of this pair's nominated flag to <tt>true</tt>. If a
* valid candidate pair has its nominated flag set, it means that it may be
* selected by ICE for sending and receiving media.
*
* @return <tt>true</tt> if this pair has already been nominated for
* selection and <tt>false</tt> otherwise.
*/
public boolean isNominated()
{
return this.isNominated;
}
/**
* Returns <tt>true</tt> if this pair has been confirmed by a connectivity
* check response and <tt>false</tt> otherwise.
*
* @return <tt>true</tt> if this pair has been confirmed by a connectivity
* check response and <tt>false</tt> otherwise.
*/
public boolean isValid()
{
return isValid;
}
/**
* Marks this pair as valid. Should only be used internally.
*/
protected void validate()
{
this.isValid = true;
}
}

View File

@ -262,7 +262,7 @@ public class CheckList
}
/**
* Recomputes priorities of all pairs in this <tt>CheckList</tt>. Methord is
* Recomputes priorities of all pairs in this <tt>CheckList</tt>. Method is
* useful when an agent changes its <tt>isControlling</tt> property as a
* result of a role conflict.
*/
@ -274,4 +274,45 @@ public class CheckList
pair.computePriority();
}
}
/**
* Removes from this <tt>CheckList</tt> and its associated triggered check
* queue all {@link CandidatePair}s that are in the <tt>Waiting</tt> and
* <tt>Frozen</tt> states and that belong to the specified
* <tt>component</tt>. Typically this will happen upon confirmation of the
* nomination of one pair in that component.
*
* @param cmp the {@link Component} whose pairs we want removed.
*/
public synchronized void removeNonStartedPairsForComponent(Component cmp)
{
Iterator<CandidatePair> pairsIter = iterator();
while(pairsIter.hasNext())
{
CandidatePair pair = pairsIter.next();
if (pair.getParentComponent() == cmp
&& pair.getState() == CandidatePairState.WAITING
&& pair.getState() == CandidatePairState.FROZEN)
{
pairsIter.remove();
}
}
synchronized(triggeredCheckQueue)
{
Iterator<CandidatePair> triggeredPairsIter
= triggeredCheckQueue.iterator();
while(triggeredPairsIter.hasNext())
{
CandidatePair pair = triggeredPairsIter.next();
if (pair.getParentComponent() == cmp
&& pair.getState() == CandidatePairState.WAITING
&& pair.getState() == CandidatePairState.FROZEN)
{
triggeredPairsIter.remove();
}
}
}
}
}

View File

@ -555,6 +555,7 @@ public class IceMediaStream
{
synchronized (validList)
{
pair.validate();
validList.add(pair);
}
}

View File

@ -127,6 +127,12 @@ public class ConnectivityCheckClient
request.addAttribute(AttributeFactory
.createIceControllingAttribute(parentAgent
.getTieBreaker()));
//if we are the controlling agent then we need to indicate our
//nominated pairs.
if(candidatePair.isNominated())
request.addAttribute(AttributeFactory
.createUseCandidateAttribute());
}
else
{
@ -346,8 +352,7 @@ public class ConnectivityCheckClient
validPair = new CandidatePair(validLocalCandidate,
validRemoteCandidate);
validPair.getParentComponent().getParentStream()
.addValidPair(validPair);
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
@ -399,15 +404,16 @@ public class ConnectivityCheckClient
if(parentAgent.isControlling()
&& request.contains(Attribute.USE_CANDIDATE))
{
parentAgent.nominatePair( validPair );
parentAgent.nominationConfirmed( validPair );
}
//If the agent is the controlled agent, the response may be the result
//of a triggered check that was sent in response to a request that
//itself had the USE-CANDIDATE attribute. This case is described in
//Section 7.2.1.5, and may now result in setting the nominated flag for
//the pair learned from the original request.
else if(checkedPair.useCandidateReceived())
parentAgent.nominatePair( checkedPair );
else if(checkedPair.useCandidateReceived()
&& ! checkedPair.isNominated())
parentAgent.nominationConfirmed( checkedPair );
}
@ -612,6 +618,32 @@ public class ConnectivityCheckClient
pairToCheck.setStateInProgress(transactionID);
}
parentClient.paceMakers.remove(this);
}
}
/**
* Returns the {@link PaceMaker} responsible for running checks for the
* specified {@link CheckList}
*
* @param list the {@link CheckList} whose {@link PaceMaker} we are trying
* to find.
*
* @return the {@link PaceMaker} responsible for running checks for the
* specified {@link CheckList} or <tt>null</tt> if we couldn't find one.
*/
private PaceMaker findPaceMaker(CheckList list)
{
synchronized(paceMakers)
{
for(PaceMaker paceMaker : paceMakers)
{
if (paceMaker.checkList == list)
return paceMaker;
}
}
return null;
}
}

View File

@ -6,8 +6,6 @@
*/
package org.ice4j.ice.checks;
import java.io.*;
import java.util.*;
import java.util.logging.*;
import org.ice4j.*;