Merge duplicate ICE candidate pairs. (#195)
This can happen if a remote candidate is discovered as peer-reflexive and later received over signaling.
This commit is contained in:
parent
ca3868ac26
commit
e90c796d6d
@ -209,6 +209,25 @@ public class CheckList
|
|||||||
return highestPriorityPair; //return even if null
|
return highestPriorityPair; //return even if null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a pair which matches the specified local and remote candidates'
|
||||||
|
* transport addresses, if any, otherwise null.
|
||||||
|
*/
|
||||||
|
public synchronized CandidatePair findPairMatching(LocalCandidate local, RemoteCandidate remote)
|
||||||
|
{
|
||||||
|
for (CandidatePair pair : this)
|
||||||
|
{
|
||||||
|
if (pair.getLocalCandidate() == local ||
|
||||||
|
pair.getLocalCandidate().getTransportAddress().equals(local.getTransportAddress()))
|
||||||
|
{
|
||||||
|
if (pair.getRemoteCandidate() == remote ||
|
||||||
|
pair.getRemoteCandidate().getTransportAddress().equals(remote.getTransportAddress()))
|
||||||
|
return pair;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether this <tt>CheckList</tt> can be considered active.
|
* Determines whether this <tt>CheckList</tt> can be considered active.
|
||||||
* RFC 5245 says: A check list with at least one pair that is Waiting is
|
* RFC 5245 says: A check list with at least one pair that is Waiting is
|
||||||
|
|||||||
@ -437,8 +437,6 @@ public class Component
|
|||||||
= getParentStream()
|
= getParentStream()
|
||||||
.getParentAgent()
|
.getParentAgent()
|
||||||
.createCandidatePair(localCnd, remoteCnd);
|
.createCandidatePair(localCnd, remoteCnd);
|
||||||
logger.info("new Pair added: " + pair.toShortString()
|
|
||||||
+ ".");
|
|
||||||
checkList.add(pair);
|
checkList.add(pair);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -465,7 +463,24 @@ public class Component
|
|||||||
{
|
{
|
||||||
for (CandidatePair pair : checkList)
|
for (CandidatePair pair : checkList)
|
||||||
{
|
{
|
||||||
streamCheckList.add(pair);
|
/* Check whether the pair is already in the check list.
|
||||||
|
* (This can happen for pairs with remote peer-reflexive candidates,
|
||||||
|
* since those candidates aren't added to the candidate list even
|
||||||
|
* though the pair is added to the check list).
|
||||||
|
*/
|
||||||
|
CandidatePair existingPair = streamCheckList.findPairMatching(pair.getLocalCandidate(), pair.getRemoteCandidate());
|
||||||
|
if (existingPair != null) {
|
||||||
|
logger.info("existing Pair updated: " +
|
||||||
|
existingPair.toShortString() +
|
||||||
|
" to " + pair.toShortString() + ".");
|
||||||
|
existingPair.setRemoteCandidate(pair.getRemoteCandidate());
|
||||||
|
existingPair.computePriority();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
streamCheckList.add(pair);
|
||||||
|
logger.info("new Pair added: " + pair.toShortString()
|
||||||
|
+ ".");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user