Package org.jitsi.service.neomedia
Class DefaultStreamConnector
- java.lang.Object
-
- org.jitsi.service.neomedia.DefaultStreamConnector
-
- All Implemented Interfaces:
StreamConnector
public class DefaultStreamConnector extends Object implements StreamConnector
Represents a default implementation of StreamConnector which is initialized with a specific pair of control and data DatagramSockets and which closes them (if they exist) when itsclose()is invoked.- Author:
- Lubomir Marinov
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jitsi.service.neomedia.StreamConnector
StreamConnector.Protocol
-
-
Field Summary
Fields Modifier and Type Field Description static intBIND_RETRIES_DEFAULT_VALUEThe default number of binds that a Media Service Implementation should execute in case a port is already bound to (each retry would be on a new random port).static StringBIND_RETRIES_PROPERTY_NAMEThe name of the property containing the number of binds that a Media Service Implementation should execute in case a port is already bound to (each retry would be on a new port in the allowed boundaries).protected DatagramSocketcontrolSocketThe DatagramSocket that a stream should use for control data (e.g.protected DatagramSocketdataSocketThe DatagramSocket that a stream should use for data (e.g.static StringMAX_PORT_NUMBER_PROPERTY_NAMEThe name of the property that contains the maximum port number that we'd like our RTP managers to bind upon.static StringMIN_PORT_NUMBER_PROPERTY_NAMEThe name of the property that contains the minimum port number that we'd like our RTP managers to bind upon.protected booleanrtcpmuxWhether this DefaultStreamConnector uses rtcp-mux.
-
Constructor Summary
Constructors Constructor Description DefaultStreamConnector()Initializes a new DefaultStreamConnector instance with no control and data DatagramSockets.DefaultStreamConnector(DatagramSocket dataSocket, DatagramSocket controlSocket)Initializes a new DefaultStreamConnector instance which is to represent a specific pair of control and data DatagramSockets.DefaultStreamConnector(DatagramSocket dataSocket, DatagramSocket controlSocket, boolean rtcpmux)Initializes a new DefaultStreamConnector instance which is to represent a specific pair of control and data DatagramSockets.DefaultStreamConnector(InetAddress bindAddr)Initializes a new DefaultStreamConnector instance with a specific bind InetAddress.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Releases the resources allocated by this instance in the course of its execution and prepares it to be garbage collected.DatagramSocketgetControlSocket()Returns a reference to the DatagramSocket that a stream should use for control data (e.g.SocketgetControlTCPSocket()Returns a reference to the Socket that a stream should use for control data (e.g.DatagramSocketgetDataSocket()Returns a reference to the DatagramSocket that a stream should use for data (e.g.SocketgetDataTCPSocket()Returns a reference to the Socket that a stream should use for data (e.g.StreamConnector.ProtocolgetProtocol()Returns the protocol of this StreamConnector.booleanisRtcpmux()Returns true if this StreamConnector uses rtcp-mux, that is, if its data and control sockets share the same local address and port.voidstarted()Notifies this instance that utilization of its DatagramSockets for data and/or control traffic has started.voidstopped()Notifies this instance that utilization of its DatagramSockets for data and/or control traffic has temporarily stopped.
-
-
-
Field Detail
-
BIND_RETRIES_DEFAULT_VALUE
public static final int BIND_RETRIES_DEFAULT_VALUE
The default number of binds that a Media Service Implementation should execute in case a port is already bound to (each retry would be on a new random port).- See Also:
- Constant Field Values
-
BIND_RETRIES_PROPERTY_NAME
public static final String BIND_RETRIES_PROPERTY_NAME
The name of the property containing the number of binds that a Media Service Implementation should execute in case a port is already bound to (each retry would be on a new port in the allowed boundaries).- See Also:
- Constant Field Values
-
MAX_PORT_NUMBER_PROPERTY_NAME
public static final String MAX_PORT_NUMBER_PROPERTY_NAME
The name of the property that contains the maximum port number that we'd like our RTP managers to bind upon.- See Also:
- Constant Field Values
-
MIN_PORT_NUMBER_PROPERTY_NAME
public static final String MIN_PORT_NUMBER_PROPERTY_NAME
The name of the property that contains the minimum port number that we'd like our RTP managers to bind upon.- See Also:
- Constant Field Values
-
controlSocket
protected DatagramSocket controlSocket
The DatagramSocket that a stream should use for control data (e.g. RTCP) traffic.
-
dataSocket
protected DatagramSocket dataSocket
The DatagramSocket that a stream should use for data (e.g. RTP) traffic.
-
rtcpmux
protected boolean rtcpmux
Whether this DefaultStreamConnector uses rtcp-mux.
-
-
Constructor Detail
-
DefaultStreamConnector
public DefaultStreamConnector()
Initializes a new DefaultStreamConnector instance with no control and data DatagramSockets.Suitable for extenders willing to delay the creation of the control and data sockets. For example, they could override
getControlSocket()and/orgetDataSocket()and create them on demand.
-
DefaultStreamConnector
public DefaultStreamConnector(InetAddress bindAddr)
Initializes a new DefaultStreamConnector instance with a specific bind InetAddress. The new instance is to attempt to bind on demand to the specified InetAddress in the port range defined by the ConfigurationService propertiesMIN_PORT_NUMBER_PROPERTY_NAMEandMAX_PORT_NUMBER_PROPERTY_NAMEat mostBIND_RETRIES_PROPERTY_NAMEtimes.- Parameters:
bindAddr- the local InetAddress the new instance is to attempt to bind to
-
DefaultStreamConnector
public DefaultStreamConnector(DatagramSocket dataSocket, DatagramSocket controlSocket)
Initializes a new DefaultStreamConnector instance which is to represent a specific pair of control and data DatagramSockets.- Parameters:
dataSocket- the DatagramSocket to be used for data (e.g. RTP) trafficcontrolSocket- the DatagramSocket to be used for control data (e.g. RTCP) traffic
-
DefaultStreamConnector
public DefaultStreamConnector(DatagramSocket dataSocket, DatagramSocket controlSocket, boolean rtcpmux)
Initializes a new DefaultStreamConnector instance which is to represent a specific pair of control and data DatagramSockets.- Parameters:
dataSocket- the DatagramSocket to be used for data (e.g. RTP) trafficcontrolSocket- the DatagramSocket to be used for control data (e.g. RTCP) trafficrtcpmux- whether rtcpmux is used.
-
-
Method Detail
-
close
public void close()
Releases the resources allocated by this instance in the course of its execution and prepares it to be garbage collected.- Specified by:
closein interfaceStreamConnector- See Also:
StreamConnector.close()
-
getControlSocket
public DatagramSocket getControlSocket()
Returns a reference to the DatagramSocket that a stream should use for control data (e.g. RTCP) traffic.- Specified by:
getControlSocketin interfaceStreamConnector- Returns:
- a reference to the DatagramSocket that a stream should use for control data (e.g. RTCP) traffic
- See Also:
StreamConnector.getControlSocket()
-
getDataSocket
public DatagramSocket getDataSocket()
Returns a reference to the DatagramSocket that a stream should use for data (e.g. RTP) traffic.- Specified by:
getDataSocketin interfaceStreamConnector- Returns:
- a reference to the DatagramSocket that a stream should use for data (e.g. RTP) traffic
- See Also:
StreamConnector.getDataSocket()
-
getDataTCPSocket
public Socket getDataTCPSocket()
Returns a reference to the Socket that a stream should use for data (e.g. RTP) traffic.- Specified by:
getDataTCPSocketin interfaceStreamConnector- Returns:
- a reference to the Socket that a stream should use for data (e.g. RTP) traffic.
-
getControlTCPSocket
public Socket getControlTCPSocket()
Returns a reference to the Socket that a stream should use for control data (e.g. RTCP).- Specified by:
getControlTCPSocketin interfaceStreamConnector- Returns:
- a reference to the Socket that a stream should use for control data (e.g. RTCP).
-
getProtocol
public StreamConnector.Protocol getProtocol()
Returns the protocol of this StreamConnector.- Specified by:
getProtocolin interfaceStreamConnector- Returns:
- the protocol of this StreamConnector
-
started
public void started()
Notifies this instance that utilization of its DatagramSockets for data and/or control traffic has started.- Specified by:
startedin interfaceStreamConnector- See Also:
StreamConnector.started()
-
stopped
public void stopped()
Notifies this instance that utilization of its DatagramSockets for data and/or control traffic has temporarily stopped. This instance should be prepared to be started at a later time again though.- Specified by:
stoppedin interfaceStreamConnector- See Also:
StreamConnector.stopped()
-
isRtcpmux
public boolean isRtcpmux()
Returns true if this StreamConnector uses rtcp-mux, that is, if its data and control sockets share the same local address and port.- Specified by:
isRtcpmuxin interfaceStreamConnector- Returns:
- true if this StreamConnector uses rtcp-mux, that is, if its data and control sockets share the same local address and port.
-
-