/* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef CPP_EVS_MANAGER_AIDL_WRAPPERS_INCLUDE_HIDLHWCAMERA_H #define CPP_EVS_MANAGER_AIDL_WRAPPERS_INCLUDE_HIDLHWCAMERA_H #include "HidlCameraStream.h" #include #include #include #include #include #include #include #include #include #include #include #include namespace aidl::android::automotive::evs::implementation { namespace aidlevs = ::aidl::android::hardware::automotive::evs; namespace hidlevs = ::android::hardware::automotive::evs; class AidlCamera : public ::aidl::android::hardware::automotive::evs::BnEvsCamera { public: // Methods from ::android::hardware::automotive::evs::IEvsCamera follow. ::ndk::ScopedAStatus doneWithFrame(const std::vector& buffers) override; ::ndk::ScopedAStatus forcePrimaryClient( const std::shared_ptr& display) override; ::ndk::ScopedAStatus getCameraInfo(aidlevs::CameraDesc* _aidl_return) override; ::ndk::ScopedAStatus getExtendedInfo(int32_t opaqueIdentifier, std::vector* value) override; ::ndk::ScopedAStatus getIntParameter(aidlevs::CameraParam id, std::vector* value) override; ::ndk::ScopedAStatus getIntParameterRange(aidlevs::CameraParam id, aidlevs::ParameterRange* _aidl_return) override; ::ndk::ScopedAStatus getParameterList(std::vector* _aidl_return) override; ::ndk::ScopedAStatus getPhysicalCameraInfo(const std::string& deviceId, aidlevs::CameraDesc* _aidl_return) override; ::ndk::ScopedAStatus importExternalBuffers(const std::vector& buffers, int32_t* _aidl_return) override; ::ndk::ScopedAStatus pauseVideoStream() override; ::ndk::ScopedAStatus resumeVideoStream() override; ::ndk::ScopedAStatus setExtendedInfo(int32_t opaqueIdentifier, const std::vector& opaqueValue) override; ::ndk::ScopedAStatus setIntParameter(aidlevs::CameraParam id, int32_t value, std::vector* effectiveValue) override; ::ndk::ScopedAStatus setPrimaryClient() override; ::ndk::ScopedAStatus setMaxFramesInFlight(int32_t bufferCount) override; ::ndk::ScopedAStatus startVideoStream( const std::shared_ptr& receiver) override; ::ndk::ScopedAStatus stopVideoStream() override; ::ndk::ScopedAStatus unsetPrimaryClient() override; explicit AidlCamera(const ::android::sp& camera, bool forceV1_0 = false); virtual ~AidlCamera() { mImpl = nullptr; } const ::android::sp getHidlCamera() const; private: class IHidlCamera; class ImplV0; class ImplV1; std::shared_ptr mImpl; }; class AidlCamera::IHidlCamera { public: virtual ::ndk::ScopedAStatus doneWithFrame(const std::vector& buffers) = 0; virtual ::ndk::ScopedAStatus forcePrimaryClient( const std::shared_ptr& display) = 0; virtual ::ndk::ScopedAStatus getCameraInfo(aidlevs::CameraDesc* _aidl_return) = 0; virtual ::ndk::ScopedAStatus getExtendedInfo(int32_t opaqueIdentifier, std::vector* value) = 0; virtual ::ndk::ScopedAStatus getIntParameter(aidlevs::CameraParam id, std::vector* value) = 0; virtual ::ndk::ScopedAStatus getIntParameterRange(aidlevs::CameraParam id, aidlevs::ParameterRange* _aidl_return) = 0; virtual ::ndk::ScopedAStatus getParameterList( std::vector* _aidl_return) = 0; virtual ::ndk::ScopedAStatus getPhysicalCameraInfo(const std::string& deviceId, aidlevs::CameraDesc* _aidl_return) = 0; virtual ::ndk::ScopedAStatus importExternalBuffers( const std::vector& buffers, int32_t* _aidl_return) = 0; virtual ::ndk::ScopedAStatus pauseVideoStream() = 0; virtual ::ndk::ScopedAStatus resumeVideoStream() = 0; virtual ::ndk::ScopedAStatus setExtendedInfo(int32_t opaqueIdentifier, const std::vector& opaqueValue) = 0; virtual ::ndk::ScopedAStatus setIntParameter(aidlevs::CameraParam id, int32_t value, std::vector* effectiveValue) = 0; virtual ::ndk::ScopedAStatus setPrimaryClient() = 0; virtual ::ndk::ScopedAStatus setMaxFramesInFlight(int32_t bufferCount) = 0; virtual ::ndk::ScopedAStatus startVideoStream( const std::shared_ptr& receiver) = 0; virtual ::ndk::ScopedAStatus stopVideoStream() = 0; virtual ::ndk::ScopedAStatus unsetPrimaryClient() = 0; virtual const ::android::sp getHidlCamera() const = 0; explicit IHidlCamera(const ::android::sp& camera) : mHidlCamera(camera) {} virtual ~IHidlCamera() { mHidlCamera = nullptr; mHidlStream = nullptr; } protected: // The low level camera interface that backs this proxy ::android::sp mHidlCamera; ::android::sp mHidlStream; std::string mId; }; class AidlCamera::ImplV0 final : public IHidlCamera { public: ::ndk::ScopedAStatus doneWithFrame(const std::vector& buffers) override; ::ndk::ScopedAStatus forcePrimaryClient( const std::shared_ptr& display) override; ::ndk::ScopedAStatus getCameraInfo(aidlevs::CameraDesc* _aidl_return) override; ::ndk::ScopedAStatus getExtendedInfo(int32_t opaqueIdentifier, std::vector* value) override; ::ndk::ScopedAStatus getIntParameter(aidlevs::CameraParam id, std::vector* value) override; ::ndk::ScopedAStatus getIntParameterRange(aidlevs::CameraParam id, aidlevs::ParameterRange* _aidl_return) override; ::ndk::ScopedAStatus getParameterList(std::vector* _aidl_return) override; ::ndk::ScopedAStatus getPhysicalCameraInfo(const std::string& deviceId, aidlevs::CameraDesc* _aidl_return) override; ::ndk::ScopedAStatus importExternalBuffers(const std::vector& buffers, int32_t* _aidl_return) override; ::ndk::ScopedAStatus pauseVideoStream() override; ::ndk::ScopedAStatus resumeVideoStream() override; ::ndk::ScopedAStatus setExtendedInfo(int32_t opaqueIdentifier, const std::vector& opaqueValue) override; ::ndk::ScopedAStatus setIntParameter(aidlevs::CameraParam id, int32_t value, std::vector* effectiveValue) override; ::ndk::ScopedAStatus setPrimaryClient() override; ::ndk::ScopedAStatus setMaxFramesInFlight(int32_t bufferCount) override; ::ndk::ScopedAStatus startVideoStream( const std::shared_ptr& receiver) override; ::ndk::ScopedAStatus stopVideoStream() override; ::ndk::ScopedAStatus unsetPrimaryClient() override; explicit ImplV0(const ::android::sp& camera); virtual ~ImplV0() { mHidlCamera = nullptr; }; const ::android::sp getHidlCamera() const override { return mHidlCamera; } }; class AidlCamera::ImplV1 final : public IHidlCamera { public: ::ndk::ScopedAStatus doneWithFrame(const std::vector& buffers) override; ::ndk::ScopedAStatus forcePrimaryClient( const std::shared_ptr& display) override; ::ndk::ScopedAStatus getCameraInfo(aidlevs::CameraDesc* _aidl_return) override; ::ndk::ScopedAStatus getExtendedInfo(int32_t opaqueIdentifier, std::vector* value) override; ::ndk::ScopedAStatus getIntParameter(aidlevs::CameraParam id, std::vector* value) override; ::ndk::ScopedAStatus getIntParameterRange(aidlevs::CameraParam id, aidlevs::ParameterRange* _aidl_return) override; ::ndk::ScopedAStatus getParameterList(std::vector* _aidl_return) override; ::ndk::ScopedAStatus getPhysicalCameraInfo(const std::string& deviceId, aidlevs::CameraDesc* _aidl_return) override; ::ndk::ScopedAStatus importExternalBuffers(const std::vector& buffers, int32_t* _aidl_return) override; ::ndk::ScopedAStatus pauseVideoStream() override; ::ndk::ScopedAStatus resumeVideoStream() override; ::ndk::ScopedAStatus setExtendedInfo(int32_t opaqueIdentifier, const std::vector& opaqueValue) override; ::ndk::ScopedAStatus setIntParameter(aidlevs::CameraParam id, int32_t value, std::vector* effectiveValue) override; ::ndk::ScopedAStatus setPrimaryClient() override; ::ndk::ScopedAStatus setMaxFramesInFlight(int32_t bufferCount) override; ::ndk::ScopedAStatus startVideoStream( const std::shared_ptr& receiver) override; ::ndk::ScopedAStatus stopVideoStream() override; ::ndk::ScopedAStatus unsetPrimaryClient() override; explicit ImplV1(const ::android::sp& camera); virtual ~ImplV1() { mHidlCamera = nullptr; } const ::android::sp getHidlCamera() const override { return mHidlCamera; } private: ::android::sp mHidlCamera; }; } // namespace aidl::android::automotive::evs::implementation #endif // CPP_EVS_MANAGER_AIDL_WRAPPERS_INCLUDE_HIDLHWCAMERA_H