]> git.sesse.net Git - casparcg/blob - modules/bluefish/bluefish.cpp
7907123fd8cd71d05b29cc0d1446cc635f14355b
[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 \r
48 std::wstring get_version()\r
49 {\r
50         try\r
51         {\r
52                 blue_initialize();\r
53         }\r
54         catch(...)\r
55         {\r
56                 return L"Not found";\r
57         }\r
58 \r
59         if(!BlueVelvetVersion)\r
60                 return L"Unknown";\r
61 \r
62         return widen(std::string(BlueVelvetVersion()));\r
63 }\r
64 \r
65 std::vector<std::wstring> get_device_list()\r
66 {\r
67         std::vector<std::wstring> devices;\r
68 \r
69         try\r
70         {               \r
71                 blue_initialize();\r
72                 \r
73                 auto blue = create_blue();\r
74 \r
75                 for(int n = 1; BLUE_PASS(blue->device_attach(n, FALSE)); ++n)\r
76                 {                               \r
77                         devices.push_back(std::wstring(get_card_desc(*blue)) + L" [" + boost::lexical_cast<std::wstring>(n) + L"]");\r
78                         blue->device_detach();          \r
79                 }\r
80         }\r
81         catch(...){}\r
82 \r
83         return devices;\r
84 }\r
85 \r
86 }}