A partir de 27 de março de 2025, recomendamos usar android-latest-release
em vez de aosp-main
para criar e contribuir com o AOSP. Para mais informações, consulte Mudanças no AOSP.
Dependências do OEM para o gerenciador de recursos de mídia
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Este documento tem como objetivo ajudar os fabricantes de equipamentos originais (OEMs)
a implementar corretamente o suporte ao gerenciador de recursos de mídia do Android e às APIs relacionadas.
Máximo de instâncias de codec simultâneas
A interface CodecCapabilities.getMaxSupportedInstances
retorna o número máximo de instâncias de codec simultâneas com suporte.
O teste CTS
testGetMaxSupportedInstances(android.media.cts.MediaCodecCapabilitiesTest)
é usado para aplicar o máximo adequado definido em
/etc/media_codecs.xml
.
Confira um exemplo:
...
<MediaCodecs>
...
<Encoders>
<MediaCodec name="OMX.<vendor>.video.encoder.avc" type="video/avc" >
...
<Limit name="concurrent-instances" max="13" />
</MediaCodec>
...
</Encoders>
...
</MediaCodecs>
Os OEMs podem usar esse teste para gerar os limites simultâneos que atendem aos requisitos.
Para fazer isto:
- Primeiro, execute o teste usando o cts-tradefed.
- Avalie a mensagem de falha resultante. Confira um exemplo:
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>
- Adicione as linhas
concurrent-instances
sugeridas na mensagem de falha
do teste ao arquivo /etc/media_codecs.xml
.
- Execute o teste novamente para verificar se ele foi bem-sucedido.
Frame rates possíveis para codecs de vídeo
A interface VideoCapabilities.getAchievableFrameRatesFor
retorna o intervalo de frame rates possíveis para um tamanho de vídeo. Essas
informações precisam ser fornecidas pelo OEM para cada dispositivo usando um arquivo XML colocado em
/etc/media_codecs_performance.xml
. Essas configurações são testadas pelos
testes CTS com.android.cts.videoperf.VideoEncoderDecoderTest
e
android.media.cts.VideoDecoderPerfTest
.
Os OEMs podem usar os testes do CTS para gerar os arquivos XML que passam nos testes. Para fazer isto:
- Primeiro, execute os testes usando o cts-tradefed. Dada a
variabilidade do desempenho do Android, é recomendável que os testes sejam executados
várias vezes para obter valores mínimos e máximos mais precisos.
- Use o script
get_achievable_rates.py fornecido para gerar o arquivo XML.
- Coloque o arquivo XML em:
/etc/media_codecs_performance.xml
Isso geralmente é feito colocando o arquivo XML no projeto do dispositivo
(device/<vendor>/<product>) e adicionando uma
linha PRODUCT_COPY_FILES
a device.mk
, assim:
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
- Execute os testes de desempenho novamente para verificar se eles foram bem-sucedidos.
Coexistência de codec seguro e codec não seguro
- supports-secure-with-non-secure-codec:
se a instância de codec seguro e a instância de codec não seguro não puderem
coexistir ao mesmo tempo, isso será indicado como configuração global no
arquivo
media_codecs.xml
.
<MediaCodecs>
<Settings>
<Setting name="supports-secure-with-non-secure-codec" value="false" />
</Settings>
<Encoders>
…
- supports-multiple-secure-codecs:
se a coexistência de várias instâncias de codec seguras não tiver suporte, isso será indicado
como uma configuração global no arquivo
media_codecs.xml
.
<MediaCodecs>
<Settings>
<Setting name="supports-multiple-secure-codecs" value="false" />
</Settings>
<Encoders>
…
- As duas configurações são verdadeiras por padrão, ou seja, se elas tiverem suporte,
não será necessário adicionar a linha de configuração ao
media_codecs.xml
.
- Os testes de CTS
ResourceManagerTest
podem falhar se essas duas configurações não estiverem definidas
corretamente.
O conteúdo e os exemplos de código nesta página estão sujeitos às licenças descritas na Licença de conteúdo. Java e OpenJDK são marcas registradas da Oracle e/ou suas afiliadas.
Última atualização 2025-07-27 UTC.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Não contém as informações de que eu preciso","missingTheInformationINeed","thumb-down"],["Muito complicado / etapas demais","tooComplicatedTooManySteps","thumb-down"],["Desatualizado","outOfDate","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Problema com as amostras / o código","samplesCodeIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-07-27 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."]]