]> git.sesse.net Git - casparcg/blobdiff - protocol/clk/CLKProtocolStrategy.cpp
[ffmpeg_producer] Recognize .mkv and .mxf files as playable without probing
[casparcg] / protocol / clk / CLKProtocolStrategy.cpp
index 30b5f7d9aeb9d4ccff54242ba5a3de200922a025..866a0bc3922e035f3471576218be379d82a8e4fa 100644 (file)
 */
 
  
-#include "..\stdafx.h"
+#include "../StdAfx.h"
 
 #include "CLKProtocolStrategy.h"
 #include "clk_commands.h"
 
-#include <modules/flash/producer/cg_proxy.h>
-
 #include <string>
 #include <algorithm>
 #include <locale>
@@ -37,12 +35,24 @@ namespace caspar { namespace protocol { namespace CLK {
 
 class CLKProtocolStrategy : public IO::protocol_strategy<wchar_t>
 {
+       enum class ParserState
+       {
+               ExpectingNewCommand,
+               ExpectingCommand,
+               ExpectingParameter
+       };
+
+       ParserState     currentState_                                                           = ParserState::ExpectingNewCommand;
+       std::wstringstream currentCommandString_;
+       std::wstring command_name_;
+       std::vector<std::wstring> parameters_;
+       clk_command_processor& command_processor_;
+       IO::client_connection<wchar_t>::ptr client_connection_;
 public:
        CLKProtocolStrategy(
-               const IO::client_connection<wchar_t>::ptr& client_connection,
-               clk_command_processor& command_processor) 
-               : currentState_(ExpectingNewCommand)
-               , command_processor_(command_processor)
+                       const IO::client_connection<wchar_t>::ptr& client_connection,
+                       clk_command_processor& command_processor) 
+               : command_processor_(command_processor)
                , client_connection_(client_connection)
        {
        }
@@ -62,18 +72,18 @@ public:
                        {
                                switch (currentState_)
                                {
-                                       case ExpectingNewCommand:
+                                       case ParserState::ExpectingNewCommand:
                                                if (currentByte == 1) 
-                                                       currentState_ = ExpectingCommand;                                       
+                                                       currentState_ = ParserState::ExpectingCommand;
                                                //just throw anything else away
                                                break;
-                                       case ExpectingCommand:
+                                       case ParserState::ExpectingCommand:
                                                if (currentByte == 2) 
-                                                       currentState_ = ExpectingParameter;
+                                                       currentState_ = ParserState::ExpectingParameter;
                                                else
                                                        command_name_ += currentByte;
                                                break;
-                                       case ExpectingParameter:
+                                       case ParserState::ExpectingParameter:
                                                //allocate new parameter
                                                if (parameters_.size() == 0 || currentByte == 2)
                                                        parameters_.push_back(std::wstring());
@@ -107,7 +117,7 @@ public:
                                        if (!command_processor_.handle(command_name_, parameters_))
                                                CASPAR_LOG(error) << "CLK: Unknown command: " << command_name_;
                                        else
-                                               CASPAR_LOG(debug) << L"CLK: Executed valid command: " 
+                                               CASPAR_LOG(info) << L"CLK: Executed valid command: " 
                                                        << currentCommandString_.str();
                                } 
                                catch (...)
@@ -124,31 +134,19 @@ public:
 private:
        void reset()
        {
-               currentState_ = ExpectingNewCommand;
+               currentState_ = ParserState::ExpectingNewCommand;
                currentCommandString_.str(L"");
                command_name_.clear();
                parameters_.clear();
        }
-
-       enum ParserState
-       {
-               ExpectingNewCommand,
-               ExpectingCommand,
-               ExpectingParameter
-       };
-
-       ParserState     currentState_;
-       std::wstringstream currentCommandString_;
-       std::wstring command_name_;
-       std::vector<std::wstring> parameters_;
-       clk_command_processor& command_processor_;
-       IO::client_connection<wchar_t>::ptr client_connection_;
 };
 
 clk_protocol_strategy_factory::clk_protocol_strategy_factory(
-               const std::vector<spl::shared_ptr<core::video_channel>>& channels)
+               const std::vector<spl::shared_ptr<core::video_channel>>& channels,
+               const spl::shared_ptr<core::cg_producer_registry>& cg_registry,
+               const spl::shared_ptr<const core::frame_producer_registry>& producer_registry)
 {
-       add_command_handlers(command_processor_, channels.at(0));
+       add_command_handlers(command_processor_, channels, channels.at(0), cg_registry, producer_registry);
 }
 
 IO::protocol_strategy<wchar_t>::ptr clk_protocol_strategy_factory::create(