-
- 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classCandidatePair.PairComparatorA Comparator using the compareTo method of the CandidatePair
-
Field Summary
Fields Modifier and Type Field Description public final static longCONSENT_FRESHNESS_UNKNOWNpublic final static CandidatePair.PairComparatorcomparatorprivate LocalCandidatelocalCandidateprivate RemoteCandidateremoteCandidateprivate longpriorityprivate booleanisValidprivate booleanisNominatedprivate CandidatePairStatestateprivate longconsentFreshness
-
Constructor Summary
Constructors Constructor Description CandidatePair(LocalCandidate localCandidate, RemoteCandidate remoteCandidate)Creates a CandidatePair instance mapping localCandidate to remoteCandidate.
-
Method Summary
Modifier and Type Method Description LocalCandidategetLocalCandidate()Returns the LocalCandidate of this CandidatePair. voidsetLocalCandidate(LocalCandidate localCnd)Sets the LocalCandidate of this CandidatePair. RemoteCandidategetRemoteCandidate()Returns the remote candidate of this CandidatePair. voidsetRemoteCandidate(RemoteCandidate remoteCnd)Sets the RemoteCandidate of this CandidatePair. longgetPriority()Returns the priority of this pair. booleanisValid()Returns true if this pair has been confirmed by a connectivity check response and false otherwise. booleanisNominated()Returns the value of this pair's nominated flag. CandidatePairStategetState()Returns the state of this CandidatePair. synchronized voidsetState(CandidatePairState newState, TransactionID tranID)Sets the CandidatePairState of this pair to state. longgetConsentFreshness()Gets the time in milliseconds of the latest consent freshness confirmation. voidsetConsentFreshness(long consentFreshness)Sets the time in milliseconds of the latest consent freshness confirmation to a specific time. StringgetFoundation()Returns the foundation of this CandidatePair. voidsetStateFailed()Sets the CandidatePairState of this pair to FAILED. voidsetStateFrozen()Sets the CandidatePairState of this pair to FROZEN. voidsetStateInProgress(TransactionID tranID)Sets the CandidatePairState of this pair to FROZEN. voidsetStateSucceeded()Sets the CandidatePairState of this pair to SUCCEEDED. voidsetStateWaiting()Sets the CandidatePairState of this pair to WAITING. booleanisFrozen()Determines whether this candidate pair is frozen or not. Candidate<out Object>getControllingAgentCandidate()Returns the candidate in this pair that belongs to the controlling agent. Candidate<out Object>getControlledAgentCandidate()Returns the candidate in this pair that belongs to the controlled agent. intcompareTo(CandidatePair candidatePair)Compares this CandidatePair with the specified object for order. booleanequals(Object obj)Compares this CandidatePair to obj and returns true if pairs have equal local and equal remote candidates and false otherwise. inthashCode()StringtoString()Returns a String representation of this CandidatePair. StringtoShortString()Returns a short String representation of this CandidatePair. ComponentgetParentComponent()Returns the Component that this pair belongs to. TransactionIDgetConnectivityCheckTransaction()Returns the TransactionID used in the connectivity check associated with this CandidatePair when it's in the IN_PROGRESS or null if it's in any other state. booleanuseCandidateSent()Returns true if someone has previously raised this pair's useCandidateSent flag and false otherwise. voidsetUseCandidateReceived()Raises the useCandidate flag for this pair. booleanuseCandidateReceived()Returns true if someone has previously raised this pair's useCandidate flag and false otherwise. voidnominate()Sets this pair's nominated flag to true. DatagramSocketgetDatagramSocket()Returns the UDP DatagramSocket (if any) for this CandidatePair. SocketgetSocket()Returns the TCP Socket (if any) for this CandidatePair. IceSocketWrappergetIceSocketWrapper()Returns the IceSocketWrapper for this CandidatePair. -
-
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
-
getLocalCandidate
LocalCandidate getLocalCandidate()
Returns the LocalCandidate of this CandidatePair.
-
setLocalCandidate
void setLocalCandidate(LocalCandidate localCnd)
Sets the LocalCandidate of this CandidatePair.
- Parameters:
localCnd- the local Candidate of this CandidatePair.
-
getRemoteCandidate
RemoteCandidate getRemoteCandidate()
Returns the remote 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.
-
getControllingAgentCandidate
Candidate<out Object> getControllingAgentCandidate()
Returns the candidate in this pair that belongs to the controlling agent.
-
getControlledAgentCandidate
Candidate<out Object> getControlledAgentCandidate()
Returns the candidate in this pair that belongs to the controlled agent.
-
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.
-
hashCode
int hashCode()
-
toShortString
String toShortString()
Returns a short String representation of this CandidatePair.
-
getParentComponent
Component getParentComponent()
Returns the Component that this pair belongs to.
-
getConnectivityCheckTransaction
TransactionID getConnectivityCheckTransaction()
Returns the TransactionID used in the connectivity check associated with this CandidatePair when it's in the IN_PROGRESS or null if it's in any other state.
-
useCandidateSent
boolean useCandidateSent()
Returns true if someone has previously raised this pair's useCandidateSent flag and false otherwise.
-
setUseCandidateReceived
void setUseCandidateReceived()
Raises the useCandidate flag for this pair.
-
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.
-
getDatagramSocket
@Deprecated() DatagramSocket getDatagramSocket()
Returns the UDP DatagramSocket (if any) for this CandidatePair.
-
getSocket
@Deprecated() Socket getSocket()
Returns the TCP Socket (if any) for this CandidatePair.
-
getIceSocketWrapper
@Deprecated() IceSocketWrapper getIceSocketWrapper()
Returns the IceSocketWrapper for this CandidatePair.
-
-
-
-