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

Commit a3f909a8 authored by Guillaume Chelfi's avatar Guillaume Chelfi
Browse files

Forward first tunnel frame OMX event to framework

This commit forwards the OMX first tunnel frame ready event to enable
the framework to support video peek in tunnel mode.

Bug: 157501309
Test: Currently untested, full CTS coverage coming soon
CTS-Coverage-Bug: 157501309
Change-Id: I298e27b1024440ea353f8a1db2afdabdb695f702
parent 2e403e84
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1471,6 +1471,10 @@ void ACodec::notifyOfRenderedFrames(bool dropIncomplete, FrameRenderTracker::Inf
    mCallback->onOutputFramesRendered(done);
}

void ACodec::onFirstTunnelFrameReady() {
    mCallback->onFirstTunnelFrameReady();
}

ACodec::BufferInfo *ACodec::dequeueBufferFromNativeWindow() {
    ANativeWindowBuffer *buf;
    CHECK(mNativeWindow.get() != NULL);
@@ -8394,6 +8398,12 @@ bool ACodec::ExecutingState::onOMXEvent(
            return true;
        }

        case OMX_EventOnFirstTunnelFrameReady:
        {
            mCodec->onFirstTunnelFrameReady();
            return true;
        }

        default:
            return BaseState::onOMXEvent(event, data1, data2);
    }
+27 −0
Original line number Diff line number Diff line
@@ -424,6 +424,7 @@ enum {
    kWhatSignaledInputEOS    = 'seos',
    kWhatOutputFramesRendered = 'outR',
    kWhatOutputBuffersChanged = 'outC',
    kWhatFirstTunnelFrameReady = 'ftfR',
};

class BufferCallback : public CodecBase::BufferCallback {
@@ -486,6 +487,7 @@ public:
    virtual void onSignaledInputEOS(status_t err) override;
    virtual void onOutputFramesRendered(const std::list<FrameRenderTracker::Info> &done) override;
    virtual void onOutputBuffersChanged() override;
    virtual void onFirstTunnelFrameReady() override;
private:
    const sp<AMessage> mNotify;
};
@@ -606,6 +608,12 @@ void CodecCallback::onOutputBuffersChanged() {
    notify->post();
}

void CodecCallback::onFirstTunnelFrameReady() {
    sp<AMessage> notify(mNotify->dup());
    notify->setInt32("what", kWhatFirstTunnelFrameReady);
    notify->post();
}

}  // namespace

////////////////////////////////////////////////////////////////////////////////
@@ -1334,6 +1342,12 @@ status_t MediaCodec::setOnFrameRenderedNotification(const sp<AMessage> &notify)
    return msg->post();
}

status_t MediaCodec::setOnFirstTunnelFrameReadyNotification(const sp<AMessage> &notify) {
    sp<AMessage> msg = new AMessage(kWhatSetNotification, this);
    msg->setMessage("first-tunnel-frame-ready", notify);
    return msg->post();
}

static void mapFormat(AString componentName, const sp<AMessage> &format, const char *kind,
                      bool reverse);

@@ -3003,6 +3017,16 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
                    break;
                }

                case kWhatFirstTunnelFrameReady:
                {
                    if (mState == STARTED && mOnFirstTunnelFrameReadyNotification != nullptr) {
                        sp<AMessage> notify = mOnFirstTunnelFrameReadyNotification->dup();
                        notify->setMessage("data", msg);
                        notify->post();
                    }
                    break;
                }

                case kWhatFillThisBuffer:
                {
                    /* size_t index = */updateBuffers(kPortIndexInput, msg);
@@ -3221,6 +3245,9 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
            if (msg->findMessage("on-frame-rendered", &notify)) {
                mOnFrameRenderedNotification = notify;
            }
            if (msg->findMessage("first-tunnel-frame-ready", &notify)) {
                mOnFirstTunnelFrameReadyNotification = notify;
            }
            break;
        }

+2 −0
Original line number Diff line number Diff line
@@ -579,6 +579,8 @@ private:
    void notifyOfRenderedFrames(
            bool dropIncomplete = false, FrameRenderTracker::Info *until = NULL);

    void onFirstTunnelFrameReady();

    // Pass |expectedFormat| to print a warning if the format differs from it.
    // Using sp<> instead of const sp<>& because expectedFormat is likely the current mOutputFormat
    // which will get updated inside.
+4 −0
Original line number Diff line number Diff line
@@ -173,6 +173,10 @@ struct CodecBase : public AHandler, /* static */ ColorUtils {
         * Notify MediaCodec that output buffers are changed.
         */
        virtual void onOutputBuffersChanged() = 0;
        /**
         * Notify MediaCodec that the first tunnel frame is ready.
         */
        virtual void onFirstTunnelFrameReady() = 0;
    };

    /**
+3 −0
Original line number Diff line number Diff line
@@ -128,6 +128,8 @@ struct MediaCodec : public AHandler {

    status_t setOnFrameRenderedNotification(const sp<AMessage> &notify);

    status_t setOnFirstTunnelFrameReadyNotification(const sp<AMessage> &notify);

    status_t createInputSurface(sp<IGraphicBufferProducer>* bufferProducer);

    status_t setInputSurface(const sp<PersistentSurface> &surface);
@@ -393,6 +395,7 @@ private:
    sp<AMessage> mCallback;
    sp<AMessage> mOnFrameRenderedNotification;
    sp<AMessage> mAsyncReleaseCompleteNotification;
    sp<AMessage> mOnFirstTunnelFrameReadyNotification;

    sp<ResourceManagerServiceProxy> mResourceManagerProxy;