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 "CameraMetadata.h" 19 20 #include <android/hardware/camera/device/3.2/ICameraDevice.h> 21 #include <hidl/MQDescriptor.h> 22 #include <hidl/Status.h> 23 #include "vsock_camera_device_session_3_4.h" 24 #include "vsock_camera_metadata.h" 25 #include "vsock_connection.h" 26 #include "vsock_frame_provider.h" 27 28 #include <vector> 29 30 namespace android::hardware::camera::device::V3_4::implementation { 31 32 using namespace ::android::hardware::camera::device; 33 using ::android::sp; 34 using ::android::hardware::hidl_string; 35 using ::android::hardware::hidl_vec; 36 using ::android::hardware::Return; 37 using ::android::hardware::Void; 38 using ::android::hardware::camera::common::V1_0::CameraResourceCost; 39 using ::android::hardware::camera::common::V1_0::Status; 40 using ::android::hardware::camera::common::V1_0::TorchMode; 41 using ::android::hardware::camera::device::V3_2::ICameraDevice; 42 using ::android::hardware::camera::device::V3_2::ICameraDeviceCallback; 43 44 class VsockCameraDevice : public ICameraDevice { 45 public: 46 using Settings = struct { 47 int32_t width; 48 int32_t height; 49 double frame_rate; 50 }; 51 52 VsockCameraDevice(const std::string& id, const Settings& settings, 53 std::shared_ptr<cuttlefish::VsockConnection> connection); 54 virtual ~VsockCameraDevice(); 55 56 /* Methods from ::android::hardware::camera::device::V3_2::ICameraDevice 57 * follow. */ 58 Return<void> getResourceCost(ICameraDevice::getResourceCost_cb _hidl_cb); 59 Return<void> getCameraCharacteristics( 60 ICameraDevice::getCameraCharacteristics_cb _hidl_cb); 61 Return<Status> setTorchMode(TorchMode); 62 Return<void> open(const sp<ICameraDeviceCallback>&, ICameraDevice::open_cb); 63 Return<void> dumpState(const ::android::hardware::hidl_handle&); 64 /* End of Methods from 65 * ::android::hardware::camera::device::V3_2::ICameraDevice */ 66 67 private: 68 std::string id_; 69 VsockCameraMetadata metadata_; 70 std::shared_ptr<cuttlefish::VsockConnection> connection_; 71 std::shared_ptr<cuttlefish::VsockFrameProvider> frame_provider_; 72 std::atomic<bool> is_open_; 73 sp<VsockCameraDeviceSession> session_; 74 }; 75 76 } // namespace android::hardware::camera::device::V3_4::implementation 77