From 04fcc44d7b31f4e21211cc30ef0432762f46ef16 Mon Sep 17 00:00:00 2001 From: Helge Norberg Date: Wed, 9 Dec 2015 17:21:36 +0100 Subject: [PATCH] Improved hotswap_producer --- core/producer/scene/hotswap_producer.cpp | 44 ++++++++++++++++++++---- core/producer/scene/hotswap_producer.h | 16 +++++---- 2 files changed, 46 insertions(+), 14 deletions(-) diff --git a/core/producer/scene/hotswap_producer.cpp b/core/producer/scene/hotswap_producer.cpp index 3afc93a61..60d807b00 100644 --- a/core/producer/scene/hotswap_producer.cpp +++ b/core/producer/scene/hotswap_producer.cpp @@ -30,18 +30,28 @@ namespace caspar { namespace core { struct hotswap_producer::impl { - monitor::subject monitor_subject; - binding> producer; - constraints size; + spl::shared_ptr monitor_subject; + binding> producer; + constraints size; - impl(int width, int height) + impl(int width, int height, bool auto_size) : size(width, height) { + producer.on_change([=] + { + if (auto_size) + { + size.width.bind(producer.get()->pixel_constraints().width); + size.height.bind(producer.get()->pixel_constraints().height); + } + + producer.get()->monitor_output().attach_parent(monitor_subject); + }); } }; -hotswap_producer::hotswap_producer(int width, int height) - : impl_(new impl(width, height)) +hotswap_producer::hotswap_producer(int width, int height, bool auto_size) + : impl_(new impl(width, height, auto_size)) { } @@ -90,7 +100,27 @@ boost::property_tree::wptree hotswap_producer::info() const monitor::subject& hotswap_producer::monitor_output() { - return impl_->monitor_subject; + return *impl_->monitor_subject; +} + +variable& hotswap_producer::get_variable(const std::wstring& name) +{ + auto producer = impl_->producer.get(); + + if (producer) + return producer->get_variable(name); + else + return frame_producer_base::get_variable(name); +} + +const std::vector& hotswap_producer::get_variables() const +{ + auto producer = impl_->producer.get(); + + if (producer) + return producer->get_variables(); + else + return frame_producer_base::get_variables(); } binding>& hotswap_producer::producer() diff --git a/core/producer/scene/hotswap_producer.h b/core/producer/scene/hotswap_producer.h index d148b9258..3fe88ba1b 100644 --- a/core/producer/scene/hotswap_producer.h +++ b/core/producer/scene/hotswap_producer.h @@ -33,15 +33,17 @@ namespace caspar { namespace core { class hotswap_producer : public frame_producer_base { public: - hotswap_producer(int width, int height); + hotswap_producer(int width, int height, bool auto_size = false); ~hotswap_producer(); - draw_frame receive_impl() override; - constraints& pixel_constraints() override; - std::wstring print() const override; - std::wstring name() const override; - boost::property_tree::wptree info() const override; - monitor::subject& monitor_output(); + draw_frame receive_impl() override; + constraints& pixel_constraints() override; + std::wstring print() const override; + std::wstring name() const override; + boost::property_tree::wptree info() const override; + monitor::subject& monitor_output() override; + variable& get_variable(const std::wstring& name) override; + const std::vector& get_variables() const override; binding>& producer(); private: -- 2.39.2