plugin-main.cpp 1.7 KB
Newer Older
1
#include <obs-module.h>
C
Colin Edwards 已提交
2
#include "decklink-devices.hpp"
3 4 5

OBS_DECLARE_MODULE()
OBS_MODULE_USE_DEFAULT_LOCALE("decklink", "en-US")
6 7 8 9
MODULE_EXPORT const char *obs_module_description(void)
{
	return "Blackmagic DeckLink source";
}
10

C
Colin Edwards 已提交
11 12
extern struct obs_source_info create_decklink_source_info();
struct obs_source_info decklink_source_info;
13

C
Colin Edwards 已提交
14 15
extern struct obs_output_info create_decklink_output_info();
struct obs_output_info decklink_output_info;
16

17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
void log_sdk_version()
{
	IDeckLinkIterator *deckLinkIterator;
	IDeckLinkAPIInformation *deckLinkAPIInformation;
	HRESULT result;

	deckLinkIterator = CreateDeckLinkIteratorInstance();
	if (deckLinkIterator == NULL) {
		blog(LOG_WARNING,
		     "A DeckLink iterator could not be created.  The DeckLink drivers may not be installed");
		return;
	}

	result = deckLinkIterator->QueryInterface(
		IID_IDeckLinkAPIInformation, (void **)&deckLinkAPIInformation);
	if (result == S_OK) {
		decklink_string_t deckLinkVersion;
		deckLinkAPIInformation->GetString(BMDDeckLinkAPIVersion,
						  &deckLinkVersion);

		blog(LOG_INFO, "Decklink API Compiled version %s",
		     BLACKMAGIC_DECKLINK_API_VERSION_STRING);

		std::string versionString;
		DeckLinkStringToStdString(deckLinkVersion, versionString);

		blog(LOG_INFO, "Decklink API Installed version %s",
		     versionString.c_str());

		deckLinkAPIInformation->Release();
	}
}

50 51
bool obs_module_load(void)
{
52 53
	log_sdk_version();

54 55 56 57
	deviceEnum = new DeckLinkDeviceDiscovery();
	if (!deviceEnum->Init())
		return true;

C
Colin Edwards 已提交
58 59
	decklink_source_info = create_decklink_source_info();
	obs_register_source(&decklink_source_info);
60

C
Colin Edwards 已提交
61 62
	decklink_output_info = create_decklink_output_info();
	obs_register_output(&decklink_output_info);
63 64 65 66 67 68 69 70

	return true;
}

void obs_module_unload(void)
{
	delete deviceEnum;
}