2 * copyright (c) 2010 Sveriges Television AB <info@casparcg.com>
\r
4 * This file is part of CasparCG.
\r
6 * CasparCG is free software: you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation, either version 3 of the License, or
\r
9 * (at your option) any later version.
\r
11 * CasparCG is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
\r
21 #include <Windows.h>
\r
23 #include <tbb/tbbmalloc_proxy.h>
\r
24 #include <tbb/task_scheduler_observer.h>
\r
27 #define _CRTDBG_MAP_ALLOC
\r
34 #include "bootstrapper.h"
\r
36 #include <common/exception/win32_exception.h>
\r
37 #include <common/exception/exceptions.h>
\r
38 #include <common/log/log.h>
\r
39 #include <common/env.h>
\r
40 #include <common/utility/assert.h>
\r
41 #include <protocol/amcp/AMCPProtocolStrategy.h>
\r
43 using namespace caspar;
\r
44 using namespace caspar::core;
\r
45 using namespace caspar::protocol;
\r
47 class win32_handler_tbb_installer : public tbb::task_scheduler_observer
\r
50 win32_handler_tbb_installer() {observe(true);}
\r
51 void on_scheduler_entry(bool is_worker)
\r
53 CASPAR_LOG(debug) << L"Started TBB Worker Thread.";
\r
54 win32_exception::install_handler();
\r
56 void on_scheduler_exit()
\r
58 CASPAR_LOG(debug) << L"Stopped TBB Worker Thread.";
\r
62 int main(int argc, wchar_t* argv[])
\r
66 std::wstringstream str;
\r
67 str << "CasparCG " << env::version() << " " << env::version_tag();
\r
68 SetConsoleTitle(str.str().c_str());
\r
70 CASPAR_LOG(info) << L"Starting CasparCG Video Playout Server Ver: " << env::version() << env::version_tag() << std::endl;
\r
71 CASPAR_LOG(info) << L"Copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\n\n" << std::endl;
\r
73 EnableMenuItem(GetSystemMenu(GetConsoleWindow(), FALSE), SC_CLOSE , MF_GRAYED);
\r
74 DrawMenuBar(GetConsoleWindow());
\r
75 MoveWindow(GetConsoleWindow(), 800, 0, 800, 1000, true);
\r
78 _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF );
\r
79 _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_DEBUG );
\r
80 _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_DEBUG );
\r
81 _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_DEBUG );
\r
83 MessageBox(nullptr, TEXT("Now is the time to connect for remote debugging..."), TEXT("Debug"), MB_OK | MB_TOPMOST);
\r
86 log::add_file_sink(env::log_folder());
\r
88 CASPAR_LOG(debug) << "Started Main Thread";
\r
90 win32_handler_tbb_installer win32_handler_tbb_installer;
\r
91 win32_exception::install_handler();
\r
95 bootstrapper caspar_device;
\r
97 auto dummy = std::make_shared<IO::DummyClientInfo>();
\r
98 amcp::AMCPProtocolStrategy amcp(caspar_device.get_channels());
\r
99 bool is_running = true;
\r
103 std::getline(std::wcin, wcmd); // TODO: It's blocking...
\r
104 is_running = wcmd != L"exit" && wcmd != L"q";
\r
105 if(wcmd.substr(0, 2) == L"12")
\r
107 wcmd = L"LOADBG 1-1 A LOOP AUTOPLAY\r\n";
\r
108 amcp.Parse(wcmd.c_str(), wcmd.length(), dummy);
\r
109 wcmd = L"LOADBG 1-2 DV LOOP AUTOPLAY\r\n";
\r
110 amcp.Parse(wcmd.c_str(), wcmd.length(), dummy);
\r
111 wcmd = L"MIXER 1-1 VIDEO FIX_RECT 0.0 0.0 0.5 0.5\r\n";
\r
112 amcp.Parse(wcmd.c_str(), wcmd.length(), dummy);
\r
113 wcmd = L"MIXER 1-2 VIDEO FIX_RECT 0.5 0.0 0.5 0.5\r\n";
\r
114 amcp.Parse(wcmd.c_str(), wcmd.length(), dummy);
\r
116 else if(wcmd.substr(0, 2) == L"10")
\r
117 wcmd = L"MIXER 1-1 VIDEO CLIP_RECT 0.4 0.4 0.5 0.5";
\r
118 if(wcmd.substr(0, 2) == L"11")
\r
119 wcmd = L"MIXER 1-1 VIDEO FIX_RECT 0.4 0.4 0.5 0.5";
\r
120 else if(wcmd.substr(0, 1) == L"1")
\r
121 wcmd = L"LOADBG 1-1 " + wcmd.substr(1, wcmd.length()-1) + L" SLIDE 100 LOOP AUTOPLAY";
\r
122 else if(wcmd.substr(0, 1) == L"2")
\r
123 wcmd = L"LOADBG 1-1 " + wcmd.substr(1, wcmd.length()-1) + L" PUSH 100 LOOP AUTOPLAY";
\r
124 else if(wcmd.substr(0, 1) == L"3")
\r
125 wcmd = L"LOADBG 1-1 " + wcmd.substr(1, wcmd.length()-1) + L" MIX 100 LOOP AUTOPLAY";
\r
126 else if(wcmd.substr(0, 1) == L"4")
\r
127 wcmd = L"LOADBG 1-1 " + wcmd.substr(1, wcmd.length()-1) + L" WIPE 100 LOOP AUTOPLAY";
\r
128 else if(wcmd.substr(0, 1) == L"5")
\r
129 wcmd = L"LOADBG 1-2 " + wcmd.substr(1, wcmd.length()-1) + L" LOOP AUTOPLAY";
\r
130 else if(wcmd.substr(0, 1) == L"6")
\r
131 wcmd = L"CG 1-2 ADD 1 BBTELEFONARE 1";
\r
132 else if(wcmd.substr(0, 1) == L"7")
\r
133 wcmd = L"LOAD 1-1 720p2500";
\r
134 else if(wcmd.substr(0, 1) == L"8")
\r
135 wcmd = L"LOAD 1-1 #FFFFFFFF AUTOPLAY";
\r
136 else if(wcmd.substr(0, 1) == L"9")
\r
137 wcmd = L"LOADBG 1-2 " + wcmd.substr(1, wcmd.length()-1) + L" [1.0-2.0] LOOP AUTOPLAY";
\r
140 amcp.Parse(wcmd.c_str(), wcmd.length(), dummy);
\r
143 catch(const std::exception&)
\r
145 CASPAR_LOG(fatal) << "UNHANDLED EXCEPTION in main thread.";
\r
146 CASPAR_LOG_CURRENT_EXCEPTION();
\r
147 std::wcout << L"Press Any Key To Exit";
\r
150 CASPAR_LOG(debug) << "Ended Main Thread";
\r