blob: 402de6cf3d146db7de9b15a9f38cc83898441ddc [file] [log] [blame]
Jan Sebechlebsky5cb39962023-11-22 17:33:07 +01001/*
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"
Jan Sebechlebsky3b478c42023-11-23 13:15:56 +010024#include "aidl/android/companion/virtualcamera/SupportedStreamConfiguration.h"
Jan Sebechlebsky5cb39962023-11-22 17:33:07 +010025#include "aidl/android/hardware/camera/device/BnCameraDevice.h"
26
27namespace android {
28namespace companion {
29namespace virtualcamera {
30
31// Representation of single virtual camera device, implements
32// ICameraDevice AIDL to expose camera to camera framework.
33class VirtualCameraDevice
34 : public ::aidl::android::hardware::camera::device::BnCameraDevice {
35 public:
36 explicit VirtualCameraDevice(
37 uint32_t cameraId,
Jan Sebechlebsky3b478c42023-11-23 13:15:56 +010038 const std::vector<
39 aidl::android::companion::virtualcamera::SupportedStreamConfiguration>&
40 supportedInputConfig,
Jan Sebechlebsky5cb39962023-11-22 17:33:07 +010041 std::shared_ptr<
42 ::aidl::android::companion::virtualcamera::IVirtualCameraCallback>
43 virtualCameraClientCallback = nullptr);
44
45 virtual ~VirtualCameraDevice() override = default;
46
47 ndk::ScopedAStatus getCameraCharacteristics(
48 ::aidl::android::hardware::camera::device::CameraMetadata* _aidl_return)
49 override;
50
51 ndk::ScopedAStatus getPhysicalCameraCharacteristics(
52 const std::string& in_physicalCameraId,
53 ::aidl::android::hardware::camera::device::CameraMetadata* _aidl_return)
54 override;
55
56 ndk::ScopedAStatus getResourceCost(
57 ::aidl::android::hardware::camera::common::CameraResourceCost*
58 _aidl_return) override;
59
60 ndk::ScopedAStatus isStreamCombinationSupported(
61 const ::aidl::android::hardware::camera::device::StreamConfiguration&
62 in_streams,
63 bool* _aidl_return) override;
64
Jan Sebechlebsky3b478c42023-11-23 13:15:56 +010065 bool isStreamCombinationSupported(
66 const ::aidl::android::hardware::camera::device::StreamConfiguration&
67 in_streams) const;
68
Jan Sebechlebsky5cb39962023-11-22 17:33:07 +010069 ndk::ScopedAStatus open(
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::ICameraDeviceSession>*
75 _aidl_return) override;
76
77 ndk::ScopedAStatus openInjectionSession(
78 const std::shared_ptr<
79 ::aidl::android::hardware::camera::device::ICameraDeviceCallback>&
80 in_callback,
81 std::shared_ptr<
82 ::aidl::android::hardware::camera::device::ICameraInjectionSession>*
83 _aidl_return) override;
84
85 ndk::ScopedAStatus setTorchMode(bool in_on) override;
86
87 ndk::ScopedAStatus turnOnTorchWithStrengthLevel(
88 int32_t in_torchStrength) override;
89
90 ndk::ScopedAStatus getTorchStrengthLevel(int32_t* _aidl_return) override;
91
92 binder_status_t dump(int fd, const char** args, uint32_t numArgs) override;
93
94 // Returns unique virtual camera name in form
95 // "device@{major}.{minor}/virtual/{numerical_id}"
96 std::string getCameraName() const;
97
Biswarup Pal68137fc2023-11-24 18:06:54 +000098 uint32_t getCameraId() const { return mCameraId; }
99
Jan Sebechlebsky5cb39962023-11-22 17:33:07 +0100100 private:
Jan Sebechlebsky0bb5e092023-12-08 16:17:54 +0100101 std::shared_ptr<VirtualCameraDevice> sharedFromThis();
102
Jan Sebechlebsky5cb39962023-11-22 17:33:07 +0100103 const uint32_t mCameraId;
104 const std::shared_ptr<
105 ::aidl::android::companion::virtualcamera::IVirtualCameraCallback>
106 mVirtualCameraClientCallback;
107
108 ::aidl::android::hardware::camera::device::CameraMetadata mCameraCharacteristics;
Jan Sebechlebsky3b478c42023-11-23 13:15:56 +0100109
110 const std::vector<
111 aidl::android::companion::virtualcamera::SupportedStreamConfiguration>
112 mSupportedInputConfigurations;
Jan Sebechlebsky5cb39962023-11-22 17:33:07 +0100113};
114
115} // namespace virtualcamera
116} // namespace companion
117} // namespace android
118
119#endif // ANDROID_COMPANION_VIRTUALCAMERA_VIRTUALCAMERADEVICE_H