• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_SERVERS_HIDL_CAMERA3_OUTPUT_UTILS_H
18 #define ANDROID_SERVERS_HIDL_CAMERA3_OUTPUT_UTILS_H
19 
20 #include <memory>
21 #include <mutex>
22 
23 #include <cutils/native_handle.h>
24 
25 #include <fmq/MessageQueue.h>
26 
27 #include <common/CameraDeviceBase.h>
28 
29 #include <android/hardware/camera/device/3.5/ICameraDeviceCallback.h>
30 
31 #include "device3/BufferUtils.h"
32 #include "device3/InFlightRequest.h"
33 #include "device3/Camera3Stream.h"
34 #include "device3/Camera3OutputUtils.h"
35 
36 namespace android {
37 
38 using ResultMetadataQueue = hardware::MessageQueue<uint8_t, hardware::kSynchronizedReadWrite>;
39 
40 namespace camera3 {
41 
42     /**
43      * Helper methods shared between HidlCamera3Device/HidlCamera3OfflineSession for HAL callbacks
44      */
45     // Camera3Device/Camera3OfflineSession internal states used in notify/processCaptureResult
46     // callbacks
47     struct HidlCaptureOutputStates : public CaptureOutputStates {
48         std::unique_ptr<ResultMetadataQueue>& fmq;
49     };
50 
51     // Handle one capture result. Assume callers hold the lock to serialize all
52     // processCaptureResult calls
53     void processOneCaptureResultLocked(
54             HidlCaptureOutputStates& states,
55             const hardware::camera::device::V3_2::CaptureResult& result,
56             const hardware::hidl_vec<
57                     hardware::camera::device::V3_4::PhysicalCameraMetadata>
58                             &physicalCameraMetadata);
59 
60     // Handle one notify message
61     void notify(CaptureOutputStates& states,
62             const hardware::camera::device::V3_2::NotifyMsg& msg);
63     void requestStreamBuffers(RequestBufferStates& states,
64             const hardware::hidl_vec<hardware::camera::device::V3_5::BufferRequest>& bufReqs,
65             hardware::camera::device::V3_5::ICameraDeviceCallback::requestStreamBuffers_cb
66                     _hidl_cb);
67     void returnStreamBuffers(ReturnBufferStates& states,
68             const hardware::hidl_vec<hardware::camera::device::V3_2::StreamBuffer>& buffers);
69 
70 } // namespace camera3
71 
72 } // namespace android
73 
74 #endif
75