#ifndef D84CC9FA_711B_4439_A0F8_424C43E082CB #define D84CC9FA_711B_4439_A0F8_424C43E082CB /* ******************************************************************************* * INCLUDE ******************************************************************************* */ #include "VideoComponent.h" #include "util/FactoryManager.h" #include namespace Video { namespace Core { /* ******************************************************************************* * CLASS DECLARE ******************************************************************************* */ class VideoMixerSelector { public: static int select(const std::string&) { return 0; } }; class VideoMixer: public VideoComponent, public ::Util::FactoryManager { public: using Ptr = Poco::AutoPtr; class Channel: public VideoComponent { public: using Ptr = Poco::AutoPtr; struct Region { double x; double y; double width; double height; bool operator==(const Region& other) const { return std::abs(x - other.x) < 1e-9 && std::abs(y - other.y) < 1e-9 && std::abs(width - other.width) < 1e-9 && std::abs(height - other.height) < 1e-9; } bool operator!=(const Region& other) const { return !(this->operator==(other)); } }; protected: Channel(const std::string& name, VideoMixer::Ptr, uint32_t id); public: ~Channel(); CONFIGURABLE_DECLARE_PARAMETER(Region, Region) CONFIGURABLE_DECLARE_PARAMETER(ZOrder, int) CONFIGURABLE_DECLARE_PARAMETER(Attach, bool) CONFIGURABLE_DECLARE_PARAMETER(Input, VideoComponent::Ptr) uint32_t id() const; protected: void onConfigChanged(ParameterNames& names) override; VideoMixer::Ptr mixer(); private: VideoMixer::Ptr _pMixer; uint32_t _id; friend VideoMixer; }; public: VideoMixer(const std::string& name); ~VideoMixer(); Channel::Ptr getChannel(uint32_t id); protected: void start() override; void stop() override; virtual Channel::Ptr createChannel(uint32_t id) = 0; template void foreachChannel(F&&); private: std::unordered_map _channels; }; inline uint32_t VideoMixer::Channel::id() const { return _id; } inline VideoMixer::Ptr VideoMixer::Channel::mixer() { return _pMixer; } template inline void VideoMixer::foreachChannel(F&& exec) { for (auto m : _channels) exec(m.second.cast()); } } } #endif