]> git.sesse.net Git - casparcg/blobdiff - shell/main.cpp
Moved framerate calculation from CLS/CINF to thumbnail generation time for each file...
[casparcg] / shell / main.cpp
index a41f3857b28e91b74c528cbdd2af90700e63ffa7..f7cd96ca9df6c907191e3811196b08bffc59288f 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
+* Copyright 2013 Sveriges Television AB http://casparcg.com/\r
 *\r
 * This file is part of CasparCG (www.casparcg.com).\r
 *\r
@@ -52,6 +52,7 @@
 #include <modules/flash/flash.h>\r
 #include <modules/ffmpeg/ffmpeg.h>\r
 #include <modules/image/image.h>\r
+#include <modules/newtek/util/air_send.h>\r
 \r
 #include <common/env.h>\r
 #include <common/exception/win32_exception.h>\r
@@ -159,6 +160,7 @@ void print_info()
        CASPAR_LOG(info) << L"FFMPEG-swscale "  << caspar::ffmpeg::get_swscale_version();\r
        CASPAR_LOG(info) << L"Flash "                   << caspar::flash::get_version();\r
        CASPAR_LOG(info) << L"Template-Host "   << caspar::flash::get_cg_version();\r
+       CASPAR_LOG(info) << L"NewTek iVGA "             << (caspar::newtek::airsend::is_available() ? L"available" : L"unavailable (" + caspar::newtek::airsend::dll_name() + L")");\r
 }\r
 \r
 LONG WINAPI UserUnhandledExceptionFilter(EXCEPTION_POINTERS* info)\r
@@ -177,9 +179,9 @@ LONG WINAPI UserUnhandledExceptionFilter(EXCEPTION_POINTERS* info)
     return EXCEPTION_EXECUTE_HANDLER;\r
 }\r
 \r
-void make_upper_case(std::wstring& str)\r
+std::wstring make_upper_case(const std::wstring& str)\r
 {\r
-       boost::to_upper(str);\r
+       return boost::to_upper_copy(str);\r
 }\r
 \r
 int main(int argc, wchar_t* argv[])\r
@@ -211,7 +213,7 @@ int main(int argc, wchar_t* argv[])
        SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS);\r
 \r
        // Install structured exception handler.\r
-       caspar::win32_exception::install_handler();\r
+       caspar::win32_exception::ensure_handler_installed_for_thread("main-thread");\r
                                \r
        // Increase time precision. This will increase accuracy of function like Sleep(1) from 10 ms to 1 ms.\r
        struct inc_prec\r
@@ -226,11 +228,11 @@ int main(int argc, wchar_t* argv[])
                tbb_thread_installer(){observe(true);}\r
                void on_scheduler_entry(bool is_worker)\r
                {\r
-                       //caspar::detail::SetThreadName(GetCurrentThreadId(), "tbb-worker-thread");\r
-                       caspar::win32_exception::install_handler();\r
+                       caspar::win32_exception::ensure_handler_installed_for_thread("tbb-worker-thread");\r
                }\r
        } tbb_thread_installer;\r
 \r
+       bool restart = false;\r
        tbb::task_scheduler_init init;\r
        \r
        try \r
@@ -259,7 +261,8 @@ int main(int argc, wchar_t* argv[])
                boost::property_tree::xml_writer_settings<wchar_t> w(' ', 3);\r
                boost::property_tree::write_xml(str, caspar::env::properties(), w);\r
                CASPAR_LOG(info) << L"casparcg.config:\n-----------------------------------------\n" << str.str().c_str() << L"-----------------------------------------";\r
-               bool wait_for_keypress;\r
+               tbb::atomic<bool> wait_for_keypress;\r
+               wait_for_keypress = false;\r
 \r
                {\r
                        boost::promise<bool> shutdown_server_now;\r
@@ -270,12 +273,15 @@ int main(int argc, wchar_t* argv[])
 \r
                        // Use separate thread for the blocking console input, will be terminated \r
                        // anyway when the main thread terminates.\r
-                       boost::thread stdin_thread([&caspar_server, &shutdown_server_now]\r
+                       boost::thread stdin_thread([&caspar_server, &shutdown_server_now, &wait_for_keypress]\r
                        {\r
+                               caspar::win32_exception::ensure_handler_installed_for_thread("stdin-thread");\r
+\r
                                // Create a amcp parser for console commands.\r
                                caspar::protocol::amcp::AMCPProtocolStrategy amcp(\r
                                                caspar_server.get_channels(),\r
                                                caspar_server.get_thumbnail_generator(),\r
+                                               caspar_server.get_media_info_repo(),\r
                                                shutdown_server_now);\r
 \r
                                // Create a dummy client which prints amcp responses to console.\r
@@ -287,11 +293,12 @@ int main(int argc, wchar_t* argv[])
                                        std::getline(std::wcin, wcmd); // TODO: It's blocking...\r
                                \r
                                        //boost::to_upper(wcmd);  // TODO COMPILER crashes on this line, Strange!\r
-                                       make_upper_case(wcmd);\r
+                                       auto upper_cmd = make_upper_case(wcmd);\r
 \r
-                                       if(wcmd == L"EXIT" || wcmd == L"Q" || wcmd == L"QUIT" || wcmd == L"BYE")\r
+                                       if(upper_cmd == L"EXIT" || upper_cmd == L"Q" || upper_cmd == L"QUIT" || upper_cmd == L"BYE")\r
                                        {\r
-                                               shutdown_server_now.set_value(true); // True to wait for keypress\r
+                                               wait_for_keypress = true;\r
+                                               shutdown_server_now.set_value(false); // False to not restart server\r
                                                break;\r
                                        }\r
                                \r
@@ -316,7 +323,7 @@ int main(int argc, wchar_t* argv[])
                                                                        L"PLAY 2-2 " + file + L" LOOP\r\n" \r
                                                                        L"PLAY 2-3 " + file + L" LOOP\r\n";\r
                                                }\r
-                                               else if(wcmd.substr(0, 1) == L"X")\r
+                                               else if(upper_cmd.substr(0, 1) == L"X")\r
                                                {\r
                                                        int num = 0;\r
                                                        std::wstring file;\r
@@ -356,7 +363,7 @@ int main(int argc, wchar_t* argv[])
                                }       \r
                        });\r
                        stdin_thread.detach();\r
-                       wait_for_keypress = shutdown_server.get();\r
+                       restart = shutdown_server.get();\r
                }\r
                Sleep(500);\r
                CASPAR_LOG(info) << "Successfully shutdown CasparCG Server.";\r
@@ -379,5 +386,5 @@ int main(int argc, wchar_t* argv[])
                Sleep(4000);\r
        }       \r
        \r
-       return 0;\r
+       return restart ? 5 : 0;\r
 }
\ No newline at end of file