diff --git a/src/org/ice4j/ice/CandidatePair.java b/src/org/ice4j/ice/CandidatePair.java
index 01548c5..2bd6254 100644
--- a/src/org/ice4j/ice/CandidatePair.java
+++ b/src/org/ice4j/ice/CandidatePair.java
@@ -156,15 +156,66 @@ public class CandidatePair
return state;
}
+ /**
+ * Sets the CandidatePairState of this pair to
+ * {@link CandidatePairState#FAILED}. This method should only be called by
+ * the ice agent, during the execution of the ICE procedures.
+ */
+ public void setStateFailed()
+ {
+ setState(CandidatePairState.FAILED, null);
+ }
+
+ /**
+ * Sets the CandidatePairState of this pair to
+ * {@link CandidatePairState#FROZEN}. This method should only be called by
+ * the ice agent, during the execution of the ICE procedures.
+ */
+ public void setStateFrozen()
+ {
+ setState(CandidatePairState.FROZEN, null);
+ }
+
+ /**
+ * Sets the CandidatePairState of this pair to
+ * {@link CandidatePairState#FROZEN}. This method should only be called by
+ * the ice agent, during the execution of the ICE procedures.
+ *
+ * @param tranID the {@link TransactionID} that we are using for the
+ * connectivity check in case we are entering the In-Progress
+ * state and null otherwise.
+ */
+ public void setStateInProgress(TransactionID tranID)
+ {
+ setState(CandidatePairState.IN_PROGRESS, tranID);
+ }
+
+ /**
+ * Sets the CandidatePairState of this pair to
+ * {@link CandidatePairState#SUCCEEDED}. This method should only be called
+ * by the ice agent, during the execution of the ICE procedures.
+ */
+ public void setStateSucceeded()
+ {
+ setState(CandidatePairState.SUCCEEDED, null);
+ }
+
+ /**
+ * Sets the CandidatePairState of this pair to
+ * {@link CandidatePairState#WAITING}. This method should only be called by
+ * the ice agent, during the execution of the ICE procedures.
+ */
+ public void setStateWaiting()
+ {
+ setState(CandidatePairState.WAITING, null);
+ }
+
/**
* Sets the CandidatePairState of this pair to state. This
* method should only be called by the ice agent, during the execution of
* the ICE procedures. Note that passing a null transaction for the
* {@link CandidatePairState#IN_PROGRESS} or a non-null for any
* other state would cause an {@link IllegalArgumentException} to be thrown.
- * I know this is not the most elegant way to handle it but this method is
- * supposed to only be used internally and I prefer the exception rather
- * than implementing one method for every state transition.
*
* @param state the state that this candidate pair is to enter.
* @param tranID the {@link TransactionID} that we are using for the
@@ -174,8 +225,8 @@ public class CandidatePair
* @throws IllegalArgumentException if state is {@link CandidatePairState
* #IN_PROGRESS} and tranID is null.
*/
- public synchronized void setState(CandidatePairState state,
- TransactionID tranID)
+ private synchronized void setState(CandidatePairState state,
+ TransactionID tranID)
throws IllegalArgumentException
{
this.state = state;
@@ -325,6 +376,10 @@ public class CandidatePair
.remoteCandidate))
return false;
+ //DO NOT change this method to also depend on other pair properties
+ //because the Conn Check Client counts on it only using the candidates
+ //for comparisons.
+
return true;
}
diff --git a/src/org/ice4j/ice/CheckList.java b/src/org/ice4j/ice/CheckList.java
index ada5f9b..fe514e9 100644
--- a/src/org/ice4j/ice/CheckList.java
+++ b/src/org/ice4j/ice/CheckList.java
@@ -74,7 +74,7 @@ public class CheckList
if(!triggeredCheckQueue.contains(pair))
{
triggeredCheckQueue.add(pair);
- pair.setState(CandidatePairState.WAITING, null);
+ pair.setStateWaiting();
}
}
}
@@ -257,7 +257,7 @@ public class CheckList
while(pairsIter.hasNext())
{
- pairsIter.next().setState(CandidatePairState.WAITING, null);
+ pairsIter.next().setStateWaiting();
}
}
diff --git a/src/org/ice4j/ice/FoundationsRegistry.java b/src/org/ice4j/ice/FoundationsRegistry.java
index 670dd47..e0b84f1 100644
--- a/src/org/ice4j/ice/FoundationsRegistry.java
+++ b/src/org/ice4j/ice/FoundationsRegistry.java
@@ -50,8 +50,7 @@ public class FoundationsRegistry
= candidate.getBase().getTransportAddress().getHostAddress();
String server = null;
- if(candidate.getType()
- == CandidateType.SERVER_REFLEXIVE_CANDIDATE
+ if(candidate.getType() == CandidateType.SERVER_REFLEXIVE_CANDIDATE
|| candidate.getType() == CandidateType.RELAYED_CANDIDATE)
{
server = candidate.getStunServerAddress().getHostAddress();
diff --git a/src/org/ice4j/ice/IceMediaStream.java b/src/org/ice4j/ice/IceMediaStream.java
index 862127b..df667c6 100644
--- a/src/org/ice4j/ice/IceMediaStream.java
+++ b/src/org/ice4j/ice/IceMediaStream.java
@@ -42,6 +42,15 @@ public class IceMediaStream
private final LinkedHashMap components
= new LinkedHashMap();
+ /**
+ * An ordered set of candidate pairs for a media stream that have been
+ * validated by a successful STUN transaction. This list is empty at the
+ * start of ICE processing, and fills as checks are performed, resulting in
+ * valid candidate pairs.
+ */
+ private final TreeSet validList
+ = new TreeSet();
+
/**
* The id that was last assigned to a component. The next id that we give
* to a component would be lastComponendID + 1;
@@ -535,4 +544,18 @@ public class IceMediaStream
this.checkList.add(candidatePair);
}
}
+
+ /**
+ * Adds pair to the valid list that this stream is
+ * maintaining.
+ *
+ * @param pair the {@link CandidatePair} to add to our valid list.
+ */
+ public void addValidPair(CandidatePair pair)
+ {
+ synchronized (validList)
+ {
+ validList.add(pair);
+ }
+ }
}
diff --git a/src/org/ice4j/ice/checks/ConnectivityCheckClient.java b/src/org/ice4j/ice/checks/ConnectivityCheckClient.java
index 7d71d0b..b3c1031 100644
--- a/src/org/ice4j/ice/checks/ConnectivityCheckClient.java
+++ b/src/org/ice4j/ice/checks/ConnectivityCheckClient.java
@@ -180,7 +180,7 @@ public class ConnectivityCheckClient
logger.fine("Received a non-symmetric response for pair: "+ pair
+". Failing");
- pair.setState(CandidatePairState.FAILED, null);
+ pair.setStateFailed();
}
//handle error responses.
else if(evt.getResponse().getMessageType()
@@ -220,7 +220,7 @@ public class ConnectivityCheckClient
{
logger.fine("Received a success response with no "
+"XOR_MAPPED_ADDRESS attribute.");
- checkedPair.setState(CandidatePairState.FAILED, null);
+ checkedPair.setStateFailed();
return; //malformed error response
}
@@ -270,20 +270,25 @@ public class ConnectivityCheckClient
validLocalCandidate = peerReflexiveCandidate;
}
+ //check if the resulting valid pair was already in our check lists.
+ CandidatePair existingPair = parentAgent.findCandidatePair(
+ validLocalCandidate.getTransportAddress(),
+ validRemoteCandidate.getTransportAddress());
+
// RFC 5245: 7.1.3.2.2. The agent constructs a candidate pair whose
// local candidate equals the mapped address of the response, and whose
// remote candidate equals the destination address to which the request
// was sent. This is called a valid pair, since it has been validated
// by a STUN connectivity check.
- CandidatePair validPair = new CandidatePair(validLocalCandidate,
+ CandidatePair validPair;
+ if(existingPair != null)
+ validPair = existingPair;
+ else
+ validPair = new CandidatePair(validLocalCandidate,
validRemoteCandidate);
- //If the pair equals the pair that generated the check or is on a check
- //list currently, it is also added to the VALID LIST, which is
- // maintained by the agent for each media stream.
-
- //if
-
+ validPair.getParentComponent().getParentStream()
+ .addValidPair(validPair);
}
/**
@@ -353,7 +358,7 @@ public class ConnectivityCheckClient
{
logger.fine("Received an unrecoverable error response for pair "
+ pair + " will mark the pair as FAILED.");
- pair.setState(CandidatePairState.FAILED, null);
+ pair.setStateFailed();
}
}
@@ -478,10 +483,9 @@ public class ConnectivityCheckClient
}
if(transactionID == null)
- pairToCheck.setState(CandidatePairState.FAILED, null);
+ pairToCheck.setStateFailed();
else
- pairToCheck.setState(
- CandidatePairState.IN_PROGRESS, transactionID);
+ pairToCheck.setStateInProgress(transactionID);
}
}
diff --git a/src/org/ice4j/ice/checks/ConnectivityCheckServer.java b/src/org/ice4j/ice/checks/ConnectivityCheckServer.java
index fe9ccf3..0030ef1 100644
--- a/src/org/ice4j/ice/checks/ConnectivityCheckServer.java
+++ b/src/org/ice4j/ice/checks/ConnectivityCheckServer.java
@@ -133,7 +133,7 @@ public class ConnectivityCheckServer
if (!parentAgent.isControlling()
&& request.contains(Attribute.USE_CANDIDATE))
{
-
+/////////////!!!!!!!!!!!!!!! TODO continue here.
}
}