Home | History | Annotate | Download | only in media
      1 <html devsite>
      2   <head>
      3     <title>Media</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 <img style="float: right; margin: 0px 15px 15px 15px;"
     27 src="images/ape_fwk_hal_media.png" alt="Android Media HAL icon"/>
     28 
     29 <p>Android includes Stagefright, a media playback engine at the native level
     30 that has built-in software-based codecs for popular media formats.</p>
     31 
     32 <p>Stagefright audio and video playback features include integration with
     33 OpenMAX codecs, session management, time-synchronized rendering, transport
     34 control, and DRM.</p>
     35 
     36 <p>Stagefright also supports integration with custom hardware codecs provided by
     37 you. To set a hardware path to encode and decode media, you must implement a
     38 hardware-based codec as an OpenMax IL (Integration Layer) component.</p>
     39 
     40 <p class="note"><strong>Note:</strong> Stagefright updates can occur through the
     41 Android <a href="/security/bulletin/index.html">monthly security
     42 update</a> process and as part of an Android OS release.</p>
     43 
     44 <h2 id="architecture">Architecture</h2>
     45 <p>Media applications interact with the Android native multimedia framework
     46 according to the following architecture.</p>
     47 <img src="/devices/media/images/ape_fwk_media.png" alt="Android media architecture"
     48 id="figure1" /><p class="img-caption"><strong>Figure 1.</strong> Media
     49 architecture</p>
     50 
     51 <dl>
     52 <dt>Application Framework</dt>
     53 <dd>At the application framework level is application code that utilizes
     54 <a href="http://developer.android.com/reference/android/media/package-summary.html">android.media</a>
     55 APIs to interact with the multimedia hardware.</dd>
     56 
     57 <dt>Binder IPC</dt>
     58 <dd>The Binder IPC proxies facilitate communication over process boundaries.
     59 They are located in the <code>frameworks/av/media/libmedia</code> directory and
     60 begin with the letter "I".</dd>
     61 
     62 <dt>Native Multimedia Framework</dt>
     63 <dd>At the native level, Android provides a multimedia framework that utilizes
     64 the Stagefright engine for audio and video recording and playback. Stagefright
     65 comes with a default list of supported software codecs and you can implement
     66 your own hardware codec by using the OpenMax integration layer standard. For
     67 more implementation details, see the MediaPlayer and Stagefright components
     68 located in <code>frameworks/av/media</code>.</dd>
     69 
     70 <dt>OpenMAX Integration Layer (IL)</dt>
     71 <dd>The OpenMAX IL provides a standardized way for Stagefright to recognize and
     72 use custom hardware-based multimedia codecs called components. You must provide
     73 an OpenMAX plugin in the form of a shared library named
     74 <code>libstagefrighthw.so</code>. This plugin links Stagefright with your custom
     75 codec components, which must be implemented according to the OpenMAX IL
     76 component standard.</dd>
     77 </dl>
     78 
     79 <h2 id="codecs">Implementing custom codecs</h2>
     80 <p>Stagefright comes with built-in software codecs for common media formats, but
     81 you can also add your own custom hardware codecs as OpenMAX components. To do
     82 this, you must create the OMX components and an OMX plugin that hooks together
     83 your custom codecs with the Stagefright framework. For example components, see
     84 the <code>hardware/ti/omap4xxx/domx/</code>; for an example plugin for the
     85 Galaxy Nexus, see <code>hardware/ti/omap4xx/libstagefrighthw</code>.</p>
     86 
     87 <p>To add your own codecs:</p>
     88 <ol>
     89 <li>Create your components according to the OpenMAX IL component standard. The
     90 component interface is located in the
     91 <code>frameworks/native/include/media/OpenMAX/OMX_Component.h</code> file. To
     92 learn more about the OpenMAX IL specification, refer to the
     93 <a href="http://www.khronos.org/openmax/">OpenMAX website</a>.</li>
     94 <li>Create a OpenMAX plugin that links your components with the Stagefright
     95 service. For the interfaces to create the plugin, see
     96 <code>frameworks/native/include/media/hardware/OMXPluginBase.h</code> and
     97 <code>HardwareAPI.h</code> header files.</li>
     98 <li>Build your plugin as a shared library with the name
     99 <code>libstagefrighthw.so</code> in your product Makefile. For example:
    100 <br>
    101 <pre class="devsite-click-to-copy">
    102 LOCAL_MODULE := libstagefrighthw
    103 </pre>
    104 <p>In your device's Makefile, ensure you declare the module as a product
    105 package:</p>
    106 <pre class="devsite-click-to-copy">
    107 PRODUCT_PACKAGES += \
    108   libstagefrighthw \
    109   ...
    110 </pre>
    111 </li>
    112 </ol>
    113 
    114 <h2 id="expose">Exposing codecs to the framework</h2>
    115 <p>The Stagefright service parses the <code>system/etc/media_codecs.xml</code>
    116 and <code>system/etc/media_profiles.xml</code> to expose the supported codecs
    117 and profiles on the device to app developers via the
    118 <code>android.media.MediaCodecList</code> and
    119 <code>android.media.CamcorderProfile</code> classes. You must create both files
    120 in the <code>device/&lt;company&gt;/&lt;device&gt;/</code> directory
    121 and copy this over to the system image's <code>system/etc</code> directory in
    122 your device's Makefile. For example:</p>
    123 <pre class="devsite-click-to-copy">
    124 PRODUCT_COPY_FILES += \
    125   device/samsung/tuna/media_profiles.xml:system/etc/media_profiles.xml \
    126   device/samsung/tuna/media_codecs.xml:system/etc/media_codecs.xml \
    127 </pre>
    128 
    129 <p>For complete examples, seee <code>device/samsung/tuna/media_codecs.xml</code>
    130 and <code>device/samsung/tuna/media_profiles.xml</code> .</p>
    131 
    132 <p class="note"><strong>Note:</strong> As of Android 4.1, the
    133 <code>&lt;Quirk&gt;</code> element for media codecs is no longer supported.</p>
    134 
    135   </body>
    136 </html>
    137