Fields Summary |
---|
private static final String | TAG |
private static Object | sInitLock |
private static android.media.MediaCodecInfo[] | sAllCodecInfos |
private static android.media.MediaCodecInfo[] | sRegularCodecInfos |
public static final int | REGULAR_CODECSUse in {@link #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. |
public static final int | ALL_CODECSUse in {@link #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. |
private android.media.MediaCodecInfo[] | mCodecInfos |
Methods Summary |
---|
static final native int | findCodecByName(java.lang.String codec)
|
private java.lang.String | findCodecForFormat(boolean encoder, MediaFormat format)
String mime = format.getString(MediaFormat.KEY_MIME);
for (MediaCodecInfo info: mCodecInfos) {
if (info.isEncoder() != encoder) {
continue;
}
try {
MediaCodecInfo.CodecCapabilities caps = info.getCapabilitiesForType(mime);
if (caps != null && caps.isFormatSupported(format)) {
return info.getName();
}
} catch (IllegalArgumentException e) {
// type is not supported
}
}
return null;
|
public final java.lang.String | findDecoderForFormat(MediaFormat format)Find a decoder supporting a given {@link MediaFormat} in the list
of media-codecs.
System.loadLibrary("media_jni");
native_init();
// mediaserver is not yet alive here
return findCodecForFormat(false /* encoder */, format);
|
public final java.lang.String | findEncoderForFormat(MediaFormat format)Find an encoder supporting a given {@link MediaFormat} in the list
of media-codecs.
return findCodecForFormat(true /* encoder */, format);
|
static final native android.media.MediaCodecInfo.CodecCapabilities | getCodecCapabilities(int index, java.lang.String type)
|
public static final int | getCodecCount()Count the number of available (regular) codecs.
initCodecList();
return sRegularCodecInfos.length;
|
public static final android.media.MediaCodecInfo | getCodecInfoAt(int index)Return the {@link MediaCodecInfo} object for the codec at
the given {@code index} in the regular list.
initCodecList();
if (index < 0 || index > sRegularCodecInfos.length) {
throw new IllegalArgumentException();
}
return sRegularCodecInfos[index];
|
public final android.media.MediaCodecInfo[] | getCodecInfos()Returns the list of {@link MediaCodecInfo} objects for the list
of media-codecs.
return Arrays.copyOf(mCodecInfos, mCodecInfos.length);
|
static final native java.lang.String | getCodecName(int index)
|
public static android.media.MediaCodecInfo | getInfoFor(java.lang.String codec)
initCodecList();
return sAllCodecInfos[findCodecByName(codec)];
|
private static android.media.MediaCodecInfo | getNewCodecInfoAt(int index)
String[] supportedTypes = getSupportedTypes(index);
MediaCodecInfo.CodecCapabilities[] caps =
new MediaCodecInfo.CodecCapabilities[supportedTypes.length];
int typeIx = 0;
for (String type: supportedTypes) {
caps[typeIx++] = getCodecCapabilities(index, type);
}
return new MediaCodecInfo(
getCodecName(index), isEncoder(index), caps);
|
static final native java.lang.String[] | getSupportedTypes(int index)
|
private static final void | initCodecList()
synchronized (sInitLock) {
if (sRegularCodecInfos == null) {
int count = native_getCodecCount();
ArrayList<MediaCodecInfo> regulars = new ArrayList<MediaCodecInfo>();
ArrayList<MediaCodecInfo> all = new ArrayList<MediaCodecInfo>();
for (int index = 0; index < count; index++) {
try {
MediaCodecInfo info = getNewCodecInfoAt(index);
all.add(info);
info = info.makeRegular();
if (info != null) {
regulars.add(info);
}
} catch (Exception e) {
Log.e(TAG, "Could not get codec capabilities", e);
}
}
sRegularCodecInfos =
regulars.toArray(new MediaCodecInfo[regulars.size()]);
sAllCodecInfos =
all.toArray(new MediaCodecInfo[all.size()]);
}
}
|
static final native boolean | isEncoder(int index)
|
private static final native int | native_getCodecCount()
|
private static final native void | native_init()
|