Skip to content

Commit

Permalink
pango: allow per feature registration
Browse files Browse the repository at this point in the history
  • Loading branch information
Stéphane Cerveau authored and GStreamer Marge Bot committed Mar 16, 2021
1 parent d41e8c6 commit 59163a1
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 32 deletions.
28 changes: 0 additions & 28 deletions ext/pango/gstbasetextoverlay.c
Expand Up @@ -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
Expand Down Expand Up @@ -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)
5 changes: 4 additions & 1 deletion ext/pango/gstclockoverlay.c
Expand Up @@ -49,10 +49,11 @@
#include "config.h"
#endif

#include "gstclockoverlay.h"
#include <gst/video/video.h>
#include <time.h>

#include "gstclockoverlay.h"
#include "gstpangoelements.h"

#define DEFAULT_PROP_TIMEFORMAT "%H:%M:%S"

Expand All @@ -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,
Expand Down
45 changes: 45 additions & 0 deletions ext/pango/gstpangoelement.c
@@ -0,0 +1,45 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2003> David Schleef <ds@schleef.org>
* Copyright (C) <2006> Julien Moutte <julien@moutte.net>
* Copyright (C) <2006> Zeeshan Ali <zeeshan.ali@nokia.com>
* Copyright (C) <2006-2008> Tim-Philipp Müller <tim centricular net>
* Copyright (C) <2009> Young-Ho Cha <ganadist@gmail.com>
* Copyright (C) 2020 Huawei Technologies Co., Ltd.
* @Author: Stéphane Cerveau <scerveau@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.
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#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);
}
}
43 changes: 43 additions & 0 deletions ext/pango/gstpangoelements.h
@@ -0,0 +1,43 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2003> David Schleef <ds@schleef.org>
* Copyright (C) <2006> Julien Moutte <julien@moutte.net>
* Copyright (C) <2006> Zeeshan Ali <zeeshan.ali@nokia.com>
* Copyright (C) <2006-2008> Tim-Philipp Müller <tim centricular net>
* Copyright (C) <2009> Young-Ho Cha <ganadist@gmail.com>
* Copyright (C) 2020 Huawei Technologies Co., Ltd.
* @Author: Stéphane Cerveau <scerveau@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_PANGO_ELEMENTS_H__
#define __GST_PANGO_ELEMENTS_H__

#include <gst/gst.h>

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__ */
48 changes: 48 additions & 0 deletions ext/pango/gstpangoplugin.c
@@ -0,0 +1,48 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2003> David Schleef <ds@schleef.org>
* Copyright (C) <2006> Julien Moutte <julien@moutte.net>
* Copyright (C) <2006> Zeeshan Ali <zeeshan.ali@nokia.com>
* Copyright (C) <2006-2008> Tim-Philipp Müller <tim centricular net>
* Copyright (C) <2009> Young-Ho Cha <ganadist@gmail.com>
* Copyright (C) 2020 Huawei Technologies Co., Ltd.
* @Author: Stéphane Cerveau <scerveau@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.
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#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)
5 changes: 4 additions & 1 deletion ext/pango/gsttextoverlay.c
Expand Up @@ -75,7 +75,8 @@
#include "config.h"
#endif

#include <gsttextoverlay.h>
#include "gsttextoverlay.h"
#include "gstpangoelements.h"

static GstStaticPadTemplate text_sink_template_factory =
GST_STATIC_PAD_TEMPLATE ("text_sink",
Expand All @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions ext/pango/gsttextrender.c
Expand Up @@ -42,12 +42,13 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <string.h>
#include <gst/gst.h>
#include <gst/video/video.h>

#include "gsttextrender.h"
#include <string.h>
#include "gstpangoelements.h"


#if G_BYTE_ORDER == G_LITTLE_ENDIAN
# define CAIRO_ARGB_A 3
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions ext/pango/gsttimeoverlay.c
Expand Up @@ -51,6 +51,7 @@
#include <gst/video/video.h>

#include "gsttimeoverlay.h"
#include "gstpangoelements.h"

#define DEFAULT_TIME_LINE GST_TIME_OVERLAY_TIME_LINE_BUFFER_TIME
#define DEFAULT_SHOW_TIMES_AS_DATES FALSE
Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions ext/pango/meson.build
@@ -1,4 +1,6 @@
pango_sources = [
'gstpangoelement.c',
'gstpangoplugin.c',
'gstbasetextoverlay.c',
'gstclockoverlay.c',
'gsttextoverlay.c',
Expand Down

0 comments on commit 59163a1

Please sign in to comment.