X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fdecklink%2Fdecklink.cpp;h=7d0a4580658db1a61ec476759e94b0908187832c;hb=db98d63fe01d245354547a202b479e36339fc709;hp=22d164959360f13683c9ca6438606d337ce45e3d;hpb=52b74f3c499e70dc74e9f926b4783968b012cd37;p=casparcg diff --git a/modules/decklink/decklink.cpp b/modules/decklink/decklink.cpp index 22d164959..7d0a45806 100644 --- a/modules/decklink/decklink.cpp +++ b/modules/decklink/decklink.cpp @@ -1,93 +1,124 @@ -/* -* copyright (c) 2010 Sveriges Television AB -* -* This file is part of CasparCG. -* -* CasparCG is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* CasparCG is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with CasparCG. If not, see . -* -*/ -#include "stdafx.h" - -#include "decklink.h" -#include "util/util.h" - -#include "consumer/decklink_consumer.h" -#include "producer/decklink_producer.h" - -#include -#include - -#include "interop/DeckLinkAPI_h.h" - -#pragma warning(push) -#pragma warning(disable : 4996) - - #include - - #include - #include - -#pragma warning(push) - -namespace caspar{ - -void init_decklink() -{ - core::register_consumer_factory(create_decklink_consumer); - core::register_producer_factory(create_decklink_producer); -} - -std::wstring get_decklink_version() -{ - std::wstring version = L"Unknown"; - - ::CoInitialize(nullptr); - try - { - CComPtr pDecklinkIterator; - if(SUCCEEDED(pDecklinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator))) - version = get_version(pDecklinkIterator); - } - catch(...){} - ::CoUninitialize(); - - return version; -} - -std::vector get_decklink_device_list() -{ - std::vector devices; - - ::CoInitialize(nullptr); - try - { - CComPtr pDecklinkIterator; - if(SUCCEEDED(pDecklinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator))) - { - CComPtr decklink; - for(int n = 1; pDecklinkIterator->Next(&decklink) == S_OK; ++n) - { - BSTR model_name = L"Unknown"; - decklink->GetModelName(&model_name); - devices.push_back(L"[" + boost::lexical_cast(n) + L"] " + model_name); - } - } - } - catch(...){} - ::CoUninitialize(); - - return devices; -} - -} \ No newline at end of file +/* +* Copyright (c) 2011 Sveriges Television AB +* +* This file is part of CasparCG (www.casparcg.com). +* +* CasparCG is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* CasparCG is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with CasparCG. If not, see . +* +* Author: Robert Nagy, ronag89@gmail.com +*/ + +#include "stdafx.h" + +#include "decklink.h" +#include "util/util.h" + +#include "consumer/decklink_consumer.h" +#include "producer/decklink_producer.h" + +#include +#include +#include + +#include + +#include "interop/DeckLinkAPI_h.h" + +#pragma warning(push) +#pragma warning(disable : 4996) + + #include + + #include + #include + +#pragma warning(push) + +namespace caspar { namespace decklink { + +std::wstring version() +{ + std::wstring version = L"Not found"; + + struct co_init + { + co_init(){ ::CoInitialize(nullptr); } + ~co_init(){ ::CoUninitialize(); } + } init; + + try + { + CComPtr pDecklinkIterator; + if (SUCCEEDED(pDecklinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator))) + version = decklink::version(pDecklinkIterator); + } + catch (...){} + + return version; +} + +std::vector device_list() +{ + std::vector devices; + + struct co_init + { + co_init(){ ::CoInitialize(nullptr); } + ~co_init(){ ::CoUninitialize(); } + } init; + + try + { + CComPtr pDecklinkIterator; + if (SUCCEEDED(pDecklinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator))) + { + IDeckLink* decklink; + for (int n = 1; pDecklinkIterator->Next(&decklink) == S_OK; ++n) + { + BSTR model_name = L"Unknown"; + decklink->GetModelName(&model_name); + decklink->Release(); + devices.push_back(std::wstring(model_name) + L" [" + boost::lexical_cast(n)+L"]"); + } + } + } + catch (...){} + + return devices; +} + +void init(const spl::shared_ptr& repo) +{ + struct co_init + { + co_init(){::CoInitialize(nullptr);} + ~co_init(){::CoUninitialize();} + } init; + + CComPtr pDecklinkIterator; + if(FAILED(pDecklinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator))) + return; + + core::register_consumer_factory([](const std::vector& params){return create_consumer(params);}); + core::register_producer_factory(create_producer); + repo->register_system_info_provider([](boost::property_tree::wptree& info) + { + info.add(L"system.decklink.version", version()); + + for (auto device : device_list()) + info.add(L"system.decklink.device", device); + }); +} + +}} \ No newline at end of file