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 #pragma once 17 18 #include <mutex> 19 20 #include <android/hardware/camera/provider/2.7/ICameraProvider.h> 21 #include <hidl/MQDescriptor.h> 22 #include <hidl/Status.h> 23 #include <json/json.h> 24 25 #include "vsock_camera_device_3_4.h" 26 #include "vsock_camera_server.h" 27 #include "vsock_connection.h" 28 29 namespace android::hardware::camera::provider::V2_7::implementation { 30 31 using ::android::sp; 32 using ::android::hardware::hidl_string; 33 using ::android::hardware::Return; 34 using ::android::hardware::camera::common::V1_0::CameraDeviceStatus; 35 using ::android::hardware::camera::common::V1_0::Status; 36 using ::android::hardware::camera::common::V1_0::VendorTagSection; 37 using ::android::hardware::camera::device::V3_4::implementation:: 38 VsockCameraDevice; 39 using ::android::hardware::camera::provider::V2_4::ICameraProviderCallback; 40 using ::android::hardware::camera::provider::V2_5::DeviceState; 41 using ::android::hardware::camera::provider::V2_7::ICameraProvider; 42 43 class VsockCameraProvider : public ICameraProvider { 44 public: 45 VsockCameraProvider(VsockCameraServer* server); 46 ~VsockCameraProvider(); 47 48 Return<Status> setCallback( 49 const sp<ICameraProviderCallback>& callback) override; 50 Return<void> getVendorTags(getVendorTags_cb _hidl_cb) override; 51 Return<void> getCameraIdList(getCameraIdList_cb _hidl_cb) override; 52 Return<void> isSetTorchModeSupported( 53 isSetTorchModeSupported_cb _hidl_cb) override; 54 Return<void> getCameraDeviceInterface_V1_x( 55 const hidl_string& cameraDeviceName, 56 getCameraDeviceInterface_V1_x_cb _hidl_cb) override; 57 Return<void> getCameraDeviceInterface_V3_x( 58 const hidl_string& cameraDeviceName, 59 getCameraDeviceInterface_V3_x_cb _hidl_cb) override; 60 Return<void> notifyDeviceStateChange( 61 hardware::hidl_bitfield<DeviceState> newState) override; 62 Return<void> getConcurrentStreamingCameraIds( 63 getConcurrentStreamingCameraIds_cb _hidl_cb) override; 64 Return<void> isConcurrentStreamCombinationSupported( 65 const hidl_vec<::android::hardware::camera::provider::V2_6::CameraIdAndStreamCombination>& configs, 66 isConcurrentStreamCombinationSupported_cb _hidl_cb) override; 67 Return<void> isConcurrentStreamCombinationSupported_2_7( 68 const hidl_vec<::android::hardware::camera::provider::V2_7::CameraIdAndStreamCombination>& configs, 69 isConcurrentStreamCombinationSupported_2_7_cb _hidl_cb) override; 70 71 private: 72 void deviceRemoved(const char* name); 73 void deviceAdded(const char* name); 74 std::mutex mutex_; 75 sp<ICameraProviderCallback> callbacks_; 76 std::shared_ptr<cuttlefish::VsockConnection> connection_; 77 VsockCameraDevice::Settings settings_; 78 VsockCameraServer* server_; 79 }; 80 81 } // namespace android::hardware::camera::provider::V2_7::implementation 82