-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
128 lines (105 loc) · 4.28 KB
/
main.cpp
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include "DeckLinkAPI.h"
#include "DeckLinkAPIDispatch_v10_8.cpp"
#include <iostream>
#include <memory>
int main(int argc, char *argv[])
{
std::unique_ptr<IDeckLinkIterator> pDeckLinkIterator(CreateDeckLinkIteratorInstance());
if (pDeckLinkIterator == nullptr)
{
std::cerr << "Could not create DeckLink iterator. Are you sure a Decklink device is connected?" << std::endl;
return 1;
}
std::shared_ptr<IDeckLink> pDeckLink;
IDeckLink* pRawDecklinkPtr = pDeckLink.get();
while (pDeckLinkIterator->Next(&pRawDecklinkPtr) == S_OK)
{
std::string deviceName;
const char* cstrDeviceName = deviceName.c_str();
if (pDeckLink->GetDisplayName(&cstrDeviceName) == S_OK)
{
// Device is found
std::cout << deviceName << std::endl;
}
IDeckLinkAPIInformation* pApiInfo = CreateDeckLinkAPIInformationInstance();
if (pApiInfo == nullptr)
{
std::cerr << "Could not create DeckLink API information instance." << std::endl;
return 1;
}
else
{
std::string apiVersion;
const char* cstrApiVersion = apiVersion.c_str();
if (pApiInfo->GetString(BMDDeckLinkAPIVersion, &cstrApiVersion) == S_OK)
{
std::cout << "API version: " << apiVersion << std::endl;
}
else
{
std::cerr << "Could not get API version." << std::endl;
}
pApiInfo->Release();
}
IDeckLinkStatus* pDeckLinkStatus;
pDeckLink->QueryInterface(IID_IDeckLinkStatus, reinterpret_cast<void **>(&pDeckLinkStatus));
if (pDeckLinkStatus == nullptr)
{
std::cerr << "Could not create DeckLink status instance." << std::endl;
return 1;
}
else
{
int64_t deviceTemp = -1;
if (pDeckLinkStatus->GetInt(bmdDeckLinkStatusDeviceTemperature, &deviceTemp) == S_OK)
{
std::cout << "Device Temperature: " << deviceTemp << " °C" << std::endl;
}
else
{
std::cerr << "Could not get device temperature." << std::endl;
}
int64_t pcieLinkWidth = -1;
int64_t pcieLinkSpeed = -1;
if ((pDeckLinkStatus->GetInt(bmdDeckLinkStatusPCIExpressLinkWidth, &pcieLinkWidth) == S_OK) && (pDeckLinkStatus->GetInt(bmdDeckLinkStatusPCIExpressLinkSpeed, &pcieLinkSpeed) == S_OK))
{
std::cout << "PCIe info: " << pcieLinkSpeed << " Gb/s" << " (" << pcieLinkWidth << " lanes)" << std::endl;
}
int64_t videoDisplayMode = -1;
int64_t videoPixelFormat = -1;
int64_t videoColorSpace = -1;
if ((pDeckLinkStatus->GetInt(bmdDeckLinkStatusCurrentVideoInputMode, &videoDisplayMode) == S_OK) && (pDeckLinkStatus->GetInt(bmdDeckLinkStatusCurrentVideoOutputMode, &videoPixelFormat) == S_OK) && (pDeckLinkStatus->GetInt(bmdDeckLinkStatusDetectedVideoInputColorspace, &videoColorSpace) == S_OK))
{
std::cout << "Video display mode:" << videoDisplayMode << " (" << videoPixelFormat << ")" << std::endl;
}
else
{
std::cerr << "Could not get video display mode. Are you sure a video input is connected?" << std::endl;
}
pDeckLinkStatus->Release();
}
IDeckLinkProfileAttributes* pProfileAttributes;
pDeckLink->QueryInterface(IID_IDeckLinkProfileAttributes, reinterpret_cast<void **>(&pProfileAttributes));
if (pProfileAttributes == nullptr)
{
std::cerr << "Could not create DeckLink profile attributes instance." << std::endl;
return 1;
}
else
{
int64_t persistentID = -1;
if (pProfileAttributes->GetInt(BMDDeckLinkPersistentID, &persistentID) == S_OK)
{
std::cout << "Device ID: " << persistentID << std::endl;
}
else
{
std::cerr << "Could not get device ID." << std::endl;
}
pProfileAttributes->Release();
}
pDeckLink->Release();
}
pDeckLinkIterator->Release();
return 0;
}