dv: allow per feature registration
authorStéphane Cerveau <scerveau@collabora.com>
Thu, 11 Feb 2021 17:57:03 +0000 (18:57 +0100)
committerStéphane Cerveau <scerveau@collabora.com>
Mon, 29 Mar 2021 10:45:21 +0000 (12:45 +0200)
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: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/876>

ext/dv/gstdv.c
ext/dv/gstdvdec.c
ext/dv/gstdvdemux.c
ext/dv/gstdvelement.c [new file with mode: 0644]
ext/dv/gstdvelements.h [new file with mode: 0644]
ext/dv/meson.build

index 9861bf6..922f7d7 100644 (file)
 #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,
index 7926ef9..414805c 100644 (file)
@@ -45,6 +45,7 @@
 #include <gst/video/gstvideometa.h>
 #include <gst/video/gstvideopool.h>
 
+#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);
index f787fea..10c2dba 100644 (file)
@@ -26,6 +26,7 @@
 #include <math.h>
 
 #include <gst/audio/audio.h>
+#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 (file)
index 0000000..b3aba67
--- /dev/null
@@ -0,0 +1,36 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ *               <2005> Wim Taymans <wim@fluendo.com>
+ *
+ * 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 <libdv/dv.h>
+#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 (file)
index 0000000..865d35e
--- /dev/null
@@ -0,0 +1,42 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd.
+ *   @Author: Julian Bouzas <julian.bouzas@collabora.com>
+ *
+ * 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 <gst/gst.h>
+#include <gst/video/video.h>
+
+
+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__ */
index fe558d3..d6c0c07 100644 (file)
@@ -1,5 +1,6 @@
 dv_sources = [
   'gstdv.c',
+  'gstdvelement.c',
   'gstdvdec.c',
   'gstdvdemux.c',
   'gstsmptetimecode.c',