Package 

Class CandidatePair

  • All Implemented Interfaces:
    java.lang.Comparable

    
    public class CandidatePair
     implements Comparable<CandidatePair>
                        

    CandidatePairs map local to remote Candidates so that they could be added to check lists. Connectivity in ICE is always verified by pairs: i.e. STUN packets are sent from the local candidate of a pair to the remote candidate of a pair. To see which pairs work, an agent schedules a series of ConnectivityChecks. Each check is a STUN request/response transaction that the client will perform on a particular candidate pair by sending a STUN request from the local candidate to the remote candidate.

    • Constructor Detail

      • CandidatePair

        CandidatePair(LocalCandidate localCandidate, RemoteCandidate remoteCandidate)
        Creates a CandidatePair instance mapping localCandidate to remoteCandidate.
        Parameters:
        localCandidate - the local candidate of the pair.
        remoteCandidate - the remote candidate of the pair.
    • Method Detail

      • setLocalCandidate

         void setLocalCandidate(LocalCandidate localCnd)

        Sets the LocalCandidate of this CandidatePair.

        Parameters:
        localCnd - the local Candidate of this CandidatePair.
      • setRemoteCandidate

         void setRemoteCandidate(RemoteCandidate remoteCnd)

        Sets the RemoteCandidate of this CandidatePair.

        Parameters:
        remoteCnd - the local Candidate of this CandidatePair.
      • getPriority

         long getPriority()

        Returns the priority of this pair.

      • isValid

         boolean isValid()

        Returns true if this pair has been confirmed by a connectivity check response and false otherwise.

      • isNominated

         boolean isNominated()

        Returns the value of this pair's nominated flag. If a valid candidate pair has its nominated flag set, it means that it may be selected by ICE for sending and receiving media.

      • getState

         CandidatePairState getState()

        Returns the state of this CandidatePair. Each candidate pair has a state that is assigned once the check list for each media stream has been computed. The ICE RFC defines five potential values that the state can have. They are represented here with the CandidatePairState enumeration.

      • setState

         synchronized void setState(CandidatePairState newState, TransactionID tranID)

        Sets the CandidatePairState of this pair to state. This method should only be called by the ice agent, during the execution of the ICE procedures. Note that passing a null transaction for the IN_PROGRESS or a non-null for any other state would cause an IllegalArgumentException to be thrown.

        Parameters:
        newState - the state that this candidate pair is to enter.
        tranID - the TransactionID that we are using for the connectivity check in case we are entering the In-Progressstate and null otherwise.
      • getConsentFreshness

         long getConsentFreshness()

        Gets the time in milliseconds of the latest consent freshness confirmation.

      • setConsentFreshness

         void setConsentFreshness(long consentFreshness)

        Sets the time in milliseconds of the latest consent freshness confirmation to a specific time.

        Parameters:
        consentFreshness - the time in milliseconds of the latest consent freshness to be set on this CandidatePair
      • getFoundation

         String getFoundation()

        Returns the foundation of this CandidatePair. The foundation of a CandidatePair is just the concatenation of the foundations of its two candidates. Initially, only the candidate pairs with unique foundations are tested. The other candidate pairs are marked "frozen". When the connectivity checks for a candidate pair succeed, the other candidate pairs with the same foundation are unfrozen. This avoids repeated checking of components which are superficially more attractive but in fact are likely to fail.

      • setStateFailed

         void setStateFailed()

        Sets the CandidatePairState of this pair to FAILED. This method should only be called by the ICE agent, during the execution of the ICE procedures.

      • setStateFrozen

         void setStateFrozen()

        Sets the CandidatePairState of this pair to FROZEN. This method should only be called by the ICE agent, during the execution of the ICE procedures.

      • setStateInProgress

         void setStateInProgress(TransactionID tranID)

        Sets the CandidatePairState of this pair to FROZEN. This method should only be called by the ICE agent, during the execution of the ICE procedures.

        Parameters:
        tranID - the TransactionID that we are using for the connectivity check in case we are entering the In-Progressstate and null otherwise.
      • setStateSucceeded

         void setStateSucceeded()

        Sets the CandidatePairState of this pair to SUCCEEDED. This method should only be called by the ICE agent, during the execution of the ICE procedures.

      • setStateWaiting

         void setStateWaiting()

        Sets the CandidatePairState of this pair to WAITING. This method should only be called by the ICE agent, during the execution of the ICE procedures.

      • isFrozen

         boolean isFrozen()

        Determines whether this candidate pair is frozen or not. Initially, only the candidate pairs with unique foundations are tested. The other candidate pairs are marked "frozen". When the connectivity checks for a candidate pair succeed, the other candidate pairs with the same foundation are unfrozen.

      • compareTo

         int compareTo(CandidatePair candidatePair)

        Compares this CandidatePair with the specified object for order. Returns a negative integer, zero, or a positive integer as this CandidatePair's priority is greater than, equal to, or less than the one of the specified object thus insuring that higher priority pairs will come first.

        Parameters:
        candidatePair - the Object to be compared.
      • equals

         boolean equals(Object obj)

        Compares this CandidatePair to obj and returns true if pairs have equal local and equal remote candidates and false otherwise.

        Parameters:
        obj - the Object that we'd like to compare this pair to.
      • toString

         String toString()

        Returns a String representation of this CandidatePair.

      • toShortString

         String toShortString()

        Returns a short String representation of this CandidatePair.

      • useCandidateSent

         boolean useCandidateSent()

        Returns true if someone has previously raised this pair's useCandidateSent flag and false otherwise.

      • useCandidateReceived

         boolean useCandidateReceived()

        Returns true if someone has previously raised this pair's useCandidate flag and false otherwise.

      • nominate

         void nominate()

        Sets this pair's nominated flag to true. If a valid candidate pair has its nominated flag set, it means that it may be selected by ICE for sending and receiving media.