]> git.sesse.net Git - casparcg/blob - modules/bluefish/bluefish.cpp
2b41c05656cba0bd4eac7fcf7233e2c600f98ce1
[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 "StdAfx.h"\r
23 \r
24 #include "bluefish.h"\r
25 \r
26 #include "consumer/bluefish_consumer.h"\r
27 \r
28 #include "util/blue_velvet.h"\r
29 \r
30 #include <common/log.h>\r
31 #include <common/utf.h>\r
32 \r
33 #include <core/consumer/frame_consumer.h>\r
34 \r
35 #include <boost/lexical_cast.hpp>\r
36 \r
37 namespace caspar { namespace bluefish {\r
38 \r
39 void init()\r
40 {\r
41         try\r
42         {\r
43                 blue_initialize();\r
44                 core::register_consumer_factory([](const std::vector<std::wstring>& params)\r
45                 {\r
46                         return create_consumer(params);\r
47                 });\r
48         }\r
49         catch(...){}\r
50 }\r
51 \r
52 std::wstring 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 u16(BlueVelvetVersion());\r
67 }\r
68 \r
69 std::vector<std::wstring> 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 }}