Class MediaFormatUtil
- java.lang.Object
-
- com.google.android.exoplayer2.util.MediaFormatUtil
-
@Deprecated public final class MediaFormatUtil extends Object
Deprecated.com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.Helper class containing utility methods for managingMediaFormatinstances.
-
-
Field Summary
Fields Modifier and Type Field Description static StringKEY_MAX_BIT_RATEDeprecated.TheMediaFormatkey for the maximum bitrate in bits per second.static StringKEY_PCM_ENCODING_EXTENDEDDeprecated.CustomMediaFormatkey associated with an integer representing the PCM encoding.static StringKEY_PIXEL_WIDTH_HEIGHT_RATIO_FLOATDeprecated.CustomMediaFormatkey associated with a float representing the ratio between a pixel's width and height.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static FormatcreateFormatFromMediaFormat(MediaFormat mediaFormat)Deprecated.Returns aFormatrepresenting the givenMediaFormat.static MediaFormatcreateMediaFormatFromFormat(Format format)Deprecated.Returns aMediaFormatrepresenting the given ExoPlayerFormat.static byte[]getArray(ByteBuffer byteBuffer)Deprecated.static ColorInfogetColorInfo(MediaFormat mediaFormat)Deprecated.Creates and returns aColorInfo, if a valid instance is described in theMediaFormat.static floatgetFloat(MediaFormat mediaFormat, String name, float defaultValue)Deprecated.SupportsMediaFormat.getFloat(String, float)forAPI < 29.static intgetInteger(MediaFormat mediaFormat, String name, int defaultValue)Deprecated.SupportsMediaFormat.getInteger(String, int)forAPI < 29.static IntegergetTimeLapseFrameRate(MediaFormat format)Deprecated.Returns the time lapse capture FPS from the givenMediaFormatif it was set.static booleanisAudioFormat(MediaFormat mediaFormat)Deprecated.Returns whether aMediaFormatis an audio format.static booleanisVideoFormat(MediaFormat mediaFormat)Deprecated.Returns whether aMediaFormatis a video format.static voidmaybeSetByteBuffer(MediaFormat format, String key, byte[] value)Deprecated.Sets aMediaFormatByteBuffervalue.static voidmaybeSetColorInfo(MediaFormat format, ColorInfo colorInfo)Deprecated.Sets aMediaFormat's color information.static voidmaybeSetFloat(MediaFormat format, String key, float value)Deprecated.Sets aMediaFormatfloat value.static voidmaybeSetInteger(MediaFormat format, String key, int value)Deprecated.Sets aMediaFormatinteger value.static voidmaybeSetString(MediaFormat format, String key, String value)Deprecated.Sets aMediaFormatStringvalue.static voidsetCsdBuffers(MediaFormat format, List<byte[]> csdBuffers)Deprecated.Sets aMediaFormat's codec specific data buffers.
-
-
-
Field Detail
-
KEY_PIXEL_WIDTH_HEIGHT_RATIO_FLOAT
public static final String KEY_PIXEL_WIDTH_HEIGHT_RATIO_FLOAT
Deprecated.CustomMediaFormatkey associated with a float representing the ratio between a pixel's width and height.- See Also:
- Constant Field Values
-
KEY_PCM_ENCODING_EXTENDED
public static final String KEY_PCM_ENCODING_EXTENDED
Deprecated.CustomMediaFormatkey associated with an integer representing the PCM encoding.Equivalent to
MediaFormat.KEY_PCM_ENCODING, except it allows additional values defined byC.PcmEncoding, includingC.ENCODING_PCM_16BIT_BIG_ENDIAN,C.ENCODING_PCM_24BIT, andC.ENCODING_PCM_32BIT.- See Also:
- Constant Field Values
-
KEY_MAX_BIT_RATE
public static final String KEY_MAX_BIT_RATE
Deprecated.TheMediaFormatkey for the maximum bitrate in bits per second.The associated value is an integer.
The key string constant is the same as
MediaFormat#KEY_MAX_BITRATE. Values for it are already returned by the framework MediaExtractor; the key is a hidden field inMediaFormatthough, which is why it's being replicated here.- See Also:
- Constant Field Values
-
-
Method Detail
-
createFormatFromMediaFormat
public static Format createFormatFromMediaFormat(MediaFormat mediaFormat)
Deprecated.Returns aFormatrepresenting the givenMediaFormat.
-
createMediaFormatFromFormat
public static MediaFormat createMediaFormatFromFormat(Format format)
Deprecated.Returns aMediaFormatrepresenting the given ExoPlayerFormat.May include the following custom keys:
-
maybeSetString
public static void maybeSetString(MediaFormat format, String key, @Nullable String value)
Deprecated.- Parameters:
format- TheMediaFormatbeing configured.key- The key to set.value- The value to set.
-
setCsdBuffers
public static void setCsdBuffers(MediaFormat format, List<byte[]> csdBuffers)
Deprecated.Sets aMediaFormat's codec specific data buffers.- Parameters:
format- TheMediaFormatbeing configured.csdBuffers- The csd buffers to set.
-
maybeSetInteger
public static void maybeSetInteger(MediaFormat format, String key, int value)
Deprecated.- Parameters:
format- TheMediaFormatbeing configured.key- The key to set.value- The value to set.
-
maybeSetFloat
public static void maybeSetFloat(MediaFormat format, String key, float value)
Deprecated.- Parameters:
format- TheMediaFormatbeing configured.key- The key to set.value- The value to set.
-
maybeSetByteBuffer
public static void maybeSetByteBuffer(MediaFormat format, String key, @Nullable byte[] value)
Deprecated.- Parameters:
format- TheMediaFormatbeing configured.key- The key to set.value- The byte array that will be wrapped to obtain the value.
-
maybeSetColorInfo
public static void maybeSetColorInfo(MediaFormat format, @Nullable ColorInfo colorInfo)
Deprecated.Sets aMediaFormat's color information. Does nothing ifcolorInfois null.- Parameters:
format- TheMediaFormatbeing configured.colorInfo- The color info to set.
-
getColorInfo
@Nullable public static ColorInfo getColorInfo(MediaFormat mediaFormat)
Deprecated.Creates and returns aColorInfo, if a valid instance is described in theMediaFormat.Under API 24,
nullwill always be returned, becauseMediaFormatcolor keys likeMediaFormat.KEY_COLOR_STANDARDwere only added in API 24.
-
getInteger
public static int getInteger(MediaFormat mediaFormat, String name, int defaultValue)
Deprecated.SupportsMediaFormat.getInteger(String, int)forAPI < 29.
-
getFloat
public static float getFloat(MediaFormat mediaFormat, String name, float defaultValue)
Deprecated.SupportsMediaFormat.getFloat(String, float)forAPI < 29.
-
getArray
public static byte[] getArray(ByteBuffer byteBuffer)
Deprecated.
-
isVideoFormat
public static boolean isVideoFormat(MediaFormat mediaFormat)
Deprecated.Returns whether aMediaFormatis a video format.
-
isAudioFormat
public static boolean isAudioFormat(MediaFormat mediaFormat)
Deprecated.Returns whether aMediaFormatis an audio format.
-
getTimeLapseFrameRate
@Nullable public static Integer getTimeLapseFrameRate(MediaFormat format)
Deprecated.Returns the time lapse capture FPS from the givenMediaFormatif it was set.
-
-