Skip to content

Commit 6b55f97

Browse files
Stéphane CerveauGStreamer Marge Bot
authored andcommitted
adaptivedemux2: fix plugin/element init
In case of per features registration such as the customizable gstreamer-full library, each element should check that the soup library can be loaded to facilitate the element registration. Initialize the debug categories properly Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2348>
1 parent 7acfd0c commit 6b55f97

File tree

11 files changed

+151
-35
lines changed

11 files changed

+151
-35
lines changed

subprojects/gst-plugins-good/ext/adaptivedemux2/dash/gstdashdemux.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@
291291
#include <gst/tag/tag.h>
292292
#include <gst/net/gstnet.h>
293293

294+
#include "gstadaptivedemuxelements.h"
294295
#include "gstdashdemux.h"
295296
#include "gstdash_debug.h"
296297

@@ -467,13 +468,11 @@ gst_dash_demux_stream_class_init (GstDashDemux2StreamClass * klass)
467468

468469

469470
#define gst_dash_demux2_parent_class parent_class
470-
G_DEFINE_TYPE_WITH_CODE (GstDashDemux2, gst_dash_demux2,
471-
GST_TYPE_ADAPTIVE_DEMUX, GST_DEBUG_CATEGORY_INIT (gst_dash_demux2_debug,
472-
"dashdemux2", 0, "dashdemux2 element")
473-
);
471+
G_DEFINE_TYPE (GstDashDemux2, gst_dash_demux2, GST_TYPE_ADAPTIVE_DEMUX);
474472

475-
GST_ELEMENT_REGISTER_DEFINE (dashdemux2, "dashdemux2",
476-
GST_RANK_PRIMARY + 1, GST_TYPE_DASH_DEMUX2);
473+
static gboolean dashdemux2_element_init (GstPlugin * plugin);
474+
475+
GST_ELEMENT_REGISTER_DEFINE_CUSTOM (dashdemux2, dashdemux2_element_init);
477476

478477
static void
479478
gst_dash_demux_dispose (GObject * obj)
@@ -3967,3 +3966,20 @@ gst_dash_demux_get_server_now_utc (GstDashDemux2 * demux)
39673966
g_date_time_unref (client_now);
39683967
return server_now;
39693968
}
3969+
3970+
static gboolean
3971+
dashdemux2_element_init (GstPlugin * plugin)
3972+
{
3973+
gboolean ret = TRUE;
3974+
3975+
GST_DEBUG_CATEGORY_INIT (gst_dash_demux2_debug,
3976+
"dashdemux2", 0, "dashdemux2 element");
3977+
3978+
if (!adaptivedemux2_base_element_init (plugin))
3979+
return TRUE;
3980+
3981+
ret = gst_element_register (plugin, "dashdemux2",
3982+
GST_RANK_PRIMARY + 1, GST_TYPE_DASH_DEMUX2);
3983+
3984+
return ret;
3985+
}

subprojects/gst-plugins-good/ext/adaptivedemux2/dash/gstdashdemux.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ struct _GstDashDemux2Class
165165
GType gst_dash_demux2_get_type (void);
166166
GType gst_dash_demux_stream_get_type (void);
167167

168-
GST_ELEMENT_REGISTER_DECLARE (dashdemux2);
169-
170168
G_END_DECLS
171169
#endif /* __GST_DASH_DEMUX_H__ */
172170

subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ By using the api_lock a thread is protected against other API calls.
109109
#include <gst/base/gstadapter.h>
110110
#include <gst/app/gstappsrc.h>
111111

112-
GST_DEBUG_CATEGORY (adaptivedemux2_debug);
112+
GST_DEBUG_CATEGORY_EXTERN (adaptivedemux2_debug);
113113
#define GST_CAT_DEFAULT adaptivedemux2_debug
114114

115115
#define DEFAULT_FAILED_COUNT 3
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* GStreamer
2+
* Copyright (C) 2021-2022 Jan Schmidt <[email protected]>
3+
*
4+
* This library is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Library General Public
6+
* License as published by the Free Software Foundation; either
7+
* version 2 of the License, or (at your option) any later version.
8+
*
9+
* This library is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* Library General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Library General Public
15+
* License along with this library; if not, write to the
16+
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17+
* Boston, MA 02110-1301, USA.
18+
*/
19+
20+
#ifdef HAVE_CONFIG_H
21+
# include <config.h>
22+
#endif
23+
24+
#include "gstadaptivedemuxelements.h"
25+
#include "../soup/gstsouploader.h"
26+
27+
GST_DEBUG_CATEGORY (adaptivedemux2_debug);
28+
#define GST_CAT_DEFAULT adaptivedemux2_debug
29+
30+
gboolean
31+
adaptivedemux2_base_element_init (GstPlugin * plugin)
32+
{
33+
static gsize res = FALSE;
34+
if (g_once_init_enter (&res)) {
35+
GST_DEBUG_CATEGORY_INIT (adaptivedemux2_debug, "adaptivedemux2", 0,
36+
"adaptivedemux2");
37+
g_once_init_leave (&res, TRUE);
38+
}
39+
#ifndef STATIC_SOUP
40+
if (!gst_soup_load_library ()) {
41+
GST_WARNING ("Failed to load libsoup library");
42+
return FALSE;
43+
}
44+
#endif
45+
return TRUE;
46+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/* GStreamer
2+
* Copyright (C) 2021-2022 Jan Schmidt <[email protected]>
3+
*
4+
* This library is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Library General Public
6+
* License as published by the Free Software Foundation; either
7+
* version 2 of the License, or (at your option) any later version.
8+
*
9+
* This library is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* Library General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Library General Public
15+
* License along with this library; if not, write to the
16+
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17+
* Boston, MA 02110-1301, USA.
18+
*/
19+
20+
#ifndef __GST_ADAPTIVEDEMUX2_ELEMENTS_H__
21+
#define __GST_ADAPTIVEDEMUX2_ELEMENTS_H__
22+
23+
#ifdef HAVE_CONFIG_H
24+
#include <config.h>
25+
#endif
26+
27+
#include <gst/gst.h>
28+
29+
gboolean adaptivedemux2_base_element_init (GstPlugin * plugin);
30+
31+
GST_ELEMENT_REGISTER_DECLARE (mssdemux2);
32+
GST_ELEMENT_REGISTER_DECLARE (hlsdemux2);
33+
GST_ELEMENT_REGISTER_DECLARE (dashdemux2);
34+
35+
#endif

subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include <gst/tag/tag.h>
5252

5353
#include "gsthlselements.h"
54+
#include "gstadaptivedemuxelements.h"
5455
#include "gsthlsdemux.h"
5556

5657
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
@@ -147,8 +148,9 @@ static void gst_hls_demux_stream_finalize (GObject * object);
147148
G_DEFINE_TYPE (GstHLSDemuxStream, gst_hls_demux_stream,
148149
GST_TYPE_ADAPTIVE_DEMUX2_STREAM);
149150

150-
GST_ELEMENT_REGISTER_DEFINE (hlsdemux2, "hlsdemux2",
151-
GST_RANK_PRIMARY + 1, GST_TYPE_HLS_DEMUX2);
151+
static gboolean hlsdemux2_element_init (GstPlugin * plugin);
152+
153+
GST_ELEMENT_REGISTER_DEFINE_CUSTOM (hlsdemux2, hlsdemux2_element_init);
152154

153155
static void
154156
gst_hls_demux_stream_class_init (GstHLSDemuxStreamClass * klass)
@@ -279,9 +281,6 @@ gst_hls_demux2_class_init (GstHLSDemux2Class * klass)
279281
adaptivedemux_class->start_fragment = gst_hls_demux_start_fragment;
280282
adaptivedemux_class->finish_fragment = gst_hls_demux_finish_fragment;
281283
adaptivedemux_class->data_received = gst_hls_demux_data_received;
282-
283-
GST_DEBUG_CATEGORY_INIT (gst_hls_demux2_debug, "hlsdemux2", 0,
284-
"hlsdemux2 element");
285284
}
286285

287286
static void
@@ -2674,3 +2673,20 @@ gst_hls_demux_get_live_seek_range (GstAdaptiveDemux * demux, gint64 * start,
26742673

26752674
return ret;
26762675
}
2676+
2677+
static gboolean
2678+
hlsdemux2_element_init (GstPlugin * plugin)
2679+
{
2680+
gboolean ret = TRUE;
2681+
2682+
GST_DEBUG_CATEGORY_INIT (gst_hls_demux2_debug, "hlsdemux2", 0,
2683+
"hlsdemux2 element");
2684+
2685+
if (!adaptivedemux2_base_element_init (plugin))
2686+
return TRUE;
2687+
2688+
ret = gst_element_register (plugin, "hlsdemux2",
2689+
GST_RANK_PRIMARY + 1, GST_TYPE_HLS_DEMUX2);
2690+
2691+
return ret;
2692+
}

subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,5 @@ GstHLSTimeMap *gst_hls_find_time_map (GstHLSDemux * demux, gint64 dsn);
246246
GType gst_hls_demux2_get_type (void);
247247
GType gst_hls_demux_stream_get_type (void);
248248

249-
GST_ELEMENT_REGISTER_DECLARE (hlsdemux2);
250-
251249
G_END_DECLS
252250
#endif /* __GST_HLS_DEMUX_H__ */

subprojects/gst-plugins-good/ext/adaptivedemux2/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ plugin_sources = [
4141
'plugin.c',
4242
'gstisoff.c',
4343
'gstadaptivedemux.c',
44+
'gstadaptivedemuxelement.c',
4445
'gstadaptivedemuxutils.c',
4546
'gstadaptivedemux-period.c',
4647
'gstadaptivedemux-stream.c',

subprojects/gst-plugins-good/ext/adaptivedemux2/mss/gstmssdemux.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,11 @@
7373
#include <stdlib.h>
7474
#include <string.h>
7575

76+
#include "gstadaptivedemuxelements.h"
7677
#include "gstmssdemux.h"
7778

7879
GST_DEBUG_CATEGORY (mssdemux2_debug);
80+
#define GST_CAT_DEFAULT mssdemux2_debug
7981

8082
static GstStaticPadTemplate gst_mss_demux_sink_template =
8183
GST_STATIC_PAD_TEMPLATE ("sink",
@@ -106,8 +108,9 @@ G_DEFINE_TYPE (GstMssDemux2, gst_mss_demux2, GST_TYPE_ADAPTIVE_DEMUX);
106108
G_DEFINE_TYPE (GstMssDemuxStream, gst_mss_demux_stream,
107109
GST_TYPE_ADAPTIVE_DEMUX2_STREAM);
108110

109-
GST_ELEMENT_REGISTER_DEFINE (mssdemux2, "mssdemux2",
110-
GST_RANK_PRIMARY + 1, GST_TYPE_MSS_DEMUX2);
111+
static gboolean mssdemux_element_init (GstPlugin * plugin);
112+
113+
GST_ELEMENT_REGISTER_DEFINE_CUSTOM (mssdemux2, mssdemux_element_init);
111114

112115
static void gst_mss_demux_dispose (GObject * object);
113116

@@ -204,8 +207,6 @@ gst_mss_demux2_class_init (GstMssDemuxClass * klass)
204207
gstadaptivedemux_class->requires_periodical_playlist_update =
205208
gst_mss_demux_requires_periodical_playlist_update;
206209

207-
GST_DEBUG_CATEGORY_INIT (mssdemux2_debug, "mssdemux2", 0,
208-
"mssdemux2 element");
209210
}
210211

211212
static void
@@ -688,3 +689,21 @@ gst_stream_type_from_mss_type (GstMssStreamType mtype)
688689
return GST_STREAM_TYPE_UNKNOWN;
689690
}
690691
}
692+
693+
static gboolean
694+
mssdemux_element_init (GstPlugin * plugin)
695+
{
696+
gboolean ret = TRUE;
697+
698+
GST_DEBUG_CATEGORY_INIT (mssdemux2_debug, "mssdemux2", 0,
699+
"mssdemux2 element");
700+
701+
if (!adaptivedemux2_base_element_init (plugin))
702+
return TRUE;
703+
704+
ret =
705+
gst_element_register (plugin, "mssdemux2", GST_RANK_PRIMARY + 1,
706+
GST_TYPE_MSS_DEMUX2);
707+
708+
return ret;
709+
}

subprojects/gst-plugins-good/ext/adaptivedemux2/mss/gstmssdemux.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@
3232

3333
G_BEGIN_DECLS
3434

35-
GST_DEBUG_CATEGORY_EXTERN (mssdemux2_debug);
36-
#define GST_CAT_DEFAULT mssdemux2_debug
37-
3835
#define GST_TYPE_MSS_DEMUX2 \
3936
(gst_mss_demux2_get_type())
4037
#define GST_MSS_DEMUX(obj) \
@@ -80,7 +77,7 @@ struct _GstMssDemux2Class {
8077
GType gst_mss_demux2_get_type (void);
8178
GType gst_mss_demux_stream_get_type (void);
8279

83-
GST_ELEMENT_REGISTER_DECLARE (mssdemux2);
80+
8481
G_END_DECLS
8582

8683
#endif /* __GST_MSSDEMUX_H__ */

0 commit comments

Comments
 (0)