android framework之Media

Android的Media框架包含了Stagefright,一个内置软件编解码器的原生播放引擎,支持OpenMAX并与硬件编解码器集成。文章详细介绍了Stagefright的架构、如何实现自定义硬件编解码器以及如何将它们暴露给框架。
摘要由CSDN通过智能技术生成

Media

Android includes Stagefright, a media playback engine at the native level that has built-in software-based codecs for popular media formats.

Stagefright audio and video playback features include integration with OpenMAX codecs, session management, time-synchronized rendering, transport control, and DRM.

Stagefright also supports integration with custom hardware codecs provided by you. To set a hardware path to encode and decode media, you must implement a hardware-based codec as an OpenMax IL (Integration Layer) component.

Note: Stagefright updates can occur through the Android monthly security update process and as part of an Android OS release.

 

Architecture


Media applications interact with the Android native multimedia framework according to the following architecture.



 Figure 1. Media architecture

Application Framework
At the application framework level is application code that utilizes  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 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 Stagefright with your custom codec components, which 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 must create the OMX components and an OMX plugin that hooks together your custom codecs with the Stagefright framework. For example components, see the hardware/ti/omap4xxx/domx/; for an example plugin for the Galaxy Nexus, seehardware/ti/omap4xx/libstagefrighthw.

To add your own codecs:

  1. 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, refer to the OpenMAX website.
  2. Create a OpenMAX plugin that links your components with the Stagefright service. For the interfaces to create the plugin, see frameworks/native/include/media/hardware/OMXPluginBase.h and HardwareAPI.h header files.
  3. Build your plugin as a shared library with the name libstagefrighthw.so in your product Makefile. For example:

     

    LOCAL_MODULE := libstagefrighthw

     

    In your device's Makefile, ensure you declare the module as a product package:

    PRODUCT_PACKAGES +=\
      libstagefrighthw \
      ...

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 andandroid.media.CamcorderProfile classes. You must create both files in the device/<company>/<device>/ directory and copy this over to the system image's system/etc directory in your device's Makefile. For example:

PRODUCT_COPY_FILES +=\
  device/samsung/tuna/media_profiles.xml:system/etc/media_profiles.xml \
  device/samsung/tuna/media_codecs.xml:system/etc/media_codecs.xml \

For complete examples, seee device/samsung/tuna/media_codecs.xml anddevice/samsung/tuna/media_profiles.xml .

Note: As of Android 4.1, the <Quirk> element for media codecs is no longer supported.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值