]> git.sesse.net Git - casparcg/blob - server/Main.cpp
8b9574c7bf1ad55b60cce4576719ba5fbbf81e81
[casparcg] / server / Main.cpp
1 /*\r
2 * copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
3 *\r
4 *  This file is part of CasparCG.\r
5 *\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
10 *\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
15 \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
18 *\r
19 */\r
20  \r
21 #include "StdAfx.h"\r
22 #include "Application.h"\r
23 #include "utils\FileOutputStream.h"\r
24 #include <tbb/task_scheduler_init.h>\r
25 #include <tbb/tbbmalloc_proxy.h>\r
26 \r
27 //the easy way to make it possible to forward WndProc messages into the application-object\r
28 caspar::Application* pGlobal_Application = 0;\r
29 \r
30 namespace caspar {\r
31         Application* GetApplication()\r
32         {\r
33                 return pGlobal_Application;\r
34         }\r
35 }\r
36 \r
37 int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int)\r
38 {\r
39         int returnValue = 0;\r
40         tstring commandline(lpCmdLine);\r
41         \r
42         tbb::task_scheduler_init task_scheduler(max(2, tbb::task_scheduler_init::default_num_threads()));\r
43         \r
44         //if(commandline == TEXT("install"))\r
45         //{\r
46         //      caspar::Application::InstallService();\r
47         //}\r
48         //else if(commandline == TEXT("uninstall"))\r
49         //{\r
50         //      caspar::Application::UninstallService();\r
51         //}\r
52         //else {\r
53                 try \r
54                 {\r
55                         caspar::utils::OutputStreamPtr pOutputStream(new caspar::utils::FileOutputStream(TEXT("startup.log")));\r
56                         caspar::utils::Logger::GetInstance().SetOutputStream(pOutputStream);\r
57                         caspar::utils::Logger::GetInstance().SetTimestamp(true);\r
58 \r
59                         caspar::Application app(lpCmdLine, hInstance);\r
60                         pGlobal_Application = &app;\r
61 \r
62                         //if(commandline.find(TEXT("service")) != tstring::npos)\r
63                         //      app.RunAsService();\r
64                         //else\r
65                                 returnValue = app.RunAsWindow();\r
66                 }\r
67                 catch(const std::exception& ex)\r
68                 {\r
69                         LOG << caspar::utils::LogLevel::Critical << TEXT("UNHANDLED EXCEPTION in main thread. Message: ") << ex.what();\r
70                 }\r
71 //      }\r
72                 \r
73         return returnValue;\r
74 }\r