X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fdecklink%2Fdecklink.cpp;h=bf6de45bea995c7ab9a0184972e83a4ea4edb369;hb=f7b48279d43e30c270ef532f97d59f0582a73efc;hp=4a8ec9ead05966282ab0d4da92a3461da831b399;hpb=f78d434c81a83b428ae2e24af862d5f2702c34f9;p=casparcg diff --git a/modules/decklink/decklink.cpp b/modules/decklink/decklink.cpp index 4a8ec9ead..bf6de45be 100644 --- a/modules/decklink/decklink.cpp +++ b/modules/decklink/decklink.cpp @@ -1,113 +1,97 @@ -/* -* 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 "interop/DeckLinkAPI_h.h" - -#pragma warning(push) -#pragma warning(disable : 4996) - - #include - - #include - #include - -#pragma warning(push) - -namespace caspar { namespace decklink { - -void init() -{ - 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); -} - -std::string get_version() -{ - std::string version = "Not found"; - - struct co_init - { - co_init(){::CoInitialize(nullptr);} - ~co_init(){::CoUninitialize();} - } init; - - try - { - CComPtr pDecklinkIterator; - if(SUCCEEDED(pDecklinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator))) - version = get_version(pDecklinkIterator); - } - catch(...){} - - return version; -} - -std::vector get_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))) - { - CComPtr decklink; - for(int n = 1; pDecklinkIterator->Next(&decklink) == S_OK; ++n) - { - BSTR model_name = L"Unknown"; - decklink->GetModelName(&model_name); - devices.push_back(u8(model_name) + " [" + boost::lexical_cast(n) + "]"); - } - } - } - catch(...){} - - 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 "decklink_api.h" + +namespace caspar { namespace decklink { + +std::wstring get_version() +{ + std::wstring ver = L"Not found"; + + struct co_init init; + + try + { + ver = decklink::version(create_iterator()); + } + catch (...){} + + return ver; +} + +std::vector device_list() +{ + std::vector devices; + + struct co_init init; + + try + { + auto pDecklinkIterator = create_iterator(); + IDeckLink* decklink; + for (int n = 1; pDecklinkIterator->Next(&decklink) == S_OK; ++n) + { + String m_name; + bool success = SUCCEEDED(decklink->GetModelName(&m_name)); + decklink->Release(); + std::wstring model_name = L"Unknown"; + + if (success) + model_name = u16(m_name); + + devices.push_back(model_name + L" [" + boost::lexical_cast(n)+L"]"); + } + } + catch (...){} + + return devices; +} + +void init(core::module_dependencies dependencies) +{ + dependencies.consumer_registry->register_consumer_factory(L"Decklink Consumer", create_consumer, describe_consumer); + dependencies.consumer_registry->register_preconfigured_consumer_factory(L"decklink", create_preconfigured_consumer); + dependencies.producer_registry->register_producer_factory(L"Decklink Producer", create_producer, describe_producer); + dependencies.system_info_provider_repo->register_system_info_provider([](boost::property_tree::wptree& info) + { + info.add(L"system.decklink.version", get_version()); + + for (auto device : device_list()) + info.add(L"system.decklink.device", device); + }); +} + +}}