From 7e499b9a66c2d2227ea1c52e13b2b7da8cea674a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Wed, 17 Feb 2021 18:17:08 +0100 Subject: [PATCH] hls: allow per feature registration Split plugin into features including dynamic types which can be indiviually registered during a static build. More details here: https://gitlab.freedesktop.org/gstreamer/gst-build/-/merge_requests/199 https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/661 Part-of: --- ext/hls/gsthls.h | 12 ------------ ext/hls/gsthlsdemux.c | 3 +++ ext/hls/gsthlsdemux.h | 1 - ext/hls/gsthlselement.c | 18 ++++++++++++++++++ ext/hls/gsthlselements.h | 18 ++++++++++++++++++ ext/hls/gsthlsplugin.c | 30 +++++++++--------------------- ext/hls/gsthlssink.c | 14 ++++++-------- ext/hls/gsthlssink2.c | 11 +++-------- ext/hls/gstm3u8playlist.c | 2 +- ext/hls/m3u8.c | 2 +- ext/hls/m3u8.h | 2 +- ext/hls/meson.build | 1 + 12 files changed, 61 insertions(+), 53 deletions(-) delete mode 100644 ext/hls/gsthls.h create mode 100644 ext/hls/gsthlselement.c create mode 100644 ext/hls/gsthlselements.h diff --git a/ext/hls/gsthls.h b/ext/hls/gsthls.h deleted file mode 100644 index 3806f4f216..0000000000 --- a/ext/hls/gsthls.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef __GST_HLS_H__ -#define __GST_HLS_H__ - -#include - -G_BEGIN_DECLS - -GST_DEBUG_CATEGORY_EXTERN (hls_debug); - -G_END_DECLS - -#endif /* __GST_HLS_H__ */ diff --git a/ext/hls/gsthlsdemux.c b/ext/hls/gsthlsdemux.c index f923a26745..46e99f41c7 100644 --- a/ext/hls/gsthlsdemux.c +++ b/ext/hls/gsthlsdemux.c @@ -43,6 +43,7 @@ #include #include +#include "gsthlselements.h" #include "gsthlsdemux.h" static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src_%u", @@ -119,6 +120,8 @@ static void gst_hls_demux_set_current_variant (GstHLSDemux * hlsdemux, #define gst_hls_demux_parent_class parent_class G_DEFINE_TYPE (GstHLSDemux, gst_hls_demux, GST_TYPE_ADAPTIVE_DEMUX); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (hlsdemux, "hlsdemux", GST_RANK_PRIMARY, + GST_TYPE_HLS_DEMUX, hls_element_init (plugin)); static void gst_hls_demux_finalize (GObject * obj) diff --git a/ext/hls/gsthlsdemux.h b/ext/hls/gsthlsdemux.h index 14b78864bd..98d6099cbf 100644 --- a/ext/hls/gsthlsdemux.h +++ b/ext/hls/gsthlsdemux.h @@ -27,7 +27,6 @@ #include #include "m3u8.h" -#include "gsthls.h" #include #if defined(HAVE_OPENSSL) #include diff --git a/ext/hls/gsthlselement.c b/ext/hls/gsthlselement.c new file mode 100644 index 0000000000..a469e44f79 --- /dev/null +++ b/ext/hls/gsthlselement.c @@ -0,0 +1,18 @@ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "gsthlselements.h" + +GST_DEBUG_CATEGORY (hls_debug); + +void +hls_element_init (GstPlugin * plugin) +{ + static gsize res = FALSE; + if (g_once_init_enter (&res)) { + GST_DEBUG_CATEGORY_INIT (hls_debug, "hls", 0, "HTTP Live Streaming (HLS)"); + g_once_init_leave (&res, TRUE); + } +} diff --git a/ext/hls/gsthlselements.h b/ext/hls/gsthlselements.h new file mode 100644 index 0000000000..4395230e44 --- /dev/null +++ b/ext/hls/gsthlselements.h @@ -0,0 +1,18 @@ +#ifndef __GST_HLS_ELEMENT_H__ +#define __GST_HLS_ELEMENT_H__ + +#include + +G_BEGIN_DECLS + +void hls_element_init (GstPlugin * plugin); + +GST_ELEMENT_REGISTER_DECLARE (hlsdemux); +GST_ELEMENT_REGISTER_DECLARE (hlssink); +GST_ELEMENT_REGISTER_DECLARE (hlssink2); + +GST_DEBUG_CATEGORY_EXTERN (hls_debug); + +G_END_DECLS + +#endif /* __GST_HLS_ELEMENT_H__ */ diff --git a/ext/hls/gsthlsplugin.c b/ext/hls/gsthlsplugin.c index fc26588474..cad1b55830 100644 --- a/ext/hls/gsthlsplugin.c +++ b/ext/hls/gsthlsplugin.c @@ -1,36 +1,24 @@ + #ifdef HAVE_CONFIG_H # include #endif -#include +#include "gsthlselements.h" -#include "gsthls.h" -#include "gsthlsdemux.h" -#include "gsthlssink.h" -#include "gsthlssink2.h" - -GST_DEBUG_CATEGORY (hls_debug); static gboolean -hls_init (GstPlugin * plugin) +plugin_init (GstPlugin * plugin) { - GST_DEBUG_CATEGORY_INIT (hls_debug, "hls", 0, "HTTP Live Streaming (HLS)"); + gboolean ret = FALSE; - if (!gst_element_register (plugin, "hlsdemux", GST_RANK_PRIMARY, - GST_TYPE_HLS_DEMUX) || FALSE) - return FALSE; - - if (!gst_hls_sink_plugin_init (plugin)) - return FALSE; - - if (!gst_hls_sink2_plugin_init (plugin)) - return FALSE; - - return TRUE; + ret |= GST_ELEMENT_REGISTER (hlsdemux, plugin); + ret |= GST_ELEMENT_REGISTER (hlssink, plugin); + ret |= GST_ELEMENT_REGISTER (hlssink2, plugin); + return ret; } GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, hls, "HTTP Live Streaming (HLS)", - hls_init, VERSION, GST_LICENSE, PACKAGE_NAME, GST_PACKAGE_ORIGIN) + plugin_init, VERSION, GST_LICENSE, PACKAGE_NAME, GST_PACKAGE_ORIGIN) diff --git a/ext/hls/gsthlssink.c b/ext/hls/gsthlssink.c index 78f8df1e67..a5f2f5e529 100644 --- a/ext/hls/gsthlssink.c +++ b/ext/hls/gsthlssink.c @@ -33,6 +33,7 @@ #include "config.h" #endif +#include "gsthlselements.h" #include "gsthlssink.h" #include #include @@ -70,6 +71,11 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", #define gst_hls_sink_parent_class parent_class G_DEFINE_TYPE (GstHlsSink, gst_hls_sink, GST_TYPE_BIN); +#define _do_init \ + hls_element_init (plugin); \ + GST_DEBUG_CATEGORY_INIT (gst_hls_sink_debug, "hlssink", 0, "HlsSink"); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (hlssink, "hlssink", GST_RANK_NONE, + GST_TYPE_HLS_SINK, _do_init); static void gst_hls_sink_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * spec); @@ -580,11 +586,3 @@ gst_hls_sink_chain_list (GstPad * pad, GstObject * parent, GstBufferList * list) return ret; } - -gboolean -gst_hls_sink_plugin_init (GstPlugin * plugin) -{ - GST_DEBUG_CATEGORY_INIT (gst_hls_sink_debug, "hlssink", 0, "HlsSink"); - return gst_element_register (plugin, "hlssink", GST_RANK_NONE, - gst_hls_sink_get_type ()); -} diff --git a/ext/hls/gsthlssink2.c b/ext/hls/gsthlssink2.c index 257c38271b..16bda35c13 100644 --- a/ext/hls/gsthlssink2.c +++ b/ext/hls/gsthlssink2.c @@ -44,6 +44,7 @@ #include "config.h" #endif +#include "gsthlselements.h" #include "gsthlssink2.h" #include #include @@ -97,6 +98,8 @@ static GstStaticPadTemplate audio_template = GST_STATIC_PAD_TEMPLATE ("audio", #define gst_hls_sink2_parent_class parent_class G_DEFINE_TYPE (GstHlsSink2, gst_hls_sink2, GST_TYPE_BIN); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (hlssink2, "hlssink2", GST_RANK_NONE, + GST_TYPE_HLS_SINK2, hls_element_init (plugin)); static void gst_hls_sink2_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * spec); @@ -683,11 +686,3 @@ gst_hls_sink2_get_property (GObject * object, guint prop_id, break; } } - -gboolean -gst_hls_sink2_plugin_init (GstPlugin * plugin) -{ - GST_DEBUG_CATEGORY_INIT (gst_hls_sink2_debug, "hlssink2", 0, "HlsSink2"); - return gst_element_register (plugin, "hlssink2", GST_RANK_NONE, - gst_hls_sink2_get_type ()); -} diff --git a/ext/hls/gstm3u8playlist.c b/ext/hls/gstm3u8playlist.c index c6007020bc..f2f1a5ef64 100644 --- a/ext/hls/gstm3u8playlist.c +++ b/ext/hls/gstm3u8playlist.c @@ -21,8 +21,8 @@ #include -#include "gsthls.h" #include "gstm3u8playlist.h" +#include "gsthlselements.h" #define GST_CAT_DEFAULT hls_debug diff --git a/ext/hls/m3u8.c b/ext/hls/m3u8.c index 7f24226cec..d20e352c3f 100644 --- a/ext/hls/m3u8.c +++ b/ext/hls/m3u8.c @@ -26,8 +26,8 @@ #include #include -#include "gsthls.h" #include "m3u8.h" +#include "gsthlselements.h" #define GST_CAT_DEFAULT hls_debug diff --git a/ext/hls/m3u8.h b/ext/hls/m3u8.h index e7b4fe10c4..aa511360d1 100644 --- a/ext/hls/m3u8.h +++ b/ext/hls/m3u8.h @@ -24,7 +24,7 @@ #ifndef __M3U8_H__ #define __M3U8_H__ -#include +#include G_BEGIN_DECLS diff --git a/ext/hls/meson.build b/ext/hls/meson.build index 3ef45ee039..3444d37e79 100644 --- a/ext/hls/meson.build +++ b/ext/hls/meson.build @@ -1,6 +1,7 @@ hls_sources = [ 'gsthlsdemux.c', 'gsthlsdemux-util.c', + 'gsthlselement.c', 'gsthlsplugin.c', 'gsthlssink.c', 'gsthlssink2.c',