Class MediaStreamImpl

  • All Implemented Interfaces:
    EventListener, javax.media.rtp.ReceiveStreamListener, javax.media.rtp.RemoteListener, javax.media.rtp.SendStreamListener, javax.media.rtp.SessionListener, MediaStream
    Direct Known Subclasses:
    AudioMediaStreamImpl, VideoMediaStreamImpl

    public class MediaStreamImpl
    extends AbstractMediaStream
    implements javax.media.rtp.ReceiveStreamListener, javax.media.rtp.SendStreamListener, javax.media.rtp.SessionListener, javax.media.rtp.RemoteListener
    Implements MediaStream using JMF.
    Author:
    Lyubomir Marinov, Emil Ivov, Sebastien Vincent, Boris Grozev, George Politis
    • Field Detail

      • PROPERTY_NAME_RECEIVE_BUFFER_LENGTH

        protected static final String PROPERTY_NAME_RECEIVE_BUFFER_LENGTH
        The name of the property indicating the length of our receive buffer.
        See Also:
        Constant Field Values
      • sendStreamsAreCreated

        protected boolean sendStreamsAreCreated
        The indicator which determines whether createSendStreams() has been executed for rtpManager. If true, the SendStreams have to be recreated when the MediaDevice, respectively the MediaDeviceSession, of this instance is changed.
    • Constructor Detail

      • MediaStreamImpl

        public MediaStreamImpl​(MediaDevice device,
                               SrtpControl srtpControl)
        Initializes a new MediaStreamImpl instance which will use the specified MediaDevice for both capture and playback of media. The new instance will not have an associated StreamConnector and it must be set later for the new instance to be able to exchange media with a remote peer.
        Parameters:
        device - the MediaDevice the new instance is to use for both capture and playback of media
        srtpControl - an existing control instance to control the SRTP operations
      • MediaStreamImpl

        public MediaStreamImpl​(StreamConnector connector,
                               MediaDevice device,
                               SrtpControl srtpControl)
        Initializes a new MediaStreamImpl instance which will use the specified MediaDevice for both capture and playback of media exchanged via the specified StreamConnector.
        Parameters:
        connector - the StreamConnector the new instance is to use for sending and receiving media or null if the StreamConnector of the new instance is to not be set at initialization time but specified later on
        device - the MediaDevice the new instance is to use for both capture and playback of media exchanged via the specified StreamConnector
        srtpControl - an existing control instance to control the ZRTP operations or null if a new control instance is to be created by the new MediaStreamImpl
    • Method Detail

      • toString

        public static String toString​(javax.media.protocol.DataSource dataSource)
        Returns a human-readable representation of a specific DataSource instance in the form of a String value.
        Parameters:
        dataSource - the DataSource to return a human-readable representation of
        Returns:
        a String value which gives a human-readable representation of the specified dataSource
      • getDiagnosticContext

        public org.jitsi.utils.logging.DiagnosticContext getDiagnosticContext()
        Gets the DiagnosticContext of this instance.
      • addDynamicRTPPayloadType

        public void addDynamicRTPPayloadType​(byte rtpPayloadType,
                                             MediaFormat format)
        Adds a new association in this MediaStream of the specified RTP payload type with the specified MediaFormat in order to allow it to report rtpPayloadType in RTP flows sending and receiving media in format. Usually, rtpPayloadType will be in the range of dynamic RTP payload types.
        Specified by:
        addDynamicRTPPayloadType in interface MediaStream
        Parameters:
        rtpPayloadType - the RTP payload type to be associated in this MediaStream with the specified MediaFormat
        format - the MediaFormat to be associated in this MediaStream with rtpPayloadType
        See Also:
        MediaStream.addDynamicRTPPayloadType(byte, MediaFormat)
      • clearDynamicRTPPayloadTypes

        public void clearDynamicRTPPayloadTypes()
        Clears the dynamic RTP payload type associations in this MediaStream.
        Specified by:
        clearDynamicRTPPayloadTypes in interface MediaStream
      • addDynamicRTPPayloadTypeOverride

        public void addDynamicRTPPayloadTypeOverride​(byte originalPt,
                                                     byte overloadPt)
        Adds an additional RTP payload mapping that will overriding one that we've set with addDynamicRTPPayloadType(byte, MediaFormat). This is necessary so that we can support the RFC3264 case where the answerer has the right to declare what payload type mappings it wants to receive RTP packets with even if they are different from those in the offer. RFC3264 claims this is for support of legacy protocols such as H.323 but we've been bumping with a number of cases where multi-component pure SIP systems also need to behave this way.

        Specified by:
        addDynamicRTPPayloadTypeOverride in interface MediaStream
        Parameters:
        originalPt - the payload type that we are overriding
        overloadPt - the payload type that we are overriding it with
      • addRemoteSourceID

        protected void addRemoteSourceID​(long remoteSourceID)
        Sets the remote SSRC identifier and fires the corresponding PropertyChangeEvent.
        Parameters:
        remoteSourceID - the SSRC identifier that this stream will be using in outgoing RTP packets from now on.
      • addRTPExtension

        public void addRTPExtension​(byte extensionID,
                                    RTPExtension rtpExtension)
        Maps or updates the mapping between extensionID and rtpExtension. If rtpExtension's MediaDirection attribute is set to INACTIVE the mapping is removed from the local extensions table and the extension would not be transmitted or handled by this stream's RTPConnector.
        Specified by:
        addRTPExtension in interface MediaStream
        Parameters:
        extensionID - the ID that is being mapped to rtpExtension
        rtpExtension - the RTPExtension that we are mapping.
      • clearRTPExtensions

        public void clearRTPExtensions()
        Clears the RTP header extension associations stored in this instance.
        Specified by:
        clearRTPExtensions in interface MediaStream
      • 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:
        close in interface MediaStream
        See Also:
        MediaStream.close()
      • configureDataInputStream

        protected void configureDataInputStream​(RTPConnectorInputStream<?> dataInputStream)
        Performs any optional configuration on a specific RTPConnectorInputStream of an RTPManager to be used by this MediaStreamImpl. Allows extenders to override.
        Parameters:
        dataInputStream - the RTPConnectorInputStream to be used by an RTPManager of this MediaStreamImpl and to be configured
      • configureDataOutputStream

        protected void configureDataOutputStream​(RTPConnectorOutputStream dataOutputStream)
        Performs any optional configuration on a specific RTPConnectorOuputStream of an RTPManager to be used by this MediaStreamImpl. Allows extenders to override.
        Parameters:
        dataOutputStream - the RTPConnectorOutputStream to be used by an RTPManager of this MediaStreamImpl and to be configured
      • configureRTPManagerBufferControl

        protected void configureRTPManagerBufferControl​(StreamRTPManager rtpManager,
                                                        javax.media.control.BufferControl bufferControl)
        Performs any optional configuration on the BufferControl of the specified RTPManager which is to be used as the RTPManager of this MediaStreamImpl. Allows extenders to override.
        Parameters:
        rtpManager - the RTPManager which is to be used by this MediaStreamImpl
        bufferControl - the BufferControl of rtpManager on which any optional configuration is to be performed
      • createDtmfTransformEngine

        protected DtmfTransformEngine createDtmfTransformEngine()
        A stub that allows audio oriented streams to create and keep a reference to a DtmfTransformEngine.
        Returns:
        a DtmfTransformEngine if this is an audio oriented stream and null otherwise.
      • createSendStreams

        protected void createSendStreams()
        Creates new SendStream instances for the streams of deviceSession through rtpManager.
      • deviceSessionChanged

        protected void deviceSessionChanged​(MediaDeviceSession oldValue,
                                            MediaDeviceSession newValue)
        Notifies this MediaStream that the MediaDevice (and respectively the MediaDeviceSession with it) which this instance uses for capture and playback of media has been changed. Allows extenders to override and provide additional processing of oldValue and newValue.
        Parameters:
        oldValue - the MediaDeviceSession with the MediaDevice this instance used work with
        newValue - the MediaDeviceSession with the MediaDevice this instance is to work with
      • getActiveRTPExtensionID

        public byte getActiveRTPExtensionID​(RTPExtension rtpExtension)
        Returns the ID currently assigned to a specific RTP extension.
        Parameters:
        rtpExtension - the RTP extension to get the currently assigned ID of
        Returns:
        the ID currently assigned to the specified RTP extension or -1 if no ID has been defined for this extension so far
      • getActiveRTPExtensions

        public Map<Byte,​RTPExtension> getActiveRTPExtensions()
        Returns a map containing all currently active RTPExtensions in use by this stream.
        Specified by:
        getActiveRTPExtensions in interface MediaStream
        Returns:
        a map containing all currently active RTPExtensions in use by this stream.
      • getCsrcEngine

        protected CsrcTransformEngine getCsrcEngine()
        Returns the engine that is responsible for adding the list of CSRC identifiers to outgoing RTP packets during a conference.
        Returns:
        the engine that is responsible for adding the list of CSRC identifiers to outgoing RTP packets during a conference.
      • getDeviceSession

        public MediaDeviceSession getDeviceSession()
        Gets the MediaDeviceSession which represents the work of this MediaStream with its associated MediaDevice.
        Returns:
        the MediaDeviceSession which represents the work of this MediaStream with its associated MediaDevice
      • getDynamicRTPPayloadType

        public byte getDynamicRTPPayloadType​(String encoding)
        Returns the payload type number that has been negotiated for the specified encoding or -1 if no payload type has been negotiated for it. If multiple formats match the specified encoding, then this method would return the first one it encounters while iterating through the map.
        Specified by:
        getDynamicRTPPayloadType in interface MediaStream
        Overrides:
        getDynamicRTPPayloadType in class AbstractMediaStream
        Parameters:
        encoding - the encoding whose payload type we are trying to obtain.
        Returns:
        the payload type number that has been negotiated for the specified encoding or -1 if no payload type has been negotiated for it.
      • getDynamicRTPPayloadTypes

        public Map<Byte,​MediaFormat> getDynamicRTPPayloadTypes()
        Gets the existing associations in this MediaStream of RTP payload types to MediaFormats. The returned Map only contains associations previously added in this instance with addDynamicRTPPayloadType(byte, MediaFormat) and not globally or well-known associations reported by MediaFormat.getRTPPayloadType().
        Specified by:
        getDynamicRTPPayloadTypes in interface MediaStream
        Returns:
        a Map of RTP payload type expressed as Byte to MediaFormat describing the existing (dynamic) associations in this instance of RTP payload types to MediaFormats. The Map represents a snapshot of the existing associations at the time of the getDynamicRTPPayloadTypes() method call and modifications to it are not reflected on the internal storage
        See Also:
        MediaStream.getDynamicRTPPayloadTypes()
      • getFecTransformEngine

        protected TransformEngineWrapper<FECTransformEngine> getFecTransformEngine()
        Creates the FECTransformEngine for this MediaStream. By default none is created, allows extenders to implement it.
        Returns:
        a TransformEngineWrapper around a FECTransformEngine. The wrapper is necessary as we may not have created the FECTransformEngine in time
      • setFecTransformEngine

        protected void setFecTransformEngine​(FECTransformEngine fecTransformEngine)
        Sets the FECTransformEngine for this MediaStream By default, nothing is done with the passed engine, allowing extenders to implement it
      • getFormat

        public MediaFormat getFormat​(byte pt)
        Returns the MediaFormat that is associated to the payload type passed in as a parameter.
        Specified by:
        getFormat in interface MediaStream
        Overrides:
        getFormat in class AbstractMediaStream
        Parameters:
        pt - the payload type of the MediaFormat to get.
        Returns:
        the MediaFormat that is associated to the payload type passed in as a parameter.
      • getLocalContributingSourceIDs

        public long[] getLocalContributingSourceIDs()
        Returns the list of CSRC identifiers for all parties currently known to contribute to the media that this stream is sending toward its remote counter part. In other words, the method returns the list of CSRC IDs that this stream will include in outgoing RTP packets. This method will return an null in case this stream is not part of a mixed conference call.
        Returns:
        a long[] array of CSRC IDs representing parties that are currently known to contribute to the media that this stream is sending or an null in case this MediaStream is not part of a conference call.
      • getLocalControlAddress

        public InetSocketAddress getLocalControlAddress()
        Gets the local address that this stream is sending RTCP traffic from.
        Returns:
        an InetSocketAddress instance indicating the local address that this stream is sending RTCP traffic from.
      • getLocalDataAddress

        public InetSocketAddress getLocalDataAddress()
        Gets the local address that this stream is sending RTP traffic from.
        Returns:
        an InetSocketAddress instance indicating the local address that this stream is sending RTP traffic from.
      • getLocalSourceID

        public long getLocalSourceID()
        Gets the synchronization source (SSRC) identifier of the local peer or -1 if it is not yet known.
        Specified by:
        getLocalSourceID in interface MediaStream
        Returns:
        the synchronization source (SSRC) identifier of the local peer or -1 if it is not yet known
        See Also:
        MediaStream.getLocalSourceID()
      • getMediaStreamStats

        public MediaStreamStats2Impl getMediaStreamStats()
        Returns the statistical information gathered about this MediaStream.
        Specified by:
        getMediaStreamStats in interface MediaStream
        Returns:
        the statistical information gathered about this MediaStream
      • getMediaType

        public org.jitsi.utils.MediaType getMediaType()
        Gets the MediaType of this MediaStream.
        Returns:
        the MediaType of this MediaStream
      • getPriority

        protected int getPriority()
        Used to set the priority of the receive/send streams. Underling implementations can override this and return different than current default value.
        Returns:
        the priority for the current thread.
      • getReceiveStream

        public javax.media.rtp.ReceiveStream getReceiveStream​(int ssrc)
        Gets a ReceiveStream which this instance plays back on its associated MediaDevice and which has a specific synchronization source identifier (SSRC).
        Parameters:
        ssrc - the synchronization source identifier of the ReceiveStream to return
        Returns:
        a ReceiveStream which this instance plays back on its associated MediaDevice and which has the specified ssrc
      • getReceiveStreams

        public Collection<javax.media.rtp.ReceiveStream> getReceiveStreams()
        Gets a list of the ReceiveStreams this instance plays back on its associated MediaDevice.
        Returns:
        a list of the ReceiveStreams this instance plays back on its associated MediaDevice
      • getRedTransformEngine

        protected REDTransformEngine getRedTransformEngine()
        Creates the REDTransformEngine for this MediaStream. By default none is created, allows extenders to implement it.
        Returns:
        the REDTransformEngine created.
      • getRemoteContributingSourceIDs

        public long[] getRemoteContributingSourceIDs()
        Returns the List of CSRC identifiers representing the parties contributing to the stream that we are receiving from this MediaStream's remote party.
        Returns:
        a List of CSRC identifiers representing the parties contributing to the stream that we are receiving from this MediaStream's remote party.
      • getRemoteSourceID

        public long getRemoteSourceID()
        Gets the synchronization source (SSRC) identifier of the remote peer or -1 if that identifier is not yet known at this point in the execution.

        Warning: A MediaStream may receive multiple RTP streams and may thus have multiple remote SSRCs. Since it is not clear how this MediaStream instance chooses which of the multiple remote SSRCs to be returned by the method, it is advisable to always consider MediaStream.getRemoteSourceIDs() first. Returns the last element of getRemoteSourceIDs() which may or may not always be appropriate.

        Specified by:
        getRemoteSourceID in interface MediaStream
        Returns:
        the synchronization source (SSRC) identifier of the remote peer or -1 if that identifier is not yet known at this point in the execution
        See Also:
        MediaStream.getRemoteSourceID()
      • getRemoteSourceIDs

        public List<Long> getRemoteSourceIDs()
        Gets the synchronization source (SSRC) identifiers of the remote peer.
        Specified by:
        getRemoteSourceIDs in interface MediaStream
        Returns:
        the synchronization source (SSRC) identifiers of the remote peer
      • getRTPConnector

        protected AbstractRTPConnector getRTPConnector()
        Gets the RTPConnector through which this instance sends and receives RTP and RTCP traffic.
        Returns:
        the RTPConnector through which this instance sends and receives RTP and RTCP traffic
      • getRTPManager

        public StreamRTPManager getRTPManager()
        Gets the RTPManager instance which sends and receives RTP and RTCP traffic on behalf of this MediaStream. If the RTPManager does not exist yet, it is created.
        Returns:
        the RTPManager instance which sends and receives RTP and RTCP traffic on behalf of this MediaStream
      • getStreamRTPManager

        public StreamRTPManager getStreamRTPManager()
        Gets the StreamRTPManager which is to forward RTP and RTCP traffic between this and other MediaStreams.
        Specified by:
        getStreamRTPManager in interface MediaStream
        Returns:
        the StreamRTPManager which is to forward RTP and RTCP traffic between this and other MediaStreams
      • getSrtpControl

        public SrtpControl getSrtpControl()
        Gets the SrtpControl which controls the SRTP of this stream.
        Specified by:
        getSrtpControl in interface MediaStream
        Returns:
        the SrtpControl which controls the SRTP of this stream
      • getTarget

        public MediaStreamTarget getTarget()
        Returns the target of this MediaStream to which it is to send and from which it is to receive data (e.g. RTP) and control data (e.g. RTCP).
        Specified by:
        getTarget in interface MediaStream
        Returns:
        the MediaStreamTarget describing the data (e.g. RTP) and the control data (e.g. RTCP) locations to which this MediaStream is to send and from which it is to receive
        See Also:
        MediaStream.setTarget(MediaStreamTarget)
      • getTransportProtocol

        public StreamConnector.Protocol getTransportProtocol()
        Returns the transport protocol used by the streams.
        Specified by:
        getTransportProtocol in interface MediaStream
        Returns:
        the transport protocol (UDP or TCP) used by the streams. null if the stream connector is not instantiated.
      • isMute

        public boolean isMute()
        Determines whether this MediaStream is set to transmit "silence" instead of the media being fed from its MediaDevice. "Silence" for video is understood as video data which is not the captured video data and may represent, for example, a black image.
        Specified by:
        isMute in interface MediaStream
        Returns:
        true if this MediaStream is set to transmit "silence" instead of the media fed from its MediaDevice; false, otherwise
        See Also:
        MediaStream.isMute()
      • queryRTPManager

        public StreamRTPManager queryRTPManager()
        Gets the RTPManager instance which sends and receives RTP and RTCP traffic on behalf of this MediaStream. If the RTPManager does not exist yet, it is not created.
        Returns:
        the RTPManager instance which sends and receives RTP and RTCP traffic on behalf of this MediaStream
      • recreateSendStreams

        protected void recreateSendStreams()
        Recreates the SendStreams of this instance (i.e. of its RTPManager) as necessary. For example, if there was no attempt to create the SendStreams prior to the call, does nothing. If they were created prior to the call, closes them and creates them again. If they were not started prior to the call, does not start them after recreating them.
      • registerCustomCodecFormats

        protected void registerCustomCodecFormats​(StreamRTPManager rtpManager)
        Registers any custom JMF Formats with a specific RTPManager. Extenders should override in order to register their own customizations and should call back to this super implementation during the execution of their override in order to register the associations defined in this instance of (dynamic) RTP payload types to MediaFormats.
        Parameters:
        rtpManager - the RTPManager to register any custom JMF Formats with
      • removeReceiveStreamForSsrc

        public void removeReceiveStreamForSsrc​(long ssrc)
        Removes the ReceiveStream with SSRC ssrc, if there is such a ReceiveStream, from the receive streams of this MediaStream
        Specified by:
        removeReceiveStreamForSsrc in interface MediaStream
        Parameters:
        ssrc - the SSRC for which to remove a ReceiveStream
      • rtpConnectorChanged

        protected void rtpConnectorChanged​(AbstractRTPConnector oldValue,
                                           AbstractRTPConnector newValue)
        Notifies this MediaStream implementation that its RTPConnector instance has changed from a specific old value to a specific new value. Allows extenders to override and perform additional processing after this MediaStream has changed its RTPConnector instance.
        Parameters:
        oldValue - the RTPConnector of this MediaStream implementation before it got changed to newValue
        newValue - the current RTPConnector of this MediaStream which replaced oldValue
      • setConnector

        public void setConnector​(StreamConnector connector)
        Sets the StreamConnector to be used by this instance for sending and receiving media.
        Specified by:
        setConnector in interface MediaStream
        Parameters:
        connector - the StreamConnector to be used by this instance for sending and receiving media
      • setDirection

        public void setDirection​(MediaDirection direction)
        Sets the direction in which media in this MediaStream is to be streamed. If this MediaStream is not currently started, calls to start() later on will start it only in the specified direction. If it is currently started in a direction different than the specified, directions other than the specified will be stopped.
        Specified by:
        setDirection in interface MediaStream
        Parameters:
        direction - the MediaDirection in which this MediaStream is to stream media when it is started
        See Also:
        MediaStream.setDirection(MediaDirection)
      • setLocalSourceID

        protected void setLocalSourceID​(long localSourceID)
        Sets the local SSRC identifier and fires the corresponding PropertyChangeEvent.
        Parameters:
        localSourceID - the SSRC identifier that this stream will be using in outgoing RTP packets from now on
      • setMute

        public void setMute​(boolean mute)
        Causes this MediaStream to stop transmitting the media being fed from this stream's MediaDevice and transmit "silence" instead. "Silence" for video is understood as video data which is not the captured video data and may represent, for example, a black image.
        Specified by:
        setMute in interface MediaStream
        Parameters:
        mute - true to have this MediaStream transmit "silence" instead of the actual media data that it captures from its MediaDevice; false to transmit actual media data captured from the MediaDevice of this MediaStream
        See Also:
        MediaStream.setMute(boolean)
      • setSSRCFactory

        public void setSSRCFactory​(SSRCFactory ssrcFactory)
        Sets the SSRCFactory which is to generate new synchronization source (SSRC) identifiers.
        Specified by:
        setSSRCFactory in interface MediaStream
        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
      • setTarget

        public void setTarget​(MediaStreamTarget target)
        Sets the target of this MediaStream to which it is to send and from which it is to receive data (e.g. RTP) and control data (e.g. RTCP).
        Specified by:
        setTarget in interface MediaStream
        Parameters:
        target - the MediaStreamTarget describing the data (e.g. RTP) and the control data (e.g. RTCP) locations to which this MediaStream is to send and from which it is to receive
        See Also:
        MediaStream.setTarget(MediaStreamTarget)
      • start

        public void start()
        Starts capturing media from this stream's MediaDevice and then streaming it through the local StreamConnector toward the stream's target address and port. Also puts the MediaStream in a listening state which make it play all media received from the StreamConnector on the stream's MediaDevice.
        Specified by:
        start in interface MediaStream
        See Also:
        MediaStream.start()
      • stop

        public void stop()
        Stops all streaming and capturing in this MediaStream and closes and releases all open/allocated devices/resources. Has no effect if this MediaStream is already closed and is simply ignored.
        Specified by:
        stop in interface MediaStream
        See Also:
        MediaStream.stop()
      • update

        public void update​(javax.media.rtp.event.ReceiveStreamEvent ev)
        Notifies this ReceiveStreamListener that the RTPManager it is registered with has generated an event related to a ReceiveStream.
        Specified by:
        update in interface javax.media.rtp.ReceiveStreamListener
        Parameters:
        ev - the ReceiveStreamEvent which specifies the ReceiveStream that is the cause of the event and the very type of the event
        See Also:
        ReceiveStreamListener.update(ReceiveStreamEvent)
      • update

        public void update​(javax.media.rtp.event.RemoteEvent ev)
        Method called back in the RemoteListener to notify listener of all RTP Remote Events.RemoteEvents are one of ReceiverReportEvent, SenderReportEvent or RemoteCollisionEvent
        Specified by:
        update in interface javax.media.rtp.RemoteListener
        Parameters:
        ev - the event
      • update

        public void update​(javax.media.rtp.event.SendStreamEvent ev)
        Notifies this SendStreamListener that the RTPManager it is registered with has generated an event related to a SendStream.
        Specified by:
        update in interface javax.media.rtp.SendStreamListener
        Parameters:
        ev - the SendStreamEvent which specifies the SendStream that is the cause of the event and the very type of the event
        See Also:
        SendStreamListener.update(SendStreamEvent)
      • update

        public void update​(javax.media.rtp.event.SessionEvent ev)
        Notifies this SessionListener that the RTPManager it is registered with has generated an event which pertains to the session as a whole and does not belong to a ReceiveStream or a SendStream or a remote participant necessarily.
        Specified by:
        update in interface javax.media.rtp.SessionListener
        Parameters:
        ev - the SessionEvent which specifies the source and the very type of the event
        See Also:
        SessionListener.update(SessionEvent)
      • setExternalTransformer

        public void setExternalTransformer​(TransformEngine transformEngine)
        Sets the external (application-provided) TransformEngine of this MediaStream.
        Specified by:
        setExternalTransformer in interface MediaStream
        Parameters:
        transformEngine - the TransformerEngine to use.
      • injectPacket

        public void injectPacket​(RawPacket pkt,
                                 boolean data,
                                 TransformEngine after)
                          throws TransmissionFailedException
        Sends a given RTP or RTCP packet to the remote peer/side.
        Specified by:
        injectPacket in interface MediaStream
        Parameters:
        pkt - the packet to send.
        data - true to send an RTP packet or false to send an RTCP packet.
        after - the TransformEngine in the TransformEngine chain of this MediaStream after which the injection is to begin. If the specified after is not in the TransformEngine chain of this MediaStream, pkt will be injected at the beginning of the TransformEngine chain of this MediaStream. Generally, the value of after should be null unless the injection is being performed by a TransformEngine itself (while executing transform or reverseTransform of a PacketTransformer of its own even).
        Throws:
        TransmissionFailedException - if the transmission failed.
      • injectPacket

        public void injectPacket​(RawPacket pkt,
                                 boolean data,
                                 TransformEngine after,
                                 boolean create)
                          throws TransmissionFailedException
        Sends a given RTP or RTCP packet to the remote peer/side.
        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
        Throws:
        TransmissionFailedException
      • getTemporalID

        public int getTemporalID​(RawPacket pkt)
        Utility method that determines the temporal layer index (TID) of an RTP packet.
        Parameters:
        pkt - the packet from which to get the temporal layer id
        Returns:
        the TID of the packet, -1 otherwise. FIXME(gp) conceptually this belongs to the VideoMediaStreamImpl, but I don't want to be obliged to cast to use this method.
      • getSpatialID

        public int getSpatialID​(RawPacket pkt)
        Utility method that determines the spatial layer index (SID) of an RTP packet.
        Parameters:
        pkt - the RTP packet.
        Returns:
        the SID of the packet, -1 otherwise. FIXME(gp) conceptually this belongs to the VideoMediaStreamImpl, but I don't want to be obliged to cast to use this method.
      • supportsFrameBoundaries

        public boolean supportsFrameBoundaries​(RawPacket pkt)
        Returns a boolean that indicates whether or not our we're able to detect the frame boundaries for the codec of the packet that is specified as an argument.
        Parameters:
        pkt - the RawPacket that holds the RTP packet.
        Returns:
        true if we're able to detect the frame boundaries for the codec of the packet that is specified as an argument, false otherwise.
      • isStartOfFrame

        public boolean isStartOfFrame​(RawPacket pkt)
        Utility method that determines whether or not a packet is a start of frame.
        Parameters:
        pkt - raw rtp packet.
        Returns:
        true if the packet is the start of a frame, false otherwise. FIXME(gp) conceptually this belongs to the VideoMediaStreamImpl, but I don't want to be obliged to cast to use this method.
      • isEndOfFrame

        public boolean isEndOfFrame​(RawPacket pkt)
        Utility method that determines whether or not a packet is an end of frame.
        Parameters:
        pkt - raw rtp packet.
        Returns:
        true if the packet is the end of a frame, false otherwise. FIXME(gp) conceptually this belongs to the VideoMediaStreamImpl, but I don't want to be obliged to cast to use this method.
      • isKeyFrame

        public boolean isKeyFrame​(byte[] buf,
                                  int off,
                                  int len)
        Utility method that determines whether or not a packet is a key frame. This is absolutely terrible, but we need a RawPacket and the method is used from RTPTranslator, which doesn't work with RawPacket.
        Specified by:
        isKeyFrame in interface MediaStream
        Parameters:
        buf - the buffer that holds the RTP packet.
        off - the offset in the buff where the RTP packet is found.
        len - then length of the RTP packet in the buffer.
        Returns:
        true if the packet is a key frame, false otherwise.
      • isKeyFrame

        public boolean isKeyFrame​(RawPacket pkt)
        Utility method that determines whether or not a packet is a key frame.
        Specified by:
        isKeyFrame in interface MediaStream
        Parameters:
        pkt - the packet.
      • getPrimaryREDBlock

        public REDBlock getPrimaryREDBlock​(org.jitsi.utils.ByteArrayBuffer baf)
        Gets the primary REDBlock that contains the payload of the RTP packet passed in as a parameter.
        Specified by:
        getPrimaryREDBlock in interface MediaStream
        Overrides:
        getPrimaryREDBlock in class AbstractMediaStream
        Parameters:
        baf - the ByteArrayBuffer that holds the RTP payload.
        Returns:
        the primary REDBlock that contains the payload of the RTP packet passed in as a parameter, or null if the buffer is invalid.
      • getRtxTransformer

        public RtxTransformer getRtxTransformer()
        Gets the RtxTransformer, if any, used by the MediaStream.
        Returns:
        the RtxTransformer used by the MediaStream or null
      • getRemoteBitrateEstimator

        public RemoteBitrateEstimatorWrapper getRemoteBitrateEstimator()
        Gets the RemoteBitrateEstimator of this VideoMediaStream.
        Returns:
        the RemoteBitrateEstimator of this VideoMediaStream if any; otherwise, null
      • setRTPTranslator

        public void setRTPTranslator​(RTPTranslator rtpTranslator)
        Sets the RTPTranslator which is to forward RTP and RTCP traffic between this and other MediaStreams.
        Specified by:
        setRTPTranslator in interface MediaStream
        Overrides:
        setRTPTranslator in class AbstractMediaStream
        Parameters:
        rtpTranslator - the RTPTranslator which is to forward RTP and RTCP traffic between this and other MediaStreams