blob: de6901ae89ff84660125f39c93bc9b12a1ad7c30 [file] [log] [blame]
Robert Ly35f2fda2013-01-29 16:27:05 -08001page.title=Media
2@jd:body
3
4<!--
Clay Murphy1b77cc22014-12-17 18:20:06 -08005 Copyright 2014 The Android Open Source Project
Robert Ly35f2fda2013-01-29 16:27:05 -08006
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>
28 Android provides a media playback engine at the native level called Stagefright that comes built-in with
29 software-based codecs for several popular media formats. Stagefright features for audio and video playback
30 include integration with OpenMAX codecs, session management, time-synchronized rendering, transport control,
31 and DRM. In addition, Stagefright supports integration with custom hardware codecs that you provide.
32 There actually isn't a HAL to implement for custom codecs, but to provide a hardware path to encode and
33 decode media, you must implement your hardware-based codec as an OpenMax IL (Integration Layer) component.
34</p>
35<h2 id="overview">
36Overview
37</h2>
38<p>The following diagram shows how media applications interact with the Android native multimedia framework.</p>
Clay Murphy1b77cc22014-12-17 18:20:06 -080039 <img src="images/media.png" alt="Android media architecture" id="figure1" />
40<p class="img-caption">
41 <strong>Figure 1.</strong> Media architecture
Robert Ly35f2fda2013-01-29 16:27:05 -080042</p>
43<dl>
44<dt>Application Framework</dt>
45 <dd>At the application framework level is the app's code, which utilizes the
46 <a href="http://developer.android.com/reference/android/media/package-summary.html">android.media</a>
47 APIs to interact with the multimedia hardware.</dd>
48 <dt>Binder IPC</dt>
49 <dd>The Binder IPC proxies facilitate communication over process boundaries. They are located in
50 the <code>frameworks/av/media/libmedia</code> directory and begin with the letter "I".</dd>
51 <dt>Native Multimedia Framework</dt>
52 <dd>At the native level, Android provides a multimedia framework that utilizes the Stagefright engine for
53 audio and video recording and playback. Stagefright comes with a default list of supported software codecs
54 and you can implement your own hardware codec by using the OpenMax integration layer standard. For more
55 implementation details, see the various MediaPlayer and Stagefright components located in
56 <code>frameworks/av/media</code>.
57 </dd>
58 <dt>OpenMAX Integration Layer (IL)</dt>
59 <dd>The OpenMAX IL provides a standardized way for Stagefright to recognize and use custom hardware-based
60 multimedia codecs called components. You must provide an OpenMAX plugin in the form of a shared library
61 named <code>libstagefrighthw.so</code>. This plugin links your custom codec components to Stagefright.
62 Your custom codecs must be implemented according to the OpenMAX IL component standard.
63 </dd>
64</dl>
65
66
67<h2 id="codecs">
68Implementing Custom Codecs
69</h2>
70<p>Stagefright comes with built-in software codecs for common media formats, but you can also add your
71 own custom hardware codecs as OpenMAX components. To do this, you need to create OMX components and also an
72 OMX plugin that hooks together your custom codecs with the Stagefright framework. For an example, see
73 the <code>hardware/ti/omap4xxx/domx/</code> for example components and <code>hardware/ti/omap4xx/libstagefrighthw</code>
74 for an example plugin for the Galaxy Nexus.
75</p>
76 <p>To add your own codecs:</p>
77<ol>
78<li>Create your components according to the OpenMAX IL component standard. The component interface is located in the
79 <code>frameworks/native/include/media/OpenMAX/OMX_Component.h</code> file. To learn more about the
80 OpenMAX IL specification, see the <a href="http://www.khronos.org/openmax/">OpenMAX website</a>.</li>
81<li>Create a OpenMAX plugin that links your components with the Stagefright service.
82 See the <code>frameworks/native/include/media/hardware/OMXPluginBase.h</code> and <code>HardwareAPI.h</code> header
83 files for the interfaces to create the plugin.
84</li>
85<li>Build your plugin as a shared library with the name <code>libstagefrighthw.so</code> in your product Makefile. For example:
86<pre>LOCAL_MODULE := libstagefrighthw</pre>
87
88<p>In your device's Makefile, ensure that you declare the module as a product package:</p>
89<pre>
90PRODUCT_PACKAGES += \
91 libstagefrighthw \
92 ...
93</pre>
94</li>
95</ol>
96
97<h2 id="expose">Exposing Codecs to the Framework</h2>
98<p>The Stagefright service parses the <code>system/etc/media_codecs.xml</code> and <code>system/etc/media_profiles.xml</code>
99 to expose the supported codecs and profiles on the device to app developers via the <code>android.media.MediaCodecList</code> and
100 <code>android.media.CamcorderProfile</code> classes. You need to create both files in the
101 <code>device/&lt;company_name&gt;/&lt;device_name&gt;/</code> directory
102 and copy this over to the system image's <code>system/etc</code> directory in your device's Makefile.
103 For example:</p>
104
105 <pre>
106PRODUCT_COPY_FILES += \
107 device/samsung/tuna/media_profiles.xml:system/etc/media_profiles.xml \
108 device/samsung/tuna/media_codecs.xml:system/etc/media_codecs.xml \
109</pre>
110
111<p>See the <code>device/samsung/tuna/media_codecs.xml</code> and
112 <code>device/samsung/tuna/media_profiles.xml</code> file for complete examples.</p>
113
114<p class="note"><strong>Note:</strong> The <code>&lt;Quirk&gt;</code> element for media codecs is no longer supported
Clay Murphy768b82a2013-11-12 11:32:41 -0800115 by Android starting in Jelly Bean.</p>