diff --git a/sys/bluez/bluez-plugin.c b/sys/bluez/bluez-plugin.c index 3e9697785c..afa16b0e53 100644 --- a/sys/bluez/bluez-plugin.c +++ b/sys/bluez/bluez-plugin.c @@ -22,26 +22,23 @@ #include #endif +#include "gstbluezelements.h" #include "gsta2dpsink.h" #include "gstavdtpsink.h" #include "gstavdtpsrc.h" #include -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, diff --git a/sys/bluez/gsta2dpsink.c b/sys/bluez/gsta2dpsink.c index 205337202b..f81e944ffc 100644 --- a/sys/bluez/gsta2dpsink.c +++ b/sys/bluez/gsta2dpsink.c @@ -27,6 +27,7 @@ #include +#include "gstbluezelements.h" #include "gsta2dpsink.h" #include @@ -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, diff --git a/sys/bluez/gsta2dpsink.h b/sys/bluez/gsta2dpsink.h index bbfe87b9c0..95002be1c8 100644 --- a/sys/bluez/gsta2dpsink.h +++ b/sys/bluez/gsta2dpsink.h @@ -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 diff --git a/sys/bluez/gstavdtpsink.c b/sys/bluez/gstavdtpsink.c index dc909aa83a..9cf5d1be1f 100644 --- a/sys/bluez/gstavdtpsink.c +++ b/sys/bluez/gstavdtpsink.c @@ -36,6 +36,7 @@ #include "a2dp-codecs.h" +#include "gstbluezelements.h" #include "gstavdtpsink.h" #include @@ -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) diff --git a/sys/bluez/gstavdtpsink.h b/sys/bluez/gstavdtpsink.h index c6b60b7f2b..7d17e42fa6 100644 --- a/sys/bluez/gstavdtpsink.h +++ b/sys/bluez/gstavdtpsink.h @@ -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); diff --git a/sys/bluez/gstavdtpsrc.c b/sys/bluez/gstavdtpsrc.c index 50132308e1..40d1f9bed4 100644 --- a/sys/bluez/gstavdtpsrc.c +++ b/sys/bluez/gstavdtpsrc.c @@ -31,6 +31,7 @@ #include #include +#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); -} diff --git a/sys/bluez/gstavdtpsrc.h b/sys/bluez/gstavdtpsrc.h index 57e26493fa..aeafbff6a2 100644 --- a/sys/bluez/gstavdtpsrc.h +++ b/sys/bluez/gstavdtpsrc.h @@ -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 index 0000000000..143c36a585 --- /dev/null +++ b/sys/bluez/gstbluezelement.c @@ -0,0 +1,38 @@ +/* GStreamer bluez plugin + * + * Copyright (C) 2013 Collabora Ltd. + * + * 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 +#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 index 0000000000..a8ae92ce9c --- /dev/null +++ b/sys/bluez/gstbluezelements.h @@ -0,0 +1,36 @@ +/* GStreamer + * Copyright (C) <2020> Julian Bouzas + * + * 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 +#endif + +#include + +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__ */ diff --git a/sys/bluez/meson.build b/sys/bluez/meson.build index a53d5b8f37..769842dbf1 100644 --- a/sys/bluez/meson.build +++ b/sys/bluez/meson.build @@ -1,5 +1,6 @@ bluez_sources = [ 'bluez-plugin.c', + 'gstbluezelement.c', 'gsta2dpsink.c', 'gstavdtpsink.c', 'gstavdtpsrc.c', diff --git a/sys/decklink/gstdecklink.cpp b/sys/decklink/gstdecklink.cpp index 7916e8bdb6..4534180597 100644 --- a/sys/decklink/gstdecklink.cpp +++ b/sys/decklink/gstdecklink.cpp @@ -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"); + 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); - 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; + 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) diff --git a/sys/decklink/gstdecklink.h b/sys/decklink/gstdecklink.h index 0e3e3d5bc7..baa78795ec 100644 --- a/sys/decklink/gstdecklink.h +++ b/sys/decklink/gstdecklink.h @@ -55,6 +55,8 @@ #define WINAPI #endif /* G_OS_WIN32 */ +void decklink_element_init (GstPlugin * plugin); + typedef enum { GST_DECKLINK_MODE_AUTO, diff --git a/sys/decklink/gstdecklinkaudiosink.cpp b/sys/decklink/gstdecklinkaudiosink.cpp index 924caf1d14..65991ba3a8 100644 --- a/sys/decklink/gstdecklinkaudiosink.cpp +++ b/sys/decklink/gstdecklinkaudiosink.cpp @@ -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) diff --git a/sys/decklink/gstdecklinkaudiosink.h b/sys/decklink/gstdecklinkaudiosink.h index 0394664b18..a9a94e7757 100644 --- a/sys/decklink/gstdecklinkaudiosink.h +++ b/sys/decklink/gstdecklinkaudiosink.h @@ -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__ */ diff --git a/sys/decklink/gstdecklinkaudiosrc.cpp b/sys/decklink/gstdecklinkaudiosrc.cpp index 41e4f85715..c0845cd25c 100644 --- a/sys/decklink/gstdecklinkaudiosrc.cpp +++ b/sys/decklink/gstdecklinkaudiosrc.cpp @@ -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) diff --git a/sys/decklink/gstdecklinkaudiosrc.h b/sys/decklink/gstdecklinkaudiosrc.h index fdb77b622c..bda465506b 100644 --- a/sys/decklink/gstdecklinkaudiosrc.h +++ b/sys/decklink/gstdecklinkaudiosrc.h @@ -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__ */ diff --git a/sys/decklink/gstdecklinkdeviceprovider.cpp b/sys/decklink/gstdecklinkdeviceprovider.cpp index c884c42817..3a98705932 100644 --- a/sys/decklink/gstdecklinkdeviceprovider.cpp +++ b/sys/decklink/gstdecklinkdeviceprovider.cpp @@ -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) diff --git a/sys/decklink/gstdecklinkdeviceprovider.h b/sys/decklink/gstdecklinkdeviceprovider.h index 0bd684defe..5f79dfd421 100644 --- a/sys/decklink/gstdecklinkdeviceprovider.h +++ b/sys/decklink/gstdecklinkdeviceprovider.h @@ -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 index 0000000000..7ba41a31a3 --- /dev/null +++ b/sys/decklink/gstdecklinkplugin.cpp @@ -0,0 +1,52 @@ +/* GStreamer + * Copyright (C) 2011 David Schleef + * Copyright (C) 2014 Sebastian Dröge + * Copyright (C) 2015 Florian Langlois + * Copyright (C) 2020 Sohonet + * + * 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 + +#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) diff --git a/sys/decklink/gstdecklinkvideosink.cpp b/sys/decklink/gstdecklinkvideosink.cpp index 7e9b514c68..a64c046a68 100644 --- a/sys/decklink/gstdecklinkvideosink.cpp +++ b/sys/decklink/gstdecklinkvideosink.cpp @@ -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, diff --git a/sys/decklink/gstdecklinkvideosink.h b/sys/decklink/gstdecklinkvideosink.h index dffe3a7f39..555ec8e72e 100644 --- a/sys/decklink/gstdecklinkvideosink.h +++ b/sys/decklink/gstdecklinkvideosink.h @@ -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); diff --git a/sys/decklink/gstdecklinkvideosrc.cpp b/sys/decklink/gstdecklinkvideosrc.cpp index 40dc31db2a..41de397d7a 100644 --- a/sys/decklink/gstdecklinkvideosrc.cpp +++ b/sys/decklink/gstdecklinkvideosrc.cpp @@ -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) diff --git a/sys/decklink/gstdecklinkvideosrc.h b/sys/decklink/gstdecklinkvideosrc.h index 3213aa5b7a..edd52d3348 100644 --- a/sys/decklink/gstdecklinkvideosrc.h +++ b/sys/decklink/gstdecklinkvideosrc.h @@ -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__ */ diff --git a/sys/decklink/meson.build b/sys/decklink/meson.build index abffb633f5..d869e79a48 100644 --- a/sys/decklink/meson.build +++ b/sys/decklink/meson.build @@ -1,4 +1,5 @@ decklink_sources = [ + 'gstdecklinkplugin.cpp', 'gstdecklink.cpp', 'gstdecklinkaudiosink.cpp', 'gstdecklinkvideosink.cpp', diff --git a/sys/dvb/dvbbasebin.c b/sys/dvb/dvbbasebin.c index 6f74a09913..3d2ba23925 100644 --- a/sys/dvb/dvbbasebin.c +++ b/sys/dvb/dvbbasebin.c @@ -30,6 +30,7 @@ #include #include #include +#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) diff --git a/sys/dvb/dvbbasebin.h b/sys/dvb/dvbbasebin.h index 96e6f8371c..29ba9c9bdb 100644 --- a/sys/dvb/dvbbasebin.h +++ b/sys/dvb/dvbbasebin.h @@ -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 diff --git a/sys/dvb/gstdvb.c b/sys/dvb/gstdvb.c index d3e8831d43..0ce6be4ccf 100644 --- a/sys/dvb/gstdvb.c +++ b/sys/dvb/gstdvb.c @@ -1,3 +1,4 @@ + /* * gstdvb.c - * Copyright (C) 2007 Alessandro Decina @@ -26,26 +27,17 @@ #include -#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 */ + gboolean ret = FALSE; - if (!gst_dvbsrc_plugin_init (plugin)) - return FALSE; + ret |= GST_ELEMENT_REGISTER (dvbsrc, plugin); + ret |= GST_ELEMENT_REGISTER (dvbbasebin, plugin); - if (!gst_dvb_base_bin_plugin_init (plugin)) - return FALSE; - - 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 index 0000000000..50f39316fe --- /dev/null +++ b/sys/dvb/gstdvbelement.c @@ -0,0 +1,44 @@ +/* + * gstdvb.c - + * Copyright (C) 2007 Alessandro Decina + * + * Authors: + * Alessandro Decina + * + * 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 + +#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 index 0000000000..4f8784bf04 --- /dev/null +++ b/sys/dvb/gstdvbelements.h @@ -0,0 +1,34 @@ +/* GStreamer + * Copyright (C) <2020> Julian Bouzas + * + * 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 +#endif + +#include + +void dvb_element_init (GstPlugin * plugin); +GST_ELEMENT_REGISTER_DECLARE (dvbbasebin); +GST_ELEMENT_REGISTER_DECLARE (dvbsrc); + +#endif /* __GST_DVB_ELEMENTS_H__ */ diff --git a/sys/dvb/gstdvbsrc.c b/sys/dvb/gstdvbsrc.c index ca6b92a426..92c918c1aa 100644 --- a/sys/dvb/gstdvbsrc.c +++ b/sys/dvb/gstdvbsrc.c @@ -93,6 +93,7 @@ #include "config.h" #endif +#include "gstdvbelements.h" #include "gstdvbsrc.h" #include #include @@ -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) diff --git a/sys/dvb/gstdvbsrc.h b/sys/dvb/gstdvbsrc.h index da6b5bc12c..249e4c3508 100644 --- a/sys/dvb/gstdvbsrc.h +++ b/sys/dvb/gstdvbsrc.h @@ -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__ */ diff --git a/sys/dvb/meson.build b/sys/dvb/meson.build index 7118fec97e..6a58f098a1 100644 --- a/sys/dvb/meson.build +++ b/sys/dvb/meson.build @@ -11,6 +11,7 @@ dvb_sources = [ 'camutils.c', 'dvbbasebin.c', 'gstdvb.c', + 'gstdvbelement.c', 'gstdvbsrc.c', 'parsechannels.c', ] diff --git a/sys/fbdev/gstfbdevsink.c b/sys/fbdev/gstfbdevsink.c index 166c543ed7..d70dd4bb9c 100644 --- a/sys/fbdev/gstfbdevsink.c +++ b/sys/fbdev/gstfbdevsink.c @@ -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 diff --git a/sys/fbdev/gstfbdevsink.h b/sys/fbdev/gstfbdevsink.h index 79982172d4..6ab9bd0eb1 100644 --- a/sys/fbdev/gstfbdevsink.h +++ b/sys/fbdev/gstfbdevsink.h @@ -67,6 +67,7 @@ struct _GstFBDEVSinkClass { }; GType gst_fbdevsink_get_type(void); +GST_ELEMENT_REGISTER_DECLARE (fbdevsink); G_END_DECLS diff --git a/sys/ipcpipeline/gstipcpipeline.c b/sys/ipcpipeline/gstipcpipeline.c index 4d647d49dd..5b2f5c53e5 100644 --- a/sys/ipcpipeline/gstipcpipeline.c +++ b/sys/ipcpipeline/gstipcpipeline.c @@ -22,21 +22,15 @@ #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 index 0000000000..ce22760d7e --- /dev/null +++ b/sys/ipcpipeline/gstipcpipelineelement.c @@ -0,0 +1,37 @@ +/* GStreamer + * Copyright (C) 2017 YouView TV Ltd + * Author: George Kiagiadakis + * + * 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 index 0000000000..97469221d8 --- /dev/null +++ b/sys/ipcpipeline/gstipcpipelineelements.h @@ -0,0 +1,37 @@ +/* GStreamer + * Copyright (C) 2017 YouView TV Ltd + * Author: George Kiagiadakis + * + * 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 +#endif + +#include + +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__ */ diff --git a/sys/ipcpipeline/gstipcpipelinesink.c b/sys/ipcpipeline/gstipcpipelinesink.c index 398bbf8e67..cc31ebcb75 100644 --- a/sys/ipcpipeline/gstipcpipelinesink.c +++ b/sys/ipcpipeline/gstipcpipelinesink.c @@ -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); diff --git a/sys/ipcpipeline/gstipcpipelinesrc.c b/sys/ipcpipeline/gstipcpipelinesrc.c index fbb7568198..9d46d63b0e 100644 --- a/sys/ipcpipeline/gstipcpipelinesrc.c +++ b/sys/ipcpipeline/gstipcpipelinesrc.c @@ -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); diff --git a/sys/ipcpipeline/gstipcslavepipeline.c b/sys/ipcpipeline/gstipcslavepipeline.c index 3ec512ef84..90de4e9397 100644 --- a/sys/ipcpipeline/gstipcslavepipeline.c +++ b/sys/ipcpipeline/gstipcslavepipeline.c @@ -42,6 +42,7 @@ #include +#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); diff --git a/sys/ipcpipeline/meson.build b/sys/ipcpipeline/meson.build index aa7ce399a5..8d449a020a 100644 --- a/sys/ipcpipeline/meson.build +++ b/sys/ipcpipeline/meson.build @@ -1,5 +1,6 @@ ipcpipeline_sources = [ 'gstipcpipeline.c', + 'gstipcpipelineelement.c', 'gstipcpipelinecomm.c', 'gstipcpipelinesink.c', 'gstipcpipelinesrc.c', diff --git a/sys/kms/gstkmssink.c b/sys/kms/gstkmssink.c index db983439e9..5c68d8c65b 100644 --- a/sys/kms/gstkmssink.c +++ b/sys/kms/gstkmssink.c @@ -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, diff --git a/sys/kms/gstkmssink.h b/sys/kms/gstkmssink.h index 4b1ebeac3c..428c057e77 100644 --- a/sys/kms/gstkmssink.h +++ b/sys/kms/gstkmssink.h @@ -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__ */ diff --git a/sys/magicleap/mlaudiosink.c b/sys/magicleap/mlaudiosink.c index 68c2c66fac..71d84d8190 100644 --- a/sys/magicleap/mlaudiosink.c +++ b/sys/magicleap/mlaudiosink.c @@ -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 { diff --git a/sys/magicleap/mlaudiosink.h b/sys/magicleap/mlaudiosink.h index dd301fc7dd..4010f665d2 100644 --- a/sys/magicleap/mlaudiosink.h +++ b/sys/magicleap/mlaudiosink.h @@ -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 diff --git a/sys/magicleap/plugin.c b/sys/magicleap/plugin.c index 81d9a946a4..49258b24ce 100644 --- a/sys/magicleap/plugin.c +++ b/sys/magicleap/plugin.c @@ -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, diff --git a/sys/opensles/meson.build b/sys/opensles/meson.build index db4e5a6429..a7f1a4d48d 100644 --- a/sys/opensles/meson.build +++ b/sys/opensles/meson.build @@ -4,6 +4,7 @@ opensles_sources = [ 'openslessink.c', 'openslessrc.c', 'opensles.c', + 'openslesplugin.c', ] opensles_option = get_option('opensles') diff --git a/sys/opensles/opensles.c b/sys/opensles/opensles.c index 1a35b63f9c..b7a7f38980 100644 --- a/sys/opensles/opensles.c +++ b/sys/opensles/opensles.c @@ -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; + static gsize res = FALSE; + if (g_once_init_enter (&res)) { + g_mutex_init (&engine_mutex); + g_once_init_leave (&res, TRUE); } - if (!gst_element_register (plugin, "openslessrc", GST_RANK_PRIMARY, - GST_TYPE_OPENSLES_SRC)) { - return FALSE; - } - - 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) diff --git a/sys/opensles/opensles.h b/sys/opensles/opensles.h index dbc341c49c..ac05ee1269 100644 --- a/sys/opensles/opensles.h +++ b/sys/opensles/opensles.h @@ -24,6 +24,8 @@ #include #include +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 index 0000000000..2bd9f23aa4 --- /dev/null +++ b/sys/opensles/openslesplugin.c @@ -0,0 +1,43 @@ +/* GStreamer + * Copyright (C) 2012 Fluendo S.A. + * + * 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) diff --git a/sys/opensles/openslessink.c b/sys/opensles/openslessink.c index 195b376d35..16cd049f39 100644 --- a/sys/opensles/openslessink.c +++ b/sys/opensles/openslessink.c @@ -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) diff --git a/sys/opensles/openslessink.h b/sys/opensles/openslessink.h index 69e6f2d919..41425f58c5 100644 --- a/sys/opensles/openslessink.h +++ b/sys/opensles/openslessink.h @@ -52,6 +52,7 @@ struct _GstOpenSLESSinkClass }; GType gst_opensles_sink_get_type (void); +GST_ELEMENT_REGISTER_DECLARE (openslessink); G_END_DECLS #endif /* __OPENSLESSINK_H__ */ diff --git a/sys/opensles/openslessrc.c b/sys/opensles/openslessrc.c index 8967c33c59..96de03e465 100644 --- a/sys/opensles/openslessrc.c +++ b/sys/opensles/openslessrc.c @@ -35,6 +35,7 @@ # include #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 { diff --git a/sys/opensles/openslessrc.h b/sys/opensles/openslessrc.h index 805bcaa47e..8ebfe2bf1f 100644 --- a/sys/opensles/openslessrc.h +++ b/sys/opensles/openslessrc.h @@ -48,6 +48,7 @@ struct _GstOpenSLESSrcClass }; GType gst_opensles_src_get_type (void); +GST_ELEMENT_REGISTER_DECLARE (openslessrc); G_END_DECLS #endif /* __OPENSLESSRC_H__ */ diff --git a/sys/shm/gstshm.c b/sys/shm/gstshm.c index 4efcf10c75..4c18676a5f 100644 --- a/sys/shm/gstshm.c +++ b/sys/shm/gstshm.c @@ -29,10 +29,12 @@ 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, diff --git a/sys/shm/gstshmsink.c b/sys/shm/gstshmsink.c index b171367df8..896651e97c 100644 --- a/sys/shm/gstshmsink.c +++ b/sys/shm/gstshmsink.c @@ -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, diff --git a/sys/shm/gstshmsink.h b/sys/shm/gstshmsink.h index a51409627f..241b802a38 100644 --- a/sys/shm/gstshmsink.h +++ b/sys/shm/gstshmsink.h @@ -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__ */ diff --git a/sys/shm/gstshmsrc.c b/sys/shm/gstshmsrc.c index 5360964758..3e6629080f 100644 --- a/sys/shm/gstshmsrc.c +++ b/sys/shm/gstshmsrc.c @@ -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); diff --git a/sys/shm/gstshmsrc.h b/sys/shm/gstshmsrc.h index 04797ab324..b14fcd7fd3 100644 --- a/sys/shm/gstshmsrc.h +++ b/sys/shm/gstshmsrc.h @@ -65,6 +65,8 @@ struct _GstShmSrcClass GType gst_shm_src_get_type (void); +GST_ELEMENT_REGISTER_DECLARE (shmsrc); + struct _GstShmPipe { int use_count; diff --git a/sys/uvch264/gstuvch264.c b/sys/uvch264/gstuvch264.c index e3d76e3229..a532687ae3 100644 --- a/sys/uvch264/gstuvch264.c +++ b/sys/uvch264/gstuvch264.c @@ -28,26 +28,19 @@ #include #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; + gboolean ret = FALSE; - if (!gst_element_register (plugin, "uvch264src", GST_RANK_NONE, - GST_TYPE_UVC_H264_SRC)) - return FALSE; + ret |= GST_ELEMENT_REGISTER (uvch264mjpgdemux, plugin); + ret |= GST_ELEMENT_REGISTER (uvch264src, plugin); + ret |= GST_DEVICE_PROVIDER_REGISTER (uvch264deviceprovider, plugin); - if (!gst_device_provider_register (plugin, "uvch264deviceprovider", - GST_RANK_PRIMARY, gst_uvc_h264_device_provider_get_type ())) - return FALSE; - - return TRUE; + return ret; } GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, diff --git a/sys/uvch264/gstuvch264_mjpgdemux.c b/sys/uvch264/gstuvch264_mjpgdemux.c index bc9406ecef..76b3c34d38 100644 --- a/sys/uvch264/gstuvch264_mjpgdemux.c +++ b/sys/uvch264/gstuvch264_mjpgdemux.c @@ -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) diff --git a/sys/uvch264/gstuvch264_mjpgdemux.h b/sys/uvch264/gstuvch264_mjpgdemux.h index e1f79b4281..8df320990f 100644 --- a/sys/uvch264/gstuvch264_mjpgdemux.h +++ b/sys/uvch264/gstuvch264_mjpgdemux.h @@ -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__ */ diff --git a/sys/uvch264/gstuvch264_src.c b/sys/uvch264/gstuvch264_src.c index db7675dfc1..55bde5abac 100644 --- a/sys/uvch264/gstuvch264_src.c +++ b/sys/uvch264/gstuvch264_src.c @@ -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) ";" \ diff --git a/sys/uvch264/gstuvch264_src.h b/sys/uvch264/gstuvch264_src.h index 535a187ffb..73aed91e1c 100644 --- a/sys/uvch264/gstuvch264_src.h +++ b/sys/uvch264/gstuvch264_src.h @@ -158,6 +158,8 @@ struct _GstUvcH264SrcClass GstBaseCameraSrcClass parent; }; +GST_ELEMENT_REGISTER_DECLARE (uvch264src); + G_END_DECLS #endif /* __GST_UVC_H264_SRC_H__ */ diff --git a/sys/uvch264/gstuvch264deviceprovider.c b/sys/uvch264/gstuvch264deviceprovider.c index 4e7e19b25d..485594ff58 100644 --- a/sys/uvch264/gstuvch264deviceprovider.c +++ b/sys/uvch264/gstuvch264deviceprovider.c @@ -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, diff --git a/sys/uvch264/gstuvch264deviceprovider.h b/sys/uvch264/gstuvch264deviceprovider.h index 599dad72bc..8b691ff913 100644 --- a/sys/uvch264/gstuvch264deviceprovider.h +++ b/sys/uvch264/gstuvch264deviceprovider.h @@ -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