Saves trickled remote candidates in the remoteCandidate list in Component. Checks for duplicates before adding new candidates.
This commit is contained in:
parent
cf6d78208f
commit
be112c1aae
@ -251,8 +251,32 @@ public class Component
|
|||||||
logger.info("Update remote candidate for " + toShortString() + ": " +
|
logger.info("Update remote candidate for " + toShortString() + ": " +
|
||||||
candidate.getTransportAddress());
|
candidate.getTransportAddress());
|
||||||
|
|
||||||
|
List<RemoteCandidate> existingCandidates
|
||||||
|
= new LinkedList<RemoteCandidate>();
|
||||||
|
synchronized (remoteCandidates)
|
||||||
|
{
|
||||||
|
existingCandidates.addAll(remoteCandidates);
|
||||||
|
}
|
||||||
|
|
||||||
synchronized(remoteUpdateCandidates)
|
synchronized(remoteUpdateCandidates)
|
||||||
{
|
{
|
||||||
|
existingCandidates.addAll(remoteUpdateCandidates);
|
||||||
|
|
||||||
|
// Make sure we add no duplicates
|
||||||
|
TransportAddress transportAddress = candidate.getTransportAddress();
|
||||||
|
CandidateType type = candidate.getType();
|
||||||
|
for (RemoteCandidate existingCandidate : existingCandidates)
|
||||||
|
{
|
||||||
|
if (transportAddress
|
||||||
|
.equals(existingCandidate.getTransportAddress())
|
||||||
|
&& type == existingCandidate.getType())
|
||||||
|
{
|
||||||
|
logger.info("Not adding duplicate remote candidate: "
|
||||||
|
+ candidate.getTransportAddress());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
remoteUpdateCandidates.add(candidate);
|
remoteUpdateCandidates.add(candidate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -331,12 +355,16 @@ public class Component
|
|||||||
public void updateRemoteCandidates()
|
public void updateRemoteCandidates()
|
||||||
{
|
{
|
||||||
List<CandidatePair> checkList = null;
|
List<CandidatePair> checkList = null;
|
||||||
|
List<RemoteCandidate> newRemoteCandidates;
|
||||||
|
|
||||||
synchronized(remoteUpdateCandidates)
|
synchronized(remoteUpdateCandidates)
|
||||||
{
|
{
|
||||||
if(remoteUpdateCandidates.size() == 0)
|
if(remoteUpdateCandidates.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
newRemoteCandidates
|
||||||
|
= new LinkedList<RemoteCandidate>(remoteUpdateCandidates);
|
||||||
|
|
||||||
List<LocalCandidate> localCnds = getLocalCandidates();
|
List<LocalCandidate> localCnds = getLocalCandidates();
|
||||||
|
|
||||||
// remove UPnP base from local candidate
|
// remove UPnP base from local candidate
|
||||||
@ -388,6 +416,11 @@ public class Component
|
|||||||
remoteUpdateCandidates.clear();
|
remoteUpdateCandidates.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
synchronized (remoteCandidates)
|
||||||
|
{
|
||||||
|
remoteCandidates.addAll(newRemoteCandidates);
|
||||||
|
}
|
||||||
|
|
||||||
//sort and prune update checklist
|
//sort and prune update checklist
|
||||||
Collections.sort(checkList, CandidatePair.comparator);
|
Collections.sort(checkList, CandidatePair.comparator);
|
||||||
parentStream.pruneCheckList(checkList);
|
parentStream.pruneCheckList(checkList);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user