Adds CheckList initialization
This commit is contained in:
parent
aac38a4528
commit
af2aa86532
@ -215,6 +215,18 @@ public class Agent
|
|||||||
component.selectDefaultCandidate();
|
component.selectDefaultCandidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all stream check lists and begins the checks.
|
||||||
|
*/
|
||||||
|
public void startChecks()
|
||||||
|
{
|
||||||
|
List<IceMediaStream> streams = getStreams();
|
||||||
|
|
||||||
|
for(IceMediaStream stream : streams)
|
||||||
|
{
|
||||||
|
stream.initCheckList();
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Computes and sets the foundations foundation for all <tt>Candidate</tt>s
|
* Computes and sets the foundations foundation for all <tt>Candidate</tt>s
|
||||||
* currently found in <tt>component</tt>.
|
* currently found in <tt>component</tt>.
|
||||||
@ -224,7 +236,7 @@ public class Agent
|
|||||||
*/
|
*/
|
||||||
private void computeFoundations(Component component)
|
private void computeFoundations(Component component)
|
||||||
{
|
{
|
||||||
List<Candidate> candidates = component.getLocalCandidates();
|
List<LocalCandidate> candidates = component.getLocalCandidates();
|
||||||
|
|
||||||
for (Candidate cand : candidates)
|
for (Candidate cand : candidates)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -645,4 +645,35 @@ public abstract class Candidate
|
|||||||
//WTF?
|
//WTF?
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether this <tt>Candidate</tt>'s<tt>TransportAddress</tt> is
|
||||||
|
* theoretically usable for communication with that of <tt>dst</tt>. Same
|
||||||
|
* as calling:
|
||||||
|
* <p>
|
||||||
|
* <tt>getTransportAddress().canReach(dst.getTransportAddress())</tt>
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param dst the <tt>Candidate</tt> that we'd like to check for
|
||||||
|
* reachability from this one.
|
||||||
|
*
|
||||||
|
* @return <tt>true</tt> if this {@link Candidate} shares the same
|
||||||
|
* <tt>Transport</tt> and family as <tt>dst</tt> or <tt>false</tt>
|
||||||
|
* otherwise.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public boolean canReach(Candidate dst)
|
||||||
|
{
|
||||||
|
return getTransportAddress().canReach(dst.getTransportAddress());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether this <tt>Candidate</tt> is the default one for its
|
||||||
|
* parent component.
|
||||||
|
*
|
||||||
|
* @return <tt>true</tt> if this <tt>Candidate</tt> is the default for its
|
||||||
|
* parent component and <tt>false</tt> if it isn't or if it has no parent
|
||||||
|
* Component yet.
|
||||||
|
*/
|
||||||
|
public abstract boolean isDefault();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,7 @@ public class CandidatePair
|
|||||||
/**
|
/**
|
||||||
* The remote candidate of this pair.
|
* The remote candidate of this pair.
|
||||||
*/
|
*/
|
||||||
private final RemoteCandidate remoteCandidate;
|
private final Candidate remoteCandidate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Priority of the candidate-pair
|
* Priority of the candidate-pair
|
||||||
@ -60,7 +60,7 @@ public class CandidatePair
|
|||||||
* @param remoteCandidate the remote candidate of the pair.
|
* @param remoteCandidate the remote candidate of the pair.
|
||||||
*/
|
*/
|
||||||
public CandidatePair(LocalCandidate localCandidate,
|
public CandidatePair(LocalCandidate localCandidate,
|
||||||
RemoteCandidate remoteCandidate)
|
Candidate remoteCandidate)
|
||||||
{
|
{
|
||||||
|
|
||||||
this.localCandidate = localCandidate;
|
this.localCandidate = localCandidate;
|
||||||
@ -103,7 +103,7 @@ public class CandidatePair
|
|||||||
*
|
*
|
||||||
* @return the remote <tt>Candidate</tt> of this <tt>CandidatePair</tt>.
|
* @return the remote <tt>Candidate</tt> of this <tt>CandidatePair</tt>.
|
||||||
*/
|
*/
|
||||||
public RemoteCandidate getRemoteCandidate()
|
public Candidate getRemoteCandidate()
|
||||||
{
|
{
|
||||||
return remoteCandidate;
|
return remoteCandidate;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -137,11 +137,11 @@ public class Component
|
|||||||
* @return Returns a copy of the list containing all local candidates
|
* @return Returns a copy of the list containing all local candidates
|
||||||
* currently registered in this <tt>Component</tt>.
|
* currently registered in this <tt>Component</tt>.
|
||||||
*/
|
*/
|
||||||
public List<Candidate> getLocalCandidates()
|
public List<LocalCandidate> getLocalCandidates()
|
||||||
{
|
{
|
||||||
synchronized(localCandidates)
|
synchronized(localCandidates)
|
||||||
{
|
{
|
||||||
return new ArrayList<Candidate>(localCandidates);
|
return new ArrayList<LocalCandidate>(localCandidates);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,7 +447,7 @@ public class Component
|
|||||||
*/
|
*/
|
||||||
protected void eliminateRedundantCandidates()
|
protected void eliminateRedundantCandidates()
|
||||||
{
|
{
|
||||||
List<Candidate> candidatesCopy = getLocalCandidates();
|
List<LocalCandidate> candidatesCopy = getLocalCandidates();
|
||||||
|
|
||||||
for (Candidate cand : candidatesCopy)
|
for (Candidate cand : candidatesCopy)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -48,6 +48,12 @@ public class IceMediaStream
|
|||||||
*/
|
*/
|
||||||
private int lastComponentID = 0;
|
private int lastComponentID = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The CHECK-LIST for this stream as described in the ICE specification.
|
||||||
|
*/
|
||||||
|
private final List<CandidatePair> checkList
|
||||||
|
= new LinkedList<CandidatePair>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The agent that this media stream belongs to.
|
* The agent that this media stream belongs to.
|
||||||
*/
|
*/
|
||||||
@ -243,4 +249,60 @@ public class IceMediaStream
|
|||||||
component.free();
|
component.free();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates, initializes and orders the list of candidate pairs that would
|
||||||
|
* be used for the connectivity checks for all components in this stream.
|
||||||
|
*/
|
||||||
|
protected void initCheckList()
|
||||||
|
{
|
||||||
|
synchronized(checkList)
|
||||||
|
{
|
||||||
|
checkList.clear();
|
||||||
|
List<Component> componentsList = getComponents();
|
||||||
|
|
||||||
|
for(Component cmp : componentsList)
|
||||||
|
{
|
||||||
|
createCheckList(cmp, checkList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and adds to <tt>checkList</tt> all the <tt>CandidatePair</tt>s
|
||||||
|
* in <tt>component</tt>.
|
||||||
|
*
|
||||||
|
* @param component the <tt>Component</tt> whose candidates we need to
|
||||||
|
* pair and extract.
|
||||||
|
* @param checkList the list that we need to update with the new pairs.
|
||||||
|
*/
|
||||||
|
private void createCheckList(Component component,
|
||||||
|
List<CandidatePair> checkList)
|
||||||
|
{
|
||||||
|
List<LocalCandidate> localCnds = component.getLocalCandidates();
|
||||||
|
List<Candidate> remoteCnds = component.getRemoteCandidates();
|
||||||
|
|
||||||
|
for(LocalCandidate localCnd : localCnds)
|
||||||
|
{
|
||||||
|
for(Candidate remoteCnd : remoteCnds)
|
||||||
|
{
|
||||||
|
if(!localCnd.canReach(remoteCnd))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
CandidatePair pair = new CandidatePair(localCnd, remoteCnd);
|
||||||
|
|
||||||
|
checkList.add(pair);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the list of <tt>CandidatePair</tt>s for this stream.
|
||||||
|
*
|
||||||
|
* @return the list of <tt>CandidatePair</tt>s for this stream.
|
||||||
|
*/
|
||||||
|
public List<CandidatePair> getCheckList()
|
||||||
|
{
|
||||||
|
return checkList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,4 +54,23 @@ public abstract class LocalCandidate
|
|||||||
{
|
{
|
||||||
getSocket().close();
|
getSocket().close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether this <tt>Candidate</tt> is the default one for its
|
||||||
|
* parent component.
|
||||||
|
*
|
||||||
|
* @return <tt>true</tt> if this <tt>Candidate</tt> is the default for its
|
||||||
|
* parent component and <tt>false</tt> if it isn't or if it has no parent
|
||||||
|
* Component yet.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean isDefault()
|
||||||
|
{
|
||||||
|
Component parentCmp = getParentComponent();
|
||||||
|
|
||||||
|
if (parentCmp == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return equals(parentCmp.getDefaultCandidate());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,4 +59,23 @@ public class RemoteCandidate
|
|||||||
{
|
{
|
||||||
super.priority = priority;
|
super.priority = priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether this <tt>Candidate</tt> is the default one for its
|
||||||
|
* parent component.
|
||||||
|
*
|
||||||
|
* @return <tt>true</tt> if this <tt>Candidate</tt> is the default for its
|
||||||
|
* parent component and <tt>false</tt> if it isn't or if it has no parent
|
||||||
|
* Component yet.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean isDefault()
|
||||||
|
{
|
||||||
|
Component parentCmp = getParentComponent();
|
||||||
|
|
||||||
|
if (parentCmp == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return equals(parentCmp.getDefaultRemoteCandidate());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,6 +41,11 @@ public class Ice
|
|||||||
|
|
||||||
System.out.println("LocalAgent:\n" + localAgent);
|
System.out.println("LocalAgent:\n" + localAgent);
|
||||||
|
|
||||||
|
localAgent.startChecks();
|
||||||
|
|
||||||
|
System.out.println("Local audio clist:\n"
|
||||||
|
+ localAgent.getStream("audio").getCheckList());
|
||||||
|
|
||||||
System.out.println("Total execution time: "
|
System.out.println("Total execution time: "
|
||||||
+ (endTime - startTime) + "ms");
|
+ (endTime - startTime) + "ms");
|
||||||
}
|
}
|
||||||
@ -112,7 +117,8 @@ public class Ice
|
|||||||
private static void transferRemoteCandidates(Component localComponent,
|
private static void transferRemoteCandidates(Component localComponent,
|
||||||
Component remoteComponent)
|
Component remoteComponent)
|
||||||
{
|
{
|
||||||
List<Candidate> remoteCandidates = remoteComponent.getLocalCandidates();
|
List<LocalCandidate> remoteCandidates
|
||||||
|
= remoteComponent.getLocalCandidates();
|
||||||
|
|
||||||
localComponent.setDefaultRemoteCandidate(
|
localComponent.setDefaultRemoteCandidate(
|
||||||
remoteComponent.getDefaultCandidate());
|
remoteComponent.getDefaultCandidate());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user