diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/dash/gstdashdemux.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/dash/gstdashdemux.c index c142d2b450..9eef0062de 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/dash/gstdashdemux.c +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/dash/gstdashdemux.c @@ -291,6 +291,7 @@ #include #include +#include "gstadaptivedemuxelements.h" #include "gstdashdemux.h" #include "gstdash_debug.h" @@ -467,13 +468,11 @@ gst_dash_demux_stream_class_init (GstDashDemux2StreamClass * klass) #define gst_dash_demux2_parent_class parent_class -G_DEFINE_TYPE_WITH_CODE (GstDashDemux2, gst_dash_demux2, - GST_TYPE_ADAPTIVE_DEMUX, GST_DEBUG_CATEGORY_INIT (gst_dash_demux2_debug, - "dashdemux2", 0, "dashdemux2 element") - ); +G_DEFINE_TYPE (GstDashDemux2, gst_dash_demux2, GST_TYPE_ADAPTIVE_DEMUX); -GST_ELEMENT_REGISTER_DEFINE (dashdemux2, "dashdemux2", - GST_RANK_PRIMARY + 1, GST_TYPE_DASH_DEMUX2); +static gboolean dashdemux2_element_init (GstPlugin * plugin); + +GST_ELEMENT_REGISTER_DEFINE_CUSTOM (dashdemux2, dashdemux2_element_init); static void gst_dash_demux_dispose (GObject * obj) @@ -3967,3 +3966,20 @@ gst_dash_demux_get_server_now_utc (GstDashDemux2 * demux) g_date_time_unref (client_now); return server_now; } + +static gboolean +dashdemux2_element_init (GstPlugin * plugin) +{ + gboolean ret = TRUE; + + GST_DEBUG_CATEGORY_INIT (gst_dash_demux2_debug, + "dashdemux2", 0, "dashdemux2 element"); + + if (!adaptivedemux2_base_element_init (plugin)) + return TRUE; + + ret = gst_element_register (plugin, "dashdemux2", + GST_RANK_PRIMARY + 1, GST_TYPE_DASH_DEMUX2); + + return ret; +} diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/dash/gstdashdemux.h b/subprojects/gst-plugins-good/ext/adaptivedemux2/dash/gstdashdemux.h index 44307da7a8..24d1ebbc7e 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/dash/gstdashdemux.h +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/dash/gstdashdemux.h @@ -165,8 +165,6 @@ struct _GstDashDemux2Class GType gst_dash_demux2_get_type (void); GType gst_dash_demux_stream_get_type (void); -GST_ELEMENT_REGISTER_DECLARE (dashdemux2); - G_END_DECLS #endif /* __GST_DASH_DEMUX_H__ */ diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux.c index 6588112dca..1d39a3f7f0 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux.c +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux.c @@ -109,7 +109,7 @@ By using the api_lock a thread is protected against other API calls. #include #include -GST_DEBUG_CATEGORY (adaptivedemux2_debug); +GST_DEBUG_CATEGORY_EXTERN (adaptivedemux2_debug); #define GST_CAT_DEFAULT adaptivedemux2_debug #define DEFAULT_FAILED_COUNT 3 diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemuxelement.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemuxelement.c new file mode 100644 index 0000000000..1d8f53769c --- /dev/null +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemuxelement.c @@ -0,0 +1,46 @@ +/* GStreamer + * Copyright (C) 2021-2022 Jan Schmidt + * + * 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 "gstadaptivedemuxelements.h" +#include "../soup/gstsouploader.h" + +GST_DEBUG_CATEGORY (adaptivedemux2_debug); +#define GST_CAT_DEFAULT adaptivedemux2_debug + +gboolean +adaptivedemux2_base_element_init (GstPlugin * plugin) +{ + static gsize res = FALSE; + if (g_once_init_enter (&res)) { + GST_DEBUG_CATEGORY_INIT (adaptivedemux2_debug, "adaptivedemux2", 0, + "adaptivedemux2"); + g_once_init_leave (&res, TRUE); + } +#ifndef STATIC_SOUP + if (!gst_soup_load_library ()) { + GST_WARNING ("Failed to load libsoup library"); + return FALSE; + } +#endif + return TRUE; +} diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemuxelements.h b/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemuxelements.h new file mode 100644 index 0000000000..50487ebb60 --- /dev/null +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemuxelements.h @@ -0,0 +1,35 @@ +/* GStreamer + * Copyright (C) 2021-2022 Jan Schmidt + * + * 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_ADAPTIVEDEMUX2_ELEMENTS_H__ +#define __GST_ADAPTIVEDEMUX2_ELEMENTS_H__ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +gboolean adaptivedemux2_base_element_init (GstPlugin * plugin); + +GST_ELEMENT_REGISTER_DECLARE (mssdemux2); +GST_ELEMENT_REGISTER_DECLARE (hlsdemux2); +GST_ELEMENT_REGISTER_DECLARE (dashdemux2); + +#endif diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.c index 67051d1bb2..d9838faa7d 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.c +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.c @@ -51,6 +51,7 @@ #include #include "gsthlselements.h" +#include "gstadaptivedemuxelements.h" #include "gsthlsdemux.h" static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", @@ -147,8 +148,9 @@ static void gst_hls_demux_stream_finalize (GObject * object); G_DEFINE_TYPE (GstHLSDemuxStream, gst_hls_demux_stream, GST_TYPE_ADAPTIVE_DEMUX2_STREAM); -GST_ELEMENT_REGISTER_DEFINE (hlsdemux2, "hlsdemux2", - GST_RANK_PRIMARY + 1, GST_TYPE_HLS_DEMUX2); +static gboolean hlsdemux2_element_init (GstPlugin * plugin); + +GST_ELEMENT_REGISTER_DEFINE_CUSTOM (hlsdemux2, hlsdemux2_element_init); static void gst_hls_demux_stream_class_init (GstHLSDemuxStreamClass * klass) @@ -279,9 +281,6 @@ gst_hls_demux2_class_init (GstHLSDemux2Class * klass) adaptivedemux_class->start_fragment = gst_hls_demux_start_fragment; adaptivedemux_class->finish_fragment = gst_hls_demux_finish_fragment; adaptivedemux_class->data_received = gst_hls_demux_data_received; - - GST_DEBUG_CATEGORY_INIT (gst_hls_demux2_debug, "hlsdemux2", 0, - "hlsdemux2 element"); } static void @@ -2674,3 +2673,20 @@ gst_hls_demux_get_live_seek_range (GstAdaptiveDemux * demux, gint64 * start, return ret; } + +static gboolean +hlsdemux2_element_init (GstPlugin * plugin) +{ + gboolean ret = TRUE; + + GST_DEBUG_CATEGORY_INIT (gst_hls_demux2_debug, "hlsdemux2", 0, + "hlsdemux2 element"); + + if (!adaptivedemux2_base_element_init (plugin)) + return TRUE; + + ret = gst_element_register (plugin, "hlsdemux2", + GST_RANK_PRIMARY + 1, GST_TYPE_HLS_DEMUX2); + + return ret; +} diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.h b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.h index 3a0109d590..041e93b01b 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.h +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.h @@ -246,7 +246,5 @@ GstHLSTimeMap *gst_hls_find_time_map (GstHLSDemux * demux, gint64 dsn); GType gst_hls_demux2_get_type (void); GType gst_hls_demux_stream_get_type (void); -GST_ELEMENT_REGISTER_DECLARE (hlsdemux2); - G_END_DECLS #endif /* __GST_HLS_DEMUX_H__ */ diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/meson.build b/subprojects/gst-plugins-good/ext/adaptivedemux2/meson.build index 61fc394450..4d8f50ada0 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/meson.build +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/meson.build @@ -41,6 +41,7 @@ plugin_sources = [ 'plugin.c', 'gstisoff.c', 'gstadaptivedemux.c', + 'gstadaptivedemuxelement.c', 'gstadaptivedemuxutils.c', 'gstadaptivedemux-period.c', 'gstadaptivedemux-stream.c', diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/mss/gstmssdemux.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/mss/gstmssdemux.c index 14d2a8b6f3..2829429578 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/mss/gstmssdemux.c +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/mss/gstmssdemux.c @@ -73,9 +73,11 @@ #include #include +#include "gstadaptivedemuxelements.h" #include "gstmssdemux.h" GST_DEBUG_CATEGORY (mssdemux2_debug); +#define GST_CAT_DEFAULT mssdemux2_debug static GstStaticPadTemplate gst_mss_demux_sink_template = GST_STATIC_PAD_TEMPLATE ("sink", @@ -106,8 +108,9 @@ G_DEFINE_TYPE (GstMssDemux2, gst_mss_demux2, GST_TYPE_ADAPTIVE_DEMUX); G_DEFINE_TYPE (GstMssDemuxStream, gst_mss_demux_stream, GST_TYPE_ADAPTIVE_DEMUX2_STREAM); -GST_ELEMENT_REGISTER_DEFINE (mssdemux2, "mssdemux2", - GST_RANK_PRIMARY + 1, GST_TYPE_MSS_DEMUX2); +static gboolean mssdemux_element_init (GstPlugin * plugin); + +GST_ELEMENT_REGISTER_DEFINE_CUSTOM (mssdemux2, mssdemux_element_init); static void gst_mss_demux_dispose (GObject * object); @@ -204,8 +207,6 @@ gst_mss_demux2_class_init (GstMssDemuxClass * klass) gstadaptivedemux_class->requires_periodical_playlist_update = gst_mss_demux_requires_periodical_playlist_update; - GST_DEBUG_CATEGORY_INIT (mssdemux2_debug, "mssdemux2", 0, - "mssdemux2 element"); } static void @@ -688,3 +689,21 @@ gst_stream_type_from_mss_type (GstMssStreamType mtype) return GST_STREAM_TYPE_UNKNOWN; } } + +static gboolean +mssdemux_element_init (GstPlugin * plugin) +{ + gboolean ret = TRUE; + + GST_DEBUG_CATEGORY_INIT (mssdemux2_debug, "mssdemux2", 0, + "mssdemux2 element"); + + if (!adaptivedemux2_base_element_init (plugin)) + return TRUE; + + ret = + gst_element_register (plugin, "mssdemux2", GST_RANK_PRIMARY + 1, + GST_TYPE_MSS_DEMUX2); + + return ret; +} diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/mss/gstmssdemux.h b/subprojects/gst-plugins-good/ext/adaptivedemux2/mss/gstmssdemux.h index 2d12119a4e..c1331bcd4f 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/mss/gstmssdemux.h +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/mss/gstmssdemux.h @@ -32,9 +32,6 @@ G_BEGIN_DECLS -GST_DEBUG_CATEGORY_EXTERN (mssdemux2_debug); -#define GST_CAT_DEFAULT mssdemux2_debug - #define GST_TYPE_MSS_DEMUX2 \ (gst_mss_demux2_get_type()) #define GST_MSS_DEMUX(obj) \ @@ -80,7 +77,7 @@ struct _GstMssDemux2Class { GType gst_mss_demux2_get_type (void); GType gst_mss_demux_stream_get_type (void); -GST_ELEMENT_REGISTER_DECLARE (mssdemux2); + G_END_DECLS #endif /* __GST_MSSDEMUX_H__ */ diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/plugin.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/plugin.c index ade4053954..b13816bafe 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/plugin.c +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/plugin.c @@ -21,23 +21,13 @@ # include #endif -#include "dash/gstdashdemux.h" -#include "hls/gsthlsdemux.h" -#include "mss/gstmssdemux.h" -#include "../soup/gstsouploader.h" +#include "gstadaptivedemuxelements.h" static gboolean plugin_init (GstPlugin * plugin) { gboolean ret = TRUE; -#ifndef STATIC_SOUP - if (!gst_soup_load_library ()) { - GST_WARNING ("Failed to load libsoup library"); - return TRUE; - } -#endif - ret |= GST_ELEMENT_REGISTER (hlsdemux2, plugin); ret |= GST_ELEMENT_REGISTER (dashdemux2, plugin); ret |= GST_ELEMENT_REGISTER (mssdemux2, plugin);