Package org.jitsi.impl.neomedia
Class AbstractRTPConnector
- java.lang.Object
-
- org.jitsi.impl.neomedia.AbstractRTPConnector
-
- All Implemented Interfaces:
javax.media.rtp.RTPConnector
- Direct Known Subclasses:
RTPConnectorTCPImpl,RTPConnectorUDPImpl
public abstract class AbstractRTPConnector extends Object implements javax.media.rtp.RTPConnector
Provides a base/default implementation of RTPConnector which has factory methods for its control and data input and output streams and has an associated StreamConnector.- Author:
- Bing SU (nova.su@gmail.com), Lyubomir Marinov, Boris Grozev
-
-
Field Summary
Fields Modifier and Type Field Description protected StreamConnectorconnectorThe pair of datagram sockets for RTP and RTCP traffic that this instance uses in the form of a StreamConnector.
-
Constructor Summary
Constructors Constructor Description AbstractRTPConnector(StreamConnector connector)Initializes a new AbstractRTPConnector which is to use a given pair of datagram sockets for RTP and RTCP traffic specified in the form of a StreamConnector.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddTarget(javax.media.rtp.SessionAddress target)Add a stream target.voidclose()Closes all sockets, stream, and the StreamConnector that this RTPConnector is using.protected abstract RTPConnectorInputStream<?>createControlInputStream()Creates the RTCP packet input stream to be used by RTPManager.protected abstract RTPConnectorOutputStreamcreateControlOutputStream()Creates the RTCP packet output stream to be used by RTPManager.protected abstract RTPConnectorInputStream<?>createDataInputStream()Creates the RTP packet input stream to be used by RTPManager.protected abstract RTPConnectorOutputStreamcreateDataOutputStream()Creates the RTP packet output stream to be used by RTPManager.StreamConnectorgetConnector()Gets the StreamConnector which represents the pair of datagram sockets for RTP and RTCP traffic used by this instance.RTPConnectorInputStream<?>getControlInputStream()Returns the input stream that is handling incoming RTCP packets.protected RTPConnectorInputStream<?>getControlInputStream(boolean create)Gets the PushSourceStream which gives access to the RTCP data received from the remote targets and optionally creates it if it does not exist yet.RTPConnectorOutputStreamgetControlOutputStream()Returns the input stream that is handling outgoing RTCP packets.protected RTPConnectorOutputStreamgetControlOutputStream(boolean create)Gets the OutputDataStream which is used to write RTCP data to be sent to from the remote targets and optionally creates it if it does not exist yet.RTPConnectorInputStream<?>getDataInputStream()Returns the input stream that is handling incoming RTP packets.protected RTPConnectorInputStream<?>getDataInputStream(boolean create)Gets the PushSourceStream which gives access to the RTP data received from the remote targets and optionally creates it if it does not exist yet.RTPConnectorOutputStreamgetDataOutputStream()Returns the input stream that is handling outgoing RTP packets.RTPConnectorOutputStreamgetDataOutputStream(boolean create)Gets the OutputDataStream which is used to write RTP data to be sent to from the remote targets and optionally creates it if it does not exist yet.intgetReceiveBufferSize()Provides a dummy implementation toRTPConnector.getReceiveBufferSize()that always returns -1.doublegetRTCPBandwidthFraction()Provides a dummy implementation toRTPConnector.getRTCPBandwidthFraction()that always returns -1.doublegetRTCPSenderBandwidthFraction()Provides a dummy implementation toRTPConnector.getRTCPSenderBandwidthFraction()that always returns -1.intgetSendBufferSize()Provides a dummy implementation toRTPConnector.getSendBufferSize()that always returns -1.voidremoveTarget(javax.media.rtp.SessionAddress target)Removes a target from our session.voidremoveTargets()Remove all stream targets.voidsetDirection(MediaDirection direction)Configures this AbstractRTPConnector to allow RTP in the specified direction.voidsetReceiveBufferSize(int size)Provides a dummy implementation toRTPConnector.setReceiveBufferSize(int).voidsetSendBufferSize(int size)Provides a dummy implementation toRTPConnector.setSendBufferSize(int).
-
-
-
Field Detail
-
connector
protected final StreamConnector connector
The pair of datagram sockets for RTP and RTCP traffic that this instance uses in the form of a StreamConnector.
-
-
Constructor Detail
-
AbstractRTPConnector
public AbstractRTPConnector(StreamConnector connector)
Initializes a new AbstractRTPConnector which is to use a given pair of datagram sockets for RTP and RTCP traffic specified in the form of a StreamConnector.- Parameters:
connector- the pair of datagram sockets for RTP and RTCP traffic the new instance is to use
-
-
Method Detail
-
addTarget
public void addTarget(javax.media.rtp.SessionAddress target) throws IOExceptionAdd a stream target. A stream target is the destination address which this RTP session will send its data to. For a single session, we can add multiple SessionAddresses, and for each address, one copy of data will be sent to.- Parameters:
target- Destination target address- Throws:
IOException- if there was a socket-related error while adding the specified target
-
close
public void close()
Closes all sockets, stream, and the StreamConnector that this RTPConnector is using.- Specified by:
closein interfacejavax.media.rtp.RTPConnector
-
createControlInputStream
protected abstract RTPConnectorInputStream<?> createControlInputStream() throws IOException
Creates the RTCP packet input stream to be used by RTPManager.- Returns:
- a new RTCP packet input stream to be used by RTPManager
- Throws:
IOException- if an error occurs during the creation of the RTCP packet input stream
-
createControlOutputStream
protected abstract RTPConnectorOutputStream createControlOutputStream() throws IOException
Creates the RTCP packet output stream to be used by RTPManager.- Returns:
- a new RTCP packet output stream to be used by RTPManager
- Throws:
IOException- if an error occurs during the creation of the RTCP packet output stream
-
createDataInputStream
protected abstract RTPConnectorInputStream<?> createDataInputStream() throws IOException
Creates the RTP packet input stream to be used by RTPManager.- Returns:
- a new RTP packet input stream to be used by RTPManager
- Throws:
IOException- if an error occurs during the creation of the RTP packet input stream
-
createDataOutputStream
protected abstract RTPConnectorOutputStream createDataOutputStream() throws IOException
Creates the RTP packet output stream to be used by RTPManager.- Returns:
- a new RTP packet output stream to be used by RTPManager
- Throws:
IOException- if an error occurs during the creation of the RTP packet output stream
-
getConnector
public final StreamConnector getConnector()
Gets the StreamConnector which represents the pair of datagram sockets for RTP and RTCP traffic used by this instance.- Returns:
- the StreamConnector which represents the pair of datagram sockets for RTP and RTCP traffic used by this instance
-
getControlInputStream
public RTPConnectorInputStream<?> getControlInputStream() throws IOException
Returns the input stream that is handling incoming RTCP packets.- Specified by:
getControlInputStreamin interfacejavax.media.rtp.RTPConnector- Returns:
- the input stream that is handling incoming RTCP packets.
- Throws:
IOException- if an error occurs during the creation of the RTCP packet input stream
-
getControlInputStream
protected RTPConnectorInputStream<?> getControlInputStream(boolean create) throws IOException
Gets the PushSourceStream which gives access to the RTCP data received from the remote targets and optionally creates it if it does not exist yet.- Parameters:
create- true to create the PushSourceStream which gives access to the RTCP data received from the remote targets if it does not exist yet; otherwise, false- Returns:
- the PushBufferStream which gives access to the RTCP data received from the remote targets; null if it does not exist yet and create is false
- Throws:
IOException- if creating the PushSourceStream fails
-
getControlOutputStream
public RTPConnectorOutputStream getControlOutputStream() throws IOException
Returns the input stream that is handling outgoing RTCP packets.- Specified by:
getControlOutputStreamin interfacejavax.media.rtp.RTPConnector- Returns:
- the input stream that is handling outgoing RTCP packets.
- Throws:
IOException- if an error occurs during the creation of the RTCP packet output stream
-
getControlOutputStream
protected RTPConnectorOutputStream getControlOutputStream(boolean create) throws IOException
Gets the OutputDataStream which is used to write RTCP data to be sent to from the remote targets and optionally creates it if it does not exist yet.- Parameters:
create- true to create the OutputDataStream which is to be used to write RTCP data to be sent to the remote targets if it does not exist yet; otherwise, false- Returns:
- the OutputDataStream which is used to write RTCP data to be sent to the remote targets; null if it does not exist yet and create is false
- Throws:
IOException- if creating the OutputDataStream fails
-
getDataInputStream
public RTPConnectorInputStream<?> getDataInputStream() throws IOException
Returns the input stream that is handling incoming RTP packets.- Specified by:
getDataInputStreamin interfacejavax.media.rtp.RTPConnector- Returns:
- the input stream that is handling incoming RTP packets.
- Throws:
IOException- if an error occurs during the creation of the RTP packet input stream
-
getDataInputStream
protected RTPConnectorInputStream<?> getDataInputStream(boolean create) throws IOException
Gets the PushSourceStream which gives access to the RTP data received from the remote targets and optionally creates it if it does not exist yet.- Parameters:
create- true to create the PushSourceStream which gives access to the RTP data received from the remote targets if it does not exist yet; otherwise, false- Returns:
- the PushBufferStream which gives access to the RTP data received from the remote targets; null if it does not exist yet and create is false
- Throws:
IOException- if creating the PushSourceStream fails
-
getDataOutputStream
public RTPConnectorOutputStream getDataOutputStream() throws IOException
Returns the input stream that is handling outgoing RTP packets.- Specified by:
getDataOutputStreamin interfacejavax.media.rtp.RTPConnector- Returns:
- the input stream that is handling outgoing RTP packets.
- Throws:
IOException- if an error occurs during the creation of the RTP
-
getDataOutputStream
public RTPConnectorOutputStream getDataOutputStream(boolean create) throws IOException
Gets the OutputDataStream which is used to write RTP data to be sent to from the remote targets and optionally creates it if it does not exist yet.- Parameters:
create- true to create the OutputDataStream which is to be used to write RTP data to be sent to the remote targets if it does not exist yet; otherwise, false- Returns:
- the OutputDataStream which is used to write RTP data to be sent to the remote targets; null if it does not exist yet and create is false
- Throws:
IOException- if creating the OutputDataStream fails
-
getReceiveBufferSize
public int getReceiveBufferSize()
Provides a dummy implementation toRTPConnector.getReceiveBufferSize()that always returns -1.- Specified by:
getReceiveBufferSizein interfacejavax.media.rtp.RTPConnector
-
getRTCPBandwidthFraction
public double getRTCPBandwidthFraction()
Provides a dummy implementation toRTPConnector.getRTCPBandwidthFraction()that always returns -1.- Specified by:
getRTCPBandwidthFractionin interfacejavax.media.rtp.RTPConnector
-
getRTCPSenderBandwidthFraction
public double getRTCPSenderBandwidthFraction()
Provides a dummy implementation toRTPConnector.getRTCPSenderBandwidthFraction()that always returns -1.- Specified by:
getRTCPSenderBandwidthFractionin interfacejavax.media.rtp.RTPConnector
-
getSendBufferSize
public int getSendBufferSize()
Provides a dummy implementation toRTPConnector.getSendBufferSize()that always returns -1.- Specified by:
getSendBufferSizein interfacejavax.media.rtp.RTPConnector
-
removeTarget
public void removeTarget(javax.media.rtp.SessionAddress target)
Removes a target from our session. If a target is removed, there will be no data sent to that address.- Parameters:
target- Destination target to be removed
-
removeTargets
public void removeTargets()
Remove all stream targets. After this operation is done. There will be no targets receiving data, so no data will be sent.
-
setReceiveBufferSize
public void setReceiveBufferSize(int size) throws IOExceptionProvides a dummy implementation toRTPConnector.setReceiveBufferSize(int).- Specified by:
setReceiveBufferSizein interfacejavax.media.rtp.RTPConnector- Parameters:
size- ignored.- Throws:
IOException
-
setSendBufferSize
public void setSendBufferSize(int size) throws IOExceptionProvides a dummy implementation toRTPConnector.setSendBufferSize(int).- Specified by:
setSendBufferSizein interfacejavax.media.rtp.RTPConnector- Parameters:
size- ignored.- Throws:
IOException
-
setDirection
public void setDirection(MediaDirection direction)
Configures this AbstractRTPConnector to allow RTP in the specified direction. That is, enables/disables the input and output data streams according to direction. Note that the control (RTCP) streams are not affected (they are always kept enabled).- Parameters:
direction- Specifies how to configure the data streams of this AbstractRTPConnector. The input stream will be enabled or disabled depending on whether direction allows receiving. The output stream will be enabled or disabled depending on whether direction allows sending.
-
-