public final class MediaCodecList extends Object
MediaCodecInfo
object,
find a codec supporting a given format and query the capabilities
of a given codec.
See MediaCodecInfo
for sample usage.
Modifier and Type | Field and Description |
---|---|
static 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. |
static int |
REGULAR_CODECS
Use in
MediaCodecList(int) to enumerate only codecs that are suitable
for regular (buffer-to-buffer) decoding or encoding. |
Constructor and Description |
---|
MediaCodecList(int kind)
Create a list of media-codecs of a specific kind.
|
Modifier and Type | Method and Description |
---|---|
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()
Deprecated.
Use
getCodecInfos() instead. |
static MediaCodecInfo |
getCodecInfoAt(int index)
Deprecated.
Use
getCodecInfos() instead. |
MediaCodecInfo[] |
getCodecInfos()
Returns the list of
MediaCodecInfo objects for the list
of media-codecs. |
static MediaCodecInfo |
getInfoFor(String codec) |
public static final int REGULAR_CODECS
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.public static final int ALL_CODECS
MediaCodecList(int)
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.public MediaCodecList(int kind)
kind
- Either REGULAR_CODECS
or ALL_CODECS
.public static final int getCodecCount()
getCodecInfos()
instead.REGULAR_CODECS
public static final MediaCodecInfo getCodecInfoAt(int index)
getCodecInfos()
instead.MediaCodecInfo
object for the codec at
the given index
in the regular list.REGULAR_CODECS
public static MediaCodecInfo getInfoFor(String codec)
public final MediaCodecInfo[] getCodecInfos()
MediaCodecInfo
objects for the list
of media-codecs.public final String findDecoderForFormat(MediaFormat format)
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.
format
- A decoder media format with optional feature directives.null
if no such codec has been found.IllegalArgumentException
- if format is not a valid media format.NullPointerException
- if format is null.for format keys
considered per android versions when evaluating suitable codecs.
public final String findEncoderForFormat(MediaFormat format)
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.
format
- An encoder media format with optional feature directives.null
if no such codec has been found.IllegalArgumentException
- if format is not a valid media format.NullPointerException
- if format is null.for format keys
considered per android versions when evaluating suitable codecs.