Implement a custom codec

By | March 25, 2015

Review(Stagefright)

png text

CustomExtractor

png text

  • MIMEとは(av/media/libstagefright/MediaDefs.cpp)

const char *MEDIA_MIMETYPE_AUDIO_FLAC = "audio/flac";  
const char *MEDIA_MIMETYPE_VIDEO_H263 = "video/3gpp";  
const char *MEDIA_MIMETYPE_VIDEO_MYMIME = "video/IamSuperMan"; // You know,It's just a sample


* snfiffでMIMEを取得(CustomExtractorで実装、DataSourceへ登録)
(参考:stagefright(3)-extractor)

CustomPlugin

png text
* media_codecs.xml

<MediaCodec name="OMX.google.flac.encoder" type="audio/flac" />

  • kComponents

const struct {
    const char *mName;    const char *mLibNameSuffix;    const char *mRole;
} kComponents[] = {
    { "OMX.google.mp3.decoder", "mp3dec", "audio_decoder.mp3" },
    { "OMX.google.flac.encoder", "flacenc", "audio_encoder.flac" },
    { "OMX.noah.wma.decoder", "gsmdec", "audio_decoder.wma" },// if add .wma
};

  • IsSoftwareCodec

static bool IsSoftwareCodec(const char *componentName) {
    if (!strncmp("OMX.google.", componentName, 11)) {
        return true;
    }

    if (!strncmp("OMX.", componentName, 4)) {  // be sure start with "OMX"
        return false;
    }

    return true;
}

Reference

Leave a Reply

Your email address will not be published. Required fields are marked *