-
Notifications
You must be signed in to change notification settings - Fork 1
/
ATEMclient.cpp
135 lines (102 loc) · 3.42 KB
/
ATEMclient.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
129
130
131
132
133
134
#include "ATEMclient.h"
ATEMclient::ATEMclient(){}
void ATEMclient::_parseGetCommands(const char *cmdStr) {
uint8_t mE;
uint16_t videoSource;
long temp;
uint8_t readBytesForTlSr;
if (!strcmp_P(cmdStr, PSTR("AMLv"))) {
_readToPacketBuffer(36);
} else if (!strcmp_P(cmdStr, PSTR("TlSr"))) {
readBytesForTlSr = ((ATEM_packetBufferLength-2)/3)*3+2;
_readToPacketBuffer(readBytesForTlSr);
} else {
_readToPacketBuffer(); // Default
}
if(!strcmp_P(cmdStr, PSTR("PrgI"))) {
mE = _packetBuffer[0];
if (mE<=1) {
#if ATEM_debug
temp = atemProgramInputVideoSource[mE];
#endif
atemProgramInputVideoSource[mE] = word(_packetBuffer[2], _packetBuffer[3]);
#if ATEM_debug
if ((_serialOutput==0x80 && atemProgramInputVideoSource[mE]!=temp) || (_serialOutput==0x81 && !hasInitialized())) {
Serial.print(F("atemProgramInputVideoSource[mE=")); Serial.print(mE); Serial.print(F("] = "));
Serial.println(atemProgramInputVideoSource[mE]);
}
#endif
}
} else
if(!strcmp_P(cmdStr, PSTR("PrvI"))) {
mE = _packetBuffer[0];
if (mE<=1) {
#if ATEM_debug
temp = atemPreviewInputVideoSource[mE];
#endif
atemPreviewInputVideoSource[mE] = word(_packetBuffer[2], _packetBuffer[3]);
#if ATEM_debug
if ((_serialOutput==0x80 && atemPreviewInputVideoSource[mE]!=temp) || (_serialOutput==0x81 && !hasInitialized())) {
Serial.print(F("atemPreviewInputVideoSource[mE=")); Serial.print(mE); Serial.print(F("] = "));
Serial.println(atemPreviewInputVideoSource[mE]);
}
#endif
}
}
}
/**
* Get Program Input; Video Source
* mE 0: ME1, 1: ME2
*/
uint16_t ATEMclient::getProgramInputVideoSource(uint8_t mE) {
return atemProgramInputVideoSource[mE];
}
/**
* Set Program Input; Video Source
* mE 0: ME1, 1: ME2
* videoSource (See video source list)
*/
void ATEMclient::setProgramInputVideoSource(uint8_t mE, uint16_t videoSource) {
_prepareCommandPacket(PSTR("CPgI"),4,(_packetBuffer[12+_cBBO+4+4+0]==mE));
_packetBuffer[12+_cBBO+4+4+0] = mE;
_packetBuffer[12+_cBBO+4+4+2] = highByte(videoSource);
_packetBuffer[12+_cBBO+4+4+3] = lowByte(videoSource);
_finishCommandPacket();
}
/**
* Get Preview Input; Video Source
* mE 0: ME1, 1: ME2
*/
uint16_t ATEMclient::getPreviewInputVideoSource(uint8_t mE) {
return atemPreviewInputVideoSource[mE];
}
/**
* Set Preview Input; Video Source
* mE 0: ME1, 1: ME2
* videoSource (See video source list)
*/
void ATEMclient::setPreviewInputVideoSource(uint8_t mE, uint16_t videoSource) {
_prepareCommandPacket(PSTR("CPvI"),4,(_packetBuffer[12+_cBBO+4+4+0]==mE));
_packetBuffer[12+_cBBO+4+4+0] = mE;
_packetBuffer[12+_cBBO+4+4+2] = highByte(videoSource);
_packetBuffer[12+_cBBO+4+4+3] = lowByte(videoSource);
_finishCommandPacket();
}
/**
* Set Cut; M/E
* mE 0: ME1, 1: ME2
*/
void ATEMclient::performCutME(uint8_t mE) {
_prepareCommandPacket(PSTR("DCut"),4);
_packetBuffer[12+_cBBO+4+4+0] = mE;
_finishCommandPacket();
}
/**
* Set Auto; M/E
* mE 0: ME1, 1: ME2
*/
void ATEMclient::performAutoME(uint8_t mE) {
_prepareCommandPacket(PSTR("DAut"),4);
_packetBuffer[12+_cBBO+4+4+0] = mE;
_finishCommandPacket();
}