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