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

Commit b1120b65 authored by Lajos Molnar's avatar Lajos Molnar Committed by Android (Google) Code Review
Browse files

Merge changes I1455bfc6,I90c7e34b,I06e001df

* changes:
  NuPlayer: use MediaCodec instead of ACodec
  MediaCodec: add getInputFormat() method
  Revert "NuPlayer: Use a software renderer when using software codecs"
parents 1d59fea1 1cd13982
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -67,8 +67,6 @@ struct ACodec : public AHierarchicalStateMachine {

    void signalRequestIDRFrame();

    bool isConfiguredForAdaptivePlayback() { return mIsConfiguredForAdaptivePlayback; }

    struct PortDescription : public RefBase {
        size_t countBuffers();
        IOMX::buffer_id bufferIDAt(size_t index) const;
@@ -178,6 +176,8 @@ private:
    sp<MemoryDealer> mDealer[2];

    sp<ANativeWindow> mNativeWindow;
    sp<AMessage> mInputFormat;
    sp<AMessage> mOutputFormat;

    Vector<BufferInfo> mBuffers[2];
    bool mPortEOS[2];
@@ -189,7 +189,6 @@ private:
    bool mIsEncoder;
    bool mUseMetadataOnEncoderOutput;
    bool mShutdownInProgress;
    bool mIsConfiguredForAdaptivePlayback;

    // If "mKeepComponentAllocated" we only transition back to Loaded state
    // and do not release the component instance.
@@ -306,6 +305,7 @@ private:
    void processDeferredMessages();

    void sendFormatChange(const sp<AMessage> &reply);
    status_t getPortFormat(OMX_U32 portIndex, sp<AMessage> &notify);

    void signalError(
            OMX_ERRORTYPE error = OMX_ErrorUndefined,
+3 −0
Original line number Diff line number Diff line
@@ -106,6 +106,7 @@ struct MediaCodec : public AHandler {
    status_t signalEndOfInputStream();

    status_t getOutputFormat(sp<AMessage> *format) const;
    status_t getInputFormat(sp<AMessage> *format) const;

    status_t getInputBuffers(Vector<sp<ABuffer> > *buffers) const;
    status_t getOutputBuffers(Vector<sp<ABuffer> > *buffers) const;
@@ -159,6 +160,7 @@ private:
        kWhatGetBuffers                     = 'getB',
        kWhatFlush                          = 'flus',
        kWhatGetOutputFormat                = 'getO',
        kWhatGetInputFormat                 = 'getI',
        kWhatDequeueInputTimedOut           = 'dITO',
        kWhatDequeueOutputTimedOut          = 'dOTO',
        kWhatCodecNotify                    = 'codc',
@@ -199,6 +201,7 @@ private:
    sp<Surface> mNativeWindow;
    SoftwareRenderer *mSoftRenderer;
    sp<AMessage> mOutputFormat;
    sp<AMessage> mInputFormat;

    List<size_t> mAvailPortBuffers[2];
    Vector<BufferInfo> mPortBuffers[2];
+23 −50
Original line number Diff line number Diff line
@@ -31,13 +31,10 @@

#include "ATSParser.h"

#include "SoftwareRenderer.h"

#include <media/stagefright/foundation/hexdump.h>
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/ACodec.h>
#include <media/stagefright/MediaDefs.h>
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/MetaData.h>
@@ -146,7 +143,6 @@ NuPlayer::NuPlayer()
    : mUIDValid(false),
      mSourceFlags(0),
      mVideoIsAVC(false),
      mNeedsSwRenderer(false),
      mAudioEOS(false),
      mVideoEOS(false),
      mScanSourcesPending(false),
@@ -442,7 +438,6 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
            ALOGV("kWhatStart");

            mVideoIsAVC = false;
            mNeedsSwRenderer = false;
            mAudioEOS = false;
            mVideoEOS = false;
            mSkipRenderingAudioUntilMediaTimeUs = -1;
@@ -533,24 +528,21 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
        {
            bool audio = msg->what() == kWhatAudioNotify;

            sp<AMessage> codecRequest;
            CHECK(msg->findMessage("codec-request", &codecRequest));

            int32_t what;
            CHECK(codecRequest->findInt32("what", &what));
            CHECK(msg->findInt32("what", &what));

            if (what == ACodec::kWhatFillThisBuffer) {
            if (what == Decoder::kWhatFillThisBuffer) {
                status_t err = feedDecoderInputData(
                        audio, codecRequest);
                        audio, msg);

                if (err == -EWOULDBLOCK) {
                    if (mSource->feedMoreTSData() == OK) {
                        msg->post(10000ll);
                    }
                }
            } else if (what == ACodec::kWhatEOS) {
            } else if (what == Decoder::kWhatEOS) {
                int32_t err;
                CHECK(codecRequest->findInt32("err", &err));
                CHECK(msg->findInt32("err", &err));

                if (err == ERROR_END_OF_STREAM) {
                    ALOGV("got %s decoder EOS", audio ? "audio" : "video");
@@ -561,7 +553,7 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
                }

                mRenderer->queueEOS(audio, err);
            } else if (what == ACodec::kWhatFlushCompleted) {
            } else if (what == Decoder::kWhatFlushCompleted) {
                bool needShutdown;

                if (audio) {
@@ -590,14 +582,17 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
                }

                finishFlushIfPossible();
            } else if (what == ACodec::kWhatOutputFormatChanged) {
            } else if (what == Decoder::kWhatOutputFormatChanged) {
                sp<AMessage> format;
                CHECK(msg->findMessage("format", &format));

                if (audio) {
                    int32_t numChannels;
                    CHECK(codecRequest->findInt32(
                    CHECK(format->findInt32(
                                "channel-count", &numChannels));

                    int32_t sampleRate;
                    CHECK(codecRequest->findInt32("sample-rate", &sampleRate));
                    CHECK(format->findInt32("sample-rate", &sampleRate));

                    ALOGV("Audio output format changed to %d Hz, %d channels",
                         sampleRate, numChannels);
@@ -621,7 +616,7 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
                    }

                    int32_t channelMask;
                    if (!codecRequest->findInt32("channel-mask", &channelMask)) {
                    if (!format->findInt32("channel-mask", &channelMask)) {
                        channelMask = CHANNEL_MASK_USE_CHANNEL_ORDER;
                    }

@@ -642,11 +637,11 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
                    // video

                    int32_t width, height;
                    CHECK(codecRequest->findInt32("width", &width));
                    CHECK(codecRequest->findInt32("height", &height));
                    CHECK(format->findInt32("width", &width));
                    CHECK(format->findInt32("height", &height));

                    int32_t cropLeft, cropTop, cropRight, cropBottom;
                    CHECK(codecRequest->findRect(
                    CHECK(format->findRect(
                                "crop",
                                &cropLeft, &cropTop, &cropRight, &cropBottom));

@@ -679,22 +674,8 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {

                    notifyListener(
                            MEDIA_SET_VIDEO_SIZE, displayWidth, displayHeight);

                    if (mNeedsSwRenderer && mNativeWindow != NULL) {
                        int32_t colorFormat;
                        CHECK(codecRequest->findInt32("color-format", &colorFormat));

                        sp<MetaData> meta = new MetaData;
                        meta->setInt32(kKeyWidth, width);
                        meta->setInt32(kKeyHeight, height);
                        meta->setRect(kKeyCropRect, cropLeft, cropTop, cropRight, cropBottom);
                        meta->setInt32(kKeyColorFormat, colorFormat);

                        mRenderer->setSoftRenderer(
                                new SoftwareRenderer(mNativeWindow->getNativeWindow(), meta));
                    }
                }
            } else if (what == ACodec::kWhatShutdownCompleted) {
            } else if (what == Decoder::kWhatShutdownCompleted) {
                ALOGV("%s shutdown completed", audio ? "audio" : "video");
                if (audio) {
                    mAudioDecoder.clear();
@@ -709,22 +690,15 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
                }

                finishFlushIfPossible();
            } else if (what == ACodec::kWhatError) {
            } else if (what == Decoder::kWhatError) {
                ALOGE("Received error from %s decoder, aborting playback.",
                     audio ? "audio" : "video");

                mRenderer->queueEOS(audio, UNKNOWN_ERROR);
            } else if (what == ACodec::kWhatDrainThisBuffer) {
                renderBuffer(audio, codecRequest);
            } else if (what == ACodec::kWhatComponentAllocated) {
                if (!audio) {
                    AString name;
                    CHECK(codecRequest->findString("componentName", &name));
                    mNeedsSwRenderer = name.startsWith("OMX.google.");
                }
            } else if (what != ACodec::kWhatComponentConfigured
                    && what != ACodec::kWhatBuffersAllocated) {
                ALOGV("Unhandled codec notification %d '%c%c%c%c'.",
            } else if (what == Decoder::kWhatDrainThisBuffer) {
                renderBuffer(audio, msg);
            } else {
                ALOGV("Unhandled decoder notification %d '%c%c%c%c'.",
                      what,
                      what >> 24,
                      (what >> 16) & 0xff,
@@ -925,8 +899,7 @@ status_t NuPlayer::instantiateDecoder(bool audio, sp<Decoder> *decoder) {

    *decoder = audio ? new Decoder(notify) :
                       new Decoder(notify, mNativeWindow);
    looper()->registerHandler(*decoder);

    (*decoder)->init();
    (*decoder)->configure(format);

    return OK;
+0 −2
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@

namespace android {

struct ACodec;
struct MetaData;
struct NuPlayerDriver;

@@ -118,7 +117,6 @@ private:
    sp<MediaPlayerBase::AudioSink> mAudioSink;
    sp<Decoder> mVideoDecoder;
    bool mVideoIsAVC;
    bool mNeedsSwRenderer;
    sp<Decoder> mAudioDecoder;
    sp<Renderer> mRenderer;

+385 −74

File changed.

Preview size limit exceeded, changes collapsed.

Loading