]> git.sesse.net Git - casparcg/blobdiff - shell/main.cpp
2.0.0.2: Fixed compability with CasparCG Client.
[casparcg] / shell / main.cpp
index 5278dd7cfb0c2415d6fba29eb2acfad91f764960..4995dafd44f6a03a73a3ccb1457f3ed48e4e0d5d 100644 (file)
 \r
 #include <conio.h>\r
 \r
-#include <core/config.h>\r
-#include <core/server.h>\r
-#include <core/protocol/amcp/AMCPProtocolStrategy.h>\r
+#include "bootstrapper.h"\r
+\r
 #include <common/exception/win32_exception.h>\r
 #include <common/exception/exceptions.h>\r
 #include <common/log/log.h>\r
+#include <common/env.h>\r
+#include <common/utility/assert.h>\r
+#include <protocol/amcp/AMCPProtocolStrategy.h>\r
+\r
+#if defined(_MSC_VER)\r
+#pragma warning (disable : 4244)\r
+#endif\r
+\r
+extern "C" \r
+{\r
+       #define __STDC_CONSTANT_MACROS\r
+       #define __STDC_LIMIT_MACROS\r
+       #include <libavformat/avformat.h>\r
+}\r
+\r
+#include <atlbase.h>\r
 \r
 using namespace caspar;\r
 using namespace caspar::core;\r
+using namespace caspar::protocol;\r
+\r
+// NOTE: This is needed in order to make CComObject work since this is not a real ATL project.\r
+CComModule _AtlModule;\r
+extern __declspec(selectany) CAtlModule* _pAtlModule = &_AtlModule;\r
 \r
 class win32_handler_tbb_installer : public tbb::task_scheduler_observer\r
 {\r
@@ -47,19 +67,31 @@ public:
        win32_handler_tbb_installer()   {observe(true);}\r
        void on_scheduler_entry(bool is_worker) \r
        {\r
-               CASPAR_LOG(debug) << L"Started TBB Worker Thread.";\r
+               //CASPAR_LOG(debug) << L"Started TBB Worker Thread.";\r
                win32_exception::install_handler();\r
        }\r
+       void on_scheduler_exit()\r
+       {\r
+               //CASPAR_LOG(debug) << L"Stopped TBB Worker Thread.";\r
+       }\r
 };\r
  \r
 int main(int argc, wchar_t* argv[])\r
 {\r
+       // Init FFMPEG\r
+       av_register_all();\r
+       avcodec_init();\r
+\r
+       // Increase time precision\r
+       timeBeginPeriod(1);\r
+\r
+       // Start caspar\r
        std::wstringstream str;\r
-       str << "CasparCG " << CASPAR_VERSION_STR << " " << CASPAR_VERSION_TAG;\r
+       str << "CasparCG " << env::version() << " " << env::version_tag();\r
        SetConsoleTitle(str.str().c_str());\r
 \r
-       CASPAR_LOG(info) << L"Starting CasparCG Video Playout Server Ver: " << CASPAR_VERSION_STR << " Tag: " << CASPAR_VERSION_TAG << std::endl;\r
-       CASPAR_LOG(info) << L"Copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\n\n" << std::endl;\r
+       std::wcout << L"Copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\n" << std::endl;\r
+       std::wcout << L"Starting CasparCG Video Playout Server Ver: " << env::version() << env::version_tag() << std::endl;\r
 \r
        EnableMenuItem(GetSystemMenu(GetConsoleWindow(), FALSE), SC_CLOSE , MF_GRAYED);\r
        DrawMenuBar(GetConsoleWindow());\r
@@ -74,16 +106,14 @@ int main(int argc, wchar_t* argv[])
        MessageBox(nullptr, TEXT("Now is the time to connect for remote debugging..."), TEXT("Debug"), MB_OK | MB_TOPMOST);\r
 #endif\r
 \r
-       log::add_file_sink(server::log_folder());\r
+       log::add_file_sink(env::log_folder());\r
        \r
-       CASPAR_LOG(debug) << "Started Main Thread";\r
-\r
        win32_handler_tbb_installer win32_handler_tbb_installer;\r
        win32_exception::install_handler();\r
                                \r
        try \r
        {\r
-               server caspar_device;\r
+               bootstrapper caspar_device;\r
                                \r
                auto dummy = std::make_shared<IO::DummyClientInfo>();\r
                amcp::AMCPProtocolStrategy amcp(caspar_device.get_channels());\r
@@ -93,7 +123,22 @@ int main(int argc, wchar_t* argv[])
                        std::wstring wcmd;\r
                        std::getline(std::wcin, wcmd); // TODO: It's blocking...\r
                        is_running = wcmd != L"exit" && wcmd != L"q";\r
-                       if(wcmd.substr(0, 1) == L"1")\r
+                       if(wcmd.substr(0, 2) == L"12")\r
+                       {\r
+                               wcmd = L"LOADBG 1-1 A LOOP AUTOPLAY\r\n";\r
+                               amcp.Parse(wcmd.c_str(), wcmd.length(), dummy);\r
+                               wcmd = L"LOADBG 1-2 DV LOOP AUTOPLAY\r\n";\r
+                               amcp.Parse(wcmd.c_str(), wcmd.length(), dummy);\r
+                               wcmd = L"MIXER 1-1 VIDEO FIX_RECT 0.0 0.0 0.5 0.5\r\n";\r
+                               amcp.Parse(wcmd.c_str(), wcmd.length(), dummy);\r
+                               wcmd = L"MIXER 1-2 VIDEO FIX_RECT 0.5 0.0 0.5 0.5\r\n";\r
+                               amcp.Parse(wcmd.c_str(), wcmd.length(), dummy);\r
+                       }\r
+                       else if(wcmd.substr(0, 2) == L"10")\r
+                               wcmd = L"MIXER 1-1 VIDEO CLIP_RECT 0.4 0.4 0.5 0.5";\r
+                       if(wcmd.substr(0, 2) == L"11")\r
+                               wcmd = L"MIXER 1-1 VIDEO FIX_RECT 0.4 0.4 0.5 0.5";\r
+                       else if(wcmd.substr(0, 1) == L"1")\r
                                wcmd = L"LOADBG 1-1 " + wcmd.substr(1, wcmd.length()-1) + L" SLIDE 100 LOOP AUTOPLAY";\r
                        else if(wcmd.substr(0, 1) == L"2")\r
                                wcmd = L"LOADBG 1-1 " + wcmd.substr(1, wcmd.length()-1) + L" PUSH 100 LOOP AUTOPLAY";\r
@@ -109,6 +154,8 @@ int main(int argc, wchar_t* argv[])
                                wcmd = L"LOAD 1-1 720p2500";\r
                        else if(wcmd.substr(0, 1) == L"8")\r
                                wcmd = L"LOAD 1-1 #FFFFFFFF AUTOPLAY";\r
+                       else if(wcmd.substr(0, 1) == L"9")\r
+                               wcmd = L"LOADBG 1-2 " + wcmd.substr(1, wcmd.length()-1) + L" [1.0-2.0] LOOP AUTOPLAY";\r
 \r
                        wcmd += L"\r\n";\r
                        amcp.Parse(wcmd.c_str(), wcmd.length(), dummy);\r
@@ -121,7 +168,10 @@ int main(int argc, wchar_t* argv[])
                std::wcout << L"Press Any Key To Exit";\r
                _getwch();\r
        }       \r
-       CASPAR_LOG(debug) << "Ended Main Thread";\r
 \r
+       timeEndPeriod(1);\r
+\r
+       CASPAR_LOG(info) << "Successfully shutdown CasparCG Server";\r
+       \r
        return 0;\r
 }
\ No newline at end of file