diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2019-03-18 15:20:09 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2019-03-18 15:20:09 +0100 |
commit | 5023b54ba76325bb0b5598d59714bdad2d55d81e (patch) | |
tree | 15cc639eff7dbfa12eeccaa52d7fd251f18969e6 /api | |
parent | 3aababf6fd53a7b0312c2c1492bab6b43584b613 (diff) |
video: add support for camera modules
Issue: #910
Diffstat (limited to 'api')
-rw-r--r-- | api/plugin-support.hpp | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/api/plugin-support.hpp b/api/plugin-support.hpp index df1344bf..65b8e10d 100644 --- a/api/plugin-support.hpp +++ b/api/plugin-support.hpp @@ -35,10 +35,11 @@ struct dylib final Tracker = 0xcafebeef, Protocol = 0xdeadf00d, Extension = 0xcafebabe, + Video = 0xbadf00d, Invalid = (unsigned)-1, }; - dylib(const QString& filename_, Type t) : + dylib(const QString& filename_, Type t, bool load = true) : full_filename(filename_), module_name(trim_filename(filename_)) { @@ -57,19 +58,25 @@ struct dylib final if (check(!handle.load())) return; - if (check((Dialog = (module_ctor_t) handle.resolve("GetDialog"), !Dialog))) - return; + if (load) + { + if (check((Dialog = (module_ctor_t) handle.resolve("GetDialog"), !Dialog))) + return; - if (check((Constructor = (module_ctor_t) handle.resolve("GetConstructor"), !Constructor))) - return; + if (check((Constructor = (module_ctor_t) handle.resolve("GetConstructor"), !Constructor))) + return; - if (check((Meta = (module_metadata_t) handle.resolve("GetMetadata"), !Meta))) - return; + if (check((Meta = (module_metadata_t) handle.resolve("GetMetadata"), !Meta))) + return; + + std::unique_ptr<Metadata_> m{Meta()}; - std::unique_ptr<Metadata_> m{Meta()}; + if (check(!m)) + return; - icon = m->icon(); - name = m->name(); + icon = m->icon(); + name = m->name(); + } type = t; #ifdef __clang__ @@ -88,18 +95,20 @@ struct dylib final const struct filter_ { Type type{Invalid}; QString glob; + bool load = true; } filters[] = { { Filter, QStringLiteral(OPENTRACK_LIBRARY_PREFIX "opentrack-filter-*." OPENTRACK_LIBRARY_EXTENSION), }, { Tracker, QStringLiteral(OPENTRACK_LIBRARY_PREFIX "opentrack-tracker-*." OPENTRACK_LIBRARY_EXTENSION), }, { Protocol, QStringLiteral(OPENTRACK_LIBRARY_PREFIX "opentrack-proto-*." OPENTRACK_LIBRARY_EXTENSION), }, { Extension, QStringLiteral(OPENTRACK_LIBRARY_PREFIX "opentrack-ext-*." OPENTRACK_LIBRARY_EXTENSION), }, + { Video, QStringLiteral(OPENTRACK_LIBRARY_PREFIX "opentrack-video-*." OPENTRACK_LIBRARY_EXTENSION), false, }, }; for (const filter_& filter : filters) { for (const QString& filename : module_directory.entryList({ filter.glob }, QDir::Files, QDir::Name)) { - auto lib = std::make_shared<dylib>(QStringLiteral("%1/%2").arg(library_path, filename), filter.type); + auto lib = std::make_shared<dylib>(QStringLiteral("%1/%2").arg(library_path, filename), filter.type, filter.load); if (lib->type == Invalid) continue; @@ -159,6 +168,7 @@ private: OPENTRACK_LIBRARY_PREFIX "opentrack-proto-", OPENTRACK_LIBRARY_PREFIX "opentrack-filter-", OPENTRACK_LIBRARY_PREFIX "opentrack-ext-", + OPENTRACK_LIBRARY_PREFIX "opentrack-video-", }; for (auto name : names) @@ -198,7 +208,8 @@ struct Modules final filter_modules(filter(dylib::Filter)), tracker_modules(filter(dylib::Tracker)), protocol_modules(filter(dylib::Protocol)), - extension_modules(filter(dylib::Extension)) + extension_modules(filter(dylib::Extension)), + video_modules(filter(dylib::Video)) {} dylib_list& filters() { return filter_modules; } dylib_list& trackers() { return tracker_modules; } @@ -211,6 +222,7 @@ private: dylib_list tracker_modules; dylib_list protocol_modules; dylib_list extension_modules; + dylib_list video_modules; static dylib_list& sorted(dylib_list& xs) { |