From 55490732bea4c5703dbc5367ba4af7df91ff5e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Tue, 16 Feb 2021 16:11:36 +0100 Subject: [PATCH] oss: 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: --- sys/oss/gstossaudio.c | 20 +++------------ sys/oss/gstossaudioelement.c | 47 +++++++++++++++++++++++++++++++++++ sys/oss/gstossaudioelements.h | 39 +++++++++++++++++++++++++++++ sys/oss/gstosssink.c | 3 +++ sys/oss/gstosssrc.c | 3 +++ sys/oss/meson.build | 2 +- 6 files changed, 97 insertions(+), 17 deletions(-) create mode 100644 sys/oss/gstossaudioelement.c create mode 100644 sys/oss/gstossaudioelements.h diff --git a/sys/oss/gstossaudio.c b/sys/oss/gstossaudio.c index 7194e2e84e..5d476b4c9b 100644 --- a/sys/oss/gstossaudio.c +++ b/sys/oss/gstossaudio.c @@ -24,30 +24,18 @@ #include "gst/gst-i18n-plugin.h" #include "common.h" +#include "gstossaudioelements.h" #include "gstosssink.h" #include "gstosssrc.h" -GST_DEBUG_CATEGORY (oss_debug); -#define GST_CAT_DEFAULT oss_debug static gboolean plugin_init (GstPlugin * plugin) { - if (!gst_element_register (plugin, "osssrc", GST_RANK_SECONDARY, - GST_TYPE_OSS_SRC) || - !gst_element_register (plugin, "osssink", GST_RANK_SECONDARY, - GST_TYPE_OSSSINK)) { - return FALSE; - } + gboolean ret = FALSE; - GST_DEBUG_CATEGORY_INIT (oss_debug, "oss", 0, "OSS elements"); - -#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 /* ENABLE_NLS */ + ret |= GST_ELEMENT_REGISTER (osssrc, plugin); + ret |= GST_ELEMENT_REGISTER (osssink, plugin); return TRUE; } diff --git a/sys/oss/gstossaudioelement.c b/sys/oss/gstossaudioelement.c new file mode 100644 index 0000000000..1793bca4f4 --- /dev/null +++ b/sys/oss/gstossaudioelement.c @@ -0,0 +1,47 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen + * + * 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 "config.h" +#endif + +#include "gst/gst-i18n-plugin.h" + +#include "common.h" +#include "gstossaudioelements.h" + +GST_DEBUG_CATEGORY (oss_debug); +#define GST_CAT_DEFAULT oss_debug + +void +oss_element_init (GstPlugin * plugin) +{ + static gsize res = FALSE; + if (g_once_init_enter (&res)) { + GST_DEBUG_CATEGORY_INIT (oss_debug, "oss", 0, "OSS elements"); + +#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 /* ENABLE_NLS */ + g_once_init_leave (&res, TRUE); + } +} diff --git a/sys/oss/gstossaudioelements.h b/sys/oss/gstossaudioelements.h new file mode 100644 index 0000000000..4770a76c6e --- /dev/null +++ b/sys/oss/gstossaudioelements.h @@ -0,0 +1,39 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen + * 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_OSS_ELEMENTS_H__ +#define __GST_OSS_ELEMENTS_H__ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +G_BEGIN_DECLS + +G_GNUC_INTERNAL void oss_element_init (GstPlugin * plugin); + +GST_ELEMENT_REGISTER_DECLARE (osssink); +GST_ELEMENT_REGISTER_DECLARE (osssrc); + +G_END_DECLS + +#endif /* __GST_OSS_ELEMENTS_H__ */ diff --git a/sys/oss/gstosssink.c b/sys/oss/gstosssink.c index 75b2cf7885..bae8edf1dc 100644 --- a/sys/oss/gstosssink.c +++ b/sys/oss/gstosssink.c @@ -66,6 +66,7 @@ #endif /* HAVE_OSS_INCLUDE_IN_SYS */ #include "common.h" +#include "gstossaudioelements.h" #include "gstosssink.h" #include @@ -128,6 +129,8 @@ static GstStaticPadTemplate osssink_sink_factory = #define gst_oss_sink_parent_class parent_class G_DEFINE_TYPE (GstOssSink, gst_oss_sink, GST_TYPE_AUDIO_SINK); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (osssink, "osssink", GST_RANK_SECONDARY, + GST_TYPE_OSSSINK, oss_element_init (plugin)); static void gst_oss_sink_dispose (GObject * object) diff --git a/sys/oss/gstosssrc.c b/sys/oss/gstosssrc.c index c4c55f9047..a34e1ee87f 100644 --- a/sys/oss/gstosssrc.c +++ b/sys/oss/gstosssrc.c @@ -60,6 +60,7 @@ #endif /* HAVE_OSS_INCLUDE_IN_SYS */ #include "common.h" +#include "gstossaudioelements.h" #include "gstosssrc.h" #include @@ -79,6 +80,8 @@ enum #define gst_oss_src_parent_class parent_class G_DEFINE_TYPE (GstOssSrc, gst_oss_src, GST_TYPE_AUDIO_SRC); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (osssrc, "osssrc", GST_RANK_SECONDARY, + GST_TYPE_OSS_SRC, oss_element_init (plugin)); static void gst_oss_src_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); diff --git a/sys/oss/meson.build b/sys/oss/meson.build index 8f8e81ce66..51cc4d34c6 100644 --- a/sys/oss/meson.build +++ b/sys/oss/meson.build @@ -26,7 +26,7 @@ endif if have_oss plugins += [library('gstossaudio', - 'gstossaudio.c', 'gstosshelper.c', 'gstosssink.c', 'gstosssrc.c', + 'gstossaudio.c', 'gstossaudioelement.c', 'gstosshelper.c', 'gstosssink.c', 'gstosssrc.c', c_args : gst_plugins_good_args, include_directories : [configinc, libsinc], dependencies : [gstaudio_dep, gstbase_dep],