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