-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathPtBi.cpp
More file actions
123 lines (109 loc) · 3.26 KB
/
PtBi.cpp
File metadata and controls
123 lines (109 loc) · 3.26 KB
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
// PtBi.cpp : Defines the entry point for the console application.
//
#include <cstring>
#include "stdafx.h"
#include "PTOpenGL.h"
#include "Audio.h"
#include "Capture.h"
class KeepDisplayOn {
UINT prevScreenSaver;
EXECUTION_STATE prevExecState;
public:
KeepDisplayOn() {
prevExecState = SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED | ES_CONTINUOUS);
SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, &prevScreenSaver, 0);
SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, FALSE, NULL, 0);
}
~KeepDisplayOn() {
SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, prevScreenSaver, NULL, 0);
SetThreadExecutionState(prevExecState);
}
};
#ifdef WIN32
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
#endif
int main(int argc, char* argv[])
{
// redirect stdout
freopen("ptbi.log", "w+", stdout);
RT_ASSERT(SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS) == TRUE, "Could not set high process priority.");
RT_ASSERT(CoInitializeEx(NULL, COINIT_MULTITHREADED) == S_OK, "Failed to initialize COM in MT mode.");
// Disable screensaver & sleep (uses RAII)
KeepDisplayOn on;
// parse arguments
BMDDisplayMode mode = bmdModeHD720p5994;
BMDPixelFormat format = bmdFormat8BitYUV;
bool disableAudio = false;
int w = 1280, h = 720, hz = 59;
for(int i=1; i<argc; ++i) {
if(strstr(argv[i], "-mode=") == argv[i]) {
if(strstr(argv[i], "720p60")) {
mode = bmdModeHD720p60;
w = 1280; h = 720; hz = 60;
}
else if(strstr(argv[i], "720p5994")) {
mode = bmdModeHD720p5994;
w = 1280; h = 720; hz = 59;
}
else if(strstr(argv[i], "720p50")) {
mode = bmdModeHD720p50;
w = 1280; h = 720; hz = 50;
}
else if(strstr(argv[i], "1080p60")) {
mode = bmdModeHD1080p6000;
w = 1920; h = 1080; hz = 60;
}
else if(strstr(argv[i], "1080p5994")) {
mode = bmdModeHD1080p5994;
w = 1920; h = 1080; hz = 59;
}
else if(strstr(argv[i], "1080p50")) {
mode = bmdModeHD1080p50;
w = 1920; h = 1080; hz = 50;
}
else if(strstr(argv[i], "1080p30")) {
mode = bmdModeHD1080p30;
w = 1920; h = 1080; hz = 30;
}
else if(strstr(argv[i], "1080p25")) {
mode = bmdModeHD1080p25;
w = 1920; h = 1080; hz = 25;
}
else if(strstr(argv[i], "PAL")) {
mode = bmdModePALp;
w = 720; h = 576; hz = 50;
}
else if(strstr(argv[i], "NTSC")) {
mode = bmdModeNTSCp;
w = 720; h = 480; hz = 59;
}
else RT_ASSERT(false, "Unknown capture mode.");
} else if(strstr(argv[i], "-pf=") == argv[i]) {
if(strstr(argv[i], "YUV")) {
format = bmdFormat8BitYUV;
}
else if(strstr(argv[i], "ARGB")) {
format = bmdFormat8BitARGB;
}
else if(strstr(argv[i], "BGRA")) {
format = bmdFormat8BitBGRA;
}
else RT_ASSERT(false, "Unknown pixel format.");
}
else if(strstr(argv[i], "-disable-audio") == argv[i]) {
disableAudio = true;
} else {
RT_ASSERT(false, "Unknown argument: " << argv[i]);
}
}
DeckLinkCapture capturer(mode, format, disableAudio);
{ // block to make sure presenter is destroyed before capturer
AudioRenderer renderer(capturer, 2);
GLPresenter presenter(capturer, w, h, hz);
capturer.start();
while(presenter.run());
}
wcout << "Final Shutdown.\n";
CoUninitialize();
return 0;
}