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.
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.
Tham chiếu Cấu trúc camera3_callback_ops
#include <
camera3.h
>
Định nghĩa tại dòng
của tệp
camera3.h
.
notify:
Lệnh gọi lại thông báo không đồng bộ từ HAL, được kích hoạt vì nhiều lý do. Chỉ dành cho thông tin độc lập với tính năng chụp khung hình hoặc yêu cầu thời gian cụ thể. Quyền sở hữu cấu trúc thông báo vẫn thuộc về HAL và msg chỉ cần hợp lệ trong thời gian diễn ra lệnh gọi này.
Nhiều luồng có thể gọi
notify()
đồng thời.
<= CAMERA_DEVICE_API_VERSION_3_1:
HAL phải gửi thông báo về thời điểm bắt đầu tiếp xúc cho một yêu cầu nhất định trước khi thực hiện lệnh gọi đầu tiên đến
process_capture_result()
cho yêu cầu đó.
>= CAMERA_DEVICE_API_VERSION_3_2:
Các vùng đệm được gửi đến khung sẽ không được gửi đến lớp ứng dụng cho đến khi nhận được dấu thời gian bắt đầu phơi sáng (hoặc dấu thời gian bắt đầu phơi sáng của hình ảnh đầu vào cho yêu cầu xử lý lại) thông qua lệnh gọi SHUTTER
notify()
. Bạn nên gửi lệnh gọi này càng sớm càng tốt.
Yêu cầu về hiệu suất:
Đây là một lệnh gọi không chặn. Khung sẽ trả về lệnh gọi này trong 5 mili giây.
Định nghĩa tại dòng
2499
của tệp
camera3.h
.
process_capture_result:
Gửi kết quả của một quá trình ghi hình đã hoàn tất đến khung.
process_capture_result()
có thể được HAL gọi nhiều lần để phản hồi một yêu cầu chụp duy nhất. Ví dụ: điều này cho phép siêu dữ liệu và các vùng đệm có độ phân giải thấp được trả về trong một lệnh gọi, còn các vùng đệm JPEG đã xử lý hậu kỳ trong một lệnh gọi sau đó, sau khi có sẵn. Mỗi lệnh gọi phải bao gồm số khung của yêu cầu mà lệnh gọi đó đang trả về siêu dữ liệu hoặc bộ đệm.
Một thành phần (vùng đệm hoặc siêu dữ liệu) của kết quả hoàn chỉnh chỉ có thể được đưa vào một lệnh gọi process_capture_result. HAL phải trả về một vùng đệm cho mỗi luồng và siêu dữ liệu kết quả cho mỗi yêu cầu trong một trong các lệnh gọi process_capture_result, ngay cả trong trường hợp xảy ra lỗi khiến một số đầu ra không được tạo. Không được phép gọi
process_capture_result()
mà không có vùng đệm đầu ra hoặc siêu dữ liệu kết quả.
Thứ tự trả về siêu dữ liệu và vùng đệm cho một kết quả không quan trọng, nhưng vùng đệm cho một luồng nhất định phải được trả về theo thứ tự FIFO. Vì vậy, vùng đệm cho yêu cầu 5 đối với luồng A phải luôn được trả về trước vùng đệm cho yêu cầu 6 đối với luồng A. Điều này cũng áp dụng cho siêu dữ liệu kết quả; siêu dữ liệu cho yêu cầu 5 phải được trả về trước siêu dữ liệu cho yêu cầu 6.
Tuy nhiên, các luồng khác nhau độc lập với nhau, vì vậy, có thể chấp nhận và dự kiến rằng vùng đệm cho yêu cầu 5 đối với luồng A có thể được trả về sau vùng đệm cho yêu cầu 6 đối với luồng B. Ngoài ra, có thể chấp nhận rằng siêu dữ liệu kết quả cho yêu cầu 6 đối với luồng B được trả về trước vùng đệm cho yêu cầu 5 đối với luồng A.
HAL vẫn giữ quyền sở hữu cấu trúc kết quả, chỉ cần hợp lệ để truy cập trong cuộc gọi này. Khung sẽ sao chép mọi thứ cần thiết trước khi lệnh gọi này trả về.
Bạn chưa cần điền vào các vùng đệm đầu ra; khung sẽ đợi hàng rào đồng bộ hoá phát hành vùng đệm luồng trước khi đọc dữ liệu vùng đệm. Do đó, HAL phải gọi phương thức này càng sớm càng tốt, ngay cả khi một số hoặc tất cả các vùng đệm đầu ra vẫn đang được điền. HAL phải bao gồm các hàng rào đồng bộ hoá bản phát hành hợp lệ trong mỗi mục đệm đầu ra của luồng output_buffers hoặc -1 nếu đệm luồng đó đã được lấp đầy.
Nếu không thể tạo vùng đệm kết quả cho một yêu cầu, HAL sẽ trả về một vùng đệm siêu dữ liệu trống, nhưng vẫn cung cấp các vùng đệm đầu ra và hàng rào đồng bộ hoá của chúng. Ngoài ra,
notify()
phải được gọi bằng thông báo ERROR_RESULT.
Nếu không thể điền vào vùng đệm đầu ra, thì trường trạng thái của vùng đệm đó phải được đặt thành STATUS_ERROR. Ngoài ra,
notify()
phải được gọi bằng thông báo ERROR_BUFFER.
Nếu toàn bộ quá trình ghi hình không thành công, thì bạn vẫn cần gọi phương thức này để trả lại các vùng đệm đầu ra cho khung. Tất cả trạng thái vùng đệm phải là STATUS_ERROR và siêu dữ liệu kết quả phải là một vùng đệm trống. Ngoài ra,
notify()
phải được gọi bằng thông báo ERROR_REQUEST. Trong trường hợp này, bạn không nên gửi từng thông báo ERROR_RESULT/ERROR_BUFFER.
Yêu cầu về hiệu suất:
Đây là một lệnh gọi không chặn. Khung sẽ trả về lệnh gọi này trong 5 mili giây.
Độ trễ của quy trình (xem S7 để biết định nghĩa) phải nhỏ hơn hoặc bằng 4 khoảng thời gian khung hình và phải nhỏ hơn hoặc bằng 8 khoảng thời gian khung hình.
Định nghĩa tại dòng
2466
của tệp
camera3.h
.
Tài liệu cho cấu trúc này được tạo từ tệp sau:
-
hardware/libhardware/include/hardware/
camera3.h
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-07-27 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-07-27 UTC."],[],[],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)"]]