#include <common/memory/safe_ptr.h>\r
\r
namespace caspar { namespace core {\r
+ \r
+std::vector<const producer_factory_t> g_factories;\r
\r
boost::unique_future<std::wstring> frame_producer::call(const std::wstring&) \r
{\r
BOOST_THROW_EXCEPTION(not_supported());\r
}\r
+\r
+struct empty_frame_producer : public frame_producer\r
+{\r
+ virtual safe_ptr<draw_frame> receive(int){return draw_frame::empty();}\r
+ virtual safe_ptr<draw_frame> last_frame() const{return draw_frame::empty();}\r
+ virtual void set_frame_factory(const safe_ptr<frame_factory>&){}\r
+ virtual uint32_t nb_frames() const {return 0;}\r
+ virtual std::wstring print() const { return L"empty";}\r
\r
-std::vector<const producer_factory_t> g_factories;\r
- \r
+ virtual boost::property_tree::wptree info() const override\r
+ {\r
+ boost::property_tree::wptree info;\r
+ info.add(L"type", L"empty-producer");\r
+ return info;\r
+ }\r
+};\r
+\r
+const safe_ptr<frame_producer>& frame_producer::empty() // nothrow\r
+{\r
+ static safe_ptr<frame_producer> producer = make_safe<empty_frame_producer>();\r
+ return producer;\r
+} \r
+\r
+safe_ptr<draw_frame> receive_and_follow(safe_ptr<frame_producer>& producer, int hints)\r
+{ \r
+ auto frame = producer->receive(hints);\r
+ if(frame == draw_frame::eof())\r
+ {\r
+ CASPAR_LOG(info) << producer->print() << " End Of File.";\r
+ auto following = producer->get_following_producer();\r
+ if(following != frame_producer::empty())\r
+ {\r
+ following->set_leading_producer(producer);\r
+ producer = std::move(following);\r
+ }\r
+\r
+ return receive_and_follow(producer, hints);\r
+ }\r
+ return frame;\r
+}\r
+\r
+void register_producer_factory(const producer_factory_t& factory)\r
+{\r
+ g_factories.push_back(factory);\r
+}\r
+\r
class destroy_producer_proxy : public frame_producer\r
{ \r
std::unique_ptr<std::shared_ptr<frame_producer>> producer_;\r
virtual uint32_t nb_frames() const override {return (*producer_)->nb_frames();}\r
};\r
\r
-safe_ptr<core::frame_producer> create_producer_destroy_proxy(safe_ptr<core::frame_producer> producer)\r
-{\r
- return make_safe<destroy_producer_proxy>(std::move(producer));\r
-}\r
-\r
class print_producer_proxy : public frame_producer\r
{ \r
std::shared_ptr<frame_producer> producer_;\r
CASPAR_LOG(info) << str << L" Uninitialized.";\r
}\r
\r
- virtual safe_ptr<draw_frame> receive(int hints) override {return (producer_)->receive(hints);}\r
- virtual safe_ptr<draw_frame> last_frame() const override {return (producer_)->last_frame();}\r
- virtual std::wstring print() const override {return (producer_)->print();}\r
- virtual boost::property_tree::wptree info() const override {return (producer_)->info();}\r
- virtual boost::unique_future<std::wstring> call(const std::wstring& str) override {return (producer_)->call(str);}\r
- virtual safe_ptr<frame_producer> get_following_producer() const override {return (producer_)->get_following_producer();}\r
- virtual void set_leading_producer(const safe_ptr<frame_producer>& producer) override {(producer_)->set_leading_producer(producer);}\r
- virtual uint32_t nb_frames() const override {return (producer_)->nb_frames();}\r
-};\r
-\r
-safe_ptr<core::frame_producer> create_producer_print_proxy(safe_ptr<core::frame_producer> producer)\r
-{\r
- return make_safe<print_producer_proxy>(std::move(producer));\r
-}\r
-\r
-struct empty_frame_producer : public frame_producer\r
-{\r
- virtual safe_ptr<draw_frame> receive(int){return draw_frame::empty();}\r
- virtual safe_ptr<draw_frame> last_frame() const{return draw_frame::empty();}\r
- virtual void set_frame_factory(const safe_ptr<frame_factory>&){}\r
- virtual uint32_t nb_frames() const {return 0;}\r
- virtual std::wstring print() const { return L"empty";}\r
- \r
- virtual boost::property_tree::wptree info() const override\r
- {\r
- boost::property_tree::wptree info;\r
- info.add(L"type", L"empty-producer");\r
- return info;\r
- }\r
+ virtual safe_ptr<draw_frame> receive(int hints) override {return (producer_)->receive(hints);}\r
+ virtual safe_ptr<draw_frame> last_frame() const override {return (producer_)->last_frame();}\r
+ virtual std::wstring print() const override {return (producer_)->print();}\r
+ virtual boost::property_tree::wptree info() const override {return (producer_)->info();}\r
+ virtual boost::unique_future<std::wstring> call(const std::wstring& str) override {return (producer_)->call(str);}\r
+ virtual safe_ptr<frame_producer> get_following_producer() const override {return (producer_)->get_following_producer();}\r
+ virtual void set_leading_producer(const safe_ptr<frame_producer>& producer) override {(producer_)->set_leading_producer(producer);}\r
+ virtual uint32_t nb_frames() const override {return (producer_)->nb_frames();}\r
};\r
\r
-const safe_ptr<frame_producer>& frame_producer::empty() // nothrow\r
-{\r
- static safe_ptr<frame_producer> producer = make_safe<empty_frame_producer>();\r
- return producer;\r
-} \r
-\r
-safe_ptr<draw_frame> receive_and_follow(safe_ptr<frame_producer>& producer, int hints)\r
-{ \r
- auto frame = producer->receive(hints);\r
- if(frame == draw_frame::eof())\r
- {\r
- CASPAR_LOG(info) << producer->print() << " End Of File.";\r
- auto following = producer->get_following_producer();\r
- if(following != frame_producer::empty())\r
- {\r
- following->set_leading_producer(producer);\r
- producer = std::move(following);\r
- }\r
-\r
- return receive_and_follow(producer, hints);\r
- }\r
- return frame;\r
-}\r
-\r
-void register_producer_factory(const producer_factory_t& factory)\r
-{\r
- g_factories.push_back(factory);\r
-}\r
-\r
safe_ptr<core::frame_producer> do_create_producer(const safe_ptr<frame_factory>& my_frame_factory, const std::vector<std::wstring>& params)\r
{\r
if(params.empty())\r
if(producer == frame_producer::empty())\r
producer = create_color_producer(my_frame_factory, params);\r
\r
- return producer;\r
+ return make_safe<destroy_producer_proxy>(make_safe<print_producer_proxy>(std::move(producer)));\r
}\r
\r
-\r
safe_ptr<core::frame_producer> create_producer(const safe_ptr<frame_factory>& my_frame_factory, const std::vector<std::wstring>& params)\r
{ \r
auto producer = do_create_producer(my_frame_factory, params);\r