-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathATEM.h
executable file
·133 lines (106 loc) · 5 KB
/
ATEM.h
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
/*
Copyright 2012 Kasper Skårhøj, SKAARHOJ, [email protected]
This file is part of the ATEM library for Arduino
The ATEM library is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
The ATEM library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with the ATEM library. If not, see http://www.gnu.org/licenses/.
*/
/**
Version 1 beta
**/
#ifndef ATEM_h
#define ATEM_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include <EthernetUdp.h>
class ATEM
{
private:
EthernetUDP _Udp; // Udp Object for communication, see constructor.
uint16_t _localPort; // local port to send from
IPAddress _switcherIP; // IP address of the switcher
boolean _serialOutput; // If set, the library will print status/debug information to the Serial object
uint8_t _sessionID; // Used internally for storing packet size during communication
uint16_t _lastRemotePacketID; // The most recent Remote Packet Id from switcher
char _packetBuffer[96]; // Buffer for storing segments of the packets from ATEM. Has the size of the largest known "segment" of a packet the ATEM sends.
uint16_t _localPacketIdCounter; // This is our counter for the command packages we might like to send to ATEM
boolean _hasInitialized; // If true, the initial reception of the ATEM memory has passed and we can begin to respond during the runLoop()
uint8_t _answer[36]; // Little buffer for creating answers back to the ATEM
// Selected ATEM State values. Naming attempts to match the switchers own protocol names
// Set through _parsePacket() when the switcher sends state information
// Accessed through getter methods
uint8_t _ATEM_PrgI; // Program input
uint8_t _ATEM_PrvI; // Preview input
uint8_t _ATEM_TlIn[8]; // Inputs 1-8, bit 0 = Prg tally, bit 1 = Prv tally. Both can be set simultaneously.
boolean _ATEM_TrPr; // Transition Preview: Is it on or not?
uint8_t _ATEM_TrSS_KeyersOnNextTransition; // Bit 0: Background; Bit 1-4: Key 1-4
uint8_t _ATEM_TrSS_TransitionStyle; // 0=MIX, 1=DIP, 2=WIPE, 3=DVE, 4=STING
boolean _ATEM_KeOn[4]; // Upstream Keyer 1-4 On state
boolean _ATEM_DskOn[2]; // Downstream Keyer 1-2 On state
boolean _ATEM_DskTie[2]; // Downstream Keyer Tie 1-2 On state
uint8_t _ATEM_TrPs_frameCount; // Count down of frames in case of a transition (manual or auto)
uint16_t _ATEM_TrPs_position; // Position from 0-1000 of the current transition in progress
uint8_t _ATEM_FtbS_frameCount; // Count down of frames in case of fade-to-black
uint8_t _ATEM_AuxS[3]; // Aux Outputs 1-3 source
uint8_t _ATEM_MPType[2]; // Media Player 1/2: Type (1=Clip, 2=Still)
uint8_t _ATEM_MPStill[2]; // Still number (if MPType==2)
uint8_t _ATEM_MPClip[2]; // Clip number (if MPType==1)
public:
ATEM(IPAddress ip, uint16_t localPort);
void connect();
void runLoop();
private:
void _parsePacket(uint16_t packetLength);
void _sendAnswerPacket(uint16_t remotePacketID);
void _sendCommandPacket(char cmd[4], uint8_t commandBytes[16], uint8_t cmdBytes);
public:
/********************************
* General Getter/Setter methods
********************************/
void serialOutput(boolean serialOutput);
bool hasInitialized();
uint16_t getATEM_lastRemotePacketId();
/********************************
* ATEM Switcher state methods
* Returns the most recent information we've
* got about the switchers state
********************************/
uint8_t getProgramInput();
uint8_t getPreviewInput();
boolean getProgramTally(uint8_t inputNumber);
boolean getPreviewTally(uint8_t inputNumber);
/********************************
* ATEM Switcher Change methods
* Asks the switcher to changes something
********************************/
void changeProgramInput(uint8_t inputNumber);
void changePreviewInput(uint8_t inputNumber);
void doCut();
void doAuto();
void fadeToBlackActivate();
void changeTransitionPosition(word value);
void changeTransitionPositionDone();
void changeTransitionPreview(bool state);
void changeTransitionType(uint8_t type);
void changeUpstreamKeyOn(uint8_t keyer, bool state);
void changeUpstreamKeyNextTransition(uint8_t keyer, bool state);
void changeDownstreamKeyOn(uint8_t keyer, bool state);
void changeDownstreamKeyTie(uint8_t keyer, bool state);
void doAutoDownstreamKeyer(uint8_t keyer);
void changeAuxState(uint8_t auxOutput, uint8_t inputNumber);
void settingsMemorySave();
void settingsMemoryClear();
void changeColorValue(uint8_t colorGenerator, uint16_t hue, uint16_t saturation, uint16_t lightness);
void mediaPlayerSelectSource(uint8_t mediaPlayer, boolean movieclip, uint8_t sourceIndex);
};
#endif