Loading automotive/evs/aidl/impl/default/include/ConfigManager.h +18 −1 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ typedef struct { class ConfigManager final { public: static std::unique_ptr<ConfigManager> Create(); static std::unique_ptr<ConfigManager> Create(const std::string path); ConfigManager(const ConfigManager&) = delete; ConfigManager& operator=(const ConfigManager&) = delete; Loading @@ -65,6 +66,15 @@ class ConfigManager final { UNKNOWN = std::numeric_limits<std::underlying_type_t<DeviceType>>::max(), }; enum class PixelFormat : std::int32_t { NV12 = 0, NV21 = 1, YV12 = 2, I420 = 3, UNKNOWN = std::numeric_limits<std::underlying_type_t<DeviceType>>::max(), }; CameraInfo() : characteristics(nullptr) {} virtual ~CameraInfo(); Loading @@ -82,6 +92,8 @@ class ConfigManager final { static DeviceType deviceTypeFromSV(const std::string_view sv); static PixelFormat pixelFormatFromSV(const std::string_view sv); DeviceType deviceType{DeviceType::NONE}; /* Loading @@ -105,6 +117,11 @@ class ConfigManager final { /* Camera module characteristics */ camera_metadata_t* characteristics; /* Format of media in a given media container. This field is effective * only for DeviceType::VIDEO. */ PixelFormat format; }; class CameraGroupInfo : public CameraInfo { Loading Loading @@ -272,7 +289,7 @@ class ConfigManager final { * @return bool * True if it completes parsing a file successfully. */ bool readConfigDataFromXML() noexcept; bool readConfigDataFromXML(const std::string path) noexcept; /* * read the information of the vehicle Loading automotive/evs/aidl/impl/default/include/EvsCameraBase.h +1 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ class EvsCameraBase : public evs::BnEvsCamera { ~EvsCameraBase() override = default; virtual std::string getId() = 0; virtual void shutdown() = 0; protected: Loading automotive/evs/aidl/impl/default/include/EvsMockCamera.h +3 −1 Original line number Diff line number Diff line Loading @@ -65,7 +65,9 @@ class EvsMockCamera : public EvsCamera { ndk::ScopedAStatus setPrimaryClient() override; ndk::ScopedAStatus unsetPrimaryClient() override; const evs::CameraDesc& getDesc() { return mDescription; } std::string getId() override { return mDescription.id; } const CameraDesc& getDesc() { return mDescription; } static std::shared_ptr<EvsMockCamera> Create(const char* deviceName); static std::shared_ptr<EvsMockCamera> Create( Loading automotive/evs/aidl/impl/default/include/EvsVideoEmulatedCamera.h +10 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ #include <aidl/android/hardware/automotive/evs/ParameterRange.h> #include <aidl/android/hardware/automotive/evs/Stream.h> #include <media/NdkMediaExtractor.h> #include <ui/GraphicBuffer.h> #include <cstdint> Loading Loading @@ -70,6 +69,8 @@ class EvsVideoEmulatedCamera : public EvsCamera { // Methods from EvsCameraBase follow. void shutdown() override; std::string getId() override { return mDescription.id; } const evs::CameraDesc& getDesc() { return mDescription; } static std::shared_ptr<EvsVideoEmulatedCamera> Create(const char* deviceName); Loading Loading @@ -117,6 +118,10 @@ class EvsVideoEmulatedCamera : public EvsCamera { bool postVideoStreamStop_locked(ndk::ScopedAStatus& status, std::unique_lock<std::mutex>& lck) override; int (*mFillBuffer)(const uint8_t* src_y, int src_stride_y, const uint8_t* src_u, int src_stride_u, const uint8_t* src_v, int src_stride_v, uint8_t* dst_argb, int dst_stride_argb, int width, int height); // The properties of this camera. CameraDesc mDescription = {}; Loading Loading @@ -149,6 +154,10 @@ class EvsVideoEmulatedCamera : public EvsCamera { uint64_t mUsage = 0; // Bytes per line in the buffers uint32_t mStride = 0; // Bytes per line in the output buffer uint32_t mDstStride = 0; // Bytes per line of U/V plane uint32_t mUvStride = 0; // Camera parameters. std::unordered_map<CameraParam, std::shared_ptr<CameraParameterDesc>> mParams; Loading automotive/evs/aidl/impl/default/src/ConfigManager.cpp +40 −12 Original line number Diff line number Diff line Loading @@ -52,6 +52,25 @@ ConfigManager::CameraInfo::DeviceType ConfigManager::CameraInfo::deviceTypeFromS return search == nameToType.end() ? DeviceType::UNKNOWN : search->second; } ConfigManager::CameraInfo::PixelFormat ConfigManager::CameraInfo::pixelFormatFromSV( const std::string_view sv) { using namespace std::string_view_literals; static const std::unordered_map<std::string_view, PixelFormat> nameToFormat = { // Full resolution Y plane followed by 2x2 subsampled U/V // interleaved plane. {"NV12"sv, PixelFormat::NV12}, // Full resolution Y plane followed by 2x2 subsampled V/U // interleaved plane. {"NV21"sv, PixelFormat::NV21}, // Full resolution Y plane followed by 2x2 subsampled V plane and then U plane. {"YV12"sv, PixelFormat::YV12}, // Full resolution Y plane followed by 2x2 subsampled U plane and then V plane. {"I420"sv, PixelFormat::I420}, }; const auto search = nameToFormat.find(sv); return search == nameToFormat.end() ? PixelFormat::UNKNOWN : search->second; } void ConfigManager::printElementNames(const XMLElement* rootElem, const std::string& prefix) const { const XMLElement* curElem = rootElem; Loading Loading @@ -144,6 +163,10 @@ bool ConfigManager::readCameraDeviceInfo(CameraInfo* aCamera, const XMLElement* aCamera->deviceType = CameraInfo::deviceTypeFromSV(typeAttr->Value()); } if (const auto formatAttr = aDeviceElem->FindAttribute("format")) { aCamera->format = CameraInfo::pixelFormatFromSV(formatAttr->Value()); } /* size information to allocate camera_metadata_t */ size_t totalEntries = 0; size_t totalDataSize = 0; Loading Loading @@ -474,20 +497,17 @@ void ConfigManager::readDisplayInfo(const XMLElement* const aDisplayElem) { return; } bool ConfigManager::readConfigDataFromXML() noexcept { bool ConfigManager::readConfigDataFromXML(const std::string path) noexcept { XMLDocument xmlDoc; const int64_t parsingStart = android::elapsedRealtimeNano(); /* load and parse a configuration file */ xmlDoc.LoadFile(sConfigOverridePath.data()); if (xmlDoc.ErrorID() != tinyxml2::XML_SUCCESS) { xmlDoc.LoadFile(sConfigDefaultPath.data()); xmlDoc.LoadFile(path.c_str()); if (xmlDoc.ErrorID() != tinyxml2::XML_SUCCESS) { LOG(ERROR) << "Failed to load and/or parse a configuration file, " << xmlDoc.ErrorStr(); return false; } } /* retrieve the root element */ const XMLElement* rootElem = xmlDoc.RootElement(); Loading Loading @@ -644,8 +664,7 @@ bool ConfigManager::readConfigDataFromBinary() { p += count * sizeof(camera_metadata_rational_t); break; default: LOG(WARNING) << "Type " << type << " is unknown; " << "data may be corrupted."; LOG(WARNING) << "Type " << type << " is unknown; " << "data may be corrupted."; break; } } Loading Loading @@ -746,8 +765,7 @@ bool ConfigManager::readConfigDataFromBinary() { p += count * sizeof(camera_metadata_rational_t); break; default: LOG(WARNING) << "Type " << type << " is unknown; " << "data may be corrupted."; LOG(WARNING) << "Type " << type << " is unknown; " << "data may be corrupted."; break; } } Loading Loading @@ -958,6 +976,16 @@ bool ConfigManager::writeConfigDataToBinary() { } std::unique_ptr<ConfigManager> ConfigManager::Create() { std::unique_ptr<ConfigManager> mgr = Create(std::string(sConfigOverridePath)); if (!mgr) { LOG(DEBUG) << "A configuration override file does not exist. Use a default file instead."; mgr = Create(std::string((sConfigDefaultPath))); } return mgr; } std::unique_ptr<ConfigManager> ConfigManager::Create(const std::string path) { std::unique_ptr<ConfigManager> cfgMgr(new ConfigManager()); /* Loading @@ -968,7 +996,7 @@ std::unique_ptr<ConfigManager> ConfigManager::Create() { * to the filesystem and construct CameraInfo instead; this was * evaluated as 10x faster. */ if (!cfgMgr->readConfigDataFromXML()) { if (!cfgMgr->readConfigDataFromXML(path)) { return nullptr; } else { return cfgMgr; Loading Loading
automotive/evs/aidl/impl/default/include/ConfigManager.h +18 −1 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ typedef struct { class ConfigManager final { public: static std::unique_ptr<ConfigManager> Create(); static std::unique_ptr<ConfigManager> Create(const std::string path); ConfigManager(const ConfigManager&) = delete; ConfigManager& operator=(const ConfigManager&) = delete; Loading @@ -65,6 +66,15 @@ class ConfigManager final { UNKNOWN = std::numeric_limits<std::underlying_type_t<DeviceType>>::max(), }; enum class PixelFormat : std::int32_t { NV12 = 0, NV21 = 1, YV12 = 2, I420 = 3, UNKNOWN = std::numeric_limits<std::underlying_type_t<DeviceType>>::max(), }; CameraInfo() : characteristics(nullptr) {} virtual ~CameraInfo(); Loading @@ -82,6 +92,8 @@ class ConfigManager final { static DeviceType deviceTypeFromSV(const std::string_view sv); static PixelFormat pixelFormatFromSV(const std::string_view sv); DeviceType deviceType{DeviceType::NONE}; /* Loading @@ -105,6 +117,11 @@ class ConfigManager final { /* Camera module characteristics */ camera_metadata_t* characteristics; /* Format of media in a given media container. This field is effective * only for DeviceType::VIDEO. */ PixelFormat format; }; class CameraGroupInfo : public CameraInfo { Loading Loading @@ -272,7 +289,7 @@ class ConfigManager final { * @return bool * True if it completes parsing a file successfully. */ bool readConfigDataFromXML() noexcept; bool readConfigDataFromXML(const std::string path) noexcept; /* * read the information of the vehicle Loading
automotive/evs/aidl/impl/default/include/EvsCameraBase.h +1 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ class EvsCameraBase : public evs::BnEvsCamera { ~EvsCameraBase() override = default; virtual std::string getId() = 0; virtual void shutdown() = 0; protected: Loading
automotive/evs/aidl/impl/default/include/EvsMockCamera.h +3 −1 Original line number Diff line number Diff line Loading @@ -65,7 +65,9 @@ class EvsMockCamera : public EvsCamera { ndk::ScopedAStatus setPrimaryClient() override; ndk::ScopedAStatus unsetPrimaryClient() override; const evs::CameraDesc& getDesc() { return mDescription; } std::string getId() override { return mDescription.id; } const CameraDesc& getDesc() { return mDescription; } static std::shared_ptr<EvsMockCamera> Create(const char* deviceName); static std::shared_ptr<EvsMockCamera> Create( Loading
automotive/evs/aidl/impl/default/include/EvsVideoEmulatedCamera.h +10 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ #include <aidl/android/hardware/automotive/evs/ParameterRange.h> #include <aidl/android/hardware/automotive/evs/Stream.h> #include <media/NdkMediaExtractor.h> #include <ui/GraphicBuffer.h> #include <cstdint> Loading Loading @@ -70,6 +69,8 @@ class EvsVideoEmulatedCamera : public EvsCamera { // Methods from EvsCameraBase follow. void shutdown() override; std::string getId() override { return mDescription.id; } const evs::CameraDesc& getDesc() { return mDescription; } static std::shared_ptr<EvsVideoEmulatedCamera> Create(const char* deviceName); Loading Loading @@ -117,6 +118,10 @@ class EvsVideoEmulatedCamera : public EvsCamera { bool postVideoStreamStop_locked(ndk::ScopedAStatus& status, std::unique_lock<std::mutex>& lck) override; int (*mFillBuffer)(const uint8_t* src_y, int src_stride_y, const uint8_t* src_u, int src_stride_u, const uint8_t* src_v, int src_stride_v, uint8_t* dst_argb, int dst_stride_argb, int width, int height); // The properties of this camera. CameraDesc mDescription = {}; Loading Loading @@ -149,6 +154,10 @@ class EvsVideoEmulatedCamera : public EvsCamera { uint64_t mUsage = 0; // Bytes per line in the buffers uint32_t mStride = 0; // Bytes per line in the output buffer uint32_t mDstStride = 0; // Bytes per line of U/V plane uint32_t mUvStride = 0; // Camera parameters. std::unordered_map<CameraParam, std::shared_ptr<CameraParameterDesc>> mParams; Loading
automotive/evs/aidl/impl/default/src/ConfigManager.cpp +40 −12 Original line number Diff line number Diff line Loading @@ -52,6 +52,25 @@ ConfigManager::CameraInfo::DeviceType ConfigManager::CameraInfo::deviceTypeFromS return search == nameToType.end() ? DeviceType::UNKNOWN : search->second; } ConfigManager::CameraInfo::PixelFormat ConfigManager::CameraInfo::pixelFormatFromSV( const std::string_view sv) { using namespace std::string_view_literals; static const std::unordered_map<std::string_view, PixelFormat> nameToFormat = { // Full resolution Y plane followed by 2x2 subsampled U/V // interleaved plane. {"NV12"sv, PixelFormat::NV12}, // Full resolution Y plane followed by 2x2 subsampled V/U // interleaved plane. {"NV21"sv, PixelFormat::NV21}, // Full resolution Y plane followed by 2x2 subsampled V plane and then U plane. {"YV12"sv, PixelFormat::YV12}, // Full resolution Y plane followed by 2x2 subsampled U plane and then V plane. {"I420"sv, PixelFormat::I420}, }; const auto search = nameToFormat.find(sv); return search == nameToFormat.end() ? PixelFormat::UNKNOWN : search->second; } void ConfigManager::printElementNames(const XMLElement* rootElem, const std::string& prefix) const { const XMLElement* curElem = rootElem; Loading Loading @@ -144,6 +163,10 @@ bool ConfigManager::readCameraDeviceInfo(CameraInfo* aCamera, const XMLElement* aCamera->deviceType = CameraInfo::deviceTypeFromSV(typeAttr->Value()); } if (const auto formatAttr = aDeviceElem->FindAttribute("format")) { aCamera->format = CameraInfo::pixelFormatFromSV(formatAttr->Value()); } /* size information to allocate camera_metadata_t */ size_t totalEntries = 0; size_t totalDataSize = 0; Loading Loading @@ -474,20 +497,17 @@ void ConfigManager::readDisplayInfo(const XMLElement* const aDisplayElem) { return; } bool ConfigManager::readConfigDataFromXML() noexcept { bool ConfigManager::readConfigDataFromXML(const std::string path) noexcept { XMLDocument xmlDoc; const int64_t parsingStart = android::elapsedRealtimeNano(); /* load and parse a configuration file */ xmlDoc.LoadFile(sConfigOverridePath.data()); if (xmlDoc.ErrorID() != tinyxml2::XML_SUCCESS) { xmlDoc.LoadFile(sConfigDefaultPath.data()); xmlDoc.LoadFile(path.c_str()); if (xmlDoc.ErrorID() != tinyxml2::XML_SUCCESS) { LOG(ERROR) << "Failed to load and/or parse a configuration file, " << xmlDoc.ErrorStr(); return false; } } /* retrieve the root element */ const XMLElement* rootElem = xmlDoc.RootElement(); Loading Loading @@ -644,8 +664,7 @@ bool ConfigManager::readConfigDataFromBinary() { p += count * sizeof(camera_metadata_rational_t); break; default: LOG(WARNING) << "Type " << type << " is unknown; " << "data may be corrupted."; LOG(WARNING) << "Type " << type << " is unknown; " << "data may be corrupted."; break; } } Loading Loading @@ -746,8 +765,7 @@ bool ConfigManager::readConfigDataFromBinary() { p += count * sizeof(camera_metadata_rational_t); break; default: LOG(WARNING) << "Type " << type << " is unknown; " << "data may be corrupted."; LOG(WARNING) << "Type " << type << " is unknown; " << "data may be corrupted."; break; } } Loading Loading @@ -958,6 +976,16 @@ bool ConfigManager::writeConfigDataToBinary() { } std::unique_ptr<ConfigManager> ConfigManager::Create() { std::unique_ptr<ConfigManager> mgr = Create(std::string(sConfigOverridePath)); if (!mgr) { LOG(DEBUG) << "A configuration override file does not exist. Use a default file instead."; mgr = Create(std::string((sConfigDefaultPath))); } return mgr; } std::unique_ptr<ConfigManager> ConfigManager::Create(const std::string path) { std::unique_ptr<ConfigManager> cfgMgr(new ConfigManager()); /* Loading @@ -968,7 +996,7 @@ std::unique_ptr<ConfigManager> ConfigManager::Create() { * to the filesystem and construct CameraInfo instead; this was * evaluated as 10x faster. */ if (!cfgMgr->readConfigDataFromXML()) { if (!cfgMgr->readConfigDataFromXML(path)) { return nullptr; } else { return cfgMgr; Loading