File: platform.cpp

package info (click to toggle)
obs-studio 29.0.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 35,920 kB
  • sloc: ansic: 182,921; cpp: 98,959; sh: 1,591; python: 945; makefile: 858; javascript: 19
file content (45 lines) | stat: -rw-r--r-- 1,229 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
#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;
}

IDeckLinkIterator *CreateDeckLinkIteratorInstance(void)
{
	IDeckLinkIterator *iterator;
	const HRESULT result =
		CoCreateInstance(CLSID_CDeckLinkIterator, nullptr, CLSCTX_ALL,
				 IID_IDeckLinkIterator, (void **)&iterator);
	return result == S_OK ? iterator : nullptr;
}

IDeckLinkVideoConversion *CreateVideoConversionInstance(void)
{
	IDeckLinkVideoConversion *conversion;
	const HRESULT result = CoCreateInstance(CLSID_CDeckLinkVideoConversion,
						nullptr, CLSCTX_ALL,
						IID_IDeckLinkVideoConversion,
						(void **)&conversion);
	return result == S_OK ? conversion : 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;
}