From 0b257dd1d509807d8928b7de8398ee01e863d0c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Thu, 11 Feb 2021 18:57:03 +0100 Subject: [PATCH] dv: 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/dv/gstdv.c | 16 +++++----------- ext/dv/gstdvdec.c | 3 +++ ext/dv/gstdvdemux.c | 3 +++ ext/dv/gstdvelement.c | 36 ++++++++++++++++++++++++++++++++++++ ext/dv/gstdvelements.h | 42 ++++++++++++++++++++++++++++++++++++++++++ ext/dv/meson.build | 1 + 6 files changed, 90 insertions(+), 11 deletions(-) create mode 100644 ext/dv/gstdvelement.c create mode 100644 ext/dv/gstdvelements.h diff --git a/ext/dv/gstdv.c b/ext/dv/gstdv.c index 9861bf6f80..922f7d7930 100644 --- a/ext/dv/gstdv.c +++ b/ext/dv/gstdv.c @@ -22,23 +22,17 @@ #include "config.h" #endif -#include "gstdvdec.h" -#include "gstdvdemux.h" +#include "gstdvelements.h" static gboolean plugin_init (GstPlugin * plugin) { - dv_init (0, 0); + gboolean ret = FALSE; - if (!gst_element_register (plugin, "dvdemux", GST_RANK_PRIMARY, - gst_dvdemux_get_type ())) - return FALSE; + ret |= GST_ELEMENT_REGISTER (dvdemux, plugin); + ret |= GST_ELEMENT_REGISTER (dvdec, plugin); - if (!gst_element_register (plugin, "dvdec", GST_RANK_MARGINAL, - gst_dvdec_get_type ())) - return FALSE; - - return TRUE; + return ret; } GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, diff --git a/ext/dv/gstdvdec.c b/ext/dv/gstdvdec.c index 7926ef93b4..414805c6c5 100644 --- a/ext/dv/gstdvdec.c +++ b/ext/dv/gstdvdec.c @@ -45,6 +45,7 @@ #include #include +#include "gstdvelements.h" #include "gstdvdec.h" /* sizes of one input buffer */ @@ -131,6 +132,8 @@ gst_dvdec_quality_get_type (void) #define gst_dvdec_parent_class parent_class G_DEFINE_TYPE (GstDVDec, gst_dvdec, GST_TYPE_ELEMENT); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (dvdec, "dvdec", GST_RANK_MARGINAL, + GST_TYPE_DVDEC, dv_element_init (plugin)); static GstFlowReturn gst_dvdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer); diff --git a/ext/dv/gstdvdemux.c b/ext/dv/gstdvdemux.c index f787fea361..10c2dbaf40 100644 --- a/ext/dv/gstdvdemux.c +++ b/ext/dv/gstdvdemux.c @@ -26,6 +26,7 @@ #include #include +#include "gstdvelements.h" #include "gstdvdemux.h" #include "gstsmptetimecode.h" @@ -130,6 +131,8 @@ static GstStaticPadTemplate audio_src_temp = GST_STATIC_PAD_TEMPLATE ("audio", #define gst_dvdemux_parent_class parent_class G_DEFINE_TYPE (GstDVDemux, gst_dvdemux, GST_TYPE_ELEMENT); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (dvdemux, "dvdemux", GST_RANK_PRIMARY, + GST_TYPE_DVDEMUX, dv_element_init (plugin)); static void gst_dvdemux_finalize (GObject * object); diff --git a/ext/dv/gstdvelement.c b/ext/dv/gstdvelement.c new file mode 100644 index 0000000000..b3aba670ea --- /dev/null +++ b/ext/dv/gstdvelement.c @@ -0,0 +1,36 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen + * <2005> Wim Taymans + * + * 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 "gstdvelements.h" + +void +dv_element_init (GstPlugin * plugin) +{ + static gsize res = FALSE; + if (g_once_init_enter (&res)) { + dv_init (0, 0); + g_once_init_leave (&res, TRUE); + } +} diff --git a/ext/dv/gstdvelements.h b/ext/dv/gstdvelements.h new file mode 100644 index 0000000000..865d35ec86 --- /dev/null +++ b/ext/dv/gstdvelements.h @@ -0,0 +1,42 @@ +/* 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_DV_ELEMENTS_H__ +#define __GST_DV_ELEMENTS_H__ + + +#include +#include + + +G_BEGIN_DECLS + +void dv_element_init (GstPlugin * plugin); + +GST_ELEMENT_REGISTER_DECLARE (dvdemux); +GST_ELEMENT_REGISTER_DECLARE (dvdec); + + +G_END_DECLS + + +#endif /* __GST_DV_ELEMENTS_H__ */ diff --git a/ext/dv/meson.build b/ext/dv/meson.build index fe558d39f6..d6c0c0730d 100644 --- a/ext/dv/meson.build +++ b/ext/dv/meson.build @@ -1,5 +1,6 @@ dv_sources = [ 'gstdv.c', + 'gstdvelement.c', 'gstdvdec.c', 'gstdvdemux.c', 'gstsmptetimecode.c',