-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
58 lines (45 loc) · 2.05 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
47
48
49
50
51
52
53
54
55
56
57
58
#include <QtGui/QGuiApplication>
#include <QtQuick/QQuickView>
#include <QtQml/QQmlContext>
#include <QtQml/QQmlEngine>
#include <QGst/Init>
#include <QGst/Quick/VideoSurface>
#include "GStreamerPlayer.h"
#include "pidiscoverer.h"
#include "nodeselector.h"
#include "thermalimageprovider.h"
int main(int argc, char *argv[])
{
#if defined(QTVIDEOSINK_PATH)
//this allows the example to run from the QtGStreamer build tree without installing QtGStreamer
qputenv("GST_PLUGIN_PATH", QTVIDEOSINK_PATH);
#endif
QGuiApplication app(argc, argv);
QGst::init(&argc, &argv);
PiDiscoverer discoverer;
QQuickView view;
QGst::Quick::VideoSurface *surface1 = new QGst::Quick::VideoSurface;
view.rootContext()->setContextProperty(QLatin1String("videoSurface1"), surface1);
GStreamerPlayer *player1 = new GStreamerPlayer(&view);
player1->setVideoSink(surface1->videoSink());
view.rootContext()->setContextProperty(QLatin1String("player1"), player1);
QNetworkAccessManager *nam = new QNetworkAccessManager;
NodeSelector nodeSelector(&discoverer, nam, player1);
QObject::connect(&discoverer, SIGNAL(nodeDiscovered(PiNode)),
&nodeSelector, SLOT(checkPlayback()));
view.rootContext()->setContextProperty(QLatin1String("nodeSelector"), &nodeSelector);
ThermalImageProvider *thermalImageProvider = new ThermalImageProvider(nam);
QObject::connect(&nodeSelector, SIGNAL(thermalUrl(QUrl)),
thermalImageProvider, SLOT(onNewThermalUrl(QUrl)));
view.rootContext()->setContextProperty(QLatin1String("thermal"), thermalImageProvider);
view.engine()->addImageProvider(QLatin1String("theramlprovider"), thermalImageProvider);
#if defined(UNINSTALLED_IMPORTS_DIR)
//this allows the example to run from the QtGStreamer build tree without installing QtGStreamer
view.engine()->addImportPath(QLatin1String(UNINSTALLED_IMPORTS_DIR));
#endif
view.setSource(QUrl(QLatin1String("qrc:///main.qml")));
view.setColor(Qt::black);
// view.show();
view.showFullScreen();
return app.exec();
}