decklink: Add Windows DeckLink project
The code specific to Windows: helps convert `BSTR` instances to `std::string`s; provides a Windows COM-specific implementation of `CreateDeckLinkDiscoveryInstance`; aliases CFUUIDGetUUIDBytes, CFUUIDBytes, and IUnknownUUID (the Linux SDK does this, but for some reason the Windows SDK does not).
This commit is contained in:
parent
b959f56291
commit
dd739d1e49
@ -3,6 +3,7 @@ if(WIN32)
|
||||
add_subdirectory(win-wasapi)
|
||||
add_subdirectory(win-dshow)
|
||||
add_subdirectory(win-capture)
|
||||
add_subdirectory(decklink/win)
|
||||
elseif(APPLE)
|
||||
add_subdirectory(mac-avcapture)
|
||||
add_subdirectory(mac-capture)
|
||||
|
@ -1,7 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(_WIN32)
|
||||
// TODO: Windows support
|
||||
#include <DeckLinkAPI.h>
|
||||
typedef BSTR decklink_string_t;
|
||||
IDeckLinkDiscovery *CreateDeckLinkDiscoveryInstance(void);
|
||||
#define IUnknownUUID IID_IUnknown
|
||||
typedef REFIID CFUUIDBytes;
|
||||
#define CFUUIDGetUUIDBytes(x) x
|
||||
#elif defined(__APPLE__)
|
||||
#include "mac/decklink-sdk/DeckLinkAPI.h"
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
46
plugins/decklink/win/CMakeLists.txt
Normal file
46
plugins/decklink/win/CMakeLists.txt
Normal file
@ -0,0 +1,46 @@
|
||||
project(win-decklink)
|
||||
|
||||
include(IDLFileHelper)
|
||||
|
||||
set(win-decklink-sdk_IDLS
|
||||
decklink-sdk/DeckLinkAPI.idl
|
||||
)
|
||||
|
||||
set(win-decklink-sdk_HEADERS
|
||||
decklink-sdk/DeckLinkAPIVersion.h
|
||||
)
|
||||
|
||||
set(win-decklink_HEADERS
|
||||
../platform.hpp
|
||||
../decklink.hpp
|
||||
../decklink-device-instance.hpp
|
||||
../decklink-device-discovery.hpp
|
||||
../decklink-device.hpp
|
||||
../decklink-device-mode.hpp
|
||||
)
|
||||
|
||||
set(win-decklink_SOURCES
|
||||
../plugin-main.cpp
|
||||
../decklink.cpp
|
||||
../decklink-device-instance.cpp
|
||||
../decklink-device-discovery.cpp
|
||||
../decklink-device.cpp
|
||||
../decklink-device-mode.cpp
|
||||
platform.cpp)
|
||||
|
||||
add_idl_files(win-decklink-sdk_GENERATED_FILES
|
||||
${win-decklink-sdk_IDLS})
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
add_library(win-decklink MODULE
|
||||
${win-decklink_SOURCES}
|
||||
${win-decklink_HEADERS}
|
||||
${win-decklink-sdk_HEADERS}
|
||||
${win-decklink-sdk_GENERATED_FILES})
|
||||
|
||||
target_link_libraries(win-decklink
|
||||
libobs)
|
||||
|
||||
install_obs_plugin_with_data(win-decklink ../data)
|
26
plugins/decklink/win/platform.cpp
Normal file
26
plugins/decklink/win/platform.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include "../platform.hpp"
|
||||
|
||||
#include <util/platform.h>
|
||||
|
||||
IDeckLinkDiscovery *CreateDeckLinkDiscoveryInstance(void)
|
||||
{
|
||||
IDeckLinkDiscovery *instance;
|
||||
const HRESULT result = CoCreateInstance(CLSID_CDeckLinkDiscovery,
|
||||
nullptr, CLSCTX_ALL, IID_IDeckLinkDiscovery,
|
||||
(void **)&instance);
|
||||
return result == S_OK ? instance : nullptr;
|
||||
}
|
||||
|
||||
bool DeckLinkStringToStdString(decklink_string_t input, std::string& output)
|
||||
{
|
||||
if (input == nullptr)
|
||||
return false;
|
||||
|
||||
size_t len = wcslen(input);
|
||||
size_t utf8_len = os_wcs_to_utf8(input, len, nullptr, 0);
|
||||
|
||||
output.resize(utf8_len);
|
||||
os_wcs_to_utf8(input, len, &output[0], utf8_len);
|
||||
|
||||
return true;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user