Adds an IceProcessingState to Agents
This commit is contained in:
parent
ab877ab6f7
commit
3c3f40a38f
@ -921,50 +921,24 @@ public class Agent
|
|||||||
{
|
{
|
||||||
pairToNominate.nominate();
|
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();
|
Component parentComponent = pairToNominate.getParentComponent();
|
||||||
IceMediaStream parentStream = parentComponent.getParentStream();
|
IceMediaStream parentStream = parentComponent.getParentStream();
|
||||||
CheckList checkList = parentStream.getCheckList();
|
CheckList checkList = parentStream.getCheckList();
|
||||||
|
|
||||||
if( checkList.getState() == CheckListState.RUNNING )
|
if( checkList.getState() == CheckListState.RUNNING )
|
||||||
|
checkList.handleNomination(pairToNominate);
|
||||||
|
|
||||||
|
//Once there is at least one nominated pair in the valid list for
|
||||||
|
//every component of the media stream and the state of the
|
||||||
|
//check list is Running
|
||||||
|
if(parentStream.allComponentsAreNominated()
|
||||||
|
&& checkList.getState() == CheckListState.RUNNING)
|
||||||
{
|
{
|
||||||
//The agent MUST remove all Waiting and Frozen pairs in the check
|
//The agent MUST change the state of processing for its check
|
||||||
//list and triggered check queue for the same component as the
|
//list for that media stream to Completed.
|
||||||
//nominated pairs for that media stream.
|
checkList.setState(CheckListState.COMPLETED);
|
||||||
checkList.removeNonCompledPairsForComponent(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:
|
o Once the state of each check list is Completed:
|
||||||
|
|
||||||
* The agent sets the state of ICE processing overall to
|
* The agent sets the state of ICE processing overall to
|
||||||
@ -973,7 +947,31 @@ public class Agent
|
|||||||
* If an agent is controlling, it examines the highest-priority
|
* If an agent is controlling, it examines the highest-priority
|
||||||
nominated candidate pair for each component of each media
|
nominated candidate pair for each component of each media
|
||||||
stream. If any of those candidate pairs differ from the
|
stream. If any of those candidate pairs differ from the
|
||||||
|
default candidate pairs in the most recent offer/answer
|
||||||
|
exchange, the controlling agent MUST generate an updated offer
|
||||||
|
as described in Section 9. If the controlling agent is using
|
||||||
|
an aggressive nomination algorithm, this may result in several
|
||||||
|
updated offers as the pairs selected for media change. An
|
||||||
|
agent MAY delay sending the offer for a brief interval (one
|
||||||
|
second is RECOMMENDED) in order to allow the selected pairs to
|
||||||
|
stabilize.
|
||||||
|
|
||||||
|
o If the state of the check list is Failed, ICE has not been able to
|
||||||
|
complete for this media stream. The correct behavior depends on
|
||||||
|
the state of the check lists for other media streams:
|
||||||
|
|
||||||
|
* If all check lists are Failed, ICE processing overall is
|
||||||
|
considered to be in the Failed state, and the agent SHOULD
|
||||||
|
consider the session a failure, SHOULD NOT restart ICE, and the
|
||||||
|
controlling agent SHOULD terminate the entire session.
|
||||||
|
|
||||||
|
* If at least one of the check lists for other media streams is
|
||||||
|
Completed, the controlling agent SHOULD remove the failed media
|
||||||
|
stream from the session in its updated offer.
|
||||||
|
|
||||||
|
* If none of the check lists for other media streams are
|
||||||
|
Completed, but at least one is Running, the agent SHOULD let
|
||||||
|
ICE continue.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -296,8 +296,7 @@ public class CheckList
|
|||||||
* @param nominatedPair the {@link CandidatePair} whose nomination we need
|
* @param nominatedPair the {@link CandidatePair} whose nomination we need
|
||||||
* to handle.
|
* to handle.
|
||||||
*/
|
*/
|
||||||
public synchronized void removeNonCompledPairsForComponent(
|
public synchronized void handleNomination(CandidatePair nominatedPair)
|
||||||
CandidatePair nominatedPair)
|
|
||||||
{
|
{
|
||||||
Component cmp = nominatedPair.getParentComponent();
|
Component cmp = nominatedPair.getParentComponent();
|
||||||
Iterator<CandidatePair> pairsIter = iterator();
|
Iterator<CandidatePair> pairsIter = iterator();
|
||||||
@ -333,5 +332,4 @@ public class CheckList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -607,6 +607,29 @@ public class IceMediaStream
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns <tt>true</tt> if there is at least one nominated {@link
|
||||||
|
* CandidatePair} in the valid list for every {@link Component} of this
|
||||||
|
* stream and <tt>false</tt> otherwise.
|
||||||
|
*
|
||||||
|
* @return <tt>true</tt> if there is at least one nominated {@link
|
||||||
|
* CandidatePair} in the valid list for every {@link Component} of this
|
||||||
|
* stream and <tt>false</tt> otherwise.
|
||||||
|
*/
|
||||||
|
public boolean allComponentsAreNominated()
|
||||||
|
{
|
||||||
|
List<Component> components = getComponents();
|
||||||
|
|
||||||
|
synchronized (validList)
|
||||||
|
{
|
||||||
|
for(CandidatePair pair : validList)
|
||||||
|
if(pair.isNominated())
|
||||||
|
components.remove(pair.getParentComponent());
|
||||||
|
}
|
||||||
|
|
||||||
|
return components.size() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the first {@link CandidatePair} stored in this stream's valid
|
* Returns the first {@link CandidatePair} stored in this stream's valid
|
||||||
* list, that belongs to the specified <tt>component</tt>.
|
* list, that belongs to the specified <tt>component</tt>.
|
||||||
|
|||||||
72
src/org/ice4j/ice/IceProcessingState.java
Normal file
72
src/org/ice4j/ice/IceProcessingState.java
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* ice4j, the OpenSource Java Solution for NAT and Firewall Traversal.
|
||||||
|
* Maintained by the SIP Communicator community (http://sip-communicator.org).
|
||||||
|
*
|
||||||
|
* Distributable under LGPL license. See terms of license at gnu.org.
|
||||||
|
*/
|
||||||
|
package org.ice4j.ice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RFC 5245 mentions that ICE processing across all media streams also has a
|
||||||
|
* state associated with it. This state is equal to <tt>Running</tt> while ICE
|
||||||
|
* processing is under way. The state is Completed when ICE processing is
|
||||||
|
* complete and Failed if it failed without success. For convenience reasons
|
||||||
|
* we are also adding an extra <tt>Waiting</tt> state that reflects the state
|
||||||
|
* of an {@link Agent} before it starts processing. This is also an {@link
|
||||||
|
* Agent}'s default state.
|
||||||
|
*
|
||||||
|
* @author Emil Ivov
|
||||||
|
*/
|
||||||
|
public enum IceProcessingState
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The state is equal to <tt>Waiting</tt> if ICE processing has not started
|
||||||
|
* for the corresponding {@link Agent}.
|
||||||
|
*/
|
||||||
|
WAITING("Waiting"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The state is equal to <tt>Running</tt> while ICE processing is under way.
|
||||||
|
*/
|
||||||
|
RUNNING("Running"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The state is Completed when ICE processing is complete.
|
||||||
|
*/
|
||||||
|
COMPLETED("Completed"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The state is Completed when ICE processing is Failed if processing
|
||||||
|
* failed without success.
|
||||||
|
*/
|
||||||
|
FAILED("Failed");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of this <tt>IceProcessingState</tt> instance.
|
||||||
|
*/
|
||||||
|
private final String stateName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an <tt>IceProcessingState</tt> instance with the specified name.
|
||||||
|
*
|
||||||
|
* @param stateName the name of the <tt>IceProcessingState</tt> instance
|
||||||
|
* we'd like to create.
|
||||||
|
*/
|
||||||
|
private IceProcessingState(String stateName)
|
||||||
|
{
|
||||||
|
this.stateName = stateName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of this <tt>IceProcessingState</tt> (e.g. "Running",
|
||||||
|
* "Completed", or "Failed").
|
||||||
|
*
|
||||||
|
* @return the name of this <tt>IceProcessingState</tt> (e.g. "Running",
|
||||||
|
* "Completed", or "Failed").
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return stateName;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user