Class RTPTranslatorImpl

  • All Implemented Interfaces:
    EventListener, javax.media.rtp.ReceiveStreamListener, RTPTranslator

    public class RTPTranslatorImpl
    extends AbstractRTPTranslator
    implements javax.media.rtp.ReceiveStreamListener
    Implements RTPTranslator which represents an RTP translator which forwards RTP and RTCP traffic between multiple MediaStreams.
    Author:
    Lyubomir Marinov
    • Constructor Summary

      Constructors 
      Constructor Description
      RTPTranslatorImpl()
      Initializes a new RTPTranslatorImpl instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addFormat​(StreamRTPManager streamRTPManager, javax.media.Format format, int payloadType)
      Specifies the RTP payload type (number) to be used for a specific Format.
      void addReceiveStreamListener​(StreamRTPManager streamRTPManager, javax.media.rtp.ReceiveStreamListener listener)
      Adds a ReceiveStreamListener to be notified about ReceiveStreamEvents related to a specific neomedia MediaStream (expressed as a StreamRTPManager for the purposes of and in the terms of RTPTranslator).
      void addRemoteListener​(StreamRTPManager streamRTPManager, javax.media.rtp.RemoteListener listener)
      Adds a RemoteListener to be notified about RemoteEvents received by this RTPTranslatorImpl.
      void addSendStreamListener​(StreamRTPManager streamRTPManager, javax.media.rtp.SendStreamListener listener)
      Not implemented because there are currently no uses of the underlying functionality.
      void addSessionListener​(StreamRTPManager streamRTPManager, javax.media.rtp.SessionListener listener)
      Not implemented because there are currently no uses of the underlying functionality.
      javax.media.rtp.SendStream createSendStream​(StreamRTPManager streamRTPManager, javax.media.protocol.DataSource dataSource, int streamIndex)
      Creates a SendStream from the stream of a specific DataSource that is at a specific zero-based position within the array/list of streams of that DataSource.
      void dispose()
      Releases the resources allocated by this instance in the course of its execution and prepares it to be garbage collected.
      void dispose​(StreamRTPManager streamRTPManager)
      Releases the resources allocated by this instance for the purposes of the functioning of a specific StreamRTPManager in the course of its execution and prepares that StreamRTPManager to be garbage collected (as far as this RTPTranslatorImpl is concerned).
      StreamRTPManager findStreamRTPManagerByReceiveSSRC​(int receiveSSRC)
      Finds the StreamRTPManager which receives a specific SSRC.
      Object getControl​(StreamRTPManager streamRTPManager, String controlType)
      Exposes Controls.getControl(String) on the internal/underlying RTPManager.
      javax.media.rtp.GlobalReceptionStats getGlobalReceptionStats​(StreamRTPManager streamRTPManager)
      Exposes RTPManager.getGlobalReceptionStats() on the internal/underlying RTPManager.
      javax.media.rtp.GlobalTransmissionStats getGlobalTransmissionStats​(StreamRTPManager streamRTPManager)
      Exposes RTPManager.getGlobalTransmissionStats() on the internal/underlying RTPManager.
      long getLocalSSRC​(StreamRTPManager streamRTPManager)
      Exposes RTPSessionMgr.getLocalSSRC() on the internal/underlying RTPSessionMgr.
      Vector<javax.media.rtp.ReceiveStream> getReceiveStreams​(StreamRTPManager streamRTPManager)
      Gets the ReceiveStreams associated with/related to a neomedia MediaStream (specified in the form of a StreamRTPManager instance for the purposes of and in the terms of RTPManagerImpl).
      RTCPFeedbackMessageSender getRtcpFeedbackMessageSender()
      Gets the RTCPFeedbackMessageSender which should be used for sending RTCP Feedback Messages from this RTPTranslator.
      Vector<javax.media.rtp.SendStream> getSendStreams​(StreamRTPManager streamRTPManager)
      Gets the SendStreams associated with/related to a neomedia MediaStream (specified in the form of a StreamRTPManager instance for the purposes of and in the terms of RTPManagerImpl).
      net.sf.fmj.media.rtp.SSRCCache getSSRCCache()
      Provides access to the underlying SSRCCache that holds statistics information about each SSRC that we receive.
      List<StreamRTPManager> getStreamRTPManagers()
      Returns a list of StreamRTPManagers currently attached to this RTPTranslator.
      void initialize​(StreamRTPManager streamRTPManager, javax.media.rtp.RTPConnector connector)  
      void removeReceiveStreamListener​(StreamRTPManager streamRTPManager, javax.media.rtp.ReceiveStreamListener listener)
      Removes a ReceiveStreamListener to no longer be notified about ReceiveStreamEvents related to a specific neomedia MediaStream (expressed as a StreamRTPManager for the purposes of and in the terms of RTPTranslator).
      void removeRemoteListener​(StreamRTPManager streamRTPManager, javax.media.rtp.RemoteListener listener)
      Removes a RemoteListener to no longer be notified about RemoteEvents received by this RTPTranslatorImpl.
      void removeSendStreamListener​(StreamRTPManager streamRTPManager, javax.media.rtp.SendStreamListener listener)
      Not implemented because there are currently no uses of the underlying functionality.
      void removeSessionListener​(StreamRTPManager streamRTPManager, javax.media.rtp.SessionListener listener)
      Not implemented because there are currently no uses of the underlying functionality.
      void setSSRCFactory​(SSRCFactory ssrcFactory)
      Sets the SSRCFactory which is to generate new synchronization source (SSRC) identifiers.
      void update​(javax.media.rtp.event.ReceiveStreamEvent event)
      Notifies this ReceiveStreamListener about a specific event related to a ReceiveStream.
      boolean writeControlPayload​(Payload controlPayload, MediaStream destination)
      Writes an RTCPFeedbackMessage into a destination identified by a specific MediaStream.
    • Constructor Detail

      • RTPTranslatorImpl

        public RTPTranslatorImpl()
        Initializes a new RTPTranslatorImpl instance.
    • Method Detail

      • addFormat

        public void addFormat​(StreamRTPManager streamRTPManager,
                              javax.media.Format format,
                              int payloadType)
        Specifies the RTP payload type (number) to be used for a specific Format. The association between the specified format and the specified payloadType is being added by a specific StreamRTPManager but effects the RTPTranslatorImpl globally.
        Parameters:
        streamRTPManager - the StreamRTPManager that is requesting the association of format to payloadType
        format - the Format which is to be associated with the specified RTP payload type (number)
        payloadType - the RTP payload type (number) to be associated with the specified format
      • addReceiveStreamListener

        public void addReceiveStreamListener​(StreamRTPManager streamRTPManager,
                                             javax.media.rtp.ReceiveStreamListener listener)
        Adds a ReceiveStreamListener to be notified about ReceiveStreamEvents related to a specific neomedia MediaStream (expressed as a StreamRTPManager for the purposes of and in the terms of RTPTranslator). If the specified listener has already been added, the method does nothing.
        Parameters:
        streamRTPManager - the StreamRTPManager which specifies the neomedia MediaStream with which the ReceiveStreamEvents delivered to the specified listener are to be related. In other words, a ReceiveStreamEvent received by RTPTranslatorImpl is first examined to determine which StreamRTPManager it is related to and then it is delivered to the ReceiveStreamListeners which have been added to this RTPTranslatorImpl by that StreamRTPManager.
        listener - the ReceiveStreamListener to be notified about ReceiveStreamEvents related to the specified streamRTPManager
      • addRemoteListener

        public void addRemoteListener​(StreamRTPManager streamRTPManager,
                                      javax.media.rtp.RemoteListener listener)
        Adds a RemoteListener to be notified about RemoteEvents received by this RTPTranslatorImpl. Though the request is being made by a specific StreamRTPManager, the addition of the specified listener and the deliveries of the RemoteEvents are performed irrespective of any StreamRTPManager.
        Parameters:
        streamRTPManager - the StreamRTPManager which is requesting the addition of the specified RemoteListener
        listener - the RemoteListener to be notified about RemoteEvents received by this RTPTranslatorImpl
      • addSendStreamListener

        public void addSendStreamListener​(StreamRTPManager streamRTPManager,
                                          javax.media.rtp.SendStreamListener listener)
        Not implemented because there are currently no uses of the underlying functionality.
      • addSessionListener

        public void addSessionListener​(StreamRTPManager streamRTPManager,
                                       javax.media.rtp.SessionListener listener)
        Not implemented because there are currently no uses of the underlying functionality.
      • createSendStream

        public javax.media.rtp.SendStream createSendStream​(StreamRTPManager streamRTPManager,
                                                           javax.media.protocol.DataSource dataSource,
                                                           int streamIndex)
                                                    throws IOException,
                                                           javax.media.format.UnsupportedFormatException
        Creates a SendStream from the stream of a specific DataSource that is at a specific zero-based position within the array/list of streams of that DataSource.
        Parameters:
        streamRTPManager - the StreamRTPManager which is requesting the creation of a SendStream. Since multiple StreamRTPManager may request the creation of a SendStream from one and the same combination of dataSource and streamIndex, the method may not create a completely new SendStream but may return a StreamRTPManager-specific view of an existing SendStream.
        dataSource - the DataSource which provides the stream from which a SendStream is to be created
        streamIndex - the zero-based position within the array/list of streams of the specified dataSource of the stream from which a SendStream is to be created
        Returns:
        a SendStream created from the specified dataSource and streamIndex. The returned SendStream implementation is a streamRTPManager-dedicated view to an actual SendStream which may have been created during a previous execution of the method
        Throws:
        IOException - if an error occurs during the execution of RTPManager.createSendStream(DataSource, int)
        javax.media.format.UnsupportedFormatException - if an error occurs during the execution of RTPManager.createSendStream(DataSource, int)
      • dispose

        public void dispose()
        Releases the resources allocated by this instance in the course of its execution and prepares it to be garbage collected.
        Specified by:
        dispose in interface RTPTranslator
      • dispose

        public void dispose​(StreamRTPManager streamRTPManager)
        Releases the resources allocated by this instance for the purposes of the functioning of a specific StreamRTPManager in the course of its execution and prepares that StreamRTPManager to be garbage collected (as far as this RTPTranslatorImpl is concerned).
      • findStreamRTPManagerByReceiveSSRC

        public StreamRTPManager findStreamRTPManagerByReceiveSSRC​(int receiveSSRC)
        Finds the StreamRTPManager which receives a specific SSRC.
        Specified by:
        findStreamRTPManagerByReceiveSSRC in interface RTPTranslator
        Parameters:
        receiveSSRC - the SSRC of the RTP stream received by the StreamRTPManager to be returned
        Returns:
        the StreamRTPManager which receives receiveSSRC of null
      • getControl

        public Object getControl​(StreamRTPManager streamRTPManager,
                                 String controlType)
        Exposes Controls.getControl(String) on the internal/underlying RTPManager.
        Parameters:
        streamRTPManager - ignored
        controlType -
        Returns:
        the return value of the invocation of RTPManager.getControl(String) on the internal/underlying RTPManager
      • getGlobalReceptionStats

        public javax.media.rtp.GlobalReceptionStats getGlobalReceptionStats​(StreamRTPManager streamRTPManager)
        Exposes RTPManager.getGlobalReceptionStats() on the internal/underlying RTPManager.
        Parameters:
        streamRTPManager - ignored
        Returns:
        the return value of the invocation of RTPManager.getGlobalReceptionStats() on the internal/underlying RTPManager
      • getGlobalTransmissionStats

        public javax.media.rtp.GlobalTransmissionStats getGlobalTransmissionStats​(StreamRTPManager streamRTPManager)
        Exposes RTPManager.getGlobalTransmissionStats() on the internal/underlying RTPManager.
        Parameters:
        streamRTPManager - ignored
        Returns:
        the return value of the invocation of RTPManager.getGlobalTransmissionStats() on the internal/underlying RTPManager
      • getLocalSSRC

        public long getLocalSSRC​(StreamRTPManager streamRTPManager)
        Exposes RTPSessionMgr.getLocalSSRC() on the internal/underlying RTPSessionMgr.
        Parameters:
        streamRTPManager - ignored
        Returns:
        the return value of the invocation of RTPSessionMgr.getLocalSSRC() on the internal/underlying RTPSessionMgr
      • getReceiveStreams

        public Vector<javax.media.rtp.ReceiveStream> getReceiveStreams​(StreamRTPManager streamRTPManager)
        Gets the ReceiveStreams associated with/related to a neomedia MediaStream (specified in the form of a StreamRTPManager instance for the purposes of and in the terms of RTPManagerImpl).
        Parameters:
        streamRTPManager - the StreamRTPManager to which the returned ReceiveStreams are to be related
        Returns:
        the ReceiveStreams related to/associated with the specified streamRTPManager
      • getRtcpFeedbackMessageSender

        public RTCPFeedbackMessageSender getRtcpFeedbackMessageSender()
        Gets the RTCPFeedbackMessageSender which should be used for sending RTCP Feedback Messages from this RTPTranslator.
        Returns:
        the RTCPFeedbackMessageSender which should be used for sending RTCP Feedback Messages from this RTPTranslator.
      • getSendStreams

        public Vector<javax.media.rtp.SendStream> getSendStreams​(StreamRTPManager streamRTPManager)
        Gets the SendStreams associated with/related to a neomedia MediaStream (specified in the form of a StreamRTPManager instance for the purposes of and in the terms of RTPManagerImpl).
        Parameters:
        streamRTPManager - the StreamRTPManager to which the returned SendStreams are to be related
        Returns:
        the SendStreams related to/associated with the specified streamRTPManager
      • getStreamRTPManagers

        public List<StreamRTPManager> getStreamRTPManagers()
        Returns a list of StreamRTPManagers currently attached to this RTPTranslator. This is admittedly wrong, to expose the bare SSRCCache to the use of of the StreamRTPManager. We should find a better way of exposing this information. Currently it is necessary for RTCP termination.
        Specified by:
        getStreamRTPManagers in interface RTPTranslator
        Returns:
        a list of StreamRTPManagers currently attached to this RTPTranslator.
      • initialize

        public void initialize​(StreamRTPManager streamRTPManager,
                               javax.media.rtp.RTPConnector connector)
      • removeReceiveStreamListener

        public void removeReceiveStreamListener​(StreamRTPManager streamRTPManager,
                                                javax.media.rtp.ReceiveStreamListener listener)
        Removes a ReceiveStreamListener to no longer be notified about ReceiveStreamEvents related to a specific neomedia MediaStream (expressed as a StreamRTPManager for the purposes of and in the terms of RTPTranslator). Since addReceiveStreamListener(StreamRTPManager, ReceiveStreamListener) does not add equal ReceiveStreamListeners, a single removal is enough to reverse multiple additions of equal ReceiveStreamListeners.
        Parameters:
        streamRTPManager - the StreamRTPManager which specifies the neomedia MediaStream with which the ReceiveStreamEvents delivered to the specified listener are to be related
        listener - the ReceiveStreamListener to no longer be notified about ReceiveStreamEvents related to the specified streamRTPManager
      • removeRemoteListener

        public void removeRemoteListener​(StreamRTPManager streamRTPManager,
                                         javax.media.rtp.RemoteListener listener)
        Removes a RemoteListener to no longer be notified about RemoteEvents received by this RTPTranslatorImpl. Though the request is being made by a specific StreamRTPManager, the addition of the specified listener and the deliveries of the RemoteEvents are performed irrespective of any StreamRTPManager so the removal follows the same logic.
        Parameters:
        streamRTPManager - the StreamRTPManager which is requesting the removal of the specified RemoteListener
        listener - the RemoteListener to no longer be notified about RemoteEvents received by this RTPTranslatorImpl
      • setSSRCFactory

        public void setSSRCFactory​(SSRCFactory ssrcFactory)
        Sets the SSRCFactory which is to generate new synchronization source (SSRC) identifiers.
        Parameters:
        ssrcFactory - the SSRCFactory which is to generate new synchronization source (SSRC) identifiers or null if this MediaStream is to employ internal logic to generate new synchronization source (SSRC) identifiers
      • update

        public void update​(javax.media.rtp.event.ReceiveStreamEvent event)
        Notifies this ReceiveStreamListener about a specific event related to a ReceiveStream.
        Specified by:
        update in interface javax.media.rtp.ReceiveStreamListener
        Parameters:
        event - a ReceiveStreamEvent which contains the specifics of the event this ReceiveStreamListener is being notified about
        See Also:
        ReceiveStreamListener.update(ReceiveStreamEvent)
      • writeControlPayload

        public boolean writeControlPayload​(Payload controlPayload,
                                           MediaStream destination)
        Writes an RTCPFeedbackMessage into a destination identified by a specific MediaStream.
        Returns:
        true if the controlPayload was written into the destination; otherwise, false
      • getSSRCCache

        public net.sf.fmj.media.rtp.SSRCCache getSSRCCache()
        Provides access to the underlying SSRCCache that holds statistics information about each SSRC that we receive.
        Specified by:
        getSSRCCache in interface RTPTranslator
        Returns:
        the underlying SSRCCache that holds statistics information about each SSRC that we receive.