-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
46 lines (37 loc) · 1.55 KB
/
main.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
#include <QApplication>
#include <QThread>
#include <QDeclarativeContext>
#include "qmlapplicationviewer.h"
#include "server.h"
#include "client.h"
#include "audiostream.h"
#include "uvoipdata.h"
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QScopedPointer<QApplication> app(createApplication(argc, argv));
QThread tcpServerThread;
QThread tcpClientThread;
QThread audioThread;
AudioStream stream;
UVoipData uvoipData;
Server tcpServer(&uvoipData);
Client tcpClient(&uvoipData, &stream);
tcpServer.moveToThread(&tcpServerThread);
tcpServerThread.start();
tcpClient.moveToThread(&tcpClientThread);
tcpClientThread.start();
stream.moveToThread(&audioThread);
audioThread.start();
stream.start();
QObject::connect(&stream, SIGNAL(updateLevel(qreal)), &uvoipData, SLOT(setHostMicrophoneLevel(qreal)), Qt::DirectConnection);
QObject::connect(&tcpClient, SIGNAL(connectedSocket(QIODevice*)), &stream, SLOT(slotClientSocket(QIODevice*)), Qt::DirectConnection);
QObject::connect(app.data(), SIGNAL(aboutToQuit()), &tcpServerThread, SLOT(quit()));
QObject::connect(app.data(), SIGNAL(aboutToQuit()), &tcpClientThread, SLOT(quit()));
QObject::connect(app.data(), SIGNAL(aboutToQuit()), &audioThread, SLOT(quit()));
QmlApplicationViewer viewer;
viewer.rootContext()->setContextProperty("uvoipData", &uvoipData);
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
viewer.setMainQmlFile(QLatin1String("qml/uVoip/main.qml"));
viewer.showExpanded();
return app->exec();
}