localCandsIter = localCandidates.iterator();
+
+ while (localCandsIter.hasNext())
+ {
+ Candidate cand2 = localCandsIter.next();
+
+ if( cand != cand2
+ && cand.getTransportAddress()
+ .equals(cand2.getTransportAddress())
+ && cand.getBase().equals(cand2.getBase())
+ && cand.getPriority() >= cand2.getPriority() )
+ {
+ localCandsIter.remove();
+ if(logger.isLoggable(Level.FINEST))
+ logger.finest("eliminating redundant cand: "+ cand2);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns the Candidate that has been selected as the default
+ * for this Component or null if no such
+ * Candidate has been selected yet. A candidate is said to be
+ * default if it would be the target of media from a non-ICE peer;
+ *
+ * @return the Candidate that has been selected as the default for
+ * this Component or null if no such Candidate
+ * has been selected yet
+ */
+ public Candidate getDefaultCandidate()
+ {
+ return defaultCandidate;
+ }
+
+ /**
+ * Selects a Candidate that should be considered as the default
+ * for this Component. A candidate is said to be default if it
+ * would be the target of media from a non-ICE peer;
+ *
+ * The ICE specification RECOMMENDEDs that default candidates be chosen
+ * based on the likelihood of those candidates to work with the peer that is
+ * being contacted. It is RECOMMENDED that the default candidates are the
+ * relayed candidates (if relayed candidates are available), server
+ * reflexive candidates (if server reflexive candidates are available), and
+ * finally host candidates.
+ *
+ */
+ protected void selectDefaultCandidate()
+ {
+ synchronized(localCandidates)
+ {
+ Iterator localCandsIter = localCandidates.iterator();
+
+ while (localCandsIter.hasNext())
+ {
+ Candidate cand = localCandsIter.next();
+
+ if(this.defaultCandidate == null)
+ {
+ this.defaultCandidate = cand;
+ continue;
+ }
+
+ if( defaultCandidate.getDefaultPreference()
+ < cand.getDefaultPreference())
+ {
+ defaultCandidate = cand;
+ }
+ }
+ }
+ }
}