Mulai 27 Maret 2025, sebaiknya gunakan android-latest-release
, bukan aosp-main
, untuk mem-build dan berkontribusi pada AOSP. Untuk mengetahui informasi selengkapnya, lihat Perubahan pada AOSP.
Dependensi OEM untuk pengelola resource media
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Dokumen ini ditujukan untuk membantu produsen peralatan asli (OEM)
menerapkan dukungan untuk pengelola resource media Android dan API terkait dengan benar.
Instance codec serentak maksimum
Antarmuka CodecCapabilities.getMaxSupportedInstances
menampilkan jumlah maksimum instance codec serentak yang didukung.
Pengujian CTS
testGetMaxSupportedInstances(android.media.cts.MediaCodecCapabilitiesTest)
digunakan untuk menerapkan maksimum yang sesuai yang ditetapkan di
/etc/media_codecs.xml
.
Berikut ini contohnya:
...
<MediaCodecs>
...
<Encoders>
<MediaCodec name="OMX.<vendor>.video.encoder.avc" type="video/avc" >
...
<Limit name="concurrent-instances" max="13" />
</MediaCodec>
...
</Encoders>
...
</MediaCodecs>
OEM dapat menggunakan pengujian ini untuk menghasilkan batas serentak yang lulus pengujian.
Untuk melakukannya:
- Jalankan pengujian terlebih dahulu menggunakan cts-tradefed.
- Evaluasi pesan kegagalan yang dihasilkan. Berikut ini contohnya:
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>
- Tambahkan baris
concurrent-instances
yang disarankan dalam pesan kegagalan
pengujian ke file /etc/media_codecs.xml
.
- Jalankan kembali pengujian untuk memverifikasi keberhasilannya.
Kecepatan frame yang dapat dicapai untuk codec video
Antarmuka VideoCapabilities.getAchievableFrameRatesFor
menampilkan rentang kecepatan frame video yang dapat dicapai untuk ukuran video. Informasi
ini harus diberikan oleh OEM untuk setiap perangkat melalui file XML yang ditempatkan di
/etc/media_codecs_performance.xml
. Setelan ini diuji oleh
pengujian CTS com.android.cts.videoperf.VideoEncoderDecoderTest
dan
android.media.cts.VideoDecoderPerfTest
.
OEM dapat menggunakan pengujian CTS untuk membuat file XML yang lulus pengujian. Untuk melakukannya:
- Jalankan pengujian terlebih dahulu menggunakan cts-tradefed. Mengingat
variabilitas performa Android, sebaiknya pengujian dijalankan
beberapa kali untuk mendapatkan nilai minimum dan maksimum yang lebih akurat.
- Gunakan skrip
get_achievable_rates.py yang disediakan untuk membuat file XML.
- Tempatkan file XML di:
/etc/media_codecs_performance.xml
Tindakan ini biasanya dilakukan dengan menempatkan file XML dalam project perangkat
(device/<vendor>/<product>) dan menambahkan
baris PRODUCT_COPY_FILES
ke device.mk
seperti ini:
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
- Jalankan kembali pengujian performa untuk memverifikasi keberhasilannya.
Koeksistensi codec aman dan codec tidak aman
- supports-secure-with-non-secure-codec —
Jika instance codec aman dan instance codec tidak aman tidak dapat
bersama-sama secara bersamaan, hal tersebut harus ditunjukkan sebagai setelan global dalam
file
media_codecs.xml
.
<MediaCodecs>
<Settings>
<Setting name="supports-secure-with-non-secure-codec" value="false" />
</Settings>
<Encoders>
…
- supports-multiple-secure-codecs —
Jika keberadaan beberapa instance codec aman tidak didukung, hal tersebut harus
ditunjukkan sebagai setelan global dalam file
media_codecs.xml
.
<MediaCodecs>
<Settings>
<Setting name="supports-multiple-secure-codecs" value="false" />
</Settings>
<Encoders>
…
- Perhatikan bahwa kedua setelan tersebut benar secara default, yang berarti jika didukung,
Anda tidak perlu menambahkan baris setelan ke
media_codecs.xml
.
- Pengujian CTS
ResourceManagerTest
dapat gagal jika kedua setelan ini tidak ditetapkan
dengan benar.
Konten dan contoh kode di halaman ini tunduk kepada lisensi yang dijelaskan dalam Lisensi Konten. Java dan OpenJDK adalah merek dagang atau merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-07-27 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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."]]