Loading automotive/evs/aidl/impl/default/include/ConfigManager.h +15 −0 Original line number Diff line number Diff line Loading @@ -25,8 +25,10 @@ #include <tinyxml2.h> #include <limits> #include <string> #include <string_view> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <vector> Loading Loading @@ -54,6 +56,15 @@ class ConfigManager final { /* Camera device's capabilities and metadata */ class CameraInfo { public: enum class DeviceType : std::int32_t { NONE = 0, MOCK = 1, V4L2 = 2, VIDEO = 3, UNKNOWN = std::numeric_limits<std::underlying_type_t<DeviceType>>::max(), }; CameraInfo() : characteristics(nullptr) {} virtual ~CameraInfo(); Loading @@ -69,6 +80,10 @@ class ConfigManager final { return characteristics != nullptr; } static DeviceType deviceTypeFromSV(const std::string_view sv); DeviceType deviceType{DeviceType::NONE}; /* * List of supported controls that the primary client can program. * Paraemters are stored with its valid range 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 @@ -73,7 +73,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/ConfigManager.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,18 @@ std::string_view ConfigManager::sConfigDefaultPath = std::string_view ConfigManager::sConfigOverridePath = "/vendor/etc/automotive/evs/evs_configuration_override.xml"; ConfigManager::CameraInfo::DeviceType ConfigManager::CameraInfo::deviceTypeFromSV( const std::string_view sv) { using namespace std::string_view_literals; static const std::unordered_map<std::string_view, DeviceType> nameToType = { {"mock"sv, DeviceType::MOCK}, {"v4l2"sv, DeviceType::V4L2}, {"video"sv, DeviceType::VIDEO}, }; const auto search = nameToType.find(sv); return search == nameToType.end() ? DeviceType::UNKNOWN : search->second; } void ConfigManager::printElementNames(const XMLElement* rootElem, const std::string& prefix) const { const XMLElement* curElem = rootElem; Loading Loading @@ -128,6 +140,10 @@ bool ConfigManager::readCameraDeviceInfo(CameraInfo* aCamera, const XMLElement* return false; } if (const auto typeAttr = aDeviceElem->FindAttribute("type")) { aCamera->deviceType = CameraInfo::deviceTypeFromSV(typeAttr->Value()); } /* size information to allocate camera_metadata_t */ size_t totalEntries = 0; size_t totalDataSize = 0; Loading Loading
automotive/evs/aidl/impl/default/include/ConfigManager.h +15 −0 Original line number Diff line number Diff line Loading @@ -25,8 +25,10 @@ #include <tinyxml2.h> #include <limits> #include <string> #include <string_view> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <vector> Loading Loading @@ -54,6 +56,15 @@ class ConfigManager final { /* Camera device's capabilities and metadata */ class CameraInfo { public: enum class DeviceType : std::int32_t { NONE = 0, MOCK = 1, V4L2 = 2, VIDEO = 3, UNKNOWN = std::numeric_limits<std::underlying_type_t<DeviceType>>::max(), }; CameraInfo() : characteristics(nullptr) {} virtual ~CameraInfo(); Loading @@ -69,6 +80,10 @@ class ConfigManager final { return characteristics != nullptr; } static DeviceType deviceTypeFromSV(const std::string_view sv); DeviceType deviceType{DeviceType::NONE}; /* * List of supported controls that the primary client can program. * Paraemters are stored with its valid range 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 @@ -73,7 +73,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/ConfigManager.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,18 @@ std::string_view ConfigManager::sConfigDefaultPath = std::string_view ConfigManager::sConfigOverridePath = "/vendor/etc/automotive/evs/evs_configuration_override.xml"; ConfigManager::CameraInfo::DeviceType ConfigManager::CameraInfo::deviceTypeFromSV( const std::string_view sv) { using namespace std::string_view_literals; static const std::unordered_map<std::string_view, DeviceType> nameToType = { {"mock"sv, DeviceType::MOCK}, {"v4l2"sv, DeviceType::V4L2}, {"video"sv, DeviceType::VIDEO}, }; const auto search = nameToType.find(sv); return search == nameToType.end() ? DeviceType::UNKNOWN : search->second; } void ConfigManager::printElementNames(const XMLElement* rootElem, const std::string& prefix) const { const XMLElement* curElem = rootElem; Loading Loading @@ -128,6 +140,10 @@ bool ConfigManager::readCameraDeviceInfo(CameraInfo* aCamera, const XMLElement* return false; } if (const auto typeAttr = aDeviceElem->FindAttribute("type")) { aCamera->deviceType = CameraInfo::deviceTypeFromSV(typeAttr->Value()); } /* size information to allocate camera_metadata_t */ size_t totalEntries = 0; size_t totalDataSize = 0; Loading