Interface MediaFormat

  • All Known Subinterfaces:
    AudioMediaFormat, VideoMediaFormat
    All Known Implementing Classes:
    AudioMediaFormatImpl, MediaFormatImpl, VideoMediaFormatImpl

    public interface MediaFormat
    The MediaFormat interface represents a generic (i.e. audio/video or other) format used to represent media represent a media stream.

    The interface contains utility methods for extracting common media format properties such as the name of the underlying encoding, or clock rate or in order comparing to compare formats. Extending interfaces representing audio or video formats are likely to add other methods.

    Author:
    Emil Ivov, Lyubomir Marinov
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int MAX_DYNAMIC_PAYLOAD_TYPE
      The maximum integer that is allowed for use in dynamic payload type assignment.
      static int MIN_DYNAMIC_PAYLOAD_TYPE
      The minimum integer that is allowed for use in dynamic payload type assignment.
      static byte RTP_PAYLOAD_TYPE_UNKNOWN
      The constant returned by getRTPPayloadType() when the MediaFormat instance describes a format without an RTP payload type (number) known in RFC 3551 "RTP Profile for Audio and Video Conferences with Minimal Control".
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean equals​(Object mediaFormat)
      Determines whether this MediaFormat is equal to mediaFormat i.e.
      boolean formatParametersMatch​(Map<String,​String> fmtps)
      Determines whether the format parameters of this MediaFormat match a specific set of format parameters.
      Map<String,​String> getAdditionalCodecSettings()
      Returns additional codec settings.
      Map<String,​String> getAdvancedAttributes()
      Returns a Map containing advanced parameters specific to this particular MediaFormat.
      double getClockRate()
      Returns the clock rate associated with this MediaFormat.
      String getClockRateString()
      Returns a String representation of the clock rate associated with this MediaFormat making sure that the value appears as an integer (i.e.
      String getEncoding()
      Returns the name of the encoding (i.e.
      Map<String,​String> getFormatParameters()
      Returns a Map containing parameters specific to this particular MediaFormat.
      org.jitsi.utils.MediaType getMediaType()
      Returns the type of this MediaFormat (e.g.
      String getRealUsedClockRateString()
      Returns a String representation of the real used clock rate associated with this MediaFormat making sure that the value appears as an integer (i.e.
      byte getRTPPayloadType()
      Gets the RTP payload type (number) of this MediaFormat as it is known in RFC 3551 "RTP Profile for Audio and Video Conferences with Minimal Control".
      boolean matches​(MediaFormat format)
      Determines whether this MediaFormat matches properties of a specific MediaFormat, such as mediaType, encoding, clockRate and channels for MediaFormats with mediaType equal to MediaType.AUDIO.
      boolean matches​(org.jitsi.utils.MediaType mediaType, String encoding, double clockRate, int channels, Map<String,​String> formatParameters)
      Determines whether this MediaFormat has specific values for its properties mediaType, encoding, clockRate and channels for MediaFormats with mediaType equal to MediaType.AUDIO.
      void setAdditionalCodecSettings​(Map<String,​String> settings)
      Sets additional codec settings.
      String toString()
      Returns a String representation of this MediaFormat containing important format attributes such as the encoding for example.
    • Field Detail

      • RTP_PAYLOAD_TYPE_UNKNOWN

        static final byte RTP_PAYLOAD_TYPE_UNKNOWN
        The constant returned by getRTPPayloadType() when the MediaFormat instance describes a format without an RTP payload type (number) known in RFC 3551 "RTP Profile for Audio and Video Conferences with Minimal Control".
        See Also:
        Constant Field Values
      • MIN_DYNAMIC_PAYLOAD_TYPE

        static final int MIN_DYNAMIC_PAYLOAD_TYPE
        The minimum integer that is allowed for use in dynamic payload type assignment.
        See Also:
        Constant Field Values
      • MAX_DYNAMIC_PAYLOAD_TYPE

        static final int MAX_DYNAMIC_PAYLOAD_TYPE
        The maximum integer that is allowed for use in dynamic payload type assignment.
        See Also:
        Constant Field Values
    • Method Detail

      • getMediaType

        org.jitsi.utils.MediaType getMediaType()
        Returns the type of this MediaFormat (e.g. audio or video).
        Returns:
        the MediaType that this format represents (e.g. audio or video).
      • getEncoding

        String getEncoding()
        Returns the name of the encoding (i.e. codec) used by this MediaFormat.
        Returns:
        The name of the encoding that this MediaFormat is using.
      • getClockRate

        double getClockRate()
        Returns the clock rate associated with this MediaFormat.
        Returns:
        The clock rate associated with this format.
      • getClockRateString

        String getClockRateString()
        Returns a String representation of the clock rate associated with this MediaFormat making sure that the value appears as an integer (i.e. contains no decimal point) unless it is actually a non integer.
        Returns:
        a String representation of the clock rate associated with this MediaFormat.
      • getRealUsedClockRateString

        String getRealUsedClockRateString()
        Returns a String representation of the real used clock rate associated with this MediaFormat making sure that the value appears as an integer (i.e. contains no decimal point) unless it is actually a non integer. This function corrects the problem of the G.722 codec which advertises its clock rate to be 8 kHz while 16 kHz is really used to encode the stream (that's an error noted in the respective RFC and kept for the sake of compatibility.).
        Returns:
        a String representation of the real used clock rate associated with this MediaFormat.
      • equals

        boolean equals​(Object mediaFormat)
        Determines whether this MediaFormat is equal to mediaFormat i.e. they have the same encoding, clock rate, format parameters, advanced attributes, etc.
        Overrides:
        equals in class Object
        Parameters:
        mediaFormat - the MediaFormat to compare to this instance
        Returns:
        true if mediaFormat is equal to this format and false otherwise.
      • formatParametersMatch

        boolean formatParametersMatch​(Map<String,​String> fmtps)
        Determines whether the format parameters of this MediaFormat match a specific set of format parameters.
        Parameters:
        fmtps - the set of format parameters to match to the format parameters of this MediaFormat
        Returns:
        true if this MediaFormat considers fmtps matching its format parameters; otherwise, false
      • getAdvancedAttributes

        Map<String,​String> getAdvancedAttributes()
        Returns a Map containing advanced parameters specific to this particular MediaFormat. The parameters returned here are meant for use in SIP/SDP or XMPP session descriptions.
        Returns:
        a Map containing advanced parameters specific to this particular MediaFormat
      • getFormatParameters

        Map<String,​String> getFormatParameters()
        Returns a Map containing parameters specific to this particular MediaFormat. The parameters returned here are meant for use in SIP/SDP or XMPP session descriptions where they get transported through the "fmtp:" attribute or <parameter/> tag respectively.
        Returns:
        a Map containing parameters specific to this particular MediaFormat.
      • getRTPPayloadType

        byte getRTPPayloadType()
        Gets the RTP payload type (number) of this MediaFormat as it is known in RFC 3551 "RTP Profile for Audio and Video Conferences with Minimal Control".
        Returns:
        the RTP payload type of this MediaFormat if it is known in RFC 3551 "RTP Profile for Audio and Video Conferences with Minimal Control"; otherwise, RTP_PAYLOAD_TYPE_UNKNOWN
      • setAdditionalCodecSettings

        void setAdditionalCodecSettings​(Map<String,​String> settings)
        Sets additional codec settings.
        Parameters:
        settings - additional settings represented by a map.
      • getAdditionalCodecSettings

        Map<String,​String> getAdditionalCodecSettings()
        Returns additional codec settings.
        Returns:
        additional settings represented by a map.
      • toString

        String toString()
        Returns a String representation of this MediaFormat containing important format attributes such as the encoding for example.
        Overrides:
        toString in class Object
        Returns:
        a String representation of this MediaFormat.
      • matches

        boolean matches​(MediaFormat format)
        Determines whether this MediaFormat matches properties of a specific MediaFormat, such as mediaType, encoding, clockRate and channels for MediaFormats with mediaType equal to MediaType.AUDIO.
        Parameters:
        format - the MediaFormat whose properties we'd like to examine
        Returns:
        true if the specified format has specific values for its properties mediaType, encoding, clockRate and channels; otherwise, false
      • matches

        boolean matches​(org.jitsi.utils.MediaType mediaType,
                        String encoding,
                        double clockRate,
                        int channels,
                        Map<String,​String> formatParameters)
        Determines whether this MediaFormat has specific values for its properties mediaType, encoding, clockRate and channels for MediaFormats with mediaType equal to MediaType.AUDIO.
        Parameters:
        mediaType - the type we expect MediaFormat to have
        encoding - the encoding we are looking for.
        clockRate - the clock rate that we'd like the format to have.
        channels - the number of channels that expect to find in this format
        formatParameters - the format parameters expected to match these of the specified format
        Returns:
        true if the specified format has specific values for its properties mediaType, encoding, clockRate and channels; otherwise, false