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 managingMediaFormat
instances.
-
-
Field Summary
Fields Modifier and Type Field Description static String
KEY_MAX_BIT_RATE
Deprecated.TheMediaFormat
key for the maximum bitrate in bits per second.static String
KEY_PCM_ENCODING_EXTENDED
Deprecated.CustomMediaFormat
key associated with an integer representing the PCM encoding.static String
KEY_PIXEL_WIDTH_HEIGHT_RATIO_FLOAT
Deprecated.CustomMediaFormat
key 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 Format
createFormatFromMediaFormat(MediaFormat mediaFormat)
Deprecated.Returns aFormat
representing the givenMediaFormat
.static MediaFormat
createMediaFormatFromFormat(Format format)
Deprecated.Returns aMediaFormat
representing the given ExoPlayerFormat
.static byte[]
getArray(ByteBuffer byteBuffer)
Deprecated.static ColorInfo
getColorInfo(MediaFormat mediaFormat)
Deprecated.Creates and returns aColorInfo
, if a valid instance is described in theMediaFormat
.static float
getFloat(MediaFormat mediaFormat, String name, float defaultValue)
Deprecated.SupportsMediaFormat.getFloat(String, float)
forAPI < 29
.static int
getInteger(MediaFormat mediaFormat, String name, int defaultValue)
Deprecated.SupportsMediaFormat.getInteger(String, int)
forAPI < 29
.static Integer
getTimeLapseFrameRate(MediaFormat format)
Deprecated.Returns the time lapse capture FPS from the givenMediaFormat
if it was set.static boolean
isAudioFormat(MediaFormat mediaFormat)
Deprecated.Returns whether aMediaFormat
is an audio format.static boolean
isVideoFormat(MediaFormat mediaFormat)
Deprecated.Returns whether aMediaFormat
is a video format.static void
maybeSetByteBuffer(MediaFormat format, String key, byte[] value)
Deprecated.Sets aMediaFormat
ByteBuffer
value.static void
maybeSetColorInfo(MediaFormat format, ColorInfo colorInfo)
Deprecated.Sets aMediaFormat
's color information.static void
maybeSetFloat(MediaFormat format, String key, float value)
Deprecated.Sets aMediaFormat
float value.static void
maybeSetInteger(MediaFormat format, String key, int value)
Deprecated.Sets aMediaFormat
integer value.static void
maybeSetString(MediaFormat format, String key, String value)
Deprecated.Sets aMediaFormat
String
value.static void
setCsdBuffers(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.CustomMediaFormat
key 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.CustomMediaFormat
key 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.TheMediaFormat
key 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 inMediaFormat
though, which is why it's being replicated here.- See Also:
- Constant Field Values
-
-
Method Detail
-
createFormatFromMediaFormat
public static Format createFormatFromMediaFormat(MediaFormat mediaFormat)
Deprecated.Returns aFormat
representing the givenMediaFormat
.
-
createMediaFormatFromFormat
public static MediaFormat createMediaFormatFromFormat(Format format)
Deprecated.Returns aMediaFormat
representing the given ExoPlayerFormat
.May include the following custom keys:
-
maybeSetString
public static void maybeSetString(MediaFormat format, String key, @Nullable String value)
Deprecated.- Parameters:
format
- TheMediaFormat
being 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
- TheMediaFormat
being configured.csdBuffers
- The csd buffers to set.
-
maybeSetInteger
public static void maybeSetInteger(MediaFormat format, String key, int value)
Deprecated.- Parameters:
format
- TheMediaFormat
being 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
- TheMediaFormat
being 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
- TheMediaFormat
being 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 ifcolorInfo
is null.- Parameters:
format
- TheMediaFormat
being 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,
null
will always be returned, becauseMediaFormat
color keys likeMediaFormat.KEY_COLOR_STANDARD
were 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 aMediaFormat
is a video format.
-
isAudioFormat
public static boolean isAudioFormat(MediaFormat mediaFormat)
Deprecated.Returns whether aMediaFormat
is an audio format.
-
getTimeLapseFrameRate
@Nullable public static Integer getTimeLapseFrameRate(MediaFormat format)
Deprecated.Returns the time lapse capture FPS from the givenMediaFormat
if it was set.
-
-