Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fc477e03 authored by Steve Kondik's avatar Steve Kondik
Browse files

stagefright: Fix metadata/message conversion issues

 * Remove duplication of code between ExtendedCodec and FFMPEGSoftCodec,
   just call into ExtendedCodec and properly ifdef QCOM-only parts.
 * Fix CSD not being converted when AV_ENHANCEMENTS wasn't set- this
   was breaking the software video codecs on Hammerhead.

Change-Id: I9cd4316ce19b15baabf12b78b992498ce48e2697
parent 396b737e
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -160,9 +160,10 @@ struct ExtendedCodec {


    static bool isSourcePauseRequired(const char *componentName);
    static bool isSourcePauseRequired(const char *componentName);


private:
    static const char* getMsgKey(int key );
    static const char* getMsgKey(int key );


private:

    static status_t setWMAFormat(
    static status_t setWMAFormat(
            const sp<MetaData> &meta, sp<IOMX> OMXhandle,
            const sp<MetaData> &meta, sp<IOMX> OMXhandle,
            IOMX::node_id nodeID, bool isEncoder );
            IOMX::node_id nodeID, bool isEncoder );
+2 −2
Original line number Original line Diff line number Diff line
@@ -38,8 +38,8 @@ struct FFMPEGSoftCodec {
        kPortIndexInput  = 0,
        kPortIndexInput  = 0,
        kPortIndexOutput = 1
        kPortIndexOutput = 1
    };
    };
    static status_t convertMetaDataToMessage(
    static void convertMessageToMetaData(
            const sp<MetaData> &meta, sp<AMessage> *format);
            const sp<AMessage> &msg, sp<MetaData> &meta);


    static const char* overrideComponentName(
    static const char* overrideComponentName(
            uint32_t quirks, const sp<MetaData> &meta,
            uint32_t quirks, const sp<MetaData> &meta,
+4 −0
Original line number Original line Diff line number Diff line
@@ -1497,10 +1497,12 @@ status_t ACodec::configureCodec(
            err = setupVideoEncoder(mime, msg);
            err = setupVideoEncoder(mime, msg);
        } else {
        } else {
            err = setupVideoDecoder(mime, msg);
            err = setupVideoDecoder(mime, msg);
#ifdef ENABLE_AV_ENHANCEMENTS
            if (err == OK) {
            if (err == OK) {
                const char* componentName = mComponentName.c_str();
                const char* componentName = mComponentName.c_str();
                ExtendedCodec::configureVideoDecoder(msg, mime, mOMX, 0, mNode, componentName);
                ExtendedCodec::configureVideoDecoder(msg, mime, mOMX, 0, mNode, componentName);
            }
            }
#endif
        }
        }
    } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG)) {
    } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG)) {
        int32_t numChannels, sampleRate;
        int32_t numChannels, sampleRate;
@@ -3704,6 +3706,7 @@ status_t ACodec::getPortFormat(OMX_U32 portIndex, sp<AMessage> &notify) {
                    if (err == OK) {
                    if (err == OK) {
                        int channelCount = 0;
                        int channelCount = 0;
                        int sampleRate = 0;
                        int sampleRate = 0;
#ifdef ENABLE_AV_ENHANCEMENTS
                        err = ExtendedCodec::getSupportedAudioFormatInfo(
                        err = ExtendedCodec::getSupportedAudioFormatInfo(
                                      &mimeType,
                                      &mimeType,
                                      mOMX,
                                      mOMX,
@@ -3711,6 +3714,7 @@ status_t ACodec::getPortFormat(OMX_U32 portIndex, sp<AMessage> &notify) {
                                      portIndex,
                                      portIndex,
                                      &channelCount,
                                      &channelCount,
                                      &sampleRate);
                                      &sampleRate);
#endif
                        notify->setString("mime", mimeType.c_str());
                        notify->setString("mime", mimeType.c_str());
                        notify->setInt32("channel-count", channelCount);
                        notify->setInt32("channel-count", channelCount);
                        notify->setInt32("sample-rate", sampleRate);
                        notify->setInt32("sample-rate", sampleRate);
+15 −20
Original line number Original line Diff line number Diff line
@@ -47,7 +47,6 @@
#define ARG_TOUCH(x) (void)x
#define ARG_TOUCH(x) (void)x


#ifdef ENABLE_AV_ENHANCEMENTS
#ifdef ENABLE_AV_ENHANCEMENTS

#include <QCMetaData.h>
#include <QCMetaData.h>
#include <QCMediaDefs.h>
#include <QCMediaDefs.h>
#include <OMX_QCOMExtns.h>
#include <OMX_QCOMExtns.h>
@@ -57,6 +56,7 @@
#include <QOMX_AudioExtensions.h>
#include <QOMX_AudioExtensions.h>
#include <QOMX_AudioIndexExtensions.h>
#include <QOMX_AudioIndexExtensions.h>
#include "include/ExtendedUtils.h"
#include "include/ExtendedUtils.h"
#endif


namespace android {
namespace android {
enum MetaKeyType{
enum MetaKeyType{
@@ -70,28 +70,22 @@ struct MetaKeyEntry{
};
};


static const MetaKeyEntry MetaKeyTable[] {
static const MetaKeyEntry MetaKeyTable[] {
   {kKeyBitRate              , "bitrate"                , INT32},
#if ENABLE_AV_ENHANCEMENTS
   {kKeyAacCodecSpecificData , "aac-codec-specific-data", CSD},
   {kKeyAacCodecSpecificData , "aac-codec-specific-data", CSD},
   {kKeyRawCodecSpecificData , "raw-codec-specific-data", CSD},
   {kKeyDivXVersion          , "divx-version"           , INT32},  // int32_t
   {kKeyDivXVersion          , "divx-version"           , INT32},  // int32_t
   {kKeyDivXDrm              , "divx-drm"               , DATA},  // void *
   {kKeyDivXDrm              , "divx-drm"               , DATA},  // void *
   {kKeyWMAEncodeOpt         , "wma-encode-opt"         , INT32},  // int32_t
   {kKeyWMAEncodeOpt         , "wma-encode-opt"         , INT32},  // int32_t
   {kKeyWMABlockAlign        , "wma-block-align"        , INT32},  // int32_t
   {kKeyWMABlockAlign        , "wma-block-align"        , INT32},  // int32_t
   {kKeyWMAVersion           , "wma-version"            , INT32},  // int32_t
   {kKeyWMAAdvEncOpt1        , "wma-adv-enc-opt1"       , INT32},  // int16_t
   {kKeyWMAAdvEncOpt1        , "wma-adv-enc-opt1"       , INT32},  // int16_t
   {kKeyWMAAdvEncOpt2        , "wma-adv-enc-opt2"       , INT32},  // int32_t
   {kKeyWMAAdvEncOpt2        , "wma-adv-enc-opt2"       , INT32},  // int32_t
   {kKeyWMAFormatTag         , "wma-format-tag"         , INT32},  // int32_t
   {kKeyWMAFormatTag         , "wma-format-tag"         , INT32},  // int32_t
   {kKeyWMABitspersample     , "wma-bits-per-sample"    , INT32},  // int32_t
   {kKeyWMABitspersample     , "wma-bits-per-sample"    , INT32},  // int32_t
   {kKeyWMAVirPktSize        , "wma-vir-pkt-size"       , INT32},  // int32_t
   {kKeyWMAVirPktSize        , "wma-vir-pkt-size"       , INT32},  // int32_t
   {kKeyWMAChannelMask       , "wma-channel-mask"       , INT32},  // int32_t
   {kKeyWMAChannelMask       , "wma-channel-mask"       , INT32},  // int32_t
   {kKeyWMVVersion           , "wmv-version"            , INT32},
   {kKeyFileFormat           , "file-format"            , STRING},  // cstring
   {kKeyFileFormat           , "file-format"            , STRING},  // cstring
   {kKeyBlockAlign           , "block-align"            , INT32},
   {kKeyRVVersion            , "rv-version"             , INT32},


   {kkeyAacFormatAdif        , "aac-format-adif"        , INT32},  // bool (int32_t)
   {kkeyAacFormatAdif        , "aac-format-adif"        , INT32},  // bool (int32_t)
   {kkeyAacFormatLtp         , "aac-format-ltp"         , INT32},
   {kkeyAacFormatLtp         , "aac-format-ltp"         , INT32},
   {kKeyAACAOT               , "aac-profile"            , INT32},


   //DTS subtype
   //DTS subtype
   {kKeyDTSSubtype           , "dts-subtype"            , INT32},  //int32_t
   {kKeyDTSSubtype           , "dts-subtype"            , INT32},  //int32_t
@@ -100,13 +94,22 @@ static const MetaKeyEntry MetaKeyTable[] {
   {kKeyUseArbitraryMode     , "use-arbitrary-mode"     , INT32},  //bool (int32_t)
   {kKeyUseArbitraryMode     , "use-arbitrary-mode"     , INT32},  //bool (int32_t)
   {kKeySmoothStreaming      , "smooth-streaming"       , INT32},  //bool (int32_t)
   {kKeySmoothStreaming      , "smooth-streaming"       , INT32},  //bool (int32_t)
   {kKeyHFR                  , "hfr"                    , INT32},  // int32_t
   {kKeyHFR                  , "hfr"                    , INT32},  // int32_t
#endif


   {kKeyBitRate              , "bitrate"                , INT32},
   {kKeySampleRate           , "sample-rate"            , INT32},
   {kKeySampleRate           , "sample-rate"            , INT32},
   {kKeyChannelCount         , "channel-count"          , INT32},
   {kKeyChannelCount         , "channel-count"          , INT32},
   {kKeyRawCodecSpecificData , "raw-codec-specific-data", CSD},


   {kKeySampleBits           , "bits-per-sample"        , INT32},
   {kKeyBitsPerSample        , "bits-per-sample"        , INT32},
   {kKeyCodecId              , "codec-id"               , INT32},
   {kKeyCodecId              , "codec-id"               , INT32},
   {kKeySampleFormat         , "sample-format"          , INT32},
   {kKeySampleFormat         , "sample-format"          , INT32},
   {kKeyBlockAlign           , "block-align"            , INT32},

   {kKeyAACAOT               , "aac-profile"            , INT32},
   {kKeyRVVersion            , "rv-version"             , INT32},
   {kKeyWMAVersion           , "wma-version"            , INT32},  // int32_t
   {kKeyWMVVersion           , "wmv-version"            , INT32},
};
};


const char* ExtendedCodec::getMsgKey(int key) {
const char* ExtendedCodec::getMsgKey(int key) {
@@ -190,6 +193,8 @@ status_t ExtendedCodec::convertMetaDataToMessage(
    return OK;
    return OK;
}
}


#ifdef ENABLE_AV_ENHANCEMENTS

uint32_t ExtendedCodec::getComponentQuirks(
uint32_t ExtendedCodec::getComponentQuirks(
        const sp<MediaCodecInfo> &info) {
        const sp<MediaCodecInfo> &info) {
    uint32_t quirks = 0;
    uint32_t quirks = 0;
@@ -1181,17 +1186,7 @@ bool ExtendedCodec::isSourcePauseRequired(const char *componentName) {
    return false;
    return false;
}
}


} //namespace android
#else

#else //ENABLE_AV_ENHANCEMENTS

namespace android {
    status_t ExtendedCodec::convertMetaDataToMessage(
            const sp<MetaData> &meta, sp<AMessage> *format) {
        ARG_TOUCH(meta);
        ARG_TOUCH(format);
        return OK;
    }


    uint32_t ExtendedCodec::getComponentQuirks (
    uint32_t ExtendedCodec::getComponentQuirks (
            const sp<MediaCodecInfo> &info) {
            const sp<MediaCodecInfo> &info) {
+64 −147
Original line number Original line Diff line number Diff line
@@ -25,10 +25,12 @@


#include <media/stagefright/FFMPEGSoftCodec.h>
#include <media/stagefright/FFMPEGSoftCodec.h>


#include <media/stagefright/ExtendedCodec.h>
#include <media/stagefright/MediaDefs.h>
#include <media/stagefright/MediaDefs.h>
#include <media/stagefright/MediaCodecList.h>
#include <media/stagefright/MediaCodecList.h>
#include <media/stagefright/MetaData.h>
#include <media/stagefright/MetaData.h>
#include <media/stagefright/OMXCodec.h>
#include <media/stagefright/OMXCodec.h>
#include <media/stagefright/Utils.h>


#include <OMX_Component.h>
#include <OMX_Component.h>
#include <OMX_AudioExt.h>
#include <OMX_AudioExt.h>
@@ -36,113 +38,28 @@


namespace android {
namespace android {


enum MetaKeyType{
void FFMPEGSoftCodec::convertMessageToMetaData(
    INT32, INT64, STRING, DATA, CSD
    const sp<AMessage> &msg, sp<MetaData> &meta) {
};

struct MetaKeyEntry{
    int MetaKey;
    const char* MsgKey;
    MetaKeyType KeyType;
};

static const MetaKeyEntry MetaKeyTable[] {
   {kKeyBitRate              , "bitrate"                , INT32},
   {kKeyWMAVersion           , "wma-version"            , INT32},  // int32_t
   {kKeyWMVVersion           , "wmv-version"            , INT32},
   {kKeyWMAEncodeOpt         , "wma-encode-opt"         , INT32},  // int32_t
   {kKeyWMABlockAlign        , "wma-block-align"        , INT32},  // int32_t
   {kKeyRVVersion            , "rv-version"             , INT32},
   {kKeyWidth                , "width"                  , INT32},
   {kKeyHeight               , "height"                 , INT32},
   {kKeyCodecId              , "codec-id"               , INT32},
   {kKeyBitsPerSample        , "bits-per-sample"        , INT32},
   {kKeyBlockAlign           , "block-align"            , INT32},
   {kKeySampleFormat         , "sample-format"          , INT32},
   {kKeySampleRate           , "sample-rate"            , INT32},
   {kKeyChannelCount         , "channel-count"          , INT32},
   {kKeyAACAOT               , "aac-profile"            , INT32},
};


const char* FFMPEGSoftCodec::getMsgKey(int key) {
    int32_t blockAlign;
    static const size_t numMetaKeys =
    if (msg->findInt32("block-align", &blockAlign)) {
                     sizeof(MetaKeyTable) / sizeof(MetaKeyTable[0]);
        meta->setInt32(kKeyBlockAlign, blockAlign);
    size_t i;
    for (i = 0; i < numMetaKeys; ++i) {
        if (key == MetaKeyTable[i].MetaKey) {
            return MetaKeyTable[i].MsgKey;
        }
    }
    return "unknown";
    }
    }


status_t FFMPEGSoftCodec::convertMetaDataToMessage(
    int32_t rvVersion;
        const sp<MetaData> &meta, sp<AMessage> *format) {
    if (msg->findInt32("rv-version", &rvVersion)) {
    const char * str_val;
        meta->setInt32(kKeyRVVersion, rvVersion);
    int32_t int32_val;
    int64_t int64_val;
    uint32_t data_type;
    const void * data;
    size_t size;
    static const size_t numMetaKeys =
                     sizeof(MetaKeyTable) / sizeof(MetaKeyTable[0]);
    size_t i;
    for (i = 0; i < numMetaKeys; ++i) {
        if (MetaKeyTable[i].KeyType == INT32 &&
            meta->findInt32(MetaKeyTable[i].MetaKey, &int32_val)) {
            ALOGV("found metakey %s of type int32", MetaKeyTable[i].MsgKey);
            format->get()->setInt32(MetaKeyTable[i].MsgKey, int32_val);
        } else if (MetaKeyTable[i].KeyType == INT64 &&
                 meta->findInt64(MetaKeyTable[i].MetaKey, &int64_val)) {
            ALOGV("found metakey %s of type int64", MetaKeyTable[i].MsgKey);
            format->get()->setInt64(MetaKeyTable[i].MsgKey, int64_val);
        } else if (MetaKeyTable[i].KeyType == STRING &&
                 meta->findCString(MetaKeyTable[i].MetaKey, &str_val)) {
            ALOGV("found metakey %s of type string", MetaKeyTable[i].MsgKey);
            format->get()->setString(MetaKeyTable[i].MsgKey, str_val);
        } else if ( (MetaKeyTable[i].KeyType == DATA ||
                   MetaKeyTable[i].KeyType == CSD) &&
                   meta->findData(MetaKeyTable[i].MetaKey, &data_type, &data, &size)) {
            ALOGV("found metakey %s of type data", MetaKeyTable[i].MsgKey);
            if (MetaKeyTable[i].KeyType == CSD) {
                const char *mime;
                CHECK(meta->findCString(kKeyMIMEType, &mime));
                if (strcasecmp(mime, MEDIA_MIMETYPE_VIDEO_AVC)) {
                    sp<ABuffer> buffer = new ABuffer(size);
                    memcpy(buffer->data(), data, size);
                    buffer->meta()->setInt32("csd", true);
                    buffer->meta()->setInt64("timeUs", 0);
                    format->get()->setBuffer("csd-0", buffer);
                } else {
                    const uint8_t *ptr = (const uint8_t *)data;
                    CHECK(size >= 8);
                    int seqLength = 0, picLength = 0;
                    for (size_t i = 4; i < (size - 4); i++)
                    {
                        if ((*(ptr + i) == 0) && (*(ptr + i + 1) == 0) &&
                           (*(ptr + i + 2) == 0) && (*(ptr + i + 3) == 1))
                            seqLength = i;
                    }
                    sp<ABuffer> buffer = new ABuffer(seqLength);
                    memcpy(buffer->data(), data, seqLength);
                    buffer->meta()->setInt32("csd", true);
                    buffer->meta()->setInt64("timeUs", 0);
                    format->get()->setBuffer("csd-0", buffer);
                    picLength=size-seqLength;
                    sp<ABuffer> buffer1 = new ABuffer(picLength);
                    memcpy(buffer1->data(), (const uint8_t *)data + seqLength, picLength);
                    buffer1->meta()->setInt32("csd", true);
                    buffer1->meta()->setInt64("timeUs", 0);
                    format->get()->setBuffer("csd-1", buffer1);
                }
            } else {
                sp<ABuffer> buffer = new ABuffer(size);
                memcpy(buffer->data(), data, size);
                format->get()->setBuffer(MetaKeyTable[i].MsgKey, buffer);
    }
    }

    int32_t wmvVersion;
    if (msg->findInt32("wmv-version", &wmvVersion)) {
        meta->setInt32(kKeyWMVVersion, wmvVersion);
    }
    }

    int32_t bitrate;
    if (msg->findInt32("bitrate", &bitrate)) {
        meta->setInt32(kKeyBitRate, bitrate);
    }
    }
    return OK;
}
}


template<class T>
template<class T>
@@ -193,7 +110,7 @@ void FFMPEGSoftCodec::overrideComponentName(


    int32_t wmvVersion = 0;
    int32_t wmvVersion = 0;
    if (!strncasecmp(mime->c_str(), MEDIA_MIMETYPE_VIDEO_WMV, strlen(MEDIA_MIMETYPE_VIDEO_WMV)) &&
    if (!strncasecmp(mime->c_str(), MEDIA_MIMETYPE_VIDEO_WMV, strlen(MEDIA_MIMETYPE_VIDEO_WMV)) &&
            msg->findInt32(getMsgKey(kKeyWMVVersion), &wmvVersion)) {
            msg->findInt32(ExtendedCodec::getMsgKey(kKeyWMVVersion), &wmvVersion)) {
        ALOGD("Found WMV version key %d", wmvVersion);
        ALOGD("Found WMV version key %d", wmvVersion);
        if (wmvVersion == 1) {
        if (wmvVersion == 1) {
            ALOGD("Use FFMPEG for unsupported WMV track");
            ALOGD("Use FFMPEG for unsupported WMV track");
@@ -203,7 +120,7 @@ void FFMPEGSoftCodec::overrideComponentName(


    int32_t encodeOptions = 0;
    int32_t encodeOptions = 0;
    if (!isEncoder && !strncasecmp(mime->c_str(), MEDIA_MIMETYPE_AUDIO_WMA, strlen(MEDIA_MIMETYPE_AUDIO_WMA)) &&
    if (!isEncoder && !strncasecmp(mime->c_str(), MEDIA_MIMETYPE_AUDIO_WMA, strlen(MEDIA_MIMETYPE_AUDIO_WMA)) &&
            !msg->findInt32(getMsgKey(kKeyWMAEncodeOpt), &encodeOptions)) {
            !msg->findInt32(ExtendedCodec::getMsgKey(kKeyWMAEncodeOpt), &encodeOptions)) {
        ALOGD("Use FFMPEG for unsupported WMA track");
        ALOGD("Use FFMPEG for unsupported WMA track");
        componentName->setTo("OMX.ffmpeg.wma.decoder");
        componentName->setTo("OMX.ffmpeg.wma.decoder");
    }
    }
@@ -211,7 +128,7 @@ void FFMPEGSoftCodec::overrideComponentName(
    // Google's decoder doesn't support MAIN profile
    // Google's decoder doesn't support MAIN profile
    int32_t aacProfile = 0;
    int32_t aacProfile = 0;
    if (!isEncoder && !strncasecmp(mime->c_str(), MEDIA_MIMETYPE_AUDIO_AAC, strlen(MEDIA_MIMETYPE_AUDIO_AAC)) &&
    if (!isEncoder && !strncasecmp(mime->c_str(), MEDIA_MIMETYPE_AUDIO_AAC, strlen(MEDIA_MIMETYPE_AUDIO_AAC)) &&
            msg->findInt32(getMsgKey(kKeyAACAOT), &aacProfile)) {
            msg->findInt32(ExtendedCodec::getMsgKey(kKeyAACAOT), &aacProfile)) {
        if (aacProfile == OMX_AUDIO_AACObjectMain) {
        if (aacProfile == OMX_AUDIO_AACObjectMain) {
            ALOGD("Use FFMPEG for AAC MAIN profile");
            ALOGD("Use FFMPEG for AAC MAIN profile");
            componentName->setTo("OMX.ffmpeg.aac.decoder");
            componentName->setTo("OMX.ffmpeg.aac.decoder");
@@ -497,7 +414,7 @@ status_t FFMPEGSoftCodec::setWMVFormat(
    int32_t version = 0;
    int32_t version = 0;
    OMX_VIDEO_PARAM_WMVTYPE paramWMV;
    OMX_VIDEO_PARAM_WMVTYPE paramWMV;


    CHECK(msg->findInt32(getMsgKey(kKeyWMVVersion), &version));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeyWMVVersion), &version));


    InitOMXParams(&paramWMV);
    InitOMXParams(&paramWMV);
    paramWMV.nPortIndex = kPortIndexInput;
    paramWMV.nPortIndex = kPortIndexInput;
@@ -526,7 +443,7 @@ status_t FFMPEGSoftCodec::setRVFormat(
    int32_t version = 0;
    int32_t version = 0;
    OMX_VIDEO_PARAM_RVTYPE paramRV;
    OMX_VIDEO_PARAM_RVTYPE paramRV;


    CHECK(msg->findInt32(getMsgKey(kKeyRVVersion), &version));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeyRVVersion), &version));


    InitOMXParams(&paramRV);
    InitOMXParams(&paramRV);
    paramRV.nPortIndex = kPortIndexInput;
    paramRV.nPortIndex = kPortIndexInput;
@@ -559,9 +476,9 @@ status_t FFMPEGSoftCodec::setFFmpegVideoFormat(


    ALOGD("setFFmpegVideoFormat");
    ALOGD("setFFmpegVideoFormat");


    CHECK(msg->findInt32(getMsgKey(kKeyCodecId), &codec_id));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeyCodecId), &codec_id));
    CHECK(msg->findInt32(getMsgKey(kKeyWidth), &width));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeyWidth), &width));
    CHECK(msg->findInt32(getMsgKey(kKeyHeight), &height));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeyHeight), &height));


    InitOMXParams(&param);
    InitOMXParams(&param);
    param.nPortIndex = kPortIndexInput;
    param.nPortIndex = kPortIndexInput;
@@ -588,9 +505,9 @@ status_t FFMPEGSoftCodec::setRawAudioFormat(
    int32_t sampleRate = 0;
    int32_t sampleRate = 0;
    int32_t bitsPerSample = 16;
    int32_t bitsPerSample = 16;


    CHECK(msg->findInt32(getMsgKey(kKeyChannelCount), &numChannels));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeyChannelCount), &numChannels));
    CHECK(msg->findInt32(getMsgKey(kKeySampleRate), &sampleRate));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeySampleRate), &sampleRate));
    if (!msg->findInt32(getMsgKey(kKeyBitsPerSample), &bitsPerSample)) {
    if (!msg->findInt32(ExtendedCodec::getMsgKey(kKeyBitsPerSample), &bitsPerSample)) {
        ALOGD("No PCM format specified, using 16 bit");
        ALOGD("No PCM format specified, using 16 bit");
    }
    }


@@ -651,13 +568,13 @@ status_t FFMPEGSoftCodec::setWMAFormat(
    int32_t formattag = 0;
    int32_t formattag = 0;
    OMX_AUDIO_PARAM_WMATYPE paramWMA;
    OMX_AUDIO_PARAM_WMATYPE paramWMA;


    CHECK(msg->findInt32(getMsgKey(kKeyChannelCount), &numChannels));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeyChannelCount), &numChannels));
    CHECK(msg->findInt32(getMsgKey(kKeySampleRate), &sampleRate));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeySampleRate), &sampleRate));
    CHECK(msg->findInt32(getMsgKey(kKeyBitRate), &bitRate));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeyBitRate), &bitRate));
    if (!msg->findInt32(getMsgKey(kKeyBlockAlign), &blockAlign)) {
    if (!msg->findInt32(ExtendedCodec::getMsgKey(kKeyBlockAlign), &blockAlign)) {
        // we should be last on the codec list, but another sniffer may
        // we should be last on the codec list, but another sniffer may
        // have handled it and there is no hardware codec.
        // have handled it and there is no hardware codec.
        if (!msg->findInt32(getMsgKey(kKeyWMABlockAlign), &blockAlign)) {
        if (!msg->findInt32(ExtendedCodec::getMsgKey(kKeyWMABlockAlign), &blockAlign)) {
            return ERROR_UNSUPPORTED;
            return ERROR_UNSUPPORTED;
        }
        }
    }
    }
@@ -665,7 +582,7 @@ status_t FFMPEGSoftCodec::setWMAFormat(
    ALOGV("Channels: %d, SampleRate: %d, BitRate: %d, blockAlign: %d",
    ALOGV("Channels: %d, SampleRate: %d, BitRate: %d, blockAlign: %d",
            numChannels, sampleRate, bitRate, blockAlign);
            numChannels, sampleRate, bitRate, blockAlign);


    CHECK(msg->findInt32(getMsgKey(kKeyWMAVersion), &version));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeyWMAVersion), &version));


    status_t err = setRawAudioFormat(msg, OMXhandle, nodeID);
    status_t err = setRawAudioFormat(msg, OMXhandle, nodeID);
    if (err != OK)
    if (err != OK)
@@ -704,8 +621,8 @@ status_t FFMPEGSoftCodec::setVORBISFormat(
    int32_t sampleRate = 0;
    int32_t sampleRate = 0;
    OMX_AUDIO_PARAM_VORBISTYPE param;
    OMX_AUDIO_PARAM_VORBISTYPE param;


    CHECK(msg->findInt32(getMsgKey(kKeyChannelCount), &numChannels));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeyChannelCount), &numChannels));
    CHECK(msg->findInt32(getMsgKey(kKeySampleRate), &sampleRate));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeySampleRate), &sampleRate));


    ALOGV("Channels: %d, SampleRate: %d",
    ALOGV("Channels: %d, SampleRate: %d",
            numChannels, sampleRate);
            numChannels, sampleRate);
@@ -738,10 +655,10 @@ status_t FFMPEGSoftCodec::setRAFormat(
    int32_t blockAlign = 0;
    int32_t blockAlign = 0;
    OMX_AUDIO_PARAM_RATYPE paramRA;
    OMX_AUDIO_PARAM_RATYPE paramRA;


    CHECK(msg->findInt32(getMsgKey(kKeyChannelCount), &numChannels));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeyChannelCount), &numChannels));
    CHECK(msg->findInt32(getMsgKey(kKeySampleRate), &sampleRate));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeySampleRate), &sampleRate));
    CHECK(msg->findInt32(getMsgKey(kKeyBitRate), &bitRate));
    msg->findInt32(ExtendedCodec::getMsgKey(kKeyBitRate), &bitRate);
    CHECK(msg->findInt32(getMsgKey(kKeyBlockAlign), &blockAlign));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeyBlockAlign), &blockAlign));


    ALOGV("Channels: %d, SampleRate: %d, BitRate: %d, blockAlign: %d",
    ALOGV("Channels: %d, SampleRate: %d, BitRate: %d, blockAlign: %d",
            numChannels, sampleRate, bitRate, blockAlign);
            numChannels, sampleRate, bitRate, blockAlign);
@@ -777,9 +694,9 @@ status_t FFMPEGSoftCodec::setFLACFormat(
    int32_t bitsPerSample = 0;
    int32_t bitsPerSample = 0;
    OMX_AUDIO_PARAM_FLACTYPE param;
    OMX_AUDIO_PARAM_FLACTYPE param;


    CHECK(msg->findInt32(getMsgKey(kKeyChannelCount), &numChannels));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeyChannelCount), &numChannels));
    CHECK(msg->findInt32(getMsgKey(kKeySampleRate), &sampleRate));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeySampleRate), &sampleRate));
    CHECK(msg->findInt32(getMsgKey(kKeyBitsPerSample), &bitsPerSample));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeyBitsPerSample), &bitsPerSample));


    ALOGV("Channels: %d, SampleRate: %d",
    ALOGV("Channels: %d, SampleRate: %d",
            numChannels, sampleRate);
            numChannels, sampleRate);
@@ -810,8 +727,8 @@ status_t FFMPEGSoftCodec::setMP2Format(
    int32_t sampleRate = 0;
    int32_t sampleRate = 0;
    OMX_AUDIO_PARAM_MP2TYPE param;
    OMX_AUDIO_PARAM_MP2TYPE param;


    CHECK(msg->findInt32(getMsgKey(kKeyChannelCount), &numChannels));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeyChannelCount), &numChannels));
    CHECK(msg->findInt32(getMsgKey(kKeySampleRate), &sampleRate));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeySampleRate), &sampleRate));


    ALOGV("Channels: %d, SampleRate: %d",
    ALOGV("Channels: %d, SampleRate: %d",
            numChannels, sampleRate);
            numChannels, sampleRate);
@@ -843,8 +760,8 @@ status_t FFMPEGSoftCodec::setAC3Format(
    int32_t bitsPerSample = 0;
    int32_t bitsPerSample = 0;
    OMX_AUDIO_PARAM_ANDROID_AC3TYPE param;
    OMX_AUDIO_PARAM_ANDROID_AC3TYPE param;


    CHECK(msg->findInt32(getMsgKey(kKeyChannelCount), &numChannels));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeyChannelCount), &numChannels));
    CHECK(msg->findInt32(getMsgKey(kKeySampleRate), &sampleRate));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeySampleRate), &sampleRate));


    ALOGV("Channels: %d, SampleRate: %d",
    ALOGV("Channels: %d, SampleRate: %d",
            numChannels, sampleRate);
            numChannels, sampleRate);
@@ -876,9 +793,9 @@ status_t FFMPEGSoftCodec::setAPEFormat(
    int32_t bitsPerSample = 0;
    int32_t bitsPerSample = 0;
    OMX_AUDIO_PARAM_APETYPE param;
    OMX_AUDIO_PARAM_APETYPE param;


    CHECK(msg->findInt32(getMsgKey(kKeyChannelCount), &numChannels));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeyChannelCount), &numChannels));
    CHECK(msg->findInt32(getMsgKey(kKeySampleRate), &sampleRate));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeySampleRate), &sampleRate));
    CHECK(msg->findInt32(getMsgKey(kKeyBitsPerSample), &bitsPerSample));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeyBitsPerSample), &bitsPerSample));


    ALOGV("Channels:%d, SampleRate:%d, bitsPerSample:%d",
    ALOGV("Channels:%d, SampleRate:%d, bitsPerSample:%d",
            numChannels, sampleRate, bitsPerSample);
            numChannels, sampleRate, bitsPerSample);
@@ -911,8 +828,8 @@ status_t FFMPEGSoftCodec::setDTSFormat(
    int32_t bitsPerSample = 0;
    int32_t bitsPerSample = 0;
    OMX_AUDIO_PARAM_DTSTYPE param;
    OMX_AUDIO_PARAM_DTSTYPE param;


    CHECK(msg->findInt32(getMsgKey(kKeyChannelCount), &numChannels));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeyChannelCount), &numChannels));
    CHECK(msg->findInt32(getMsgKey(kKeySampleRate), &sampleRate));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeySampleRate), &sampleRate));


    ALOGV("Channels: %d, SampleRate: %d",
    ALOGV("Channels: %d, SampleRate: %d",
            numChannels, sampleRate);
            numChannels, sampleRate);
@@ -942,7 +859,7 @@ status_t FFMPEGSoftCodec::setFFmpegAudioFormat(
    int32_t codec_id = 0;
    int32_t codec_id = 0;
    int32_t numChannels = 0;
    int32_t numChannels = 0;
    int32_t bitRate = 0;
    int32_t bitRate = 0;
    int32_t bitsPerSample = 0;
    int32_t bitsPerSample = 16;
    int32_t sampleRate = 0;
    int32_t sampleRate = 0;
    int32_t blockAlign = 0;
    int32_t blockAlign = 0;
    int32_t sampleFormat = 0;
    int32_t sampleFormat = 0;
@@ -950,13 +867,13 @@ status_t FFMPEGSoftCodec::setFFmpegAudioFormat(


    ALOGD("setFFmpegAudioFormat");
    ALOGD("setFFmpegAudioFormat");


    CHECK(msg->findInt32(getMsgKey(kKeyCodecId), &codec_id));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeyCodecId), &codec_id));
    CHECK(msg->findInt32(getMsgKey(kKeyChannelCount), &numChannels));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeyChannelCount), &numChannels));
    CHECK(msg->findInt32(getMsgKey(kKeyBitRate), &bitRate));
    CHECK(msg->findInt32(ExtendedCodec::getMsgKey(kKeySampleFormat), &sampleFormat));
    CHECK(msg->findInt32(getMsgKey(kKeyBitsPerSample), &bitsPerSample));
    msg->findInt32(ExtendedCodec::getMsgKey(kKeyBitRate), &bitRate);
    CHECK(msg->findInt32(getMsgKey(kKeySampleRate), &sampleRate));
    msg->findInt32(ExtendedCodec::getMsgKey(kKeyBitsPerSample), &bitsPerSample);
    CHECK(msg->findInt32(getMsgKey(kKeyBlockAlign), &blockAlign));
    msg->findInt32(ExtendedCodec::getMsgKey(kKeySampleRate), &sampleRate);
    CHECK(msg->findInt32(getMsgKey(kKeySampleFormat), &sampleFormat));
    msg->findInt32(ExtendedCodec::getMsgKey(kKeyBlockAlign), &blockAlign);


    status_t err = setRawAudioFormat(msg, OMXhandle, nodeID);
    status_t err = setRawAudioFormat(msg, OMXhandle, nodeID);
    if (err != OK)
    if (err != OK)
Loading