2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
4 * This file is part of CasparCG (www.casparcg.com).
6 * CasparCG is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * CasparCG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
19 * Author: Robert Nagy, ronag89@gmail.com
25 #include "util/util.h"
27 #include "consumer/decklink_consumer.h"
28 #include "producer/decklink_producer.h"
30 #include <core/consumer/frame_consumer.h>
31 #include <core/producer/frame_producer.h>
32 #include <core/system_info_provider.h>
34 #include <boost/property_tree/ptree.hpp>
36 #include "interop/DeckLinkAPI_h.h"
39 #pragma warning(disable : 4996)
48 namespace caspar { namespace decklink {
50 std::wstring version()
52 std::wstring version = L"Not found";
56 co_init(){ ::CoInitialize(nullptr); }
57 ~co_init(){ ::CoUninitialize(); }
62 CComPtr<IDeckLinkIterator> pDecklinkIterator;
63 if (SUCCEEDED(pDecklinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator)))
64 version = decklink::version(pDecklinkIterator);
71 std::vector<std::wstring> device_list()
73 std::vector<std::wstring> devices;
77 co_init(){ ::CoInitialize(nullptr); }
78 ~co_init(){ ::CoUninitialize(); }
83 CComPtr<IDeckLinkIterator> pDecklinkIterator;
84 if (SUCCEEDED(pDecklinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator)))
87 for (int n = 1; pDecklinkIterator->Next(&decklink) == S_OK; ++n)
89 BSTR model_name = L"Unknown";
90 decklink->GetModelName(&model_name);
92 devices.push_back(std::wstring(model_name) + L" [" + boost::lexical_cast<std::wstring>(n)+L"]");
101 void init(core::module_dependencies dependencies)
105 co_init(){::CoInitialize(nullptr);}
106 ~co_init(){::CoUninitialize();}
109 CComPtr<IDeckLinkIterator> pDecklinkIterator;
110 if(FAILED(pDecklinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator)))
113 core::register_consumer_factory(create_consumer);
114 core::register_preconfigured_consumer_factory(L"decklink", create_preconfigured_consumer);
115 core::register_producer_factory(create_producer);
116 dependencies.system_info_provider_repo->register_system_info_provider([](boost::property_tree::wptree& info)
118 info.add(L"system.decklink.version", version());
120 for (auto device : device_list())
121 info.add(L"system.decklink.device", device);