]> git.sesse.net Git - casparcg/blobdiff - protocol/clk/clk_commands.cpp
[general] Added cg_producer_registry as dependency in frame_producer_dependencies
[casparcg] / protocol / clk / clk_commands.cpp
index 95b218d3f765a2ab595bdcd9e429b2561d8f8ebf..d853f02b759b67c3bb4b503ca0220ad26d97ef4b 100644 (file)
 * Author: Helge Norberg, helge.norberg@svt.se\r
 */\r
 \r
-#include "../stdafx.h"\r
+#include "../StdAfx.h"\r
 \r
 #include <stdexcept>\r
 #include <sstream>\r
+#include <future>\r
 \r
 #include <boost/lexical_cast.hpp>\r
 \r
 #include <common/log.h>\r
+#include <common/memory.h>\r
 \r
-#include <modules/flash/producer/cg_proxy.h>\r
+#include <core/video_channel.h>\r
+#include <core/producer/stage.h>\r
+#include <core/producer/cg_proxy.h>\r
 \r
 #include "clk_commands.h"\r
 \r
@@ -36,34 +40,44 @@ namespace caspar { namespace protocol { namespace CLK {
 \r
 class command_context\r
 {\r
-       bool clock_loaded_;\r
-       spl::shared_ptr<core::video_channel> channel_;\r
+       bool                                                                                                    clock_loaded_ = false;\r
+       std::vector<spl::shared_ptr<core::video_channel>>               channels_;\r
+       spl::shared_ptr<core::video_channel>                                    channel_;\r
+       spl::shared_ptr<core::cg_producer_registry>                             cg_registry_;\r
+       spl::shared_ptr<const core::frame_producer_registry>    producer_registry_;\r
 public:\r
-       command_context(const spl::shared_ptr<core::video_channel>& channel)\r
-               : clock_loaded_(false)\r
+       command_context(\r
+                       const std::vector<spl::shared_ptr<core::video_channel>>& channels,\r
+                       const spl::shared_ptr<core::video_channel>& channel,\r
+                       const spl::shared_ptr<core::cg_producer_registry>& cg_registry,\r
+                       const spl::shared_ptr<const core::frame_producer_registry>& producer_registry)\r
+               : channels_(channels)\r
                , channel_(channel)\r
+               , cg_registry_(cg_registry)\r
+               , producer_registry_(producer_registry)\r
        {\r
        }\r
 \r
        void send_to_flash(const std::wstring& data)\r
        {\r
-               if (!clock_loaded_) \r
+               if (!clock_loaded_)\r
                {\r
-                       flash::create_cg_proxy(channel_).add(\r
-                               0, L"hawrysklocka/clock.ft", true, L"", data);\r
+                       core::frame_producer_dependencies dependencies(channel_->frame_factory(), channels_, channel_->video_format_desc(), producer_registry_, cg_registry_);\r
+                       cg_registry_->get_or_create_proxy(channel_, dependencies, core::cg_proxy::DEFAULT_LAYER, L"hawrysklocka/clock")->add(\r
+                                       0, L"hawrysklocka/clock", true, L"", data);\r
                        clock_loaded_ = true;\r
                }\r
                else\r
                {\r
-                       flash::create_cg_proxy(channel_).update(0, data);\r
+                       cg_registry_->get_proxy(channel_, core::cg_proxy::DEFAULT_LAYER)->update(0, data);\r
                }\r
-                               \r
-               CASPAR_LOG(debug) << L"CLK: Clockdata sent: " << data;\r
+\r
+               CASPAR_LOG(info) << L"CLK: Clockdata sent: " << data;\r
        }\r
 \r
        void reset()\r
        {\r
-               channel_->stage().clear(flash::cg_proxy::DEFAULT_LAYER);\r
+               channel_->stage().clear(core::cg_proxy::DEFAULT_LAYER);\r
                clock_loaded_ = false;\r
                CASPAR_LOG(info) << L"CLK: Recieved and executed reset-command";\r
        }\r
@@ -93,10 +107,10 @@ std::wstring get_xml(
 {\r
        std::wstringstream stream;\r
 \r
-       stream << L"<templateData>";    \r
+       stream << L"<templateData>";\r
        stream << L"<componentData id=\"command\">";\r
        stream << L"<command id=\"" << command_name << "\"";\r
-       \r
+\r
        std::vector<std::wstring>::const_iterator it = parameters.begin();\r
        std::vector<std::wstring>::const_iterator end = parameters.end();\r
 \r
@@ -133,9 +147,9 @@ std::wstring get_xml(
 }\r
 \r
 clk_command_handler create_send_xml_handler(\r
-       const std::wstring& command_name, \r
-       bool expect_clock, \r
-       bool expect_time, \r
+       const std::wstring& command_name,\r
+       bool expect_clock,\r
+       bool expect_time,\r
        const spl::shared_ptr<command_context>& context)\r
 {\r
        return [=] (const std::vector<std::wstring>& params)\r
@@ -146,31 +160,34 @@ clk_command_handler create_send_xml_handler(
 }\r
 \r
 void add_command_handlers(\r
-       clk_command_processor& processor, \r
-       const spl::shared_ptr<core::video_channel>& channel)\r
+       clk_command_processor& processor,\r
+       const std::vector<spl::shared_ptr<core::video_channel>>& channels,\r
+       const spl::shared_ptr<core::video_channel>& channel,\r
+       const spl::shared_ptr<core::cg_producer_registry>& cg_registry,\r
+       const spl::shared_ptr<const core::frame_producer_registry>& producer_registry)\r
 {\r
-       auto context = spl::make_shared<command_context>(channel);\r
+       auto context = spl::make_shared<command_context>(channels, channel, cg_registry, producer_registry);\r
 \r
        processor\r
-               .add_handler(L"DUR", \r
+               .add_handler(L"DUR",\r
                        create_send_xml_handler(L"DUR", true, true, context))\r
-               .add_handler(L"NEWDUR", \r
+               .add_handler(L"NEWDUR",\r
                        create_send_xml_handler(L"NEWDUR", true, true, context))\r
-               .add_handler(L"UNTIL", \r
+               .add_handler(L"UNTIL",\r
                        create_send_xml_handler(L"UNTIL", true, true, context))\r
-               .add_handler(L"NEXTEVENT", \r
+               .add_handler(L"NEXTEVENT",\r
                        create_send_xml_handler(L"NEXTEVENT", true, false, context))\r
-               .add_handler(L"STOP", \r
+               .add_handler(L"STOP",\r
                        create_send_xml_handler(L"STOP", true, false, context))\r
-               .add_handler(L"ADD", \r
+               .add_handler(L"ADD",\r
                        create_send_xml_handler(L"ADD", true, true, context))\r
-               .add_handler(L"SUB", \r
+               .add_handler(L"SUB",\r
                        create_send_xml_handler(L"SUB", true, true, context))\r
-               .add_handler(L"TIMELINE_LOAD", \r
+               .add_handler(L"TIMELINE_LOAD",\r
                        create_send_xml_handler(L"TIMELINE_LOAD", false, false, context))\r
-               .add_handler(L"TIMELINE_PLAY", \r
+               .add_handler(L"TIMELINE_PLAY",\r
                        create_send_xml_handler(L"TIMELINE_PLAY", false, false, context))\r
-               .add_handler(L"TIMELINE_STOP", \r
+               .add_handler(L"TIMELINE_STOP",\r
                        create_send_xml_handler(L"TIMELINE_STOP", false, false, context))\r
                .add_handler(L"RESET", [=] (const std::vector<std::wstring>& params)\r
                {\r