-/*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG.\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-*/\r
-#include "stdafx.h"\r
-\r
-#include "decklink.h"\r
-#include "util/util.h"\r
-\r
-#include "consumer/decklink_consumer.h"\r
-#include "producer/decklink_producer.h"\r
-\r
-#include <core/consumer/frame_consumer.h>\r
-#include <core/producer/frame_producer.h>\r
-\r
-#include "interop/DeckLinkAPI_h.h"\r
-\r
-#pragma warning(push)\r
-#pragma warning(disable : 4996)\r
-\r
- #include <atlbase.h>\r
-\r
- #include <atlcom.h>\r
- #include <atlhost.h>\r
-\r
-#pragma warning(push)\r
-\r
-namespace caspar{\r
-\r
-void init_decklink()\r
-{\r
- core::register_consumer_factory(create_decklink_consumer);\r
- core::register_producer_factory(create_decklink_producer);\r
-}\r
-\r
-std::wstring get_decklink_version() \r
-{\r
- std::wstring version = L"Unknown";\r
-\r
- ::CoInitialize(nullptr);\r
- try\r
- {\r
- CComPtr<IDeckLinkIterator> pDecklinkIterator;\r
- if(SUCCEEDED(pDecklinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator))) \r
- version = get_version(pDecklinkIterator);\r
- }\r
- catch(...){}\r
- ::CoUninitialize();\r
-\r
- return version;\r
-}\r
-\r
-std::vector<std::wstring> get_decklink_device_list()\r
-{\r
- std::vector<std::wstring> devices;\r
-\r
- ::CoInitialize(nullptr);\r
- try\r
- {\r
- CComPtr<IDeckLinkIterator> pDecklinkIterator;\r
- if(SUCCEEDED(pDecklinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator)))\r
- { \r
- CComPtr<IDeckLink> decklink;\r
- for(int n = 1; pDecklinkIterator->Next(&decklink) == S_OK; ++n) \r
- {\r
- BSTR model_name = L"Unknown";\r
- decklink->GetModelName(&model_name);\r
- devices.push_back(L"[" + boost::lexical_cast<std::wstring>(n) + L"] " + model_name); \r
- }\r
- }\r
- }\r
- catch(...){}\r
- ::CoUninitialize();\r
-\r
- return devices;\r
-}\r
-\r
-}
\ No newline at end of file
+/*
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
+*
+* 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 <http://www.gnu.org/licenses/>.
+*
+* 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 <core/consumer/frame_consumer.h>
+#include <core/producer/frame_producer.h>
+#include <core/system_info_provider.h>
+
+#include <boost/property_tree/ptree.hpp>
+
+#include "interop/DeckLinkAPI_h.h"
+
+#pragma warning(push)
+#pragma warning(disable : 4996)
+
+ #include <atlbase.h>
+
+ #include <atlcom.h>
+ #include <atlhost.h>
+
+#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<IDeckLinkIterator> pDecklinkIterator;
+ if (SUCCEEDED(pDecklinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator)))
+ version = decklink::version(pDecklinkIterator);
+ }
+ catch (...){}
+
+ return version;
+}
+
+std::vector<std::wstring> device_list()
+{
+ std::vector<std::wstring> devices;
+
+ struct co_init
+ {
+ co_init(){ ::CoInitialize(nullptr); }
+ ~co_init(){ ::CoUninitialize(); }
+ } init;
+
+ try
+ {
+ CComPtr<IDeckLinkIterator> 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<std::wstring>(n)+L"]");
+ }
+ }
+ }
+ catch (...){}
+
+ return devices;
+}
+
+void init(const spl::shared_ptr<core::system_info_provider_repository>& repo)
+{
+ struct co_init
+ {
+ co_init(){::CoInitialize(nullptr);}
+ ~co_init(){::CoUninitialize();}
+ } init;
+
+ CComPtr<IDeckLinkIterator> pDecklinkIterator;
+ if(FAILED(pDecklinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator)))
+ return;
+
+ core::register_consumer_factory([](const std::vector<std::wstring>& 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