qt: allow per feature registration

Split plugin into features including
dynamic types which can be indiviually
registered during a static build.

More details here:

https://gitlab.freedesktop.org/gstreamer/gst-build/-/merge_requests/199
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/661

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/876>
This commit is contained in:
Stéphane Cerveau 2021-02-12 17:09:19 +01:00
parent 801a2243e5
commit 6cbba1e470
8 changed files with 100 additions and 18 deletions

View file

@ -22,32 +22,22 @@
#include "config.h"
#endif
#include "gstqtoverlay.h"
#include "gstqtsink.h"
#include "gstqtsrc.h"
#include "gstqtelements.h"
#include "qtitem.h"
#include <QtQml/QQmlApplicationEngine>
static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "qmlglsink",
GST_RANK_NONE, GST_TYPE_QT_SINK)) {
return FALSE;
}
gboolean ret = FALSE;
if (!gst_element_register (plugin, "qmlglsrc",
GST_RANK_NONE, GST_TYPE_QT_SRC)) {
return FALSE;
}
ret |= GST_ELEMENT_REGISTER (qmlglsink, plugin);
if (!gst_element_register (plugin, "qmlgloverlay",
GST_RANK_NONE, GST_TYPE_QT_OVERLAY)) {
return FALSE;
}
/* this means the plugin must be loaded before the qml engine is loaded */
qmlRegisterType<QtGLVideoItem> ("org.freedesktop.gstreamer.GLVideoItem", 1, 0, "GstGLVideoItem");
ret |= GST_ELEMENT_REGISTER (qmlglsrc, plugin);
return TRUE;
ret |= GST_ELEMENT_REGISTER (qmlgloverlay, plugin);
return ret;
}
#ifndef GST_PACKAGE_NAME

39
ext/qt/gstqtelement.cc Normal file
View file

@ -0,0 +1,39 @@
/*
* GStreamer
* Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstqtelements.h"
#include "qtitem.h"
#include <QtQml/QQmlApplicationEngine>
gboolean
qt5_element_init (GstPlugin * plugin)
{
static gsize res = FALSE;
if (g_once_init_enter (&res)) {
/* this means the plugin must be loaded before the qml engine is loaded */
qmlRegisterType<QtGLVideoItem> ("org.freedesktop.gstreamer.GLVideoItem", 1, 0, "GstGLVideoItem");
g_once_init_leave (&res, TRUE);
}
return res;
}

35
ext/qt/gstqtelements.h Normal file
View file

@ -0,0 +1,35 @@
/*
* Copyright (C) 2020 Huawei Technologies Co., Ltd.
* @Author: Julian Bouzas <julian.bouzas@collabora.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __GST_QT_ELEMENTS_H__
#define __GST_QT_ELEMENTS_H__
#include <gst/gst.h>
G_BEGIN_DECLS
gboolean qt5_element_init (GstPlugin * plugin);
GST_ELEMENT_REGISTER_DECLARE (qmlglsink);
GST_ELEMENT_REGISTER_DECLARE (qmlglsrc);
GST_ELEMENT_REGISTER_DECLARE (qmlgloverlay);
G_END_DECLS
#endif /* __GST_QT_ELEMENTS_H__ */

View file

@ -79,6 +79,7 @@
#include "config.h"
#endif
#include "gstqtelements.h"
#include "gstqtoverlay.h"
#include "qtglrenderer.h"
#include "gstqtglutility.h"
@ -131,6 +132,10 @@ static guint gst_qt_overlay_signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE_WITH_CODE (GstQtOverlay, gst_qt_overlay,
GST_TYPE_GL_FILTER, GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT,
"qtoverlay", 0, "Qt Video Overlay"));
#define _do_init \
ret |= qt5_element_init (plugin);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (qmlgloverlay, "qmlgloverlay",
GST_RANK_NONE, GST_TYPE_QT_OVERLAY, _do_init);
static void
gst_qt_overlay_class_init (GstQtOverlayClass * klass)

View file

@ -72,6 +72,7 @@
#include "config.h"
#endif
#include "gstqtelements.h"
#include "gstqtsink.h"
#include <QtGui/QGuiApplication>
@ -134,6 +135,10 @@ enum
G_DEFINE_TYPE_WITH_CODE (GstQtSink, gst_qt_sink,
GST_TYPE_VIDEO_SINK, GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT,
"qtsink", 0, "Qt Video Sink"));
#define _do_init \
ret |= qt5_element_init (plugin);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (qmlglsink, "qmlglsink",
GST_RANK_NONE, GST_TYPE_QT_SINK, _do_init);
static void
gst_qt_sink_class_init (GstQtSinkClass * klass)

View file

@ -27,6 +27,7 @@
#include "config.h"
#endif
#include "gstqtelements.h"
#include "gstqtsrc.h"
#include <QtGui/QGuiApplication>
@ -76,6 +77,10 @@ enum
G_DEFINE_TYPE_WITH_CODE (GstQtSrc, gst_qt_src,
GST_TYPE_PUSH_SRC, GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT,
"qtsrc", 0, "Qt Video Src"));
#define _do_init \
ret |= qt5_element_init (plugin);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (qmlglsrc, "qmlglsrc",
GST_RANK_NONE, GST_TYPE_QT_SRC, _do_init);
static const gfloat vertical_flip_matrix[] = {
1.0f, 0.0f, 0.0f, 0.0f,

View file

@ -1,5 +1,6 @@
sources = [
'gstplugin.cc',
'gstqtelement.cc',
'gstqsgtexture.cc',
'gstqtglutility.cc',
'gstqtoverlay.cc',

View file

@ -79,6 +79,7 @@ versionAtLeast(QT_VERSION, "5.5") {
SOURCES += \
gstplugin.cc \
gstqtelement.cc \
gstqtglutility.cc \
gstqsgtexture.cc \
gstqtoverlay.cc \
@ -89,6 +90,7 @@ SOURCES += \
qtitem.cc
HEADERS += \
gstqtelements.h \
gstqsgtexture.h \
gstqtgl.h \
gstqtglutility.h \