diff options
author | Lajos Molnar <lajos@google.com> | 2021-10-20 16:10:08 -0700 |
---|---|---|
committer | Jaideep Sharma <quic_jaidshar@quicinc.com> | 2021-12-23 10:27:51 +0530 |
commit | 8dcfdf74c1c0b2e088eba211fa0e69b7782d5d0b (patch) | |
tree | f55c2c8377fa5c7e5d756ddb6289340d2ea1485a | |
parent | 48cbb14e1815430efd7ff5086e7a4c70e75d475f (diff) |
media: allow excluding arbitrary codecs from REGULAR_CODECS list.
This can be done by adding the 'special-codec' feature as a required
feature to media_codecs.xml, e.g.
<MediaCodec name="..." type="...">
...
<Feature name"special-codec" required="true" />
</MediaCodec>
This feature is not exposed to applications, and is only used to
exclude a codec from the REGULAR_CODECS list.
Bug: 197577115
Bug: 196518411
Bug: 191944087
Test: CtsVideoTestCases and manual testing with a modified media_codecs.xml
Change-Id: Ica5510bbe7e781f25ca329535d2ba771afbdb263
(cherry picked from commit daa879ac687bdbcb9594a5fc5c811a4c7c66ac44)
CRs-Fixed: 3099105
Change-Id: Ic7a863838f5db3326306e5bb95b4eb9b092ceead
-rw-r--r-- | media/java/android/media/MediaCodecInfo.java | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/media/java/android/media/MediaCodecInfo.java b/media/java/android/media/MediaCodecInfo.java index 9a82ab168492..dadeed110f01 100644 --- a/media/java/android/media/MediaCodecInfo.java +++ b/media/java/android/media/MediaCodecInfo.java @@ -181,10 +181,15 @@ public final class MediaCodecInfo { public String mName; public int mValue; public boolean mDefault; + public boolean mInternal; public Feature(String name, int value, boolean def) { + this(name, value, def, false /* internal */); + } + public Feature(String name, int value, boolean def, boolean internal) { mName = name; mValue = value; mDefault = def; + mInternal = internal; } } @@ -571,6 +576,11 @@ public final class MediaCodecInfo { public static final String FEATURE_LowLatency = "low-latency"; /** + * Do not include in REGULAR_CODECS list in MediaCodecList. + */ + private static final String FEATURE_SpecialCodec = "special-codec"; + + /** * <b>video encoder only</b>: codec supports quantization parameter bounds. * @see MediaFormat#KEY_VIDEO_QP_MAX * @see MediaFormat#KEY_VIDEO_QP_MIN @@ -608,6 +618,8 @@ public final class MediaCodecInfo { new Feature(FEATURE_MultipleFrames, (1 << 5), false), new Feature(FEATURE_DynamicTimestamp, (1 << 6), false), new Feature(FEATURE_LowLatency, (1 << 7), true), + // feature to exclude codec from REGULAR codec list + new Feature(FEATURE_SpecialCodec, (1 << 30), false, true), }; private static final Feature[] encoderFeatures = { @@ -615,6 +627,8 @@ public final class MediaCodecInfo { new Feature(FEATURE_MultipleFrames, (1 << 1), false), new Feature(FEATURE_DynamicTimestamp, (1 << 2), false), new Feature(FEATURE_QpBounds, (1 << 3), false), + // feature to exclude codec from REGULAR codec list + new Feature(FEATURE_SpecialCodec, (1 << 30), false, true), }; /** @hide */ @@ -622,7 +636,9 @@ public final class MediaCodecInfo { Feature[] features = getValidFeatures(); String[] res = new String[features.length]; for (int i = 0; i < res.length; i++) { - res[i] = features[i].mName; + if (!features[i].mInternal) { + res[i] = features[i].mName; + } } return res; } @@ -770,6 +786,10 @@ public final class MediaCodecInfo { // check feature support for (Feature feat: getValidFeatures()) { + if (feat.mInternal) { + continue; + } + Integer yesNo = (Integer)map.get(MediaFormat.KEY_FEATURE_ + feat.mName); if (yesNo == null) { continue; @@ -1083,7 +1103,9 @@ public final class MediaCodecInfo { mFlagsRequired |= feat.mValue; } mFlagsSupported |= feat.mValue; - mDefaultFormat.setInteger(key, 1); + if (!feat.mInternal) { + mDefaultFormat.setInteger(key, 1); + } // TODO restrict features by mFlagsVerified once all codecs reliably verify them } } |