From c271d2958ee9f61903a2dd39141794a80b26c6b7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Cerveau?= Date: Thu, 18 Feb 2021 16:23:42 +0100 Subject: [PATCH] qroverlay: 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: --- ext/qroverlay/gstdebugqroverlay.c | 5 +++ ext/qroverlay/gstqroverlay.c | 28 ++--------------- ext/qroverlay/gstqroverlayelement.c | 44 ++++++++++++++++++++++++++ ext/qroverlay/gstqroverlayelements.h | 38 +++++++++++++++++++++++ ext/qroverlay/gstqroverlayplugin.c | 60 ++++++++++++++++++++++++++++++++++++ ext/qroverlay/meson.build | 2 +- 6 files changed, 151 insertions(+), 26 deletions(-) create mode 100644 ext/qroverlay/gstqroverlayelement.c create mode 100644 ext/qroverlay/gstqroverlayelements.h create mode 100644 ext/qroverlay/gstqroverlayplugin.c diff --git a/ext/qroverlay/gstdebugqroverlay.c b/ext/qroverlay/gstdebugqroverlay.c index 6a7f8e3..0c5d8a2 100644 --- a/ext/qroverlay/gstdebugqroverlay.c +++ b/ext/qroverlay/gstdebugqroverlay.c @@ -54,8 +54,10 @@ #include #include +#include "gstqroverlayelements.h" #include "gstdebugqroverlay.h" + GST_DEBUG_CATEGORY_STATIC (gst_debug_qr_overlay_debug); #define GST_CAT_DEFAULT gst_debug_qr_overlay_debug @@ -96,6 +98,9 @@ struct _GstDebugQROverlay #define gst_debug_qr_overlay_parent_class parent_class G_DEFINE_TYPE (GstDebugQROverlay, gst_debug_qr_overlay, GST_TYPE_BASE_QR_OVERLAY); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (debugqroverlay, "debugqroverlay", + GST_RANK_NONE, GST_TYPE_DEBUG_QR_OVERLAY, qroverlay_element_init (plugin)); + static void gst_debug_qr_overlay_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); diff --git a/ext/qroverlay/gstqroverlay.c b/ext/qroverlay/gstqroverlay.c index 9fc312d..beaacb7 100644 --- a/ext/qroverlay/gstqroverlay.c +++ b/ext/qroverlay/gstqroverlay.c @@ -47,11 +47,9 @@ #include #include +#include "gstqroverlayelements.h" #include "gstqroverlay.h" -GST_DEBUG_CATEGORY_STATIC (gst_qr_overlay_debug); -#define GST_CAT_DEFAULT gst_qr_overlay_debug - enum { PROP_0, @@ -68,6 +66,8 @@ struct _GstQROverlay #define gst_qr_overlay_parent_class parent_class G_DEFINE_TYPE (GstQROverlay, gst_qr_overlay, GST_TYPE_BASE_QR_OVERLAY); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (qroverlay, "qroverlay", GST_RANK_NONE, + GST_TYPE_QR_OVERLAY, qroverlay_element_init (plugin)); static gchar * get_qrcode_content (GstBaseQROverlay * base, GstBuffer * buf, @@ -156,25 +156,3 @@ static void gst_qr_overlay_init (GstQROverlay * filter) { } - -#include "gstdebugqroverlay.h" - -static gboolean -qroverlay_init (GstPlugin * qroverlay) -{ - GST_DEBUG_CATEGORY_INIT (gst_qr_overlay_debug, "qroverlay", 0, - "Qrcode overlay element"); - - if (gst_element_register (qroverlay, "debugqroverlay", GST_RANK_NONE, - GST_TYPE_DEBUG_QR_OVERLAY)) - return gst_element_register (qroverlay, "qroverlay", GST_RANK_NONE, - GST_TYPE_QR_OVERLAY); - - return FALSE; -} - -GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, - GST_VERSION_MINOR, - qroverlay, - "libqrencode qroverlay plugin", - qroverlay_init, VERSION, "LGPL", PACKAGE_NAME, GST_PACKAGE_ORIGIN) diff --git a/ext/qroverlay/gstqroverlayelement.c b/ext/qroverlay/gstqroverlayelement.c new file mode 100644 index 0000000..c64958b --- /dev/null +++ b/ext/qroverlay/gstqroverlayelement.c @@ -0,0 +1,44 @@ +/* + * GStreamer + * Copyright (C) 2006 Stefan Kost + * Copyright (c) 2020 Anthony Violo + * Copyright (c) 2020 Thibault Saunier + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "gstqroverlayelements.h" + +GST_DEBUG_CATEGORY_STATIC (gst_qr_overlay_debug); +#define GST_CAT_DEFAULT gst_qr_overlay_debug + +void +qroverlay_element_init (GstPlugin * plugin) +{ + static gsize res = FALSE; + + if (g_once_init_enter (&res)) { + GST_DEBUG_CATEGORY_INIT (gst_qr_overlay_debug, "qroverlay", 0, + "Qrcode overlay element"); + g_once_init_leave (&res, TRUE); + } +} diff --git a/ext/qroverlay/gstqroverlayelements.h b/ext/qroverlay/gstqroverlayelements.h new file mode 100644 index 0000000..7002ee0 --- /dev/null +++ b/ext/qroverlay/gstqroverlayelements.h @@ -0,0 +1,38 @@ +/* + * GStreamer + * Copyright (C) 2006 Stefan Kost + * Copyright (c) 2020 Anthony Violo + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GST_QR_OVERLAY_H__ +#define __GST_QR_OVERLAY_H__ + +#include "gstbaseqroverlay.h" + +G_BEGIN_DECLS +#define GST_TYPE_QR_OVERLAY (gst_qr_overlay_get_type()) + +G_DECLARE_FINAL_TYPE (GstQROverlay, gst_qr_overlay, GST, QR_OVERLAY, GstBaseQROverlay); + + +void qroverlay_element_init (GstPlugin * plugin); +GST_ELEMENT_REGISTER_DECLARE (debugqroverlay); +GST_ELEMENT_REGISTER_DECLARE (qroverlay); + +G_END_DECLS +#endif /* __GST_QR_OVERLAY_H__ */ diff --git a/ext/qroverlay/gstqroverlayplugin.c b/ext/qroverlay/gstqroverlayplugin.c new file mode 100644 index 0000000..9a52788 --- /dev/null +++ b/ext/qroverlay/gstqroverlayplugin.c @@ -0,0 +1,60 @@ +/* + * GStreamer + * Copyright (C) 2006 Stefan Kost + * Copyright (c) 2020 Anthony Violo + * Copyright (c) 2020 Thibault Saunier + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/** + * SECTION:element-qroverlay + * + * Element to set random data on a qroverlay. + * + * ## Example launch line + * + * ``` bash + * gst-launch -v -m videotestsrc ! qroverlay ! fakesink silent=TRUE + * ``` + * + * Since: 1.20 + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "gstqroverlayelements.h" + +static gboolean +plugin_init (GstPlugin * plugin) +{ + gboolean ret = FALSE; + + ret |= GST_ELEMENT_REGISTER (debugqroverlay, plugin); + ret |= GST_ELEMENT_REGISTER (qroverlay, plugin); + + return ret; +} + +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + qroverlay, + "libqrencode qroverlay plugin", + plugin_init, VERSION, "LGPL", PACKAGE_NAME, GST_PACKAGE_ORIGIN) diff --git a/ext/qroverlay/meson.build b/ext/qroverlay/meson.build index 0b1803d..3b3b51d 100644 --- a/ext/qroverlay/meson.build +++ b/ext/qroverlay/meson.build @@ -2,7 +2,7 @@ qrencode_dep = dependency('libqrencode', required: get_option('qroverlay')) if qrencode_dep.found() json_dep = dependency('json-glib-1.0', fallback : ['json-glib', 'json_glib_dep'], required: get_option('qroverlay')) if json_dep.found() - gstqroverlay = library('gstqroverlay', ['gstqroverlay.c', 'gstdebugqroverlay.c', 'gstbaseqroverlay.c'], + gstqroverlay = library('gstqroverlay', ['gstqroverlay.c', 'gstdebugqroverlay.c', 'gstbaseqroverlay.c', 'gstqroverlayelement.c', 'gstqroverlayplugin.c'], c_args : gst_plugins_bad_args, include_directories : [configinc], dependencies : [gstvideo_dep, qrencode_dep, json_dep], -- 2.7.4