From 277daa828644fcc679ca0e0d30955a0b3f1f9577 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Cerveau?= Date: Mon, 15 Feb 2021 13:02:59 +0100 Subject: [PATCH] autodetect: 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/autodetect/gstautoaudiosink.c | 4 +++ gst/autodetect/gstautoaudiosrc.c | 4 +++ gst/autodetect/gstautodetect.c | 28 --------------------- gst/autodetect/gstautodetect.h | 5 ++-- gst/autodetect/gstautodetectelement.c | 42 +++++++++++++++++++++++++++++++ gst/autodetect/gstautodetectelements.h | 41 +++++++++++++++++++++++++++++++ gst/autodetect/gstautodetectplugin.c | 45 ++++++++++++++++++++++++++++++++++ gst/autodetect/gstautovideosink.c | 4 +++ gst/autodetect/gstautovideosrc.c | 4 +++ gst/autodetect/meson.build | 2 ++ 10 files changed, 148 insertions(+), 31 deletions(-) create mode 100644 gst/autodetect/gstautodetectelement.c create mode 100644 gst/autodetect/gstautodetectelements.h create mode 100644 gst/autodetect/gstautodetectplugin.c diff --git a/gst/autodetect/gstautoaudiosink.c b/gst/autodetect/gstautoaudiosink.c index 26d9f4f..5c18972 100644 --- a/gst/autodetect/gstautoaudiosink.c +++ b/gst/autodetect/gstautoaudiosink.c @@ -39,6 +39,8 @@ #include "config.h" #endif +#include "gstautodetectelements.h" +#include "gstautodetect.h" #include "gstautoaudiosink.h" #define DEFAULT_TS_OFFSET 0 @@ -58,6 +60,8 @@ static void gst_auto_audio_sink_configure (GstAutoDetect * autodetect, GstElement * kid); G_DEFINE_TYPE (GstAutoAudioSink, gst_auto_audio_sink, GST_TYPE_AUTO_DETECT); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (autoaudiosink, "autoaudiosink", + GST_RANK_NONE, GST_TYPE_AUTO_AUDIO_SINK, autodetect_element_init (plugin)); static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, diff --git a/gst/autodetect/gstautoaudiosrc.c b/gst/autodetect/gstautoaudiosrc.c index bf3704b..6c957cc 100644 --- a/gst/autodetect/gstautoaudiosrc.c +++ b/gst/autodetect/gstautoaudiosrc.c @@ -40,9 +40,13 @@ #include "config.h" #endif +#include "gstautodetectelements.h" +#include "gstautodetect.h" #include "gstautoaudiosrc.h" G_DEFINE_TYPE (GstAutoAudioSrc, gst_auto_audio_src, GST_TYPE_AUTO_DETECT); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (autoaudiosrc, "autoaudiosrc", + GST_RANK_NONE, GST_TYPE_AUTO_AUDIO_SRC, autodetect_element_init (plugin)); static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, diff --git a/gst/autodetect/gstautodetect.c b/gst/autodetect/gstautodetect.c index d6224fa..864d465 100644 --- a/gst/autodetect/gstautodetect.c +++ b/gst/autodetect/gstautodetect.c @@ -27,12 +27,6 @@ #include #include "gstautodetect.h" -#include "gstautoaudiosink.h" -#include "gstautoaudiosrc.h" -#include "gstautovideosink.h" -#include "gstautovideosrc.h" - -GST_DEBUG_CATEGORY (autodetect_debug); #define DEFAULT_SYNC TRUE @@ -486,25 +480,3 @@ gst_auto_detect_get_property (GObject * object, guint prop_id, break; } } - -static gboolean -plugin_init (GstPlugin * plugin) -{ - GST_DEBUG_CATEGORY_INIT (autodetect_debug, "autodetect", 0, - "Autodetection audio/video output wrapper elements"); - - return gst_element_register (plugin, "autovideosink", - GST_RANK_NONE, GST_TYPE_AUTO_VIDEO_SINK) && - gst_element_register (plugin, "autovideosrc", - GST_RANK_NONE, GST_TYPE_AUTO_VIDEO_SRC) && - gst_element_register (plugin, "autoaudiosink", - GST_RANK_NONE, GST_TYPE_AUTO_AUDIO_SINK) && - gst_element_register (plugin, "autoaudiosrc", - GST_RANK_NONE, GST_TYPE_AUTO_AUDIO_SRC); -} - -GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, - GST_VERSION_MINOR, - autodetect, - "Plugin contains auto-detection plugins for video/audio in- and outputs", - plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN) diff --git a/gst/autodetect/gstautodetect.h b/gst/autodetect/gstautodetect.h index 05ae89f..09592ff 100644 --- a/gst/autodetect/gstautodetect.h +++ b/gst/autodetect/gstautodetect.h @@ -20,10 +20,9 @@ #ifndef __GST_AUTO_DETECT_H__ #define __GST_AUTO_DETECT_H__ -G_BEGIN_DECLS +#include -GST_DEBUG_CATEGORY_EXTERN (autodetect_debug); -#define GST_CAT_DEFAULT autodetect_debug +G_BEGIN_DECLS #define GST_TYPE_AUTO_DETECT (gst_auto_detect_get_type ()) #define GST_AUTO_DETECT(obj) \ diff --git a/gst/autodetect/gstautodetectelement.c b/gst/autodetect/gstautodetectelement.c new file mode 100644 index 0000000..ad736e5 --- /dev/null +++ b/gst/autodetect/gstautodetectelement.c @@ -0,0 +1,42 @@ +/* GStreamer + * (c) 2005 Ronald S. Bultje + * + * 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 +#include + +#include + +#include "gstautodetectelements.h" + +GST_DEBUG_CATEGORY (autodetect_debug); + +void +autodetect_element_init (GstPlugin * plugin) +{ + static gsize res = FALSE; + if (g_once_init_enter (&res)) { + GST_DEBUG_CATEGORY_INIT (autodetect_debug, "autodetect", 0, + "Autodetection audio/video output wrapper elements"); + g_once_init_leave (&res, TRUE); + } +} diff --git a/gst/autodetect/gstautodetectelements.h b/gst/autodetect/gstautodetectelements.h new file mode 100644 index 0000000..7d51d38 --- /dev/null +++ b/gst/autodetect/gstautodetectelements.h @@ -0,0 +1,41 @@ +/* GStreamer + * (c) 2005 Ronald S. Bultje + * 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. + */ + +#ifndef __GST_AUTO_DETECT_ELEMENTS_H__ +#define __GST_AUTO_DETECT_ELEMENTS_H__ + +#include + +G_BEGIN_DECLS + +void autodetect_element_init (GstPlugin * plugin); + +GST_ELEMENT_REGISTER_DECLARE (autovideosink); +GST_ELEMENT_REGISTER_DECLARE (autovideosrc); +GST_ELEMENT_REGISTER_DECLARE (autoaudiosink); +GST_ELEMENT_REGISTER_DECLARE (autoaudiosrc); + +GST_DEBUG_CATEGORY_EXTERN (autodetect_debug); +#define GST_CAT_DEFAULT autodetect_debug + +G_END_DECLS + +#endif /* __GST_AUTO_DETECT_ELEMENTS_H__ */ diff --git a/gst/autodetect/gstautodetectplugin.c b/gst/autodetect/gstautodetectplugin.c new file mode 100644 index 0000000..c925e5a --- /dev/null +++ b/gst/autodetect/gstautodetectplugin.c @@ -0,0 +1,45 @@ +/* GStreamer + * (c) 2005 Ronald S. Bultje + * + * 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 + +#include "gstautodetectelements.h" + +static gboolean +plugin_init (GstPlugin * plugin) +{ + gboolean ret = FALSE; + + ret |= GST_ELEMENT_REGISTER (autovideosink, plugin); + ret |= GST_ELEMENT_REGISTER (autovideosrc, plugin); + ret |= GST_ELEMENT_REGISTER (autoaudiosink, plugin); + ret |= GST_ELEMENT_REGISTER (autoaudiosrc, plugin); + + return ret; +} + +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + autodetect, + "Plugin contains auto-detection plugins for video/audio in- and outputs", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN) diff --git a/gst/autodetect/gstautovideosink.c b/gst/autodetect/gstautovideosink.c index d46aa69..b3eaf1f 100644 --- a/gst/autodetect/gstautovideosink.c +++ b/gst/autodetect/gstautovideosink.c @@ -39,6 +39,8 @@ #include "config.h" #endif +#include "gstautodetectelements.h" +#include "gstautodetect.h" #include "gstautovideosink.h" #define DEFAULT_TS_OFFSET 0 @@ -58,6 +60,8 @@ static void gst_auto_video_sink_configure (GstAutoDetect * autodetect, GstElement * kid); G_DEFINE_TYPE (GstAutoVideoSink, gst_auto_video_sink, GST_TYPE_AUTO_DETECT); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (autovideosink, "autovideosink", + GST_RANK_NONE, GST_TYPE_AUTO_VIDEO_SINK, autodetect_element_init (plugin)); static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, diff --git a/gst/autodetect/gstautovideosrc.c b/gst/autodetect/gstautovideosrc.c index e5778db..00d0855 100644 --- a/gst/autodetect/gstautovideosrc.c +++ b/gst/autodetect/gstautovideosrc.c @@ -40,9 +40,13 @@ #include "config.h" #endif +#include "gstautodetectelements.h" +#include "gstautodetect.h" #include "gstautovideosrc.h" G_DEFINE_TYPE (GstAutoVideoSrc, gst_auto_video_src, GST_TYPE_AUTO_DETECT); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (autovideosrc, "autovideosrc", + GST_RANK_NONE, GST_TYPE_AUTO_VIDEO_SRC, autodetect_element_init (plugin)); static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, diff --git a/gst/autodetect/meson.build b/gst/autodetect/meson.build index 996808a..2cbe424 100644 --- a/gst/autodetect/meson.build +++ b/gst/autodetect/meson.build @@ -2,6 +2,8 @@ autodetect_sources = [ 'gstautoaudiosink.c', 'gstautoaudiosrc.c', 'gstautodetect.c', + 'gstautodetectplugin.c', + 'gstautodetectelement.c', 'gstautovideosink.c', 'gstautovideosrc.c', ] -- 2.7.4