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