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.
Media applications interact with the Android native multimedia framework according to the following architecture.
Figure 1. Media architecture
frameworks/av/media/libmedia
directory and
begin with the letter "I".frameworks/av/media
.libstagefrighthw.so
. This plugin links Stagefright with your custom
codec components, which 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 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, see hardware/ti/omap4xx/libstagefrighthw
.
To add your own codecs:
frameworks/native/include/media/OpenMAX/OMX_Component.h
file. To
learn more about the OpenMAX IL specification, refer to the
OpenMAX website.frameworks/native/include/media/hardware/OMXPluginBase.h
and
HardwareAPI.h
header files.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 \ ...
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 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
and device/samsung/tuna/media_profiles.xml
.
Note: As of Android 4.1, the
<Quirk>
element for media codecs is no longer supported.