Class 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 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 IOException
        Add 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:
        close in interface javax.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:
        getControlInputStream in interface javax.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:
        getControlOutputStream in interface javax.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:
        getDataInputStream in interface javax.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:
        getDataOutputStream in interface javax.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 to RTPConnector.getReceiveBufferSize() that always returns -1.
        Specified by:
        getReceiveBufferSize in interface javax.media.rtp.RTPConnector
      • getRTCPBandwidthFraction

        public double getRTCPBandwidthFraction()
        Provides a dummy implementation to RTPConnector.getRTCPBandwidthFraction() that always returns -1.
        Specified by:
        getRTCPBandwidthFraction in interface javax.media.rtp.RTPConnector
      • getRTCPSenderBandwidthFraction

        public double getRTCPSenderBandwidthFraction()
        Provides a dummy implementation to RTPConnector.getRTCPSenderBandwidthFraction() that always returns -1.
        Specified by:
        getRTCPSenderBandwidthFraction in interface javax.media.rtp.RTPConnector
      • getSendBufferSize

        public int getSendBufferSize()
        Provides a dummy implementation to RTPConnector.getSendBufferSize() that always returns -1.
        Specified by:
        getSendBufferSize in interface javax.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 IOException
        Provides a dummy implementation to RTPConnector.setReceiveBufferSize(int).
        Specified by:
        setReceiveBufferSize in interface javax.media.rtp.RTPConnector
        Parameters:
        size - ignored.
        Throws:
        IOException
      • setSendBufferSize

        public void setSendBufferSize​(int size)
                               throws IOException
        Provides a dummy implementation to RTPConnector.setSendBufferSize(int).
        Specified by:
        setSendBufferSize in interface javax.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.