Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2023 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_COMPANION_VIRTUALCAMERA_VIRTUALCAMERADEVICE_H |
| 18 | #define ANDROID_COMPANION_VIRTUALCAMERA_VIRTUALCAMERADEVICE_H |
| 19 | |
| 20 | #include <cstdint> |
| 21 | #include <memory> |
| 22 | |
| 23 | #include "aidl/android/companion/virtualcamera/IVirtualCameraCallback.h" |
| 24 | #include "aidl/android/hardware/camera/device/BnCameraDevice.h" |
| 25 | |
| 26 | namespace android { |
| 27 | namespace companion { |
| 28 | namespace virtualcamera { |
| 29 | |
| 30 | // Representation of single virtual camera device, implements |
| 31 | // ICameraDevice AIDL to expose camera to camera framework. |
| 32 | class VirtualCameraDevice |
| 33 | : public ::aidl::android::hardware::camera::device::BnCameraDevice { |
| 34 | public: |
| 35 | explicit VirtualCameraDevice( |
| 36 | uint32_t cameraId, |
| 37 | std::shared_ptr< |
| 38 | ::aidl::android::companion::virtualcamera::IVirtualCameraCallback> |
| 39 | virtualCameraClientCallback = nullptr); |
| 40 | |
| 41 | virtual ~VirtualCameraDevice() override = default; |
| 42 | |
| 43 | ndk::ScopedAStatus getCameraCharacteristics( |
| 44 | ::aidl::android::hardware::camera::device::CameraMetadata* _aidl_return) |
| 45 | override; |
| 46 | |
| 47 | ndk::ScopedAStatus getPhysicalCameraCharacteristics( |
| 48 | const std::string& in_physicalCameraId, |
| 49 | ::aidl::android::hardware::camera::device::CameraMetadata* _aidl_return) |
| 50 | override; |
| 51 | |
| 52 | ndk::ScopedAStatus getResourceCost( |
| 53 | ::aidl::android::hardware::camera::common::CameraResourceCost* |
| 54 | _aidl_return) override; |
| 55 | |
| 56 | ndk::ScopedAStatus isStreamCombinationSupported( |
| 57 | const ::aidl::android::hardware::camera::device::StreamConfiguration& |
| 58 | in_streams, |
| 59 | bool* _aidl_return) override; |
| 60 | |
| 61 | ndk::ScopedAStatus open( |
| 62 | const std::shared_ptr< |
| 63 | ::aidl::android::hardware::camera::device::ICameraDeviceCallback>& |
| 64 | in_callback, |
| 65 | std::shared_ptr< |
| 66 | ::aidl::android::hardware::camera::device::ICameraDeviceSession>* |
| 67 | _aidl_return) override; |
| 68 | |
| 69 | ndk::ScopedAStatus openInjectionSession( |
| 70 | const std::shared_ptr< |
| 71 | ::aidl::android::hardware::camera::device::ICameraDeviceCallback>& |
| 72 | in_callback, |
| 73 | std::shared_ptr< |
| 74 | ::aidl::android::hardware::camera::device::ICameraInjectionSession>* |
| 75 | _aidl_return) override; |
| 76 | |
| 77 | ndk::ScopedAStatus setTorchMode(bool in_on) override; |
| 78 | |
| 79 | ndk::ScopedAStatus turnOnTorchWithStrengthLevel( |
| 80 | int32_t in_torchStrength) override; |
| 81 | |
| 82 | ndk::ScopedAStatus getTorchStrengthLevel(int32_t* _aidl_return) override; |
| 83 | |
| 84 | binder_status_t dump(int fd, const char** args, uint32_t numArgs) override; |
| 85 | |
| 86 | // Returns unique virtual camera name in form |
| 87 | // "device@{major}.{minor}/virtual/{numerical_id}" |
| 88 | std::string getCameraName() const; |
| 89 | |
Biswarup Pal | 68137fc | 2023-11-24 18:06:54 +0000 | [diff] [blame^] | 90 | uint32_t getCameraId() const { return mCameraId; } |
| 91 | |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 92 | private: |
| 93 | const uint32_t mCameraId; |
| 94 | const std::shared_ptr< |
| 95 | ::aidl::android::companion::virtualcamera::IVirtualCameraCallback> |
| 96 | mVirtualCameraClientCallback; |
| 97 | |
| 98 | ::aidl::android::hardware::camera::device::CameraMetadata mCameraCharacteristics; |
| 99 | }; |
| 100 | |
| 101 | } // namespace virtualcamera |
| 102 | } // namespace companion |
| 103 | } // namespace android |
| 104 | |
| 105 | #endif // ANDROID_COMPANION_VIRTUALCAMERA_VIRTUALCAMERADEVICE_H |