From 91858ba6a3c08d0b46c45efe3f6d485d13f8717f Mon Sep 17 00:00:00 2001 From: Boris Grozev Date: Mon, 28 Nov 2016 14:05:40 -0600 Subject: [PATCH] feat: Removes the VIRTUAL_SOCKET_LAYER flag, enabling it by default. --- src/main/java/org/ice4j/StackProperties.java | 14 ------- src/main/java/org/ice4j/ice/Agent.java | 12 +----- src/main/java/org/ice4j/ice/Component.java | 38 ++++++------------- .../ice/harvest/SinglePortUdpHarvester.java | 6 +-- .../org/ice4j/ice/harvest/TcpHarvester.java | 23 +++-------- 5 files changed, 19 insertions(+), 74 deletions(-) diff --git a/src/main/java/org/ice4j/StackProperties.java b/src/main/java/org/ice4j/StackProperties.java index 2904cd2..da5b11d 100644 --- a/src/main/java/org/ice4j/StackProperties.java +++ b/src/main/java/org/ice4j/StackProperties.java @@ -232,20 +232,6 @@ public class StackProperties public static final String USE_DYNAMIC_HOST_HARVESTER = "org.ice4j.ice.harvest.USE_DYNAMIC_HOST_HARVESTER"; - /** - * The name of the property which specifies whether the virtual socket - * layer should be enabled. - * WARNING: enabling the virtual socket layer will break applications which - * use sockets from specific {@code CandidatePair}s in subtle and - * potentially hard to debug ways. This should only be used by applications - * that specifically want to use the virtual socket layer (i.e. use the - * socket instance provided by the {@code Component}, and not a specific - * {@code CandidatePair}). - * This is currently EXPERIMENTAL. - */ - public static final String ENABLE_VIRTUAL_SOCKET_LAYER - = "org.ice4j.ice.harvest.ENABLE_VIRTUAL_SOCKET_LAYER"; - /** * Returns the String value of the specified property (minus all * encompassing whitespaces)and null in case no property value was mapped diff --git a/src/main/java/org/ice4j/ice/Agent.java b/src/main/java/org/ice4j/ice/Agent.java index 1ece7ae..1c6fe8b 100644 --- a/src/main/java/org/ice4j/ice/Agent.java +++ b/src/main/java/org/ice4j/ice/Agent.java @@ -114,15 +114,6 @@ public class Agent public static final String PROPERTY_ICE_PROCESSING_STATE = "IceProcessingState"; - /** - * The flag which indicates whether the virtual socket layer should be - * enabled or not. - */ - public static boolean ENABLE_VIRTUAL_SOCKET_LAYER - = StackProperties.getBoolean( - StackProperties.ENABLE_VIRTUAL_SOCKET_LAYER, - false); - /** * The LinkedHashMap used to store the media streams * This map preserves the insertion order of the media streams. @@ -385,8 +376,7 @@ public class Agent if (logger.isLoggable(Level.FINE)) { - logger.fine("Created a new Agent, ufrag=" + ufrag - + ", VSL=" + ENABLE_VIRTUAL_SOCKET_LAYER); + logger.fine("Created a new Agent, ufrag=" + ufrag); } } diff --git a/src/main/java/org/ice4j/ice/Component.java b/src/main/java/org/ice4j/ice/Component.java index e268ab4..0c771e8 100644 --- a/src/main/java/org/ice4j/ice/Component.java +++ b/src/main/java/org/ice4j/ice/Component.java @@ -124,9 +124,7 @@ public class Component private final Logger logger; /** - * The {@link MergingDatagramSocket} instance which, if the virtual socket - * layer is enabled (see - * {@link StackProperties#ENABLE_VIRTUAL_SOCKET_LAYER}), will serve as the + * The {@link MergingDatagramSocket} instance which will serve as the * single socket instance for this {@link Component}, merging received * packets from all of its candidates. */ @@ -152,25 +150,17 @@ public class Component this.componentID = componentID; this.parentStream = mediaStream; - if (Agent.ENABLE_VIRTUAL_SOCKET_LAYER) + try { - try - { - mergingDatagramSocket = new MergingDatagramSocket(); - mergingDatagramSocketWrapper - = new IceUdpSocketWrapper( - new MultiplexingDatagramSocket( - mergingDatagramSocket)); - } - catch (SocketException se) - { - throw new RuntimeException(se); - } + mergingDatagramSocket = new MergingDatagramSocket(); + mergingDatagramSocketWrapper + = new IceUdpSocketWrapper( + new MultiplexingDatagramSocket( + mergingDatagramSocket)); } - else + catch (SocketException se) { - mergingDatagramSocket = null; - mergingDatagramSocketWrapper = null; + throw new RuntimeException(se); } logger @@ -950,9 +940,7 @@ public class Component /** * @return the single socket for this {@link Component} which should be - * used for reading and writing data, if the virtual socket layer is enabled - * (see {@link StackProperties#ENABLE_VIRTUAL_SOCKET_LAYER}), and - * {@code null} if it is not enabled. + * used for reading and writing data. */ public MergingDatagramSocket getSocket() { @@ -961,12 +949,10 @@ public class Component /** * @return an {@link IceSocketWrapper} instance wrapping the socket for this - * candidate (see {@link #getSocket()}), if the virtual socket layer is - * enabled (see {@link StackProperties#ENABLE_VIRTUAL_SOCKET_LAYER}), or - * {@code null} if it is not enabled. + * candidate (see {@link #getSocket()}). * @deprecated Use {@link #getSocket()} directly. This is only introduced * to ease the transition of applications which are already written to use - * a {@link IceSocketWrapper} instance. + * an {@link IceSocketWrapper} instance. */ @Deprecated public IceSocketWrapper getSocketWrapper() diff --git a/src/main/java/org/ice4j/ice/harvest/SinglePortUdpHarvester.java b/src/main/java/org/ice4j/ice/harvest/SinglePortUdpHarvester.java index e910cac..be9e25c 100644 --- a/src/main/java/org/ice4j/ice/harvest/SinglePortUdpHarvester.java +++ b/src/main/java/org/ice4j/ice/harvest/SinglePortUdpHarvester.java @@ -363,11 +363,7 @@ public class SinglePortUdpHarvester new TransportAddress(remoteAddress, Transport.UDP)); // TODO: maybe move this code to the candidates. - MergingDatagramSocket componentSocket = component.getSocket(); - if (componentSocket != null) - { - componentSocket.add(multiplexing); - } + component.getSocket().add(multiplexing); // XXX is this necessary? synchronized (candidateSockets) diff --git a/src/main/java/org/ice4j/ice/harvest/TcpHarvester.java b/src/main/java/org/ice4j/ice/harvest/TcpHarvester.java index 5a3c455..07ba748 100644 --- a/src/main/java/org/ice4j/ice/harvest/TcpHarvester.java +++ b/src/main/java/org/ice4j/ice/harvest/TcpHarvester.java @@ -488,21 +488,11 @@ public class TcpHarvester IceProcessingState state = component.getParentStream().getParentAgent().getState(); - if (!IceProcessingState.WAITING.equals(state) + if (logger.isLoggable(Level.FINE) + && !IceProcessingState.WAITING.equals(state) && !IceProcessingState.RUNNING.equals(state)) { - // If we are using the VSL, we can still make use of the socket. - // Otherwise, we have no use for it, so we better close it (and - // log a warning) early. - if (!Agent.ENABLE_VIRTUAL_SOCKET_LAYER) - { - throw new IllegalStateException( - "The associated Agent is in state " + state); - } - else if (logger.isLoggable(Level.FINE)) - { - logger.fine("Adding a socket to an Agent in state " + state); - } + logger.fine("Adding a socket to an Agent in state " + state); } // Socket to add to the candidate @@ -530,11 +520,8 @@ public class TcpHarvester candidate.addSocket(candidateSocket); // TODO: Maybe move this code to the candidate. - MergingDatagramSocket componentSocket = component.getSocket(); - if (componentSocket != null) - { - componentSocket.add(multiplexing); - } + component.getSocket().add(multiplexing); + // the socket is not our responsibility anymore. It is up to // the candidate/component to close/free it. }