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 aPRODUCT_COPY_FILES
line todevice.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.