【Android多媒体】多媒体架构-Android官网
2016-04-26 10:28
411 查看
http://blog.csdn.net/mandagod/article/details/47190911
Android provides a media playback engine at the native level called Stagefright
that comes built-in with software-based codecs for several popular media formats. Stagefright features for audio and video playback include integration with OpenMAX codecs, session management, time-synchronized rendering, transport control, and DRM.
In addition, Stagefright supports integration with custom hardware codecs that you provide. There actually isn’t a HAL to implement for custom codecs, but to provide a hardware path to encode and decode media, you must implement your hardware-based codec as
an OpenMax IL (Integration Layer) component.
The following diagram shows how media applications interact with the Android native multimedia framework.
Figure 1. Media architecture
Application Framework
At the application framework level is the app’s code, which utilizes the android.media APIs to interact with the multimedia hardware.
Binder IPC
The Binder IPC proxies facilitate communication over process boundaries. They are located in the frameworks/av/media/libmedia directory and begin with the letter “I”.
Native Multimedia Framework
At the native level, Android provides a multimedia framework that utilizes the Stagefright engine for audio and video recording and playback. Stagefright comes with a default list of supported software codecs and you can implement your own hardware codec by
using the OpenMax integration layer standard. For more implementation details, see the various MediaPlayer and Stagefright components located in frameworks/av/media.
OpenMAX Integration Layer (IL)
The OpenMAX IL provides a standardized way for Stagefright to recognize and use custom hardware-based multimedia codecs called components. You must provide an OpenMAX plugin in the form of a shared library named libstagefrighthw.so. This plugin links your custom
codec components to Stagefright. Your custom codecs must be implemented according to the OpenMAX IL component standard.
Stagefright comes with built-in software codecs for common media formats, but you can also add your own custom hardware codecs as OpenMAX components. To do this, you need to create OMX components and also an OMX plugin that hooks together your custom codecs
with the Stagefright framework. For an example, see the hardware/ti/omap4xxx/domx/ for example components and hardware/ti/omap4xx/libstagefrighthw for an example plugin for the Galaxy Nexus.
To add your own codecs:
Create your components according to the OpenMAX IL component standard. The component interface is located in the frameworks/native/include/media/OpenMAX/OMX_Component.h file. To learn more about the OpenMAX IL specification, see the
OpenMAX website.
Create a OpenMAX plugin that links your components with the Stagefright service. See the frameworks/native/include/media/hardware/OMXPluginBase.h and HardwareAPI.h header files for the interfaces to create the plugin.
Build your plugin as a shared library with the name libstagefrighthw.so in your product Makefile. For example:
In your device’s Makefile, ensure that you declare the module as a product package:
The Stagefright service parses the system/etc/media_codecs.xml and system/etc/media_profiles.xml to expose the supported codecs and profiles on the device to app developers via the android.media.MediaCodecList and android.media.CamcorderProfile classes. You
need to create both files in the device/// directory and copy this over to the system image’s system/etc directory in your device’s Makefile. For example:
See the device/samsung/tuna/media_codecs.xml and device/samsung/tuna/media_profiles.xml file for complete examples.
Note: The element for media codecs is no longer supported by Android starting in Jelly Bean.
Media
Android provides a media playback engine at the native level called Stagefrightthat comes built-in with software-based codecs for several popular media formats. Stagefright features for audio and video playback include integration with OpenMAX codecs, session management, time-synchronized rendering, transport control, and DRM.
In addition, Stagefright supports integration with custom hardware codecs that you provide. There actually isn’t a HAL to implement for custom codecs, but to provide a hardware path to encode and decode media, you must implement your hardware-based codec as
an OpenMax IL (Integration Layer) component.
Architecture
The following diagram shows how media applications interact with the Android native multimedia framework.Figure 1. Media architecture
Application Framework
At the application framework level is the app’s code, which utilizes the android.media APIs to interact with the multimedia hardware.
Binder IPC
The Binder IPC proxies facilitate communication over process boundaries. They are located in the frameworks/av/media/libmedia directory and begin with the letter “I”.
Native Multimedia Framework
At the native level, Android provides a multimedia framework that utilizes the Stagefright engine for audio and video recording and playback. Stagefright comes with a default list of supported software codecs and you can implement your own hardware codec by
using the OpenMax integration layer standard. For more implementation details, see the various MediaPlayer and Stagefright components located in frameworks/av/media.
OpenMAX Integration Layer (IL)
The OpenMAX IL provides a standardized way for Stagefright to recognize and use custom hardware-based multimedia codecs called components. You must provide an OpenMAX plugin in the form of a shared library named libstagefrighthw.so. This plugin links your custom
codec components to Stagefright. Your custom codecs must be implemented according to the OpenMAX IL component standard.
Implementing Custom Codecs
Stagefright comes with built-in software codecs for common media formats, but you can also add your own custom hardware codecs as OpenMAX components. To do this, you need to create OMX components and also an OMX plugin that hooks together your custom codecswith the Stagefright framework. For an example, see the hardware/ti/omap4xxx/domx/ for example components and hardware/ti/omap4xx/libstagefrighthw for an example plugin for the Galaxy Nexus.
To add your own codecs:
Create your components according to the OpenMAX IL component standard. The component interface is located in the frameworks/native/include/media/OpenMAX/OMX_Component.h file. To learn more about the OpenMAX IL specification, see the
OpenMAX website.
Create a OpenMAX plugin that links your components with the Stagefright service. See the frameworks/native/include/media/hardware/OMXPluginBase.h and HardwareAPI.h header files for the interfaces to create the plugin.
Build your plugin as a shared library with the name libstagefrighthw.so in your product Makefile. For example:
<code class="hljs fix has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span class="hljs-attribute" style="box-sizing: border-box;">LOCAL_MODULE :</span>=<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;"> libstagefrighthw</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>
In your device’s Makefile, ensure that you declare the module as a product package:
<code class="hljs r has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">PRODUCT_PACKAGES += \ libstagefrighthw \ <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">...</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul>
Exposing Codecs to the Framework
The Stagefright service parses the system/etc/media_codecs.xml and system/etc/media_profiles.xml to expose the supported codecs and profiles on the device to app developers via the android.media.MediaCodecList and android.media.CamcorderProfile classes. Youneed to create both files in the device/// directory and copy this over to the system image’s system/etc directory in your device’s Makefile. For example:
<code class="hljs avrasm has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">PRODUCT_COPY_FILES += \ device/samsung/tuna/media_profiles<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.xml</span>:system/etc/media_profiles<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.xml</span> \ device/samsung/tuna/media_codecs<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.xml</span>:system/etc/media_codecs<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.xml</span> \</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul>
See the device/samsung/tuna/media_codecs.xml and device/samsung/tuna/media_profiles.xml file for complete examples.
Note: The element for media codecs is no longer supported by Android starting in Jelly Bean.
相关文章推荐
- PHP学习网站(借鉴)
- 从零开始学习OpenCL开发(一)架构
- 4月第3周B2B网站覆盖数排名TOP15:阿里巴巴第一
- 微信Android客户端架构演进之路
- 机器学习等学习网站
- cobar实现mysql分片及分片集之内双节点之间的高可用
- 如何从零开始搭建一个技术平台
- Java处理 网站高并发问题 的优化方法
- (GeoTrust 企业(OV)型 增强版(EV) SSL证书
- 6个优秀的思维导图网站
- NASA等资料下载网站记录
- 架构畅想:如果以你所会去进行架构,会到哪一步?
- 夺命雷公狗ThinkPHP项目之----企业网站22之网站前台中间层(解决代码冗余)
- 世界顶级Web性能专家带你优化出高性能网站
- (4)学习ardupilot源码——引言和代码架构
- 50 个 jQuery 插件可将你的网站带到另外一个高度
- PHP网站性能优化
- 58沈剑:架构师的平凡之路
- java 抓取网站内容 异常code: 403
- 1号店11.11:从应用架构落地点谈高可用高并发高性能