File: decklink-device-mode.cpp

package info (click to toggle)
obs-studio 30.2.3%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 47,852 kB
  • sloc: ansic: 202,137; cpp: 112,402; makefile: 868; python: 599; sh: 275; javascript: 19
file content (92 lines) | stat: -rw-r--r-- 1,744 bytes parent folder | download | duplicates (2)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "decklink-device-mode.hpp"

DeckLinkDeviceMode::DeckLinkDeviceMode(IDeckLinkDisplayMode *mode, long long id)
	: id(id),
	  mode(mode)
{
	if (mode == nullptr)
		return;

	decklink_string_t decklinkStringName;
	if (mode->GetName(&decklinkStringName) == S_OK)
		DeckLinkStringToStdString(decklinkStringName, name);
}

DeckLinkDeviceMode::DeckLinkDeviceMode(const std::string &name, long long id)
	: id(id),
	  mode(nullptr),
	  name(name)
{
}

DeckLinkDeviceMode::~DeckLinkDeviceMode(void) {}

BMDDisplayMode DeckLinkDeviceMode::GetDisplayMode(void) const
{
	if (mode != nullptr)
		return mode->GetDisplayMode();

	return bmdModeUnknown;
}

int DeckLinkDeviceMode::GetWidth()
{
	if (mode != nullptr)
		return mode->GetWidth();

	return 0;
}

int DeckLinkDeviceMode::GetHeight()
{
	if (mode != nullptr)
		return mode->GetHeight();

	return 0;
}

bool DeckLinkDeviceMode::GetFrameRate(BMDTimeValue *frameDuration,
				      BMDTimeScale *timeScale)
{
	if (mode != nullptr)
		return SUCCEEDED(mode->GetFrameRate(frameDuration, timeScale));

	return false;
}

BMDDisplayModeFlags DeckLinkDeviceMode::GetDisplayModeFlags(void) const
{
	if (mode != nullptr)
		return mode->GetFlags();

	return (BMDDisplayModeFlags)0;
}

long long DeckLinkDeviceMode::GetId(void) const
{
	return id;
}

const std::string &DeckLinkDeviceMode::GetName(void) const
{
	return name;
}

bool DeckLinkDeviceMode::IsEqualFrameRate(int64_t num, int64_t den)
{
	bool equal = false;

	if (mode) {
		BMDTimeValue frameDuration;
		BMDTimeScale timeScale;
		if (SUCCEEDED(mode->GetFrameRate(&frameDuration, &timeScale)))
			equal = timeScale * den == frameDuration * num;
	}

	return equal;
}

void DeckLinkDeviceMode::SetMode(IDeckLinkDisplayMode *mode_)
{
	mode = mode_;
}