Class AbstractMediaStream

  • All Implemented Interfaces:
    MediaStream
    Direct Known Subclasses:
    MediaStreamImpl

    public abstract class AbstractMediaStream
    extends Object
    implements MediaStream
    Abstract base implementation of MediaStream to ease the implementation of the interface.
    Author:
    Lyubomir Marinov, George Politis
    • Field Detail

      • rtpTranslator

        protected RTPTranslator rtpTranslator
        The RTPTranslator, if any, which forwards RTP and RTCP traffic between this and other MediaStreams.
    • Constructor Detail

      • AbstractMediaStream

        public AbstractMediaStream()
    • Method Detail

      • assertDirection

        protected void assertDirection​(MediaDirection direction,
                                       MediaDirection deviceDirection,
                                       String illegalArgumentExceptionMessage)
                                throws IllegalArgumentException
        Asserts that the state of this instance will remain consistent if a specific MediaDirection (i.e. direction) and a MediaDevice with a specific MediaDirection (i.e. deviceDirection) are both set on this instance.
        Parameters:
        direction - the MediaDirection to validate against the specified deviceDirection
        deviceDirection - the MediaDirection of a MediaDevice to validate against the specified direction
        illegalArgumentExceptionMessage - the message of the IllegalArgumentException to be thrown if the state of this instance would've been compromised if direction and the MediaDevice associated with deviceDirection were both set on this instance
        Throws:
        IllegalArgumentException - if the state of this instance would've been compromised were both direction and the MediaDevice associated with deviceDirection set on this instance
      • firePropertyChange

        protected void firePropertyChange​(String property,
                                          Object oldValue,
                                          Object newValue)
        Fires a new PropertyChangeEvent to the PropertyChangeListeners registered with this instance in order to notify about a change in the value of a specific property which had its old value modified to a specific new value.
        Parameters:
        property - the name of the property of this instance which had its value changed
        oldValue - the value of the property with the specified name before the change
        newValue - the value of the property with the specified name after the change
      • getName

        public String getName()
        Returns the name of this stream or null if no name has been set. A stream name is used by some protocols, for diagnostic purposes mostly. In XMPP for example this is the name of the content element that describes a stream.
        Specified by:
        getName in interface MediaStream
        Returns:
        the name of this stream or null if no name has been set.
      • getProperty

        public Object getProperty​(String propertyName)
        Gets the value of a specific opaque property of this MediaStream.
        Specified by:
        getProperty in interface MediaStream
        Parameters:
        propertyName - the name of the opaque property of this MediaStream the value of which is to be returned
        Returns:
        the value of the opaque property of this MediaStream specified by propertyName
      • handleAttributes

        protected void handleAttributes​(MediaFormat format,
                                        Map<String,​String> attrs)
        Handles attributes contained in MediaFormat.
        Parameters:
        format - the MediaFormat to handle the attributes of
        attrs - the attributes Map to handle
      • injectPacket

        public void injectPacket​(RawPacket pkt,
                                 boolean data)
                          throws TransmissionFailedException
        Sends a given RTP or RTCP packet to the remote peer/side.
        Parameters:
        pkt - the packet to send.
        data - true to send an RTP packet or false to send an RTCP packet.
        Throws:
        TransmissionFailedException - if the transmission failed.
      • setName

        public void setName​(String name)
        Sets the name of this stream. Stream names are used by some protocols, for diagnostic purposes mostly. In XMPP for example this is the name of the content element that describes a stream.
        Specified by:
        setName in interface MediaStream
        Parameters:
        name - the name of this stream or null if no name has been set.
      • setProperty

        public void setProperty​(String propertyName,
                                Object value)
        Sets the value of a specific opaque property of this MediaStream.
        Specified by:
        setProperty in interface MediaStream
        Parameters:
        propertyName - the name of the opaque property of this MediaStream the value of which is to be set to the specified value
        value - the value of the opaque property of this MediaStream specified by propertyName to be set
      • 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
        Parameters:
        rtpTranslator - the RTPTranslator which is to forward RTP and RTCP traffic between this and other MediaStreams
      • getDynamicRTPPayloadType

        public byte getDynamicRTPPayloadType​(String codec)
        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
        Parameters:
        codec - the encoding whose payload type we are trying to obtain.
        Returns:
        the payload type number that has been negotiated for the specified codec or -1 if no payload type has been negotiated for 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
        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.
      • setTransportCCEngine

        public void setTransportCCEngine​(TransportCCEngine engine)
        Sets the TransportCCEngine of this media stream. Note that for this to take effect it needs to be called early, before the transform chain is initialized (i.e. before a connector is set).
        Specified by:
        setTransportCCEngine in interface MediaStream
        Parameters:
        engine - the engine to set.
      • 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
        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.
      • getPrimaryREDBlock

        public REDBlock getPrimaryREDBlock​(RawPacket pkt)
        Gets the primary REDBlock that contains the payload of the RTP packet passed in as a parameter.
        Specified by:
        getPrimaryREDBlock in interface MediaStream
        Parameters:
        pkt - the RawPacket 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.