Commit 22465514 authored by Andrew Voznytsa's avatar Andrew Voznytsa

Repackage video sink into GstQgcVideoSinkBin

parent a6d15868
......@@ -282,123 +282,15 @@ VideoManager::setfullScreen(bool f)
//-----------------------------------------------------------------------------
#if defined(QGC_GST_STREAMING)
gboolean
VideoManager::_videoSinkQuery(GstPad* pad, GstObject* parent, GstQuery* query)
{
GstElement* element;
switch (GST_QUERY_TYPE(query)) {
case GST_QUERY_CAPS:
element = gst_bin_get_by_name(GST_BIN(parent), "glupload");
break;
case GST_QUERY_CONTEXT:
element = gst_bin_get_by_name(GST_BIN(parent), "qmlglsink");
break;
default:
return gst_pad_query_default (pad, parent, query);
}
if (element == nullptr) {
qWarning() << "VideoManager::_videoSinkQuery(): No element found";
return FALSE;
}
GstPad* sinkpad = gst_element_get_static_pad(element, "sink");
if (sinkpad == nullptr) {
qWarning() << "VideoManager::_videoSinkQuery(): No sink pad found";
return FALSE;
}
const gboolean ret = gst_pad_query(sinkpad, query);
gst_object_unref(sinkpad);
sinkpad = nullptr;
return ret;
}
GstElement*
VideoManager::_makeVideoSink(gpointer widget)
{
GstElement* glupload = nullptr;
GstElement* glcolorconvert = nullptr;
GstElement* qmlglsink = nullptr;
GstElement* bin = nullptr;
GstElement* sink = nullptr;
do {
if ((glupload = gst_element_factory_make("glupload", "glupload")) == nullptr) {
qCritical() << "VideoManager::_makeVideoSink() failed. Error with gst_element_factory_make('glupload')";
break;
}
if ((glcolorconvert = gst_element_factory_make("glcolorconvert", "glcolorconvert")) == nullptr) {
qCritical() << "VideoManager::_makeVideoSink() failed. Error with gst_element_factory_make('glcolorconvert')";
break;
}
if ((qmlglsink = gst_element_factory_make("qmlglsink", "qmlglsink")) == nullptr) {
qCritical() << "VideoManager::_makeVideoSink() failed. Error with gst_element_factory_make('qmlglsink')";
break;
}
g_object_set(qmlglsink, "widget", widget, NULL);
if ((bin = gst_bin_new("videosink")) == nullptr) {
qCritical() << "VideoManager::_makeVideoSink() failed. Error with gst_bin_new('videosink')";
break;
}
GstPad* pad;
if ((pad = gst_element_get_static_pad(glupload, "sink")) == nullptr) {
qCritical() << "VideoManager::_makeVideoSink() failed. Error with gst_element_get_static_pad(glupload, 'sink')";
break;
}
gst_bin_add_many(GST_BIN(bin), glupload, glcolorconvert, qmlglsink, nullptr);
gboolean ret = gst_element_link_many(glupload, glcolorconvert, qmlglsink, nullptr);
qmlglsink = glcolorconvert = glupload = nullptr;
if (!ret) {
qCritical() << "VideoManager::_makeVideoSink() failed. Error with gst_element_link_many()";
break;
}
GstPad* ghostpad = gst_ghost_pad_new("sink", pad);
GstElement* sink;
gst_pad_set_query_function(ghostpad, _videoSinkQuery);
gst_element_add_pad(bin, ghostpad);
gst_object_unref(pad);
pad = nullptr;
sink = bin;
bin = nullptr;
} while(0);
if (bin != nullptr) {
gst_object_unref(bin);
bin = nullptr;
}
if (qmlglsink != nullptr) {
gst_object_unref(qmlglsink);
qmlglsink = nullptr;
}
if (glcolorconvert != nullptr) {
gst_object_unref(glcolorconvert);
glcolorconvert = nullptr;
}
if (glupload != nullptr) {
gst_object_unref(glupload);
glupload = nullptr;
if ((sink = gst_element_factory_make("qgcvideosinkbin", nullptr)) != nullptr) {
g_object_set(sink, "widget", widget, NULL);
} else {
qCritical() << "VideoManager::_makeVideoSink() failed. Error with gst_element_factory_make('qgcvideosinkbin')";
}
return sink;
......
......@@ -67,6 +67,7 @@ static void gst_android_log(GstDebugCategory * category,
#endif
#endif
GST_PLUGIN_STATIC_DECLARE(qmlgl);
GST_PLUGIN_STATIC_DECLARE(qgc);
G_END_DECLS
#endif
......@@ -168,6 +169,8 @@ void initializeVideoStreaming(int &argc, char* argv[], char* logpath, char* debu
} else {
qCritical() << "unable to find qmlglsink - you need to build it yourself and add to GST_PLUGIN_PATH";
}
GST_PLUGIN_STATIC_REGISTER(qgc);
#else
qmlRegisterType<GLVideoItemStub>("org.freedesktop.gstreamer.GLVideoItem", 1, 0, "GstGLVideoItem");
Q_UNUSED(argc)
......
......@@ -127,6 +127,10 @@ VideoEnabled {
$$PWD/iOS
}
SOURCES += \
$$PWD/gstqgcvideosinkbin.c \
$$PWD/gstqgc.c
include($$PWD/../../qmlglsink.pri)
} else {
LinuxBuild|MacBuild|iOSBuild|WindowsBuild|AndroidBuild {
......
/****************************************************************************
*
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
/**
* @file
* @brief GStreamer plugin for QGC's Video Receiver
* @author Andrew Voznyts <andrew.voznytsa@gmail.com>
* @author Tomaz Canabrava <tcanabrava@kde.org>
*/
#include <gst/gst.h>
gboolean gst_qgc_video_sink_bin_plugin_init(GstPlugin *plugin);
static gboolean
plugin_init(GstPlugin* plugin)
{
if (!gst_qgc_video_sink_bin_plugin_init(plugin)) {
return FALSE;
}
return TRUE;
}
#define PACKAGE "QGC Video Receiver"
#define PACKAGE_VERSION "current"
#define GST_LICENSE "LGPL"
#define GST_PACKAGE_NAME "GStreamer plugin for QGC's Video Receiver"
#define GST_PACKAGE_ORIGIN "http://qgroundcontrol.com/"
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR,
qgc, "QGC Video Receiver plugin",
plugin_init, PACKAGE_VERSION,
GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment