#include <boost/lexical_cast.hpp>\r
#include <boost/algorithm/string.hpp>\r
#include <boost/filesystem.hpp>\r
+#include <boost/regex.hpp>\r
\r
#if defined(_MSC_VER)\r
#pragma warning (push, 1) // TODO: Legacy code, just disable warnings\r
}\r
}\r
\r
+\r
+\r
+//std::function<std::wstring()> channel_cg_add_command::parse(const std::wstring& message, const std::vector<renderer::render_device_ptr>& channels)\r
+//{\r
+// static boost::wregex expr(L"^CG\\s(?<CHANNEL>\\d+)-?(?<LAYER>\\d+)?\\sADD\\s(?<FLASH_LAYER>\\d+)\\s(?<TEMPLATE>\\S+)\\s?(?<START_LABEL>\\S\\S+)?\\s?(?<PLAY_ON_LOAD>\\d)?\\s?(?<DATA>.*)?");\r
+//\r
+// boost::wsmatch what;\r
+// if(!boost::regex_match(message, what, expr))\r
+// return nullptr;\r
+//\r
+// auto info = channel_info::parse(what, channels);\r
+//\r
+// int flash_layer_index = boost::lexical_cast<int>(what["FLASH_LAYER"].str());\r
+//\r
+// std::wstring templatename = what["TEMPLATE"].str();\r
+// bool play_on_load = what["PLAY_ON_LOAD"].matched ? what["PLAY_ON_LOAD"].str() != L"0" : 0;\r
+// std::wstring start_label = what["START_LABEL"].str(); \r
+// std::wstring data = get_data(what["DATA"].str());\r
+// \r
+// boost::replace_all(templatename, "\"", "");\r
+//\r
+// return [=]() -> std::wstring\r
+// { \r
+// std::wstring fullFilename = flash::flash_producer::find_template(server::template_folder() + templatename);\r
+// if(fullFilename.empty())\r
+// BOOST_THROW_EXCEPTION(file_not_found());\r
+// \r
+// std::wstring extension = boost::filesystem::wpath(fullFilename).extension();\r
+// std::wstring filename = templatename;\r
+// filename.append(extension);\r
+//\r
+// flash::get_default_cg_producer(info.channel, std::max<int>(DEFAULT_CHANNEL_LAYER+1, info.layer_index))\r
+// ->add(flash_layer_index, filename, play_on_load, start_label, data);\r
+//\r
+// CASPAR_LOG(info) << L"Executed [amcp_channel_cg_add]";\r
+// return L"";\r
+// };\r
+\r
bool LoadbgCommand::DoExecute()\r
{\r
transition_info transitionInfo;\r
\r
bool bLoop = false;\r
- unsigned short transitionParameterIndex = 1;\r
\r
- if(_parameters.size() > 1 && _parameters[1] == TEXT("LOOP"))\r
- ++transitionParameterIndex;\r
+ // TRANSITION\r
\r
- //Setup transition info\r
- if(_parameters.size() > transitionParameterIndex) //type\r
+ std::wstring message;\r
+ for(size_t n = 0; n < _parameters.size(); ++n)\r
+ message += _parameters[n] + L" ";\r
+ \r
+ static const boost::wregex expr(L".*(?<TRANSITION>CUT|PUSH|SLIDE|WIPE)\\s*(?<DURATION>\\d+)\\s*(?<TWEEN>EASE\\w*)?\\s*(?<DIRECTION>FROMLEFT|FROMRIGHT|LEFT|RIGHT)?.*");\r
+ boost::wsmatch what;\r
+ if(boost::regex_match(message, what, expr))\r
{\r
- std::wstring transitionType = _parameters[transitionParameterIndex];\r
+ auto transition = what["TRANSITION"].str();\r
+ transitionInfo.duration = lexical_cast_or_default<size_t>(what["DURATION"].str());\r
+ auto direction = what["DIRECTION"].matched ? what["DIRECTION"].str() : L"";\r
+ auto tween = what["TWEEN"].matched ? what["TWEEN"].str() : L"";\r
+ transitionInfo.tweener = get_tweener(tween); \r
\r
- if(transitionType == TEXT("CUT"))\r
+ if(transition == TEXT("CUT"))\r
transitionInfo.type = transition::cut;\r
- else if(transitionType == TEXT("MIX"))\r
+ else if(transition == TEXT("MIX"))\r
transitionInfo.type = transition::mix;\r
- else if(transitionType == TEXT("PUSH"))\r
+ else if(transition == TEXT("PUSH"))\r
transitionInfo.type = transition::push;\r
- else if(transitionType == TEXT("SLIDE"))\r
+ else if(transition == TEXT("SLIDE"))\r
transitionInfo.type = transition::slide;\r
- else if(transitionType == TEXT("WIPE"))\r
+ else if(transition == TEXT("WIPE"))\r
transitionInfo.type = transition::wipe;\r
-\r
- if(_parameters.size() > static_cast<unsigned short>(transitionParameterIndex+1)) //duration\r
- {\r
- int duration = _ttoi(_parameters[transitionParameterIndex+1].c_str());\r
- if(duration > 0)\r
- transitionInfo.duration = duration;\r
-\r
- if(_parameters.size() > static_cast<unsigned short>(transitionParameterIndex+2)) //direction\r
- {\r
- std::wstring direction = _parameters[transitionParameterIndex+2];\r
-\r
- if(direction == TEXT("FROMLEFT"))\r
- transitionInfo.direction = transition_direction::from_left;\r
- else if(direction == TEXT("FROMRIGHT"))\r
- transitionInfo.direction = transition_direction::from_right;\r
- else if(direction == TEXT("LEFT"))\r
- transitionInfo.direction = transition_direction::from_right;\r
- else if(direction == TEXT("RIGHT"))\r
- transitionInfo.direction = transition_direction::from_left;\r
- }\r
- }\r
+ \r
+ if(direction == TEXT("FROMLEFT"))\r
+ transitionInfo.direction = transition_direction::from_left;\r
+ else if(direction == TEXT("FROMRIGHT"))\r
+ transitionInfo.direction = transition_direction::from_right;\r
+ else if(direction == TEXT("LEFT"))\r
+ transitionInfo.direction = transition_direction::from_right;\r
+ else if(direction == TEXT("RIGHT"))\r
+ transitionInfo.direction = transition_direction::from_left;\r
}\r
-\r
+ \r
//Perform loading of the clip\r
try\r
{\r