自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
camera3_callback_ops 结构参考
#include <
camera3.h
>
文件
camera3.h
第 2397 行的定义。
notify:
来自 HAL 的异步通知回调,因各种原因触发。仅适用于与帧捕获无关或需要特定时间的信息。消息结构的所有权仍归 HAL 所有,并且消息只需在此调用期间有效。
多个线程可以同时调用
notify()
。
<= CAMERA_DEVICE_API_VERSION_3_1:
HAL 必须在首次针对给定请求调用
process_capture_result()
之前,发送有关该请求开始曝光的通知。
>= CAMERA_DEVICE_API_VERSION_3_2:
在通过 SHUTTER
notify()
调用收到曝光开始时间戳(或重新处理请求的输入图像的曝光开始时间戳)之前,传递给框架的缓冲区不会调度到应用层。强烈建议您尽早调度此调用。
性能要求:
这是一个非阻塞调用。框架将在 5 毫秒内返回此调用。
第 2499 行的定义
文件
camera3.h
。
process_capture_result:
将已完成捕获的结果发送到框架。
process_capture_result()
可能会被 HAL 调用多次,以响应单个捕获请求。这样一来,例如,可以在一次调用中返回元数据和低分辨率缓冲区,并在稍后的调用中返回后处理的 JPEG 缓冲区(一旦可用)。每次调用都必须包含相应请求的帧号,该请求用于返回元数据或缓冲区。
完整结果的某个组成部分(缓冲区或元数据)可能仅包含在一个 process_capture_result 调用中。对于每个请求,HAL 必须通过一次 process_capture_result 调用返回每个数据流的缓冲区和结果元数据,即使在生成部分输出时发生错误也是如此。不允许在不使用输出缓冲区或结果元数据的情况下调用
process_capture_result()
。
返回单个结果的元数据和缓冲区的顺序无关紧要,但给定流的缓冲区必须按 FIFO 顺序返回。因此,数据流 A 的请求 5 的缓冲区必须始终在数据流 A 的请求 6 的缓冲区之前返回。这也适用于结果元数据;必须先返回请求 5 的元数据,然后才能返回请求 6 的元数据。
不过,不同的流是相互独立的,因此流 A 的请求 5 的缓冲区可能会在流 B 的请求 6 的缓冲区之后返回,这是可以接受的,也是预期之中的。流 B 的请求 6 的结果元数据可能会在流 A 的请求 5 的缓冲区之前返回,这也是可以接受的。
HAL 保留结果结构的所有权,该结构只需在本次调用期间有效即可。框架会在此调用返回之前复制所需的一切内容。
输出缓冲区尚无需填充;框架将等待流缓冲区释放同步栅栏,然后再读取缓冲区数据。因此,即使部分或全部输出缓冲区仍在填充中,HAL 也应尽快调用此方法。HAL 必须在每个 output_buffers 流缓冲区条目中包含有效的版本同步栅栏,如果该流缓冲区已填充,则包含 -1。
如果无法为请求构建结果缓冲区,HAL 应返回一个空的元数据缓冲区,但仍应提供输出缓冲区及其同步栅栏。此外,还必须使用 ERROR_RESULT 消息调用
notify()
。
如果无法填充输出缓冲区,则必须将其状态字段设置为 STATUS_ERROR。此外,必须使用 ERROR_BUFFER 消息调用 notify()。
notify()
必须使用 ERROR_BUFFER 消息调用。
如果整个拍摄过程失败,仍需调用此方法以将输出缓冲区返回到框架。所有缓冲区状态都应为 STATUS_ERROR,并且结果元数据应为空缓冲区。此外,必须使用 ERROR_REQUEST 消息调用 notify()。
在这种情况下,不应发送各个 ERROR_RESULT/ERROR_BUFFER 消息。
性能要求:
这是一个非阻塞调用。框架将在 5 毫秒内返回此调用。
流水线延迟时间(定义见 S7)应小于或等于 4 个帧间隔,且必须小于或等于 8 个帧间隔。
文件
camera3.h
第 2466 行的定义。
此结构体的文档是从以下文件生成的:
-
hardware/libhardware/include/hardware/
camera3.h
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Android Hardware Abstraction Layer: camera3_callback_ops Struct Reference\n\ncamera3_callback_ops Struct Reference\n=====================================\n\n[Data Fields](#pub-attribs) \ncamera3_callback_ops Struct Reference \n\n`\n#include \u003c\n`[camera3.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/camera3.h)`\n\u003e\n`\n\n|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Data Fields ----------- ||\n| void(\\* | [process_capture_result](/reference/hal/structcamera3__callback__ops#a2f7cf688a195532999b8498d6ef15e45) )(const struct [camera3_callback_ops](/reference/hal/structcamera3__callback__ops) \\*, const [camera3_capture_result_t](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/camera3.h) \\*result) |\n| ||\n| void(\\* | [notify](/reference/hal/structcamera3__callback__ops#a6d702d6e962f95105b984b17462619b3) )(const struct [camera3_callback_ops](/reference/hal/structcamera3__callback__ops) \\*, const [camera3_notify_msg_t](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/camera3.h) \\*msg) |\n| ||\n\n\nDetailed Description\n--------------------\n\n\nDefinition at line\n[2397](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/camera3.h)\nof file\n[camera3.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/camera3.h)\n.\n\nField Documentation\n-------------------\n\n\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| void(\\* notify)(const struct [camera3_callback_ops](/reference/hal/structcamera3__callback__ops) \\*, const [camera3_notify_msg_t](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/camera3.h) \\*msg) |\n\n\nnotify:\n\n\nAsynchronous notification callback from the HAL, fired for various reasons. Only for information independent of frame capture, or that require specific timing. The ownership of the message structure remains with the HAL, and the msg only needs to be valid for the duration of this call.\n\n\nMultiple threads may call\n[notify()](/reference/hal/structcamera3__callback__ops#a6d702d6e962f95105b984b17462619b3)\nsimultaneously.\n\n\n\\\u003c= CAMERA_DEVICE_API_VERSION_3_1:\n\n\nThe notification for the start of exposure for a given request must be sent by the HAL before the first call to\n[process_capture_result()](/reference/hal/structcamera3__callback__ops#a2f7cf688a195532999b8498d6ef15e45)\nfor that request is made.\n\n\n\\\u003e= CAMERA_DEVICE_API_VERSION_3_2:\n\n\nBuffers delivered to the framework will not be dispatched to the application layer until a start of exposure timestamp (or input image's start of exposure timestamp for a reprocess request) has been received via a SHUTTER\n[notify()](/reference/hal/structcamera3__callback__ops#a6d702d6e962f95105b984b17462619b3)\ncall. It is highly recommended to dispatch this call as early as possible.\n\n*** ** * ** ***\n\n\nPerformance requirements:\n\n\nThis is a non-blocking call. The framework will return this call in 5ms.\n\n\nDefinition at line\n[2499](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/camera3.h)\nof file\n[camera3.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/camera3.h)\n.\n\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| void(\\* process_capture_result)(const struct [camera3_callback_ops](/reference/hal/structcamera3__callback__ops) \\*, const [camera3_capture_result_t](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/camera3.h) \\*result) |\n\n\nprocess_capture_result:\n\n\nSend results from a completed capture to the framework.\n[process_capture_result()](/reference/hal/structcamera3__callback__ops#a2f7cf688a195532999b8498d6ef15e45)\nmay be invoked multiple times by the HAL in response to a single capture request. This allows, for example, the metadata and low-resolution buffers to be returned in one call, and post-processed JPEG buffers in a later call, once it is available. Each call must include the frame number of the request it is returning metadata or buffers for.\n\n\nA component (buffer or metadata) of the complete result may only be included in one process_capture_result call. A buffer for each stream, and the result metadata, must be returned by the HAL for each request in one of the process_capture_result calls, even in case of errors producing some of the output. A call to\n[process_capture_result()](/reference/hal/structcamera3__callback__ops#a2f7cf688a195532999b8498d6ef15e45)\nwith neither output buffers or result metadata is not allowed.\n\n\nThe order of returning metadata and buffers for a single result does not matter, but buffers for a given stream must be returned in FIFO order. So the buffer for request 5 for stream A must always be returned before the buffer for request 6 for stream A. This also applies to the result metadata; the metadata for request 5 must be returned before the metadata for request 6.\n\n\nHowever, different streams are independent of each other, so it is acceptable and expected that the buffer for request 5 for stream A may be returned after the buffer for request 6 for stream B is. And it is acceptable that the result metadata for request 6 for stream B is returned before the buffer for request 5 for stream A is.\n\n\nThe HAL retains ownership of result structure, which only needs to be valid to access during this call. The framework will copy whatever it needs before this call returns.\n\n\nThe output buffers do not need to be filled yet; the framework will wait on the stream buffer release sync fence before reading the buffer data. Therefore, this method should be called by the HAL as soon as possible, even if some or all of the output buffers are still in being filled. The HAL must include valid release sync fences into each output_buffers stream buffer entry, or -1 if that stream buffer is already filled.\n\n\nIf the result buffer cannot be constructed for a request, the HAL should return an empty metadata buffer, but still provide the output buffers and their sync fences. In addition,\n[notify()](/reference/hal/structcamera3__callback__ops#a6d702d6e962f95105b984b17462619b3)\nmust be called with an ERROR_RESULT message.\n\n\nIf an output buffer cannot be filled, its status field must be set to STATUS_ERROR. In addition,\n[notify()](/reference/hal/structcamera3__callback__ops#a6d702d6e962f95105b984b17462619b3)\nmust be called with a ERROR_BUFFER message.\n\n\nIf the entire capture has failed, then this method still needs to be called to return the output buffers to the framework. All the buffer statuses should be STATUS_ERROR, and the result metadata should be an empty buffer. In addition,\n[notify()](/reference/hal/structcamera3__callback__ops#a6d702d6e962f95105b984b17462619b3)\nmust be called with a ERROR_REQUEST message. In this case, individual ERROR_RESULT/ERROR_BUFFER messages should not be sent.\n\n\nPerformance requirements:\n\n\nThis is a non-blocking call. The framework will return this call in 5ms.\n\n\nThe pipeline latency (see S7 for definition) should be less than or equal to 4 frame intervals, and must be less than or equal to 8 frame intervals.\n\n\nDefinition at line\n[2466](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/camera3.h)\nof file\n[camera3.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/camera3.h)\n.\n\n*** ** * ** ***\n\nThe documentation for this struct was generated from the following file:\n\n- hardware/libhardware/include/hardware/ [camera3.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/camera3.h)"]]