Class MediaFormatUtil
- java.lang.Object
-
- com.google.android.exoplayer2.util.MediaFormatUtil
-
public final class MediaFormatUtil extends Object
Helper class containing utility methods for managingMediaFormatinstances.
-
-
Field Summary
Fields Modifier and Type Field Description static StringKEY_PCM_ENCODING_EXTENDEDCustomMediaFormatkey associated with an integer representing the PCM encoding.static StringKEY_PIXEL_WIDTH_HEIGHT_RATIO_FLOATCustomMediaFormatkey 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 MediaFormatcreateMediaFormatFromFormat(Format format)Returns aMediaFormatrepresenting the given ExoPlayerFormat.static voidmaybeSetByteBuffer(MediaFormat format, String key, byte[] value)Sets aMediaFormatByteBuffervalue.static voidmaybeSetColorInfo(MediaFormat format, ColorInfo colorInfo)Sets aMediaFormat's color information.static voidmaybeSetFloat(MediaFormat format, String key, float value)Sets aMediaFormatfloat value.static voidmaybeSetInteger(MediaFormat format, String key, int value)Sets aMediaFormatinteger value.static voidmaybeSetString(MediaFormat format, String key, String value)Sets aMediaFormatStringvalue.static voidsetCsdBuffers(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
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
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
-
-
Method Detail
-
createMediaFormatFromFormat
public static MediaFormat createMediaFormatFromFormat(Format format)
Returns aMediaFormatrepresenting the given ExoPlayerFormat.May include the following custom keys:
-
maybeSetString
public static void maybeSetString(MediaFormat format, String key, @Nullable String value)
- Parameters:
format- TheMediaFormatbeing 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- TheMediaFormatbeing configured.csdBuffers- The csd buffers to set.
-
maybeSetInteger
public static void maybeSetInteger(MediaFormat format, String key, int value)
- 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)
- 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)
- 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)
Sets aMediaFormat's color information. Does nothing ifcolorInfois null.- Parameters:
format- TheMediaFormatbeing configured.colorInfo- The color info to set.
-
-