How to use MediaCodec API to invoke my custom decoder

1.4k views Asked by At

I have a video decoder which is ported to android and is successfully working as a standalone application, however i want to integrate this code to android multimedia framework. So, this code i have added to android's media framework. That is i have added it to root/media/libstagefright/codecs/myDecoder.

I have written an Android.mk under myDecoder folder that i have added and placed the source code of my decoder and the compilation is successful and i'm able to run it in an emulator.

Now, I have read that the new MediaCodec API in android allows us to access and use the codecs available in android source.

My question is, now that i have integrated my decoder to android source code:

Is it possible for me to use my decoder to decode an input stream and render it on the device screen?

My decoder has a Function that should be invoked for decoding a stream. This function takes the path of the input stream as a parameter.

Should i modify something in my source code of the decoder to match the requirements of the MediaCodec API.

Any help regarding the same will be really helpful to me.

-Regards.

1

There are 1 answers

2
Ganesh On

MediaCodec internally employs ACodec abstraction which talks to an underlying OMX component. Hence, your codec should be registered an an OMX component in media_codecs.xml file of your platform.

To ensure that your custom codec is picked up always, you can ensure that your codec is registered as the very first component in the media_codecs.xml file for the specific type of codec you wish to employ.

Apart from this, as long as your codec supports standard OMX functionalities and Android specific extensions like Native Buffer usage etc, it should work fine.

Note: I presume your application takes of providing the input and consuming the output from the MediaCodec.