Implements support for Check List and Timer State Updates (RFC 5245 7.1.3.3.)
This commit is contained in:
parent
834b10cc69
commit
2ad5090e23
@ -132,7 +132,7 @@ public class Agent
|
|||||||
* The entity that will be taking care of incoming connectivity checks.
|
* The entity that will be taking care of incoming connectivity checks.
|
||||||
*/
|
*/
|
||||||
private final ConnectivityCheckServer connCheckServer
|
private final ConnectivityCheckServer connCheckServer
|
||||||
= new ConnectivityCheckServer(this, this);
|
= new ConnectivityCheckServer(this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether this agent has both sent and received candidate lists
|
* Indicates whether this agent has both sent and received candidate lists
|
||||||
|
|||||||
@ -569,7 +569,7 @@ public class IceMediaStream
|
|||||||
* @return <tt>true</tt> if this stream's <tt>validList</tt> contains a
|
* @return <tt>true</tt> if this stream's <tt>validList</tt> contains a
|
||||||
* pair with the specified <tt>foundation</tt> and <tt>false</tt> otherwise.
|
* pair with the specified <tt>foundation</tt> and <tt>false</tt> otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean containsFoundation(String foundation)
|
public boolean validListContainsFoundation(String foundation)
|
||||||
{
|
{
|
||||||
synchronized(validList)
|
synchronized(validList)
|
||||||
{
|
{
|
||||||
@ -580,4 +580,51 @@ public class IceMediaStream
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns <tt>true</tt> if this stream's valid list contains at least
|
||||||
|
* one {@link CandidatePair} for each {@link Component} of the stream and
|
||||||
|
* <tt>false</tt> otherwise.
|
||||||
|
*
|
||||||
|
* @return <tt>true</tt> if this stream's valid list contains at least
|
||||||
|
* one {@link CandidatePair} for each {@link Component} of the stream and
|
||||||
|
* <tt>false</tt> otherwise.
|
||||||
|
*/
|
||||||
|
public boolean validListContainsAllComponents()
|
||||||
|
{
|
||||||
|
List<Component> cmpList = getComponents();
|
||||||
|
for(Component cmp : cmpList)
|
||||||
|
{
|
||||||
|
if (getValidPair(cmp) != null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
//it looks like there's at least one component we don't have a
|
||||||
|
//valid candidate for.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the first {@link CandidatePair} stored in this stream's valid
|
||||||
|
* list, that belongs to the specified <tt>component</tt>.
|
||||||
|
*
|
||||||
|
* @param component the {@link Component} we'd like to obtain a valid
|
||||||
|
* pair for.
|
||||||
|
*
|
||||||
|
* @return a valid {@link CandidatePair} for the specified
|
||||||
|
* <tt>component</tt> if at least one exists, and <tt>null</tt> otherwise.
|
||||||
|
*/
|
||||||
|
public CandidatePair getValidPair(Component component)
|
||||||
|
{
|
||||||
|
synchronized(validList)
|
||||||
|
{
|
||||||
|
for(CandidatePair pair : validList)
|
||||||
|
if(pair.getParentComponent() == component)
|
||||||
|
return pair;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -214,6 +214,51 @@ public class ConnectivityCheckClient
|
|||||||
{
|
{
|
||||||
processSuccessResponse(evt);
|
processSuccessResponse(evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//7.1.3.3. Check List and Timer State Updates
|
||||||
|
//Regardless of whether the check was successful or failed, the
|
||||||
|
//completion of the transaction may require updating of check list and
|
||||||
|
//timer states.
|
||||||
|
CandidatePair checkedPair = ((CandidatePair)evt.getTransactionID()
|
||||||
|
.getApplicationData());
|
||||||
|
IceMediaStream stream = checkedPair.getParentComponent()
|
||||||
|
.getParentStream();
|
||||||
|
CheckList checkList = stream.getCheckList();
|
||||||
|
|
||||||
|
//If all of the pairs in the check list are now either in the Failed or
|
||||||
|
//Succeeded state:
|
||||||
|
boolean allPairsDone = true;
|
||||||
|
for(CandidatePair pair : checkList)
|
||||||
|
if(pair.getState() != CandidatePairState.FAILED
|
||||||
|
&& pair.getState() != CandidatePairState.SUCCEEDED)
|
||||||
|
allPairsDone = false;
|
||||||
|
|
||||||
|
if (allPairsDone)
|
||||||
|
{
|
||||||
|
//If there is not a pair in the valid list for each component of the
|
||||||
|
//media stream, the state of the check list is set to Failed.
|
||||||
|
if ( !stream.validListContainsAllComponents())
|
||||||
|
{
|
||||||
|
checkList.setState(CheckListState.FAILED);
|
||||||
|
}
|
||||||
|
|
||||||
|
//For each frozen check list, the agent groups together all of the
|
||||||
|
//pairs with the same foundation, and for each group, sets the
|
||||||
|
//state of the pair with the lowest component ID to Waiting. If
|
||||||
|
//there is more than one such pair, the one with the highest
|
||||||
|
//priority is used.
|
||||||
|
List<IceMediaStream> allOtherStreams = parentAgent.getStreams();
|
||||||
|
allOtherStreams.remove(checkList);
|
||||||
|
for (IceMediaStream anotherStream : allOtherStreams)
|
||||||
|
{
|
||||||
|
CheckList anotherCheckList = anotherStream.getCheckList();
|
||||||
|
if(anotherCheckList.isFrozen())
|
||||||
|
{
|
||||||
|
anotherCheckList.computeInitialCheckListPairStates();
|
||||||
|
startChecks(anotherCheckList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -332,7 +377,7 @@ public class ConnectivityCheckClient
|
|||||||
boolean wasFrozen = checkList.isFrozen();
|
boolean wasFrozen = checkList.isFrozen();
|
||||||
|
|
||||||
for(CandidatePair pair : checkList)
|
for(CandidatePair pair : checkList)
|
||||||
if (parentStream.containsFoundation(pair.getFoundation())
|
if (parentStream.validListContainsFoundation(pair.getFoundation())
|
||||||
&& pair.getState() == CandidatePairState.FROZEN)
|
&& pair.getState() == CandidatePairState.FROZEN)
|
||||||
pair.setStateWaiting();
|
pair.setStateWaiting();
|
||||||
|
|
||||||
|
|||||||
@ -35,12 +35,6 @@ public class ConnectivityCheckServer
|
|||||||
*/
|
*/
|
||||||
private final Agent parentAgent;
|
private final Agent parentAgent;
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link IncomingCheckProcessor} that we should notify when we notice
|
|
||||||
* new remote transport addresses.
|
|
||||||
*/
|
|
||||||
private final IncomingCheckProcessor addressHandler;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The stun stack that we will use for connectivity checks.
|
* The stun stack that we will use for connectivity checks.
|
||||||
*/
|
*/
|
||||||
@ -52,13 +46,10 @@ public class ConnectivityCheckServer
|
|||||||
* information such as user fragments for example.
|
* information such as user fragments for example.
|
||||||
*
|
*
|
||||||
* @param parentAgent the <tt>Agent</tt> that is creating this instance.
|
* @param parentAgent the <tt>Agent</tt> that is creating this instance.
|
||||||
* @param addressHandler the handler that
|
|
||||||
*/
|
*/
|
||||||
public ConnectivityCheckServer(Agent parentAgent,
|
public ConnectivityCheckServer(Agent parentAgent)
|
||||||
IncomingCheckProcessor addressHandler)
|
|
||||||
{
|
{
|
||||||
this.parentAgent = parentAgent;
|
this.parentAgent = parentAgent;
|
||||||
this.addressHandler = addressHandler;
|
|
||||||
stunStack.addRequestListener(this);
|
stunStack.addRequestListener(this);
|
||||||
stunStack.getCredentialsManager().registerAuthority(this);
|
stunStack.getCredentialsManager().registerAuthority(this);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user