From 59163a107df861696526d7b15bf804bfac7c64c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Fri, 11 Dec 2020 18:47:41 +0100 Subject: [PATCH] pango: 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/pango/gstbasetextoverlay.c | 28 -------------------- ext/pango/gstclockoverlay.c | 5 +++- ext/pango/gstpangoelement.c | 45 +++++++++++++++++++++++++++++++ ext/pango/gstpangoelements.h | 43 ++++++++++++++++++++++++++++++ ext/pango/gstpangoplugin.c | 48 ++++++++++++++++++++++++++++++++++ ext/pango/gsttextoverlay.c | 5 +++- ext/pango/gsttextrender.c | 7 +++-- ext/pango/gsttimeoverlay.c | 3 +++ ext/pango/meson.build | 2 ++ 9 files changed, 154 insertions(+), 32 deletions(-) create mode 100644 ext/pango/gstpangoelement.c create mode 100644 ext/pango/gstpangoelements.h create mode 100644 ext/pango/gstpangoplugin.c diff --git a/ext/pango/gstbasetextoverlay.c b/ext/pango/gstbasetextoverlay.c index 4e5024ece1..609a3f4801 100644 --- a/ext/pango/gstbasetextoverlay.c +++ b/ext/pango/gstbasetextoverlay.c @@ -43,9 +43,6 @@ * clipped properly during blitting (if wrapping is disabled) */ -GST_DEBUG_CATEGORY (pango_debug); -#define GST_CAT_DEFAULT pango_debug - #define DEFAULT_PROP_TEXT "" #define DEFAULT_PROP_SHADING FALSE #define DEFAULT_PROP_VALIGNMENT GST_BASE_TEXT_OVERLAY_VALIGN_BASELINE @@ -3075,28 +3072,3 @@ gst_base_text_overlay_change_state (GstElement * element, return ret; } - -static gboolean -plugin_init (GstPlugin * plugin) -{ - if (!gst_element_register (plugin, "textoverlay", GST_RANK_NONE, - GST_TYPE_TEXT_OVERLAY) || - !gst_element_register (plugin, "timeoverlay", GST_RANK_NONE, - GST_TYPE_TIME_OVERLAY) || - !gst_element_register (plugin, "clockoverlay", GST_RANK_NONE, - GST_TYPE_CLOCK_OVERLAY) || - !gst_element_register (plugin, "textrender", GST_RANK_NONE, - GST_TYPE_TEXT_RENDER)) { - return FALSE; - } - - /*texttestsrc_plugin_init(module, plugin); */ - - GST_DEBUG_CATEGORY_INIT (pango_debug, "pango", 0, "Pango elements"); - - return TRUE; -} - -GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, - pango, "Pango-based text rendering and overlay", plugin_init, - VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN) diff --git a/ext/pango/gstclockoverlay.c b/ext/pango/gstclockoverlay.c index ba8e625e65..5e7a5fa787 100644 --- a/ext/pango/gstclockoverlay.c +++ b/ext/pango/gstclockoverlay.c @@ -49,10 +49,11 @@ #include "config.h" #endif -#include "gstclockoverlay.h" #include #include +#include "gstclockoverlay.h" +#include "gstpangoelements.h" #define DEFAULT_PROP_TIMEFORMAT "%H:%M:%S" @@ -65,6 +66,8 @@ enum #define gst_clock_overlay_parent_class parent_class G_DEFINE_TYPE (GstClockOverlay, gst_clock_overlay, GST_TYPE_BASE_TEXT_OVERLAY); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (clockoverlay, "clockoverlay", + GST_RANK_NONE, GST_TYPE_CLOCK_OVERLAY, pango_element_init (plugin)); static void gst_clock_overlay_finalize (GObject * object); static void gst_clock_overlay_set_property (GObject * object, guint prop_id, diff --git a/ext/pango/gstpangoelement.c b/ext/pango/gstpangoelement.c new file mode 100644 index 0000000000..789e0866f1 --- /dev/null +++ b/ext/pango/gstpangoelement.c @@ -0,0 +1,45 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen + * Copyright (C) <2003> David Schleef + * Copyright (C) <2006> Julien Moutte + * Copyright (C) <2006> Zeeshan Ali + * Copyright (C) <2006-2008> Tim-Philipp Müller + * Copyright (C) <2009> Young-Ho Cha + * Copyright (C) 2020 Huawei Technologies Co., Ltd. + * @Author: Stéphane Cerveau + * + * 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 +#endif + +#include "gstpangoelements.h" + +GST_DEBUG_CATEGORY (pango_debug); +#define GST_CAT_DEFAULT pango_debug + +void +pango_element_init (GstPlugin * plugin) +{ + static gsize res = FALSE; + if (g_once_init_enter (&res)) { + /*texttestsrc_plugin_init(module, plugin); */ + GST_DEBUG_CATEGORY_INIT (pango_debug, "pango", 0, "Pango elements"); + g_once_init_leave (&res, TRUE); + } +} diff --git a/ext/pango/gstpangoelements.h b/ext/pango/gstpangoelements.h new file mode 100644 index 0000000000..c6b5c30e12 --- /dev/null +++ b/ext/pango/gstpangoelements.h @@ -0,0 +1,43 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen + * Copyright (C) <2003> David Schleef + * Copyright (C) <2006> Julien Moutte + * Copyright (C) <2006> Zeeshan Ali + * Copyright (C) <2006-2008> Tim-Philipp Müller + * Copyright (C) <2009> Young-Ho Cha + * Copyright (C) 2020 Huawei Technologies Co., Ltd. + * @Author: Stéphane Cerveau + * + * 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_PANGO_ELEMENTS_H__ +#define __GST_PANGO_ELEMENTS_H__ + +#include + +G_BEGIN_DECLS + +G_GNUC_INTERNAL void pango_element_init (GstPlugin * plugin); + +GST_ELEMENT_REGISTER_DECLARE (textoverlay); +GST_ELEMENT_REGISTER_DECLARE (timeoverlay); +GST_ELEMENT_REGISTER_DECLARE (clockoverlay); +GST_ELEMENT_REGISTER_DECLARE (textrender); + +G_END_DECLS + +#endif /* __GST_PANGO_ELEMENTS_H__ */ diff --git a/ext/pango/gstpangoplugin.c b/ext/pango/gstpangoplugin.c new file mode 100644 index 0000000000..721c271e3f --- /dev/null +++ b/ext/pango/gstpangoplugin.c @@ -0,0 +1,48 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen + * Copyright (C) <2003> David Schleef + * Copyright (C) <2006> Julien Moutte + * Copyright (C) <2006> Zeeshan Ali + * Copyright (C) <2006-2008> Tim-Philipp Müller + * Copyright (C) <2009> Young-Ho Cha + * Copyright (C) 2020 Huawei Technologies Co., Ltd. + * @Author: Stéphane Cerveau + * + * 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 +#endif + +#include "gstpangoelements.h" + +static gboolean +plugin_init (GstPlugin * plugin) +{ + gboolean ret = FALSE; + + ret |= GST_ELEMENT_REGISTER (textoverlay, plugin); + ret |= GST_ELEMENT_REGISTER (timeoverlay, plugin); + ret |= GST_ELEMENT_REGISTER (clockoverlay, plugin); + ret |= GST_ELEMENT_REGISTER (textrender, plugin); + + return ret; +} + +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, + pango, "Pango-based text rendering and overlay", plugin_init, + VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN) diff --git a/ext/pango/gsttextoverlay.c b/ext/pango/gsttextoverlay.c index 8622a75019..10b895dbe0 100644 --- a/ext/pango/gsttextoverlay.c +++ b/ext/pango/gsttextoverlay.c @@ -75,7 +75,8 @@ #include "config.h" #endif -#include +#include "gsttextoverlay.h" +#include "gstpangoelements.h" static GstStaticPadTemplate text_sink_template_factory = GST_STATIC_PAD_TEMPLATE ("text_sink", @@ -85,6 +86,8 @@ GST_STATIC_PAD_TEMPLATE ("text_sink", ); G_DEFINE_TYPE (GstTextOverlay, gst_text_overlay, GST_TYPE_BASE_TEXT_OVERLAY); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (textoverlay, "textoverlay", + GST_RANK_NONE, GST_TYPE_TEXT_OVERLAY, pango_element_init (plugin)); static void gst_text_overlay_class_init (GstTextOverlayClass * klass) diff --git a/ext/pango/gsttextrender.c b/ext/pango/gsttextrender.c index e98be0b10e..e6f5b3afcf 100644 --- a/ext/pango/gsttextrender.c +++ b/ext/pango/gsttextrender.c @@ -42,12 +42,13 @@ #ifdef HAVE_CONFIG_H #include #endif - +#include #include #include #include "gsttextrender.h" -#include +#include "gstpangoelements.h" + #if G_BYTE_ORDER == G_LITTLE_ENDIAN # define CAIRO_ARGB_A 3 @@ -165,6 +166,8 @@ static void gst_text_render_adjust_values_with_fontdesc (GstTextRender * #define gst_text_render_parent_class parent_class G_DEFINE_TYPE (GstTextRender, gst_text_render, GST_TYPE_ELEMENT); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (textrender, "textrender", + GST_RANK_NONE, GST_TYPE_TEXT_RENDER, pango_element_init (plugin)); static void gst_text_render_finalize (GObject * object); static void gst_text_render_set_property (GObject * object, diff --git a/ext/pango/gsttimeoverlay.c b/ext/pango/gsttimeoverlay.c index 66f49abf71..6de1de6d21 100644 --- a/ext/pango/gsttimeoverlay.c +++ b/ext/pango/gsttimeoverlay.c @@ -51,6 +51,7 @@ #include #include "gsttimeoverlay.h" +#include "gstpangoelements.h" #define DEFAULT_TIME_LINE GST_TIME_OVERLAY_TIME_LINE_BUFFER_TIME #define DEFAULT_SHOW_TIMES_AS_DATES FALSE @@ -67,6 +68,8 @@ enum #define gst_time_overlay_parent_class parent_class G_DEFINE_TYPE (GstTimeOverlay, gst_time_overlay, GST_TYPE_BASE_TEXT_OVERLAY); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (timeoverlay, "timeoverlay", + GST_RANK_NONE, GST_TYPE_TIME_OVERLAY, pango_element_init (plugin)); static void gst_time_overlay_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); diff --git a/ext/pango/meson.build b/ext/pango/meson.build index edd9694d65..8368f4450c 100644 --- a/ext/pango/meson.build +++ b/ext/pango/meson.build @@ -1,4 +1,6 @@ pango_sources = [ + 'gstpangoelement.c', + 'gstpangoplugin.c', 'gstbasetextoverlay.c', 'gstclockoverlay.c', 'gsttextoverlay.c',