Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a stagefright plugin

I have a task which involves integration of a video decoder into Stagefright(Android's multimedia framework). I searched and found the following about creating a new plugin for Stagefright:

To add support for a new format, you need to:

  • Develop a new Extractor class, if the container is not supported yet.

  • Develop a new Decoder class, that implements the interface needed by the StageFright core to read the data.

  • Associate the mime-type of the files to read to your new Decoder in the OMXCodec.cpp file, in the kDecoderInfo array.

    static const CodecInfo kDecoderInfo[] = {  
        {MEDIA_MIMETYPE_AUDIO_AAC, "OMX.TI.AAC.decode"},
        {MEDIA_MIMETYPE_AUDIO_AAC, "AACDecoder"},
    };

The above data is all i could find out on net. Right now i have a simple app that will take a file as an input and render it on the screen using native API's in android. Can anyone please tell me how to proceed further. And from where does all these OMXCodec.cpp and others come into picture and which directory of my project should i have them in. Please provide solutions regarding the same. Thanks in advance.

like image 424
Zax Avatar asked Dec 27 '22 07:12

Zax


1 Answers

From your question, it appears that you are looking at a recommendation which is specific for Ice-Cream Sandwich or earlier versions of Android. The first thing you should be clear about is the version of the android i.e. Ice-Cream Sandwich or before or JellyBean and after. The integration of codecs is different across different releases of Android.

I have already commented on your other question which is specific for JellyBean and later (Reference: Android: How to integrate a decoder to multimedia framework)

If you would like to integrate your codec in Ice-Cream Sandwich or before, the steps are already available in your question. In addition to adding the decoder into kDecoderInfo list, you may like to setup certain quirks as shown here.

For the question on OMXCodec.cpp, you can find this file at frameworks/base/media/libstagefright/ in case of Ice-Cream Sandwich and frameworks/av/media/libstagefright/ in case of JellyBean.

If you have followed all the steps to integrate the video decoder into the Stagefright framework, then the easiest test would be to perform the following:

  1. Copy a media file into SD-Card

  2. In OMXCodec.cpp, enable logs by removing the comment in this statement //#define LOG_NDEBUG 0 and run a mm in the directory. Copy the rebuilt libstagefright.so to /system/lib on your device.

  3. Enable logcat and start capturing logs.

  4. Goto gallery, select your file and allow the standard player to play your file.

  5. Check your log file if the player has selected your OMX component by searching for your component name. If found, your integration of codec into Stagefright is successful. Else, you will have to debug and find out what is the problem.

Postscript:

  1. Based on your queries, I presume you aren't familiar with Android sources. Please refer to androidxref site to become familiar with AOSP distributions.

  2. Unless you are planning to support a new media file-format, you will not require to support Extractor class. MediaExtractor abstracts a file-format parser and helps to de-multiplex the different tracks in a media file.

I hope with this information, you should be able to get your codec integrated and functional in Android.

like image 177
Ganesh Avatar answered Dec 28 '22 20:12

Ganesh