playback: allow per feature registration
authorStéphane Cerveau <scerveau@collabora.com>
Thu, 22 Oct 2020 09:07:26 +0000 (11:07 +0200)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 10 Dec 2020 13:01:57 +0000 (13:01 +0000)
Split plugin into features including
elements and device providers 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-base/-/merge_requests/900>

18 files changed:
gst/playback/gstdecodebin2.c
gst/playback/gstdecodebin3.c
gst/playback/gstparsebin.c
gst/playback/gstplaybackelement.c [moved from gst/playback/gstplayback.h with 51% similarity]
gst/playback/gstplaybackelements.h [new file with mode: 0644]
gst/playback/gstplaybackplugin.c [moved from gst/playback/gstplayback.c with 54% similarity]
gst/playback/gstplaybin2.c
gst/playback/gstplaybin3.c
gst/playback/gstplaysink.c
gst/playback/gstplaysink.h
gst/playback/gststreamsynchronizer.c
gst/playback/gststreamsynchronizer.h
gst/playback/gstsubtitleoverlay.c
gst/playback/gstsubtitleoverlay.h
gst/playback/gsturidecodebin.c
gst/playback/gsturidecodebin3.c
gst/playback/gsturisourcebin.c
gst/playback/meson.build

index aa0ec50..c46ac22 100644 (file)
@@ -99,7 +99,7 @@
 #include <gst/pbutils/pbutils.h>
 
 #include "gstplay-enum.h"
-#include "gstplayback.h"
+#include "gstplaybackelements.h"
 #include "gstrawcaps.h"
 #include "gstplaybackutils.h"
 
@@ -584,37 +584,29 @@ static GstPadProbeReturn pad_event_cb (GstPad * pad, GstPadProbeInfo * info,
  * Standard GObject boilerplate *
  ********************************/
 
-static void gst_decode_bin_class_init (GstDecodeBinClass * klass);
-static void gst_decode_bin_init (GstDecodeBin * decode_bin);
 static void gst_decode_bin_dispose (GObject * object);
 static void gst_decode_bin_finalize (GObject * object);
 
-static GType
-gst_decode_bin_get_type (void)
-{
-  static GType gst_decode_bin_type = 0;
-
-  if (!gst_decode_bin_type) {
-    static const GTypeInfo gst_decode_bin_info = {
-      sizeof (GstDecodeBinClass),
-      NULL,
-      NULL,
-      (GClassInitFunc) gst_decode_bin_class_init,
-      NULL,
-      NULL,
-      sizeof (GstDecodeBin),
-      0,
-      (GInstanceInitFunc) gst_decode_bin_init,
-      NULL
-    };
-
-    gst_decode_bin_type =
-        g_type_register_static (GST_TYPE_BIN, "GstDecodeBin",
-        &gst_decode_bin_info, 0);
-  }
-
-  return gst_decode_bin_type;
-}
+/* Register some quarks here for the stream topology message */
+static GQuark topology_structure_name = 0;
+static GQuark topology_caps = 0;
+static GQuark topology_next = 0;
+static GQuark topology_pad = 0;
+static GQuark topology_element_srcpad = 0;
+
+GType gst_decode_bin_get_type (void);
+G_DEFINE_TYPE (GstDecodeBin, gst_decode_bin, GST_TYPE_BIN);
+#define _do_init \
+    GST_DEBUG_CATEGORY_INIT (gst_decode_bin_debug, "decodebin", 0, "decoder bin");\
+    topology_structure_name = g_quark_from_static_string ("stream-topology"); \
+    topology_caps = g_quark_from_static_string ("caps");\
+    topology_next = g_quark_from_static_string ("next");\
+    topology_pad = g_quark_from_static_string ("pad");\
+    topology_element_srcpad = g_quark_from_static_string ("element-srcpad");\
+    ret |= playback_element_init (plugin);\
+
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (decodebin, "decodebin", GST_RANK_NONE,
+    GST_TYPE_DECODE_BIN, _do_init);
 
 static gboolean
 _gst_boolean_accumulator (GSignalInvocationHint * ihint,
@@ -4527,12 +4519,6 @@ _gst_element_get_linked_caps (GstElement * src, GstElement * sink,
   return caps;
 }
 
-static GQuark topology_structure_name = 0;
-static GQuark topology_caps = 0;
-static GQuark topology_next = 0;
-static GQuark topology_pad = 0;
-static GQuark topology_element_srcpad = 0;
-
 /* FIXME: Invent gst_structure_take_structure() to prevent all the
  * structure copying for nothing
  */
@@ -5704,19 +5690,3 @@ gst_decode_bin_remove_element (GstBin * bin, GstElement * element)
 
   return GST_BIN_CLASS (parent_class)->remove_element (bin, element);
 }
-
-gboolean
-gst_decode_bin_plugin_init (GstPlugin * plugin)
-{
-  GST_DEBUG_CATEGORY_INIT (gst_decode_bin_debug, "decodebin", 0, "decoder bin");
-
-  /* Register some quarks here for the stream topology message */
-  topology_structure_name = g_quark_from_static_string ("stream-topology");
-  topology_caps = g_quark_from_static_string ("caps");
-  topology_next = g_quark_from_static_string ("next");
-  topology_pad = g_quark_from_static_string ("pad");
-  topology_element_srcpad = g_quark_from_static_string ("element-srcpad");
-
-  return gst_element_register (plugin, "decodebin", GST_RANK_NONE,
-      GST_TYPE_DECODE_BIN);
-}
index 653aa94..b932903 100644 (file)
@@ -30,7 +30,7 @@
 #include <gst/gst.h>
 #include <gst/pbutils/pbutils.h>
 
-#include "gstplayback.h"
+#include "gstplaybackelements.h"
 #include "gstplay-enum.h"
 #include "gstrawcaps.h"
 
@@ -425,6 +425,11 @@ static guint gst_decodebin3_signals[LAST_SIGNAL] = { 0 };
 GType gst_decodebin3_get_type (void);
 #define gst_decodebin3_parent_class parent_class
 G_DEFINE_TYPE (GstDecodebin3, gst_decodebin3, GST_TYPE_BIN);
+#define _do_init \
+    GST_DEBUG_CATEGORY_INIT (decodebin3_debug, "decodebin3", 0, "decoder bin");\
+    ret |= playback_element_init (plugin);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (decodebin3, "decodebin3", GST_RANK_NONE,
+    GST_TYPE_DECODEBIN3, _do_init);
 
 static GstStaticCaps default_raw_caps = GST_STATIC_CAPS (DEFAULT_RAW_CAPS);
 
@@ -3011,12 +3016,3 @@ gst_decodebin3_change_state (GstElement * element, GstStateChange transition)
 beach:
   return ret;
 }
-
-gboolean
-gst_decodebin3_plugin_init (GstPlugin * plugin)
-{
-  GST_DEBUG_CATEGORY_INIT (decodebin3_debug, "decodebin3", 0, "decoder bin");
-
-  return gst_element_register (plugin, "decodebin3", GST_RANK_NONE,
-      GST_TYPE_DECODEBIN3);
-}
index 4f9f8b6..ab3b587 100644 (file)
 #include <gst/pbutils/pbutils.h>
 
 #include "gstplay-enum.h"
-#include "gstplayback.h"
+#include "gstplaybackelements.h"
 #include "gstplaybackutils.h"
 #include "gstrawcaps.h"
 
@@ -495,37 +495,16 @@ static GstPadProbeReturn pad_event_cb (GstPad * pad, GstPadProbeInfo * info,
  * Standard GObject boilerplate *
  ********************************/
 
-static void gst_parse_bin_class_init (GstParseBinClass * klass);
-static void gst_parse_bin_init (GstParseBin * parse_bin);
 static void gst_parse_bin_dispose (GObject * object);
 static void gst_parse_bin_finalize (GObject * object);
+static GType gst_parse_bin_get_type (void);
 
-static GType
-gst_parse_bin_get_type (void)
-{
-  static GType gst_parse_bin_type = 0;
-
-  if (!gst_parse_bin_type) {
-    static const GTypeInfo gst_parse_bin_info = {
-      sizeof (GstParseBinClass),
-      NULL,
-      NULL,
-      (GClassInitFunc) gst_parse_bin_class_init,
-      NULL,
-      NULL,
-      sizeof (GstParseBin),
-      0,
-      (GInstanceInitFunc) gst_parse_bin_init,
-      NULL
-    };
-
-    gst_parse_bin_type =
-        g_type_register_static (GST_TYPE_BIN, "GstParseBin",
-        &gst_parse_bin_info, 0);
-  }
-
-  return gst_parse_bin_type;
-}
+G_DEFINE_TYPE (GstParseBin, gst_parse_bin, GST_TYPE_BIN);
+#define _do_init \
+    GST_DEBUG_CATEGORY_INIT (gst_parse_bin_debug, "parsebin", 0, "parser bin");\
+    ret |= playback_element_init (plugin);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (parsebin, "parsebin", GST_RANK_NONE,
+    GST_TYPE_PARSE_BIN, _do_init);
 
 static gboolean
 _gst_boolean_accumulator (GSignalInvocationHint * ihint,
@@ -4399,12 +4378,3 @@ gst_parse_bin_handle_message (GstBin * bin, GstMessage * msg)
   else
     GST_BIN_CLASS (parent_class)->handle_message (bin, msg);
 }
-
-gboolean
-gst_parse_bin_plugin_init (GstPlugin * plugin)
-{
-  GST_DEBUG_CATEGORY_INIT (gst_parse_bin_debug, "parsebin", 0, "parser bin");
-
-  return gst_element_register (plugin, "parsebin", GST_RANK_NONE,
-      GST_TYPE_PARSE_BIN);
-}
similarity index 51%
rename from gst/playback/gstplayback.h
rename to gst/playback/gstplaybackelement.c
index 26e3683..7ac053b 100644 (file)
@@ -1,5 +1,7 @@
 /* GStreamer
  * Copyright (C) <2007> Wim Taymans <wim.taymans@gmail.com>
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd.
+ *
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
  * Boston, MA 02110-1301, USA.
  */
+/**
+ * SECTION:plugin-playback:
+ * @short_description: Set of elements to create dynamic pipelines (or part of it) to play
+ * media files.
+ */
 
-#ifndef __GST_PLAY_BACK_H__
-#define __GST_PLAY_BACK_H__
-
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
 #include <gst/gst.h>
 
-gboolean gst_decode_bin_plugin_init (GstPlugin * plugin);
-gboolean gst_decodebin3_plugin_init (GstPlugin * plugin);
-gboolean gst_uri_decode_bin_plugin_init (GstPlugin * plugin);
-gboolean gst_uri_decode_bin3_plugin_init (GstPlugin * plugin);
-gboolean gst_uri_source_bin_plugin_init (GstPlugin * plugin);
-gboolean gst_parse_bin_plugin_init (GstPlugin * plugin);
+#include <gst/gst-i18n-plugin.h>
+#include <gst/pbutils/pbutils.h>
+
+#include "gstplaybackelements.h"
 
-gboolean gst_play_bin_plugin_init (GstPlugin * plugin);
-gboolean gst_play_bin2_plugin_init (GstPlugin * plugin);
-gboolean gst_play_bin3_plugin_init (GstPlugin * plugin, gboolean as_playbin);
 
+gboolean
+playback_element_init (GstPlugin * plugin)
+{
+  static gsize res = FALSE;
+  if (g_once_init_enter (&res)) {
+    gst_pb_utils_init ();
 
-#endif /* __GST_PLAY_BACK_H__ */
+#ifdef ENABLE_NLS
+    GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
+        LOCALEDIR);
+    bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif /* ENABLE_NLS */
+    g_once_init_leave (&res, TRUE);
+  }
+  return res;
+}
diff --git a/gst/playback/gstplaybackelements.h b/gst/playback/gstplaybackelements.h
new file mode 100644 (file)
index 0000000..e08608d
--- /dev/null
@@ -0,0 +1,44 @@
+/* GStreamer
+ * Copyright (C) <2007> Wim Taymans <wim.taymans@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_PLAY_BACK_ELEMENTS_H__
+#define __GST_PLAY_BACK_ELEMENTS_H__
+
+#include <gst/gst.h>
+
+GST_ELEMENT_REGISTER_DECLARE (playbin);
+GST_ELEMENT_REGISTER_DECLARE (playbin3);
+GST_ELEMENT_REGISTER_DECLARE (playsink);
+GST_ELEMENT_REGISTER_DECLARE (subtitleoverlay);
+GST_ELEMENT_REGISTER_DECLARE (streamsynchronizer);
+GST_ELEMENT_REGISTER_DECLARE (decodebin);
+GST_ELEMENT_REGISTER_DECLARE (decodebin3);
+GST_ELEMENT_REGISTER_DECLARE (uridecodebin);
+GST_ELEMENT_REGISTER_DECLARE (uridecodebin3);
+GST_ELEMENT_REGISTER_DECLARE (urisourcebin);
+GST_ELEMENT_REGISTER_DECLARE (parsebin);
+
+gboolean gst_play_bin_custom_element_init (GstPlugin * plugin);
+gboolean gst_play_bin3_custom_element_init (GstPlugin * plugin);
+
+G_GNUC_INTERNAL gboolean playback_element_init (GstPlugin * plugin);
+
+#endif /* __GST_PLAY_BACK_ELEMENTS_H__ */
similarity index 54%
rename from gst/playback/gstplayback.c
rename to gst/playback/gstplaybackplugin.c
index 248e9cd..95d438d 100644 (file)
 #include <gst/gst-i18n-plugin.h>
 #include <gst/pbutils/pbutils.h>
 
-#include "gstplayback.h"
-#include "gstplaysink.h"
-#include "gstsubtitleoverlay.h"
-#include "gststreamsynchronizer.h"
+#include "gstplaybackelements.h"
+
 
 static gboolean
 plugin_init (GstPlugin * plugin)
 {
-  gboolean res;
-
-  gst_pb_utils_init ();
-
-#ifdef ENABLE_NLS
-  GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
-      LOCALEDIR);
-  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
-  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-#endif /* ENABLE_NLS */
-
-  /* Swap in playbin3 as 'playbin' if USE_PLAYBIN3=1 */
-  {
-    const gchar *env = g_getenv ("USE_PLAYBIN3");
-    if (env && g_str_has_prefix (env, "1"))
-      res = gst_play_bin3_plugin_init (plugin, TRUE);
-    else
-      res = gst_play_bin2_plugin_init (plugin);
-  }
-
-  res &= gst_play_bin3_plugin_init (plugin, FALSE);
-  res &= gst_play_sink_plugin_init (plugin);
-  res &= gst_subtitle_overlay_plugin_init (plugin);
-  res &= gst_stream_synchronizer_plugin_init (plugin);
-
-  res &= gst_decode_bin_plugin_init (plugin);
-  res &= gst_decodebin3_plugin_init (plugin);
-  res &= gst_uri_decode_bin_plugin_init (plugin);
-  res &= gst_uri_decode_bin3_plugin_init (plugin);
-  res &= gst_uri_source_bin_plugin_init (plugin);
-  res &= gst_parse_bin_plugin_init (plugin);
+  gboolean res = FALSE;
+  if (!g_getenv ("USE_PLAYBIN3"))
+    res |= GST_ELEMENT_REGISTER (playbin, plugin);
+  res |= GST_ELEMENT_REGISTER (playbin3, plugin);
+  res |= GST_ELEMENT_REGISTER (playsink, plugin);
+  res |= GST_ELEMENT_REGISTER (subtitleoverlay, plugin);
+  res |= GST_ELEMENT_REGISTER (streamsynchronizer, plugin);
+  res |= GST_ELEMENT_REGISTER (decodebin, plugin);
+  res |= GST_ELEMENT_REGISTER (decodebin3, plugin);
+  res |= GST_ELEMENT_REGISTER (uridecodebin, plugin);
+  res |= GST_ELEMENT_REGISTER (uridecodebin3, plugin);
+  res |= GST_ELEMENT_REGISTER (urisourcebin, plugin);
+  res |= GST_ELEMENT_REGISTER (parsebin, plugin);
 
   return res;
 }
index a8d719f..c13bfa8 100644 (file)
 #include <gst/video/navigation.h>
 #include <gst/video/colorbalance.h>
 #include "gstplay-enum.h"
-#include "gstplayback.h"
+#include "gstplaybackelements.h"
 #include "gstplaysink.h"
 #include "gstsubtitleoverlay.h"
 #include "gstplaybackutils.h"
@@ -591,8 +591,6 @@ enum
 static GstStaticCaps raw_audio_caps = GST_STATIC_CAPS ("audio/x-raw(ANY)");
 static GstStaticCaps raw_video_caps = GST_STATIC_CAPS ("video/x-raw(ANY)");
 
-static void gst_play_bin_class_init (GstPlayBinClass * klass);
-static void gst_play_bin_init (GstPlayBin * playbin);
 static void gst_play_bin_finalize (GObject * object);
 
 static void gst_play_bin_set_property (GObject * object, guint prop_id,
@@ -655,57 +653,43 @@ static void gst_play_bin_navigation_init (gpointer g_iface,
 static void gst_play_bin_colorbalance_init (gpointer g_iface,
     gpointer g_iface_data);
 
-static GType
-gst_play_bin_get_type (void)
+static GType gst_play_bin_get_type (void);
+
+static void
+_do_init_type (GType type)
 {
-  static GType gst_play_bin_type = 0;
-
-  if (!gst_play_bin_type) {
-    static const GTypeInfo gst_play_bin_info = {
-      sizeof (GstPlayBinClass),
-      NULL,
-      NULL,
-      (GClassInitFunc) gst_play_bin_class_init,
-      NULL,
-      NULL,
-      sizeof (GstPlayBin),
-      0,
-      (GInstanceInitFunc) gst_play_bin_init,
-      NULL
-    };
-    static const GInterfaceInfo svol_info = {
-      NULL, NULL, NULL
-    };
-    static const GInterfaceInfo ov_info = {
-      gst_play_bin_overlay_init,
-      NULL, NULL
-    };
-    static const GInterfaceInfo nav_info = {
-      gst_play_bin_navigation_init,
-      NULL, NULL
-    };
-    static const GInterfaceInfo col_info = {
-      gst_play_bin_colorbalance_init,
-      NULL, NULL
-    };
-
-    gst_play_bin_type = g_type_register_static (GST_TYPE_PIPELINE,
-        "GstPlayBin", &gst_play_bin_info, 0);
-
-    g_type_add_interface_static (gst_play_bin_type, GST_TYPE_STREAM_VOLUME,
-        &svol_info);
-    g_type_add_interface_static (gst_play_bin_type, GST_TYPE_VIDEO_OVERLAY,
-        &ov_info);
-    g_type_add_interface_static (gst_play_bin_type, GST_TYPE_NAVIGATION,
-        &nav_info);
-    g_type_add_interface_static (gst_play_bin_type, GST_TYPE_COLOR_BALANCE,
-        &col_info);
-  }
-
-  return gst_play_bin_type;
+
+  static const GInterfaceInfo svol_info = {
+    NULL, NULL, NULL
+  };
+  static const GInterfaceInfo ov_info = {
+    gst_play_bin_overlay_init,
+    NULL, NULL
+  };
+  static const GInterfaceInfo nav_info = {
+    gst_play_bin_navigation_init,
+    NULL, NULL
+  };
+  static const GInterfaceInfo col_info = {
+    gst_play_bin_colorbalance_init,
+    NULL, NULL
+  };
+
+  g_type_add_interface_static (type, GST_TYPE_STREAM_VOLUME, &svol_info);
+  g_type_add_interface_static (type, GST_TYPE_VIDEO_OVERLAY, &ov_info);
+  g_type_add_interface_static (type, GST_TYPE_NAVIGATION, &nav_info);
+  g_type_add_interface_static (type, GST_TYPE_COLOR_BALANCE, &col_info);
 }
 
-static void
+G_DEFINE_TYPE_WITH_CODE (GstPlayBin, gst_play_bin, GST_TYPE_PIPELINE,
+    _do_init_type (g_define_type_id));
+#define _do_init \
+    GST_DEBUG_CATEGORY_INIT (gst_play_bin_debug, "playbin", 0, "play bin");\
+    ret |= playback_element_init (plugin);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (playbin, "playbin", GST_RANK_NONE,
+    GST_TYPE_PLAY_BIN, _do_init);
+
+void
 gst_play_bin_class_init (GstPlayBinClass * klass)
 {
   GObjectClass *gobject_klass;
@@ -6091,12 +6075,3 @@ gst_play_bin_colorbalance_init (gpointer g_iface, gpointer g_iface_data)
   iface->get_value = gst_play_bin_colorbalance_get_value;
   iface->get_balance_type = gst_play_bin_colorbalance_get_balance_type;
 }
-
-gboolean
-gst_play_bin2_plugin_init (GstPlugin * plugin)
-{
-  GST_DEBUG_CATEGORY_INIT (gst_play_bin_debug, "playbin", 0, "play bin");
-
-  return gst_element_register (plugin, "playbin", GST_RANK_NONE,
-      GST_TYPE_PLAY_BIN);
-}
index 323dc1f..753e12d 100644 (file)
 #include <gst/video/navigation.h>
 #include <gst/video/colorbalance.h>
 #include "gstplay-enum.h"
-#include "gstplayback.h"
+#include "gstplaybackelements.h"
 #include "gstplaysink.h"
 #include "gstsubtitleoverlay.h"
 #include "gstplaybackutils.h"
@@ -601,8 +601,6 @@ static GstStaticCaps raw_audio_caps = GST_STATIC_CAPS ("audio/x-raw(ANY)");
 static GstStaticCaps raw_video_caps = GST_STATIC_CAPS ("video/x-raw(ANY)");
 #endif
 
-static void gst_play_bin3_class_init (GstPlayBin3Class * klass);
-static void gst_play_bin3_init (GstPlayBin3 * playbin);
 static void gst_play_bin3_finalize (GObject * object);
 
 static void gst_play_bin3_set_property (GObject * object, guint prop_id,
@@ -653,56 +651,38 @@ static void gst_play_bin3_navigation_init (gpointer g_iface,
 static void gst_play_bin3_colorbalance_init (gpointer g_iface,
     gpointer g_iface_data);
 
-static GType
-gst_play_bin3_get_type (void)
+static void
+_do_init_type (GType type)
 {
-  static GType gst_play_bin3_type = 0;
-
-  if (!gst_play_bin3_type) {
-    static const GTypeInfo gst_play_bin3_info = {
-      sizeof (GstPlayBin3Class),
-      NULL,
-      NULL,
-      (GClassInitFunc) gst_play_bin3_class_init,
-      NULL,
-      NULL,
-      sizeof (GstPlayBin3),
-      0,
-      (GInstanceInitFunc) gst_play_bin3_init,
-      NULL
-    };
-    static const GInterfaceInfo svol_info = {
-      NULL, NULL, NULL
-    };
-    static const GInterfaceInfo ov_info = {
-      gst_play_bin3_overlay_init,
-      NULL, NULL
-    };
-    static const GInterfaceInfo nav_info = {
-      gst_play_bin3_navigation_init,
-      NULL, NULL
-    };
-    static const GInterfaceInfo col_info = {
-      gst_play_bin3_colorbalance_init,
-      NULL, NULL
-    };
-
-    gst_play_bin3_type = g_type_register_static (GST_TYPE_PIPELINE,
-        "GstPlayBin3", &gst_play_bin3_info, 0);
-
-    g_type_add_interface_static (gst_play_bin3_type, GST_TYPE_STREAM_VOLUME,
-        &svol_info);
-    g_type_add_interface_static (gst_play_bin3_type, GST_TYPE_VIDEO_OVERLAY,
-        &ov_info);
-    g_type_add_interface_static (gst_play_bin3_type, GST_TYPE_NAVIGATION,
-        &nav_info);
-    g_type_add_interface_static (gst_play_bin3_type, GST_TYPE_COLOR_BALANCE,
-        &col_info);
-  }
-
-  return gst_play_bin3_type;
+  static const GInterfaceInfo svol_info = {
+    NULL, NULL, NULL
+  };
+  static const GInterfaceInfo ov_info = {
+    gst_play_bin3_overlay_init,
+    NULL, NULL
+  };
+  static const GInterfaceInfo nav_info = {
+    gst_play_bin3_navigation_init,
+    NULL, NULL
+  };
+  static const GInterfaceInfo col_info = {
+    gst_play_bin3_colorbalance_init,
+    NULL, NULL
+  };
+
+  g_type_add_interface_static (type, GST_TYPE_STREAM_VOLUME, &svol_info);
+  g_type_add_interface_static (type, GST_TYPE_VIDEO_OVERLAY, &ov_info);
+  g_type_add_interface_static (type, GST_TYPE_NAVIGATION, &nav_info);
+  g_type_add_interface_static (type, GST_TYPE_COLOR_BALANCE, &col_info);
 }
 
+static GType gst_play_bin3_get_type (void);
+G_DEFINE_TYPE_WITH_CODE (GstPlayBin3, gst_play_bin3, GST_TYPE_PIPELINE,
+    _do_init_type (g_define_type_id));
+
+GST_ELEMENT_REGISTER_DEFINE_CUSTOM (playbin3,
+    gst_play_bin3_custom_element_init);
+
 static void
 gst_play_bin3_class_init (GstPlayBin3Class * klass)
 {
@@ -5168,14 +5148,20 @@ gst_play_bin3_colorbalance_init (gpointer g_iface, gpointer g_iface_data)
 }
 
 gboolean
-gst_play_bin3_plugin_init (GstPlugin * plugin, gboolean as_playbin)
+gst_play_bin3_custom_element_init (GstPlugin * plugin)
 {
-  GST_DEBUG_CATEGORY_INIT (gst_play_bin3_debug, "playbin3", 0, "play bin");
+  gboolean ret = TRUE;
 
-  if (as_playbin)
-    return gst_element_register (plugin, "playbin", GST_RANK_NONE,
+  GST_DEBUG_CATEGORY_INIT (gst_play_bin3_debug, "playbin3", 0, "play bin3");
+
+  ret &= playback_element_init (plugin);
+
+  if (g_getenv ("USE_PLAYBIN3"))
+    ret &= gst_element_register (plugin, "playbin", GST_RANK_NONE,
+        GST_TYPE_PLAY_BIN);
+  else
+    ret &= gst_element_register (plugin, "playbin3", GST_RANK_NONE,
         GST_TYPE_PLAY_BIN);
 
-  return gst_element_register (plugin, "playbin3", GST_RANK_NONE,
-      GST_TYPE_PLAY_BIN);
+  return ret;
 }
index e626fcf..c53a5f1 100644 (file)
@@ -33,6 +33,7 @@
 #include <gst/video/videooverlay.h>
 #include <gst/video/navigation.h>
 
+#include "gstplaybackelements.h"
 #include "gstplaysink.h"
 #include "gststreamsynchronizer.h"
 #include "gstplaysinkvideoconvert.h"
@@ -412,7 +413,7 @@ static void gst_play_sink_colorbalance_init (gpointer g_iface,
     gpointer g_iface_data);
 
 static void
-_do_init (GType type)
+_do_init_type (GType type)
 {
   static const GInterfaceInfo svol_info = {
     NULL, NULL, NULL
@@ -437,7 +438,13 @@ _do_init (GType type)
 }
 
 G_DEFINE_TYPE_WITH_CODE (GstPlaySink, gst_play_sink, GST_TYPE_BIN,
-    _do_init (g_define_type_id));
+    _do_init_type (g_define_type_id));
+#define _do_init \
+    GST_DEBUG_CATEGORY_INIT (gst_play_sink_debug, "playsink", 0, "play sink");\
+    ret |= playback_element_init (plugin);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (playsink, "playsink", GST_RANK_NONE,
+    GST_TYPE_PLAY_SINK, _do_init);
+
 
 static void
 gst_play_sink_class_init (GstPlaySinkClass * klass)
@@ -5521,11 +5528,3 @@ gst_play_sink_colorbalance_init (gpointer g_iface, gpointer g_iface_data)
   iface->get_value = gst_play_sink_colorbalance_get_value;
   iface->get_balance_type = gst_play_sink_colorbalance_get_balance_type;
 }
-
-gboolean
-gst_play_sink_plugin_init (GstPlugin * plugin)
-{
-  GST_DEBUG_CATEGORY_INIT (gst_play_sink_debug, "playsink", 0, "play bin");
-  return gst_element_register (plugin, "playsink", GST_RANK_NONE,
-      GST_TYPE_PLAY_SINK);
-}
index fa19d9d..b3a3d8f 100644 (file)
@@ -101,8 +101,6 @@ GstSample *      gst_play_sink_convert_sample  (GstPlaySink * playsink, GstCaps
 
 gboolean         gst_play_sink_reconfigure    (GstPlaySink * playsink);
 
-gboolean         gst_play_sink_plugin_init    (GstPlugin * plugin);
-
 G_END_DECLS
 
 #endif /* __GST_PLAY_SINK_H__ */
index 41836f7..082e8b0 100644 (file)
@@ -21,6 +21,7 @@
 #include "config.h"
 #endif
 
+#include "gstplaybackelements.h"
 #include "gststreamsynchronizer.h"
 
 GST_DEBUG_CATEGORY_STATIC (stream_synchronizer_debug);
@@ -55,6 +56,10 @@ static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink_%u",
 #define gst_stream_synchronizer_parent_class parent_class
 G_DEFINE_TYPE (GstStreamSynchronizer, gst_stream_synchronizer,
     GST_TYPE_ELEMENT);
+#define _do_init \
+    ret |= playback_element_init (plugin);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (streamsynchronizer, "streamsynchronizer",
+    GST_RANK_NONE, GST_TYPE_STREAM_SYNCHRONIZER, _do_init);
 
 typedef struct
 {
@@ -1193,14 +1198,7 @@ gst_stream_synchronizer_class_init (GstStreamSynchronizerClass * klass)
       GST_DEBUG_FUNCPTR (gst_stream_synchronizer_request_new_pad);
   element_class->release_pad =
       GST_DEBUG_FUNCPTR (gst_stream_synchronizer_release_pad);
-}
 
-gboolean
-gst_stream_synchronizer_plugin_init (GstPlugin * plugin)
-{
   GST_DEBUG_CATEGORY_INIT (stream_synchronizer_debug,
       "streamsynchronizer", 0, "Stream Synchronizer");
-
-  return gst_element_register (plugin, "streamsynchronizer", GST_RANK_NONE,
-      GST_TYPE_STREAM_SYNCHRONIZER);
 }
index e6310be..2df9e0d 100644 (file)
@@ -66,8 +66,6 @@ struct _GstStreamSynchronizerClass
 
 GType gst_stream_synchronizer_get_type (void);
 
-gboolean gst_stream_synchronizer_plugin_init (GstPlugin * plugin);
-
 G_END_DECLS
 
 #endif /* __GST_STREAM_SYNCHRONIZER_H__ */
index 6420b76..8e19fca 100644 (file)
@@ -39,6 +39,7 @@
 #include "config.h"
 #endif
 
+#include "gstplaybackelements.h"
 #include "gstsubtitleoverlay.h"
 
 #include <gst/pbutils/missing-plugins.h>
@@ -85,6 +86,13 @@ G_DEFINE_TYPE (GstSubtitleOverlay, gst_subtitle_overlay, GST_TYPE_BIN);
 
 static GQuark _subtitle_overlay_event_marker_id = 0;
 
+#define _do_init \
+    GST_DEBUG_CATEGORY_INIT (subtitle_overlay_debug, "subtitleoverlay", 0, "Subtitle Overlay"); \
+    ret |= playback_element_init (plugin); \
+    _subtitle_overlay_event_marker_id = g_quark_from_static_string ("gst-subtitle-overlay-event-marker")
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (subtitleoverlay, "subtitleoverlay",
+    GST_RANK_NONE, GST_TYPE_SUBTITLE_OVERLAY, _do_init);
+
 static void
 do_async_start (GstSubtitleOverlay * self)
 {
@@ -2106,16 +2114,3 @@ gst_subtitle_overlay_init (GstSubtitleOverlay * self)
   self->fps_n = 0;
   self->fps_d = 0;
 }
-
-gboolean
-gst_subtitle_overlay_plugin_init (GstPlugin * plugin)
-{
-  GST_DEBUG_CATEGORY_INIT (subtitle_overlay_debug, "subtitleoverlay", 0,
-      "Subtitle Overlay");
-
-  _subtitle_overlay_event_marker_id =
-      g_quark_from_static_string ("gst-subtitle-overlay-event-marker");
-
-  return gst_element_register (plugin, "subtitleoverlay", GST_RANK_NONE,
-      GST_TYPE_SUBTITLE_OVERLAY);
-}
index 53c10c4..22a04ff 100644 (file)
@@ -112,7 +112,6 @@ struct _GstSubtitleOverlayClass
 };
 
 GType gst_subtitle_overlay_get_type (void);
-gboolean gst_subtitle_overlay_plugin_init (GstPlugin * plugin);
 
 GstCaps *gst_subtitle_overlay_create_factory_caps (void);
 
index aed3ab7..4807df1 100644 (file)
@@ -41,7 +41,7 @@
 
 #include "gstplay-enum.h"
 #include "gstrawcaps.h"
-#include "gstplayback.h"
+#include "gstplaybackelements.h"
 #include "gstplaybackutils.h"
 
 #define GST_TYPE_URI_DECODE_BIN \
@@ -208,6 +208,12 @@ GType gst_uri_decode_bin_get_type (void);
 #define gst_uri_decode_bin_parent_class parent_class
 G_DEFINE_TYPE (GstURIDecodeBin, gst_uri_decode_bin, GST_TYPE_BIN);
 
+#define _do_init \
+    GST_DEBUG_CATEGORY_INIT (gst_uri_decode_bin_debug, "uridecodebin", 0, "URI decoder element"); \
+    ret |= playback_element_init (plugin);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (uridecodebin, "uridecodebin",
+    GST_RANK_NONE, GST_TYPE_URI_DECODE_BIN, _do_init);
+
 static void remove_decoders (GstURIDecodeBin * bin, gboolean force);
 static void gst_uri_decode_bin_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
@@ -2924,13 +2930,3 @@ setup_failed:
     return GST_STATE_CHANGE_FAILURE;
   }
 }
-
-gboolean
-gst_uri_decode_bin_plugin_init (GstPlugin * plugin)
-{
-  GST_DEBUG_CATEGORY_INIT (gst_uri_decode_bin_debug, "uridecodebin", 0,
-      "URI decoder element");
-
-  return gst_element_register (plugin, "uridecodebin", GST_RANK_NONE,
-      GST_TYPE_URI_DECODE_BIN);
-}
index 295ba45..6d0d779 100644 (file)
@@ -55,7 +55,7 @@
 
 #include "gstplay-enum.h"
 #include "gstrawcaps.h"
-#include "gstplayback.h"
+#include "gstplaybackelements.h"
 #include "gstplaybackutils.h"
 
 #define GST_TYPE_URI_DECODE_BIN3 \
@@ -329,6 +329,12 @@ GType gst_uri_decode_bin3_get_type (void);
 #define gst_uri_decode_bin3_parent_class parent_class
 G_DEFINE_TYPE (GstURIDecodeBin3, gst_uri_decode_bin3, GST_TYPE_BIN);
 
+#define _do_init \
+    GST_DEBUG_CATEGORY_INIT (gst_uri_decode_bin3_debug, "uridecodebin3", 0, "URI decoder element 3"); \
+    ret |= playback_element_init (plugin);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (uridecodebin3, "uridecodebin3",
+    GST_RANK_NONE, GST_TYPE_URI_DECODE_BIN3, _do_init);
+
 #define REMOVE_SIGNAL(obj,id)            \
 if (id) {                                \
   g_signal_handler_disconnect (obj, id); \
@@ -1144,13 +1150,3 @@ gst_uri_decodebin3_send_event (GstElement * element, GstEvent * event)
 
   return GST_ELEMENT_CLASS (parent_class)->send_event (element, event);
 }
-
-gboolean
-gst_uri_decode_bin3_plugin_init (GstPlugin * plugin)
-{
-  GST_DEBUG_CATEGORY_INIT (gst_uri_decode_bin3_debug, "uridecodebin3", 0,
-      "URI decoder element 3");
-
-  return gst_element_register (plugin, "uridecodebin3", GST_RANK_NONE,
-      GST_TYPE_URI_DECODE_BIN3);
-}
index b8100d2..89275e5 100644 (file)
@@ -50,7 +50,7 @@
 
 #include "gstplay-enum.h"
 #include "gstrawcaps.h"
-#include "gstplayback.h"
+#include "gstplaybackelements.h"
 #include "gstplaybackutils.h"
 
 #define GST_TYPE_URI_SOURCE_BIN \
@@ -256,6 +256,12 @@ GType gst_uri_source_bin_get_type (void);
 #define gst_uri_source_bin_parent_class parent_class
 G_DEFINE_TYPE (GstURISourceBin, gst_uri_source_bin, GST_TYPE_BIN);
 
+#define _do_init \
+    GST_DEBUG_CATEGORY_INIT (gst_uri_source_bin_debug, "urisourcebin", 0, "URI source element"); \
+    ret |= playback_element_init (plugin);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (urisourcebin, "urisourcebin",
+    GST_RANK_NONE, GST_TYPE_URI_SOURCE_BIN, _do_init);
+
 static void gst_uri_source_bin_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
 static void gst_uri_source_bin_get_property (GObject * object, guint prop_id,
@@ -2853,13 +2859,3 @@ setup_failed:
     return GST_STATE_CHANGE_FAILURE;
   }
 }
-
-gboolean
-gst_uri_source_bin_plugin_init (GstPlugin * plugin)
-{
-  GST_DEBUG_CATEGORY_INIT (gst_uri_source_bin_debug, "urisourcebin", 0,
-      "URI source element");
-
-  return gst_element_register (plugin, "urisourcebin", GST_RANK_NONE,
-      GST_TYPE_URI_SOURCE_BIN);
-}
index babcb6e..1ad770d 100644 (file)
@@ -5,7 +5,8 @@ playback_sources = [
   'gsturidecodebin3.c',
   'gsturisourcebin.c',
   'gstparsebin.c',
-  'gstplayback.c',
+  'gstplaybackplugin.c',
+  'gstplaybackelement.c',
   'gstplaybackutils.c',
   'gstplaybin2.c',
   'gstplaybin3.c',