1 /* 2 * Copyright (C) 2022 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 CPP_EVS_MANAGER_AIDL_WRAPPERS_INCLUDE_HIDLCAMERA_H 18 #define CPP_EVS_MANAGER_AIDL_WRAPPERS_INCLUDE_HIDLCAMERA_H 19 20 #include "AidlCameraStream.h" 21 22 #include <aidl/android/hardware/automotive/evs/BnEvsCamera.h> 23 #include <aidl/android/hardware/automotive/evs/BufferDesc.h> 24 #include <aidl/android/hardware/automotive/evs/CameraDesc.h> 25 #include <aidl/android/hardware/automotive/evs/CameraParam.h> 26 #include <aidl/android/hardware/automotive/evs/EvsEventDesc.h> 27 #include <aidl/android/hardware/automotive/evs/EvsResult.h> 28 #include <aidl/android/hardware/automotive/evs/IEvsCameraStream.h> 29 #include <aidl/android/hardware/automotive/evs/IEvsDisplay.h> 30 #include <aidl/android/hardware/automotive/evs/ParameterRange.h> 31 #include <aidl/android/hardware/automotive/evs/Stream.h> 32 #include <android/hardware/automotive/evs/1.1/IEvsCamera.h> 33 34 #include <unordered_map> 35 36 namespace aidl::android::automotive::evs::implementation { 37 38 namespace aidlevs = ::aidl::android::hardware::automotive::evs; 39 namespace hidlevs = ::android::hardware::automotive::evs; 40 41 class HidlCamera final : public hidlevs::V1_1::IEvsCamera { 42 public: 43 // Methods from ::android::hardware::automotive::evs::V1_0::IEvsCamera follow. 44 ::android::hardware::Return<void> getCameraInfo(getCameraInfo_cb _hidl_cb) override; 45 ::android::hardware::Return<hidlevs::V1_0::EvsResult> setMaxFramesInFlight( 46 uint32_t bufferCount) override; 47 ::android::hardware::Return<hidlevs::V1_0::EvsResult> startVideoStream( 48 const ::android::sp<::android::hardware::automotive::evs::V1_0::IEvsCameraStream>& 49 stream) override; 50 ::android::hardware::Return<void> doneWithFrame( 51 const hidlevs::V1_0::BufferDesc& buffer) override; 52 ::android::hardware::Return<void> stopVideoStream() override; 53 ::android::hardware::Return<int32_t> getExtendedInfo(uint32_t opaqueIdentifier) override; 54 ::android::hardware::Return<hidlevs::V1_0::EvsResult> setExtendedInfo( 55 uint32_t opaqueIdentifier, int32_t opaqueValue) override; 56 57 // Methods from ::android::hardware::automotive::evs::V1_1::IEvsCamera follow. 58 ::android::hardware::Return<void> getCameraInfo_1_1(getCameraInfo_1_1_cb _hidl_cb) override; 59 ::android::hardware::Return<void> getPhysicalCameraInfo( 60 const ::android::hardware::hidl_string& deviceId, 61 getPhysicalCameraInfo_cb _hidl_cb) override; 62 ::android::hardware::Return<hidlevs::V1_0::EvsResult> doneWithFrame_1_1( 63 const ::android::hardware::hidl_vec<hidlevs::V1_1::BufferDesc>& buffer) override; pauseVideoStream()64 ::android::hardware::Return<hidlevs::V1_0::EvsResult> pauseVideoStream() override { 65 return hidlevs::V1_0::EvsResult::UNDERLYING_SERVICE_ERROR; 66 } resumeVideoStream()67 ::android::hardware::Return<hidlevs::V1_0::EvsResult> resumeVideoStream() override { 68 return hidlevs::V1_0::EvsResult::UNDERLYING_SERVICE_ERROR; 69 } 70 ::android::hardware::Return<hidlevs::V1_0::EvsResult> setMaster() override; 71 ::android::hardware::Return<hidlevs::V1_0::EvsResult> forceMaster( 72 const ::android::sp<hidlevs::V1_0::IEvsDisplay>& display) override; 73 ::android::hardware::Return<hidlevs::V1_0::EvsResult> unsetMaster() override; 74 ::android::hardware::Return<void> getParameterList(getParameterList_cb _hidl_cb) override; 75 ::android::hardware::Return<void> getIntParameterRange( 76 hidlevs::V1_1::CameraParam id, getIntParameterRange_cb _hidl_cb) override; 77 ::android::hardware::Return<void> setIntParameter(hidlevs::V1_1::CameraParam id, int32_t value, 78 setIntParameter_cb _hidl_cb) override; 79 ::android::hardware::Return<void> getIntParameter(hidlevs::V1_1::CameraParam id, 80 getIntParameter_cb _hidl_cb) override; 81 ::android::hardware::Return<hidlevs::V1_0::EvsResult> setExtendedInfo_1_1( 82 uint32_t opaqueIdentifier, 83 const ::android::hardware::hidl_vec<uint8_t>& opaqueValue) override; 84 ::android::hardware::Return<void> getExtendedInfo_1_1(uint32_t opaqueIdentifier, 85 getExtendedInfo_1_1_cb _hidl_cb) override; 86 ::android::hardware::Return<void> importExternalBuffers( 87 const ::android::hardware::hidl_vec<hidlevs::V1_1::BufferDesc>& buffers, 88 importExternalBuffers_cb _hidl_cb) override; 89 HidlCamera(const std::shared_ptr<aidlevs::IEvsCamera> & camera)90 explicit HidlCamera(const std::shared_ptr<aidlevs::IEvsCamera>& camera) : mAidlCamera(camera) {} 91 virtual ~HidlCamera(); 92 getAidlCamera()93 const std::shared_ptr<aidlevs::IEvsCamera> getAidlCamera() const { return mAidlCamera; } 94 95 private: 96 // The low level camera interface that backs this proxy 97 std::shared_ptr<aidlevs::IEvsCamera> mAidlCamera; 98 std::shared_ptr<AidlCameraStream> mAidlStream; 99 }; 100 101 } // namespace aidl::android::automotive::evs::implementation 102 103 #endif // CPP_EVS_MANAGER_AIDL_WRAPPERS_INCLUDE_HIDLCAMERA_H 104