Kể từ ngày 27 tháng 3 năm 2025, bạn nên sử dụng android-latest-release
thay vì aosp-main
để xây dựng và đóng góp cho AOSP. Để biết thêm thông tin, hãy xem phần Thay đổi đối với AOSP.
Siêu dữ liệu khung
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Siêu dữ liệu khung được giới thiệu trong Android 11 dưới dạng một thành phần của cấu trúc dữ liệu BufferDesc. Trường mới này được khai báo là vec<uint8_t>
để phù hợp với định dạng dữ liệu do khách hàng xác định và không rõ ràng đối với trình quản lý 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>
đại diện cho các mảng có kích thước động với dữ liệu được lưu trữ trong một vùng đệm riêng biệt. Các thực thể như vậy được biểu thị bằng một thực thể của vec<T>
trong cấu trúc, nghĩa là việc triển khai trình điều khiển HAL của Máy ảnh EVS sở hữu siêu dữ liệu này và phải dọn dẹp siêu dữ liệu đó đúng cách. Có hai cách để điền siêu dữ liệu:
- Thay đổi kích thước vùng chứa và điền dữ liệu bằng cách sử dụng
operator[]
struct BufferDesc desc = {};
...
desc.metadata.resize(10);
for (auto i = 0; i < 10; ++i) {
desc.metadata[i] = frameInfo[i];
}
...
- Sử dụng
setToExternal()
để vec<T>
trỏ đến cấu trúc dữ liệu tuỳ chỉnh của bạn.
struct BufferDesc desc = {};
struct FrameMetadata metadata = {
...
}; // this is in vendor-defined format.
desc.metadata.setToExternal(&metadata, sizeof(metadata));
...
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-08-08 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-08-08 UTC."],[],[],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 ```"]]