Added in API level 16

MediaCodecList


class MediaCodecList
kotlin.Any
   ↳ android.media.MediaCodecList

Allows you to enumerate available codecs, each specified as a MediaCodecInfo object, find a codec supporting a given format and query the capabilities of a given codec.

See MediaCodecInfo for sample usage.

Summary

Constants
static Int

Use in MediaCodecList to enumerate all codecs, even ones that are not suitable for regular (buffer-to-buffer) decoding or encoding.

static Int

Use in MediaCodecList to enumerate only codecs that are suitable for regular (buffer-to-buffer) decoding or encoding.

Public constructors

Create a list of media-codecs of a specific kind.

Public methods
String!

Find a decoder supporting a given MediaFormat in the list of media-codecs.

String!

Find an encoder supporting a given MediaFormat in the list of media-codecs.

static Int

Count the number of available (regular) codecs.

static MediaCodecInfo!

Return the MediaCodecInfo object for the codec at the given index in the regular list.

Array<MediaCodecInfo!>!

Returns the list of MediaCodecInfo objects for the list of media-codecs.

Constants

ALL_CODECS

Added in API level 21
static val ALL_CODECS: Int

Use in MediaCodecList to enumerate all codecs, even ones that are not suitable for regular (buffer-to-buffer) decoding or encoding. These include codecs, for example, that only work with special input or output surfaces, such as secure-only or tunneled-only codecs.

Value: 1

REGULAR_CODECS

Added in API level 21
static val REGULAR_CODECS: Int

Use in MediaCodecList to enumerate only codecs that are suitable for regular (buffer-to-buffer) decoding or encoding. NOTE: These are the codecs that are returned prior to API 21, using the now deprecated static methods.

Value: 0

Public constructors

MediaCodecList

Added in API level 21
MediaCodecList(kind: Int)

Create a list of media-codecs of a specific kind.

Parameters
kind Int: Either MediaCodecList#REGULAR_CODECS or MediaCodecList#ALL_CODECS.

Public methods

findDecoderForFormat

Added in API level 21
fun findDecoderForFormat(format: MediaFormat!): String!

Find a decoder supporting a given MediaFormat in the list of media-codecs.

Note: On android.os.Build.VERSION_CODES#LOLLIPOP, format must not contain a frame rate. Use format.setString(MediaFormat.KEY_FRAME_RATE, null) to clear any existing frame rate setting in the format.

Parameters
format MediaFormat!: A decoder media format with optional feature directives.
Return
String! the name of a decoder that supports the given format and feature requests, or null if no such codec has been found.
Exceptions
java.lang.IllegalArgumentException if format is not a valid media format.
java.lang.NullPointerException if format is null.

findEncoderForFormat

Added in API level 21
fun findEncoderForFormat(format: MediaFormat!): String!

Find an encoder supporting a given MediaFormat in the list of media-codecs.

Note: On android.os.Build.VERSION_CODES#LOLLIPOP, format must not contain a frame rate. Use format.setString(MediaFormat.KEY_FRAME_RATE, null) to clear any existing frame rate setting in the format.

Parameters
format MediaFormat!: An encoder media format with optional feature directives.
Return
String! the name of an encoder that supports the given format and feature requests, or null if no such codec has been found.
Exceptions
java.lang.IllegalArgumentException if format is not a valid media format.
java.lang.NullPointerException if format is null.

getCodecCount

Added in API level 16
Deprecated in API level 21
static fun getCodecCount(): Int

Deprecated: Use getCodecInfos instead.

Count the number of available (regular) codecs.

See Also

getCodecInfoAt

Added in API level 16
Deprecated in API level 21
static fun getCodecInfoAt(index: Int): MediaCodecInfo!

Deprecated: Use getCodecInfos instead.

Return the MediaCodecInfo object for the codec at the given index in the regular list.

See Also

getCodecInfos

Added in API level 21
fun getCodecInfos(): Array<MediaCodecInfo!>!

Returns the list of MediaCodecInfo objects for the list of media-codecs.