*/
-#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>
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)
{
}
{
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());
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 (...)
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(