1 /* 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 36 namespace android { 37 namespace hardware { 38 namespace camera { 39 namespace device { 40 namespace V3_3 { 41 namespace implementation { 42 43 using namespace ::android::hardware::camera::device; 44 using ::android::hardware::camera::device::V3_2::CaptureRequest; 45 using ::android::hardware::camera::device::V3_2::StreamConfiguration; 46 using ::android::hardware::camera::device::V3_3::HalStreamConfiguration; 47 using ::android::hardware::camera::device::V3_3::ICameraDeviceSession; 48 using ::android::hardware::camera::common::V1_0::Status; 49 using ::android::hardware::camera::common::V1_0::helper::HandleImporter; 50 using ::android::hardware::kSynchronizedReadWrite; 51 using ::android::hardware::MessageQueue; 52 using ::android::hardware::MQDescriptorSync; 53 using ::android::hardware::Return; 54 using ::android::hardware::Void; 55 using ::android::hardware::hidl_vec; 56 using ::android::hardware::hidl_string; 57 using ::android::sp; 58 using ::android::Mutex; 59 60 struct 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 getInterfaceCameraDeviceSession67 virtual sp<V3_2::ICameraDeviceSession> getInterface() override { 68 return new TrampolineSessionInterface_3_3(this); 69 } 70 71 protected: 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); 79 private: 80 81 struct TrampolineSessionInterface_3_3 : public ICameraDeviceSession { TrampolineSessionInterface_3_3CameraDeviceSession::TrampolineSessionInterface_3_382 TrampolineSessionInterface_3_3(sp<CameraDeviceSession> parent) : 83 mParent(parent) {} 84 constructDefaultRequestSettingsCameraDeviceSession::TrampolineSessionInterface_3_385 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 configureStreamsCameraDeviceSession::TrampolineSessionInterface_3_391 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 processCaptureRequestCameraDeviceSession::TrampolineSessionInterface_3_397 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 getCaptureRequestMetadataQueueCameraDeviceSession::TrampolineSessionInterface_3_3103 virtual Return<void> getCaptureRequestMetadataQueue( 104 V3_3::ICameraDeviceSession::getCaptureRequestMetadataQueue_cb _hidl_cb) override { 105 return mParent->getCaptureRequestMetadataQueue(_hidl_cb); 106 } 107 getCaptureResultMetadataQueueCameraDeviceSession::TrampolineSessionInterface_3_3108 virtual Return<void> getCaptureResultMetadataQueue( 109 V3_3::ICameraDeviceSession::getCaptureResultMetadataQueue_cb _hidl_cb) override { 110 return mParent->getCaptureResultMetadataQueue(_hidl_cb); 111 } 112 flushCameraDeviceSession::TrampolineSessionInterface_3_3113 virtual Return<Status> flush() override { 114 return mParent->flush(); 115 } 116 closeCameraDeviceSession::TrampolineSessionInterface_3_3117 virtual Return<void> close() override { 118 return mParent->close(); 119 } 120 configureStreams_3_3CameraDeviceSession::TrampolineSessionInterface_3_3121 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 139