Skip to content

Commit

Permalink
Merged in filnet/librepilot/LP-109_video_gadget (pull request #454)
Browse files Browse the repository at this point in the history
LP-109 video gadget

Approved-by: Philippe Renon <[email protected]>
Approved-by: Lalanne Laurent <[email protected]>
Approved-by: Jan NIJS <[email protected]>
Approved-by: Brian Webb <[email protected]>
  • Loading branch information
filnet authored and f5soh committed Sep 18, 2017
2 parents 9d05ed3 + bb05d8c commit dbe95ae
Show file tree
Hide file tree
Showing 108 changed files with 7,221 additions and 82 deletions.
4 changes: 3 additions & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ build:
- if [ $$arch = 32 ]; then target=i686; fi
- if [ $$arch = 64 ]; then target=x86_64; fi
- echo -e "[librepilot-mingw]\nSigLevel = Optional TrustAll\nServer = http://download.librepilot.org/repo/mingw" >> /etc/pacman.conf
- pacman -Syu --noconfirm --noprogressbar --needed git unzip tar mingw-w64-${target}-toolchain mingw-w64-${target}-ccache mingw-w64-${target}-ntldd mingw-w64-${target}-qt5 mingw-w64-${target}-SDL mingw-w64-${target}-mesa mingw-w64-${target}-openssl mingw-w64-${target}-gdal-minimal mingw-w64-${target}-OpenSceneGraph mingw-w64-${target}-osgearth
- pacman -Syu --noconfirm --noprogressbar --needed git unzip tar mingw-w64-${target}-toolchain mingw-w64-${target}-ccache mingw-w64-${target}-ntldd mingw-w64-${target}-qt5 mingw-w64-${target}-SDL mingw-w64-${target}-mesa mingw-w64-${target}-openssl
- pacman -Syu --noconfirm --noprogressbar --needed mingw-w64-${target}-gdal-minimal mingw-w64-${target}-OpenSceneGraph mingw-w64-${target}-osgearth
- pacman -Syu --noconfirm --noprogressbar --needed mingw-w64-${target}-gstreamer mingw-w64-${target}-gst-plugins-base mingw-w64-${target}-gst-plugins-good mingw-w64-${target}-gst-plugins-bad
- mingw32-make all_sdk_install
- git config core.filemode false
- mingw32-make build-info && cat build/build-info.txt
Expand Down
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,22 @@ ifeq ($(UNAME), Linux)
GCS_WITH_OSG := 1
GCS_WITH_OSGEARTH := 1
GCS_COPY_OSG := 0
GCS_WITH_GSTREAMER := 0
GCS_COPY_GSTREAMER := 0
else ifeq ($(UNAME), Darwin)
UAVOBJGENERATOR := $(BUILD_DIR)/uavobjgenerator/uavobjgenerator
GCS_WITH_OSG := 1
GCS_WITH_OSGEARTH := 0
GCS_COPY_OSG := 1
GCS_WITH_GSTREAMER := 0
GCS_COPY_GSTREAMER := 0
else ifeq ($(UNAME), Windows)
UAVOBJGENERATOR := $(BUILD_DIR)/uavobjgenerator/uavobjgenerator.exe
GCS_WITH_OSG := 1
GCS_WITH_OSGEARTH := 1
GCS_COPY_OSG := 1
GCS_WITH_GSTREAMER := 1
GCS_COPY_GSTREAMER := 1
endif

export UAVOBJGENERATOR
Expand All @@ -159,6 +165,13 @@ ifeq ($(GCS_WITH_OSG), 1)
endif
endif

ifeq ($(GCS_WITH_GSTREAMER), 1)
GCS_EXTRA_CONF += gstreamer
ifeq ($(GCS_COPY_GSTREAMER), 1)
GCS_EXTRA_CONF += copy_gstreamer
endif
endif

##############################
#
# All targets
Expand Down Expand Up @@ -590,6 +603,10 @@ config_help:
@$(ECHO) " (Needed unless using system versions)"
@$(ECHO) " Options: 0 or 1"
@$(ECHO)
@$(ECHO) " GCS_WITH_GSTREAMER=$(GCS_WITH_GSTREAMER)"
@$(ECHO) " Build the GCS with GStreamer support, this enables the video gadget and extra PFD video views"
@$(ECHO) " Options: 0 or 1"
@$(ECHO)
@$(ECHO) " CCACHE=$(CCACHE)"
@$(ECHO) " A prefix to compiler invocations, usually 'ccache' or 'path/to/ccache'"
@$(ECHO)
Expand Down
1 change: 1 addition & 0 deletions flight/pios/common/pios_board_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ void PIOS_BOARD_IO_Configure_GCS_RCVR()
void PIOS_BOARD_IO_Configure_OPLink_RCVR()
{
uint32_t pios_oplinkrcvr_id;

OPLinkReceiverInitialize();
#if defined(PIOS_INCLUDE_RFM22B)
PIOS_OPLinkRCVR_Init(&pios_oplinkrcvr_id, pios_rfm22b_id);
Expand Down
27 changes: 14 additions & 13 deletions flight/pios/common/pios_ms56xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
#define POW2(x) (1 << x)

// Command addresses
#define MS56XX_RESET 0x1E
#define MS56XX_CALIB_ADDR 0xA2 /* First sample is factory stuff */
#define MS56XX_CALIB_LEN 16
#define MS56XX_ADC_READ 0x00
#define MS56XX_PRES_ADDR 0x40
#define MS56XX_TEMP_ADDR 0x50
#define MS56XX_RESET 0x1E
#define MS56XX_CALIB_ADDR 0xA2 /* First sample is factory stuff */
#define MS56XX_CALIB_LEN 16
#define MS56XX_ADC_READ 0x00
#define MS56XX_PRES_ADDR 0x40
#define MS56XX_TEMP_ADDR 0x50

// Option to change the interleave between Temp and Pressure conversions
// Undef for normal operation
Expand Down Expand Up @@ -128,7 +128,7 @@ const PIOS_SENSORS_Driver PIOS_MS56xx_Driver = {
*/
void PIOS_MS56xx_Init(const struct pios_ms56xx_cfg *cfg, int32_t i2c_device)
{
i2c_id = i2c_device;
i2c_id = i2c_device;

ms56xx_address = cfg->address;
version = cfg->version;
Expand Down Expand Up @@ -262,14 +262,14 @@ int32_t PIOS_MS56xx_ReadADC(void)
// Offset and sensitivity at actual temperature
if (version == MS56XX_VERSION_5611) {
// OFF = OFFT1 + TCO * dT = C2 * 2^16 + (C4 * dT) / 2^7
Offset = ((int64_t)CalibData.C[1]) * POW2(16) + (((int64_t)CalibData.C[3]) * deltaTemp) / POW2(7) - Offset2;
Offset = ((int64_t)CalibData.C[1]) * POW2(16) + (((int64_t)CalibData.C[3]) * deltaTemp) / POW2(7) - Offset2;
// SENS = SENST1 + TCS * dT = C1 * 2^15 + (C3 * dT) / 2^8
Sens = ((int64_t)CalibData.C[0]) * POW2(15) + (((int64_t)CalibData.C[2]) * deltaTemp) / POW2(8) - Sens2;
Sens = ((int64_t)CalibData.C[0]) * POW2(15) + (((int64_t)CalibData.C[2]) * deltaTemp) / POW2(8) - Sens2;
} else {
// OFF = OFFT1 + TCO * dT = C2 * 2^17 + (C4 * dT) / 2^6
Offset = ((int64_t)CalibData.C[1]) * POW2(17) + (((int64_t)CalibData.C[3]) * deltaTemp) / POW2(6) - Offset2;
Offset = ((int64_t)CalibData.C[1]) * POW2(17) + (((int64_t)CalibData.C[3]) * deltaTemp) / POW2(6) - Offset2;
// SENS = SENST1 + TCS * dT = C1 * 2^16 + (C3 * dT) / 2^7
Sens = ((int64_t)CalibData.C[0]) * POW2(16) + (((int64_t)CalibData.C[2]) * deltaTemp) / POW2(7) - Sens2;
Sens = ((int64_t)CalibData.C[0]) * POW2(16) + (((int64_t)CalibData.C[2]) * deltaTemp) / POW2(7) - Sens2;
}

// Temperature compensated pressure (10…1200mbar with 0.01mbar resolution)
Expand Down Expand Up @@ -516,10 +516,11 @@ bool PIOS_MS56xx_driver_poll(__attribute__((unused)) uintptr_t context)
}

/* Poll the pressure sensor and return the temperature and pressure. */
bool PIOS_MS56xx_Read(float *temperature, float *pressure) {
bool PIOS_MS56xx_Read(float *temperature, float *pressure)
{
if (PIOS_MS56xx_driver_poll(0)) {
*temperature = results.temperature;
*pressure = results.sample;
*pressure = results.sample;
return true;
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion flight/pios/common/pios_oplinkrcvr.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <pios_oplinkrcvr_priv.h>

// Put receiver in failsafe if not updated within timeout
#define PIOS_OPLINK_RCVR_TIMEOUT_MS 100
#define PIOS_OPLINK_RCVR_TIMEOUT_MS 100

/* Provide a RCVR driver */
static int32_t PIOS_OPLinkRCVR_Get(uint32_t rcvr_id, uint8_t channel);
Expand Down
1 change: 0 additions & 1 deletion flight/targets/boards/revolution/pios_board.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
******************************************************************************
* @addtogroup OpenPilotSystem OpenPilot System
Expand Down
1 change: 0 additions & 1 deletion flight/targets/boards/sparky2/pios_board.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
******************************************************************************
* @addtogroup OpenPilotSystem OpenPilot System
Expand Down
2 changes: 1 addition & 1 deletion ground/gcs/copydata.pro
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ win32 {

for(dll, QT_DLLS) {
addCopyFileTarget($${dll},$$[QT_INSTALL_BINS],$${GCS_APP_PATH})
win32:addCopyDependenciesTarget($${dll},$$[QT_INSTALL_BINS],$${GCS_APP_PATH})
addCopyDependenciesTarget($${dll},$$[QT_INSTALL_BINS],$${GCS_APP_PATH})
}

# copy OpenSSL DLLs
Expand Down
4 changes: 4 additions & 0 deletions ground/gcs/src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,10 @@ void systemInit()
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
format.setSwapInterval(0);
QSurfaceFormat::setDefaultFormat(format);

// see https://bugreports.qt.io/browse/QTBUG-40332
int timeout = std::numeric_limits<int>::max();
qputenv("QT_BEARER_POLL_TIMEOUT", QString::number(timeout).toLatin1());
}

static FileLogger *logger = NULL;
Expand Down
2 changes: 2 additions & 0 deletions ground/gcs/src/libs/extensionsystem/pluginerrorview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,11 @@ void PluginErrorView::update(PluginSpec *spec)
case PluginSpec::Stopped:
text = tr("Stopped");
tooltip = tr("Plugin was shut down");
break;
case PluginSpec::Deleted:
text = tr("Deleted");
tooltip = tr("Plugin ended its life cycle and was deleted");
break;
}
m_ui->state->setText(text);
m_ui->state->setToolTip(tooltip);
Expand Down
83 changes: 83 additions & 0 deletions ground/gcs/src/libs/gstreamer/copydata.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
win32:gstreamer {

GST_BIN_DIR = $$system(pkg-config --variable=exec_prefix gstreamer-1.0)/bin
GST_PLUGINS_DIR = $$system(pkg-config --variable=pluginsdir gstreamer-1.0)

# gstreamer libraries
GST_LIBS = \
libgstreamer-1.0-0.dll

gstreamer_utilities:GST_LIBS += \
gst-inspect-1.0.exe \
gst-launch-1.0.exe

for(lib, GST_LIBS) {
addCopyFileTarget($${lib},$${GST_BIN_DIR},$${GCS_APP_PATH})
addCopyDependenciesTarget($${lib},$${GST_BIN_DIR},$${GCS_APP_PATH})
}

# gstreamer core
GST_PLUGINS = \
libgstcoreelements.dll

# gst-plugins-base
GST_PLUGINS += \
libgstapp.dll \
libgstaudiotestsrc.dll \
libgstpango.dll \
libgstplayback.dll \
libgsttcp.dll \
libgsttypefindfunctions.dll \
libgstvideoconvert.dll \
libgstvideorate.dll \
libgstvideoscale.dll \
libgstvideotestsrc.dll

# gst-plugins-good
GST_PLUGINS += \
libgstautodetect.dll \
libgstavi.dll \
libgstdeinterlace.dll \
libgstdirectsoundsink.dll \
libgstimagefreeze.dll \
libgstjpeg.dll \
libgstrawparse.dll \
libgstrtp.dll \
libgstrtpmanager.dll \
libgstrtsp.dll \
libgstudp.dll \
libgstvideomixer.dll

# gst-plugins-bad
GST_PLUGINS += \
libgstaudiovisualizers.dll \
libgstautoconvert.dll \
libgstcompositor.dll \
libgstd3dvideosink.dll \
libgstdebugutilsbad.dll \
libgstdirectsoundsrc.dll \
libgstopengl.dll \
libgstinter.dll \
libgstmpegpsdemux.dll \
libgstmpegpsmux.dll \
libgstmpegtsdemux.dll \
libgstmpegtsmux.dll \
libgstvideoparsersbad.dll \
libgstwinks.dll \
libgstwinscreencap.dll

# gst-plugins-ugly
GST_PLUGINS += \
libgstmpeg2dec.dll \
libgstx264.dll

# gst-libav
GST_PLUGINS += \
libgstlibav.dll

for(lib, GST_PLUGINS) {
addCopyFileTarget($${lib},$${GST_PLUGINS_DIR},$${GCS_LIBRARY_PATH}/gstreamer-1.0)
addCopyDependenciesTarget($${lib},$${GST_PLUGINS_DIR},$${GCS_APP_PATH})
}

}
136 changes: 136 additions & 0 deletions ground/gcs/src/libs/gstreamer/devicemonitor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/**
******************************************************************************
*
* @file devicemonitor.cpp
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 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 General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "devicemonitor.h"

#include "gst_util.h"

#include <gst/gst.h>

#include <QDebug>

static GstBusSyncReply my_bus_sync_func(GstBus *bus, GstMessage *message, gpointer user_data)
{
Q_UNUSED(bus)

DeviceMonitor * dm;
GstDevice *device;
gchar *name;

switch (GST_MESSAGE_TYPE(message)) {
case GST_MESSAGE_DEVICE_ADDED:
gst_message_parse_device_added(message, &device);
name = gst_device_get_display_name(device);

dm = (DeviceMonitor *)user_data;
QMetaObject::invokeMethod(dm, "device_added", Qt::QueuedConnection,
Q_ARG(QString, QString(name)));

g_free(name);
break;
case GST_MESSAGE_DEVICE_REMOVED:
gst_message_parse_device_removed(message, &device);
name = gst_device_get_display_name(device);

dm = (DeviceMonitor *)user_data;
QMetaObject::invokeMethod(dm, "device_removed", Qt::QueuedConnection,
Q_ARG(QString, QString(name)));

g_free(name);
break;
default:
break;
}

// no need to pass it to the async queue, there is none...
return GST_BUS_DROP;
}

DeviceMonitor::DeviceMonitor(QObject *parent) : QObject(parent)
{
// initialize gstreamer
gst::init(NULL, NULL);

monitor = gst_device_monitor_new();

GstBus *bus = gst_device_monitor_get_bus(monitor);
gst_bus_set_sync_handler(bus, (GstBusSyncHandler)my_bus_sync_func, this, NULL);
gst_object_unref(bus);

GstCaps *caps = NULL; // gst_caps_new_empty_simple("video/x-raw");
const gchar *classes = "Video/Source";
gst_device_monitor_add_filter(monitor, classes, caps);
if (caps) {
gst_caps_unref(caps);
}

if (!gst_device_monitor_start(monitor)) {
qWarning() << "Failed to start device monitor";
}
}

DeviceMonitor::~DeviceMonitor()
{
gst_device_monitor_stop(monitor);
gst_object_unref(monitor);
}

QList<Device> DeviceMonitor::devices() const
{
QList<Device> devices;

GList *list = gst_device_monitor_get_devices(monitor);
while (list != NULL) {
gchar *name;
gchar *device_class;

GstDevice *device = (GstDevice *)list->data;
name = gst_device_get_display_name(device);
device_class = gst_device_get_device_class(device);

devices << Device(name, device_class);

g_free(name);
g_free(device_class);

gst_object_unref(device);
list = g_list_remove_link(list, list);
}

return devices;
}

void DeviceMonitor::device_added(QString name)
{
// qDebug() << "**** ADDED:" << name;
emit deviceAdded(name);
}

void DeviceMonitor::device_removed(QString name)
{
// qDebug() << "**** REMOVED:" << name;
emit deviceRemoved(name);
}
Loading

0 comments on commit dbe95ae

Please sign in to comment.