Minor cleanup.

This commit is contained in:
boris 2014-08-29 08:26:51 +00:00
parent eac04a777d
commit 9b9fbb71d0
7 changed files with 48 additions and 62 deletions

View File

@ -85,6 +85,13 @@ public class Agent
private static final Logger logger private static final Logger logger
= Logger.getLogger(Agent.class.getName()); = Logger.getLogger(Agent.class.getName());
/**
* The name of the {@link PropertyChangeEvent} that we use to deliver
* events on changes in the state of ICE processing in this agent.
*/
public static final String PROPERTY_ICE_PROCESSING_STATE
= "IceProcessingState";
/** /**
* The LinkedHashMap used to store the media streams * The LinkedHashMap used to store the media streams
* This map preserves the insertion order of the media streams. * This map preserves the insertion order of the media streams.
@ -124,13 +131,6 @@ public class Agent
*/ */
private final DefaultNominator nominator; private final DefaultNominator nominator;
/**
* The name of the {@link PropertyChangeEvent} that we use to deliver
* events on changes in the state of ICE processing in this agent.
*/
public static final String PROPERTY_ICE_PROCESSING_STATE
= "IceProcessingState";
/** /**
* The value of <tt>Ta</tt> as specified by the application or <tt>-1</tt> * The value of <tt>Ta</tt> as specified by the application or <tt>-1</tt>
* if non was specified and we should calculate one ourselves. * if non was specified and we should calculate one ourselves.
@ -141,7 +141,7 @@ public class Agent
* The <tt>List</tt> of remote addresses that we have discovered through * The <tt>List</tt> of remote addresses that we have discovered through
* incoming connectivity checks, before actually receiving a session * incoming connectivity checks, before actually receiving a session
* description from the peer and that may potentially contain peer reflexive * description from the peer and that may potentially contain peer reflexive
* addresses. This list is stored and only if and while connectivity checks * addresses. This list is stored only if and while connectivity checks
* are not running. Once they start, we are able to determine whether the * are not running. Once they start, we are able to determine whether the
* addresses in here are actually peer-reflexive or not, and schedule * addresses in here are actually peer-reflexive or not, and schedule
* the necessary triggered checks. * the necessary triggered checks.
@ -241,7 +241,7 @@ public class Agent
private boolean shutdown = false; private boolean shutdown = false;
/** /**
* Indicates that harvesting has been started at least ones. Used to warn * Indicates that harvesting has been started at least once. Used to warn
* users who are trying to trickle, that they have already completed a * users who are trying to trickle, that they have already completed a
* harvest. We may use it to throw an exception at some point if it's ever * harvest. We may use it to throw an exception at some point if it's ever
* a problem. * a problem.
@ -301,8 +301,8 @@ public class Agent
// Since we add a new stream, we must wait to add the component and the // Since we add a new stream, we must wait to add the component and the
// remote candidates before starting to "RUN" this Agent. // remote candidates before starting to "RUN" this Agent.
// This is usefull if this Agent is already in COMPLETED state // This is useful if this Agent is already in COMPLETED state
// (isStarted() == true) due to a previous successful ICE preocedure: // (isStarted() == true) due to a previous successful ICE procedure:
// this way incoming connectivity checks are registered in the // this way incoming connectivity checks are registered in the
// preDiscoveredPairsQueue until this Agent is in RUNNING state. // preDiscoveredPairsQueue until this Agent is in RUNNING state.
this.setState(IceProcessingState.WAITING); this.setState(IceProcessingState.WAITING);
@ -322,7 +322,7 @@ public class Agent
* @param minPort the port number where we should first try to bind before * @param minPort the port number where we should first try to bind before
* moving to the next one (i.e. <tt>minPort + 1</tt>) * moving to the next one (i.e. <tt>minPort + 1</tt>)
* @param maxPort the maximum port number where we should try binding * @param maxPort the maximum port number where we should try binding
* before giving up and throwinG an exception. * before giving up and throwing an exception.
* *
* @return the newly created {@link Component} and with a list containing * @return the newly created {@link Component} and with a list containing
* all and only local candidates. * all and only local candidates.
@ -364,10 +364,10 @@ public class Agent
/* /*
* Lyubomir: After we've gathered the LocalCandidate for a Component and * Lyubomir: After we've gathered the LocalCandidate for a Component and
* before we've make them available to the caller, we have to make sure * before we've made them available to the caller, we have to make sure
* that the ConnectivityCheckServer is started. If there's been a * that the ConnectivityCheckServer is started. If there's been a
* previous connectivity establishment which has completed, it has * previous connectivity establishment which has completed, it has
* stopped the ConnectivityCheckServer. If the ConnectivtyCheckServer is * stopped the ConnectivityCheckServer. If the ConnectivityCheckServer is
* not started after we've made the gathered LocalCandidates available * not started after we've made the gathered LocalCandidates available
* to the caller, the caller may send them and a connectivity check may * to the caller, the caller may send them and a connectivity check may
* arrive from the remote Agent. * arrive from the remote Agent.
@ -1388,9 +1388,8 @@ public class Agent
{ {
//first check whether we already know about the remote address in case //first check whether we already know about the remote address in case
//we've just discovered a peer-reflexive candidate. //we've just discovered a peer-reflexive candidate.
CandidatePair knownPair = null; CandidatePair knownPair
= findCandidatePair(
knownPair = this.findCandidatePair(
triggerPair.getLocalCandidate().getTransportAddress(), triggerPair.getLocalCandidate().getTransportAddress(),
triggerPair.getRemoteCandidate().getTransportAddress()); triggerPair.getRemoteCandidate().getTransportAddress());

View File

@ -35,7 +35,7 @@ public class HostCandidateHarvester
= Logger.getLogger(HostCandidateHarvester.class.getName()); = Logger.getLogger(HostCandidateHarvester.class.getName());
/** /**
* Manages statisics about harvesting time. * Manages statistics about harvesting time.
*/ */
private HarvestStatistics harvestStatistics = new HarvestStatistics(); private HarvestStatistics harvestStatistics = new HarvestStatistics();
@ -312,7 +312,7 @@ public class HostCandidateHarvester
* @param minPort the port number where we should first try to bind before * @param minPort the port number where we should first try to bind before
* moving to the next one (i.e. <tt>minPort + 1</tt>) * moving to the next one (i.e. <tt>minPort + 1</tt>)
* @param maxPort the maximum port number where we should try binding * @param maxPort the maximum port number where we should try binding
* before giving up and throwinG an exception. * before giving up and throwing an exception.
* *
* @return the newly created <tt>DatagramSocket</tt>. * @return the newly created <tt>DatagramSocket</tt>.
* *
@ -488,7 +488,7 @@ public class HostCandidateHarvester
* @param minPort the port number where we should first try to bind before * @param minPort the port number where we should first try to bind before
* moving to the next one (i.e. <tt>minPort + 1</tt>) * moving to the next one (i.e. <tt>minPort + 1</tt>)
* @param maxPort the maximum port number where we should try binding * @param maxPort the maximum port number where we should try binding
* before giving up and throwinG an exception. * before giving up and throwing an exception.
* *
* @throws IllegalArgumentException if either <tt>minPort</tt> or * @throws IllegalArgumentException if either <tt>minPort</tt> or
* <tt>maxPort</tt> is not a valid port number or if <tt>minPort</tt> is * <tt>maxPort</tt> is not a valid port number or if <tt>minPort</tt> is

View File

@ -19,11 +19,11 @@ public abstract class IceSocketWrapper
/** /**
* Sends a <tt>DatagramPacket</tt> from this socket * Sends a <tt>DatagramPacket</tt> from this socket
* It is a utility method to provide a common way to send for both * It is a utility method to provide a common way to send for both
* UDP and TCP socket. If the underlying socket is a TCP ones, it is still * UDP and TCP socket. If the underlying socket is a TCP one, it is still
* possible to get the <tt>OutputStream</tt> and do stuff with it. * possible to get the <tt>OutputStream</tt> and do stuff with it.
* *
* *
* @param p <tt>DatagramPacket</tt> to sent * @param p <tt>DatagramPacket</tt> to send
* @throws IOException if something goes wrong * @throws IOException if something goes wrong
*/ */
public abstract void send(DatagramPacket p) public abstract void send(DatagramPacket p)
@ -32,7 +32,7 @@ public abstract class IceSocketWrapper
/** /**
* Receives a <tt>DatagramPacket</tt> from this socket. * Receives a <tt>DatagramPacket</tt> from this socket.
* It is a utility method to provide a common way to receive for both * It is a utility method to provide a common way to receive for both
* UDP and TCP socket. If the underlying socket is a TCP ones, it is still * UDP and TCP socket. If the underlying socket is a TCP one, it is still
* possible to get the <tt>InputStream</tt> and do stuff with it. * possible to get the <tt>InputStream</tt> and do stuff with it.
* *
* @param p <tt>DatagramPacket</tt> * @param p <tt>DatagramPacket</tt>
@ -68,20 +68,20 @@ public abstract class IceSocketWrapper
public abstract SocketAddress getLocalSocketAddress(); public abstract SocketAddress getLocalSocketAddress();
/** /**
* Returns Socket object if the delegate socket is a TCP ones, null * Returns Socket object if the delegate socket is a TCP one, null
* otherwise. * otherwise.
* *
* @return Socket object if the delegate socket is a TCP ones, null * @return Socket object if the delegate socket is a TCP one, null
* otherwise * otherwise.
*/ */
public abstract Socket getTCPSocket(); public abstract Socket getTCPSocket();
/** /**
* Returns DatagramSocket object if the delegate socket is a TCP ones, null * Returns DatagramSocket object if the delegate socket is a UDP one, null
* otherwise. * otherwise.
* *
* @return DatagramSocket object if the delegate socket is a TCP ones, null * @return DatagramSocket object if the delegate socket is a UDP one, null
* otherwise * otherwise.
*/ */
public abstract DatagramSocket getUDPSocket(); public abstract DatagramSocket getUDPSocket();
} }

View File

@ -135,24 +135,18 @@ public class IceTcpSocketWrapper
} }
/** /**
* Returns Socket object if the delegate socket is a TCP ones, null * {@inheritDoc}
* otherwise.
*
* @return Socket object if the delegate socket is a TCP ones, null
* otherwise
*/ */
@Override
public Socket getTCPSocket() public Socket getTCPSocket()
{ {
return socket; return socket;
} }
/** /**
* Returns DatagramSocket object if the delegate socket is a TCP ones, null * {@inheritDoc}
* otherwise.
*
* @return DatagramSocket object if the delegate socket is a TCP ones, null
* otherwise
*/ */
@Override
public DatagramSocket getUDPSocket() public DatagramSocket getUDPSocket()
{ {
return null; return null;

View File

@ -87,24 +87,18 @@ public class IceUdpSocketWrapper
} }
/** /**
* Returns Socket object if the delegate socket is a TCP ones, null * {@inheritDoc}
* otherwise.
*
* @return Socket object if the delegate socket is a TCP ones, null
* otherwise
*/ */
@Override
public Socket getTCPSocket() public Socket getTCPSocket()
{ {
return null; return null;
} }
/** /**
* Returns DatagramSocket object if the delegate socket is a TCP ones, null * {@inheritDoc}
* otherwise.
*
* @return DatagramSocket object if the delegate socket is a TCP ones, null
* otherwise
*/ */
@Override
public DatagramSocket getUDPSocket() public DatagramSocket getUDPSocket()
{ {
return socket; return socket;

View File

@ -317,18 +317,19 @@ public class MultiplexingSocket
* @throws SocketTimeoutException if the timeout has expired * @throws SocketTimeoutException if the timeout has expired
* @throws IOException if an I/O error occurs * @throws IOException if an I/O error occurs
*/ */
private void receive(List<DatagramPacket> received, DatagramPacket p, private void receive(List<DatagramPacket> received,
int timeout) DatagramPacket p,
int timeout)
throws SocketTimeoutException, IOException throws SocketTimeoutException, IOException
{ {
long now, start = System.currentTimeMillis(); long now, start = System.currentTimeMillis();
DatagramPacket r = null; DatagramPacket r = null;
do do
{ {
now = System.currentTimeMillis(); now = System.currentTimeMillis();
if (timeout > 0 && now - start >= timeout) if (timeout > 0 && now - start >= timeout)
throw new SocketTimeoutException("Socket timeout"); throw new SocketTimeoutException("Socket timeout");
boolean doReceive; boolean doReceive;
@ -341,10 +342,10 @@ public class MultiplexingSocket
doReceive = false; doReceive = false;
try try
{ {
if (timeout > 0) if (timeout > 0)
receiveSyncRoot.wait(timeout - (now - start)); receiveSyncRoot.wait(timeout - (now - start));
else else
receiveSyncRoot.wait(); receiveSyncRoot.wait();
} }
catch (InterruptedException iex) catch (InterruptedException iex)
{ {

View File

@ -56,7 +56,7 @@ public class StunStack
/** /**
* Our network gateway. * Our network gateway.
*/ */
private NetAccessManager netAccessManager = null; private final NetAccessManager netAccessManager;
/** /**
* The {@link CredentialsManager} that we are using for retrieving * The {@link CredentialsManager} that we are using for retrieving
@ -464,8 +464,6 @@ public class StunStack
ioex); ioex);
} }
} }
/**
/** /**
* Sends a specific STUN <tt>Indication</tt> to a specific destination * Sends a specific STUN <tt>Indication</tt> to a specific destination