]> git.sesse.net Git - casparcg/blob - modules/bluefish/bluefish.cpp
2.0. Updated namespaces.
[casparcg] / modules / bluefish / bluefish.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 #include "bluefish.h"\r
21 \r
22 #include "consumer/bluefish_consumer.h"\r
23 \r
24 #include "util/blue_velvet.h"\r
25 \r
26 #include <common/log/log.h>\r
27 #include <common/utility/string.h>\r
28 \r
29 #include <core/consumer/frame_consumer.h>\r
30 \r
31 #include <boost/lexical_cast.hpp>\r
32 \r
33 namespace caspar { namespace bluefish {\r
34 \r
35 void init()\r
36 {\r
37         try\r
38         {\r
39                 blue_initialize();\r
40                 core::register_consumer_factory([](const std::vector<std::wstring>& params)\r
41                 {\r
42                         return create_consumer(params);\r
43                 });\r
44         }\r
45         catch(...)\r
46         {\r
47                 //CASPAR_LOG_CURRENT_EXCEPTION();\r
48                 CASPAR_LOG(info) << L"Bluefish not supported.";\r
49         }\r
50 }\r
51 \r
52 std::wstring get_version()\r
53 {\r
54         try\r
55         {\r
56                 blue_initialize();\r
57         }\r
58         catch(...)\r
59         {\r
60                 return L"Not found";\r
61         }\r
62 \r
63         if(!BlueVelvetVersion)\r
64                 return L"Unknown";\r
65 \r
66         return widen(std::string(BlueVelvetVersion()));\r
67 }\r
68 \r
69 std::vector<std::wstring> get_device_list()\r
70 {\r
71         std::vector<std::wstring> devices;\r
72 \r
73         try\r
74         {               \r
75                 blue_initialize();\r
76                 \r
77                 auto blue = create_blue();\r
78 \r
79                 for(int n = 1; BLUE_PASS(blue->device_attach(n, FALSE)); ++n)\r
80                 {                               \r
81                         devices.push_back(std::wstring(get_card_desc(*blue)) + L" [" + boost::lexical_cast<std::wstring>(n) + L"]");\r
82                         blue->device_detach();          \r
83                 }\r
84         }\r
85         catch(...){}\r
86 \r
87         return devices;\r
88 }\r
89 \r
90 }}