Loading automotive/evs/aidl/impl/default/include/EvsCameraBase.h 0 → 100644 +43 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 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. */ #pragma once #include <aidl/android/hardware/automotive/evs/BnEvsCamera.h> namespace aidl::android::hardware::automotive::evs::implementation { class EvsCameraBase : public evs::BnEvsCamera { private: using Base = evs::BnEvsCamera; using Self = EvsCameraBase; public: using Base::Base; ~EvsCameraBase() override = default; virtual void shutdown() = 0; protected: // This is used for the derived classes and it prevents constructors from direct access // while it allows this class to be instantiated via ndk::SharedRefBase::make<>. struct Sigil { explicit Sigil() = default; }; }; } // namespace aidl::android::hardware::automotive::evs::implementation automotive/evs/aidl/impl/default/include/EvsEnumerator.h +2 −2 Original line number Diff line number Diff line Loading @@ -17,8 +17,8 @@ #pragma once #include "ConfigManager.h" #include "EvsCameraBase.h" #include "EvsGlDisplay.h" #include "EvsMockCamera.h" #include <aidl/android/frameworks/automotive/display/ICarDisplayProxy.h> #include <aidl/android/hardware/automotive/evs/BnEvsEnumerator.h> Loading Loading @@ -72,7 +72,7 @@ class EvsEnumerator final : public ::aidl::android::hardware::automotive::evs::B private: struct CameraRecord { evs::CameraDesc desc; std::weak_ptr<EvsMockCamera> activeInstance; std::weak_ptr<EvsCameraBase> activeInstance; CameraRecord(const char* cameraId) : desc() { desc.id = cameraId; } }; Loading automotive/evs/aidl/impl/default/include/EvsMockCamera.h +5 −10 Original line number Diff line number Diff line Loading @@ -17,8 +17,8 @@ #pragma once #include "ConfigManager.h" #include "EvsCameraBase.h" #include <aidl/android/hardware/automotive/evs/BnEvsCamera.h> #include <aidl/android/hardware/automotive/evs/BufferDesc.h> #include <aidl/android/hardware/automotive/evs/CameraDesc.h> #include <aidl/android/hardware/automotive/evs/CameraParam.h> Loading @@ -36,14 +36,7 @@ namespace aidl::android::hardware::automotive::evs::implementation { class EvsMockCamera : public evs::BnEvsCamera { // This prevents constructors from direct access while it allows this class to // be instantiated via ndk::SharedRefBase::make<>. private: struct Sigil { explicit Sigil() = default; }; class EvsMockCamera : public EvsCameraBase { public: // Methods from ::android::hardware::automotive::evs::IEvsCamera follow. ndk::ScopedAStatus doneWithFrame(const std::vector<evs::BufferDesc>& buffers) override; Loading Loading @@ -81,7 +74,9 @@ class EvsMockCamera : public evs::BnEvsCamera { EvsMockCamera& operator=(const EvsMockCamera&) = delete; virtual ~EvsMockCamera() override; void shutdown(); // Methods from EvsCameraBase follow. void shutdown() override; const evs::CameraDesc& getDesc() { return mDescription; } Loading automotive/evs/aidl/impl/default/src/EvsEnumerator.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #include "EvsEnumerator.h" #include "ConfigManager.h" #include "EvsCameraBase.h" #include "EvsGlDisplay.h" #include "EvsMockCamera.h" Loading Loading @@ -243,7 +244,7 @@ ScopedAStatus EvsEnumerator::openCamera(const std::string& id, const Stream& cfg } // Has this camera already been instantiated by another caller? std::shared_ptr<EvsMockCamera> pActiveCamera = pRecord->activeInstance.lock(); std::shared_ptr<EvsCameraBase> pActiveCamera = pRecord->activeInstance.lock(); if (pActiveCamera) { LOG(WARNING) << "Killing previous camera because of new caller"; closeCamera(pActiveCamera); Loading Loading @@ -273,7 +274,7 @@ ScopedAStatus EvsEnumerator::openCamera(const std::string& id, const Stream& cfg pRecord->activeInstance = pActiveCamera; if (!pActiveCamera) { LOG(ERROR) << "Failed to create new EvsMockCamera object for " << id; LOG(ERROR) << "Failed to create new EVS camera object for " << id; return ScopedAStatus::fromServiceSpecificError( static_cast<int>(EvsResult::UNDERLYING_SERVICE_ERROR)); } Loading Loading @@ -460,7 +461,7 @@ void EvsEnumerator::closeCamera_impl(const std::shared_ptr<IEvsCamera>& pCamera, if (!pRecord) { LOG(ERROR) << "Asked to close a camera whose name isn't recognized"; } else { std::shared_ptr<EvsMockCamera> pActiveCamera = pRecord->activeInstance.lock(); std::shared_ptr<EvsCameraBase> pActiveCamera = pRecord->activeInstance.lock(); if (!pActiveCamera) { LOG(WARNING) << "Somehow a camera is being destroyed " << "when the enumerator didn't know one existed"; Loading Loading
automotive/evs/aidl/impl/default/include/EvsCameraBase.h 0 → 100644 +43 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 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. */ #pragma once #include <aidl/android/hardware/automotive/evs/BnEvsCamera.h> namespace aidl::android::hardware::automotive::evs::implementation { class EvsCameraBase : public evs::BnEvsCamera { private: using Base = evs::BnEvsCamera; using Self = EvsCameraBase; public: using Base::Base; ~EvsCameraBase() override = default; virtual void shutdown() = 0; protected: // This is used for the derived classes and it prevents constructors from direct access // while it allows this class to be instantiated via ndk::SharedRefBase::make<>. struct Sigil { explicit Sigil() = default; }; }; } // namespace aidl::android::hardware::automotive::evs::implementation
automotive/evs/aidl/impl/default/include/EvsEnumerator.h +2 −2 Original line number Diff line number Diff line Loading @@ -17,8 +17,8 @@ #pragma once #include "ConfigManager.h" #include "EvsCameraBase.h" #include "EvsGlDisplay.h" #include "EvsMockCamera.h" #include <aidl/android/frameworks/automotive/display/ICarDisplayProxy.h> #include <aidl/android/hardware/automotive/evs/BnEvsEnumerator.h> Loading Loading @@ -72,7 +72,7 @@ class EvsEnumerator final : public ::aidl::android::hardware::automotive::evs::B private: struct CameraRecord { evs::CameraDesc desc; std::weak_ptr<EvsMockCamera> activeInstance; std::weak_ptr<EvsCameraBase> activeInstance; CameraRecord(const char* cameraId) : desc() { desc.id = cameraId; } }; Loading
automotive/evs/aidl/impl/default/include/EvsMockCamera.h +5 −10 Original line number Diff line number Diff line Loading @@ -17,8 +17,8 @@ #pragma once #include "ConfigManager.h" #include "EvsCameraBase.h" #include <aidl/android/hardware/automotive/evs/BnEvsCamera.h> #include <aidl/android/hardware/automotive/evs/BufferDesc.h> #include <aidl/android/hardware/automotive/evs/CameraDesc.h> #include <aidl/android/hardware/automotive/evs/CameraParam.h> Loading @@ -36,14 +36,7 @@ namespace aidl::android::hardware::automotive::evs::implementation { class EvsMockCamera : public evs::BnEvsCamera { // This prevents constructors from direct access while it allows this class to // be instantiated via ndk::SharedRefBase::make<>. private: struct Sigil { explicit Sigil() = default; }; class EvsMockCamera : public EvsCameraBase { public: // Methods from ::android::hardware::automotive::evs::IEvsCamera follow. ndk::ScopedAStatus doneWithFrame(const std::vector<evs::BufferDesc>& buffers) override; Loading Loading @@ -81,7 +74,9 @@ class EvsMockCamera : public evs::BnEvsCamera { EvsMockCamera& operator=(const EvsMockCamera&) = delete; virtual ~EvsMockCamera() override; void shutdown(); // Methods from EvsCameraBase follow. void shutdown() override; const evs::CameraDesc& getDesc() { return mDescription; } Loading
automotive/evs/aidl/impl/default/src/EvsEnumerator.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #include "EvsEnumerator.h" #include "ConfigManager.h" #include "EvsCameraBase.h" #include "EvsGlDisplay.h" #include "EvsMockCamera.h" Loading Loading @@ -243,7 +244,7 @@ ScopedAStatus EvsEnumerator::openCamera(const std::string& id, const Stream& cfg } // Has this camera already been instantiated by another caller? std::shared_ptr<EvsMockCamera> pActiveCamera = pRecord->activeInstance.lock(); std::shared_ptr<EvsCameraBase> pActiveCamera = pRecord->activeInstance.lock(); if (pActiveCamera) { LOG(WARNING) << "Killing previous camera because of new caller"; closeCamera(pActiveCamera); Loading Loading @@ -273,7 +274,7 @@ ScopedAStatus EvsEnumerator::openCamera(const std::string& id, const Stream& cfg pRecord->activeInstance = pActiveCamera; if (!pActiveCamera) { LOG(ERROR) << "Failed to create new EvsMockCamera object for " << id; LOG(ERROR) << "Failed to create new EVS camera object for " << id; return ScopedAStatus::fromServiceSpecificError( static_cast<int>(EvsResult::UNDERLYING_SERVICE_ERROR)); } Loading Loading @@ -460,7 +461,7 @@ void EvsEnumerator::closeCamera_impl(const std::shared_ptr<IEvsCamera>& pCamera, if (!pRecord) { LOG(ERROR) << "Asked to close a camera whose name isn't recognized"; } else { std::shared_ptr<EvsMockCamera> pActiveCamera = pRecord->activeInstance.lock(); std::shared_ptr<EvsCameraBase> pActiveCamera = pRecord->activeInstance.lock(); if (!pActiveCamera) { LOG(WARNING) << "Somehow a camera is being destroyed " << "when the enumerator didn't know one existed"; Loading