Class MediaFormat

java.lang.Object
com.brightcove.player.model.MediaFormat
All Implemented Interfaces:
android.os.Parcelable

public final class MediaFormat extends Object implements android.os.Parcelable
An immutable Parcelable object that can be used describe the format of media stream.

This is a derivative of the media format class in ExoPlayer 1 SDK.

  • Field Details

    • OFFSET_SAMPLE_RELATIVE

      public static final long OFFSET_SAMPLE_RELATIVE
      A value for subSampleOffsetUs to indicate that sub-sample timestamps are relative to the timestamps of their parent samples.
      See Also:
    • NO_INITIALIZATION_DATA

      public static final List<byte[]> NO_INITIALIZATION_DATA
      Empty initialization data.
    • trackId

      @Nullable public final String trackId
      The identifier for the track represented by the format, or null if unknown or not applicable.
    • mimeType

      @NonNull public final String mimeType
      The mime type of the format.
    • bitrate

      public final int bitrate
      The average bandwidth in bits per second, or Constants.NO_VALUE if unknown or not applicable.
    • maxInputSize

      public final int maxInputSize
      The maximum size of a buffer of data (typically one sample) in the format, or Constants.NO_VALUE if unknown or not applicable.
    • durationUs

      public final long durationUs
      The duration in microseconds, or Constants.UNKNOWN_TIME_US if the duration is unknown, or Constants.MATCH_LONGEST_US if the duration should match the duration of the longest track whose duration is known.
    • initializationData

      @NonNull public final List<byte[]> initializationData
      Initialization data that must be provided to the decoder. Set to NO_INITIALIZATION_DATA if there is initialization data.
    • adaptive

      public final boolean adaptive
      Specifies whether the format represents an adaptive track, meaning that the format of the actual media data may change (e.g. to adapt to network conditions).
    • width

      public final int width
      The width of the video in pixels, or Constants.NO_VALUE if unknown or not applicable.
    • height

      public final int height
      The height of the video in pixels, or Constants.NO_VALUE if unknown or not applicable.
    • maxWidth

      public final int maxWidth
      If the video is flagged adaptive, this is the maximum width of the video in pixels that will be encountered in the stream. Set to Constants.NO_VALUE if unknown or not applicable.
    • maxHeight

      public final int maxHeight
      If the video is flagged adaptive, this is the maximum height of the video in pixels that will be encountered in the stream. Set to Constants.NO_VALUE if unknown or not applicable.
    • pixelWidthHeightRatio

      public final float pixelWidthHeightRatio
      The width to height ratio of pixels in the video, or Constants.NO_VALUE if unknown or not applicable.
    • stereoMode

      public final int stereoMode
      The stereo layout for 360/3D/VR video, or NO_VALUE if not applicable.
    • rotationDegrees

      public final int rotationDegrees
      The clockwise rotation that should be applied to the video for it to be rendered in the correct orientation, or Constants.NO_VALUE if unknown or not applicable.
    • projectionData

      @Nullable public final byte[] projectionData
      The projection data for 360/VR video, or null if not applicable.
    • channelCount

      public final int channelCount
      The number of audio channels, or Constants.NO_VALUE if unknown or not applicable.
    • sampleRate

      public final int sampleRate
      The audio sampling rate in Hz, or Constants.NO_VALUE if unknown or not applicable.
    • pcmEncoding

      public final int pcmEncoding
      The encoding for PCM audio streams.
    • encoderDelay

      public final int encoderDelay
      The number of samples to trim from the start of the decoded audio stream.
    • encoderPadding

      public final int encoderPadding
      The number of samples to trim from the end of the decoded audio stream.
    • language

      @Nullable public final String language
      The language of the track, or null if unknown or not applicable
    • subSampleOffsetUs

      public final long subSampleOffsetUs
      For samples that contain sub-samples, this is an offset that should be added to sub-sample timestamps.
    • CREATOR

      public static final android.os.Parcelable.Creator<MediaFormat> CREATOR
  • Method Details

    • createVideoFormat

      public static MediaFormat createVideoFormat(String trackId, String mimeType, int bitrate, int maxInputSize, long durationUs, int width, int height, List<byte[]> initializationData)
    • createVideoFormat

      public static MediaFormat createVideoFormat(String trackId, String mimeType, int bitrate, int maxInputSize, long durationUs, int width, int height, List<byte[]> initializationData, int rotationDegrees, float pixelWidthHeightRatio)
    • createVideoFormat

      public static MediaFormat createVideoFormat(String trackId, String mimeType, int bitrate, int maxInputSize, long durationUs, int width, int height, List<byte[]> initializationData, int rotationDegrees, float pixelWidthHeightRatio, byte[] projectionData, int stereoMode)
    • createAudioFormat

      public static MediaFormat createAudioFormat(String trackId, String mimeType, int bitrate, int maxInputSize, long durationUs, int channelCount, int sampleRate, List<byte[]> initializationData, String language)
    • createAudioFormat

      public static MediaFormat createAudioFormat(String trackId, String mimeType, int bitrate, int maxInputSize, long durationUs, int channelCount, int sampleRate, List<byte[]> initializationData, String language, int pcmEncoding)
    • createTextFormat

      public static MediaFormat createTextFormat(String trackId, String mimeType, int bitrate, long durationUs, String language)
    • createTextFormat

      public static MediaFormat createTextFormat(String trackId, String mimeType, int bitrate, long durationUs, String language, long subSampleOffsetUs)
    • createImageFormat

      public static MediaFormat createImageFormat(String trackId, String mimeType, int bitrate, long durationUs, List<byte[]> initializationData, String language)
    • createFormatForMimeType

      public static MediaFormat createFormatForMimeType(String trackId, String mimeType, int bitrate, long durationUs)
    • createId3Format

      public static MediaFormat createId3Format()
    • copyWithMaxInputSize

      public MediaFormat copyWithMaxInputSize(int maxInputSize)
    • copyWithMaxVideoDimensions

      public MediaFormat copyWithMaxVideoDimensions(int maxWidth, int maxHeight)
    • copyWithSubSampleOffsetUs

      public MediaFormat copyWithSubSampleOffsetUs(long subSampleOffsetUs)
    • copyWithDurationUs

      public MediaFormat copyWithDurationUs(long durationUs)
    • copyWithLanguage

      public MediaFormat copyWithLanguage(String language)
    • copyWithFixedTrackInfo

      public MediaFormat copyWithFixedTrackInfo(String trackId, int bitrate, int width, int height, String language)
    • copyAsAdaptive

      public MediaFormat copyAsAdaptive(String trackId)
    • copyWithGaplessInfo

      public MediaFormat copyWithGaplessInfo(int encoderDelay, int encoderPadding)
    • getFrameworkMediaFormatV16

      public final android.media.MediaFormat getFrameworkMediaFormatV16()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • describeContents

      public int describeContents()
      Specified by:
      describeContents in interface android.os.Parcelable
    • writeToParcel

      public void writeToParcel(android.os.Parcel dest, int flags)
      Specified by:
      writeToParcel in interface android.os.Parcelable