自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
帧元数据
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
帧元数据作为 BufferDesc 数据结构的成员在 Android 11 中引入。这一新字段声明为 vec<uint8_t>
以适应客户定义的数据格式,并且其对 EVS 管理器而言是不透明的。
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>
表示大小动态变化的数组,其数据存储在单独的缓冲区中。此类实例由 struct 中的 vec<T>
实例表示,这意味着 EVS 相机 HAL 驱动程序实现拥有此元数据并应对其进行恰当的清理。填充元数据可以采用两种方式:
- 使用
operator[]
调整容器大小并填充数据
struct BufferDesc desc = {};
...
desc.metadata.resize(10);
for (auto i = 0; i < 10; ++i) {
desc.metadata[i] = frameInfo[i];
}
...
- 使用
setToExternal()
使 vec<T>
指向您的自定义数据结构。
struct BufferDesc desc = {};
struct FrameMetadata metadata = {
...
}; // this is in vendor-defined format.
desc.metadata.setToExternal(&metadata, sizeof(metadata));
...
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-08。
[null,null,["最后更新时间 (UTC):2025-08-08。"],[],[],null,["# Frame metadata is introduced in Android 11 as a member of the BufferDesc data\nstructure. This new field is declared as `vec\u003cuint8_t\u003e` to accommodate\na customer-defined data format and is opaque to EVS manager. \n\n```carbon\nstruct BufferDesc {\n /**\n * HIDL counterpart of AHardwareBuffer_Desc. Please see\n * hardware/interfaces/graphics/common/1.2/types.hal for more details.\n */\n HardwareBuffer buffer;\n ...\n\n /**\n * Time that this buffer is being filled.\n */\n int64_t timestamp;\n\n /**\n * Frame metadata field. This is opaque to EVS manager.\n */\n vec\u003cuint8_t\u003e metadata;\n};\n```\n\nHIDL `vec\u003cT\u003e` represents dynamically sized arrays with the data\nstored in a separate buffer. Such instances are represented with an instance of the\n`vec\u003cT\u003e` in the [struct](/devices/architecture/hidl/types#struct),\nwhich means the EVS Camera HAL driver implementation owns this metadata and should clean\nit up properly. There are two ways to fill metadata:\n\n- Resize the container and fill data by using [operator[]](https://android.googlesource.com/platform/system/libhwbinder/+/8539c12501d835979c853a249f8925ef64ecd042/include/hwbinder/HidlSupport.h#115) \n\n ```transact-sql\n struct BufferDesc desc = {};\n ...\n desc.metadata.resize(10);\n for (auto i = 0; i \u003c 10; ++i) {\n desc.metadata[i] = frameInfo[i];\n }\n ...\n \n ```\n- Use [setToExternal()](https://android.googlesource.com/platform/system/libhwbinder/+/8539c12501d835979c853a249f8925ef64ecd042/include/hwbinder/HidlSupport.h#83)`\n ` to make `vec\u003cT\u003e` point to your custom data structure. \n\n ```text\n struct BufferDesc desc = {};\n struct FrameMetadata metadata = {\n ...\n }; // this is in vendor-defined format.\n\n\n desc.metadata.setToExternal(&metadata, sizeof(metadata));\n ...\n ```"]]