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

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

Merge "Revert "Revert "media: remove IGraphicBufferSource.aidl"""

parents bdb7b5d4 9917d4ab
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@ cc_library_shared {
        "CCodecConfig.cpp",
        "Codec2Buffer.cpp",
        "Codec2InfoBuilder.cpp",
        "Omx2IGraphicBufferSource.cpp",
        "PipelineWatcher.cpp",
        "ReflectedParamUpdater.cpp",
        "SkipCutBuffer.cpp",
+53 −48
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@
#include <C2ParamInternal.h>
#include <C2PlatformSupport.h>

#include <android/IGraphicBufferSource.h>
#include <android/IOMXBufferSource.h>
#include <android/hardware/media/omx/1.0/IGraphicBufferSource.h>
#include <android/hardware/media/omx/1.0/IOmx.h>
@@ -35,8 +34,11 @@
#include <gui/IGraphicBufferProducer.h>
#include <gui/Surface.h>
#include <gui/bufferqueue/1.0/H2BGraphicBufferProducer.h>
#include <media/omx/1.0/WGraphicBufferSource.h>
#include <media/omx/1.0/WOmxNode.h>
#include <media/openmax/OMX_Core.h>
#include <media/openmax/OMX_IndexExt.h>
#include <media/stagefright/omx/1.0/WGraphicBufferSource.h>
#include <media/stagefright/omx/OmxGraphicBufferSource.h>
#include <media/stagefright/BufferProducerWrapper.h>
#include <media/stagefright/MediaCodecConstants.h>
#include <media/stagefright/PersistentSurface.h>
@@ -45,7 +47,6 @@
#include "CCodec.h"
#include "CCodecBufferChannel.h"
#include "InputSurfaceWrapper.h"
#include "Omx2IGraphicBufferSource.h"

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

@@ -54,9 +55,10 @@ namespace android {
using namespace std::chrono_literals;
using ::android::hardware::graphics::bufferqueue::V1_0::utils::H2BGraphicBufferProducer;
using android::base::StringPrintf;
using BGraphicBufferSource = ::android::IGraphicBufferSource;
using ::android::hardware::media::c2::V1_0::IInputSurface;

typedef hardware::media::omx::V1_0::IGraphicBufferSource HGraphicBufferSource;

namespace {

class CCodecWatchdog : public AHandler {
@@ -180,9 +182,10 @@ private:

class GraphicBufferSourceWrapper : public InputSurfaceWrapper {
public:
//    explicit GraphicBufferSourceWrapper(const sp<BGraphicBufferSource> &source) : mSource(source) {}
    typedef hardware::media::omx::V1_0::Status OmxStatus;

    GraphicBufferSourceWrapper(
            const sp<BGraphicBufferSource> &source,
            const sp<HGraphicBufferSource> &source,
            uint32_t width,
            uint32_t height,
            uint64_t usage)
@@ -194,6 +197,7 @@ public:

    status_t connect(const std::shared_ptr<Codec2Client::Component> &comp) override {
        mNode = new C2OMXNode(comp);
        mOmxNode = new hardware::media::omx::V1_0::utils::TWOmxNode(mNode);
        mNode->setFrameSize(mWidth, mHeight);

        // Usage is queried during configure(), so setting it beforehand.
@@ -204,7 +208,8 @@ public:

        // NOTE: we do not use/pass through color aspects from GraphicBufferSource as we
        // communicate that directly to the component.
        mSource->configure(mNode, mDataSpace);
        mSource->configure(
                mOmxNode, static_cast<hardware::graphics::common::V1_0::Dataspace>(mDataSpace));
        return OK;
    }

@@ -220,21 +225,16 @@ public:
        source->onOmxIdle();
        source->onOmxLoaded();
        mNode.clear();
        mOmxNode.clear();
    }

    status_t GetStatus(const binder::Status &status) {
        status_t err = OK;
        if (!status.isOk()) {
            err = status.serviceSpecificErrorCode();
            if (err == OK) {
                err = status.transactionError();
                if (err == OK) {
                    // binder status failed, but there is no servie or transaction error
                    err = UNKNOWN_ERROR;
                }
    status_t GetStatus(hardware::Return<OmxStatus> &&status) {
        if (status.isOk()) {
            return static_cast<status_t>(status.withDefault(OmxStatus::UNKNOWN_ERROR));
        } else if (status.isDeadObject()) {
            return DEAD_OBJECT;
        }
        }
        return err;
        return UNKNOWN_ERROR;
    }

    status_t start() override {
@@ -359,7 +359,15 @@ public:
                err = res;
            } else {
                status << " delayUs";
                res = GetStatus(mSource->getStopTimeOffsetUs(&config.mInputDelayUs));
                hardware::Return<void> trans = mSource->getStopTimeOffsetUs(
                        [&res, &delayUs = config.mInputDelayUs](
                                auto status, auto stopTimeOffsetUs) {
                            res = static_cast<status_t>(status);
                            delayUs = stopTimeOffsetUs;
                        });
                if (!trans.isOk()) {
                    res = trans.isDeadObject() ? DEAD_OBJECT : UNKNOWN_ERROR;
                }
                if (res != OK) {
                    status << " (=> " << asString(res) << ")";
                } else {
@@ -388,8 +396,9 @@ public:
    }

private:
    sp<BGraphicBufferSource> mSource;
    sp<HGraphicBufferSource> mSource;
    sp<C2OMXNode> mNode;
    sp<hardware::media::omx::V1_0::IOmxNode> mOmxNode;
    uint32_t mWidth;
    uint32_t mHeight;
    Config mConfig;
@@ -1092,9 +1101,7 @@ sp<PersistentSurface> CCodec::CreateOmxInputSurface() {
                gbs = source;
            });
    if (transStatus.isOk() && s == OmxStatus::OK) {
        return new PersistentSurface(
                new H2BGraphicBufferProducer(gbp),
                sp<::android::IGraphicBufferSource>(new LWGraphicBufferSource(gbs)));
        return new PersistentSurface(new H2BGraphicBufferProducer(gbp), gbs);
    }

    return nullptr;
@@ -1125,28 +1132,28 @@ void CCodec::createInputSurface() {
    }

    sp<PersistentSurface> persistentSurface = CreateCompatibleInputSurface();
    sp<hidl::base::V1_0::IBase> hidlTarget = persistentSurface->getHidlTarget();
    sp<IInputSurface> hidlInputSurface = IInputSurface::castFrom(hidlTarget);
    sp<HGraphicBufferSource> gbs = HGraphicBufferSource::castFrom(hidlTarget);

    if (persistentSurface->getHidlTarget()) {
        sp<IInputSurface> hidlInputSurface = IInputSurface::castFrom(
                persistentSurface->getHidlTarget());
        if (!hidlInputSurface) {
            ALOGE("Corrupted input surface");
            mCallback->onInputSurfaceCreationFailed(UNKNOWN_ERROR);
            return;
        }
    if (hidlInputSurface) {
        std::shared_ptr<Codec2Client::InputSurface> inputSurface =
                std::make_shared<Codec2Client::InputSurface>(hidlInputSurface);
        err = setupInputSurface(std::make_shared<C2InputSurfaceWrapper>(
                inputSurface));
        bufferProducer = inputSurface->getGraphicBufferProducer();
    } else {
    } else if (gbs) {
        int32_t width = 0;
        (void)outputFormat->findInt32("width", &width);
        int32_t height = 0;
        (void)outputFormat->findInt32("height", &height);
        err = setupInputSurface(std::make_shared<GraphicBufferSourceWrapper>(
                persistentSurface->getBufferSource(), width, height, usage));
                gbs, width, height, usage));
        bufferProducer = persistentSurface->getBufferProducer();
    } else {
        ALOGE("Corrupted input surface");
        mCallback->onInputSurfaceCreationFailed(UNKNOWN_ERROR);
        return;
    }

    if (err != OK) {
@@ -1212,15 +1219,10 @@ void CCodec::setInputSurface(const sp<PersistentSurface> &surface) {
        outputFormat = config->mOutputFormat;
        usage = config->mISConfig ? config->mISConfig->mUsage : 0;
    }
    auto hidlTarget = surface->getHidlTarget();
    if (hidlTarget) {
        sp<IInputSurface> inputSurface =
                IInputSurface::castFrom(hidlTarget);
        if (!inputSurface) {
            ALOGE("Failed to set input surface: Corrupted surface.");
            mCallback->onInputSurfaceDeclined(UNKNOWN_ERROR);
            return;
        }
    sp<hidl::base::V1_0::IBase> hidlTarget = surface->getHidlTarget();
    sp<IInputSurface> inputSurface = IInputSurface::castFrom(hidlTarget);
    sp<HGraphicBufferSource> gbs = HGraphicBufferSource::castFrom(hidlTarget);
    if (inputSurface) {
        status_t err = setupInputSurface(std::make_shared<C2InputSurfaceWrapper>(
                std::make_shared<Codec2Client::InputSurface>(inputSurface)));
        if (err != OK) {
@@ -1228,18 +1230,22 @@ void CCodec::setInputSurface(const sp<PersistentSurface> &surface) {
            mCallback->onInputSurfaceDeclined(err);
            return;
        }
    } else {
    } else if (gbs) {
        int32_t width = 0;
        (void)outputFormat->findInt32("width", &width);
        int32_t height = 0;
        (void)outputFormat->findInt32("height", &height);
        status_t err = setupInputSurface(std::make_shared<GraphicBufferSourceWrapper>(
                surface->getBufferSource(), width, height, usage));
                gbs, width, height, usage));
        if (err != OK) {
            ALOGE("Failed to set up input surface: %d", err);
            mCallback->onInputSurfaceDeclined(err);
            return;
        }
    } else {
        ALOGE("Failed to set input surface: Corrupted surface.");
        mCallback->onInputSurfaceDeclined(UNKNOWN_ERROR);
        return;
    }
    mCallback->onInputSurfaceAccepted(inputFormat, outputFormat);
}
@@ -1867,6 +1873,7 @@ extern "C" android::CodecBase *CreateCodec() {
// Create Codec 2.0 input surface
extern "C" android::PersistentSurface *CreateInputSurface() {
    using namespace android;
    using ::android::hardware::media::omx::V1_0::implementation::TWGraphicBufferSource;
    // Attempt to create a Codec2's input surface.
    std::shared_ptr<Codec2Client::InputSurface> inputSurface =
            Codec2Client::CreateInputSurface();
@@ -1880,9 +1887,7 @@ extern "C" android::PersistentSurface *CreateInputSurface() {
                return nullptr;
            }
            return new PersistentSurface(
                    gbs->getIGraphicBufferProducer(),
                    sp<IGraphicBufferSource>(
                        new Omx2IGraphicBufferSource(gbs)));
                    gbs->getIGraphicBufferProducer(), new TWGraphicBufferSource(gbs));
        } else {
            return nullptr;
        }
+0 −2
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ cc_library_headers {
filegroup {
    name: "libmedia_omx_aidl",
    srcs: [
        "aidl/android/IGraphicBufferSource.aidl",
        "aidl/android/IOMXBufferSource.aidl",
    ],
    path: "aidl",
@@ -53,7 +52,6 @@ cc_library_shared {
        "IOMX.cpp",
        "MediaCodecBuffer.cpp",
        "OMXBuffer.cpp",
        "omx/1.0/WGraphicBufferSource.cpp",
        "omx/1.0/WOmxBufferSource.cpp",
        "omx/1.0/WOmxNode.cpp",
        "omx/1.0/WOmxObserver.cpp",
+0 −1
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@
#include <utils/NativeHandle.h>

#include <media/omx/1.0/WOmxNode.h>
#include <android/IGraphicBufferSource.h>
#include <android/IOMXBufferSource.h>

namespace android {
+10 −2
Original line number Diff line number Diff line
@@ -34,9 +34,17 @@
#include <media/openmax/OMX_VideoExt.h>

namespace android {
namespace hardware {
namespace media {
namespace omx {
namespace V1_0 {
struct IGraphicBufferSource;
}  // namespace V1_0
}  // namespace omx
}  // namespace media
}  // namespace hardware

class IGraphicBufferProducer;
class IGraphicBufferSource;
class IMemory;
class IOMXBufferSource;
class IOMXNode;
@@ -82,7 +90,7 @@ public:

    virtual status_t createInputSurface(
            sp<IGraphicBufferProducer> *bufferProducer,
            sp<IGraphicBufferSource> *bufferSource) = 0;
            sp<hardware::media::omx::V1_0::IGraphicBufferSource> *bufferSource) = 0;
};

class IOMXNode : public IInterface {
Loading