ttml: allow per feature registration
authorStéphane Cerveau <scerveau@collabora.com>
Wed, 24 Feb 2021 12:07:30 +0000 (13:07 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 23 Mar 2021 14:19:17 +0000 (14:19 +0000)
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>

ext/ttml/gstttmlelement.c [new file with mode: 0644]
ext/ttml/gstttmlelements.h [new file with mode: 0644]
ext/ttml/gstttmlparse.c
ext/ttml/gstttmlplugin.c
ext/ttml/gstttmlrender.c
ext/ttml/meson.build

diff --git a/ext/ttml/gstttmlelement.c b/ext/ttml/gstttmlelement.c
new file mode 100644 (file)
index 0000000..97e9103
--- /dev/null
@@ -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);
+  }
+}
diff --git a/ext/ttml/gstttmlelements.h b/ext/ttml/gstttmlelements.h
new file mode 100644 (file)
index 0000000..000d1ce
--- /dev/null
@@ -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__ */
index d827a48..7966fba 100644 (file)
 #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);
+}
index 9137a8f..cb36c49 100644 (file)
 #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,
index f8d063f..8589d6b 100644 (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);
+}
index 2d22fdf..710a440 100644 (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],