Class MediaFormatUtil
- java.lang.Object
-
- com.google.android.exoplayer2.util.MediaFormatUtil
-
public final class MediaFormatUtil extends Object
Helper class containing utility methods for managingMediaFormat
instances.
-
-
Field Summary
Fields Modifier and Type Field Description static String
KEY_PCM_ENCODING_EXTENDED
CustomMediaFormat
key associated with an integer representing the PCM encoding.static String
KEY_PIXEL_WIDTH_HEIGHT_RATIO_FLOAT
CustomMediaFormat
key associated with a float representing the ratio between a pixel's width and height.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static MediaFormat
createMediaFormatFromFormat(Format format)
Returns aMediaFormat
representing the given ExoPlayerFormat
.static void
maybeSetByteBuffer(MediaFormat format, String key, byte[] value)
Sets aMediaFormat
ByteBuffer
value.static void
maybeSetColorInfo(MediaFormat format, ColorInfo colorInfo)
Sets aMediaFormat
's color information.static void
maybeSetFloat(MediaFormat format, String key, float value)
Sets aMediaFormat
float value.static void
maybeSetInteger(MediaFormat format, String key, int value)
Sets aMediaFormat
integer value.static void
maybeSetString(MediaFormat format, String key, String value)
Sets aMediaFormat
String
value.static void
setCsdBuffers(MediaFormat format, List<byte[]> csdBuffers)
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
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
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
-
-
Method Detail
-
createMediaFormatFromFormat
public static MediaFormat createMediaFormatFromFormat(Format format)
Returns aMediaFormat
representing the given ExoPlayerFormat
.May include the following custom keys:
-
maybeSetString
public static void maybeSetString(MediaFormat format, String key, @Nullable String value)
- 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)
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)
- 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)
- 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)
- 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)
Sets aMediaFormat
's color information. Does nothing ifcolorInfo
is null.- Parameters:
format
- TheMediaFormat
being configured.colorInfo
- The color info to set.
-
-