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

Commit 120c4da8 authored by Pawin Vongmasa's avatar Pawin Vongmasa
Browse files

Use HIDL's memory for shared memory and add wrapper interfaces for

IGraphicBufferProducer.

Test: Compiles
Bug: 31399200
Change-Id: I17a3b1c8f20e9c11474761d120edd2e75353cc6d
parent c91e7fb9
Loading
Loading
Loading
Loading
+11 −16
Original line number Diff line number Diff line
@@ -40,7 +40,9 @@ struct AnwBufferAttributes {
    uint32_t stride;
    PixelFormat format;
    uint32_t usage; // TODO: convert to an enum
    uint32_t generationNumber;
    uint64_t layerCount;
    uint64_t id;
};

/**
@@ -52,25 +54,18 @@ struct AnwBuffer {
};

/**
 * Ref: frameworks/native/include/binder/IMemory.h
 * Ref: frameworks/native/libs/binder/IMemory.cpp
 * Ref: frameworks/native/include/android/rect.h
 * Ref: frameworks/native/include/ui/Rect.h
 */

/**
 * This struct contains attributes for a shared memory buffer that can be put
 * into a union.
 */
struct SharedMemoryAttributes {
    uint32_t size;
    uint32_t flags; // TODO: convert to an enum
    uint32_t offset;
struct Rect {
    int32_t left;
    int32_t top;
    int32_t right;
    int32_t bottom;
};

/**
 * A SharedMemory is simply SharedMemoryAttributes plus a native handle.
 * Ref: frameworks/native/include/ui/Region.h
 */
struct SharedMemory {
    handle nativeHandle;
    SharedMemoryAttributes attr;
};
typedef vec<Rect> Region;
+16 −0
Original line number Diff line number Diff line
@@ -8,17 +8,21 @@ genrule {
        "types.hal",
        "IGraphicBufferSource.hal",
        "IOmx.hal",
        "IOmxBufferProducer.hal",
        "IOmxBufferSource.hal",
        "IOmxNode.hal",
        "IOmxObserver.hal",
        "IOmxProducerListener.hal",
    ],
    out: [
        "android/hardware/media/omx/1.0/types.cpp",
        "android/hardware/media/omx/1.0/GraphicBufferSourceAll.cpp",
        "android/hardware/media/omx/1.0/OmxAll.cpp",
        "android/hardware/media/omx/1.0/OmxBufferProducerAll.cpp",
        "android/hardware/media/omx/1.0/OmxBufferSourceAll.cpp",
        "android/hardware/media/omx/1.0/OmxNodeAll.cpp",
        "android/hardware/media/omx/1.0/OmxObserverAll.cpp",
        "android/hardware/media/omx/1.0/OmxProducerListenerAll.cpp",
    ],
}

@@ -30,9 +34,11 @@ genrule {
        "types.hal",
        "IGraphicBufferSource.hal",
        "IOmx.hal",
        "IOmxBufferProducer.hal",
        "IOmxBufferSource.hal",
        "IOmxNode.hal",
        "IOmxObserver.hal",
        "IOmxProducerListener.hal",
    ],
    out: [
        "android/hardware/media/omx/1.0/types.h",
@@ -46,6 +52,11 @@ genrule {
        "android/hardware/media/omx/1.0/BnHwOmx.h",
        "android/hardware/media/omx/1.0/BpHwOmx.h",
        "android/hardware/media/omx/1.0/BsOmx.h",
        "android/hardware/media/omx/1.0/IOmxBufferProducer.h",
        "android/hardware/media/omx/1.0/IHwOmxBufferProducer.h",
        "android/hardware/media/omx/1.0/BnOmxBufferProducer.h",
        "android/hardware/media/omx/1.0/BpOmxBufferProducer.h",
        "android/hardware/media/omx/1.0/BsOmxBufferProducer.h",
        "android/hardware/media/omx/1.0/IOmxBufferSource.h",
        "android/hardware/media/omx/1.0/IHwOmxBufferSource.h",
        "android/hardware/media/omx/1.0/BnHwOmxBufferSource.h",
@@ -61,6 +72,11 @@ genrule {
        "android/hardware/media/omx/1.0/BnHwOmxObserver.h",
        "android/hardware/media/omx/1.0/BpHwOmxObserver.h",
        "android/hardware/media/omx/1.0/BsOmxObserver.h",
        "android/hardware/media/omx/1.0/IOmxProducerListener.h",
        "android/hardware/media/omx/1.0/IHwOmxProducerListener.h",
        "android/hardware/media/omx/1.0/BnOmxProducerListener.h",
        "android/hardware/media/omx/1.0/BpOmxProducerListener.h",
        "android/hardware/media/omx/1.0/BsOmxProducerListener.h",
    ],
}

+22 −8
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import android.hardware.media@1.0::types;

import IOmxNode;
import IOmxObserver;
import IOmxBufferProducer;
import IGraphicBufferSource;

/**
 * Ref: frameworks/av/include/media/IOMX.h: IOMX
@@ -32,15 +34,15 @@ interface IOmx {
     * Information for an IOmxNode component.
     */
    struct ComponentInfo {
        string mName;       //< Name of the component.
        vec<string> mRoles; //< Roles of the component.
        string mName;
        vec<string> mRoles;
    };

    /**
     * List available components.
     *
     * @param[out] status will be the status of the call.
     * @param[out] nodeList will be a list of ComponentInfo.
     * @param[out] status The status of the call.
     * @param[out] nodeList The list of ComponentInfo.
     */
    listNodes(
        ) generates (
@@ -51,11 +53,11 @@ interface IOmx {
    /**
     * Allocate an IOmxNode instance with the specified component name.
     *
     * @param[in] name is the name of the component to create.
     * @param[in] observer is an observer object that will receive messages from
     * @param[in] name The name of the component to create.
     * @param[in] observer An observer object that will receive messages from
     * the created instance.
     * @param[out] status will be the status of the call.
     * @param[out] omxNode will be the allocated instance of IOmxNode.
     * @param[out] status The status of the call.
     * @param[out] omxNode The allocated instance of IOmxNode.
     */
    allocateNode(
            string name,
@@ -65,5 +67,17 @@ interface IOmx {
            IOmxNode omxNode
        );

    /**
     * Create an input surface for recording.
     *
     * @param[out] producer The associated producer end of the buffer queue.
     * @param[out] source The associated `IGraphicBufferSource`.
     */
    createInputSurface(
        ) generates (
            Status status,
            IOmxBufferProducer producer,
            IGraphicBufferSource source
        );
};
+693 −0

File added.

Preview size limit exceeded, changes collapsed.

+84 −77
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ interface IOmxNode {
    /**
     * Free the node.
     *
     * @param[out] status will be the status of the call.
     * @param[out] status Status of the call.
     */
    freeNode(
        ) generates (
@@ -45,9 +45,9 @@ interface IOmxNode {
    /**
     * Invoke a command on the node.
     *
     * @param[in] cmd indicates the type of the command.
     * @param[in] param is a parameter for the command.
     * @param[out] status will be the status of the call.
     * @param[in] cmd Type of the command.
     * @param[in] param Parameter for the command.
     * @param[out] status Status of the call.
     *
     * @see OMX_SendCommand() in the OpenMax IL standard.
     */
@@ -61,33 +61,33 @@ interface IOmxNode {
    /**
     * Retrieve a parameter setting from the node.
     *
     * @param[in] index indicates the type of the parameter to retrieve.
     * @param[in] inParams holds some information about the retrieval.
     * @param[out] status will be the status of the call.
     * @param[out] outParams will be the current parameter setting.
     * @param[in] index Type of the parameter to retrieve.
     * @param[in] inParams Information about the retrieval.
     * @param[out] status Status of the call.
     * @param[out] outParams Current parameter setting.
     *
     * @see OMX_GetParameter() in the OpenMax IL standard.
     */
    getParameter(
            uint32_t index,
            Bytes inParams // TODO: describe structure better or point at standard
            Bytes inParams
        ) generates (
            Status status,
            Bytes outParams // TODO: describe structure better or point at standard
            Bytes outParams
        );

    /**
     * Change a parameter setting of the node.
     *
     * @param[in] index indicates the type of the parameter to change.
     * @param[in] params holds the new parameter setting.
     * @param[out] status will be the status of the call.
     * @param[in] index Type of the parameter to change.
     * @param[in] params New parameter setting.
     * @param[out] status Status of the call.
     *
     * @see OMX_SetParameter() in the OpenMax IL standard.
     */
    setParameter(
            uint32_t index,
            Bytes params // TODO: describe structure better or point at standard
            Bytes params
        ) generates (
            Status status
        );
@@ -95,33 +95,33 @@ interface IOmxNode {
    /**
     * Retrieve a configuration from the node.
     *
     * @param[in] index indicates the type of the configuration to retrieve.
     * @param[in] inConfig holds some information about the retrieval.
     * @param[out] status will be the status of the call.
     * @param[out] outConfig will be the current configuration.
     * @param[in] index Type of the configuration to retrieve.
     * @param[in] inConfig Information about the retrieval.
     * @param[out] status Status of the call.
     * @param[out] outConfig Current configuration.
     *
     * @see OMX_GetConfig() in the OpenMax IL standard.
     */
    getConfig(
            uint32_t index,
            Bytes inConfig // TODO: describe structure better or point at standard
            Bytes inConfig
        ) generates (
            Status status,
            Bytes outConfig // TODO: describe structure better or point at standard
            Bytes outConfig
        );

    /**
     * Change a configuration of the node.
     *
     * @param[in] index indicates the type of the configuration to change.
     * @param[in] config holds the new configuration.
     * @param[out] status will be the status of the call.
     * @param[in] index Type of the configuration to change.
     * @param[in] config New configuration.
     * @param[out] status Status of the call.
     *
     * @see OMX_SetConfig() in the OpenMax IL standard.
     */
    setConfig(
            uint32_t index,
            Bytes config // TODO: describe structure better or point at standard
            Bytes config
        ) generates (
            Status status
        );
@@ -129,8 +129,9 @@ interface IOmxNode {
    /**
     * Set the mode of a port on the node.
     *
     * @param[in] portIndex is the index of the port.
     * @param[in] mode is the target mode on the specified port.
     * @param[in] portIndex Index of the port.
     * @param[in] mode Target mode on the specified port.
     * @param[out] status Status of the call.
     */
    setPortMode(
            uint32_t portIndex,
@@ -143,11 +144,11 @@ interface IOmxNode {
     * Prepare a port for adaptive playback. This is based on the extension
     * "OMX.google.android.index.prepareForAdaptivePlayback".
     *
     * @param[in] portIndex is the index of the port.
     * @param[in] enable indicates whether adaptive playback is enabled or not.
     * @param[in] maxFrameWidth specifies the maximum frame width.
     * @param[in] maxFrameHeight specifies the maximum frame height.
     * @param[out] status status will be the status of the call.
     * @param[in] portIndex Index of the port.
     * @param[in] enable Whether the adaptive playback is enabled or not.
     * @param[in] maxFrameWidth Maximum frame width.
     * @param[in] maxFrameHeight Maximum frame height.
     * @param[out] status Status of the call.
     */
    prepareForAdaptivePlayback(
            uint32_t portIndex,
@@ -162,13 +163,12 @@ interface IOmxNode {
     * Configure a port for a tunneled playback mode. This is based on the
     * extension "OMX.google.android.index.configureVideoTunnelMode".
     *
     * @param[in] portIndex is the index of the port.
     * @param[in] tunneled indicates whether the tunneled mode is used or not.
     * @param[in] audioHwSync is the HW SYNC ID of the audio HAL output stream
     * to sync the video with.
     * @param[out] status will be the status of the call.
     * @param[out] sidebandHandle will contain the codec-allocated sideband
     * window handle.
     * @param[in] portIndex Index of the port.
     * @param[in] tunneled Whether the tunneled mode is used or not.
     * @param[in] audioHwSync HW SYNC ID of the audio HAL output stream to sync
     * the video with.
     * @param[out] status Status of the call.
     * @param[out] sidebandHandle Codec-allocated sideband window handle.
     */
    configureVideoTunnelMode(
            uint32_t portIndex,
@@ -183,23 +183,23 @@ interface IOmxNode {
     * Retrieve the buffer usage on a port. This is based on the extension
     * "OMX.google.android.index.getAndroidNativeBufferUsage".
     *
     * @param[in] portIndex is the index of the port.
     * @param[out] status will be the status of the call.
     * @param[out] usage will be the usage.
     * @param[in] portIndex Index of the port.
     * @param[out] status Status of the call.
     * @param[out] usage Current graphic buffer usage.
     */
    getGraphicBufferUsage(
            uint32_t portIndex
        ) generates (
            Status status,
            uint32_t usage // TODO: Ask graphics team to define an enum.
            uint32_t usage
        );

    /**
     * Set up a listener to events related to the input surface.
     *
     * @param[in] bufferSource is the listener object that implements
     * @param[in] bufferSource Listener object that implements
     * IOmxBufferSource.
     * @param[out] status will be the status of the call.
     * @param[out] status Status of the call.
     *
     * @see IOmxBufferSource.
     */
@@ -212,13 +212,12 @@ interface IOmxNode {
    /**
     * Allocate an opaque buffer on a port as a native handle.
     *
     * @param[in] portIndex is the index of the port.
     * @param[in] size is the desired size of the buffer.
     * @param[out] status will be the status of the call.
     * @param[out] buffer will be the id of the allocated buffer, which will be
     * needed in some other buffer-related function calls.
     * @param[out] nativeHandle will be the native handle of the allocated
     * buffer.
     * @param[in] portIndex Index of the port.
     * @param[in] size Desired size of the buffer.
     * @param[out] status Status of the call.
     * @param[out] buffer Id of the allocated buffer, which will be needed in
     * other buffer-related functions.
     * @param[out] nativeHandle Native handle of the allocated buffer.
     *
     * @see OMX_AllocateBuffer() in the OpenMax IL standard.
     */
@@ -234,11 +233,11 @@ interface IOmxNode {
    /**
     * Assign a buffer to a port.
     *
     * @param[in] portIndex is the index of the port.
     * @param[in] omxBuffer is the buffer to be assigned to the port.
     * @param[out] status will be the status of the call.
     * @param[out] buffer will be the id of the assigned buffer, which will be
     * needed in some other buffer-related function calls.
     * @param[in] portIndex Index of the port.
     * @param[in] omxBuffer Buffer to be assigned to the port.
     * @param[out] status Status of the call.
     * @param[out] buffer Id of the assigned buffer, which will be needed in
     * other buffer-related functions.
     *
     * @see OMX_UseBuffer() in the OpenMax IL standard.
     */
@@ -254,9 +253,9 @@ interface IOmxNode {
     * Free a buffer previously assigned to a port by allocateSecureBuffer() or
     * useBuffer().
     *
     * @param[in] portIndex is the index of the port.
     * @param[in] buffer is the id of the buffer to be freed.
     * @param[out] status will be the status of the call.
     * @param[in] portIndex Index of the port.
     * @param[in] buffer Id of the buffer to be freed.
     * @param[out] status Status of the call.
     *
     * @see OMX_FreeBuffer() in the OpenMax IL standard.
     */
@@ -276,10 +275,10 @@ interface IOmxNode {
     * the new buffer passed in via \p omxBuffer before OMX_FillThisBuffer() is
     * called. Otherwise, \p omxBuffer is not used.
     *
     * @param[in] buffer is the id of the buffer to fill.
     * @param[in] omxBuffer points to the new buffer in metadata mode.
     * @param[in] fence is the fence to wait for (if not null).
     * @param[out] status is the status of the call.
     * @param[in] buffer Id of the buffer to fill.
     * @param[in] omxBuffer New buffer information (in metadata mode).
     * @param[in] fence Fence to wait for (if not null).
     * @param[out] status Status of the call.
     *
     * @see OMX_FillThisBuffer() in the OpenMax IL standard.
     */
@@ -300,21 +299,19 @@ interface IOmxNode {
     * the new buffer passed in via \p omxBuffer before OMX_EmptyThisBuffer() is
     * called. Otherwise, \p omxBuffer is not used.
     *
     * @param[in] buffer is the id of the buffer to fill.
     * @param[in] omxBuffer points to the new buffer in metadata mode.
     * @param[in] flags is put into the header information that is passed to
     * OMX_EmptyBuffer().
     * @param[in] timestampUs is put into the header information that is passed
     * to OMX_EmptyBuffer().
     * @param[in] fence is the fence to wait for (if not null).
     * @param[out] status is the status of the call.
     * @param[in] buffer Id of the buffer to fill.
     * @param[in] omxBuffer New buffer information (in metadata mode).
     * @param[in] flags Flags to be passed to OMX_EmptyBuffer().
     * @param[in] timestampUs Timestamp OMX_EmptyBuffer().
     * @param[in] fence Fence to wait for (if not null).
     * @param[out] status Status of the call.
     *
     * @see OMX_EmptyThisBuffer() in the OpenMax IL standard.
     */
    emptyBuffer(
            BufferId buffer,
            CodecBuffer omxBuffer,
            uint32_t flags, // TODO: describe structure better or point at standard
            uint32_t flags,
            uint64_t timestampUs,
            Fence fence
        ) generates (
@@ -324,9 +321,9 @@ interface IOmxNode {
    /**
     * Request the node to translate an extension string to an index.
     *
     * @param[in] parameterName is the requested extension string.
     * @param[out] status is the status of the call.
     * @param[out] index is the translated index.
     * @param[in] parameterName Requested extension string.
     * @param[out] status Status of the call.
     * @param[out] index Translated index.
     *
     * @see OMX_GetExtensionIndex() in the OpenMax IL standard.
     */
@@ -343,8 +340,8 @@ interface IOmxNode {
     * receive the message in batches by the callback
     * IOmxObserver::onMessages().
     *
     * @param[in] msg is the message to send.
     * @param[out] status is the status of the call.
     * @param[in] msg Message to send.
     * @param[out] status Status of the call.
     *
     * @see IOmxObserver::onMessages().
     */
@@ -354,5 +351,15 @@ interface IOmxNode {
            Status status
        );

    /**
     * Set quirks.
     *
     * @param[in] quirks Quirks for the component, generally obtained from
     * MediaCodecList::getQuirksFor().
     */
    oneway setQuirks(
            uint32_t quirks
        );

};
Loading