• 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_CAMERA3OFFLINESESSION_H
18 #define ANDROID_SERVERS_HIDL_CAMERA3OFFLINESESSION_H
19 
20 #include <memory>
21 #include <mutex>
22 
23 #include <utils/String16.h>
24 
25 #include <android/hardware/camera/device/3.6/ICameraOfflineSession.h>
26 
27 #include <fmq/MessageQueue.h>
28 
29 #include "HidlCamera3OutputUtils.h"
30 #include "common/CameraOfflineSessionBase.h"
31 
32 #include "device3/Camera3BufferManager.h"
33 #include "device3/Camera3OfflineSession.h"
34 #include "device3/InFlightRequest.h"
35 
36 namespace android {
37 
38 namespace camera3 {
39 
40 class Camera3Stream;
41 class Camera3OutputStreamInterface;
42 class Camera3StreamInterface;
43 
44 } // namespace camera3
45 
46 /**
47  * HidlCamera3OfflineSession for offline session defined in HIDL ICameraOfflineSession@3.6 or higher
48  */
49 class HidlCamera3OfflineSession :
50             public Camera3OfflineSession,
51             virtual public hardware::camera::device::V3_5::ICameraDeviceCallback {
52   public:
53 
54     // initialize by Camera3Device.
HidlCamera3OfflineSession(const std::string & id,const sp<camera3::Camera3Stream> & inputStream,const camera3::StreamSet & offlineStreamSet,camera3::BufferRecords && bufferRecords,const camera3::InFlightRequestMap & offlineReqs,const Camera3OfflineStates & offlineStates,sp<hardware::camera::device::V3_6::ICameraOfflineSession> offlineSession)55     explicit HidlCamera3OfflineSession(const std::string& id,
56             const sp<camera3::Camera3Stream>& inputStream,
57             const camera3::StreamSet& offlineStreamSet,
58             camera3::BufferRecords&& bufferRecords,
59             const camera3::InFlightRequestMap& offlineReqs,
60             const Camera3OfflineStates& offlineStates,
61             sp<hardware::camera::device::V3_6::ICameraOfflineSession> offlineSession) :
62       Camera3OfflineSession(id, inputStream, offlineStreamSet, std::move(bufferRecords),
63               offlineReqs, offlineStates),
64       mSession(offlineSession) {};
65 
66     virtual ~HidlCamera3OfflineSession();
67 
68     virtual status_t initialize(wp<NotificationListener> listener) override;
69 
70     /**
71      * HIDL ICameraDeviceCallback interface
72      * Implementation of android::hardware::camera::device::V3_5::ICameraDeviceCallback
73      */
74 
75     hardware::Return<void> processCaptureResult_3_4(
76             const hardware::hidl_vec<
77                     hardware::camera::device::V3_4::CaptureResult>& results) override;
78     hardware::Return<void> processCaptureResult(
79             const hardware::hidl_vec<
80                     hardware::camera::device::V3_2::CaptureResult>& results) override;
81     hardware::Return<void> notify(
82             const hardware::hidl_vec<
83                     hardware::camera::device::V3_2::NotifyMsg>& msgs) override;
84 
85     hardware::Return<void> requestStreamBuffers(
86             const hardware::hidl_vec<
87                     hardware::camera::device::V3_5::BufferRequest>& bufReqs,
88             requestStreamBuffers_cb _hidl_cb) override;
89 
90     hardware::Return<void> returnStreamBuffers(
91             const hardware::hidl_vec<
92                     hardware::camera::device::V3_2::StreamBuffer>& buffers) override;
93 
94     /**
95      * End of CameraOfflineSessionBase interface
96      */
97 
98   private:
99     sp<hardware::camera::device::V3_6::ICameraOfflineSession> mSession;
100     // FMQ to write result on. Must be guarded by mProcessCaptureResultLock.
101     std::unique_ptr<ResultMetadataQueue> mResultMetadataQueue;
102 
103     virtual void closeSessionLocked() override;
104 
105     virtual void releaseSessionLocked() override;
106 }; // class Camera3OfflineSession
107 
108 }; // namespace android
109 
110 #endif
111