Home | History | Annotate | Download | only in media
      1 page.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)
     28 properly 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
     33 returns the maximum number of supported concurrent codec instances.</p>
     34 
     35 <p>The CTS test 
     36 <code>testGetMaxSupportedInstances(android.media.cts.MediaCodecCapabilitiesTest)</code>
     37 is 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 &lt;MediaCodecs&gt;
     45     ...
     46     &lt;Encoders&gt;
     47         &lt;MediaCodec name="OMX.<em>&lt;vendor&gt;</em>.video.encoder.avc" type="video/avc" &gt;
     48            ...
     49             &lt;Limit name="concurrent-instances" max="13" /&gt;
     50         &lt;/MediaCodec&gt;
     51         ...
     52     &lt;/Encoders&gt;
     53     ...
     54 &lt;/MediaCodecs&gt;
     55 </pre>
     56 
     57 <p>OEMs can use this test to generate the concurrent limits that pass the test.
     58 To 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>
     65 There was 1 failure:
     66 1) testGetMaxSupportedInstances(android.media.cts.MediaCodecCapabilitiesTest)
     67 junit.framework.AssertionFailedError: In order to pass the test, please publish
     68 following codecs' concurrent instances limit in /etc/media_codecs.xml:
     69 &lt;MediaCodec name="OMX.<em>&lt;vendor&gt;</em>.video.encoder.mpeg4" type="video/mp4v-es" &gt;
     70     &lt;Limit name="concurrent-instances" max="13" /&gt;
     71 &lt;/MediaCodec&gt;
     72 &lt;MediaCodec name="OMX.<em>&lt;vendor&gt;</em>.video.encoder.h263" type="video/3gpp" &gt;
     73     &lt;Limit name="concurrent-instances" max="13" /&gt;
     74 &lt;/MediaCodec&gt;
     75 &lt;MediaCodec name="OMX.<em>&lt;vendor&gt;</em>.video.encoder.avc" type="video/avc" &gt;
     76     &lt;Limit name="concurrent-instances" max="13" /&gt;
     77 &lt;/MediaCodec>
     78 &lt;MediaCodec name="OMX.<em>&lt;vendor&gt;</em>.video.encoder.vp8" type="video/x-vnd.on2.vp8" &gt;
     79     &lt;Limit name="concurrent-instances" max="13" /&gt;
     80 &lt;/MediaCodec&gt;
     81 &lt;MediaCodec name="OMX.<em>&lt;vendor&gt;</em>.video.decoder.avc" type="video/avc" &gt;
     82     &lt;Limit name="concurrent-instances" max="13" /&gt;
     83 &lt;/MediaCodec&gt;
     84 &lt;MediaCodec name="OMX.<em>&lt;vendor&gt;</em>.video.decoder.avc.secure" type="video/avc" &gt;
     85     &lt;Limit name="concurrent-instances" max="4" /&gt;
     86 &lt;/MediaCodec&gt;
     87 &lt;MediaCodec name="OMX.<em>&lt;vendor&gt;</em>.video.decoder.mpeg4" type="video/mp4v-es" &gt;
     88     &lt;Limit name="concurrent-instances" max="12" /&gt;
     89 &lt;/MediaCodec&gt;
     90 &lt;MediaCodec name="OMX.<em>&lt;vendor&gt;</em>.video.decoder.h263" type="video/3gpp" &gt;
     91     &lt;Limit name="concurrent-instances" max="12" /&gt;
     92 &lt;/MediaCodec&gt;
     93 &lt;MediaCodec name="OMX.<em>&lt;vendor&gt;</em>.video.decoder.vp8" type="video/x-vnd.on2.vp8" &gt;
     94     &lt;Limit name="concurrent-instances" max="12" /&gt;
     95 &lt;/MediaCodec&gt;
     96 </pre>
     97 
     98     <li>Add the <code>concurrent-instances</code> lines suggested in the test
     99 failure 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
    106 returns the range of achievable video frame rates for a video size. This
    107 information 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
    109 the <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
    115 variability of Android performance, it is recommended the tests are run
    116 multiple times to get more accurate minimum and maximum values.
    117     <li>Use the provided <a
    118 href="https://android.googlesource.com/platform/cts/+/marshmallow-cts-dev/tools/cts-media/get_achievable_rates.py">get_achievable_rates.py</a>
    119 script to generate the XML file.
    120     <li>Place the XML file at: <code>/etc/media_codecs_performance.xml</code><br>
    121 This is usually done by placing the XML file in the device project
    122 (device/<em>&lt;vendor&gt;</em>/<em>&lt;product&gt;</em>) and adding a
    123 <code>PRODUCT_COPY_FILES</code> line to <code>device.mk</code> like so:
    124 <pre>
    125 PRODUCT_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 &mdash;
    137 If the instance of secure codec and the instance of non-secure codec cant
    138 co-exist at the same time, that should be indicated as global setting in the
    139 <code>media_codecs.xml</code> file.
    140 <pre>
    141 &lt;MediaCodecs&gt;
    142     &lt;Settings&gt;
    143         &lt;Setting name="supports-secure-with-non-secure-codec" value="false" /&gt;
    144     &lt;/Settings&gt;
    145     &lt;Encoders&gt;
    146 
    147 </pre>
    148   <li>supports-multiple-secure-codecs &mdash;
    149 If co-exist of multiple secure codec instances is not supported, that should be
    150 indicated as a global setting in the <code>media_codecs.xml</code> file.
    151 <pre>
    152 &lt;MediaCodecs&gt;
    153     &lt;Settings&gt;
    154         &lt;Setting name="supports-multiple-secure-codecs" value="false" /&gt;
    155     &lt;/Settings&gt;
    156     &lt;Encoders&gt;
    157 
    158 </pre>
    159   <li>Note that the both settings are true by default, meaning if they are supported,
    160 theres 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
    162 properly.
    163 </ul>
    164