Mobile native Wearable native

Media Codec

Media codec provides interfaces for encoding and decoding audio and video data.

To use codecs:

  1. Create a handle for the codec instance with the mediacodec_create() function. After a successful handle creation, your system can use the codec.

  2. Set the codec configuration with the mediacodec_set_codec(), and mediacodec_set_vdec_info() or mediacodec_set_venc_info() functions.

    You can also prepare for the available ready state with the mediacodec_prepare() function.

  3. Decode and encode with the mediacodec_process_input() and mediacodec_get_output() functions.

A single MediaCodec instance handles 1 specific type of data (such as aac audio or H.264 video), and can encode or decode. The codec operates on "raw" data, so strip off any file headers (such as ID3 tags).

The following figures illustrate the general media state changes.

Figure: Media state changes

Media state changes

Go to top