diff --git a/src/org/ice4j/ice/Agent.java b/src/org/ice4j/ice/Agent.java
index 475eeb1..409dbc3 100644
--- a/src/org/ice4j/ice/Agent.java
+++ b/src/org/ice4j/ice/Agent.java
@@ -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 true. This
- * may end ICE processing for this media stream as per Section 8 in RFC
- * 5245. The method has no effect if pairToNominate is not on any
- * valid list.
+ * Adds pair 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 USE-CANDIDATE 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
+
+ */
+
+
+
}
/**
diff --git a/src/org/ice4j/ice/CandidatePair.java b/src/org/ice4j/ice/CandidatePair.java
index 4d167fb..855c8e4 100644
--- a/src/org/ice4j/ice/CandidatePair.java
+++ b/src/org/ice4j/ice/CandidatePair.java
@@ -45,6 +45,18 @@ public class CandidatePair
*/
private boolean useCandidate = false;
+ /**
+ * Indicates whether this CandidatePair 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 Comparator using the compareTo method of the
* CandidatePair.
@@ -502,4 +514,47 @@ public class CandidatePair
{
return useCandidate;
}
+
+ /**
+ * Sets this pair's nominated flag to true. 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 true. 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 true if this pair has already been nominated for
+ * selection and false otherwise.
+ */
+ public boolean isNominated()
+ {
+ return this.isNominated;
+ }
+
+ /**
+ * Returns true if this pair has been confirmed by a connectivity
+ * check response and false otherwise.
+ *
+ * @return true if this pair has been confirmed by a connectivity
+ * check response and false otherwise.
+ */
+ public boolean isValid()
+ {
+ return isValid;
+ }
+
+ /**
+ * Marks this pair as valid. Should only be used internally.
+ */
+ protected void validate()
+ {
+ this.isValid = true;
+ }
}
diff --git a/src/org/ice4j/ice/CheckList.java b/src/org/ice4j/ice/CheckList.java
index fe514e9..25b23b3 100644
--- a/src/org/ice4j/ice/CheckList.java
+++ b/src/org/ice4j/ice/CheckList.java
@@ -262,7 +262,7 @@ public class CheckList
}
/**
- * Recomputes priorities of all pairs in this CheckList. Methord is
+ * Recomputes priorities of all pairs in this CheckList. Method is
* useful when an agent changes its isControlling property as a
* result of a role conflict.
*/
@@ -274,4 +274,45 @@ public class CheckList
pair.computePriority();
}
}
+
+ /**
+ * Removes from this CheckList and its associated triggered check
+ * queue all {@link CandidatePair}s that are in the Waiting and
+ * Frozen states and that belong to the specified
+ * component. 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 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 triggeredPairsIter
+ = triggeredCheckQueue.iterator();
+ while(triggeredPairsIter.hasNext())
+ {
+ CandidatePair pair = triggeredPairsIter.next();
+ if (pair.getParentComponent() == cmp
+ && pair.getState() == CandidatePairState.WAITING
+ && pair.getState() == CandidatePairState.FROZEN)
+ {
+ triggeredPairsIter.remove();
+ }
+ }
+ }
+ }
+
}
diff --git a/src/org/ice4j/ice/IceMediaStream.java b/src/org/ice4j/ice/IceMediaStream.java
index 8cff4a9..f2ed6be 100644
--- a/src/org/ice4j/ice/IceMediaStream.java
+++ b/src/org/ice4j/ice/IceMediaStream.java
@@ -555,6 +555,7 @@ public class IceMediaStream
{
synchronized (validList)
{
+ pair.validate();
validList.add(pair);
}
}
diff --git a/src/org/ice4j/ice/checks/ConnectivityCheckClient.java b/src/org/ice4j/ice/checks/ConnectivityCheckClient.java
index 65f536a..66e058e 100644
--- a/src/org/ice4j/ice/checks/ConnectivityCheckClient.java
+++ b/src/org/ice4j/ice/checks/ConnectivityCheckClient.java
@@ -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 null 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;
+ }
}
diff --git a/src/org/ice4j/ice/checks/ConnectivityCheckServer.java b/src/org/ice4j/ice/checks/ConnectivityCheckServer.java
index 5ae69e5..c0524ff 100644
--- a/src/org/ice4j/ice/checks/ConnectivityCheckServer.java
+++ b/src/org/ice4j/ice/checks/ConnectivityCheckServer.java
@@ -6,8 +6,6 @@
*/
package org.ice4j.ice.checks;
-import java.io.*;
-import java.util.*;
import java.util.logging.*;
import org.ice4j.*;