public class CandidatePair extends Object implements Comparable<CandidatePair>
Modifier and Type | Class and Description |
---|---|
static class |
CandidatePair.PairComparator
A Comparator using the compareTo method of the
CandidatePair
|
Modifier and Type | Field and Description |
---|---|
static CandidatePair.PairComparator |
comparator
A Comparator using the compareTo method of the
CandidatePair.
|
private TransactionID |
connCheckTranID
The
TransactionID of the client transaction for a connectivity
check over this pair in case it is in the
CandidatePairState.IN_PROGRESS state. |
static long |
CONSENT_FRESHNESS_UNKNOWN
The value of the consentFreshness property of
CandidatePair which indicates that the time in milliseconds of
the latest consent freshness confirmation is unknown.
|
private long |
consentFreshness
The time in milliseconds of the latest consent freshness confirmation.
|
private boolean |
isNominated
If a valid candidate pair has its nominated flag set, it means that it
may be selected by ICE for sending and receiving media.
|
private boolean |
isValid
Indicates whether this CandidatePair is on any of this agent's
valid pair lists.
|
private LocalCandidate |
localCandidate
The local candidate of this pair.
|
private static long |
MATH_POW_2_32
The value of Math.pow(2, 32) calculated once for the purposes of
optimizing performance.
|
private long |
priority
Priority of the candidate-pair
|
private RemoteCandidate |
remoteCandidate
The remote candidate of this pair.
|
private CandidatePairState |
state
Each candidate pair has a state that is assigned once the check list
for each media stream has been computed.
|
private boolean |
useCandidate
A flag indicating whether we have seen an incoming check request that
contained the USE-CANDIDATE attribute for this pair.
|
private boolean |
useCandidateSent
A flag indicating whether we have sent a check request that
contained the USE-CANDIDATE attribute for this pair.
|
Constructor and Description |
---|
CandidatePair(LocalCandidate localCandidate,
RemoteCandidate remoteCandidate)
Creates a CandidatePair instance mapping localCandidate
to remoteCandidate.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(CandidatePair candidatePair)
Compares this CandidatePair with the specified object for order.
|
protected void |
computePriority()
A candidate pair priority is computed the following way:
Let G be the priority for the candidate provided by the controlling agent. |
boolean |
equals(Object obj)
Compares this CandidatePair to obj and returns
true if pairs have equal local and equal remote candidates and
false otherwise.
|
TransactionID |
getConnectivityCheckTransaction()
Returns the
TransactionID used in the connectivity check
associated with this CandidatePair when it's in the
CandidatePairState.IN_PROGRESS or null if it's in
any other state. |
long |
getConsentFreshness()
Gets the time in milliseconds of the latest consent freshness
confirmation.
|
Candidate<?> |
getControlledAgentCandidate()
Returns the candidate in this pair that belongs to the controlled agent.
|
Candidate<?> |
getControllingAgentCandidate()
Returns the candidate in this pair that belongs to the controlling agent.
|
DatagramSocket |
getDatagramSocket()
Deprecated.
|
String |
getFoundation()
Returns the foundation of this CandidatePair.
|
IceSocketWrapper |
getIceSocketWrapper()
Deprecated.
|
LocalCandidate |
getLocalCandidate()
Returns the LocalCandidate of this CandidatePair.
|
Component |
getParentComponent()
Returns the Component that this pair belongs to.
|
long |
getPriority()
Returns the priority of this pair.
|
RemoteCandidate |
getRemoteCandidate()
Returns the remote candidate of this CandidatePair.
|
Socket |
getSocket()
Deprecated.
|
CandidatePairState |
getState()
Returns the state of this CandidatePair.
|
int |
hashCode() |
boolean |
isFrozen()
Determines whether this candidate pair is frozen or not.
|
boolean |
isNominated()
Returns the value of this pair's nominated flag.
|
boolean |
isValid()
Returns true if this pair has been confirmed by a connectivity
check response and false otherwise.
|
void |
nominate()
Sets this pair's nominated flag to true.
|
(package private) void |
setConsentFreshness()
Sets the time in milliseconds of the latest consent freshness
confirmation to now.
|
(package private) void |
setConsentFreshness(long consentFreshness)
Sets the time in milliseconds of the latest consent freshness
confirmation to a specific time.
|
protected void |
setLocalCandidate(LocalCandidate localCnd)
Sets the LocalCandidate of this CandidatePair.
|
protected void |
setRemoteCandidate(RemoteCandidate remoteCnd)
Sets the RemoteCandidate of this CandidatePair.
|
private void |
setState(CandidatePairState newState,
TransactionID tranID)
Sets the CandidatePairState of this pair to state.
|
void |
setStateFailed()
Sets the CandidatePairState of this pair to
CandidatePairState.FAILED . |
void |
setStateFrozen()
Sets the CandidatePairState of this pair to
CandidatePairState.FROZEN . |
void |
setStateInProgress(TransactionID tranID)
Sets the CandidatePairState of this pair to
CandidatePairState.FROZEN . |
void |
setStateSucceeded()
Sets the CandidatePairState of this pair to
CandidatePairState.SUCCEEDED . |
void |
setStateWaiting()
Sets the CandidatePairState of this pair to
CandidatePairState.WAITING . |
void |
setUseCandidateReceived()
Raises the useCandidate flag for this pair.
|
void |
setUseCandidateSent()
Raises the useCandidateSent flag for this pair.
|
String |
toShortString()
Returns a short String representation of this CandidatePair.
|
String |
toString()
Returns a String representation of this CandidatePair.
|
boolean |
useCandidateReceived()
Returns true if someone has previously raised this pair's
useCandidate flag and false otherwise.
|
boolean |
useCandidateSent()
Returns true if someone has previously raised this pair's
useCandidateSent flag and false otherwise.
|
protected void |
validate()
Marks this pair as valid.
|
public static final long CONSENT_FRESHNESS_UNKNOWN
private static final long MATH_POW_2_32
public static final CandidatePair.PairComparator comparator
private LocalCandidate localCandidate
private RemoteCandidate remoteCandidate
private long priority
private boolean useCandidate
private boolean useCandidateSent
private boolean isValid
private boolean isNominated
private CandidatePairState state
private TransactionID connCheckTranID
TransactionID
of the client transaction for a connectivity
check over this pair in case it is in the
CandidatePairState.IN_PROGRESS
state.private long consentFreshness
public CandidatePair(LocalCandidate localCandidate, RemoteCandidate remoteCandidate)
localCandidate
- the local candidate of the pair.remoteCandidate
- the remote candidate of the pair.public String getFoundation()
public LocalCandidate getLocalCandidate()
protected void setLocalCandidate(LocalCandidate localCnd)
localCnd
- the local Candidate of this
CandidatePair.public RemoteCandidate getRemoteCandidate()
protected void setRemoteCandidate(RemoteCandidate remoteCnd)
remoteCnd
- the local Candidate of this
CandidatePair.public CandidatePairState getState()
public void setStateFailed()
CandidatePairState.FAILED
. This method should only be called by
the ICE agent, during the execution of the ICE procedures.public void setStateFrozen()
CandidatePairState.FROZEN
. This method should only be called by
the ICE agent, during the execution of the ICE procedures.public void setStateInProgress(TransactionID tranID)
CandidatePairState.FROZEN
. This method should only be called by
the ICE agent, during the execution of the ICE procedures.tranID
- the TransactionID
that we are using for the
connectivity check in case we are entering the In-Progress
state and null otherwise.public void setStateSucceeded()
CandidatePairState.SUCCEEDED
. This method should only be called
by the ICE agent, during the execution of the ICE procedures.public void setStateWaiting()
CandidatePairState.WAITING
. This method should only be called by
the ICE agent, during the execution of the ICE procedures.private void setState(CandidatePairState newState, TransactionID tranID) throws IllegalArgumentException
CandidatePairState.IN_PROGRESS
or a non-null for any
other state would cause an IllegalArgumentException
to be thrown.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-Progress
state and null otherwise.IllegalArgumentException
- if state is #IN_PROGRESS
and tranID is null.public boolean isFrozen()
public Candidate<?> getControllingAgentCandidate()
public Candidate<?> getControlledAgentCandidate()
protected void computePriority()
pair priority = 2^32*MIN(G,D) + 2*MAX(G,D) + (G>D?1:0)
This formula ensures a unique priority for each pair. Once the priority is assigned, the agent sorts the candidate pairs in decreasing order of priority. If two pairs have identical priority, the ordering amongst them is arbitrary.
public long getPriority()
public int compareTo(CandidatePair candidatePair)
compareTo
in interface Comparable<CandidatePair>
candidatePair
- the Object to be compared.ClassCastException
- if the specified object's type prevents it
from being compared to this Object.public boolean equals(Object obj)
public String toString()
public String toShortString()
public Component getParentComponent()
public TransactionID getConnectivityCheckTransaction()
TransactionID
used in the connectivity check
associated with this CandidatePair
when it's in the
CandidatePairState.IN_PROGRESS
or null if it's in
any other state.TransactionID
used in the connectivity check
associated with this CandidatePair
when it's in the
CandidatePairState.IN_PROGRESS
or null if it's in
any other state.public void setUseCandidateSent()
public boolean useCandidateSent()
public void setUseCandidateReceived()
public boolean useCandidateReceived()
public void nominate()
public boolean isNominated()
public boolean isValid()
protected void validate()
public long getConsentFreshness()
void setConsentFreshness()
void setConsentFreshness(long consentFreshness)
consentFreshness
- the time in milliseconds of the latest consent
freshness to be set on this CandidatePair@Deprecated public DatagramSocket getDatagramSocket()
@Deprecated public Socket getSocket()
@Deprecated public IceSocketWrapper getIceSocketWrapper()
Copyright © 2018. All rights reserved.