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

Commit da53ce37 authored by Wonsik Kim's avatar Wonsik Kim Committed by Android (Google) Code Review
Browse files

Merge "stagefright: add profile capability check for audio codecs"

parents e1c37946 ed2a94af
Loading
Loading
Loading
Loading
+27 −1
Original line number Diff line number Diff line
@@ -4330,7 +4330,6 @@ status_t QueryCodec(
    caps->mFlags = 0;
    caps->mComponentName = componentName;

    // NOTE: OMX does not provide a way to query AAC profile support
    if (isVideo) {
        OMX_VIDEO_PARAM_PROFILELEVELTYPE param;
        InitOMXParams(&param);
@@ -4384,6 +4383,33 @@ status_t QueryCodec(
            }
            caps->mColorFormats.push(portFormat.eColorFormat);
        }
    } else if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_AAC, mime)) {
        // More audio codecs if they have profiles.
        OMX_AUDIO_PARAM_ANDROID_PROFILETYPE param;
        InitOMXParams(&param);
        param.nPortIndex = isEncoder ? 1 : 0;
        for (param.nProfileIndex = 0;; ++param.nProfileIndex) {
            err = omx->getParameter(
                    node, (OMX_INDEXTYPE)OMX_IndexParamAudioProfileQuerySupported,
                    &param, sizeof(param));

            if (err != OK) {
                break;
            }

            CodecProfileLevel profileLevel;
            profileLevel.mProfile = param.eProfile;
            // For audio, level is ignored.
            profileLevel.mLevel = 0;

            caps->mProfileLevels.push(profileLevel);
        }

        // NOTE: Without Android extensions, OMX does not provide a way to query
        // AAC profile support
        if (param.nProfileIndex == 0) {
            ALOGW("component %s doesn't support profile query.", componentName);
        }
    }

    if (isVideo && !isEncoder) {
+30 −1
Original line number Diff line number Diff line
@@ -20,9 +20,11 @@

#include "SoftAACEncoder2.h"
#include <OMX_AudioExt.h>
#include <OMX_IndexExt.h>

#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/hexdump.h>
#include <utils/misc.h>

namespace android {

@@ -35,6 +37,14 @@ static void InitOMXParams(T *params) {
    params->nVersion.s.nStep = 0;
}

static const OMX_U32 kSupportedProfiles[] = {
    OMX_AUDIO_AACObjectLC,
    OMX_AUDIO_AACObjectHE,
    OMX_AUDIO_AACObjectHE_PS,
    OMX_AUDIO_AACObjectLD,
    OMX_AUDIO_AACObjectELD,
};

SoftAACEncoder2::SoftAACEncoder2(
        const char *name,
        const OMX_CALLBACKTYPE *callbacks,
@@ -117,7 +127,7 @@ status_t SoftAACEncoder2::initEncoder() {

OMX_ERRORTYPE SoftAACEncoder2::internalGetParameter(
        OMX_INDEXTYPE index, OMX_PTR params) {
    switch (index) {
    switch ((OMX_U32) index) {
        case OMX_IndexParamAudioPortFormat:
        {
            OMX_AUDIO_PARAM_PORTFORMATTYPE *formatParams =
@@ -220,6 +230,25 @@ OMX_ERRORTYPE SoftAACEncoder2::internalGetParameter(
            return OMX_ErrorNone;
        }

        case OMX_IndexParamAudioProfileQuerySupported:
        {
            OMX_AUDIO_PARAM_ANDROID_PROFILETYPE *profileParams =
                (OMX_AUDIO_PARAM_ANDROID_PROFILETYPE *)params;

            if (profileParams->nPortIndex != 1) {
                return OMX_ErrorUndefined;
            }

            if (profileParams->nProfileIndex >= NELEM(kSupportedProfiles)) {
                return OMX_ErrorNoMore;
            }

            profileParams->eProfile =
                kSupportedProfiles[profileParams->nProfileIndex];

            return OMX_ErrorNone;
        }

        default:
            return SimpleSoftOMXComponent::internalGetParameter(index, params);
    }