Home | History | Annotate | Download | only in media
      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 &lt;MediaCodecs&gt;
     44     ...
     45     &lt;Encoders&gt;
     46         &lt;MediaCodec name="OMX.<em>&lt;vendor&gt;</em>.video.encoder.avc" type="video/avc" &gt;
     47            ...
     48             &lt;Limit name="concurrent-instances" max="13" /&gt;
     49         &lt;/MediaCodec&gt;
     50         ...
     51     &lt;/Encoders&gt;
     52     ...
     53 &lt;/MediaCodecs&gt;
     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 &lt;MediaCodec name="OMX.<em>&lt;vendor&gt;</em>.video.encoder.mpeg4" type="video/mp4v-es" &gt;
     69     &lt;Limit name="concurrent-instances" max="13" /&gt;
     70 &lt;/MediaCodec&gt;
     71 &lt;MediaCodec name="OMX.<em>&lt;vendor&gt;</em>.video.encoder.h263" type="video/3gpp" &gt;
     72     &lt;Limit name="concurrent-instances" max="13" /&gt;
     73 &lt;/MediaCodec&gt;
     74 &lt;MediaCodec name="OMX.<em>&lt;vendor&gt;</em>.video.encoder.avc" type="video/avc" &gt;
     75     &lt;Limit name="concurrent-instances" max="13" /&gt;
     76 &lt;/MediaCodec>
     77 &lt;MediaCodec name="OMX.<em>&lt;vendor&gt;</em>.video.encoder.vp8" type="video/x-vnd.on2.vp8" &gt;
     78     &lt;Limit name="concurrent-instances" max="13" /&gt;
     79 &lt;/MediaCodec&gt;
     80 &lt;MediaCodec name="OMX.<em>&lt;vendor&gt;</em>.video.decoder.avc" type="video/avc" &gt;
     81     &lt;Limit name="concurrent-instances" max="13" /&gt;
     82 &lt;/MediaCodec&gt;
     83 &lt;MediaCodec name="OMX.<em>&lt;vendor&gt;</em>.video.decoder.avc.secure" type="video/avc" &gt;
     84     &lt;Limit name="concurrent-instances" max="4" /&gt;
     85 &lt;/MediaCodec&gt;
     86 &lt;MediaCodec name="OMX.<em>&lt;vendor&gt;</em>.video.decoder.mpeg4" type="video/mp4v-es" &gt;
     87     &lt;Limit name="concurrent-instances" max="12" /&gt;
     88 &lt;/MediaCodec&gt;
     89 &lt;MediaCodec name="OMX.<em>&lt;vendor&gt;</em>.video.decoder.h263" type="video/3gpp" &gt;
     90     &lt;Limit name="concurrent-instances" max="12" /&gt;
     91 &lt;/MediaCodec&gt;
     92 &lt;MediaCodec name="OMX.<em>&lt;vendor&gt;</em>.video.decoder.vp8" type="video/x-vnd.on2.vp8" &gt;
     93     &lt;Limit name="concurrent-instances" max="12" /&gt;
     94 &lt;/MediaCodec&gt;
     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>&lt;vendor&gt;</em>/<em>&lt;product&gt;</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 &mdash;
    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 &lt;MediaCodecs&gt;
    141     &lt;Settings&gt;
    142         &lt;Setting name="supports-secure-with-non-secure-codec" value="false" /&gt;
    143     &lt;/Settings&gt;
    144     &lt;Encoders&gt;
    145 
    146 </pre>
    147   <li>supports-multiple-secure-codecs &mdash;
    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 &lt;MediaCodecs&gt;
    152     &lt;Settings&gt;
    153         &lt;Setting name="supports-multiple-secure-codecs" value="false" /&gt;
    154     &lt;/Settings&gt;
    155     &lt;Encoders&gt;
    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