Package com.google.android.exoplayer2
Class Format
- java.lang.Object
-
- com.google.android.exoplayer2.Format
-
- All Implemented Interfaces:
Parcelable
public final class Format extends Object implements Parcelable
Represents a media format.When building formats, populate all fields whose values are known and relevant to the type of format being constructed. For information about different types of format, see ExoPlayer's Supported formats page.
Fields commonly relevant to all formats
Fields relevant to container formats
containerMimeType- If the container only contains a single media track, fields relevant to sample formats can are also be relevant and can be set to describe the sample format of that track.
- If the container only contains one track of a given type (possibly alongside tracks of other types), then fields relevant to that track type can be set to describe the properties of the track. See the sections below for video, audio and text formats.
Fields relevant to sample formats
sampleMimeTypemaxInputSizeinitializationDatadrmInitDatasubsampleOffsetUs- Fields relevant to the sample format's track type are also relevant. See the sections below for video, audio and text formats.
Fields relevant to video formats
Fields relevant to audio formats
Fields relevant to text formats
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFormat.BuilderBuildsFormatinstances.-
Nested classes/interfaces inherited from interface android.os.Parcelable
Parcelable.ClassLoaderCreator<T extends Object>, Parcelable.Creator<T extends Object>
-
-
Field Summary
Fields Modifier and Type Field Description intaccessibilityChannelThe Accessibility channel, orNO_VALUEif not known or applicable.intaverageBitrateThe average bitrate in bits per second, orNO_VALUEif unknown or not applicable.intbitrateThe bitrate in bits per second.intchannelCountThe number of audio channels, orNO_VALUEif unknown or not applicable.StringcodecsCodecs of the format as described in RFC 6381, or null if unknown or not applicable.ColorInfocolorInfoThe color metadata associated with the video, or null if not applicable.StringcontainerMimeTypeThe mime type of the container, or null if unknown or not applicable.static Parcelable.Creator<Format>CREATORDrmInitDatadrmInitDataDRM initialization data if the stream is protected, or null otherwise.intencoderDelayThe number of frames to trim from the start of the decoded audio stream, or 0 if not applicable.intencoderPaddingThe number of frames to trim from the end of the decoded audio stream, or 0 if not applicable.Class<? extends ExoMediaCrypto>exoMediaCryptoTypeThe type ofExoMediaCryptothat will be associated with the content this format describes, ornullif the content is not encrypted.floatframeRateThe frame rate in frames per second, orNO_VALUEif unknown or not applicable.intheightThe height of the video in pixels, orNO_VALUEif unknown or not applicable.StringidAn identifier for the format, or null if unknown or not applicable.List<byte[]>initializationDataInitialization data that must be provided to the decoder.StringlabelThe human readable label, or null if unknown or not applicable.StringlanguageThe language as an IETF BCP 47 conformant tag, or null if unknown or not applicable.intmaxInputSizeThe maximum size of a buffer of data (typically one sample), orNO_VALUEif unknown or not applicable.MetadatametadataMetadata, or null if unknown or not applicable.static intNO_VALUEA value for various fields to indicate that the field's value is unknown or not applicable.static longOFFSET_SAMPLE_RELATIVEA value forsubsampleOffsetUsto indicate that subsample timestamps are relative to the timestamps of their parent samples.intpcmEncodingTheC.PcmEncodingfor PCM audio.intpeakBitrateThe peak bitrate in bits per second, orNO_VALUEif unknown or not applicable.floatpixelWidthHeightRatioThe width to height ratio of pixels in the video, or 1.0 if unknown or not applicable.byte[]projectionDataThe projection data for 360/VR video, or null if not applicable.introleFlagsTrack role flags.introtationDegreesThe clockwise rotation that should be applied to the video for it to be rendered in the correct orientation, or 0 if unknown or not applicable.StringsampleMimeTypeThe sample mime type, or null if unknown or not applicable.intsampleRateThe audio sampling rate in Hz, orNO_VALUEif unknown or not applicable.intselectionFlagsTrack selection flags.intstereoModeThe stereo layout for 360/3D/VR video, orNO_VALUEif not applicable.longsubsampleOffsetUsFor samples that contain subsamples, this is an offset that should be added to subsample timestamps.intwidthThe width of the video in pixels, orNO_VALUEif unknown or not applicable.-
Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Format.BuilderbuildUpon()Returns aFormat.Builderinitialized with the values of this instance.FormatcopyWithBitrate(int bitrate)Deprecated.FormatcopyWithDrmInitData(DrmInitData drmInitData)Deprecated.FormatcopyWithExoMediaCryptoType(Class<? extends ExoMediaCrypto> exoMediaCryptoType)Returns a copy of this format with the specifiedexoMediaCryptoType.FormatcopyWithFrameRate(float frameRate)Deprecated.FormatcopyWithGaplessInfo(int encoderDelay, int encoderPadding)Deprecated.FormatcopyWithLabel(String label)Deprecated.UsebuildUpon()andFormat.Builder.setLabel(String).FormatcopyWithManifestFormatInfo(Format manifestFormat)Deprecated.FormatcopyWithMaxInputSize(int maxInputSize)Deprecated.FormatcopyWithMetadata(Metadata metadata)Deprecated.FormatcopyWithSubsampleOffsetUs(long subsampleOffsetUs)Deprecated.FormatcopyWithVideoSize(int width, int height)Deprecated.static FormatcreateAudioContainerFormat(String id, String label, String containerMimeType, String sampleMimeType, String codecs, Metadata metadata, int bitrate, int channelCount, int sampleRate, List<byte[]> initializationData, int selectionFlags, int roleFlags, String language)Deprecated.UseFormat.Builder.static FormatcreateAudioSampleFormat(String id, String sampleMimeType, String codecs, int bitrate, int maxInputSize, int channelCount, int sampleRate, int pcmEncoding, int encoderDelay, int encoderPadding, List<byte[]> initializationData, DrmInitData drmInitData, int selectionFlags, String language, Metadata metadata)Deprecated.UseFormat.Builder.static FormatcreateAudioSampleFormat(String id, String sampleMimeType, String codecs, int bitrate, int maxInputSize, int channelCount, int sampleRate, int pcmEncoding, List<byte[]> initializationData, DrmInitData drmInitData, int selectionFlags, String language)Deprecated.UseFormat.Builder.static FormatcreateAudioSampleFormat(String id, String sampleMimeType, String codecs, int bitrate, int maxInputSize, int channelCount, int sampleRate, List<byte[]> initializationData, DrmInitData drmInitData, int selectionFlags, String language)Deprecated.UseFormat.Builder.static FormatcreateContainerFormat(String id, String label, String containerMimeType, String sampleMimeType, String codecs, int bitrate, int selectionFlags, int roleFlags, String language)Deprecated.UseFormat.Builder.static FormatcreateImageSampleFormat(String id, String sampleMimeType, int selectionFlags, List<byte[]> initializationData, String language)Deprecated.UseFormat.Builder.static FormatcreateSampleFormat(String id, String sampleMimeType)Deprecated.UseFormat.Builder.static FormatcreateTextContainerFormat(String id, String label, String containerMimeType, String sampleMimeType, String codecs, int bitrate, int selectionFlags, int roleFlags, String language)Deprecated.UseFormat.Builder.static FormatcreateTextContainerFormat(String id, String label, String containerMimeType, String sampleMimeType, String codecs, int bitrate, int selectionFlags, int roleFlags, String language, int accessibilityChannel)Deprecated.UseFormat.Builder.static FormatcreateTextSampleFormat(String id, String sampleMimeType, int selectionFlags, String language)Deprecated.UseFormat.Builder.static FormatcreateTextSampleFormat(String id, String sampleMimeType, int selectionFlags, String language, int accessibilityChannel, long subsampleOffsetUs, List<byte[]> initializationData)Deprecated.UseFormat.Builder.static FormatcreateVideoContainerFormat(String id, String label, String containerMimeType, String sampleMimeType, String codecs, Metadata metadata, int bitrate, int width, int height, float frameRate, List<byte[]> initializationData, int selectionFlags, int roleFlags)Deprecated.UseFormat.Builder.static FormatcreateVideoSampleFormat(String id, String sampleMimeType, String codecs, int bitrate, int maxInputSize, int width, int height, float frameRate, List<byte[]> initializationData, int rotationDegrees, float pixelWidthHeightRatio, byte[] projectionData, int stereoMode, ColorInfo colorInfo, DrmInitData drmInitData)Deprecated.UseFormat.Builder.static FormatcreateVideoSampleFormat(String id, String sampleMimeType, String codecs, int bitrate, int maxInputSize, int width, int height, float frameRate, List<byte[]> initializationData, int rotationDegrees, float pixelWidthHeightRatio, DrmInitData drmInitData)Deprecated.UseFormat.Builder.static FormatcreateVideoSampleFormat(String id, String sampleMimeType, String codecs, int bitrate, int maxInputSize, int width, int height, float frameRate, List<byte[]> initializationData, DrmInitData drmInitData)Deprecated.UseFormat.Builder.intdescribeContents()booleanequals(Object obj)intgetPixelCount()inthashCode()booleaninitializationDataEquals(Format other)Returns whether theinitializationDatas belonging to this format andotherare equal.static StringtoLogString(Format format)Returns a prettierStringthantoString(), intended for logging.StringtoString()FormatwithManifestFormatInfo(Format manifestFormat)voidwriteToParcel(Parcel dest, int flags)
-
-
-
Field Detail
-
NO_VALUE
public static final int NO_VALUE
A value for various fields to indicate that the field's value is unknown or not applicable.- See Also:
- Constant Field Values
-
OFFSET_SAMPLE_RELATIVE
public static final long OFFSET_SAMPLE_RELATIVE
A value forsubsampleOffsetUsto indicate that subsample timestamps are relative to the timestamps of their parent samples.- See Also:
- Constant Field Values
-
id
@Nullable public final String id
An identifier for the format, or null if unknown or not applicable.
-
label
@Nullable public final String label
The human readable label, or null if unknown or not applicable.
-
language
@Nullable public final String language
The language as an IETF BCP 47 conformant tag, or null if unknown or not applicable.
-
selectionFlags
@SelectionFlags public final int selectionFlags
Track selection flags.
-
roleFlags
@RoleFlags public final int roleFlags
Track role flags.
-
averageBitrate
public final int averageBitrate
The average bitrate in bits per second, orNO_VALUEif unknown or not applicable. The way in which this field is populated depends on the type of media to which the format corresponds:- DASH representations: Always
NO_VALUE. - HLS variants: The
AVERAGE-BANDWIDTHattribute defined on the correspondingEXT-X-STREAM-INFtag in the master playlist, orNO_VALUEif not present. - SmoothStreaming track elements: The
Bitrateattribute defined on the correspondingTrackElementin the manifest, orNO_VALUEif not present. - Progressive container formats: Often
NO_VALUE, but may be populated with the average bitrate of the container if known. - Sample formats: Often
NO_VALUE, but may be populated with the average bitrate of the stream of samples with typesampleMimeTypeif known. Note that ifsampleMimeTypeis a compressed format (e.g.,MimeTypes.AUDIO_AAC), then this bitrate is for the stream of still compressed samples.
- DASH representations: Always
-
peakBitrate
public final int peakBitrate
The peak bitrate in bits per second, orNO_VALUEif unknown or not applicable. The way in which this field is populated depends on the type of media to which the format corresponds:- DASH representations: The
@bandwidthattribute of the correspondingRepresentationelement in the manifest. - HLS variants: The
BANDWIDTHattribute defined on the correspondingEXT-X-STREAM-INFtag. - SmoothStreaming track elements: Always
NO_VALUE. - Progressive container formats: Often
NO_VALUE, but may be populated with the peak bitrate of the container if known. - Sample formats: Often
NO_VALUE, but may be populated with the peak bitrate of the stream of samples with typesampleMimeTypeif known. Note that ifsampleMimeTypeis a compressed format (e.g.,MimeTypes.AUDIO_AAC), then this bitrate is for the stream of still compressed samples.
- DASH representations: The
-
bitrate
public final int bitrate
The bitrate in bits per second. This is the peak bitrate if known, or else the average bitrate if known, or elseNO_VALUE. Equivalent to:peakBitrate != NO_VALUE ? peakBitrate : averageBitrate.
-
codecs
@Nullable public final String codecs
Codecs of the format as described in RFC 6381, or null if unknown or not applicable.
-
metadata
@Nullable public final Metadata metadata
Metadata, or null if unknown or not applicable.
-
containerMimeType
@Nullable public final String containerMimeType
The mime type of the container, or null if unknown or not applicable.
-
sampleMimeType
@Nullable public final String sampleMimeType
The sample mime type, or null if unknown or not applicable.
-
maxInputSize
public final int maxInputSize
The maximum size of a buffer of data (typically one sample), orNO_VALUEif unknown or not applicable.
-
initializationData
public final List<byte[]> initializationData
Initialization data that must be provided to the decoder. Will not be null, but may be empty if initialization data is not required.
-
drmInitData
@Nullable public final DrmInitData drmInitData
DRM initialization data if the stream is protected, or null otherwise.
-
subsampleOffsetUs
public final long subsampleOffsetUs
For samples that contain subsamples, this is an offset that should be added to subsample timestamps. A value ofOFFSET_SAMPLE_RELATIVEindicates that subsample timestamps are relative to the timestamps of their parent samples.
-
width
public final int width
The width of the video in pixels, orNO_VALUEif unknown or not applicable.
-
height
public final int height
The height of the video in pixels, orNO_VALUEif unknown or not applicable.
-
frameRate
public final float frameRate
The frame rate in frames per second, orNO_VALUEif unknown or 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 0 if unknown or not applicable. Only 0, 90, 180 and 270 are supported.
-
pixelWidthHeightRatio
public final float pixelWidthHeightRatio
The width to height ratio of pixels in the video, or 1.0 if unknown or not applicable.
-
projectionData
@Nullable public final byte[] projectionData
The projection data for 360/VR video, or null if not applicable.
-
stereoMode
@StereoMode public final int stereoMode
The stereo layout for 360/3D/VR video, orNO_VALUEif not applicable. Valid stereo modes areC.STEREO_MODE_MONO,C.STEREO_MODE_TOP_BOTTOM,C.STEREO_MODE_LEFT_RIGHT,C.STEREO_MODE_STEREO_MESH.
-
colorInfo
@Nullable public final ColorInfo colorInfo
The color metadata associated with the video, or null if not applicable.
-
channelCount
public final int channelCount
The number of audio channels, orNO_VALUEif unknown or not applicable.
-
sampleRate
public final int sampleRate
The audio sampling rate in Hz, orNO_VALUEif unknown or not applicable.
-
pcmEncoding
@PcmEncoding public final int pcmEncoding
TheC.PcmEncodingfor PCM audio. Set toNO_VALUEfor other media types.
-
encoderDelay
public final int encoderDelay
The number of frames to trim from the start of the decoded audio stream, or 0 if not applicable.
-
encoderPadding
public final int encoderPadding
The number of frames to trim from the end of the decoded audio stream, or 0 if not applicable.
-
accessibilityChannel
public final int accessibilityChannel
The Accessibility channel, orNO_VALUEif not known or applicable.
-
exoMediaCryptoType
@Nullable public final Class<? extends ExoMediaCrypto> exoMediaCryptoType
The type ofExoMediaCryptothat will be associated with the content this format describes, ornullif the content is not encrypted. Cannot be null ifdrmInitDatais non-null.
-
CREATOR
public static final Parcelable.Creator<Format> CREATOR
-
-
Method Detail
-
createVideoContainerFormat
@Deprecated public static Format createVideoContainerFormat(@Nullable String id, @Nullable String label, @Nullable String containerMimeType, @Nullable String sampleMimeType, @Nullable String codecs, @Nullable Metadata metadata, int bitrate, int width, int height, float frameRate, @Nullable List<byte[]> initializationData, @SelectionFlags int selectionFlags, @RoleFlags int roleFlags)
Deprecated.UseFormat.Builder.
-
createVideoSampleFormat
@Deprecated public static Format createVideoSampleFormat(@Nullable String id, @Nullable String sampleMimeType, @Nullable String codecs, int bitrate, int maxInputSize, int width, int height, float frameRate, @Nullable List<byte[]> initializationData, @Nullable DrmInitData drmInitData)
Deprecated.UseFormat.Builder.
-
createVideoSampleFormat
@Deprecated public static Format createVideoSampleFormat(@Nullable String id, @Nullable String sampleMimeType, @Nullable String codecs, int bitrate, int maxInputSize, int width, int height, float frameRate, @Nullable List<byte[]> initializationData, int rotationDegrees, float pixelWidthHeightRatio, @Nullable DrmInitData drmInitData)
Deprecated.UseFormat.Builder.
-
createVideoSampleFormat
@Deprecated public static Format createVideoSampleFormat(@Nullable String id, @Nullable String sampleMimeType, @Nullable String codecs, int bitrate, int maxInputSize, int width, int height, float frameRate, @Nullable List<byte[]> initializationData, int rotationDegrees, float pixelWidthHeightRatio, @Nullable byte[] projectionData, @StereoMode int stereoMode, @Nullable ColorInfo colorInfo, @Nullable DrmInitData drmInitData)
Deprecated.UseFormat.Builder.
-
createAudioContainerFormat
@Deprecated public static Format createAudioContainerFormat(@Nullable String id, @Nullable String label, @Nullable String containerMimeType, @Nullable String sampleMimeType, @Nullable String codecs, @Nullable Metadata metadata, int bitrate, int channelCount, int sampleRate, @Nullable List<byte[]> initializationData, @SelectionFlags int selectionFlags, @RoleFlags int roleFlags, @Nullable String language)
Deprecated.UseFormat.Builder.
-
createAudioSampleFormat
@Deprecated public static Format createAudioSampleFormat(@Nullable String id, @Nullable String sampleMimeType, @Nullable String codecs, int bitrate, int maxInputSize, int channelCount, int sampleRate, @Nullable List<byte[]> initializationData, @Nullable DrmInitData drmInitData, @SelectionFlags int selectionFlags, @Nullable String language)
Deprecated.UseFormat.Builder.
-
createAudioSampleFormat
@Deprecated public static Format createAudioSampleFormat(@Nullable String id, @Nullable String sampleMimeType, @Nullable String codecs, int bitrate, int maxInputSize, int channelCount, int sampleRate, @PcmEncoding int pcmEncoding, @Nullable List<byte[]> initializationData, @Nullable DrmInitData drmInitData, @SelectionFlags int selectionFlags, @Nullable String language)
Deprecated.UseFormat.Builder.
-
createAudioSampleFormat
@Deprecated public static Format createAudioSampleFormat(@Nullable String id, @Nullable String sampleMimeType, @Nullable String codecs, int bitrate, int maxInputSize, int channelCount, int sampleRate, @PcmEncoding int pcmEncoding, int encoderDelay, int encoderPadding, @Nullable List<byte[]> initializationData, @Nullable DrmInitData drmInitData, @SelectionFlags int selectionFlags, @Nullable String language, @Nullable Metadata metadata)
Deprecated.UseFormat.Builder.
-
createTextContainerFormat
@Deprecated public static Format createTextContainerFormat(@Nullable String id, @Nullable String label, @Nullable String containerMimeType, @Nullable String sampleMimeType, @Nullable String codecs, int bitrate, @SelectionFlags int selectionFlags, @RoleFlags int roleFlags, @Nullable String language)
Deprecated.UseFormat.Builder.
-
createTextContainerFormat
@Deprecated public static Format createTextContainerFormat(@Nullable String id, @Nullable String label, @Nullable String containerMimeType, @Nullable String sampleMimeType, @Nullable String codecs, int bitrate, @SelectionFlags int selectionFlags, @RoleFlags int roleFlags, @Nullable String language, int accessibilityChannel)
Deprecated.UseFormat.Builder.
-
createTextSampleFormat
@Deprecated public static Format createTextSampleFormat(@Nullable String id, @Nullable String sampleMimeType, @SelectionFlags int selectionFlags, @Nullable String language)
Deprecated.UseFormat.Builder.
-
createTextSampleFormat
@Deprecated public static Format createTextSampleFormat(@Nullable String id, @Nullable String sampleMimeType, @SelectionFlags int selectionFlags, @Nullable String language, int accessibilityChannel, long subsampleOffsetUs, @Nullable List<byte[]> initializationData)
Deprecated.UseFormat.Builder.
-
createImageSampleFormat
@Deprecated public static Format createImageSampleFormat(@Nullable String id, @Nullable String sampleMimeType, @SelectionFlags int selectionFlags, @Nullable List<byte[]> initializationData, @Nullable String language)
Deprecated.UseFormat.Builder.
-
createContainerFormat
@Deprecated public static Format createContainerFormat(@Nullable String id, @Nullable String label, @Nullable String containerMimeType, @Nullable String sampleMimeType, @Nullable String codecs, int bitrate, @SelectionFlags int selectionFlags, @RoleFlags int roleFlags, @Nullable String language)
Deprecated.UseFormat.Builder.
-
createSampleFormat
@Deprecated public static Format createSampleFormat(@Nullable String id, @Nullable String sampleMimeType)
Deprecated.UseFormat.Builder.
-
buildUpon
public Format.Builder buildUpon()
Returns aFormat.Builderinitialized with the values of this instance.
-
copyWithMaxInputSize
@Deprecated public Format copyWithMaxInputSize(int maxInputSize)
Deprecated.
-
copyWithSubsampleOffsetUs
@Deprecated public Format copyWithSubsampleOffsetUs(long subsampleOffsetUs)
Deprecated.
-
copyWithLabel
@Deprecated public Format copyWithLabel(@Nullable String label)
Deprecated.UsebuildUpon()andFormat.Builder.setLabel(String).
-
copyWithManifestFormatInfo
@Deprecated public Format copyWithManifestFormatInfo(Format manifestFormat)
Deprecated.
-
copyWithGaplessInfo
@Deprecated public Format copyWithGaplessInfo(int encoderDelay, int encoderPadding)
Deprecated.
-
copyWithFrameRate
@Deprecated public Format copyWithFrameRate(float frameRate)
Deprecated.
-
copyWithDrmInitData
@Deprecated public Format copyWithDrmInitData(@Nullable DrmInitData drmInitData)
Deprecated.
-
copyWithMetadata
@Deprecated public Format copyWithMetadata(@Nullable Metadata metadata)
Deprecated.
-
copyWithBitrate
@Deprecated public Format copyWithBitrate(int bitrate)
Deprecated.
-
copyWithVideoSize
@Deprecated public Format copyWithVideoSize(int width, int height)
Deprecated.
-
copyWithExoMediaCryptoType
public Format copyWithExoMediaCryptoType(@Nullable Class<? extends ExoMediaCrypto> exoMediaCryptoType)
Returns a copy of this format with the specifiedexoMediaCryptoType.
-
getPixelCount
public int getPixelCount()
-
initializationDataEquals
public boolean initializationDataEquals(Format other)
Returns whether theinitializationDatas belonging to this format andotherare equal.- Parameters:
other- The other format whoseinitializationDatais being compared.- Returns:
- Whether the
initializationDatas belonging to this format andotherare equal.
-
toLogString
public static String toLogString(@Nullable Format format)
Returns a prettierStringthantoString(), intended for logging.
-
describeContents
public int describeContents()
- Specified by:
describeContentsin interfaceParcelable
-
writeToParcel
public void writeToParcel(Parcel dest, int flags)
- Specified by:
writeToParcelin interfaceParcelable
-
-