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

Commit 23a0e169 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "CCodec: Episode II --- Prepare For Audio"

parents 45c4f319 96310bd5
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -622,7 +622,7 @@ static void usage(const char *me) {
    fprintf(stderr, "       -o playback audio\n");
    fprintf(stderr, "       -w(rite) filename (write to .mp4 file)\n");
    fprintf(stderr, "       -k seek test\n");
    fprintf(stderr, "       -O(verride) name of the component\n");
    fprintf(stderr, "       -N(ame) of the component\n");
    fprintf(stderr, "       -x display a histogram of decoding times/fps "
                    "(video only)\n");
    fprintf(stderr, "       -q don't show progress indicator\n");
@@ -708,7 +708,7 @@ int main(int argc, char **argv) {
    sp<ALooper> looper;

    int res;
    while ((res = getopt(argc, argv, "haqn:lm:b:ptsrow:kO:xSTd:D:")) >= 0) {
    while ((res = getopt(argc, argv, "haqn:lm:b:ptsrow:kN:xSTd:D:")) >= 0) {
        switch (res) {
            case 'a':
            {
@@ -737,7 +737,7 @@ int main(int argc, char **argv) {
                break;
            }

            case 'O':
            case 'N':
            {
                gComponentNameOverride.setTo(optarg);
                break;
+0 −4
Original line number Diff line number Diff line
@@ -117,9 +117,6 @@ cc_library_shared {
        "android.hardware.media.omx@1.0",
        "android.hardware.graphics.allocator@2.0",
        "android.hardware.graphics.mapper@2.0",

        // XXX: hack
        "libstagefright_soft_c2avcdec",
    ],

    static_libs: [
@@ -135,7 +132,6 @@ cc_library_shared {
        "libstagefright_id3",
        "libFLAC",

        // XXX: hack
        "libstagefright_codec2_vndk",
    ],

+34 −5
Original line number Diff line number Diff line
@@ -18,11 +18,10 @@
#define LOG_TAG "CCodec"
#include <utils/Log.h>

// XXX: HACK
#include "codecs/avcdec/C2SoftAvcDec.h"

#include <thread>

#include <C2PlatformSupport.h>

#include <gui/Surface.h>
#include <media/stagefright/CCodec.h>

@@ -181,8 +180,18 @@ void CCodec::allocate(const AString &componentName) {
    // TODO: use C2ComponentStore to create component
    mListener.reset(new CCodecListener(mChannel));

    std::shared_ptr<C2Component> comp(new C2SoftAvcDec(componentName.c_str(), 0));
    comp->setListener_vb(mListener, C2_DONT_BLOCK);
    std::shared_ptr<C2Component> comp;
    c2_status_t err = GetCodec2PlatformComponentStore()->createComponent(
            componentName.c_str(), &comp);
    if (err != C2_OK) {
        Mutexed<State>::Locked state(mState);
        state->mState = RELEASED;
        state.unlock();
        mCallback->onError(err, ACTION_CODE_FATAL);
        state.lock();
        return;
    }
    comp->setListener_vb(mListener, C2_MAY_BLOCK);
    {
        Mutexed<State>::Locked state(mState);
        if (state->mState != ALLOCATING) {
@@ -233,6 +242,26 @@ void CCodec::configure(const sp<AMessage> &msg) {
            setSurface(surface);
        }

        // XXX: hack
        bool audio = mime.startsWithIgnoreCase("audio/");
        if (encoder) {
            outputFormat->setString("mime", mime);
            inputFormat->setString("mime", AStringPrintf("%s/raw", audio ? "audio" : "video"));
            if (audio) {
                inputFormat->setInt32("channel-count", 1);
                inputFormat->setInt32("sample-rate", 44100);
                outputFormat->setInt32("channel-count", 1);
                outputFormat->setInt32("sample-rate", 44100);
            }
        } else {
            inputFormat->setString("mime", mime);
            outputFormat->setString("mime", AStringPrintf("%s/raw", audio ? "audio" : "video"));
            if (audio) {
                outputFormat->setInt32("channel-count", 2);
                outputFormat->setInt32("sample-rate", 44100);
            }
        }

        // TODO

        return OK;
+515 −127

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -552,7 +552,7 @@ void MediaCodec::PostReplyWithError(const sp<AReplyToken> &replyID, int32_t err)
//static
sp<CodecBase> MediaCodec::GetCodecBase(const AString &name, bool nameIsType) {
    static bool ccodecEnabled = property_get_bool("debug.stagefright.ccodec", false);
    if (ccodecEnabled && !nameIsType && name.startsWithIgnoreCase("codec2.")) {
    if (ccodecEnabled && !nameIsType && name.startsWithIgnoreCase("c2.")) {
        return new CCodec;
    } else if (nameIsType || name.startsWithIgnoreCase("omx.")) {
        // at this time only ACodec specifies a mime type.
Loading