Makes it possible to complete connectivity establishment, create new streams, components and candidates and start a new connectivity establishment for them only.
This commit is contained in:
parent
1d3ce5ee57
commit
7de929986c
@ -237,11 +237,11 @@ public class Agent
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new media stream and stores it
|
||||
* Creates a new media stream and stores it.
|
||||
*
|
||||
* @param mediaStreamName the name of the media stream
|
||||
* @param mediaStreamName the name of the media stream
|
||||
*
|
||||
* @return a reference to the newly created <tt>IceMediaStream</tt>.
|
||||
* @return the newly created and stored <tt>IceMediaStream</tt>
|
||||
*/
|
||||
public IceMediaStream createMediaStream(String mediaStreamName)
|
||||
{
|
||||
@ -296,7 +296,20 @@ public class Agent
|
||||
|
||||
Component component = stream.createComponent(transport);
|
||||
|
||||
gatherCandidates(component, preferredPort, minPort, maxPort );
|
||||
gatherCandidates(component, preferredPort, minPort, maxPort);
|
||||
|
||||
/*
|
||||
* Lyubomir: After we've gathered the LocalCandidate for a Component and
|
||||
* before we've make them available to the caller, we have to make sure
|
||||
* that the ConnectivityCheckServer is started. If there's been a
|
||||
* previous connectivity establishment which has completed, it has
|
||||
* stopped the ConnectivityCheckServer. If the ConnectivtyCheckServer is
|
||||
* not started after we've made the gathered LocalCandidates available
|
||||
* to the caller, the caller may send them and a connectivity check may
|
||||
* arrive from the remote Agent.
|
||||
*/
|
||||
connCheckServer.start();
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@ -501,7 +514,8 @@ public class Agent
|
||||
protected void initCheckLists()
|
||||
{
|
||||
//first init the check list.
|
||||
List<IceMediaStream> streams = getStreams();
|
||||
List<IceMediaStream> streams
|
||||
= getStreamsWithPendingConnectivityEstablishment();
|
||||
|
||||
//init the maximum number of check list entries per stream.
|
||||
int maxCheckListSize = Integer.getInteger(
|
||||
@ -731,6 +745,44 @@ public class Agent
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the <tt>IceMediaStream</tt>s registered with this <tt>Agent</tt> for
|
||||
* which connectivity establishment is pending. For example, after a set of
|
||||
* <tt>IceMediaStream</tt>s is registered with this <tt>Agent</tt>,
|
||||
* connectivity establishment completes for them and then a new set of
|
||||
* <tt>IceMediaStream</tt>s is registered with this <tt>Agent</tt>, the
|
||||
* <tt>IceMediaStream</tt>s with pending connectivity establishment are
|
||||
* those from the second set.
|
||||
*
|
||||
* @return a <tt>List</tt> of the <tt>IceMediaStream</tt>s registered with
|
||||
* this <tt>Agent</tt> for which connectivity is pending.
|
||||
*/
|
||||
List<IceMediaStream> getStreamsWithPendingConnectivityEstablishment()
|
||||
{
|
||||
|
||||
/*
|
||||
* Lyubomir: We want to support establishing connectivity for streams
|
||||
* which have been created after connectivity has been established for
|
||||
* previously created streams. That is why we will remove the streams
|
||||
* which have their connectivity checks completed or failed i.e. these
|
||||
* streams have been handled by a previous connectivity establishment.
|
||||
*/
|
||||
List<IceMediaStream> streams = getStreams();
|
||||
Iterator<IceMediaStream> streamIter = streams.iterator();
|
||||
|
||||
while (streamIter.hasNext())
|
||||
{
|
||||
IceMediaStream stream = streamIter.next();
|
||||
CheckList checkList = stream.getCheckList();
|
||||
CheckListState checkListState = checkList.getState();
|
||||
|
||||
if (CheckListState.COMPLETED.equals(checkListState)
|
||||
|| CheckListState.FAILED.equals(checkListState))
|
||||
streamIter.remove();
|
||||
}
|
||||
return streams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the <tt>StunStack</tt> used by this <tt>Agent</tt>.
|
||||
*
|
||||
|
||||
@ -70,7 +70,10 @@ class ConnectivityCheckClient
|
||||
public void startChecks()
|
||||
{
|
||||
CheckList firstCheckList
|
||||
= parentAgent.getStreams().get(0).getCheckList();
|
||||
= parentAgent
|
||||
.getStreamsWithPendingConnectivityEstablishment()
|
||||
.get(0)
|
||||
.getCheckList();
|
||||
|
||||
startChecks(firstCheckList);
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ import org.ice4j.stack.*;
|
||||
* checks.
|
||||
*
|
||||
* @author Emil Ivov
|
||||
* @author Lyubomir Marinov
|
||||
*/
|
||||
class ConnectivityCheckServer
|
||||
implements RequestListener,
|
||||
@ -28,14 +29,20 @@ class ConnectivityCheckServer
|
||||
* The <tt>Logger</tt> used by the <tt>ConnectivityCheckServer</tt>
|
||||
* class and its instances for logging output.
|
||||
*/
|
||||
private static final Logger logger = Logger
|
||||
.getLogger(ConnectivityCheckServer.class.getName());
|
||||
private static final Logger logger
|
||||
= Logger.getLogger(ConnectivityCheckServer.class.getName());
|
||||
|
||||
/**
|
||||
* The agent that created us.
|
||||
*/
|
||||
private final Agent parentAgent;
|
||||
|
||||
/**
|
||||
* The indicator which determines whether this
|
||||
* <tt>ConnectivityCheckServer</tt> is currently started.
|
||||
*/
|
||||
private boolean started = false;
|
||||
|
||||
/**
|
||||
* The <tt>StunStack </tt> that we will use for connectivity checks.
|
||||
*/
|
||||
@ -53,8 +60,9 @@ class ConnectivityCheckServer
|
||||
this.parentAgent = parentAgent;
|
||||
|
||||
stunStack = this.parentAgent.getStunStack();
|
||||
stunStack.addRequestListener(this);
|
||||
stunStack.getCredentialsManager().registerAuthority(this);
|
||||
|
||||
start();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -366,10 +374,26 @@ class ConnectivityCheckServer
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops this server.
|
||||
* Starts this <tt>ConnectivityCheckServer</tt>. If it is not currently
|
||||
* running, does nothing.
|
||||
*/
|
||||
public void start()
|
||||
{
|
||||
if (!started)
|
||||
{
|
||||
stunStack.addRequestListener(this);
|
||||
started = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops this <tt>ConnectivityCheckServer</tt>. A stopped
|
||||
* <tt>ConnectivityCheckServer</tt> can be restarted by calling
|
||||
* {@link #start()} on it.
|
||||
*/
|
||||
public void stop()
|
||||
{
|
||||
stunStack.removeRequestListener(this);
|
||||
started = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,12 +322,8 @@ public class IceMediaStream
|
||||
*/
|
||||
protected void createCheckList(List<CandidatePair> checkList)
|
||||
{
|
||||
List<Component> componentsList = getComponents();
|
||||
|
||||
for(Component cmp : componentsList)
|
||||
{
|
||||
for(Component cmp : getComponents())
|
||||
createCheckList(cmp, checkList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -348,12 +344,12 @@ public class IceMediaStream
|
||||
{
|
||||
for(Candidate remoteCnd : remoteCnds)
|
||||
{
|
||||
if(!localCnd.canReach(remoteCnd))
|
||||
continue;
|
||||
if(localCnd.canReach(remoteCnd))
|
||||
{
|
||||
CandidatePair pair = new CandidatePair(localCnd, remoteCnd);
|
||||
|
||||
CandidatePair pair = new CandidatePair(localCnd, remoteCnd);
|
||||
|
||||
checkList.add(pair);
|
||||
checkList.add(pair);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -632,9 +628,9 @@ public class IceMediaStream
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <tt>false</tt> if there is at least one nominated {@link
|
||||
* 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>true</tt> otherwise.
|
||||
* 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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user