Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dbf1552d authored by Lajos Molnar's avatar Lajos Molnar
Browse files

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
parent 1a08a8f5
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -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);
+7 −5
Original line number Diff line number Diff line
@@ -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) {
                }
                if (yesNo > 0) {
                    mFlagsRequired |= feat.mValue;
                    mDefaultFormat.setInteger(key, 1);
                } else {
                }
                mFlagsSupported |= feat.mValue;
                mDefaultFormat.setInteger(key, 1);
                }
                // TODO restrict features by mFlagsVerified once all codecs reliably verify them
            }
        }
+5 −0
Original line number Diff line number Diff line
@@ -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();

    /**