Starting March 27, 2025, we recommend using android-latest-release
instead of aosp-main
to build and contribute to AOSP. For more information, see Changes to AOSP.
OEM dependencies for media resource manager
Stay organized with collections
Save and categorize content based on your preferences.
This document is intended to help original equipment manufacturers (OEMs)
properly implement support for Android media resource manager and related APIs.
Max concurrent codec instances
The CodecCapabilities.getMaxSupportedInstances
interface
returns the maximum number of supported concurrent codec instances.
The CTS test
testGetMaxSupportedInstances(android.media.cts.MediaCodecCapabilitiesTest)
is used to enforce the proper maximum is set in
/etc/media_codecs.xml
.
Here is an example:
...
<MediaCodecs>
...
<Encoders>
<MediaCodec name="OMX.<vendor>.video.encoder.avc" type="video/avc" >
...
<Limit name="concurrent-instances" max="13" />
</MediaCodec>
...
</Encoders>
...
</MediaCodecs>
OEMs can use this test to generate the concurrent limits that pass the test.
To do this:
- Run the test first using cts-tradefed.
- Evaluate the resulting failure message. Here is an example:
There was 1 failure:
1) testGetMaxSupportedInstances(android.media.cts.MediaCodecCapabilitiesTest)
junit.framework.AssertionFailedError: In order to pass the test, please publish
following codecs' concurrent instances limit in /etc/media_codecs.xml:
<MediaCodec name="OMX.<vendor>.video.encoder.mpeg4" type="video/mp4v-es" >
<Limit name="concurrent-instances" max="13" />
</MediaCodec>
<MediaCodec name="OMX.<vendor>.video.encoder.h263" type="video/3gpp" >
<Limit name="concurrent-instances" max="13" />
</MediaCodec>
<MediaCodec name="OMX.<vendor>.video.encoder.avc" type="video/avc" >
<Limit name="concurrent-instances" max="13" />
</MediaCodec>
<MediaCodec name="OMX.<vendor>.video.encoder.vp8" type="video/x-vnd.on2.vp8" >
<Limit name="concurrent-instances" max="13" />
</MediaCodec>
<MediaCodec name="OMX.<vendor>.video.decoder.avc" type="video/avc" >
<Limit name="concurrent-instances" max="13" />
</MediaCodec>
<MediaCodec name="OMX.<vendor>.video.decoder.avc.secure" type="video/avc" >
<Limit name="concurrent-instances" max="4" />
</MediaCodec>
<MediaCodec name="OMX.<vendor>.video.decoder.mpeg4" type="video/mp4v-es" >
<Limit name="concurrent-instances" max="12" />
</MediaCodec>
<MediaCodec name="OMX.<vendor>.video.decoder.h263" type="video/3gpp" >
<Limit name="concurrent-instances" max="12" />
</MediaCodec>
<MediaCodec name="OMX.<vendor>.video.decoder.vp8" type="video/x-vnd.on2.vp8" >
<Limit name="concurrent-instances" max="12" />
</MediaCodec>
- Add the
concurrent-instances
lines suggested in the test
failure message to the /etc/media_codecs.xml
file.
- Re-run the test to verify its success.
Achievable frame rates for video codecs
The VideoCapabilities.getAchievableFrameRatesFor
interface
returns the range of achievable video frame rates for a video size. This
information must be provided by the OEM for each device via an XML file placed at
/etc/media_codecs_performance.xml
. These settings are tested by
the com.android.cts.videoperf.VideoEncoderDecoderTest
and
android.media.cts.VideoDecoderPerfTest
CTS tests.
OEMs can use the CTS tests to generate the XML files that pass the tests. To do this:
- Run the tests first using cts-tradefed. Given the
variability of Android performance, it is recommended the tests are run
multiple times to get more accurate minimum and maximum values.
- Use the provided
get_achievable_rates.py script to generate the XML file.
- Place the XML file at:
/etc/media_codecs_performance.xml
This is usually done by placing the XML file in the device project
(device/<vendor>/<product>) and adding a
PRODUCT_COPY_FILES
line to device.mk
like so:
PRODUCT_COPY_FILES += \
...
device/moto/shamu/media_codecs.xml:system/etc/media_codecs.xml \
+ device/moto/shamu/media_codecs_performance.xml:system/etc/media_codecs_performance.xml
- Re-run the performance tests to verify their success.
Coexistence of secure codec and non-secure codec
- supports-secure-with-non-secure-codec —
If the instance of secure codec and the instance of non-secure codec can't
coexist at the same time, that should be indicated as global setting in the
media_codecs.xml
file.
<MediaCodecs>
<Settings>
<Setting name="supports-secure-with-non-secure-codec" value="false" />
</Settings>
<Encoders>
…
- supports-multiple-secure-codecs —
If the coexistence of multiple secure codec instances is not supported, that should be
indicated as a global setting in the
media_codecs.xml
file.
<MediaCodecs>
<Settings>
<Setting name="supports-multiple-secure-codecs" value="false" />
</Settings>
<Encoders>
…
- Note that the both settings are true by default, meaning if they are supported,
there's no need to add the setting line to the
media_codecs.xml
.
- The
ResourceManagerTest
CTS tests may fail if these two settings were not set
properly.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-06-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-18 UTC."],[],[],null,["# OEM dependencies for media resource manager\n\nThis document is intended to help original equipment manufacturers (OEMs)\nproperly implement support for Android media resource manager and related APIs.\n\nMax concurrent codec instances\n------------------------------\n\nThe `CodecCapabilities.getMaxSupportedInstances` interface\nreturns the maximum number of supported concurrent codec instances.\n\nThe CTS test\n`testGetMaxSupportedInstances(android.media.cts.MediaCodecCapabilitiesTest)`\nis used to enforce the proper maximum is set in\n`/etc/media_codecs.xml`.\n\nHere is an example: \n\n```\n...\n\u003cMediaCodecs\u003e\n ...\n \u003cEncoders\u003e\n \u003cMediaCodec name=\"OMX.\u003cvendor\u003e.video.encoder.avc\" type=\"video/avc\" \u003e\n ...\n \u003cLimit name=\"concurrent-instances\" max=\"13\" /\u003e\n \u003c/MediaCodec\u003e\n ...\n \u003c/Encoders\u003e\n ...\n\u003c/MediaCodecs\u003e\n```\n\nOEMs can use this test to generate the concurrent limits that pass the test.\nTo do this:\n\n1. Run the test first using cts-tradefed.\n2. Evaluate the resulting failure message. Here is an example: \n\n ```\n There was 1 failure:\n 1) testGetMaxSupportedInstances(android.media.cts.MediaCodecCapabilitiesTest)\n junit.framework.AssertionFailedError: In order to pass the test, please publish\n following codecs' concurrent instances limit in /etc/media_codecs.xml:\n \u003cMediaCodec name=\"OMX.\u003cvendor\u003e.video.encoder.mpeg4\" type=\"video/mp4v-es\" \u003e\n \u003cLimit name=\"concurrent-instances\" max=\"13\" /\u003e\n \u003c/MediaCodec\u003e\n \u003cMediaCodec name=\"OMX.\u003cvendor\u003e.video.encoder.h263\" type=\"video/3gpp\" \u003e\n \u003cLimit name=\"concurrent-instances\" max=\"13\" /\u003e\n \u003c/MediaCodec\u003e\n \u003cMediaCodec name=\"OMX.\u003cvendor\u003e.video.encoder.avc\" type=\"video/avc\" \u003e\n \u003cLimit name=\"concurrent-instances\" max=\"13\" /\u003e\n \u003c/MediaCodec\u003e\n \u003cMediaCodec name=\"OMX.\u003cvendor\u003e.video.encoder.vp8\" type=\"video/x-vnd.on2.vp8\" \u003e\n \u003cLimit name=\"concurrent-instances\" max=\"13\" /\u003e\n \u003c/MediaCodec\u003e\n \u003cMediaCodec name=\"OMX.\u003cvendor\u003e.video.decoder.avc\" type=\"video/avc\" \u003e\n \u003cLimit name=\"concurrent-instances\" max=\"13\" /\u003e\n \u003c/MediaCodec\u003e\n \u003cMediaCodec name=\"OMX.\u003cvendor\u003e.video.decoder.avc.secure\" type=\"video/avc\" \u003e\n \u003cLimit name=\"concurrent-instances\" max=\"4\" /\u003e\n \u003c/MediaCodec\u003e\n \u003cMediaCodec name=\"OMX.\u003cvendor\u003e.video.decoder.mpeg4\" type=\"video/mp4v-es\" \u003e\n \u003cLimit name=\"concurrent-instances\" max=\"12\" /\u003e\n \u003c/MediaCodec\u003e\n \u003cMediaCodec name=\"OMX.\u003cvendor\u003e.video.decoder.h263\" type=\"video/3gpp\" \u003e\n \u003cLimit name=\"concurrent-instances\" max=\"12\" /\u003e\n \u003c/MediaCodec\u003e\n \u003cMediaCodec name=\"OMX.\u003cvendor\u003e.video.decoder.vp8\" type=\"video/x-vnd.on2.vp8\" \u003e\n \u003cLimit name=\"concurrent-instances\" max=\"12\" /\u003e\n \u003c/MediaCodec\u003e\n ```\n3. Add the `concurrent-instances` lines suggested in the test failure message to the `/etc/media_codecs.xml` file.\n4. Re-run the test to verify its success.\n\nAchievable frame rates for video codecs\n---------------------------------------\n\nThe `VideoCapabilities.getAchievableFrameRatesFor` interface\nreturns the range of achievable video frame rates for a video size. This\ninformation must be provided by the OEM for each device via an XML file placed at\n`/etc/media_codecs_performance.xml`. These settings are tested by\nthe `com.android.cts.videoperf.VideoEncoderDecoderTest` and\n`android.media.cts.VideoDecoderPerfTest` CTS tests.\n\nOEMs can use the CTS tests to generate the XML files that pass the tests. To do this:\n\n1. Run the tests first using cts-tradefed. Given the variability of Android performance, it is recommended the tests are run multiple times to get more accurate minimum and maximum values.\n2. Use the provided [get_achievable_rates.py](https://android.googlesource.com/platform/cts/+/android16-release/tools/cts-media/get_achievable_rates.py) script to generate the XML file.\n3. Place the XML file at: `/etc/media_codecs_performance.xml` \n This is usually done by placing the XML file in the device project (device/*\\\u003cvendor\\\u003e* /*\\\u003cproduct\\\u003e* ) and adding a `PRODUCT_COPY_FILES` line to `device.mk` like so: \n\n ```\n PRODUCT_COPY_FILES += \\\n ...\n device/moto/shamu/media_codecs.xml:system/etc/media_codecs.xml \\\n + device/moto/shamu/media_codecs_performance.xml:system/etc/media_codecs_performance.xml\n ```\n4. Re-run the performance tests to verify their success.\n\nCoexistence of secure codec and non-secure codec\n------------------------------------------------\n\n- supports-secure-with-non-secure-codec --- If the instance of secure codec and the instance of non-secure codec can't coexist at the same time, that should be indicated as global setting in the `media_codecs.xml` file. \n\n ```\n \u003cMediaCodecs\u003e\n \u003cSettings\u003e\n \u003cSetting name=\"supports-secure-with-non-secure-codec\" value=\"false\" /\u003e\n \u003c/Settings\u003e\n \u003cEncoders\u003e\n …\n ```\n- supports-multiple-secure-codecs --- If the coexistence of multiple secure codec instances is not supported, that should be indicated as a global setting in the `media_codecs.xml` file. \n\n ```\n \u003cMediaCodecs\u003e\n \u003cSettings\u003e\n \u003cSetting name=\"supports-multiple-secure-codecs\" value=\"false\" /\u003e\n \u003c/Settings\u003e\n \u003cEncoders\u003e\n …\n ```\n- Note that the both settings are true by default, meaning if they are supported, there's no need to add the setting line to the `media_codecs.xml`.\n- The `ResourceManagerTest` CTS tests may fail if these two settings were not set properly."]]