1 <html devsite> 2 <head> 3 <title>OEM Dependencies for Media Resource Manager</title> 4 <meta name="project_path" value="/_project.yaml" /> 5 <meta name="book_path" value="/_book.yaml" /> 6 </head> 7 <body> 8 <!-- 9 Copyright 2017 The Android Open Source Project 10 11 Licensed under the Apache License, Version 2.0 (the "License"); 12 you may not use this file except in compliance with the License. 13 You may obtain a copy of the License at 14 15 http://www.apache.org/licenses/LICENSE-2.0 16 17 Unless required by applicable law or agreed to in writing, software 18 distributed under the License is distributed on an "AS IS" BASIS, 19 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 See the License for the specific language governing permissions and 21 limitations under the License. 22 --> 23 24 25 26 <p>This document is intended to help original equipment manufacturers (OEMs) 27 properly implement support for Android media resource manager and related APIs.</p> 28 29 <h2 id=1_max_concurrent_codec_instances>1. Max concurrent codec instances</h2> 30 31 <p>The <code>CodecCapabilities.getMaxSupportedInstances</code> interface 32 returns the maximum number of supported concurrent codec instances.</p> 33 34 <p>The CTS test 35 <code>testGetMaxSupportedInstances(android.media.cts.MediaCodecCapabilitiesTest)</code> 36 is used to enforce the proper maximum is set in 37 <code>/etc/media_codecs.xml</code>.</p> 38 39 <p>Here is an example:</p> 40 41 <pre class="devsite-click-to-copy"> 42 ... 43 <MediaCodecs> 44 ... 45 <Encoders> 46 <MediaCodec name="OMX.<em><vendor></em>.video.encoder.avc" type="video/avc" > 47 ... 48 <Limit name="concurrent-instances" max="13" /> 49 </MediaCodec> 50 ... 51 </Encoders> 52 ... 53 </MediaCodecs> 54 </pre> 55 56 <p>OEMs can use this test to generate the concurrent limits that pass the test. 57 To do this:</p> 58 59 <ol> 60 <li>Run the test first using cts-tradefed. 61 <li>Evaluate the resulting failure message. Here is an example: 62 63 <pre class="devsite-click-to-copy"> 64 There was 1 failure: 65 1) testGetMaxSupportedInstances(android.media.cts.MediaCodecCapabilitiesTest) 66 junit.framework.AssertionFailedError: In order to pass the test, please publish 67 following codecs' concurrent instances limit in /etc/media_codecs.xml: 68 <MediaCodec name="OMX.<em><vendor></em>.video.encoder.mpeg4" type="video/mp4v-es" > 69 <Limit name="concurrent-instances" max="13" /> 70 </MediaCodec> 71 <MediaCodec name="OMX.<em><vendor></em>.video.encoder.h263" type="video/3gpp" > 72 <Limit name="concurrent-instances" max="13" /> 73 </MediaCodec> 74 <MediaCodec name="OMX.<em><vendor></em>.video.encoder.avc" type="video/avc" > 75 <Limit name="concurrent-instances" max="13" /> 76 </MediaCodec> 77 <MediaCodec name="OMX.<em><vendor></em>.video.encoder.vp8" type="video/x-vnd.on2.vp8" > 78 <Limit name="concurrent-instances" max="13" /> 79 </MediaCodec> 80 <MediaCodec name="OMX.<em><vendor></em>.video.decoder.avc" type="video/avc" > 81 <Limit name="concurrent-instances" max="13" /> 82 </MediaCodec> 83 <MediaCodec name="OMX.<em><vendor></em>.video.decoder.avc.secure" type="video/avc" > 84 <Limit name="concurrent-instances" max="4" /> 85 </MediaCodec> 86 <MediaCodec name="OMX.<em><vendor></em>.video.decoder.mpeg4" type="video/mp4v-es" > 87 <Limit name="concurrent-instances" max="12" /> 88 </MediaCodec> 89 <MediaCodec name="OMX.<em><vendor></em>.video.decoder.h263" type="video/3gpp" > 90 <Limit name="concurrent-instances" max="12" /> 91 </MediaCodec> 92 <MediaCodec name="OMX.<em><vendor></em>.video.decoder.vp8" type="video/x-vnd.on2.vp8" > 93 <Limit name="concurrent-instances" max="12" /> 94 </MediaCodec> 95 </pre> 96 97 <li>Add the <code>concurrent-instances</code> lines suggested in the test 98 failure message to the <code>/etc/media_codecs.xml</code> file. 99 100 <li>Re-run the test to verify its success. 101 </ol> 102 103 <h2 id=2_achievable_frame_rates_for_video_codecs>2. Achievable frame rates for video codecs</h2> 104 <p>The <code>VideoCapabilities.getAchievableFrameRatesFor</code> interface 105 returns the range of achievable video frame rates for a video size. This 106 information must be provided by the OEM for each device via an XML file placed at 107 <code>/etc/media_codecs_performance.xml</code>. These settings are tested by 108 the <code>com.android.cts.videoperf.VideoEncoderDecoderTest</code> and 109 <code>android.media.cts.VideoDecoderPerfTest</code> CTS tests.</p> 110 111 <p>OEMs can use the CTS tests to generate the XML files that pass the tests. To do this:</p> 112 <ol> 113 <li>Run the tests first using cts-tradefed. Given the 114 variability of Android performance, it is recommended the tests are run 115 multiple times to get more accurate minimum and maximum values. 116 <li>Use the provided <a 117 href="https://android.googlesource.com/platform/cts/+/marshmallow-cts-dev/tools/cts-media/get_achievable_rates.py">get_achievable_rates.py</a> 118 script to generate the XML file. 119 <li>Place the XML file at: <code>/etc/media_codecs_performance.xml</code><br> 120 This is usually done by placing the XML file in the device project 121 (device/<em><vendor></em>/<em><product></em>) and adding a 122 <code>PRODUCT_COPY_FILES</code> line to <code>device.mk</code> like so: 123 <pre class="devsite-click-to-copy"> 124 PRODUCT_COPY_FILES += \ 125 ... 126 device/moto/shamu/media_codecs.xml:system/etc/media_codecs.xml \ 127 + device/moto/shamu/media_codecs_performance.xml:system/etc/media_codecs_performance.xml 128 </pre> 129 <li>Re-run the performance tests to verify their success. 130 </ol> 131 132 <h2 id=3_co-exist_of_secure_codec_and_non-secure_codec>3. Co-exist of secure codec and non-secure codec</h2> 133 134 <ul> 135 <li>supports-secure-with-non-secure-codec — 136 If the instance of secure codec and the instance of non-secure codec cant 137 co-exist at the same time, that should be indicated as global setting in the 138 <code>media_codecs.xml</code> file. 139 <pre class="devsite-click-to-copy"> 140 <MediaCodecs> 141 <Settings> 142 <Setting name="supports-secure-with-non-secure-codec" value="false" /> 143 </Settings> 144 <Encoders> 145 146 </pre> 147 <li>supports-multiple-secure-codecs — 148 If co-exist of multiple secure codec instances is not supported, that should be 149 indicated as a global setting in the <code>media_codecs.xml</code> file. 150 <pre class="devsite-click-to-copy"> 151 <MediaCodecs> 152 <Settings> 153 <Setting name="supports-multiple-secure-codecs" value="false" /> 154 </Settings> 155 <Encoders> 156 157 </pre> 158 <li>Note that the both settings are true by default, meaning if they are supported, 159 theres no need to add the setting line to the <code>media_codecs.xml</code>. 160 <li>The <code>ResourceManagerTest</code> CTS tests may fail if these two settings were not set 161 properly. 162 </ul> 163 164 </body> 165 </html> 166