blob: 0c95b7a3c45cbff8d282efe96a882cff1d6f4ce4 [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"
24#include "aidl/android/hardware/camera/device/BnCameraDevice.h"
25
26namespace android {
27namespace companion {
28namespace virtualcamera {
29
30// Representation of single virtual camera device, implements
31// ICameraDevice AIDL to expose camera to camera framework.
32class 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
90 private:
91 const uint32_t mCameraId;
92 const std::shared_ptr<
93 ::aidl::android::companion::virtualcamera::IVirtualCameraCallback>
94 mVirtualCameraClientCallback;
95
96 ::aidl::android::hardware::camera::device::CameraMetadata mCameraCharacteristics;
97};
98
99} // namespace virtualcamera
100} // namespace companion
101} // namespace android
102
103#endif // ANDROID_COMPANION_VIRTUALCAMERA_VIRTUALCAMERADEVICE_H