-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.cpp
88 lines (70 loc) · 3.18 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
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
/*
Copyright (C) 2012-2013 Collabora Ltd. <[email protected]>
@author George Kiagiadakis <[email protected]>
Copyright (C) 2013 basysKom GmbH <[email protected]>
@author Benjamin Federau <[email protected]>
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtGui/QGuiApplication>
#include <QtQuick/QQuickView>
#include <QtQuick/QQuickItem>
#include <QtQml/QQmlContext>
#include <QtQml/QQmlEngine>
#include <QtOpenGL/QGLFormat>
#include <QGst/Init>
#include <QGst/Quick/VideoSurface>
#include <QGst/Quick/VideoItem>
#include <gst/gst.h>
#include <QThread>
#include <gstqtquick2videosink.h>
#include <PrimaryFlightDisplayQML.h>
#include <LinkManager1.h>
#include <UASManager1.h>
// Needed to manually register plugin
gboolean plugin_init(GstPlugin *plugin);
// Since Qt QML scene rendering is on a rendering thread and not the UI thread, use a 'direct' call instead of the glib 'signal/slot'
// The UI thread blocks during the 'update-node' call, so it's safe to make this direct call on the rendering thread
gpointer gst_qt_quick2_video_sink_update_node(GstQtQuick2VideoSink *self, gpointer node, qreal x, qreal y, qreal w, qreal h);
void* update_node(void* surface, void* node, qreal x, qreal y, qreal w, qreal h)
{
return gst_qt_quick2_video_sink_update_node((GstQtQuick2VideoSink*)surface, (gpointer)node, x, y, w, h);
}
int main(int argc, char **argv)
{
QGuiApplication app(argc, argv);
QGst::init(&argc, &argv);
qDebug() << "Start Link Manager";
LinkManager::instance();
qDebug() << "Start UAS Manager";
UASManager::instance();
gboolean success = gst_plugin_register_static (GST_VERSION_MAJOR,
GST_VERSION_MINOR ,
"qt5videosink",
"A video sink that can draw on any Qt surface",
&plugin_init,
"1.2.0",
"LGPL",
"libgstqt5videosink.so",
"QtGStreamer",
"http://gstreamer.freedesktop.org");
if (!success)
{
qCritical() << "Could not register qt5videosink plugin with GStreamer!";
}
PrimaryFlightDisplayQML theDisplay;
// Connect for android sleep signals
QObject::connect(&app, SIGNAL(applicationStateChanged(Qt::ApplicationState)), &theDisplay,
SLOT(applicationStateChanged(Qt::ApplicationState)), Qt::UniqueConnection);
int retVal = app.exec();
QGst::cleanup();
return retVal;
}