From 58779e7538d80d526d9802922a4c34986c1097cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Fri, 12 Feb 2021 16:04:16 +0100 Subject: [PATCH] soup: 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/soup/gstsoup.c | 36 +++----------------- ext/soup/gstsoupelement.c | 58 ++++++++++++++++++++++++++++++++ ext/soup/gstsoupelements.h | 34 +++++++++++++++++++ ext/soup/gstsouphttpclientsink.c | 3 ++ ext/soup/gstsouphttpsrc.c | 3 ++ ext/soup/meson.build | 1 + 6 files changed, 104 insertions(+), 31 deletions(-) create mode 100644 ext/soup/gstsoupelement.c create mode 100644 ext/soup/gstsoupelements.h diff --git a/ext/soup/gstsoup.c b/ext/soup/gstsoup.c index 3be491d2e5..47046ccb3d 100644 --- a/ext/soup/gstsoup.c +++ b/ext/soup/gstsoup.c @@ -18,43 +18,17 @@ #include -#include "gstsouphttpsrc.h" -#include "gstsouphttpclientsink.h" -#include "gstsouputils.h" - -GST_DEBUG_CATEGORY (soup_utils_debug); +#include "gstsoupelements.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 + gboolean ret = FALSE; - /* see https://bugzilla.gnome.org/show_bug.cgi?id=674885 */ - g_type_ensure (G_TYPE_SOCKET); - g_type_ensure (G_TYPE_SOCKET_ADDRESS); - g_type_ensure (G_TYPE_SOCKET_SERVICE); - g_type_ensure (G_TYPE_SOCKET_FAMILY); - g_type_ensure (G_TYPE_SOCKET_CLIENT); - g_type_ensure (G_TYPE_RESOLVER); - g_type_ensure (G_TYPE_PROXY_RESOLVER); - g_type_ensure (G_TYPE_PROXY_ADDRESS); - g_type_ensure (G_TYPE_TLS_CERTIFICATE); - g_type_ensure (G_TYPE_TLS_CONNECTION); - g_type_ensure (G_TYPE_TLS_DATABASE); - g_type_ensure (G_TYPE_TLS_INTERACTION); + ret |= GST_ELEMENT_REGISTER (souphttpsrc, plugin); + ret |= GST_ELEMENT_REGISTER (souphttpclientsink, plugin); - gst_element_register (plugin, "souphttpsrc", GST_RANK_PRIMARY, - GST_TYPE_SOUP_HTTP_SRC); - gst_element_register (plugin, "souphttpclientsink", GST_RANK_NONE, - GST_TYPE_SOUP_HTTP_CLIENT_SINK); - GST_DEBUG_CATEGORY_INIT (soup_utils_debug, "souputils", 0, "Soup utils"); - - return TRUE; + return ret; } GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, diff --git a/ext/soup/gstsoupelement.c b/ext/soup/gstsoupelement.c new file mode 100644 index 0000000000..d8e8ea48de --- /dev/null +++ b/ext/soup/gstsoupelement.c @@ -0,0 +1,58 @@ +/* GStreamer + * Copyright (C) 2007-2008 Wouter Cloetens + * + * 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 + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "gstsoupelements.h" +#include "gstsouphttpsrc.h" +#include "gstsouphttpclientsink.h" +#include "gstsouputils.h" + +GST_DEBUG_CATEGORY (soup_utils_debug); + +void +soup_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 + + /* see https://bugzilla.gnome.org/show_bug.cgi?id=674885 */ + g_type_ensure (G_TYPE_SOCKET); + g_type_ensure (G_TYPE_SOCKET_ADDRESS); + g_type_ensure (G_TYPE_SOCKET_SERVICE); + g_type_ensure (G_TYPE_SOCKET_FAMILY); + g_type_ensure (G_TYPE_SOCKET_CLIENT); + g_type_ensure (G_TYPE_RESOLVER); + g_type_ensure (G_TYPE_PROXY_RESOLVER); + g_type_ensure (G_TYPE_PROXY_ADDRESS); + g_type_ensure (G_TYPE_TLS_CERTIFICATE); + g_type_ensure (G_TYPE_TLS_CONNECTION); + g_type_ensure (G_TYPE_TLS_DATABASE); + g_type_ensure (G_TYPE_TLS_INTERACTION); + + g_once_init_leave (&res, TRUE); + GST_DEBUG_CATEGORY_INIT (soup_utils_debug, "souputils", 0, "Soup utils"); + } +} diff --git a/ext/soup/gstsoupelements.h b/ext/soup/gstsoupelements.h new file mode 100644 index 0000000000..17b9c80e61 --- /dev/null +++ b/ext/soup/gstsoupelements.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2020 Huawei Technologies Co., Ltd. + * @Author: 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_SOUP_ELEMENTS_H__ +#define __GST_SOUP_ELEMENTS_H__ + +#include + +G_BEGIN_DECLS + +void soup_element_init (GstPlugin * plugin); + +GST_ELEMENT_REGISTER_DECLARE (souphttpsrc); +GST_ELEMENT_REGISTER_DECLARE (souphttpclientsink); + +G_END_DECLS + +#endif /* __GST_SOUP_ELEMENTS_H__ */ diff --git a/ext/soup/gstsouphttpclientsink.c b/ext/soup/gstsouphttpclientsink.c index 17c69f5ca4..9768f3c778 100644 --- a/ext/soup/gstsouphttpclientsink.c +++ b/ext/soup/gstsouphttpclientsink.c @@ -40,6 +40,7 @@ #include #include +#include "gstsoupelements.h" #include "gstsouphttpclientsink.h" #include "gstsouputils.h" @@ -114,6 +115,8 @@ 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 void gst_soup_http_client_sink_class_init (GstSoupHttpClientSinkClass * klass) diff --git a/ext/soup/gstsouphttpsrc.c b/ext/soup/gstsouphttpsrc.c index a89922293f..e1f2f6d0ef 100644 --- a/ext/soup/gstsouphttpsrc.c +++ b/ext/soup/gstsouphttpsrc.c @@ -78,6 +78,7 @@ #include #include #include +#include "gstsoupelements.h" #include "gstsouphttpsrc.h" #include "gstsouputils.h" @@ -192,6 +193,8 @@ static void gst_soup_http_src_authenticate_cb (SoupSession * session, 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 void gst_soup_http_src_class_init (GstSoupHTTPSrcClass * klass) diff --git a/ext/soup/meson.build b/ext/soup/meson.build index 03cff4cf0d..9eaa60b52d 100644 --- a/ext/soup/meson.build +++ b/ext/soup/meson.build @@ -2,6 +2,7 @@ soup_sources = [ 'gstsouphttpsrc.c', 'gstsouphttpclientsink.c', 'gstsouputils.c', + 'gstsoupelement.c', 'gstsoup.c', ]