]> git.sesse.net Git - casparcg/blobdiff - modules/decklink/decklink.cpp
[ffmpeg] use implicit constructor of video_format_desc for clarity
[casparcg] / modules / decklink / decklink.cpp
index 4a8ec9ead05966282ab0d4da92a3461da831b399..bf6de45bea995c7ab9a0184972e83a4ea4edb369 100644 (file)
-/*\r
-* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG (www.casparcg.com).\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
-* Author: Robert Nagy, ronag89@gmail.com\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 { namespace decklink {\r
-\r
-void init()\r
-{\r
-       struct co_init\r
-       {\r
-               co_init(){::CoInitialize(nullptr);}\r
-               ~co_init(){::CoUninitialize();}\r
-       } init;\r
-       \r
-       CComPtr<IDeckLinkIterator> pDecklinkIterator;\r
-       if(FAILED(pDecklinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator)))         \r
-               return;\r
-               \r
-       core::register_consumer_factory([](const std::vector<std::string>& params){return create_consumer(params);});\r
-       core::register_producer_factory(create_producer);\r
-}\r
-\r
-std::string get_version() \r
-{\r
-       std::string version = "Not found";\r
-       \r
-       struct co_init\r
-       {\r
-               co_init(){::CoInitialize(nullptr);}\r
-               ~co_init(){::CoUninitialize();}\r
-       } init;\r
-\r
-       try\r
-       {\r
-               CComPtr<IDeckLinkIterator> pDecklinkIterator;\r
-               if(SUCCEEDED(pDecklinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator)))              \r
-                       version = get_version(pDecklinkIterator);\r
-       }\r
-       catch(...){}\r
-\r
-       return version;\r
-}\r
-\r
-std::vector<std::string> get_device_list()\r
-{\r
-       std::vector<std::string> devices;\r
-       \r
-       struct co_init\r
-       {\r
-               co_init(){::CoInitialize(nullptr);}\r
-               ~co_init(){::CoUninitialize();}\r
-       } init;\r
-\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(u8(model_name) + " [" + boost::lexical_cast<std::string>(n) + "]");   \r
-                       }\r
-               }\r
-       }\r
-       catch(...){}\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 "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<std::wstring> device_list()
+{
+       std::vector<std::wstring> 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<std::wstring>(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);
+       });
+}
+
+}}