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