From 8fb69d68706e8fcbaa348bf2f233c5e06063ab85 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Sun, 7 Jul 2019 13:42:39 +0200 Subject: [PATCH] plugin: Add global codec to UI Handler map --- source/plugin.cpp | 16 ++++++++++++++++ source/plugin.hpp | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/source/plugin.cpp b/source/plugin.cpp index 8d69ea1..8c76374 100644 --- a/source/plugin.cpp +++ b/source/plugin.cpp @@ -36,6 +36,22 @@ std::list> obsffmpeg::initializers; std::list> obsffmpeg::finalizers; +// Codec to Handler mapping. +static std::map> codec_to_handler_map; + +void obsffmpeg::register_codec_handler(std::string codec, std::shared_ptr handler) +{ + codec_to_handler_map.emplace(codec, handler); +} + +std::shared_ptr obsffmpeg::find_codec_handler(std::string codec) +{ + auto found = codec_to_handler_map.find(codec); + if (found == codec_to_handler_map.end()) + return nullptr; + return found->second; +} + static std::map> generic_factories; MODULE_EXPORT bool obs_module_load(void) diff --git a/source/plugin.hpp b/source/plugin.hpp index 8599374..cf4b75b 100644 --- a/source/plugin.hpp +++ b/source/plugin.hpp @@ -20,12 +20,17 @@ #include #include #include +#include "ui/handler.hpp" namespace obsffmpeg { extern std::list> initializers; extern std::list> finalizers; + void register_codec_handler(std::string codec, std::shared_ptr handler); + + std::shared_ptr find_codec_handler(std::string codec); + } // namespace obsffmpeg MODULE_EXPORT bool obs_module_load(void);