Implements client side valid list construction (RFC 5245: Section 7.1.3.2.2)
This commit is contained in:
parent
ba1fdf0a9d
commit
7e2b709d28
@ -156,15 +156,66 @@ public class CandidatePair
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <tt>CandidatePairState</tt> 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 <tt>CandidatePairState</tt> 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 <tt>CandidatePairState</tt> 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 <tt>In-Progress</tt>
|
||||
* state and <tt>null</tt> otherwise.
|
||||
*/
|
||||
public void setStateInProgress(TransactionID tranID)
|
||||
{
|
||||
setState(CandidatePairState.IN_PROGRESS, tranID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <tt>CandidatePairState</tt> 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 <tt>CandidatePairState</tt> 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 <tt>CandidatePairState</tt> of this pair to <tt>state</tt>. This
|
||||
* method should only be called by the ice agent, during the execution of
|
||||
* the ICE procedures. Note that passing a <tt>null</tt> transaction for the
|
||||
* {@link CandidatePairState#IN_PROGRESS} or a non-<tt>null</tt> 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 <tt>tranID</tt> is <tt>null</tt>.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -42,6 +42,15 @@ public class IceMediaStream
|
||||
private final LinkedHashMap<Integer, Component> components
|
||||
= new LinkedHashMap<Integer, Component>();
|
||||
|
||||
/**
|
||||
* 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<CandidatePair> validList
|
||||
= new TreeSet<CandidatePair>();
|
||||
|
||||
/**
|
||||
* 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 <tt>pair</tt> to the <tt>valid list</tt> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ public class ConnectivityCheckServer
|
||||
if (!parentAgent.isControlling()
|
||||
&& request.contains(Attribute.USE_CANDIDATE))
|
||||
{
|
||||
|
||||
/////////////!!!!!!!!!!!!!!! TODO continue here.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user