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

Commit 7879fa98 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Merge cherrypicks of [8655472, 8655254, 8655915, 8655916, 8655554, 8655935,...

Merge cherrypicks of [8655472, 8655254, 8655915, 8655916, 8655554, 8655935, 8655917, 8655800, 8655789, 8655473, 8655918, 8655474, 8655408, 8655351] into qt-release

Change-Id: I7c37e317194e0a8b6da6fc2c6478bd51320b91eb
parents 39fb9c9a fd5486c7
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -959,9 +959,9 @@ std::vector<C2Component::Traits> const& Codec2Client::ListComponents() {

std::shared_ptr<Codec2Client::InputSurface> Codec2Client::CreateInputSurface(
        char const* serviceName) {
    uint32_t inputSurfaceSetting = ::android::base::GetUintProperty(
            "debug.stagefright.c2inputsurface", uint32_t(0));
    if (inputSurfaceSetting == 0) {
    int32_t inputSurfaceSetting = ::android::base::GetIntProperty(
            "debug.stagefright.c2inputsurface", int32_t(0));
    if (inputSurfaceSetting <= 0) {
        return nullptr;
    }
    size_t index = GetServiceNames().size();
+3 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ cc_library_shared {
        "CCodecConfig.cpp",
        "Codec2Buffer.cpp",
        "Codec2InfoBuilder.cpp",
        "Omx2IGraphicBufferSource.cpp",
        "PipelineWatcher.cpp",
        "ReflectedParamUpdater.cpp",
        "SkipCutBuffer.cpp",
@@ -41,8 +42,10 @@ cc_library_shared {
        "libmedia",
        "libmedia_omx",
        "libsfplugin_ccodec_utils",
        "libstagefright_bufferqueue_helper",
        "libstagefright_codecbase",
        "libstagefright_foundation",
        "libstagefright_omx",
        "libstagefright_omx_utils",
        "libstagefright_xmlparser",
        "libui",
+22 −5
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@
#include "CCodec.h"
#include "CCodecBufferChannel.h"
#include "InputSurfaceWrapper.h"
#include "Omx2IGraphicBufferSource.h"

extern "C" android::PersistentSurface *CreateInputSurface();

@@ -1067,6 +1068,7 @@ sp<PersistentSurface> CCodec::CreateOmxInputSurface() {
    OmxStatus s;
    android::sp<HGraphicBufferProducer> gbp;
    android::sp<HGraphicBufferSource> gbs;

    using ::android::hardware::Return;
    Return<void> transStatus = omx->createInputSurface(
            [&s, &gbp, &gbs](
@@ -1852,15 +1854,30 @@ extern "C" android::CodecBase *CreateCodec() {

// Create Codec 2.0 input surface
extern "C" android::PersistentSurface *CreateInputSurface() {
    using namespace android;
    // Attempt to create a Codec2's input surface.
    std::shared_ptr<android::Codec2Client::InputSurface> inputSurface =
            android::Codec2Client::CreateInputSurface();
    std::shared_ptr<Codec2Client::InputSurface> inputSurface =
            Codec2Client::CreateInputSurface();
    if (!inputSurface) {
        if (property_get_int32("debug.stagefright.c2inputsurface", 0) == -1) {
            sp<IGraphicBufferProducer> gbp;
            sp<OmxGraphicBufferSource> gbs = new OmxGraphicBufferSource();
            status_t err = gbs->initCheck();
            if (err != OK) {
                ALOGE("Failed to create persistent input surface: error %d", err);
                return nullptr;
            }
    return new android::PersistentSurface(
            return new PersistentSurface(
                    gbs->getIGraphicBufferProducer(),
                    sp<IGraphicBufferSource>(
                        new Omx2IGraphicBufferSource(gbs)));
        } else {
            return nullptr;
        }
    }
    return new PersistentSurface(
            inputSurface->getGraphicBufferProducer(),
            static_cast<android::sp<android::hidl::base::V1_0::IBase>>(
            static_cast<sp<android::hidl::base::V1_0::IBase>>(
            inputSurface->getHalInterface()));
}
+3 −0
Original line number Diff line number Diff line
@@ -896,6 +896,9 @@ status_t CCodecBufferChannel::start(
                input->buffers.reset(new DummyInputBuffers(mName));
            } else if (mMetaMode == MODE_ANW) {
                input->buffers.reset(new GraphicMetadataInputBuffers(mName));
                // This is to ensure buffers do not get released prematurely.
                // TODO: handle this without going into array mode
                forceArrayMode = true;
            } else {
                input->buffers.reset(new GraphicInputBuffers(numInputSlots, mName));
            }
+185 −0
Original line number Diff line number Diff line
/*
 * Copyright 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifdef __LP64__
#define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS
#endif

//#define LOG_NDEBUG 0
#define LOG_TAG "Omx2IGraphicBufferSource"
#include <android-base/logging.h>

#include "Omx2IGraphicBufferSource.h"

#include <android/BnOMXBufferSource.h>
#include <media/OMXBuffer.h>
#include <media/stagefright/omx/OMXUtils.h>

#include <OMX_Component.h>
#include <OMX_Index.h>
#include <OMX_IndexExt.h>

namespace android {

namespace /* unnamed */ {

// OmxGraphicBufferSource -> IOMXBufferSource

struct OmxGbs2IOmxBs : public BnOMXBufferSource {
    sp<OmxGraphicBufferSource> mBase;
    OmxGbs2IOmxBs(sp<OmxGraphicBufferSource> const& base) : mBase{base} {}
    BnStatus onOmxExecuting() override {
        return mBase->onOmxExecuting();
    }
    BnStatus onOmxIdle() override {
        return mBase->onOmxIdle();
    }
    BnStatus onOmxLoaded() override {
        return mBase->onOmxLoaded();
    }
    BnStatus onInputBufferAdded(int32_t bufferId) override {
        return mBase->onInputBufferAdded(bufferId);
    }
    BnStatus onInputBufferEmptied(
            int32_t bufferId,
            OMXFenceParcelable const& fenceParcel) override {
        return mBase->onInputBufferEmptied(bufferId, fenceParcel.get());
    }
};

struct OmxNodeWrapper : public IOmxNodeWrapper {
    sp<IOMXNode> mBase;
    OmxNodeWrapper(sp<IOMXNode> const& base) : mBase{base} {}
    status_t emptyBuffer(
            int32_t bufferId, uint32_t flags,
            const sp<GraphicBuffer> &buffer,
            int64_t timestamp, int fenceFd) override {
        return mBase->emptyBuffer(bufferId, buffer, flags, timestamp, fenceFd);
    }
    void dispatchDataSpaceChanged(
            int32_t dataSpace, int32_t aspects, int32_t pixelFormat) override {
        omx_message msg{};
        msg.type = omx_message::EVENT;
        msg.fenceFd = -1;
        msg.u.event_data.event = OMX_EventDataSpaceChanged;
        msg.u.event_data.data1 = dataSpace;
        msg.u.event_data.data2 = aspects;
        msg.u.event_data.data3 = pixelFormat;
        mBase->dispatchMessage(msg);
    }
};

} // unnamed namespace

// Omx2IGraphicBufferSource
Omx2IGraphicBufferSource::Omx2IGraphicBufferSource(
        sp<OmxGraphicBufferSource> const& base)
      : mBase{base},
        mOMXBufferSource{new OmxGbs2IOmxBs(base)} {
}

BnStatus Omx2IGraphicBufferSource::setSuspend(
        bool suspend, int64_t timeUs) {
    return BnStatus::fromStatusT(mBase->setSuspend(suspend, timeUs));
}

BnStatus Omx2IGraphicBufferSource::setRepeatPreviousFrameDelayUs(
        int64_t repeatAfterUs) {
    return BnStatus::fromStatusT(mBase->setRepeatPreviousFrameDelayUs(repeatAfterUs));
}

BnStatus Omx2IGraphicBufferSource::setMaxFps(float maxFps) {
    return BnStatus::fromStatusT(mBase->setMaxFps(maxFps));
}

BnStatus Omx2IGraphicBufferSource::setTimeLapseConfig(
        double fps, double captureFps) {
    return BnStatus::fromStatusT(mBase->setTimeLapseConfig(fps, captureFps));
}

BnStatus Omx2IGraphicBufferSource::setStartTimeUs(
        int64_t startTimeUs) {
    return BnStatus::fromStatusT(mBase->setStartTimeUs(startTimeUs));
}

BnStatus Omx2IGraphicBufferSource::setStopTimeUs(
        int64_t stopTimeUs) {
    return BnStatus::fromStatusT(mBase->setStopTimeUs(stopTimeUs));
}

BnStatus Omx2IGraphicBufferSource::getStopTimeOffsetUs(
        int64_t *stopTimeOffsetUs) {
    return BnStatus::fromStatusT(mBase->getStopTimeOffsetUs(stopTimeOffsetUs));
}

BnStatus Omx2IGraphicBufferSource::setColorAspects(
        int32_t aspects) {
    return BnStatus::fromStatusT(mBase->setColorAspects(aspects));
}

BnStatus Omx2IGraphicBufferSource::setTimeOffsetUs(
        int64_t timeOffsetsUs) {
    return BnStatus::fromStatusT(mBase->setTimeOffsetUs(timeOffsetsUs));
}

BnStatus Omx2IGraphicBufferSource::signalEndOfInputStream() {
    return BnStatus::fromStatusT(mBase->signalEndOfInputStream());
}

BnStatus Omx2IGraphicBufferSource::configure(
        const sp<IOMXNode>& omxNode, int32_t dataSpace) {
    if (omxNode == NULL) {
        return BnStatus::fromServiceSpecificError(BAD_VALUE);
    }

    // Do setInputSurface() first, the node will try to enable metadata
    // mode on input, and does necessary error checking. If this fails,
    // we can't use this input surface on the node.
    status_t err = omxNode->setInputSurface(mOMXBufferSource);
    if (err != NO_ERROR) {
        ALOGE("Unable to set input surface: %d", err);
        return BnStatus::fromServiceSpecificError(err);
    }

    uint32_t consumerUsage;
    if (omxNode->getParameter(
            (OMX_INDEXTYPE)OMX_IndexParamConsumerUsageBits,
            &consumerUsage, sizeof(consumerUsage)) != OK) {
        consumerUsage = 0;
    }

    OMX_PARAM_PORTDEFINITIONTYPE def;
    InitOMXParams(&def);
    def.nPortIndex = 0; // kPortIndexInput

    err = omxNode->getParameter(
            OMX_IndexParamPortDefinition, &def, sizeof(def));
    if (err != NO_ERROR) {
        ALOGE("Failed to get port definition: %d", err);
        return BnStatus::fromServiceSpecificError(UNKNOWN_ERROR);
    }

    return BnStatus::fromStatusT(mBase->configure(
            new OmxNodeWrapper(omxNode),
            dataSpace,
            def.nBufferCountActual,
            def.format.video.nFrameWidth,
            def.format.video.nFrameHeight,
            consumerUsage));
}

} // namespace android
Loading