X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=shell%2Fmain.cpp;h=f9e827305259949c6d32282e2a362bc8878a0bd1;hb=0f3e10032e58269125392b8ce6a30134af1dd7b6;hp=493340622a49bd170b320af6f6c7e2e64addc7bf;hpb=9cda7b764339f16ce7babe85e78c016a28bbfa1d;p=casparcg diff --git a/shell/main.cpp b/shell/main.cpp index 493340622..f9e827305 100644 --- a/shell/main.cpp +++ b/shell/main.cpp @@ -66,6 +66,8 @@ #include #include +#include + using namespace caspar; // NOTE: This is needed in order to make CComObject work since this is not a real ATL project. @@ -155,15 +157,127 @@ LONG WINAPI UserUnhandledExceptionFilter(EXCEPTION_POINTERS* info) << L"Flag:" << info->ExceptionRecord->ExceptionFlags << L"\n" << L"Info:" << info->ExceptionRecord->ExceptionInformation << L"\n" << L"Continuing execution. \n#######################"; + + CASPAR_LOG_CALL_STACK(); } catch(...){} - return EXCEPTION_EXECUTE_HANDLER; + return EXCEPTION_CONTINUE_EXECUTION; +} + +void run() +{ + // Create server object which initializes channels, protocols and controllers. + server caspar_server; + + auto server = spl::make_shared(5253); + caspar_server.subscribe(server); + + //auto console_obs = reactive::make_observer([](const monitor::event& e) + //{ + // std::stringstream str; + // str << e; + // CASPAR_LOG(trace) << str.str().c_str(); + //}); + + //caspar_server.subscribe(console_obs); + + // Create a amcp parser for console commands. + protocol::amcp::AMCPProtocolStrategy amcp(caspar_server.channels()); + + // Create a dummy client which prints amcp responses to console. + auto console_client = std::make_shared(); + + std::wstring wcmd; + while(true) + { + std::getline(std::wcin, wcmd); // TODO: It's blocking... + + boost::to_upper(wcmd); + + if(wcmd == L"EXIT" || wcmd == L"Q" || wcmd == L"QUIT" || wcmd == L"BYE") + break; + + // This is just dummy code for testing. + if(wcmd.substr(0, 1) == L"1") + wcmd = L"LOADBG 1-1 " + wcmd.substr(1, wcmd.length()-1) + L" SLIDE 100 LOOP \r\nPLAY 1-1"; + else if(wcmd.substr(0, 1) == L"2") + wcmd = L"MIXER 1-0 VIDEO IS_KEY 1"; + else if(wcmd.substr(0, 1) == L"3") + wcmd = L"CG 1-2 ADD 1 BBTELEFONARE 1"; + else if(wcmd.substr(0, 1) == L"4") + wcmd = L"PLAY 1-1 DV FILTER yadif=1:-1 LOOP"; + else if(wcmd.substr(0, 1) == L"5") + { + auto file = wcmd.substr(2, wcmd.length()-1); + wcmd = L"PLAY 1-1 " + file + L" LOOP\r\n" + L"PLAY 1-2 " + file + L" LOOP\r\n" + L"PLAY 1-3 " + file + L" LOOP\r\n" + L"PLAY 2-1 " + file + L" LOOP\r\n" + L"PLAY 2-2 " + file + L" LOOP\r\n" + L"PLAY 2-3 " + file + L" LOOP\r\n"; + } + else if(wcmd.substr(0, 1) == L"7") + { + wcmd = L""; + wcmd += L"CLEAR 1\r\n"; + wcmd += L"MIXER 1 CLEAR\r\n"; + wcmd += L"PLAY 1-0 GREEN\r\n"; + wcmd += L"PLAY 1-1 BLUE\r\n"; + wcmd += L"CG 1-2 ADD 1 ECS_TEST 1\r\n"; + wcmd += L"MIXER 1-2 FILL 0 -1 1 2\r\n"; + } + else if(wcmd.substr(0, 1) == L"8") + { + wcmd = L""; + wcmd += L"MIXER 1-1 FILL 0.0 0.5 1.0 1.0 500 linear DEFER\r\n"; + wcmd += L"MIXER 1-2 FILL 0.0 0.0 1.0 1.0 500 linear DEFER\r\n"; + wcmd += L"MIXER 1 COMMIT\r\n"; + } + else if(wcmd.substr(0, 1) == L"X") + { + int num = 0; + std::wstring file; + try + { + num = boost::lexical_cast(wcmd.substr(1, 2)); + file = wcmd.substr(4, wcmd.length()-1); + } + catch(...) + { + num = boost::lexical_cast(wcmd.substr(1, 1)); + file = wcmd.substr(3, wcmd.length()-1); + } + + int n = 0; + int num2 = num; + while(num2 > 0) + { + num2 >>= 1; + n++; + } + + wcmd = L"MIXER 1 GRID " + boost::lexical_cast(n); + + for(int i = 1; i <= num; ++i) + wcmd += L"\r\nPLAY 1-" + boost::lexical_cast(i) + L" " + file + L" LOOP";// + L" SLIDE 100 LOOP"; + } + + wcmd += L"\r\n"; + amcp.Parse(wcmd.c_str(), static_cast(wcmd.length()), console_client); + } + CASPAR_LOG(info) << "Successfully shutdown CasparCG Server."; +} + +void on_abort(int) +{ + CASPAR_THROW_EXCEPTION(invalid_operation() << msg_info("abort called")); } int main(int argc, wchar_t* argv[]) { SetUnhandledExceptionFilter(UserUnhandledExceptionFilter); + signal(SIGABRT, on_abort); std::wcout << L"Type \"q\" to close application." << std::endl; @@ -234,110 +348,9 @@ int main(int argc, wchar_t* argv[]) boost::property_tree::xml_writer_settings w(' ', 3); boost::property_tree::write_xml(str, env::properties(), w); CASPAR_LOG(info) << L"casparcg.config:\n-----------------------------------------\n" << str.str().c_str() << L"-----------------------------------------"; - - { - // Create server object which initializes channels, protocols and controllers. - server caspar_server; - - auto server = spl::make_shared(5253); - caspar_server.subscribe(server); - - //auto console_obs = reactive::make_observer([](const monitor::event& e) - //{ - // std::stringstream str; - // str << e; - // CASPAR_LOG(trace) << str.str().c_str(); - //}); - - //caspar_server.subscribe(console_obs); - - // Create a amcp parser for console commands. - protocol::amcp::AMCPProtocolStrategy amcp(caspar_server.channels()); - - // Create a dummy client which prints amcp responses to console. - auto console_client = std::make_shared(); - - std::wstring wcmd; - while(true) - { - std::getline(std::wcin, wcmd); // TODO: It's blocking... - - boost::to_upper(wcmd); - - if(wcmd == L"EXIT" || wcmd == L"Q" || wcmd == L"QUIT" || wcmd == L"BYE") - break; - - // This is just dummy code for testing. - if(wcmd.substr(0, 1) == L"1") - wcmd = L"LOADBG 1-1 " + wcmd.substr(1, wcmd.length()-1) + L" SLIDE 100 LOOP \r\nPLAY 1-1"; - else if(wcmd.substr(0, 1) == L"2") - wcmd = L"MIXER 1-0 VIDEO IS_KEY 1"; - else if(wcmd.substr(0, 1) == L"3") - wcmd = L"CG 1-2 ADD 1 BBTELEFONARE 1"; - else if(wcmd.substr(0, 1) == L"4") - wcmd = L"PLAY 1-1 DV FILTER yadif=1:-1 LOOP"; - else if(wcmd.substr(0, 1) == L"5") - { - auto file = wcmd.substr(2, wcmd.length()-1); - wcmd = L"PLAY 1-1 " + file + L" LOOP\r\n" - L"PLAY 1-2 " + file + L" LOOP\r\n" - L"PLAY 1-3 " + file + L" LOOP\r\n" - L"PLAY 2-1 " + file + L" LOOP\r\n" - L"PLAY 2-2 " + file + L" LOOP\r\n" - L"PLAY 2-3 " + file + L" LOOP\r\n"; - } - else if(wcmd.substr(0, 1) == L"7") - { - wcmd = L""; - wcmd += L"CLEAR 1\r\n"; - wcmd += L"MIXER 1 CLEAR\r\n"; - wcmd += L"PLAY 1-0 GREEN\r\n"; - wcmd += L"PLAY 1-1 BLUE\r\n"; - wcmd += L"CG 1-2 ADD 1 ECS_TEST 1\r\n"; - wcmd += L"MIXER 1-2 FILL 0 -1 1 2\r\n"; - } - else if(wcmd.substr(0, 1) == L"8") - { - wcmd = L""; - wcmd += L"MIXER 1-1 FILL 0.0 0.5 1.0 1.0 500 linear DEFER\r\n"; - wcmd += L"MIXER 1-2 FILL 0.0 0.0 1.0 1.0 500 linear DEFER\r\n"; - wcmd += L"MIXER 1 COMMIT\r\n"; - } - else if(wcmd.substr(0, 1) == L"X") - { - int num = 0; - std::wstring file; - try - { - num = boost::lexical_cast(wcmd.substr(1, 2)); - file = wcmd.substr(4, wcmd.length()-1); - } - catch(...) - { - num = boost::lexical_cast(wcmd.substr(1, 1)); - file = wcmd.substr(3, wcmd.length()-1); - } - - int n = 0; - int num2 = num; - while(num2 > 0) - { - num2 >>= 1; - n++; - } - - wcmd = L"MIXER 1 GRID " + boost::lexical_cast(n); - - for(int i = 1; i <= num; ++i) - wcmd += L"\r\nPLAY 1-" + boost::lexical_cast(i) + L" " + file + L" LOOP";// + L" SLIDE 100 LOOP"; - } - - wcmd += L"\r\n"; - amcp.Parse(wcmd.c_str(), static_cast(wcmd.length()), console_client); - } - } - Sleep(500); - CASPAR_LOG(info) << "Successfully shutdown CasparCG Server."; + + run(); + system("pause"); } catch(boost::property_tree::file_parser_error&)