-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathqatemcontroller.cpp
More file actions
79 lines (67 loc) · 2.19 KB
/
qatemcontroller.cpp
File metadata and controls
79 lines (67 loc) · 2.19 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
#include "qatemcontroller.h"
#include "libqatemcontrol/qatemconnection.h"
#include <QTextStream>
#include <QCoreApplication>
#include <QHostAddress>
#include <QTimer>
QAtemController::QAtemController(QObject *parent) :
QObject(parent)
{
m_connection = new QAtemConnection(this);
connect(m_connection, SIGNAL(socketError(QString)),
this, SLOT(handleError(QString)));
connect(m_connection, SIGNAL(connected()),
this, SLOT(handleConnect()));
}
void QAtemController::connectAtem(const QString &address, const QString &command, quint8 input) {
QHostAddress host(address);
if(host.isNull())
{
handleError(tr("Invalid switcher address"));
return;
}
m_connection->connectToSwitcher(host);
m_command = command;
m_input = input;
}
void QAtemController::switchInput(quint8 input) {
m_connection->changePreviewInput(input);
m_connection->doAuto();
QCoreApplication::exit(-1);
}
void QAtemController::switchInputNoTrans(quint8 input) {
m_connection->changeProgramInput(input);
QCoreApplication::exit(-1);
}
void QAtemController::handleConnect() {
QTextStream out(stderr);
if (m_command == "switch") {
out << "Transitioning to input " << QString::number(m_input) << " with " << QString::number(m_delay) << "ms delay" << endl << endl;
if (m_delay > 0) {
QTimer::singleShot(m_delay, this, SLOT(switchInputSlot()));
} else {
switchInput(m_input);
}
} else if (m_command == "switchNoTrans") {
out << "Changing to input " << QString::number(m_input) << " with " << QString::number(m_delay) << "ms delay" << endl << endl;
if (m_delay > 0) {
QTimer::singleShot(m_delay, this, SLOT(switchInputSlot()));
} else {
switchInputNoTrans(m_input);
}
} else {
handleError("Not a valid command");
}
}
void QAtemController::switchInputSlot() {
switchInput(m_input);
}
void QAtemController::switchInputNoTransSlot() {
switchInputNoTrans(m_input);
}
void QAtemController::handleError(const QString &errorString)
{
QTextStream out(stderr);
out << errorString << endl << endl;
QCoreApplication::exit(-1);
}