-/*\r
-* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG (www.casparcg.com).\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-*\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-* Author: Robert Nagy, ronag89@gmail.com\r
-*/\r
-\r
-#include "../stdafx.h"\r
-\r
-#include "reroute_producer.h"\r
-\r
-#include <core/producer/frame_producer.h>\r
-#include <core/frame/draw_frame.h>\r
-#include <core/frame/frame_factory.h>\r
-#include <core/frame/pixel_format.h>\r
-#include <core/frame/frame.h>\r
-#include <core/video_channel.h>\r
-#include <core/producer/stage.h>\r
-\r
-#include <common/except.h>\r
-#include <common/diagnostics/graph.h>\r
-#include <common/log.h>\r
-#include <common/reactive.h>\r
-\r
-#include <asmlib.h>\r
-\r
-#include <tbb/concurrent_queue.h>\r
-\r
-#include <boost/property_tree/ptree.hpp>\r
-#include <boost/foreach.hpp>\r
-#include <boost/optional.hpp>\r
-#include <boost/range/algorithm_ext/push_back.hpp>\r
-#include <boost/range/numeric.hpp>\r
-#include <boost/range/adaptor/map.hpp>\r
-\r
-#include <queue>\r
-\r
-namespace caspar { namespace reroute {\r
- \r
-class reroute_producer : public reactive::observer<std::map<int, core::draw_frame>>\r
- , public core::frame_producer_base\r
-{\r
- const spl::shared_ptr<diagnostics::graph> graph_;\r
- \r
- tbb::concurrent_bounded_queue<std::map<int, core::draw_frame>> input_buffer_;\r
-public:\r
- explicit reroute_producer() \r
- {\r
- graph_->set_color("late-frame", diagnostics::color(0.6f, 0.3f, 0.3f));\r
- graph_->set_color("dropped-frame", diagnostics::color(0.3f, 0.6f, 0.3f));\r
- graph_->set_text(print());\r
- diagnostics::register_graph(graph_);\r
-\r
- input_buffer_.set_capacity(1);\r
- }\r
- \r
- // observable\r
-\r
- void on_next(const std::map<int, core::draw_frame>& frames)\r
- {\r
- if(!input_buffer_.try_push(frames))\r
- graph_->set_tag("dropped-frame"); \r
- }\r
-\r
- // frame_producer\r
- \r
- core::draw_frame receive_impl() override\r
- { \r
- std::map<int, core::draw_frame> frames;\r
- if(!input_buffer_.try_pop(frames))\r
- {\r
- graph_->set_tag("late-frame");\r
- return core::draw_frame::late(); \r
- }\r
-\r
- return boost::accumulate(frames | boost::adaptors::map_values, core::draw_frame::empty(), core::draw_frame::over);\r
- } \r
- \r
- std::wstring print() const override\r
- {\r
- return L"reroute[]";\r
- }\r
-\r
- std::wstring name() const override\r
- {\r
- return L"reroute";\r
- }\r
-\r
- boost::property_tree::wptree info() const override\r
- {\r
- boost::property_tree::wptree info;\r
- info.add(L"type", L"rerotue-producer");\r
- return info;\r
- }\r
- \r
- void subscribe(const monitor::observable::observer_ptr& o) override\r
- {\r
- }\r
-\r
- void unsubscribe(const monitor::observable::observer_ptr& o) override\r
- {\r
- }\r
-};\r
-\r
-spl::shared_ptr<core::frame_producer> create_producer(core::video_channel& channel)\r
-{\r
- auto producer = spl::make_shared<reroute_producer>();\r
- \r
- std::weak_ptr<reactive::observer<std::map<int, core::draw_frame>>> o = producer;\r
-\r
- channel.stage().subscribe(o);\r
-\r
- return producer;\r
-}\r
-\r
+/*
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
+*
+* This file is part of CasparCG (www.casparcg.com).
+*
+* CasparCG is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* CasparCG is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
+*
+* Author: Robert Nagy, ronag89@gmail.com
+*/
+
+#include "../stdafx.h"
+
+#include "reroute_producer.h"
+
+#include <core/producer/frame_producer.h>
+#include <core/frame/draw_frame.h>
+#include <core/frame/frame_factory.h>
+#include <core/frame/pixel_format.h>
+#include <core/frame/frame.h>
+#include <core/video_channel.h>
+#include <core/producer/stage.h>
+
+#include <common/except.h>
+#include <common/diagnostics/graph.h>
+#include <common/log.h>
+#include <common/reactive.h>
+
+#include <asmlib.h>
+
+#include <tbb/concurrent_queue.h>
+
+#include <boost/property_tree/ptree.hpp>
+#include <boost/foreach.hpp>
+#include <boost/optional.hpp>
+#include <boost/range/algorithm_ext/push_back.hpp>
+#include <boost/range/numeric.hpp>
+#include <boost/range/adaptor/map.hpp>
+
+#include <queue>
+
+namespace caspar { namespace reroute {
+
+class reroute_producer : public reactive::observer<std::map<int, core::draw_frame>>
+ , public core::frame_producer_base
+{
+ const spl::shared_ptr<diagnostics::graph> graph_;
+
+ tbb::concurrent_bounded_queue<std::map<int, core::draw_frame>> input_buffer_;
+public:
+ explicit reroute_producer()
+ {
+ graph_->set_color("late-frame", diagnostics::color(0.6f, 0.3f, 0.3f));
+ graph_->set_color("dropped-frame", diagnostics::color(0.3f, 0.6f, 0.3f));
+ graph_->set_text(print());
+ diagnostics::register_graph(graph_);
+
+ input_buffer_.set_capacity(1);
+ }
+
+ // observable
+
+ void on_next(const std::map<int, core::draw_frame>& frames)
+ {
+ if(!input_buffer_.try_push(frames))
+ graph_->set_tag("dropped-frame");
+ }
+
+ // frame_producer
+
+ core::draw_frame receive_impl() override
+ {
+ std::map<int, core::draw_frame> frames;
+ if(!input_buffer_.try_pop(frames))
+ {
+ graph_->set_tag("late-frame");
+ return core::draw_frame::late();
+ }
+
+ return boost::accumulate(frames | boost::adaptors::map_values, core::draw_frame::empty(), core::draw_frame::over);
+ }
+
+ std::wstring print() const override
+ {
+ return L"reroute[]";
+ }
+
+ std::wstring name() const override
+ {
+ return L"reroute";
+ }
+
+ boost::property_tree::wptree info() const override
+ {
+ boost::property_tree::wptree info;
+ info.add(L"type", L"rerotue-producer");
+ return info;
+ }
+
+ void subscribe(const monitor::observable::observer_ptr& o) override
+ {
+ }
+
+ void unsubscribe(const monitor::observable::observer_ptr& o) override
+ {
+ }
+};
+
+spl::shared_ptr<core::frame_producer> create_producer(core::video_channel& channel)
+{
+ auto producer = spl::make_shared<reroute_producer>();
+
+ std::weak_ptr<reactive::observer<std::map<int, core::draw_frame>>> o = producer;
+
+ channel.stage().subscribe(o);
+
+ return producer;
+}
+
}}
\ No newline at end of file