Media modules

Android 10 or higher includes several updatable media components that enable updating framework components through Google Play Store infrastructure or through a partner-provided over-the-air (OTA) mechanism. Media components are packaged together in modules that allows providing security updates and feature updates without requiring a full system image update.

Updatable media components exist in the following modules.

For details on adding custom extractors and decoders, see Customizing Media Components.

Media extractors

In Android 9 and lower, extracters are compiled into a single libstagefright.so file. In Android 10 or higher, media extractors are separate components. Each extractor has its own .so file with an entry point that provides a sniffer function to determine whether the extractor can handle the given media file, and a factory function that creates an instance of the extractor for the given media file. Each extractor is named (to help in debugging) and versioned to indicate which extractor is the newest.

The media framework automatically loads all available extractor .so files, so you can create your own extractors by adding a new .so file without needing to modify libstagefright or other media framework libraries. You can also ensure that a custom extractor is preferred over the Google-provided extractor.

MediaSession2 API

The MediaSession2 API allows media apps to expose their transport controls and playback information to other processes such as the Android framework and other apps. This component can't be customized.

MediaParser API

The MediaParser API allows ExoPlayer to make efficient use of framework media container parsers to extract media samples from media containers. MediaParser includes the following changes to source code boundaries:

  • frameworks/base/apex/media/framework/java/android/media/MediaParser.java. API and thin layer implementation.

  • external/exoplayer/. Exoplayer verbatim sources on which MediaParser is built.

The MediaParser API can’t be customized. To test MediaParser, use the tests in cts/tests/tests/mediaparser/.

Media codecs

The Media Codecs module includes updatable software Codec2 components. Support for customization differs between releases:

  • In Android 11 or higher (specifically Google Play System Update v292100200), you can customize the parameters for ION memory allocation (see below for details).

  • In Android 9 or lower, the OMX codec API isn't updatable, but you can still use it in the vendor partition.

ION memory allocation

In Android 11 or higher and Google Play System Update v292100200 or higher, you can customize the following parameters for ION memory allocation.

Parameter Default value Description
heapMask 0xFFFFFFFF All heap types allowed.
allocFlags 0 No flags set.
minAlignment 0 No alignment.

To override the parameters:

  1. Register a default android.hardware.media.c2 service and provide custom ION usage parameters.

  2. Add the following code to the device manifest.xml.

    <hal format="hidl">
        <name>android.hardware.media.c2</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IComponentStore</name>
            <instance>default</instance>
        </interface>
    </hal>
    

Format and dependences

The Media module (com.android.media) and Media Codec module (com.android.media.swcodec) are in APEX format. Included media components rely only on NDK APIs.

Updates

During an update, the framework components on the device load an APEX package that contains Java and native code.

Media Updates

Figure 1. The media component update flow

After the framework installs the APEX package, the device reboots and mounts the disk image and media system processes (media.extractor and media.codec) load the updated modules from the mount point.