ttml: 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-bad/-/merge_requests/2038>
This commit is contained in:
Stéphane Cerveau 2021-02-24 13:07:30 +01:00 committed by GStreamer Marge Bot
parent 4f16edf0d0
commit 0b07d970fe
6 changed files with 129 additions and 23 deletions

42
ext/ttml/gstttmlelement.c Normal file
View file

@ -0,0 +1,42 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) 2004 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
* Copyright (C) <2015> British Broadcasting Corporation <dash@rd.bbc.co.uk>
*
* 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 "gstttmlelements.h"
GST_DEBUG_CATEGORY (ttmlrender_debug);
void
ttml_element_init (GstPlugin * plugin)
{
static gsize res = FALSE;
if (g_once_init_enter (&res)) {
gst_plugin_add_dependency_simple (plugin, "GST_TTML_AUTOPLUG", NULL, NULL,
GST_PLUGIN_DEPENDENCY_FLAG_NONE);
g_once_init_leave (&res, TRUE);
}
}

View file

@ -0,0 +1,35 @@
/* GStreamer
* Copyright (C) <2020> The GStreamer Contributors.
*
* 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_TTML_ELEMENTS_H__
#define __GST_TTML_ELEMENTS_H__
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <gst/gst.h>
void ttml_element_init (GstPlugin * plugin);
GST_ELEMENT_REGISTER_DECLARE (ttmlparse);
GST_ELEMENT_REGISTER_DECLARE (ttmlrender);
#endif /* __GST_TTML_ELEMENTS_H__ */

View file

@ -50,12 +50,14 @@
#include <sys/types.h>
#include <glib.h>
#include "gstttmlelements.h"
#include "gstttmlparse.h"
#include "ttmlparse.h"
GST_DEBUG_CATEGORY_EXTERN (ttmlparse_debug);
GST_DEBUG_CATEGORY (ttmlparse_debug);
#define GST_CAT_DEFAULT ttmlparse_debug
#define DEFAULT_ENCODING NULL
static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
@ -82,9 +84,11 @@ static GstStateChangeReturn gst_ttml_parse_change_state (GstElement * element,
static GstFlowReturn gst_ttml_parse_chain (GstPad * sinkpad, GstObject * parent,
GstBuffer * buf);
static gboolean gst_element_ttmlparse_init (GstPlugin * plugin);
#define gst_ttml_parse_parent_class parent_class
G_DEFINE_TYPE (GstTtmlParse, gst_ttml_parse, GST_TYPE_ELEMENT);
GST_ELEMENT_REGISTER_DEFINE_CUSTOM (ttmlparse, gst_element_ttmlparse_init);
static void
gst_ttml_parse_dispose (GObject * object)
@ -596,3 +600,21 @@ gst_ttml_parse_change_state (GstElement * element, GstStateChange transition)
return ret;
}
static gboolean
gst_element_ttmlparse_init (GstPlugin * plugin)
{
guint rank = GST_RANK_NONE;
ttml_element_init (plugin);
/* We don't want this autoplugged by default yet for now */
if (g_getenv ("GST_TTML_AUTOPLUG")) {
GST_INFO_OBJECT (plugin, "Registering ttml elements with primary rank.");
rank = GST_RANK_PRIMARY;
}
GST_DEBUG_CATEGORY_INIT (ttmlparse_debug, "ttmlparse", 0, "TTML parser");
return gst_element_register (plugin, "ttmlparse", rank, GST_TYPE_TTML_PARSE);
}

View file

@ -24,35 +24,18 @@
#include <config.h>
#endif
#include "gstttmlparse.h"
#include "gstttmlrender.h"
#include "gstttmlelements.h"
GST_DEBUG_CATEGORY (ttmlparse_debug);
GST_DEBUG_CATEGORY (ttmlrender_debug);
static gboolean
plugin_init (GstPlugin * plugin)
{
guint rank = GST_RANK_NONE;
gboolean ret = FALSE;
/* We don't want this autoplugged by default yet for now */
if (g_getenv ("GST_TTML_AUTOPLUG")) {
GST_INFO_OBJECT (plugin, "Registering ttml elements with primary rank.");
rank = GST_RANK_PRIMARY;
}
ret |= GST_ELEMENT_REGISTER (ttmlparse, plugin);
ret |= GST_ELEMENT_REGISTER (ttmlrender, plugin);
gst_plugin_add_dependency_simple (plugin, "GST_TTML_AUTOPLUG", NULL, NULL,
GST_PLUGIN_DEPENDENCY_FLAG_NONE);
if (!gst_element_register (plugin, "ttmlparse", rank, GST_TYPE_TTML_PARSE))
return FALSE;
if (!gst_element_register (plugin, "ttmlrender", rank, GST_TYPE_TTML_RENDER))
return FALSE;
GST_DEBUG_CATEGORY_INIT (ttmlparse_debug, "ttmlparse", 0, "TTML parser");
GST_DEBUG_CATEGORY_INIT (ttmlrender_debug, "ttmlrender", 0, "TTML renderer");
return TRUE;
return ret;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,

View file

@ -48,6 +48,7 @@
#include <string.h>
#include <math.h>
#include "gstttmlelements.h"
#include "gstttmlrender.h"
#include "subtitle.h"
#include "subtitlemeta.h"
@ -196,6 +197,7 @@ static GstTtmlRenderRenderedImage *gst_ttml_render_stitch_images (GPtrArray *
images, GstTtmlDirection direction);
static gboolean gst_ttml_render_color_is_transparent (GstSubtitleColor * color);
static gboolean gst_element_ttmlrender_init (GstPlugin * plugin);
GType
gst_ttml_render_get_type (void)
@ -222,6 +224,8 @@ gst_ttml_render_get_type (void)
return type;
}
GST_ELEMENT_REGISTER_DEFINE_CUSTOM (ttmlrender, gst_element_ttmlrender_init);
static void
gst_ttml_render_base_init (gpointer g_class)
{
@ -3059,3 +3063,22 @@ gst_ttml_render_change_state (GstElement * element, GstStateChange transition)
return ret;
}
static gboolean
gst_element_ttmlrender_init (GstPlugin * plugin)
{
guint rank = GST_RANK_NONE;
ttml_element_init (plugin);
/* We don't want this autoplugged by default yet for now */
if (g_getenv ("GST_TTML_AUTOPLUG")) {
GST_INFO_OBJECT (plugin, "Registering ttml elements with primary rank.");
rank = GST_RANK_PRIMARY;
}
GST_DEBUG_CATEGORY_INIT (ttmlrender_debug, "ttmlrender", 0, "TTML renderer");
return gst_element_register (plugin, "ttmlrender", rank,
GST_TYPE_TTML_RENDER);
}

View file

@ -10,6 +10,7 @@ if libxml_dep.found() and pango_dep.found() and cairo_dep.found() and pangocairo
'gstttmlparse.c',
'ttmlparse.c',
'gstttmlrender.c',
'gstttmlelement.c',
'gstttmlplugin.c'],
c_args : gst_plugins_bad_args,
include_directories : [configinc],