1 /* 2 * Copyright (C) 2018 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_5_CAMERADEVICE_H 18 #define ANDROID_HARDWARE_CAMERA_DEVICE_V3_5_CAMERADEVICE_H 19 20 #include "CameraDeviceSession.h" 21 #include <../../../../3.4/default/include/device_v3_4_impl/CameraDevice_3_4.h> 22 23 #include <android/hardware/camera/device/3.5/ICameraDevice.h> 24 25 namespace android { 26 namespace hardware { 27 namespace camera { 28 namespace device { 29 namespace V3_5 { 30 namespace implementation { 31 32 using namespace ::android::hardware::camera::device; 33 34 using ::android::hardware::camera::common::V1_0::helper::CameraModule; 35 using ::android::hardware::Return; 36 using ::android::hardware::Void; 37 using ::android::hardware::hidl_string; 38 using ::android::hardware::camera::common::V1_0::TorchMode; 39 using ::android::hardware::camera::common::V1_0::helper::CameraModule; 40 using ::android::hardware::camera::common::V1_0::Status; 41 using ::android::sp; 42 43 struct CameraDevice : public V3_4::implementation::CameraDevice { 44 // Called by provider HAL. 45 // Provider HAL must ensure the uniqueness of CameraDevice object per cameraId, or there could 46 // be multiple CameraDevice trying to access the same physical camera. Also, provider will have 47 // to keep track of all CameraDevice objects in order to notify CameraDevice when the underlying 48 // camera is detached. 49 // Delegates nearly all work to CameraDevice_3_4 50 CameraDevice(sp<CameraModule> module, 51 const std::string& cameraId, 52 const SortedVector<std::pair<std::string, std::string>>& cameraDeviceNames); 53 virtual ~CameraDevice(); 54 getInterfaceCameraDevice55 virtual sp<V3_2::ICameraDevice> getInterface() override { 56 return new TrampolineDeviceInterface_3_5(this); 57 } 58 59 protected: 60 virtual sp<V3_2::implementation::CameraDeviceSession> createSession(camera3_device_t*, 61 const camera_metadata_t* deviceInfo, 62 const sp<V3_2::ICameraDeviceCallback>&) override; 63 64 Return<void> getPhysicalCameraCharacteristics(const hidl_string& physicalCameraId, 65 V3_5::ICameraDevice::getPhysicalCameraCharacteristics_cb _hidl_cb); 66 67 Return<void> isStreamCombinationSupported( 68 const V3_4::StreamConfiguration& streams, 69 V3_5::ICameraDevice::isStreamCombinationSupported_cb _hidl_cb); 70 71 private: 72 struct TrampolineDeviceInterface_3_5 : public ICameraDevice { TrampolineDeviceInterface_3_5CameraDevice::TrampolineDeviceInterface_3_573 TrampolineDeviceInterface_3_5(sp<CameraDevice> parent) : 74 mParent(parent) {} 75 getResourceCostCameraDevice::TrampolineDeviceInterface_3_576 virtual Return<void> getResourceCost(V3_2::ICameraDevice::getResourceCost_cb _hidl_cb) 77 override { 78 return mParent->getResourceCost(_hidl_cb); 79 } 80 getCameraCharacteristicsCameraDevice::TrampolineDeviceInterface_3_581 virtual Return<void> getCameraCharacteristics( 82 V3_2::ICameraDevice::getCameraCharacteristics_cb _hidl_cb) override { 83 return mParent->getCameraCharacteristics(_hidl_cb); 84 } 85 setTorchModeCameraDevice::TrampolineDeviceInterface_3_586 virtual Return<Status> setTorchMode(TorchMode mode) override { 87 return mParent->setTorchMode(mode); 88 } 89 openCameraDevice::TrampolineDeviceInterface_3_590 virtual Return<void> open(const sp<V3_2::ICameraDeviceCallback>& callback, 91 V3_2::ICameraDevice::open_cb _hidl_cb) override { 92 return mParent->open(callback, _hidl_cb); 93 } 94 dumpStateCameraDevice::TrampolineDeviceInterface_3_595 virtual Return<void> dumpState(const hidl_handle& fd) override { 96 return mParent->dumpState(fd); 97 } 98 getPhysicalCameraCharacteristicsCameraDevice::TrampolineDeviceInterface_3_599 virtual Return<void> getPhysicalCameraCharacteristics(const hidl_string& physicalCameraId, 100 V3_5::ICameraDevice::getPhysicalCameraCharacteristics_cb _hidl_cb) override { 101 return mParent->getPhysicalCameraCharacteristics(physicalCameraId, _hidl_cb); 102 } 103 isStreamCombinationSupportedCameraDevice::TrampolineDeviceInterface_3_5104 virtual Return<void> isStreamCombinationSupported( 105 const V3_4::StreamConfiguration& streams, 106 V3_5::ICameraDevice::isStreamCombinationSupported_cb _hidl_cb) override { 107 return mParent->isStreamCombinationSupported(streams, _hidl_cb); 108 } 109 110 private: 111 sp<CameraDevice> mParent; 112 }; 113 }; 114 115 } // namespace implementation 116 } // namespace V3_5 117 } // namespace device 118 } // namespace camera 119 } // namespace hardware 120 } // namespace android 121 122 #endif // ANDROID_HARDWARE_CAMERA_DEVICE_V3_5_CAMERADEVICE_H 123