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

Commit 7e0bef8a authored by Lajos Molnar's avatar Lajos Molnar
Browse files

stagefright: add a way to update native handle in OMX buffers

Bug: 22775369
Change-Id: I7d7eb0868fef896d1cb0a45bec759a00f0783673
parent 5adc7364
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -118,6 +118,10 @@ public:
            node_id node, OMX_U32 port_index,
            const sp<GraphicBuffer> &graphicBuffer, buffer_id buffer) = 0;

    virtual status_t updateNativeHandleInMeta(
            node_id node, OMX_U32 port_index,
            const sp<NativeHandle> &nativeHandle, buffer_id buffer) = 0;

    // This will set *type to resulting metadata buffer type on OMX error (not on binder error) as
    // well as on success.
    virtual status_t createInputSurface(
+39 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include <media/IOMX.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/openmax/OMX_IndexExt.h>
#include <utils/NativeHandle.h>

namespace android {

@@ -60,6 +61,7 @@ enum {
    SET_INTERNAL_OPTION,
    UPDATE_GRAPHIC_BUFFER_IN_META,
    CONFIGURE_VIDEO_TUNNEL_MODE,
    UPDATE_NATIVE_HANDLE_IN_META,
};

class BpOMX : public BpInterface<IOMX> {
@@ -313,6 +315,24 @@ public:
        return err;
    }

    virtual status_t updateNativeHandleInMeta(
            node_id node, OMX_U32 port_index,
            const sp<NativeHandle> &nativeHandle, buffer_id buffer) {
        Parcel data, reply;
        data.writeInterfaceToken(IOMX::getInterfaceDescriptor());
        data.writeInt32((int32_t)node);
        data.writeInt32(port_index);
        data.writeInt32(nativeHandle != NULL);
        if (nativeHandle != NULL) {
            data.writeNativeHandle(nativeHandle->handle());
        }
        data.writeInt32((int32_t)buffer);
        remote()->transact(UPDATE_NATIVE_HANDLE_IN_META, data, &reply);

        status_t err = reply.readInt32();
        return err;
    }

    virtual status_t createInputSurface(
            node_id node, OMX_U32 port_index, android_dataspace dataSpace,
            sp<IGraphicBufferProducer> *bufferProducer, MetadataBufferType *type) {
@@ -908,6 +928,25 @@ status_t BnOMX::onTransact(
            return NO_ERROR;
        }

        case UPDATE_NATIVE_HANDLE_IN_META:
        {
            CHECK_OMX_INTERFACE(IOMX, data, reply);

            node_id node = (node_id)data.readInt32();
            OMX_U32 port_index = data.readInt32();
            native_handle *handle = NULL;
            if (data.readInt32()) {
                handle = data.readNativeHandle();
            }
            buffer_id buffer = (buffer_id)data.readInt32();

            status_t err = updateNativeHandleInMeta(
                    node, port_index, NativeHandle::create(handle, true /* ownshandle */), buffer);
            reply->writeInt32(err);

            return NO_ERROR;
        }

        case CREATE_INPUT_SURFACE:
        {
            CHECK_OMX_INTERFACE(IOMX, data, reply);
+11 −0
Original line number Diff line number Diff line
@@ -111,6 +111,10 @@ struct MuxOMX : public IOMX {
            node_id node, OMX_U32 port_index,
            const sp<GraphicBuffer> &graphicBuffer, buffer_id buffer);

    virtual status_t updateNativeHandleInMeta(
            node_id node, OMX_U32 port_index,
            const sp<NativeHandle> &nativeHandle, buffer_id buffer);

    virtual status_t createInputSurface(
            node_id node, OMX_U32 port_index, android_dataspace dataSpace,
            sp<IGraphicBufferProducer> *bufferProducer, MetadataBufferType *type);
@@ -387,6 +391,13 @@ status_t MuxOMX::updateGraphicBufferInMeta(
            node, port_index, graphicBuffer, buffer);
}

status_t MuxOMX::updateNativeHandleInMeta(
        node_id node, OMX_U32 port_index,
        const sp<NativeHandle> &nativeHandle, buffer_id buffer) {
    return getOMX(node)->updateNativeHandleInMeta(
            node, port_index, nativeHandle, buffer);
}

status_t MuxOMX::createInputSurface(
        node_id node, OMX_U32 port_index, android_dataspace dataSpace,
        sp<IGraphicBufferProducer> *bufferProducer, MetadataBufferType *type) {
+4 −0
Original line number Diff line number Diff line
@@ -93,6 +93,10 @@ public:
            node_id node, OMX_U32 port_index,
            const sp<GraphicBuffer> &graphicBuffer, buffer_id buffer);

    virtual status_t updateNativeHandleInMeta(
            node_id node, OMX_U32 port_index,
            const sp<NativeHandle> &nativeHandle, buffer_id buffer);

    virtual status_t createInputSurface(
            node_id node, OMX_U32 port_index, android_dataspace dataSpace,
            sp<IGraphicBufferProducer> *bufferProducer,
+4 −0
Original line number Diff line number Diff line
@@ -79,6 +79,10 @@ struct OMXNodeInstance {
            OMX_U32 portIndex, const sp<GraphicBuffer> &graphicBuffer,
            OMX::buffer_id buffer);

    status_t updateNativeHandleInMeta(
            OMX_U32 portIndex, const sp<NativeHandle> &nativeHandle,
            OMX::buffer_id buffer);

    status_t createInputSurface(
            OMX_U32 portIndex, android_dataspace dataSpace,
            sp<IGraphicBufferProducer> *bufferProducer,
Loading