Skip to content

Commit

Permalink
Initial setup for Mac Installer (Video Steaming)
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmaphobic committed Jul 8, 2015
1 parent a5ab544 commit 5b0e135
Show file tree
Hide file tree
Showing 10 changed files with 344 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
libs/lib/Frameworks/GStreamer.framework
*.swp
*.nfs
CMakeFiles
Expand Down
25 changes: 13 additions & 12 deletions QGCApplication.pro
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,6 @@ include(libs/qextserialport/src/qextserialport.pri)

include(QGCExternalLibs.pri)

#
# Post link configuration
#

include(QGCSetup.pri)

#
# Installer targets
#

include(QGCInstaller.pri)

#
# Main QGroundControl portion of project file
#
Expand Down Expand Up @@ -702,3 +690,16 @@ AndroidBuild {
$$PWD/android/src/org/qgroundcontrol/qgchelper/UsbDeviceJNI.java \
$$PWD/android/src/org/qgroundcontrol/qgchelper/UsbIoManager.java
}

#-------------------------------------------------------------------------------------
#
# Post link configuration
#

include(QGCSetup.pri)

#
# Installer targets
#

include(QGCInstaller.pri)
14 changes: 13 additions & 1 deletion QGCInstaller.pri
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@

installer {
MacBuild {
VideoEnabled {
# Install the gstreamer framework
# This will:
# Copy from the original distibution into libs/lib/Framworks (if not already there)
# Prune the framework, removing stuff we don't need
# Relocate all dylibs so they can work under @executable_path/...
# Copy the result into the app bundle
# Make sure qgroundcontrol can find them
message("Preparing GStreamer Framework")
QMAKE_POST_LINK += && $$BASEDIR/tools/prepare_gstreamer_framework.sh $$BASEDIR/libs/lib/Frameworks/ $$DESTDIR/$${TARGET}.app $${TARGET}
} else {
message("Skipping GStreamer Framework")
}
# We cd to release directory so we can run macdeployqt without a path to the
# qgroundcontrol.app file. If you specify a path to the .app file the symbolic
# links to plugins will not be created correctly.
Expand All @@ -27,7 +40,6 @@ installer {
QMAKE_POST_LINK += && cd ..
QMAKE_POST_LINK += && hdiutil create -layout SPUD -srcfolder $${DESTDIR}/qgroundcontrol.app -volname QGroundControl $${DESTDIR}/qgroundcontrol.dmg
}

WindowsBuild {
# The pdb moving command are commented out for now since we are including the .pdb in the installer. This makes it much
# easier to debug user crashes.
Expand Down
3 changes: 2 additions & 1 deletion QGCSetup.pri
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ WindowsBuild {
#

MacBuild {

# Copy non-standard libraries and frameworks into app package
QMAKE_POST_LINK += && $$QMAKE_COPY_DIR $$BASEDIR/libs/lib/mac64/lib $$DESTDIR/$${TARGET}.app/Contents/libs
QMAKE_POST_LINK += && $$QMAKE_COPY_DIR -L $$BASEDIR/libs/lib/Frameworks $$DESTDIR/$${TARGET}.app/Contents
QMAKE_POST_LINK += && rsync -a --delete $$BASEDIR/libs/lib/Frameworks $$DESTDIR/$${TARGET}.app/Contents/

# Fix library paths inside executable

Expand Down
25 changes: 25 additions & 0 deletions src/QGCApplication.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ static QObject* mavManagerSingletonFactory(QQmlEngine*, QJSEngine*)
* @param argv The string array of parameters
**/

static void qgcputenv(const QString& key, const QString& root, const QString& path)
{
QString value = root + path;
qputenv(key.toStdString().c_str(), QByteArray(value.toStdString().c_str()));
}

QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
: QApplication(argc, argv)
Expand Down Expand Up @@ -266,8 +271,28 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)

//----------------------------------------------------------------
//-- Video Streaming
#if defined(QGC_GST_STREAMING)
#ifdef Q_OS_MAC
#ifndef __ios__
QString currentDir = QCoreApplication::applicationDirPath();
qgcputenv("GST_PLUGIN_SCANNER", currentDir, "/gst-plugin-scanner");
qgcputenv("GTK_PATH", currentDir, "/../Frameworks/GStreamer.framework/Versions/Current");
qgcputenv("GIO_EXTRA_MODULES", currentDir, "/../Frameworks/GStreamer.framework/Versions/Current/lib/gio/modules");
qgcputenv("GST_PLUGIN_SYSTEM_PATH_1_0", currentDir, "/../Frameworks/GStreamer.framework/Versions/Current/lib/gstreamer-1.0");
qgcputenv("GST_PLUGIN_SYSTEM_PATH", currentDir, "/../Frameworks/GStreamer.framework/Versions/Current/lib/gstreamer-1.0");
qgcputenv("GST_PLUGIN_PATH_1_0", currentDir, "/../Frameworks/GStreamer.framework/Versions/Current/lib/gstreamer-1.0");
qgcputenv("GST_PLUGIN_PATH", currentDir, "/../Frameworks/GStreamer.framework/Versions/Current/lib/gstreamer-1.0");
// QStringList env = QProcessEnvironment::systemEnvironment().keys();
// foreach(QString key, env) {
// qDebug() << key << QProcessEnvironment::systemEnvironment().value(key);
// }
#endif
#endif
#endif

qmlRegisterType<VideoItem>("QGroundControl.QgcQtGStreamer", 1, 0, "VideoItem");
qmlRegisterUncreatableType<VideoSurface>("QGroundControl.QgcQtGStreamer", 1, 0, "VideoSurface", QLatin1String("VideoSurface from QML is not supported"));

#if defined(QGC_GST_STREAMING)
GError* error = NULL;
if (!gst_init_check(&argc, &argv, &error)) {
Expand Down
7 changes: 7 additions & 0 deletions src/VideoStreaming/VideoReceiver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,34 +87,41 @@ void VideoReceiver::start()

do {
if ((_pipeline = gst_pipeline_new("receiver")) == NULL) {
qCritical() << "VideoReceiver::start() failed. Error with gst_pipeline_new()";
break;
}

if ((dataSource = gst_element_factory_make("udpsrc", "udp-source")) == NULL) {
qCritical() << "VideoReceiver::start() failed. Error with gst_element_factory_make('udpsrc')";
break;
}

if ((caps = gst_caps_from_string("application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264")) == NULL) {
qCritical() << "VideoReceiver::start() failed. Error with gst_caps_from_string()";
break;
}

g_object_set(G_OBJECT(dataSource), "uri", qPrintable(_uri), "caps", caps, NULL);

if ((demux = gst_element_factory_make("rtph264depay", "rtp-h264-depacketizer")) == NULL) {
qCritical() << "VideoReceiver::start() failed. Error with gst_element_factory_make('rtph264depay')";
break;
}

if ((parser = gst_element_factory_make("h264parse", "h264-parser")) == NULL) {
qCritical() << "VideoReceiver::start() failed. Error with gst_element_factory_make('h264parse')";
break;
}

if ((decoder = gst_element_factory_make("avdec_h264", "h264-decoder")) == NULL) {
qCritical() << "VideoReceiver::start() failed. Error with gst_element_factory_make('avdec_h264')";
break;
}

gst_bin_add_many(GST_BIN(_pipeline), dataSource, demux, parser, decoder, _videoSink, NULL);

if (gst_element_link_many(dataSource, demux, parser, decoder, _videoSink, NULL) != (gboolean)TRUE) {
qCritical() << "VideoReceiver::start() failed. Error with gst_element_link_many()";
break;
}

Expand Down
27 changes: 22 additions & 5 deletions src/VideoStreaming/VideoStreaming.pri
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@
LinuxBuild {
CONFIG += link_pkgconfig
packagesExist(gstreamer-1.0) {
message("Including support for video streaming")
PKGCONFIG += gstreamer-1.0 gstreamer-video-1.0
CONFIG += VideoEnabled
}
} else:MacBuild {
#- gstreamer framework installed by the gstreamer devel installer
GST_ROOT = /Library/Frameworks/GStreamer.framework
exists($$GST_ROOT) {
message("Including support for video streaming")
CONFIG += VideoEnabled
INCLUDEPATH += $$GST_ROOT/Headers
LIBS += -F/Library/Frameworks -framework GStreamer
Expand All @@ -44,7 +42,6 @@ LinuxBuild {
#- gstreamer framework installed by the gstreamer iOS SDK installer (default to home directory)
GST_ROOT = $$(HOME)/Library/Developer/GStreamer/iPhone.sdk/GStreamer.framework
exists($$GST_ROOT) {
message("Including support for video streaming")
CONFIG += VideoEnabled
INCLUDEPATH += $$GST_ROOT/Headers
LIBS += -F$$(HOME)/Library/Developer/GStreamer/iPhone.sdk -framework GStreamer
Expand All @@ -53,7 +50,6 @@ LinuxBuild {
#- gstreamer installed by default under c:/gstreamer
GST_ROOT = c:/gstreamer/1.0/x86
exists($$GST_ROOT) {
message("Including support for video streaming")
CONFIG += VideoEnabled
LIBS += -L$$GST_ROOT/lib/gstreamer-1.0/static -lgstreamer-1.0 -lgstvideo-1.0 -lgstbase-1.0
LIBS += -L$$GST_ROOT/lib -lglib-2.0 -lintl -lgobject-2.0
Expand All @@ -67,6 +63,8 @@ LinuxBuild {

VideoEnabled {

message("Including support for video streaming")

DEFINES += \
QGC_GST_STREAMING \
GST_PLUGIN_BUILD_STATIC \
Expand Down Expand Up @@ -123,6 +121,25 @@ VideoEnabled {
$$PWD/gstqtvideosink/utils/utils.cpp \

} else {
message("Skipping support for video streaming (Unsupported platform)")
LinuxBuild|MacBuild|iOSBuild|WindowsBuild {
message("Skipping support for video streaming (GStreamer libraries not installed)")
MacBuild {
message(" You can download it from http://gstreamer.freedesktop.org/data/pkg/osx/")
message(" Select the devel package and install it (gstreamer-1.0-devel-1.x.x-x86_64.pkg)")
message(" It will be installed in /Libraries/Frameworks")
}
LinuxBuild {
message(" You can install it using apt-get")
message(" sudo apt-get install gstreamer1.0*")
message(" sudo apt-get install libgstreamer1.0*")
}
WindowsBuild {
message(" You can download it from http://gstreamer.freedesktop.org/data/pkg/windows/")
message(" Select the devel AND runtime packages and install them (x86, not the 64-Bit)")
message(" It will be installed in C:/gstreamer. You need to update you PATH to point to the bin directory.")
}
} else {
message("Skipping support for video streaming (Unsupported platform)")
}
}

3 changes: 2 additions & 1 deletion src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ This file is part of the QGROUNDCONTROL project
*
*/

#include <QtGlobal>
#include <QApplication>
#include <QSslSocket>
#ifndef __mobile__
#include <QSerialPortInfo>
#endif

#include <QProcessEnvironment>
#include "QGCApplication.h"
#include "MainWindow.h"
#include "configuration.h"
Expand Down
Loading

0 comments on commit 5b0e135

Please sign in to comment.