blob: dd52b35b8e3160643cdf9dbfc168c61c477ea007 [file] [log] [blame]
Eino-Ville Talvala50fe4302017-08-22 16:15:09 -07001/*
2 * Copyright (C) 2017 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_HARDWARE_CAMERA_DEVICE_V3_3_CAMERADEVICE3SESSION_H
18#define ANDROID_HARDWARE_CAMERA_DEVICE_V3_3_CAMERADEVICE3SESSION_H
19
20#include <android/hardware/camera/device/3.2/ICameraDevice.h>
21#include <android/hardware/camera/device/3.3/ICameraDeviceSession.h>
22#include <../../3.2/default/CameraDeviceSession.h>
23#include <fmq/MessageQueue.h>
24#include <hidl/MQDescriptor.h>
25#include <hidl/Status.h>
26#include <include/convert.h>
27#include <deque>
28#include <map>
29#include <unordered_map>
30#include "CameraMetadata.h"
31#include "HandleImporter.h"
32#include "hardware/camera3.h"
33#include "hardware/camera_common.h"
34#include "utils/Mutex.h"
35
36namespace android {
37namespace hardware {
38namespace camera {
39namespace device {
40namespace V3_3 {
41namespace implementation {
42
43using namespace ::android::hardware::camera::device;
44using ::android::hardware::camera::device::V3_2::CaptureRequest;
45using ::android::hardware::camera::device::V3_2::StreamConfiguration;
46using ::android::hardware::camera::device::V3_3::HalStreamConfiguration;
47using ::android::hardware::camera::device::V3_3::ICameraDeviceSession;
48using ::android::hardware::camera::common::V1_0::Status;
49using ::android::hardware::camera::common::V1_0::helper::HandleImporter;
50using ::android::hardware::kSynchronizedReadWrite;
51using ::android::hardware::MessageQueue;
52using ::android::hardware::MQDescriptorSync;
53using ::android::hardware::Return;
54using ::android::hardware::Void;
55using ::android::hardware::hidl_vec;
56using ::android::hardware::hidl_string;
57using ::android::sp;
58using ::android::Mutex;
59
60struct CameraDeviceSession : public V3_2::implementation::CameraDeviceSession {
61
62 CameraDeviceSession(camera3_device_t*,
63 const camera_metadata_t* deviceInfo,
64 const sp<V3_2::ICameraDeviceCallback>&);
65 virtual ~CameraDeviceSession();
66
67 virtual sp<V3_2::ICameraDeviceSession> getInterface() override {
68 return new TrampolineSessionInterface_3_3(this);
69 }
70
71protected:
72 // Methods from v3.2 and earlier will trampoline to inherited implementation
73
74 // New methods for v3.3
75
76 Return<void> configureStreams_3_3(
77 const StreamConfiguration& requestedConfiguration,
78 ICameraDeviceSession::configureStreams_3_3_cb _hidl_cb);
79private:
80
81 struct TrampolineSessionInterface_3_3 : public ICameraDeviceSession {
82 TrampolineSessionInterface_3_3(sp<CameraDeviceSession> parent) :
83 mParent(parent) {}
84
85 virtual Return<void> constructDefaultRequestSettings(
86 V3_2::RequestTemplate type,
87 V3_3::ICameraDeviceSession::constructDefaultRequestSettings_cb _hidl_cb) override {
88 return mParent->constructDefaultRequestSettings(type, _hidl_cb);
89 }
90
91 virtual Return<void> configureStreams(
92 const V3_2::StreamConfiguration& requestedConfiguration,
93 V3_3::ICameraDeviceSession::configureStreams_cb _hidl_cb) override {
94 return mParent->configureStreams(requestedConfiguration, _hidl_cb);
95 }
96
97 virtual Return<void> processCaptureRequest(const hidl_vec<V3_2::CaptureRequest>& requests,
98 const hidl_vec<V3_2::BufferCache>& cachesToRemove,
99 V3_3::ICameraDeviceSession::processCaptureRequest_cb _hidl_cb) override {
100 return mParent->processCaptureRequest(requests, cachesToRemove, _hidl_cb);
101 }
102
103 virtual Return<void> getCaptureRequestMetadataQueue(
104 V3_3::ICameraDeviceSession::getCaptureRequestMetadataQueue_cb _hidl_cb) override {
105 return mParent->getCaptureRequestMetadataQueue(_hidl_cb);
106 }
107
108 virtual Return<void> getCaptureResultMetadataQueue(
109 V3_3::ICameraDeviceSession::getCaptureResultMetadataQueue_cb _hidl_cb) override {
110 return mParent->getCaptureResultMetadataQueue(_hidl_cb);
111 }
112
113 virtual Return<Status> flush() override {
114 return mParent->flush();
115 }
116
117 virtual Return<void> close() override {
118 return mParent->close();
119 }
120
121 virtual Return<void> configureStreams_3_3(
122 const StreamConfiguration& requestedConfiguration, configureStreams_3_3_cb _hidl_cb) override {
123 return mParent->configureStreams_3_3(requestedConfiguration, _hidl_cb);
124 }
125
126 private:
127 sp<CameraDeviceSession> mParent;
128 };
129};
130
131} // namespace implementation
132} // namespace V3_3
133} // namespace device
134} // namespace camera
135} // namespace hardware
136} // namespace android
137
138#endif // ANDROID_HARDWARE_CAMERA_DEVICE_V3_3_CAMERADEVICE3SESSION_H