From: Stéphane Cerveau Date: Tue, 3 May 2022 09:34:15 +0000 (+0200) Subject: soup: Fix plugin/element init X-Git-Tag: 1.22.0~1578 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=39b13fcdbd29227504190530f878219b642b0af6;p=platform%2Fupstream%2Fgstreamer.git soup: 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 category properly Part-of: --- diff --git a/subprojects/gst-plugins-good/ext/soup/gstsoup.c b/subprojects/gst-plugins-good/ext/soup/gstsoup.c index 4fb1816..c993c6c 100644 --- a/subprojects/gst-plugins-good/ext/soup/gstsoup.c +++ b/subprojects/gst-plugins-good/ext/soup/gstsoup.c @@ -31,15 +31,6 @@ plugin_init (GstPlugin * plugin) { gboolean ret = FALSE; - GST_DEBUG_CATEGORY_INIT (gst_soup_debug, "soup", 0, "soup"); - -#ifndef STATIC_SOUP - if (!gst_soup_load_library ()) { - GST_WARNING ("Failed to load libsoup library"); - return TRUE; - } -#endif - ret |= GST_ELEMENT_REGISTER (souphttpsrc, plugin); ret |= GST_ELEMENT_REGISTER (souphttpclientsink, plugin); diff --git a/subprojects/gst-plugins-good/ext/soup/gstsoupelement.c b/subprojects/gst-plugins-good/ext/soup/gstsoupelement.c index 7558d72..7451006 100644 --- a/subprojects/gst-plugins-good/ext/soup/gstsoupelement.c +++ b/subprojects/gst-plugins-good/ext/soup/gstsoupelement.c @@ -25,7 +25,7 @@ GST_DEBUG_CATEGORY (soup_utils_debug); -void +gboolean soup_element_init (GstPlugin * plugin) { static gsize res = FALSE; @@ -55,4 +55,11 @@ soup_element_init (GstPlugin * plugin) 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/soup/gstsoupelements.h b/subprojects/gst-plugins-good/ext/soup/gstsoupelements.h index 17b9c80..1cd3aa3 100644 --- a/subprojects/gst-plugins-good/ext/soup/gstsoupelements.h +++ b/subprojects/gst-plugins-good/ext/soup/gstsoupelements.h @@ -24,7 +24,7 @@ G_BEGIN_DECLS -void soup_element_init (GstPlugin * plugin); +gboolean soup_element_init (GstPlugin * plugin); GST_ELEMENT_REGISTER_DECLARE (souphttpsrc); GST_ELEMENT_REGISTER_DECLARE (souphttpclientsink); diff --git a/subprojects/gst-plugins-good/ext/soup/gstsouphttpclientsink.c b/subprojects/gst-plugins-good/ext/soup/gstsouphttpclientsink.c index e846596..caff7dd 100644 --- a/subprojects/gst-plugins-good/ext/soup/gstsouphttpclientsink.c +++ b/subprojects/gst-plugins-good/ext/soup/gstsouphttpclientsink.c @@ -115,8 +115,11 @@ GST_STATIC_PAD_TEMPLATE ("sink", #define gst_soup_http_client_sink_parent_class parent_class G_DEFINE_TYPE (GstSoupHttpClientSink, gst_soup_http_client_sink, GST_TYPE_BASE_SINK); -GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (souphttpclientsink, "souphttpclientsink", - GST_RANK_NONE, GST_TYPE_SOUP_HTTP_CLIENT_SINK, soup_element_init (plugin)); + +static gboolean souphttpclientsink_element_init (GstPlugin * plugin); +GST_ELEMENT_REGISTER_DEFINE_CUSTOM (souphttpclientsink, + souphttpclientsink_element_init); + static void gst_soup_http_client_sink_class_init (GstSoupHttpClientSinkClass * klass) @@ -211,9 +214,6 @@ gst_soup_http_client_sink_class_init (GstSoupHttpClientSinkClass * klass) GST_DEBUG_FUNCPTR (gst_soup_http_client_sink_unlock); base_sink_class->render = GST_DEBUG_FUNCPTR (gst_soup_http_client_sink_render); - - GST_DEBUG_CATEGORY_INIT (souphttpclientsink_dbg, "souphttpclientsink", 0, - "souphttpclientsink element"); } static void @@ -912,3 +912,21 @@ authenticate (SoupMessage * msg, SoupAuth * auth, } return FALSE; } + +static gboolean +souphttpclientsink_element_init (GstPlugin * plugin) +{ + gboolean ret = TRUE; + + GST_DEBUG_CATEGORY_INIT (souphttpclientsink_dbg, "souphttpclientsink", 0, + "souphttpclientsink element"); + + if (!soup_element_init (plugin)) + return TRUE; + + ret = + gst_element_register (plugin, "souphttpclientsink", GST_RANK_NONE, + GST_TYPE_SOUP_HTTP_CLIENT_SINK); + + return ret; +} diff --git a/subprojects/gst-plugins-good/ext/soup/gstsouphttpsrc.c b/subprojects/gst-plugins-good/ext/soup/gstsouphttpsrc.c index 094ca76..aa50979 100644 --- a/subprojects/gst-plugins-good/ext/soup/gstsouphttpsrc.c +++ b/subprojects/gst-plugins-good/ext/soup/gstsouphttpsrc.c @@ -272,8 +272,9 @@ static gboolean gst_soup_http_src_accept_certificate_cb (SoupMessage * msg, G_DEFINE_TYPE_WITH_CODE (GstSoupHTTPSrc, gst_soup_http_src, GST_TYPE_PUSH_SRC, G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER, gst_soup_http_src_uri_handler_init)); -GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (souphttpsrc, "souphttpsrc", - GST_RANK_PRIMARY, GST_TYPE_SOUP_HTTP_SRC, soup_element_init (plugin)); + +static gboolean souphttpsrc_element_init (GstPlugin * plugin); +GST_ELEMENT_REGISTER_DEFINE_CUSTOM (souphttpsrc, souphttpsrc_element_init); static void gst_soup_http_src_class_init (GstSoupHTTPSrcClass * klass) @@ -519,9 +520,6 @@ gst_soup_http_src_class_init (GstSoupHTTPSrcClass * klass) gstbasesrc_class->query = GST_DEBUG_FUNCPTR (gst_soup_http_src_query); gstpushsrc_class->create = GST_DEBUG_FUNCPTR (gst_soup_http_src_create); - - GST_DEBUG_CATEGORY_INIT (souphttpsrc_debug, "souphttpsrc", 0, - "SOUP HTTP src"); } static void @@ -2631,3 +2629,20 @@ gst_soup_http_src_uri_handler_init (gpointer g_iface, gpointer iface_data) iface->get_uri = gst_soup_http_src_uri_get_uri; iface->set_uri = gst_soup_http_src_uri_set_uri; } + +static gboolean +souphttpsrc_element_init (GstPlugin * plugin) +{ + gboolean ret = TRUE; + + GST_DEBUG_CATEGORY_INIT (souphttpsrc_debug, "souphttpsrc", 0, + "SOUP HTTP src"); + + if (!soup_element_init (plugin)) + return TRUE; + + ret = gst_element_register (plugin, "souphttpsrc", + GST_RANK_PRIMARY, GST_TYPE_SOUP_HTTP_SRC); + + return ret; +}