Google is committed to advancing racial equity for Black communities. See how.

Frame Metadata

Frame metadata is introduced in Android 11 as a member of the BufferDesc data structure. This new field is declared as vec<uint8_t> to accommodate a customer-defined data format and is opaque to EVS manager.

struct BufferDesc {
    /**
     * HIDL counterpart of AHardwareBuffer_Desc. Please see
     * hardware/interfaces/graphics/common/1.2/types.hal for more details.
     */
    HardwareBuffer buffer;
    ...

    /**
     * Time that this buffer is being filled.
     */
    int64_t timestamp;

    /**
     * Frame metadata field. This is opaque to EVS manager.
     */
    vec<uint8_t> metadata;
};

HIDL vec<T> represents dynamically-sized arrays with the data stored in a separate buffer. Such instances are represented with an instance of the vec<T> in the struct, which means the EVS Camera HAL driver implementation owns this metadata and should clean it up properly. There are two ways to fill metadata:

  • Resize the container and fill data by using operator[]
        struct BufferDesc desc = {};
        ...
        desc.metadata.resize(10);
        for (auto i = 0; i < 10; ++i) {
            desc.metadata[i] = frameInfo[i];
        }
        ...
        
  • Use setToExternal() to make vec<T> point to your custom data structure.
    struct BufferDesc desc = {};
    struct FrameMetadata metadata = {
       ...
    }; // this is in vendor-defined format.
    
    desc.metadata.setToExternal(&metadata, sizeof(metadata)); ...