UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
decklink_temperature.cpp
Go to the documentation of this file.
1
16#include <cstdint>
17#include <iostream>
18
19#ifdef WIN32
20#include "../ext-deps/DeckLink/Windows/DeckLinkAPI_h.h" /* From DeckLink SDK */
21#else
22#include "../ext-deps/DeckLink/Linux/DeckLinkAPI.h" /* From DeckLink SDK */
23#endif
24
25using namespace std;
26
27int main() {
28 cout << "Prints temperatures for all BMD devices. Takes no argument.\n\n";
29 IDeckLinkIterator *deckLinkIterator = nullptr;
30#ifdef WIN32
31 // Initialize COM on this thread
32 HRESULT result = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
33 if (FAILED(result)) {
34 return 2;
35 }
36 result = CoCreateInstance(CLSID_CDeckLinkIterator, nullptr, CLSCTX_ALL,
37 IID_IDeckLinkIterator, (void **) &deckLinkIterator);
38 if (FAILED(result)) {
39 return 2;
40 }
41#else
42 deckLinkIterator = CreateDeckLinkIteratorInstance();
43#endif
44 if (deckLinkIterator == nullptr) {
45 return 1;
46 }
47
48 int numDevices = 0;
49 // Enumerate all cards in this system
50 IDeckLink *deckLink = nullptr;
51 while (deckLinkIterator->Next(&deckLink) == S_OK)
52 {
53 IDeckLinkStatus *stat = nullptr;
54 deckLink->QueryInterface(IID_IDeckLinkStatus, reinterpret_cast<void**>(&stat));
55 int64_t temp;
56 cout << "Device " << numDevices++ << " temperature: ";
57 if (HRESULT res = stat->GetInt(bmdDeckLinkStatusDeviceTemperature, &temp); res != S_OK) {
58 if (res == E_NOTIMPL) {
59 cout << "NOT IMPLEMENTED\n";
60 } else {
61 cout << "error: 0x" << hex << "\n";
62 }
63 } else {
64 cout << temp << "\n";
65 }
66
67 deckLink->Release();
68 }
69 if (numDevices == 0) {
70 cout << "\tno devices found!\n";
71 }
72
73 deckLinkIterator->Release();
74
75#ifdef WIN32
76 CoUninitialize();
77#endif
78}
79
@ FAILED