plugins-sys: allow per feature registration
authorStéphane Cerveau <scerveau@collabora.com>
Fri, 26 Mar 2021 10:00:50 +0000 (11:00 +0100)
committerOlivier Crête <olivier.crete@ocrete.ca>
Fri, 9 Apr 2021 19:23:40 +0000 (19:23 +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/2116>

66 files changed:
sys/bluez/bluez-plugin.c
sys/bluez/gsta2dpsink.c
sys/bluez/gsta2dpsink.h
sys/bluez/gstavdtpsink.c
sys/bluez/gstavdtpsink.h
sys/bluez/gstavdtpsrc.c
sys/bluez/gstavdtpsrc.h
sys/bluez/gstbluezelement.c [new file with mode: 0644]
sys/bluez/gstbluezelements.h [new file with mode: 0644]
sys/bluez/meson.build
sys/decklink/gstdecklink.cpp
sys/decklink/gstdecklink.h
sys/decklink/gstdecklinkaudiosink.cpp
sys/decklink/gstdecklinkaudiosink.h
sys/decklink/gstdecklinkaudiosrc.cpp
sys/decklink/gstdecklinkaudiosrc.h
sys/decklink/gstdecklinkdeviceprovider.cpp
sys/decklink/gstdecklinkdeviceprovider.h
sys/decklink/gstdecklinkplugin.cpp [new file with mode: 0644]
sys/decklink/gstdecklinkvideosink.cpp
sys/decklink/gstdecklinkvideosink.h
sys/decklink/gstdecklinkvideosrc.cpp
sys/decklink/gstdecklinkvideosrc.h
sys/decklink/meson.build
sys/dvb/dvbbasebin.c
sys/dvb/dvbbasebin.h
sys/dvb/gstdvb.c
sys/dvb/gstdvbelement.c [new file with mode: 0644]
sys/dvb/gstdvbelements.h [new file with mode: 0644]
sys/dvb/gstdvbsrc.c
sys/dvb/gstdvbsrc.h
sys/dvb/meson.build
sys/fbdev/gstfbdevsink.c
sys/fbdev/gstfbdevsink.h
sys/ipcpipeline/gstipcpipeline.c
sys/ipcpipeline/gstipcpipelineelement.c [new file with mode: 0644]
sys/ipcpipeline/gstipcpipelineelements.h [new file with mode: 0644]
sys/ipcpipeline/gstipcpipelinesink.c
sys/ipcpipeline/gstipcpipelinesrc.c
sys/ipcpipeline/gstipcslavepipeline.c
sys/ipcpipeline/meson.build
sys/kms/gstkmssink.c
sys/kms/gstkmssink.h
sys/magicleap/mlaudiosink.c
sys/magicleap/mlaudiosink.h
sys/magicleap/plugin.c
sys/opensles/meson.build
sys/opensles/opensles.c
sys/opensles/opensles.h
sys/opensles/openslesplugin.c [new file with mode: 0644]
sys/opensles/openslessink.c
sys/opensles/openslessink.h
sys/opensles/openslessrc.c
sys/opensles/openslessrc.h
sys/shm/gstshm.c
sys/shm/gstshmsink.c
sys/shm/gstshmsink.h
sys/shm/gstshmsrc.c
sys/shm/gstshmsrc.h
sys/uvch264/gstuvch264.c
sys/uvch264/gstuvch264_mjpgdemux.c
sys/uvch264/gstuvch264_mjpgdemux.h
sys/uvch264/gstuvch264_src.c
sys/uvch264/gstuvch264_src.h
sys/uvch264/gstuvch264deviceprovider.c
sys/uvch264/gstuvch264deviceprovider.h

index 3e96977..afa16b0 100644 (file)
 #include <config.h>
 #endif
 
+#include "gstbluezelements.h"
 #include "gsta2dpsink.h"
 #include "gstavdtpsink.h"
 #include "gstavdtpsrc.h"
 #include <string.h>
 
-GST_DEBUG_CATEGORY (avdtp_debug);
 
 static gboolean
 plugin_init (GstPlugin * plugin)
 {
-  GST_DEBUG_CATEGORY_INIT (avdtp_debug, "avdtp", 0, "avdtp utils");
+  gboolean ret = FALSE;
 
-  gst_element_register (plugin, "a2dpsink", GST_RANK_NONE, GST_TYPE_A2DP_SINK);
+  ret |= GST_ELEMENT_REGISTER (a2dpsink, plugin);
+  ret |= GST_ELEMENT_REGISTER (avdtpsink, plugin);
+  ret |= GST_ELEMENT_REGISTER (avdtpsrc, plugin);
 
-  gst_element_register (plugin, "avdtpsink",
-      GST_RANK_NONE, GST_TYPE_AVDTP_SINK);
-
-  gst_element_register (plugin, "avdtpsrc", GST_RANK_NONE, GST_TYPE_AVDTP_SRC);
-
-  return TRUE;
+  return ret;
 }
 
 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
index 2053372..f81e944 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <unistd.h>
 
+#include "gstbluezelements.h"
 #include "gsta2dpsink.h"
 
 #include <gst/rtp/gstrtpbasepayload.h>
@@ -48,6 +49,8 @@ enum
 
 #define parent_class gst_a2dp_sink_parent_class
 G_DEFINE_TYPE (GstA2dpSink, gst_a2dp_sink, GST_TYPE_BIN);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (a2dpsink, "a2dpsink", GST_RANK_NONE,
+    GST_TYPE_A2DP_SINK, bluez_element_init (plugin));
 
 static GstStaticPadTemplate gst_a2dp_sink_factory =
     GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
index bbfe87b..95002be 100644 (file)
@@ -66,8 +66,6 @@ struct _GstA2dpSinkClass
 
 GType gst_a2dp_sink_get_type (void);
 
-gboolean gst_a2dp_sink_plugin_init (GstPlugin * plugin);
-
 GstCaps *gst_a2dp_sink_get_device_caps (GstA2dpSink * self);
 
 G_END_DECLS
index dc909aa..9cf5d1b 100644 (file)
@@ -36,6 +36,7 @@
 
 #include "a2dp-codecs.h"
 
+#include "gstbluezelements.h"
 #include "gstavdtpsink.h"
 
 #include <gst/rtp/rtp.h>
@@ -69,6 +70,8 @@ enum
 
 #define parent_class gst_avdtp_sink_parent_class
 G_DEFINE_TYPE (GstAvdtpSink, gst_avdtp_sink, GST_TYPE_BASE_SINK);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (avdtpsink, "avdtpsink", GST_RANK_NONE,
+    GST_TYPE_AVDTP_SINK, bluez_element_init (plugin));
 
 static GstStaticPadTemplate avdtp_sink_factory =
     GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
@@ -410,14 +413,6 @@ gst_avdtp_sink_init (GstAvdtpSink * self)
    */
 }
 
-gboolean
-gst_avdtp_sink_plugin_init (GstPlugin * plugin)
-{
-  return gst_element_register (plugin, "avdtpsink", GST_RANK_NONE,
-      GST_TYPE_AVDTP_SINK);
-}
-
-
 /* public functions */
 GstCaps *
 gst_avdtp_sink_get_device_caps (GstAvdtpSink * sink)
index c6b60b7..7d17e42 100644 (file)
@@ -86,8 +86,6 @@ gchar *gst_avdtp_sink_get_device (GstAvdtpSink * sink);
 
 gchar *gst_avdtp_sink_get_transport (GstAvdtpSink * sink);
 
-gboolean gst_avdtp_sink_plugin_init (GstPlugin * plugin);
-
 void gst_avdtp_sink_set_crc (GstAvdtpSink * self, gboolean crc);
 
 void gst_avdtp_sink_set_channel_mode (GstAvdtpSink * self, const gchar * mode);
index 5013230..40d1f9b 100644 (file)
@@ -31,6 +31,7 @@
 #include <poll.h>
 
 #include <gst/rtp/gstrtppayloads.h>
+#include "gstbluezelements.h"
 #include "gstavdtpsrc.h"
 
 GST_DEBUG_CATEGORY_STATIC (avdtpsrc_debug);
@@ -47,6 +48,8 @@ enum
 
 #define parent_class gst_avdtp_src_parent_class
 G_DEFINE_TYPE (GstAvdtpSrc, gst_avdtp_src, GST_TYPE_BASE_SRC);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (avdtpsrc, "avdtpsrc", GST_RANK_NONE,
+    GST_TYPE_AVDTP_SRC, bluez_element_init (plugin));
 
 static GstStaticPadTemplate gst_avdtp_src_template =
     GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
@@ -525,10 +528,3 @@ gst_avdtp_src_unlock_stop (GstBaseSrc * bsrc)
 
   return TRUE;
 }
-
-gboolean
-gst_avdtp_src_plugin_init (GstPlugin * plugin)
-{
-  return gst_element_register (plugin, "avdtpsrc", GST_RANK_NONE,
-      GST_TYPE_AVDTP_SRC);
-}
index 57e2649..aeafbff 100644 (file)
@@ -68,7 +68,5 @@ struct _GstAvdtpSrc
 
 GType gst_avdtp_src_get_type (void);
 
-gboolean gst_avdtp_src_plugin_init (GstPlugin * plugin);
-
 G_END_DECLS
 #endif
diff --git a/sys/bluez/gstbluezelement.c b/sys/bluez/gstbluezelement.c
new file mode 100644 (file)
index 0000000..143c36a
--- /dev/null
@@ -0,0 +1,38 @@
+/* GStreamer bluez plugin
+ *
+ * Copyright (C) 2013 Collabora Ltd. <tim.muller@collabora.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 "gstbluezelements.h"
+
+
+GST_DEBUG_CATEGORY (avdtp_debug);
+
+void
+bluez_element_init (GstPlugin * plugin)
+{
+  static gsize res = FALSE;
+  if (g_once_init_enter (&res)) {
+    GST_DEBUG_CATEGORY_INIT (avdtp_debug, "avdtp", 0, "avdtp utils");
+    g_once_init_leave (&res, TRUE);
+  }
+}
diff --git a/sys/bluez/gstbluezelements.h b/sys/bluez/gstbluezelements.h
new file mode 100644 (file)
index 0000000..a8ae92c
--- /dev/null
@@ -0,0 +1,36 @@
+/* GStreamer
+ * Copyright (C) <2020> Julian Bouzas <julian.bouzas@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_BLUEZ_ELEMENTS_H__
+#define __GST_BLUEZ_ELEMENTS_H__
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gst/gst.h>
+
+void bluez_element_init (GstPlugin * plugin);
+
+GST_ELEMENT_REGISTER_DECLARE (a2dpsink);
+GST_ELEMENT_REGISTER_DECLARE (avdtpsink);
+GST_ELEMENT_REGISTER_DECLARE (avdtpsrc);
+
+#endif /* __GST_BLUEZ_ELEMENTS_H__ */
index a53d5b8..769842d 100644 (file)
@@ -1,5 +1,6 @@
 bluez_sources = [
   'bluez-plugin.c',
+  'gstbluezelement.c',
   'gsta2dpsink.c',
   'gstavdtpsink.c',
   'gstavdtpsrc.c',
index 7916e8b..4534180 100644 (file)
@@ -1992,45 +1992,22 @@ gst_decklink_clock_get_internal_time (GstClock * clock)
   return result;
 }
 
-static gboolean
-plugin_init (GstPlugin * plugin)
+void
+decklink_element_init (GstPlugin * plugin)
 {
-  GST_DEBUG_CATEGORY_INIT (gst_decklink_debug, "decklink", 0,
-      "debug category for decklink plugin");
-
-  gst_element_register (plugin, "decklinkaudiosink", GST_RANK_NONE,
-      GST_TYPE_DECKLINK_AUDIO_SINK);
-  gst_element_register (plugin, "decklinkvideosink", GST_RANK_NONE,
-      GST_TYPE_DECKLINK_VIDEO_SINK);
-  gst_element_register (plugin, "decklinkaudiosrc", GST_RANK_NONE,
-      GST_TYPE_DECKLINK_AUDIO_SRC);
-  gst_element_register (plugin, "decklinkvideosrc", GST_RANK_NONE,
-      GST_TYPE_DECKLINK_VIDEO_SRC);
-
-  gst_device_provider_register (plugin, "decklinkdeviceprovider",
-      GST_RANK_PRIMARY, GST_TYPE_DECKLINK_DEVICE_PROVIDER);
-
-  gst_type_mark_as_plugin_api (GST_TYPE_DECKLINK_AUDIO_CHANNELS,
-      (GstPluginAPIFlags) 0);
-  gst_type_mark_as_plugin_api (GST_TYPE_DECKLINK_AUDIO_CONNECTION,
-      (GstPluginAPIFlags) 0);
-  gst_type_mark_as_plugin_api (GST_TYPE_DECKLINK_PROFILE_ID,
-      (GstPluginAPIFlags) 0);
-  gst_type_mark_as_plugin_api (GST_TYPE_DECKLINK_KEYER_MODE,
-      (GstPluginAPIFlags) 0);
-  gst_type_mark_as_plugin_api (GST_TYPE_DECKLINK_MODE, (GstPluginAPIFlags) 0);
-  gst_type_mark_as_plugin_api (GST_TYPE_DECKLINK_TIMECODE_FORMAT,
-      (GstPluginAPIFlags) 0);
-  gst_type_mark_as_plugin_api (GST_TYPE_DECKLINK_VIDEO_FORMAT,
-      (GstPluginAPIFlags) 0);
-  gst_type_mark_as_plugin_api (GST_TYPE_DECKLINK_CONNECTION,
-      (GstPluginAPIFlags) 0);
-
-  return TRUE;
+  static gsize res = FALSE;
+  if (g_once_init_enter (&res)) {
+    GST_DEBUG_CATEGORY_INIT (gst_decklink_debug, "decklink", 0,
+        "debug category for decklink plugin");
+    gst_type_mark_as_plugin_api (GST_TYPE_DECKLINK_AUDIO_CHANNELS, (GstPluginAPIFlags) 0);
+    gst_type_mark_as_plugin_api (GST_TYPE_DECKLINK_AUDIO_CONNECTION, (GstPluginAPIFlags) 0);
+    gst_type_mark_as_plugin_api (GST_TYPE_DECKLINK_PROFILE_ID, (GstPluginAPIFlags) 0);
+    gst_type_mark_as_plugin_api (GST_TYPE_DECKLINK_KEYER_MODE, (GstPluginAPIFlags) 0);
+    gst_type_mark_as_plugin_api (GST_TYPE_DECKLINK_MODE, (GstPluginAPIFlags) 0);
+    gst_type_mark_as_plugin_api (GST_TYPE_DECKLINK_TIMECODE_FORMAT, (GstPluginAPIFlags) 0);
+    gst_type_mark_as_plugin_api (GST_TYPE_DECKLINK_VIDEO_FORMAT, (GstPluginAPIFlags) 0);
+    gst_type_mark_as_plugin_api (GST_TYPE_DECKLINK_CONNECTION, (GstPluginAPIFlags) 0);
+
+    g_once_init_leave (&res, TRUE);
+  }
 }
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
-    GST_VERSION_MINOR,
-    decklink,
-    "Blackmagic Decklink plugin",
-    plugin_init, VERSION, "LGPL", PACKAGE_NAME, GST_PACKAGE_ORIGIN)
index 0e3e3d5..baa7879 100644 (file)
@@ -55,6 +55,8 @@
 #define WINAPI
 #endif /* G_OS_WIN32 */
 
+void decklink_element_init (GstPlugin * plugin);
+
 typedef enum {
   GST_DECKLINK_MODE_AUTO,
 
index 924caf1..65991ba 100644 (file)
@@ -101,6 +101,8 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
 #define parent_class gst_decklink_audio_sink_parent_class
 G_DEFINE_TYPE (GstDecklinkAudioSink, gst_decklink_audio_sink,
     GST_TYPE_BASE_SINK);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (decklinkaudiosink, "decklinkaudiosink", GST_RANK_NONE,
+    GST_TYPE_DECKLINK_AUDIO_SINK, decklink_element_init (plugin));
 
 static void
 gst_decklink_audio_sink_class_init (GstDecklinkAudioSinkClass * klass)
index 0394664..a9a94e7 100644 (file)
@@ -67,6 +67,8 @@ struct _GstDecklinkAudioSinkClass
 
 GType gst_decklink_audio_sink_get_type (void);
 
+GST_ELEMENT_REGISTER_DECLARE (decklinkaudiosink);
+
 G_END_DECLS
 
 #endif /* __GST_DECKLINK_AUDIO_SINK_H__ */
index 41e4f85..c0845cd 100644 (file)
@@ -140,6 +140,8 @@ static gboolean gst_decklink_audio_src_stop (GstDecklinkAudioSrc * self);
 
 #define parent_class gst_decklink_audio_src_parent_class
 G_DEFINE_TYPE (GstDecklinkAudioSrc, gst_decklink_audio_src, GST_TYPE_PUSH_SRC);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (decklinkaudiosrc, "decklinkaudiosrc", GST_RANK_NONE,
+    GST_TYPE_DECKLINK_AUDIO_SRC, decklink_element_init (plugin));
 
 static void
 gst_decklink_audio_src_class_init (GstDecklinkAudioSrcClass * klass)
index fdb77b6..bda4655 100644 (file)
@@ -94,6 +94,8 @@ struct _GstDecklinkAudioSrcClass
 
 GType gst_decklink_audio_src_get_type (void);
 
+GST_ELEMENT_REGISTER_DECLARE (decklinkaudiosrc);
+
 G_END_DECLS
 
 #endif /* __GST_DECKLINK_AUDIO_SRC_H__ */
index c884c42..3a98705 100644 (file)
@@ -26,6 +26,8 @@
 
 G_DEFINE_TYPE (GstDecklinkDeviceProvider, gst_decklink_device_provider,
     GST_TYPE_DEVICE_PROVIDER);
+GST_DEVICE_PROVIDER_REGISTER_DEFINE (decklinkdeviceprovider, "decklinkdeviceprovider",
+    GST_RANK_PRIMARY, GST_TYPE_DECKLINK_DEVICE_PROVIDER);
 
 static void
 gst_decklink_device_provider_init (GstDecklinkDeviceProvider * self)
index 0bd684d..5f79dfd 100644 (file)
@@ -41,6 +41,7 @@ struct _GstDecklinkDeviceProvider
 };
 
 GType gst_decklink_device_provider_get_type (void);
+GST_DEVICE_PROVIDER_REGISTER_DECLARE (decklinkdeviceprovider);
 
 G_END_DECLS
 
diff --git a/sys/decklink/gstdecklinkplugin.cpp b/sys/decklink/gstdecklinkplugin.cpp
new file mode 100644 (file)
index 0000000..7ba41a3
--- /dev/null
@@ -0,0 +1,52 @@
+/* GStreamer
+ * Copyright (C) 2011 David Schleef <ds@schleef.org>
+ * Copyright (C) 2014 Sebastian Dröge <sebastian@centricular.com>
+ * Copyright (C) 2015 Florian Langlois <florian.langlois@fr.thalesgroup.com>
+ * Copyright (C) 2020 Sohonet <dev@sohonet.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 Street, Suite 500,
+ * Boston, MA 02110-1335, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gst/gst.h>
+
+#include "gstdecklinkaudiosink.h"
+#include "gstdecklinkvideosink.h"
+#include "gstdecklinkaudiosrc.h"
+#include "gstdecklinkvideosrc.h"
+#include "gstdecklinkdeviceprovider.h"
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+  GST_ELEMENT_REGISTER (decklinkaudiosink, plugin);
+  GST_ELEMENT_REGISTER (decklinkvideosink, plugin);
+  GST_ELEMENT_REGISTER (decklinkaudiosrc, plugin);
+  GST_ELEMENT_REGISTER (decklinkvideosrc, plugin);
+
+  GST_DEVICE_PROVIDER_REGISTER (decklinkdeviceprovider, plugin);
+
+  return TRUE;
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+    GST_VERSION_MINOR,
+    decklink,
+    "Blackmagic Decklink plugin",
+    plugin_init, VERSION, "LGPL", PACKAGE_NAME, GST_PACKAGE_ORIGIN)
index 7e9b514..a64c046 100644 (file)
@@ -280,6 +280,8 @@ gst_decklink_video_sink_start_scheduled_playback (GstElement * element);
 #define parent_class gst_decklink_video_sink_parent_class
 G_DEFINE_TYPE (GstDecklinkVideoSink, gst_decklink_video_sink,
     GST_TYPE_BASE_SINK);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (decklinkvideosink, "decklinkvideosink", GST_RANK_NONE,
+                                       GST_TYPE_DECKLINK_VIDEO_SINK, decklink_element_init (plugin));
 
 static gboolean
 reset_framerate (GstCapsFeatures * features, GstStructure * structure,
index dffe3a7..555ec8e 100644 (file)
@@ -84,6 +84,8 @@ struct _GstDecklinkVideoSinkClass
 
 GType gst_decklink_video_sink_get_type (void);
 
+GST_ELEMENT_REGISTER_DECLARE (decklinkvideosink);
+
 void gst_decklink_video_sink_convert_to_internal_clock (GstDecklinkVideoSink * self,
     GstClockTime * timestamp, GstClockTime * duration);
 
index 40dc31d..41de397 100644 (file)
@@ -242,6 +242,8 @@ static void gst_decklink_video_src_start_streams (GstElement * element);
 
 #define parent_class gst_decklink_video_src_parent_class
 G_DEFINE_TYPE (GstDecklinkVideoSrc, gst_decklink_video_src, GST_TYPE_PUSH_SRC);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (decklinkvideosrc, "decklinkvideosrc", GST_RANK_NONE,
+    GST_TYPE_DECKLINK_VIDEO_SRC, decklink_element_init (plugin));
 
 static void
 gst_decklink_video_src_class_init (GstDecklinkVideoSrcClass * klass)
index 3213aa5..edd52d3 100644 (file)
@@ -124,6 +124,8 @@ struct _GstDecklinkVideoSrcClass
 
 GType gst_decklink_video_src_get_type (void);
 
+GST_ELEMENT_REGISTER_DECLARE (decklinkvideosrc);
+
 G_END_DECLS
 
 #endif /* __GST_DECKLINK_VIDEO_SRC_H__ */
index abffb63..d869e79 100644 (file)
@@ -1,4 +1,5 @@
 decklink_sources = [
+  'gstdecklinkplugin.cpp',
   'gstdecklink.cpp',
   'gstdecklinkaudiosink.cpp',
   'gstdecklinkvideosink.cpp',
index 6f74a09..3d2ba23 100644 (file)
@@ -30,6 +30,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <gst/mpegts/mpegts.h>
+#include "gstdvbelements.h"
 #include "dvbbasebin.h"
 #include "parsechannels.h"
 
@@ -169,7 +170,12 @@ G_DEFINE_TYPE_EXTENDED (DvbBaseBin, dvb_base_bin, GST_TYPE_BIN,
     0,
     G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER,
         dvb_base_bin_uri_handler_init));
-
+#define _do_init \
+  GST_DEBUG_CATEGORY_INIT (dvb_base_bin_debug, "dvbbasebin", 0, "DVB bin"); \
+  cam_init (); \
+  dvb_element_init (plugin);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (dvbbasebin, "dvbbasebin", GST_RANK_NONE,
+    GST_TYPE_DVB_BASE_BIN, _do_init);
 
 static void
 dvb_base_bin_ref_stream (DvbBaseBinStream * stream)
@@ -1216,16 +1222,6 @@ dvb_base_bin_uri_handler_init (gpointer g_iface, gpointer iface_data)
   iface->set_uri = dvb_base_bin_uri_set_uri;
 }
 
-gboolean
-gst_dvb_base_bin_plugin_init (GstPlugin * plugin)
-{
-  GST_DEBUG_CATEGORY_INIT (dvb_base_bin_debug, "dvbbasebin", 0, "DVB bin");
-
-  cam_init ();
-
-  return gst_element_register (plugin, "dvbbasebin",
-      GST_RANK_NONE, GST_TYPE_DVB_BASE_BIN);
-}
 
 static void
 dvb_base_bin_program_destroy (gpointer data)
index 96e6f83..29ba9c9 100644 (file)
@@ -75,7 +75,6 @@ struct _DvbBaseBinClass {
 };
 
 GType dvb_base_bin_get_type(void);
-gboolean gst_dvb_base_bin_plugin_init (GstPlugin *plugin);
 
 G_END_DECLS
 
index d3e8831..0ce6be4 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * gstdvb.c - 
  * Copyright (C) 2007 Alessandro Decina
 
 #include <gst/gst-i18n-plugin.h>
 
-#include "gstdvbsrc.h"
-#include "dvbbasebin.h"
+#include "gstdvbelements.h"
 
 static gboolean
 plugin_init (GstPlugin * plugin)
 {
-#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 */
-
-  if (!gst_dvbsrc_plugin_init (plugin))
-    return FALSE;
+  gboolean ret = FALSE;
 
-  if (!gst_dvb_base_bin_plugin_init (plugin))
-    return FALSE;
+  ret |= GST_ELEMENT_REGISTER (dvbsrc, plugin);
+  ret |= GST_ELEMENT_REGISTER (dvbbasebin, plugin);
 
-  return TRUE;
+  return ret;
 }
 
 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
diff --git a/sys/dvb/gstdvbelement.c b/sys/dvb/gstdvbelement.c
new file mode 100644 (file)
index 0000000..50f3931
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * gstdvb.c -
+ * Copyright (C) 2007 Alessandro Decina
+ *
+ * Authors:
+ *   Alessandro Decina <alessandro.d@gmail.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 <gst/gst-i18n-plugin.h>
+
+#include "gstdvbelements.h"
+
+void
+dvb_element_init (GstPlugin * plugin)
+{
+  static gsize res = FALSE;
+  if (g_once_init_enter (&res)) {
+#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);
+  }
+}
diff --git a/sys/dvb/gstdvbelements.h b/sys/dvb/gstdvbelements.h
new file mode 100644 (file)
index 0000000..4f8784b
--- /dev/null
@@ -0,0 +1,34 @@
+/* GStreamer
+ * Copyright (C) <2020> Julian Bouzas <julian.bouzas@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_DVB_ELEMENTS_H__
+#define __GST_DVB_ELEMENTS_H__
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gst/gst.h>
+
+void dvb_element_init (GstPlugin * plugin);
+GST_ELEMENT_REGISTER_DECLARE (dvbbasebin);
+GST_ELEMENT_REGISTER_DECLARE (dvbsrc);
+
+#endif /* __GST_DVB_ELEMENTS_H__ */
index ca6b92a..92c918c 100644 (file)
@@ -93,6 +93,7 @@
 #include "config.h"
 #endif
 
+#include "gstdvbelements.h"
 #include "gstdvbsrc.h"
 #include <gst/gst.h>
 #include <gst/glib-compat-private.h>
@@ -601,6 +602,11 @@ static GstStaticPadTemplate ts_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
 
 #define gst_dvbsrc_parent_class parent_class
 G_DEFINE_TYPE (GstDvbSrc, gst_dvbsrc, GST_TYPE_PUSH_SRC);
+#define _do_init \
+  GST_DEBUG_CATEGORY_INIT (gstdvbsrc_debug, "dvbsrc", 0, "DVB Source Element");\
+  dvb_element_init (plugin);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (dvbsrc, "dvbsrc", GST_RANK_NONE,
+    GST_TYPE_DVBSRC, _do_init);
 
 static guint gst_dvbsrc_signals[LAST_SIGNAL] = { 0 };
 
@@ -1859,14 +1865,6 @@ gst_dvbsrc_finalize (GObject * _object)
  * register the element factories and pad templates
  * register the features
  */
-gboolean
-gst_dvbsrc_plugin_init (GstPlugin * plugin)
-{
-  GST_DEBUG_CATEGORY_INIT (gstdvbsrc_debug, "dvbsrc", 0, "DVB Source Element");
-
-  return gst_element_register (plugin, "dvbsrc", GST_RANK_NONE,
-      GST_TYPE_DVBSRC);
-}
 
 static GstFlowReturn
 gst_dvbsrc_read_device (GstDvbSrc * object, int size, GstBuffer ** buffer)
index da6b5bc..249e4c3 100644 (file)
@@ -144,7 +144,6 @@ struct _GstDvbSrcClass
 
 
 GType gst_dvbsrc_get_type (void);
-gboolean gst_dvbsrc_plugin_init (GstPlugin * plugin);
 
 G_END_DECLS
 #endif /* __GST_DVBSRC_H__ */
index 7118fec..6a58f09 100644 (file)
@@ -11,6 +11,7 @@ dvb_sources = [
   'camutils.c',
   'dvbbasebin.c',
   'gstdvb.c',
+  'gstdvbelement.c',
   'gstdvbsrc.c',
   'parsechannels.c',
 ]
index 166c543..d70dd4b 100644 (file)
@@ -83,6 +83,8 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
 
 #define parent_class gst_fbdevsink_parent_class
 G_DEFINE_TYPE (GstFBDEVSink, gst_fbdevsink, GST_TYPE_VIDEO_SINK);
+GST_ELEMENT_REGISTER_DEFINE (fbdevsink, "fbdevsink", GST_RANK_NONE,
+    GST_TYPE_FBDEVSINK);
 
 static void
 gst_fbdevsink_init (GstFBDEVSink * fbdevsink)
@@ -394,11 +396,7 @@ gst_fbdevsink_change_state (GstElement * element, GstStateChange transition)
 static gboolean
 plugin_init (GstPlugin * plugin)
 {
-  if (!gst_element_register (plugin, "fbdevsink", GST_RANK_NONE,
-          GST_TYPE_FBDEVSINK))
-    return FALSE;
-
-  return TRUE;
+  return GST_ELEMENT_REGISTER (fbdevsink, plugin);
 }
 
 static void
index 7998217..6ab9bd0 100644 (file)
@@ -67,6 +67,7 @@ struct _GstFBDEVSinkClass {
 };
 
 GType gst_fbdevsink_get_type(void);
+GST_ELEMENT_REGISTER_DECLARE (fbdevsink);
 
 G_END_DECLS
 
index 4d647d4..5b2f5c5 100644 (file)
 #include "config.h"
 #endif
 
-#include "gstipcpipelinecomm.h"
-#include "gstipcpipelinesink.h"
-#include "gstipcpipelinesrc.h"
-#include "gstipcslavepipeline.h"
+#include "gstipcpipelineelements.h"
+
 
 static gboolean
 plugin_init (GstPlugin * plugin)
 {
-  gst_ipc_pipeline_comm_plugin_init ();
-  gst_element_register (plugin, "ipcpipelinesrc", GST_RANK_NONE,
-      GST_TYPE_IPC_PIPELINE_SRC);
-  gst_element_register (plugin, "ipcpipelinesink", GST_RANK_NONE,
-      GST_TYPE_IPC_PIPELINE_SINK);
-  gst_element_register (plugin, "ipcslavepipeline", GST_RANK_NONE,
-      GST_TYPE_IPC_SLAVE_PIPELINE);
+  GST_ELEMENT_REGISTER (ipcpipelinesrc, plugin);
+  GST_ELEMENT_REGISTER (ipcpipelinesink, plugin);
+  GST_ELEMENT_REGISTER (ipcslavepipeline, plugin);
 
   return TRUE;
 }
diff --git a/sys/ipcpipeline/gstipcpipelineelement.c b/sys/ipcpipeline/gstipcpipelineelement.c
new file mode 100644 (file)
index 0000000..ce22760
--- /dev/null
@@ -0,0 +1,37 @@
+/* GStreamer
+ * Copyright (C) 2017 YouView TV Ltd
+ *  Author: George Kiagiadakis <george.Kiagiadakis@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 Street, Suite 500,
+ * Boston, MA 02110-1335, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "gstipcpipelineelements.h"
+#include "gstipcpipelinecomm.h"
+
+
+void
+icepipeline_element_init (GstPlugin * plugin)
+{
+  static gsize res = FALSE;
+  if (g_once_init_enter (&res)) {
+    gst_ipc_pipeline_comm_plugin_init ();
+    g_once_init_leave (&res, TRUE);
+  }
+}
diff --git a/sys/ipcpipeline/gstipcpipelineelements.h b/sys/ipcpipeline/gstipcpipelineelements.h
new file mode 100644 (file)
index 0000000..9746922
--- /dev/null
@@ -0,0 +1,37 @@
+/* GStreamer
+ * Copyright (C) 2017 YouView TV Ltd
+ *  Author: George Kiagiadakis <george.Kiagiadakis@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_IPCPIPELINE_ELEMENTS_H__
+#define __GST_IPCPIPELINE_ELEMENTS_H__
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gst/gst.h>
+
+void icepipeline_element_init (GstPlugin * plugin);
+
+GST_ELEMENT_REGISTER_DECLARE (ipcpipelinesink);
+GST_ELEMENT_REGISTER_DECLARE (ipcpipelinesrc);
+GST_ELEMENT_REGISTER_DECLARE (ipcslavepipeline);
+
+#endif /* __GST_IPCPIPELINE_ELEMENTS_H__ */
index 398bbf8..cc31ebc 100644 (file)
@@ -73,6 +73,7 @@
 #  include "config.h"
 #endif
 
+#include "gstipcpipelineelements.h"
 #include "gstipcpipelinesink.h"
 
 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
@@ -109,6 +110,9 @@ enum
 #define gst_ipc_pipeline_sink_parent_class parent_class
 G_DEFINE_TYPE_WITH_CODE (GstIpcPipelineSink, gst_ipc_pipeline_sink,
     GST_TYPE_ELEMENT, _do_init);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (ipcpipelinesink, "ipcpipelinesink",
+    GST_RANK_NONE, GST_TYPE_IPC_PIPELINE_SINK,
+    icepipeline_element_init (plugin));
 
 static void gst_ipc_pipeline_sink_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
index fbb7568..9d46d63 100644 (file)
@@ -40,6 +40,7 @@
 #  include "config.h"
 #endif
 
+#include "gstipcpipelineelements.h"
 #include "gstipcpipelinesrc.h"
 
 static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
@@ -79,6 +80,9 @@ static GQuark QUARK_UPSTREAM;
 #define gst_ipc_pipeline_src_parent_class parent_class
 G_DEFINE_TYPE_WITH_CODE (GstIpcPipelineSrc, gst_ipc_pipeline_src,
     GST_TYPE_ELEMENT, _do_init);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (ipcpipelinesrc, "ipcpipelinesrc",
+    GST_RANK_NONE, GST_TYPE_IPC_PIPELINE_SRC,
+    icepipeline_element_init (plugin));
 
 static void gst_ipc_pipeline_src_finalize (GObject * object);
 static void gst_ipc_pipeline_src_dispose (GObject * object);
index 3ec512e..90de4e9 100644 (file)
@@ -42,6 +42,7 @@
 
 #include <string.h>
 
+#include "gstipcpipelineelements.h"
 #include "gstipcpipelinesrc.h"
 #include "gstipcslavepipeline.h"
 
@@ -53,6 +54,9 @@ GST_DEBUG_CATEGORY_STATIC (gst_ipcslavepipeline_debug);
 #define gst_ipc_slave_pipeline_parent_class parent_class
 G_DEFINE_TYPE_WITH_CODE (GstIpcSlavePipeline, gst_ipc_slave_pipeline,
     GST_TYPE_PIPELINE, _do_init);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (ipcslavepipeline, "ipcslavepipeline",
+    GST_RANK_NONE, GST_TYPE_IPC_SLAVE_PIPELINE,
+    icepipeline_element_init (plugin));
 
 static gboolean gst_ipc_slave_pipeline_post_message (GstElement * element,
     GstMessage * message);
index aa7ce39..8d449a0 100644 (file)
@@ -1,5 +1,6 @@
 ipcpipeline_sources = [
   'gstipcpipeline.c',
+  'gstipcpipelineelement.c',
   'gstipcpipelinecomm.c',
   'gstipcpipelinesink.c',
   'gstipcpipelinesrc.c',
index db98343..5c68d8c 100644 (file)
@@ -81,6 +81,8 @@ G_DEFINE_TYPE_WITH_CODE (GstKMSSink, gst_kms_sink, GST_TYPE_VIDEO_SINK,
     GST_DEBUG_CATEGORY_GET (CAT_PERFORMANCE, "GST_PERFORMANCE");
     G_IMPLEMENT_INTERFACE (GST_TYPE_VIDEO_OVERLAY,
         gst_kms_sink_video_overlay_init));
+GST_ELEMENT_REGISTER_DEFINE (kmssink, GST_PLUGIN_NAME, GST_RANK_SECONDARY,
+    GST_TYPE_KMS_SINK);
 
 enum
 {
@@ -2084,11 +2086,7 @@ gst_kms_sink_class_init (GstKMSSinkClass * klass)
 static gboolean
 plugin_init (GstPlugin * plugin)
 {
-  if (!gst_element_register (plugin, GST_PLUGIN_NAME, GST_RANK_SECONDARY,
-          GST_TYPE_KMS_SINK))
-    return FALSE;
-
-  return TRUE;
+  return GST_ELEMENT_REGISTER (kmssink, plugin);
 }
 
 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, kms,
index 4b1ebea..428c057 100644 (file)
@@ -100,7 +100,7 @@ struct _GstKMSSinkClass {
 };
 
 GType gst_kms_sink_get_type (void) G_GNUC_CONST;
-
+GST_ELEMENT_REGISTER_DECLARE (kmssink);
 G_END_DECLS
 
 #endif /* __GST_KMS_SINK_H__ */
index 68c2c66..71d84d8 100644 (file)
@@ -113,6 +113,9 @@ struct _GstMLAudioSink
 };
 
 G_DEFINE_TYPE (GstMLAudioSink, gst_ml_audio_sink, GST_TYPE_AUDIO_SINK);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (mlaudiosink, "mlaudiosink",
+    GST_RANK_PRIMARY + 10, GST_TYPE_ML_AUDIO_SINK,
+    GST_DEBUG_CATEGORY_INIT (mgl_debug, "magicleap", 0, "Magic Leap elements"));
 
 enum
 {
index dd301fc..4010f66 100644 (file)
@@ -27,5 +27,5 @@ G_BEGIN_DECLS
 
 #define GST_TYPE_ML_AUDIO_SINK gst_ml_audio_sink_get_type ()
 G_DECLARE_FINAL_TYPE (GstMLAudioSink, gst_ml_audio_sink, GST, ML_AUDIO_SINK, GstAudioSink)
-
+GST_ELEMENT_REGISTER_DECLARE (mlaudiosink);
 G_END_DECLS
index 81d9a94..49258b2 100644 (file)
@@ -29,12 +29,7 @@ GST_DEBUG_CATEGORY (mgl_debug);
 static gboolean
 plugin_init (GstPlugin * plugin)
 {
-  if (!gst_element_register (plugin, "mlaudiosink", GST_RANK_PRIMARY + 10,
-          GST_TYPE_ML_AUDIO_SINK))
-    return FALSE;
-
-  GST_DEBUG_CATEGORY_INIT (mgl_debug, "magicleap", 0, "Magic Leap elements");
-  return TRUE;
+  return GST_ELEMENT_REGISTER (mlaudiosink, plugin);
 }
 
 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
index db4e5a6..a7f1a4d 100644 (file)
@@ -4,6 +4,7 @@ opensles_sources = [
   'openslessink.c',
   'openslessrc.c',
   'opensles.c',
+  'openslesplugin.c',
 ]
 
 opensles_option = get_option('opensles')
index 1a35b63..b7a7f38 100644 (file)
@@ -77,25 +77,12 @@ gst_opensles_release_engine (SLObjectItf engine_object_parameter)
   g_mutex_unlock (&engine_mutex);
 }
 
-static gboolean
-plugin_init (GstPlugin * plugin)
+void
+opensles_element_init (GstPlugin * plugin)
 {
-  g_mutex_init (&engine_mutex);
-
-  if (!gst_element_register (plugin, "openslessink", GST_RANK_PRIMARY,
-          GST_TYPE_OPENSLES_SINK)) {
-    return FALSE;
-  }
-  if (!gst_element_register (plugin, "openslessrc", GST_RANK_PRIMARY,
-          GST_TYPE_OPENSLES_SRC)) {
-    return FALSE;
+  static gsize res = FALSE;
+  if (g_once_init_enter (&res)) {
+    g_mutex_init (&engine_mutex);
+    g_once_init_leave (&res, TRUE);
   }
-
-  return TRUE;
 }
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
-    GST_VERSION_MINOR,
-    opensles,
-    "OpenSL ES support for GStreamer",
-    plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
index dbc341c..ac05ee1 100644 (file)
@@ -24,6 +24,8 @@
 #include <gst/gst.h>
 #include <SLES/OpenSLES.h>
 
+void opensles_element_init (GstPlugin * plugin);
+
 SLObjectItf gst_opensles_get_engine (void);
 void gst_opensles_release_engine (SLObjectItf engine_object);
 
diff --git a/sys/opensles/openslesplugin.c b/sys/opensles/openslesplugin.c
new file mode 100644 (file)
index 0000000..2bd9f23
--- /dev/null
@@ -0,0 +1,43 @@
+/* GStreamer
+ * Copyright (C) 2012 Fluendo S.A. <support@fluendo.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 "opensles.h"
+#include "openslessink.h"
+#include "openslessrc.h"
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+  gboolean ret = FALSE;
+
+  ret |= GST_ELEMENT_REGISTER (openslessink, plugin);
+  ret |= GST_ELEMENT_REGISTER (openslessrc, plugin);
+
+  return ret;
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+    GST_VERSION_MINOR,
+    opensles,
+    "OpenSL ES support for GStreamer",
+    plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
index 195b376..16cd049 100644 (file)
@@ -74,6 +74,8 @@ static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
 #define parent_class gst_opensles_sink_parent_class
 G_DEFINE_TYPE_WITH_CODE (GstOpenSLESSink, gst_opensles_sink,
     GST_TYPE_AUDIO_BASE_SINK, _do_init);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (openslessink, "openslessink",
+    GST_RANK_PRIMARY, GST_TYPE_OPENSLES_SINK, opensles_element_init (plugin));
 
 static GstAudioRingBuffer *
 gst_opensles_sink_create_ringbuffer (GstAudioBaseSink * base)
index 69e6f2d..41425f5 100644 (file)
@@ -52,6 +52,7 @@ struct _GstOpenSLESSinkClass
 };
 
 GType gst_opensles_sink_get_type (void);
+GST_ELEMENT_REGISTER_DECLARE (openslessink);
 
 G_END_DECLS
 #endif /* __OPENSLESSINK_H__ */
index 8967c33..96de03e 100644 (file)
@@ -35,6 +35,7 @@
 #  include <config.h>
 #endif
 
+#include "opensles.h"
 #include "openslessrc.h"
 
 GST_DEBUG_CATEGORY_STATIC (opensles_src_debug);
@@ -58,6 +59,8 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
 #define parent_class gst_opensles_src_parent_class
 G_DEFINE_TYPE_WITH_CODE (GstOpenSLESSrc, gst_opensles_src,
     GST_TYPE_AUDIO_BASE_SRC, _do_init);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (openslessrc, "openslessrc",
+    GST_RANK_PRIMARY, GST_TYPE_OPENSLES_SRC, opensles_element_init (plugin));
 
 enum
 {
index 805bcaa..8ebfe2b 100644 (file)
@@ -48,6 +48,7 @@ struct _GstOpenSLESSrcClass
 };
 
 GType gst_opensles_src_get_type (void);
+GST_ELEMENT_REGISTER_DECLARE (openslessrc);
 
 G_END_DECLS
 #endif /* __OPENSLESSRC_H__ */
index 4efcf10..4c18676 100644 (file)
 static gboolean
 plugin_init (GstPlugin * plugin)
 {
-  return gst_element_register (plugin, "shmsrc",
-      GST_RANK_NONE, GST_TYPE_SHM_SRC) &&
-      gst_element_register (plugin, "shmsink",
-      GST_RANK_NONE, GST_TYPE_SHM_SINK);
+  gboolean ret = FALSE;
+
+  ret |= GST_ELEMENT_REGISTER (shmsrc, plugin);
+  ret |= GST_ELEMENT_REGISTER (shmsink, plugin);
+
+  return ret;
 }
 
 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
index b171367..896651e 100644 (file)
@@ -83,6 +83,8 @@ static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
 
 #define gst_shm_sink_parent_class parent_class
 G_DEFINE_TYPE (GstShmSink, gst_shm_sink, GST_TYPE_BASE_SINK);
+GST_ELEMENT_REGISTER_DEFINE (shmsink, "shmsink", GST_RANK_NONE,
+    GST_TYPE_SHM_SINK);
 
 static void gst_shm_sink_finalize (GObject * object);
 static void gst_shm_sink_set_property (GObject * object, guint prop_id,
index a514096..241b802 100644 (file)
@@ -78,5 +78,7 @@ struct _GstShmSinkClass
 
 GType gst_shm_sink_get_type (void);
 
+GST_ELEMENT_REGISTER_DECLARE (shmsink);
+
 G_END_DECLS
 #endif /* __GST_SHM_SINK_H__ */
index 5360964..3e66290 100644 (file)
@@ -76,6 +76,7 @@ static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
 
 #define gst_shm_src_parent_class parent_class
 G_DEFINE_TYPE (GstShmSrc, gst_shm_src, GST_TYPE_PUSH_SRC);
+GST_ELEMENT_REGISTER_DEFINE (shmsrc, "shmsrc", GST_RANK_NONE, GST_TYPE_SHM_SRC);
 
 static void gst_shm_src_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
index 04797ab..b14fcd7 100644 (file)
@@ -65,6 +65,8 @@ struct _GstShmSrcClass
 
 GType gst_shm_src_get_type (void);
 
+GST_ELEMENT_REGISTER_DECLARE (shmsrc);
+
 struct _GstShmPipe {
   int use_count;
 
index e3d76e3..a532687 100644 (file)
 #include <gst/gst.h>
 #include "gstuvch264_mjpgdemux.h"
 #include "gstuvch264_src.h"
-
-extern GType gst_uvc_h264_device_provider_get_type ();
+#include "gstuvch264deviceprovider.h"
 
 
 static gboolean
 plugin_init (GstPlugin * plugin)
 {
-  if (!gst_element_register (plugin, "uvch264mjpgdemux", GST_RANK_NONE,
-          GST_TYPE_UVC_H264_MJPG_DEMUX))
-    return FALSE;
-
-  if (!gst_element_register (plugin, "uvch264src", GST_RANK_NONE,
-          GST_TYPE_UVC_H264_SRC))
-    return FALSE;
+  gboolean ret = FALSE;
 
-  if (!gst_device_provider_register (plugin, "uvch264deviceprovider",
-          GST_RANK_PRIMARY, gst_uvc_h264_device_provider_get_type ()))
-    return FALSE;
+  ret |= GST_ELEMENT_REGISTER (uvch264mjpgdemux, plugin);
+  ret |= GST_ELEMENT_REGISTER (uvch264src, plugin);
+  ret |= GST_DEVICE_PROVIDER_REGISTER (uvch264deviceprovider, plugin);
 
-  return TRUE;
+  return ret;
 }
 
 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
index bc9406e..76b3c34 100644 (file)
@@ -130,6 +130,8 @@ static gboolean gst_uvc_h264_mjpg_demux_query (GstPad * pad,
 
 #define gst_uvc_h264_mjpg_demux_parent_class parent_class
 G_DEFINE_TYPE (GstUvcH264MjpgDemux, gst_uvc_h264_mjpg_demux, GST_TYPE_ELEMENT);
+GST_ELEMENT_REGISTER_DEFINE (uvch264mjpgdemux, "uvch264mjpgdemux",
+    GST_RANK_NONE, GST_TYPE_UVC_H264_MJPG_DEMUX);
 
 static void
 gst_uvc_h264_mjpg_demux_class_init (GstUvcH264MjpgDemuxClass * klass)
index e1f79b4..8df3209 100644 (file)
@@ -104,6 +104,8 @@ struct _GstUvcH264MjpgDemuxClass {
 
 GType gst_uvc_h264_mjpg_demux_get_type (void);
 
+GST_ELEMENT_REGISTER_DECLARE (uvch264mjpgdemux);
+
 G_END_DECLS
 
 #endif /* __GST_UVC_H264_MJPG_DEMUX_H__ */
index db7675d..55bde5a 100644 (file)
@@ -123,6 +123,8 @@ GST_DEBUG_CATEGORY (uvc_h264_src_debug);
 
 #define gst_uvc_h264_src_parent_class parent_class
 G_DEFINE_TYPE (GstUvcH264Src, gst_uvc_h264_src, GST_TYPE_BASE_CAMERA_SRC);
+GST_ELEMENT_REGISTER_DEFINE (uvch264src, "uvch264src", GST_RANK_NONE,
+    GST_TYPE_UVC_H264_SRC);
 
 #define GST_UVC_H264_SRC_VF_CAPS_STR \
   GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL) ";" \
index 535a187..73aed91 100644 (file)
@@ -158,6 +158,8 @@ struct _GstUvcH264SrcClass
   GstBaseCameraSrcClass parent;
 };
 
+GST_ELEMENT_REGISTER_DECLARE (uvch264src);
+
 G_END_DECLS
 
 #endif /* __GST_UVC_H264_SRC_H__ */
index 4e7e19b..485594f 100644 (file)
@@ -54,6 +54,9 @@ struct _GstUvcH264Device
 
 G_DEFINE_TYPE (GstUvcH264Device, gst_uvc_h264_device, GST_TYPE_DEVICE);
 /* *INDENT-ON* */
+GST_DEVICE_PROVIDER_REGISTER_DEFINE (uvch264deviceprovider,
+    "uvch264deviceprovider", GST_RANK_PRIMARY,
+    gst_uvc_h264_device_provider_get_type ());
 
 static void
 gst_uvc_h264_device_get_property (GObject * object, guint prop_id,
index 599dad7..8b691ff 100644 (file)
@@ -26,5 +26,5 @@ G_BEGIN_DECLS
 G_DECLARE_FINAL_TYPE (GstUvcH264Device, gst_uvc_h264_device, GST, UVC_H264_DEVICE, GstDevice)
 
 G_DECLARE_FINAL_TYPE (GstUvcH264DeviceProvider, gst_uvc_h264_device_provider, GST, UVC_H264_DEVICE_PROVIDER, GstDeviceProvider)
-
+GST_DEVICE_PROVIDER_REGISTER_DECLARE (uvch264deviceprovider);
 G_END_DECLS