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

Commit e6109e2f authored by Lajos Molnar's avatar Lajos Molnar
Browse files

mediaplayer: support async mode for widevine legacy mode

Bug: 14679336
Change-Id: Id224eb8c31ec148ca9a144758cc56ddbf5465f5c
parent 421f47ca
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -135,6 +135,8 @@ struct MediaCodec : public AHandler {
    status_t getOutputFormat(sp<AMessage> *format) const;
    status_t getInputFormat(sp<AMessage> *format) const;

    status_t getWidevineLegacyBuffers(Vector<sp<ABuffer> > *buffers) const;

    status_t getInputBuffers(Vector<sp<ABuffer> > *buffers) const;
    status_t getOutputBuffers(Vector<sp<ABuffer> > *buffers) const;

+6 −14
Original line number Diff line number Diff line
@@ -244,15 +244,7 @@ void NuPlayer::Decoder::onConfigure(const sp<AMessage> &format) {
        return;
    }

    // the following should work after start
//    CHECK_EQ((status_t)OK, mCodec->getInputBuffers(&mInputBuffers));
    releaseAndResetMediaBuffers();
//    CHECK_EQ((status_t)OK, mCodec->getOutputBuffers(&mOutputBuffers));
//    ALOGV("[%s] got %zu input and %zu output buffers",
//            mComponentName.c_str(),
//            mInputBuffers.size(),
//            mOutputBuffers.size());


    mPaused = false;
    mResumePending = false;
@@ -262,16 +254,14 @@ void NuPlayer::Decoder::onSetRenderer(const sp<Renderer> &renderer) {
    bool hadNoRenderer = (mRenderer == NULL);
    mRenderer = renderer;
    if (hadNoRenderer && mRenderer != NULL) {
        requestCodecNotification();
        // this means that the widevine legacy source is ready
        onRequestInputBuffers();
    }
}

void NuPlayer::Decoder::onGetInputBuffers(
        Vector<sp<ABuffer> > *dstBuffers) {
    dstBuffers->clear();
    for (size_t i = 0; i < mInputBuffers.size(); i++) {
        dstBuffers->push(mInputBuffers[i]);
    }
    CHECK_EQ((status_t)OK, mCodec->getWidevineLegacyBuffers(dstBuffers));
}

void NuPlayer::Decoder::onResume(bool notifyComplete) {
@@ -367,7 +357,9 @@ void NuPlayer::Decoder::onShutdown(bool notifyComplete) {
}

void NuPlayer::Decoder::doRequestBuffers() {
    if (isDiscontinuityPending()) {
    // mRenderer is only NULL if we have a legacy widevine source that
    // is not yet ready. In this case we must not fetch input.
    if (isDiscontinuityPending() || mRenderer == NULL) {
        return;
    }
    status_t err = OK;
+15 −1
Original line number Diff line number Diff line
@@ -546,6 +546,16 @@ status_t MediaCodec::getName(AString *name) const {
    return OK;
}

status_t MediaCodec::getWidevineLegacyBuffers(Vector<sp<ABuffer> > *buffers) const {
    sp<AMessage> msg = new AMessage(kWhatGetBuffers, this);
    msg->setInt32("portIndex", kPortIndexInput);
    msg->setPointer("buffers", buffers);
    msg->setInt32("widevine", true);

    sp<AMessage> response;
    return PostAndAwaitResponse(msg, &response);
}

status_t MediaCodec::getInputBuffers(Vector<sp<ABuffer> > *buffers) const {
    sp<AMessage> msg = new AMessage(kWhatGetBuffers, this);
    msg->setInt32("portIndex", kPortIndexInput);
@@ -1602,8 +1612,12 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
        {
            sp<AReplyToken> replyID;
            CHECK(msg->senderAwaitsResponse(&replyID));
            // Unfortunately widevine legacy source requires knowing all of the
            // codec input buffers, so we have to provide them even in async mode.
            int32_t widevine = 0;
            msg->findInt32("widevine", &widevine);

            if (!isExecuting() || (mFlags & kFlagIsAsync)) {
            if (!isExecuting() || ((mFlags & kFlagIsAsync) && !widevine)) {
                PostReplyWithError(replyID, INVALID_OPERATION);
                break;
            } else if (mFlags & kFlagStickyError) {