1 /*
2  * Copyright (C) 2021 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_PROVIDER_V2_7_CAMERAPROVIDER_H
18 #define ANDROID_HARDWARE_CAMERA_PROVIDER_V2_7_CAMERAPROVIDER_H
19 
20 #include <android/hardware/camera/provider/2.6/ICameraProviderCallback.h>
21 #include <android/hardware/camera/provider/2.7/ICameraProvider.h>
22 #include <hidl/MQDescriptor.h>
23 #include <hidl/Status.h>
24 
25 namespace android {
26 namespace hardware {
27 namespace camera {
28 namespace provider {
29 namespace V2_7 {
30 namespace implementation {
31 
32 using ::android::sp;
33 using ::android::hardware::hidl_string;
34 using ::android::hardware::hidl_vec;
35 using ::android::hardware::Return;
36 using ::android::hardware::Void;
37 using ::android::hardware::camera::common::V1_0::CameraDeviceStatus;
38 using ::android::hardware::camera::common::V1_0::Status;
39 using ::android::hardware::camera::common::V1_0::TorchModeStatus;
40 using ::android::hardware::camera::common::V1_0::VendorTag;
41 using ::android::hardware::camera::common::V1_0::VendorTagSection;
42 using ::android::hardware::camera::provider::V2_4::ICameraProviderCallback;
43 using ::android::hardware::camera::provider::V2_5::DeviceState;
44 using ::android::hardware::camera::provider::V2_7::CameraIdAndStreamCombination;
45 using ::android::hardware::camera::provider::V2_7::ICameraProvider;
46 using ::android::hidl::base::V1_0::IBase;
47 
48 // Default recommended RPC thread count for camera provider implementations
49 const int HWBINDER_THREAD_COUNT = 6;
50 
51 template <typename IMPL>
52 struct CameraProvider : public ICameraProvider {
CameraProviderCameraProvider53     CameraProvider() : impl() {}
~CameraProviderCameraProvider54     ~CameraProvider() {}
55 
56     // Caller must use this method to check if CameraProvider ctor failed
isInitFailedCameraProvider57     bool isInitFailed() { return impl.isInitFailed(); }
58 
59     // Methods from ::android::hardware::camera::provider::V2_4::ICameraProvider follow.
setCallbackCameraProvider60     Return<Status> setCallback(const sp<ICameraProviderCallback>& callback) override {
61         return impl.setCallback(callback);
62     }
63 
getVendorTagsCameraProvider64     Return<void> getVendorTags(getVendorTags_cb _hidl_cb) override {
65         return impl.getVendorTags(_hidl_cb);
66     }
67 
getCameraIdListCameraProvider68     Return<void> getCameraIdList(getCameraIdList_cb _hidl_cb) override {
69         return impl.getCameraIdList(_hidl_cb);
70     }
71 
isSetTorchModeSupportedCameraProvider72     Return<void> isSetTorchModeSupported(isSetTorchModeSupported_cb _hidl_cb) override {
73         return impl.isSetTorchModeSupported(_hidl_cb);
74     }
75 
getCameraDeviceInterface_V1_xCameraProvider76     Return<void> getCameraDeviceInterface_V1_x(const hidl_string& cameraDeviceName,
77                                                getCameraDeviceInterface_V1_x_cb _hidl_cb) override {
78         return impl.getCameraDeviceInterface_V1_x(cameraDeviceName, _hidl_cb);
79     }
80 
getCameraDeviceInterface_V3_xCameraProvider81     Return<void> getCameraDeviceInterface_V3_x(const hidl_string& cameraDeviceName,
82                                                getCameraDeviceInterface_V3_x_cb _hidl_cb) override {
83         return impl.getCameraDeviceInterface_V3_x(cameraDeviceName, _hidl_cb);
84     }
85 
86     // Methods from ::android::hardware::camera::provider::V2_5::ICameraProvider follow.
notifyDeviceStateChangeCameraProvider87     Return<void> notifyDeviceStateChange(hardware::hidl_bitfield<DeviceState> newState) override {
88         return impl.notifyDeviceStateChange(newState);
89     }
90 
91     // Methods from ::android::hardware::camera::provider::V2_7::ICameraProvider follow.
getConcurrentStreamingCameraIdsCameraProvider92     Return<void> getConcurrentStreamingCameraIds(
93             getConcurrentStreamingCameraIds_cb _hidl_cb) override {
94         return impl.getConcurrentStreamingCameraIds(_hidl_cb);
95     }
96 
isConcurrentStreamCombinationSupportedCameraProvider97     Return<void> isConcurrentStreamCombinationSupported(
98             const hidl_vec<
99                     ::android::hardware::camera::provider::V2_6::CameraIdAndStreamCombination>&
100                     configs,
101             isConcurrentStreamCombinationSupported_cb _hidl_cb) override {
102         return impl.isConcurrentStreamCombinationSupported(configs, _hidl_cb);
103     }
104 
isConcurrentStreamCombinationSupported_2_7CameraProvider105     Return<void> isConcurrentStreamCombinationSupported_2_7(
106             const hidl_vec<CameraIdAndStreamCombination>& configs,
107             isConcurrentStreamCombinationSupported_2_7_cb _hidl_cb) override {
108         return impl.isConcurrentStreamCombinationSupported_2_7(configs, _hidl_cb);
109     }
110 
111   private:
112     IMPL impl;
113 };
114 
115 }  // namespace implementation
116 }  // namespace V2_7
117 }  // namespace provider
118 }  // namespace camera
119 }  // namespace hardware
120 }  // namespace android
121 
122 #endif  // ANDROID_HARDWARE_CAMERA_PROVIDER_V2_4_CAMERAPROVIDER_H