From cd8c3a2e53b26f777bb171da2e56429542bfcf58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Tue, 16 Feb 2021 14:35:51 +0100 Subject: [PATCH] rtsp: 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: --- gst/rtsp/gstrtpdec.c | 3 ++ gst/rtsp/gstrtsp.c | 19 ++----- gst/rtsp/gstrtspelement.c | 65 +++++++++++++++++++++++ gst/rtsp/{gstrtsp.h => gstrtspelements.h} | 17 ++++-- gst/rtsp/gstrtspsrc.c | 3 ++ gst/rtsp/meson.build | 1 + 6 files changed, 90 insertions(+), 18 deletions(-) create mode 100644 gst/rtsp/gstrtspelement.c rename gst/rtsp/{gstrtsp.h => gstrtspelements.h} (87%) diff --git a/gst/rtsp/gstrtpdec.c b/gst/rtsp/gstrtpdec.c index f8c56763c3..c5550ce362 100644 --- a/gst/rtsp/gstrtpdec.c +++ b/gst/rtsp/gstrtpdec.c @@ -56,6 +56,7 @@ #include #endif +#include "gstrtspelements.h" #include "gstrtpdec.h" #include @@ -196,6 +197,8 @@ static guint gst_rtp_dec_signals[LAST_SIGNAL] = { 0 }; #define gst_rtp_dec_parent_class parent_class G_DEFINE_TYPE (GstRTPDec, gst_rtp_dec, GST_TYPE_ELEMENT); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (rtpdec, "rtpdec", GST_RANK_NONE, + GST_TYPE_RTP_DEC, rtsp_element_init (plugin)); static void gst_rtp_dec_class_init (GstRTPDecClass * g_class) diff --git a/gst/rtsp/gstrtsp.c b/gst/rtsp/gstrtsp.c index 66e2c3f6d4..89bb88ae9b 100644 --- a/gst/rtsp/gstrtsp.c +++ b/gst/rtsp/gstrtsp.c @@ -45,26 +45,17 @@ #include "config.h" #endif -#include "gst/gst-i18n-plugin.h" - -#include "gstrtpdec.h" -#include "gstrtspsrc.h" +#include "gstrtspelements.h" static gboolean plugin_init (GstPlugin * plugin) { -#ifdef ENABLE_NLS - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); -#endif /* ENABLE_NLS */ + gboolean ret = FALSE; - if (!gst_element_register (plugin, "rtspsrc", GST_RANK_NONE, - GST_TYPE_RTSPSRC)) - return FALSE; - if (!gst_element_register (plugin, "rtpdec", GST_RANK_NONE, GST_TYPE_RTP_DEC)) - return FALSE; + ret |= GST_ELEMENT_REGISTER (rtspsrc, plugin); + ret |= GST_ELEMENT_REGISTER (rtpdec, plugin); - return TRUE; + return ret; } GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, diff --git a/gst/rtsp/gstrtspelement.c b/gst/rtsp/gstrtspelement.c new file mode 100644 index 0000000000..f296a4b0d4 --- /dev/null +++ b/gst/rtsp/gstrtspelement.c @@ -0,0 +1,65 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen + * <2006> Wim Taymans + * Copyright (C) 2020 Huawei Technologies Co., Ltd. + * @Author: Stéphane Cerveau + * + * 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. + */ +/* + * Unless otherwise indicated, Source Code is licensed under MIT license. + * See further explanation attached in License Statement (distributed in the file + * LICENSE). + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "gst/gst-i18n-plugin.h" + +#include "gstrtspelements.h" + +void +rtsp_element_init (GstPlugin * plugin) +{ + static gsize res = FALSE; + if (g_once_init_enter (&res)) { +#ifdef ENABLE_NLS + bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); +#endif /* ENABLE_NLS */ + g_once_init_leave (&res, TRUE); + } +} diff --git a/gst/rtsp/gstrtsp.h b/gst/rtsp/gstrtspelements.h similarity index 87% rename from gst/rtsp/gstrtsp.h rename to gst/rtsp/gstrtspelements.h index e0f5ef8e02..cfab82aab6 100644 --- a/gst/rtsp/gstrtsp.h +++ b/gst/rtsp/gstrtspelements.h @@ -41,13 +41,22 @@ * SOFTWARE. */ -#ifndef __GST_RTSP_H__ -#define __GST_RTSP_H__ +#ifndef __GST_RTSP_ELEMENTS_H__ +#define __GST_RTSP_ELEMENTS_H__ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include G_BEGIN_DECLS +void rtsp_element_init (GstPlugin * plugin); + +GST_ELEMENT_REGISTER_DECLARE (rtspsrc); +GST_ELEMENT_REGISTER_DECLARE (rtpdec); G_END_DECLS -#endif /* __GST_RTSP_H__ */ - +#endif /* __GST_RTSP_ELEMENTS_H__ */ diff --git a/gst/rtsp/gstrtspsrc.c b/gst/rtsp/gstrtspsrc.c index e4e966e724..e66a6adedc 100644 --- a/gst/rtsp/gstrtspsrc.c +++ b/gst/rtsp/gstrtspsrc.c @@ -114,6 +114,7 @@ #include "gst/gst-i18n-plugin.h" +#include "gstrtspelements.h" #include "gstrtspsrc.h" GST_DEBUG_CATEGORY_STATIC (rtspsrc_debug); @@ -479,6 +480,8 @@ static guint gst_rtspsrc_signals[LAST_SIGNAL] = { 0 }; #define gst_rtspsrc_parent_class parent_class G_DEFINE_TYPE_WITH_CODE (GstRTSPSrc, gst_rtspsrc, GST_TYPE_BIN, G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER, gst_rtspsrc_uri_handler_init)); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (rtspsrc, "rtspsrc", GST_RANK_NONE, + GST_TYPE_RTSPSRC, rtsp_element_init (plugin)); #ifndef GST_DISABLE_GST_DEBUG static inline const char * diff --git a/gst/rtsp/meson.build b/gst/rtsp/meson.build index 372b883f0e..d60d9a975c 100644 --- a/gst/rtsp/meson.build +++ b/gst/rtsp/meson.build @@ -1,4 +1,5 @@ rtsp_sources = [ + 'gstrtspelement.c', 'gstrtsp.c', 'gstrtspsrc.c', 'gstrtpdec.c',