MediaCodecList  |  API reference  |  Android Developers


public final class MediaCodecList
extends Object



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

int ALL_CODECS

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

int REGULAR_CODECS

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

Public constructors

MediaCodecList(int kind)

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

Public methods

String findDecoderForFormat(MediaFormat format)

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

String findEncoderForFormat(MediaFormat format)

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

static int getCodecCount()

This method was deprecated in API level 21. Use getCodecInfos() instead.

static MediaCodecInfo getCodecInfoAt(int index)

This method was deprecated in API level 21. Use getCodecInfos() instead.

MediaCodecInfo[] getCodecInfos()

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

Inherited methods

From class java.lang.Object

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Constants

REGULAR_CODECS

public static final int REGULAR_CODECS

Use in MediaCodecList(int) 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.

Constant Value: 0 (0x00000000)

Public constructors

Public methods

findDecoderForFormat

public String findDecoderForFormat (MediaFormat format)

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

Note: On 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.
Returns
String the name of a decoder that supports the given format and feature requests, or null if no such codec has been found.
Throws
IllegalArgumentException if format is not a valid media format.
NullPointerException if format is null.

findEncoderForFormat

public String findEncoderForFormat (MediaFormat format)

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

Note: On 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.
Returns
String the name of an encoder that supports the given format and feature requests, or null if no such codec has been found.
Throws
IllegalArgumentException if format is not a valid media format.
NullPointerException if format is null.

getCodecCount

public static int getCodecCount ()

This method was deprecated in API level 21.
Use getCodecInfos() instead.

Count the number of available (regular) codecs.

Returns
int