MediaCodecInfo: allow getting info for secure codec

3 minor fixes:
- return correct codec's info from MediaCodec.getCodecInfo()
- treat required features supported
- make feature spec optional in isFormatSupported

Bug: 17154761
Change-Id: Ie98af35ec16caf48a76358fe178f9cc243abad4f
This commit is contained in:
Lajos Molnar
2014-08-28 06:39:01 -07:00
parent 1a08a8f52f
commit dbf1552d52
3 changed files with 14 additions and 8 deletions

View File

@@ -1619,8 +1619,7 @@ final public class MediaCodec {
* @throws IllegalStateException if in the Uninitialized state.
*/
public MediaCodecInfo getCodecInfo() {
return MediaCodecList.getCodecInfoAt(
MediaCodecList.findCodecByName(getName()));
return MediaCodecList.getInfoFor(getName());
}
private native final ByteBuffer[] getBuffers(boolean input);

View File

@@ -321,6 +321,9 @@ public final class MediaCodecInfo {
// check feature support
for (Feature feat: getValidFeatures()) {
Integer yesNo = (Integer)map.get(MediaFormat.KEY_FEATURE_ + feat.mName);
if (yesNo == null) {
continue;
}
if ((yesNo == 1 && !isFeatureSupported(feat.mName)) ||
(yesNo == 0 && isFeatureRequired(feat.mName))) {
return false;
@@ -470,13 +473,12 @@ public final class MediaCodecInfo {
Integer yesNo = (Integer)map.get(key);
if (yesNo == null) {
continue;
} else if (yesNo > 0) {
mFlagsRequired |= feat.mValue;
mDefaultFormat.setInteger(key, 1);
} else {
mFlagsSupported |= feat.mValue;
mDefaultFormat.setInteger(key, 1);
}
if (yesNo > 0) {
mFlagsRequired |= feat.mValue;
}
mFlagsSupported |= feat.mValue;
mDefaultFormat.setInteger(key, 1);
// TODO restrict features by mFlagsVerified once all codecs reliably verify them
}
}

View File

@@ -116,6 +116,11 @@ final public class MediaCodecList {
/* package private */ static native final int findCodecByName(String codec);
/** @hide */
public static MediaCodecInfo getInfoFor(String codec) {
return sAllCodecInfos[findCodecByName(codec)];
}
private static native final void native_init();
/**