Manually formats (while reading the source code in the context of early DTLS support) for consistency.

This commit is contained in:
Lyubomir Marinov 2016-03-22 22:42:37 -05:00
parent ed15e98916
commit edd325a973
7 changed files with 73 additions and 67 deletions

View File

@ -707,7 +707,7 @@ public class Agent
synchronized(stateListeners) synchronized(stateListeners)
{ {
if(!stateListeners.contains(l)) if(!stateListeners.contains(l))
this.stateListeners.add(l); stateListeners.add(l);
} }
} }
@ -721,7 +721,7 @@ public class Agent
{ {
synchronized(stateListeners) synchronized(stateListeners)
{ {
this.stateListeners.remove(l); stateListeners.remove(l);
} }
} }
@ -1637,23 +1637,24 @@ public class Agent
public synchronized void nominate(CandidatePair pair) public synchronized void nominate(CandidatePair pair)
throws IllegalStateException throws IllegalStateException
{ {
if(! isControlling() ) if(!isControlling())
throw new IllegalStateException("Only controlling agents can " {
+"nominate pairs"); throw new IllegalStateException(
"Only controlling agents can nominate pairs");
}
Component parentComponent = pair.getParentComponent(); Component parentComponent = pair.getParentComponent();
IceMediaStream parentStream = parentComponent.getParentStream(); IceMediaStream parentStream = parentComponent.getParentStream();
//If the pair is not already nominated and if its parent component //If the pair is not already nominated and if its parent component
//does not already contain a nominated pair - nominate it. //does not already contain a nominated pair - nominate it.
if(!pair.isNominated() if (!pair.isNominated()
&& !parentStream.validListContainsNomineeForComponent( && !parentStream.validListContainsNomineeForComponent(
parentComponent)) parentComponent))
{ {
logger.info("verify if nominated pair answer again"); logger.info("verify if nominated pair answer again");
pair.nominate(); pair.nominate();
pair.getParentComponent().getParentStream() parentStream.getCheckList().scheduleTriggeredCheck(pair);
.getCheckList().scheduleTriggeredCheck(pair);
} }
} }

View File

@ -956,24 +956,24 @@ public abstract class Candidate<T extends Candidate<?>>
TransportAddress relatedAddress = null; TransportAddress relatedAddress = null;
switch (getType()) switch (getType())
{ {
case SERVER_REFLEXIVE_CANDIDATE: case SERVER_REFLEXIVE_CANDIDATE:
if(getBase() != null) if(getBase() != null)
{ {
relatedAddress = getBase().getTransportAddress(); relatedAddress = getBase().getTransportAddress();
} }
break; break;
case PEER_REFLEXIVE_CANDIDATE: case PEER_REFLEXIVE_CANDIDATE:
if(getBase() != null) if(getBase() != null)
{ {
relatedAddress = getBase().getTransportAddress(); relatedAddress = getBase().getTransportAddress();
} }
break; break;
case RELAYED_CANDIDATE: case RELAYED_CANDIDATE:
relatedAddress = getMappedAddress(); relatedAddress = getMappedAddress();
break; break;
default: default:
//host candidate //host candidate
return null; return null;
} }
// Update the related candidate conforming to the related address. // Update the related candidate conforming to the related address.
this.relatedCandidate = findRelatedCandidate(relatedAddress); this.relatedCandidate = findRelatedCandidate(relatedAddress);

View File

@ -131,7 +131,6 @@ public class CandidatePair
public CandidatePair(LocalCandidate localCandidate, public CandidatePair(LocalCandidate localCandidate,
RemoteCandidate remoteCandidate) RemoteCandidate remoteCandidate)
{ {
this.localCandidate = localCandidate; this.localCandidate = localCandidate;
this.remoteCandidate = remoteCandidate; this.remoteCandidate = remoteCandidate;
@ -449,9 +448,9 @@ public class CandidatePair
CandidatePair candidatePair = (CandidatePair) obj; CandidatePair candidatePair = (CandidatePair) obj;
//DO NOT change this method to also depend on other pair properties // XXX DO NOT change this method to also depend on other pair properties
//because the Conn Check Client counts on it only using the candidates // because ConnectivityCheckClient counts on it only using the
//for comparisons. // candidates for comparisons.
return return
localCandidate.equals(candidatePair.localCandidate) localCandidate.equals(candidatePair.localCandidate)
&& remoteCandidate.equals(candidatePair.remoteCandidate); && remoteCandidate.equals(candidatePair.remoteCandidate);
@ -616,8 +615,8 @@ public class CandidatePair
getParentComponent().getParentStream().firePairPropertyChange( getParentComponent().getParentStream().firePairPropertyChange(
this, this,
IceMediaStream.PROPERTY_PAIR_NOMINATED, IceMediaStream.PROPERTY_PAIR_NOMINATED,
false, /* oldValue */ false,
true); /* newValue */ true);
} }
/** /**

View File

@ -383,9 +383,9 @@ public class CheckList
return; return;
} }
logger.info("Selected pair for stream " + logger.info(
cmp.toShortString() + ": " + "Selected pair for stream " + cmp.toShortString() + ": "
nominatedPair.toShortString()); + nominatedPair.toShortString());
cmp.setSelectedPair(nominatedPair); cmp.setSelectedPair(nominatedPair);

View File

@ -248,7 +248,7 @@ class ConnectivityCheckClient
//if we are the controlling agent then we need to indicate our //if we are the controlling agent then we need to indicate our
//nominated pairs. //nominated pairs.
if(candidatePair.isNominated()) if (candidatePair.isNominated())
{ {
logger.fine( logger.fine(
"Add USE-CANDIDATE in check for: " "Add USE-CANDIDATE in check for: "
@ -485,7 +485,7 @@ class ConnectivityCheckClient
TransportAddress mappedAddress = null; TransportAddress mappedAddress = null;
if(! response.containsAttribute(Attribute.XOR_MAPPED_ADDRESS)) if (!response.containsAttribute(Attribute.XOR_MAPPED_ADDRESS))
{ {
logger.fine("Received a success response with no " logger.fine("Received a success response with no "
+ "XOR_MAPPED_ADDRESS attribute."); + "XOR_MAPPED_ADDRESS attribute.");
@ -496,14 +496,14 @@ class ConnectivityCheckClient
} }
XorMappedAddressAttribute mappedAddressAttr XorMappedAddressAttribute mappedAddressAttr
= (XorMappedAddressAttribute)response = (XorMappedAddressAttribute)
.getAttribute(Attribute.XOR_MAPPED_ADDRESS); response.getAttribute(Attribute.XOR_MAPPED_ADDRESS);
mappedAddress = mappedAddressAttr mappedAddress
.getAddress(response.getTransactionID()); = mappedAddressAttr.getAddress(response.getTransactionID());
// XXX AddressAttribute always returns UDP based TransportAddress // XXX AddressAttribute always returns UDP based TransportAddress
if(checkedPair.getLocalCandidate().getTransport() == Transport.TCP) if (checkedPair.getLocalCandidate().getTransport() == Transport.TCP)
{ {
mappedAddress mappedAddress
= new TransportAddress( = new TransportAddress(
@ -514,8 +514,7 @@ class ConnectivityCheckClient
LocalCandidate validLocalCandidate = null; LocalCandidate validLocalCandidate = null;
validLocalCandidate = parentAgent validLocalCandidate = parentAgent.findLocalCandidate(mappedAddress);
.findLocalCandidate(mappedAddress);
RemoteCandidate validRemoteCandidate = checkedPair.getRemoteCandidate(); RemoteCandidate validRemoteCandidate = checkedPair.getRemoteCandidate();
@ -523,7 +522,7 @@ class ConnectivityCheckClient
// response. If the transport address does not match any of the // response. If the transport address does not match any of the
// local candidates that the agent knows about, the mapped address // local candidates that the agent knows about, the mapped address
// represents a new candidate -- a peer reflexive candidate. // represents a new candidate -- a peer reflexive candidate.
if ( validLocalCandidate == null) if (validLocalCandidate == null)
{ {
//Like other candidates, PEER-REFLEXIVE candidates have a type, //Like other candidates, PEER-REFLEXIVE candidates have a type,
//base, priority, and foundation. They are computed as follows: //base, priority, and foundation. They are computed as follows:
@ -557,9 +556,12 @@ class ConnectivityCheckClient
//generated from it momentarily //generated from it momentarily
validLocalCandidate = peerReflexiveCandidate; validLocalCandidate = peerReflexiveCandidate;
if(checkedPair.getParentComponent().getSelectedPair() == null) if (checkedPair.getParentComponent().getSelectedPair() == null)
logger.info("Receive a peer-reflexive candidate: " + {
peerReflexiveCandidate.getTransportAddress()); logger.info(
"Receive a peer-reflexive candidate: "
+ peerReflexiveCandidate.getTransportAddress());
}
} }
//check if the resulting valid pair was already in our check lists. //check if the resulting valid pair was already in our check lists.
@ -588,27 +590,27 @@ class ConnectivityCheckClient
// (for the same check) from other peer come at the very same time, that // (for the same check) from other peer come at the very same time, that
// we will trigger the nominationConfirmed (that will pass the pair as // we will trigger the nominationConfirmed (that will pass the pair as
// as selected if it is the first time). // as selected if it is the first time).
synchronized(checkedPair) synchronized (checkedPair)
{ {
//The agent sets the state of the pair that *generated* the check to //The agent sets the state of the pair that *generated* the check to
//Succeeded. Note that, the pair which *generated* the check may be //Succeeded. Note that, the pair which *generated* the check may be
//different than the valid pair constructed above //different than the valid pair constructed above
if(checkedPair.getParentComponent().getSelectedPair() == null) if (checkedPair.getParentComponent().getSelectedPair() == null)
logger.info("Pair succeeded: " + checkedPair.toShortString()); logger.info("Pair succeeded: " + checkedPair.toShortString());
checkedPair.setStateSucceeded(); checkedPair.setStateSucceeded();
} }
if(! validPair.isValid()) if (!validPair.isValid())
{ {
if(validPair.getParentComponent().getSelectedPair() == null) if (validPair.getParentComponent().getSelectedPair() == null)
logger.info("Pair validated: " + validPair.toShortString()); logger.info("Pair validated: " + validPair.toShortString());
parentAgent.validatePair(validPair); parentAgent.validatePair(validPair);
} }
//The agent changes the states for all other Frozen pairs for the //The agent changes the states for all other Frozen pairs for the
//same media stream and same foundation to Waiting. //same media stream and same foundation to Waiting.
IceMediaStream parentStream = checkedPair.getParentComponent() IceMediaStream parentStream
.getParentStream(); = checkedPair.getParentComponent().getParentStream();
synchronized(this) synchronized(this)
{ {
@ -616,10 +618,14 @@ class ConnectivityCheckClient
= new Vector<>(parentStream.getCheckList()); = new Vector<>(parentStream.getCheckList());
for(CandidatePair pair : parentCheckList) for(CandidatePair pair : parentCheckList)
if ((pair.getState() == CandidatePairState.FROZEN) {
if (pair.getState() == CandidatePairState.FROZEN
&& checkedPair.getFoundation().equals( && checkedPair.getFoundation().equals(
pair.getFoundation())) pair.getFoundation()))
{
pair.setStateWaiting(); pair.setStateWaiting();
}
}
} }
// The agent examines the check list for all other streams in turn. If // The agent examines the check list for all other streams in turn. If
@ -636,7 +642,7 @@ class ConnectivityCheckClient
synchronized (checkList) synchronized (checkList)
{ {
for(CandidatePair pair : checkList) for (CandidatePair pair : checkList)
{ {
if (parentStream.validListContainsFoundation( if (parentStream.validListContainsFoundation(
pair.getFoundation()) pair.getFoundation())
@ -652,7 +658,7 @@ class ConnectivityCheckClient
//foundation, and for each group, sets the state of the pair with //foundation, and for each group, sets the state of the pair with
//the lowest component ID to Waiting. If there is more than one //the lowest component ID to Waiting. If there is more than one
//such pair, the one with the highest priority is used. //such pair, the one with the highest priority is used.
if(checkList.isFrozen()) if (checkList.isFrozen())
checkList.computeInitialCheckListPairStates(); checkList.computeInitialCheckListPairStates();
if (wasFrozen) if (wasFrozen)
@ -663,7 +669,7 @@ class ConnectivityCheckClient
} }
} }
if(validPair.getParentComponent().getSelectedPair() == null) if (validPair.getParentComponent().getSelectedPair() == null)
{ {
logger.info("IsControlling: " + parentAgent.isControlling() + logger.info("IsControlling: " + parentAgent.isControlling() +
" USE-CANDIDATE:" + " USE-CANDIDATE:" +
@ -674,8 +680,8 @@ class ConnectivityCheckClient
//If the agent was a controlling agent, and it had included a USE- //If the agent was a controlling agent, and it had included a USE-
//CANDIDATE attribute in the Binding request, the valid pair generated //CANDIDATE attribute in the Binding request, the valid pair generated
//from that check has its nominated flag set to true. //from that check has its nominated flag set to true.
if((parentAgent.isControlling() if (parentAgent.isControlling()
&& request.containsAttribute(Attribute.USE_CANDIDATE))) && request.containsAttribute(Attribute.USE_CANDIDATE))
{ {
if(validPair.getParentComponent().getSelectedPair() == null) if(validPair.getParentComponent().getSelectedPair() == null)
{ {
@ -695,7 +701,7 @@ class ConnectivityCheckClient
//itself had the USE-CANDIDATE attribute. This case is described in //itself had the USE-CANDIDATE attribute. This case is described in
//Section 7.2.1.5, and may now result in setting the nominated flag for //Section 7.2.1.5, and may now result in setting the nominated flag for
//the pair learned from the original request. //the pair learned from the original request.
else if(!parentAgent.isControlling() else if (!parentAgent.isControlling()
&& checkedPair.useCandidateReceived() && checkedPair.useCandidateReceived()
&& !checkedPair.isNominated()) && !checkedPair.isNominated())
{ {
@ -704,7 +710,7 @@ class ConnectivityCheckClient
logger.info( logger.info(
"Nomination confirmed for pair: " "Nomination confirmed for pair: "
+ validPair.toShortString()); + validPair.toShortString());
parentAgent.nominationConfirmed( checkedPair ); parentAgent.nominationConfirmed(checkedPair);
} }
else else
{ {

View File

@ -322,7 +322,7 @@ public class DefaultNominator
} }
} }
if(allFailed && !pair.isNominated()) if (allFailed && !pair.isNominated())
{ {
// all other pairs are failed to do not waste time, cancel // all other pairs are failed to do not waste time, cancel
// timer and nominate ourself (the relayed candidate). // timer and nominate ourself (the relayed candidate).

View File

@ -690,9 +690,9 @@ public class IceMediaStream
*/ */
protected boolean validListContainsNomineeForComponent(Component component) protected boolean validListContainsNomineeForComponent(Component component)
{ {
synchronized(validList) synchronized (validList)
{ {
for(CandidatePair pair : validList) for (CandidatePair pair : validList)
{ {
if (pair.isNominated() if (pair.isNominated()
&& pair.getParentComponent() == component) && pair.getParentComponent() == component)
@ -742,9 +742,9 @@ public class IceMediaStream
synchronized (validList) synchronized (validList)
{ {
for(CandidatePair pair : validList) for (CandidatePair pair : validList)
{ {
if(pair.isNominated()) if (pair.isNominated())
components.remove(pair.getParentComponent()); components.remove(pair.getParentComponent());
} }
} }