autodetect: allow per feature registration
authorStéphane Cerveau <scerveau@collabora.com>
Mon, 15 Feb 2021 12:02:59 +0000 (13:02 +0100)
committerStéphane Cerveau <scerveau@collabora.com>
Mon, 29 Mar 2021 10:45:22 +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>

gst/autodetect/gstautoaudiosink.c
gst/autodetect/gstautoaudiosrc.c
gst/autodetect/gstautodetect.c
gst/autodetect/gstautodetect.h
gst/autodetect/gstautodetectelement.c [new file with mode: 0644]
gst/autodetect/gstautodetectelements.h [new file with mode: 0644]
gst/autodetect/gstautodetectplugin.c [new file with mode: 0644]
gst/autodetect/gstautovideosink.c
gst/autodetect/gstautovideosrc.c
gst/autodetect/meson.build

index 26d9f4f..5c18972 100644 (file)
@@ -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,
index bf3704b..6c957cc 100644 (file)
 #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,
index d6224fa..864d465 100644 (file)
 #include <gst/gst.h>
 
 #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)
index 05ae89f..09592ff 100644 (file)
 #ifndef __GST_AUTO_DETECT_H__
 #define __GST_AUTO_DETECT_H__
 
-G_BEGIN_DECLS
+#include <gst/gst.h>
 
-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 (file)
index 0000000..ad736e5
--- /dev/null
@@ -0,0 +1,42 @@
+/* GStreamer
+ * (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+ *
+ * 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 <stdio.h>
+#include <string.h>
+
+#include <gst/gst.h>
+
+#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 (file)
index 0000000..7d51d38
--- /dev/null
@@ -0,0 +1,41 @@
+/* GStreamer
+ * (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd.
+ *   @Author: Stéphane Cerveau <stephane.cerveau@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_AUTO_DETECT_ELEMENTS_H__
+#define __GST_AUTO_DETECT_ELEMENTS_H__
+
+#include <gst/gst.h>
+
+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 (file)
index 0000000..c925e5a
--- /dev/null
@@ -0,0 +1,45 @@
+/* GStreamer
+ * (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+ *
+ * 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.h>
+
+#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)
index d46aa69..b3eaf1f 100644 (file)
@@ -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,
index e5778db..00d0855 100644 (file)
 #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,
index 996808a..2cbe424 100644 (file)
@@ -2,6 +2,8 @@ autodetect_sources = [
   'gstautoaudiosink.c',
   'gstautoaudiosrc.c',
   'gstautodetect.c',
+  'gstautodetectplugin.c',
+  'gstautodetectelement.c',
   'gstautovideosink.c',
   'gstautovideosrc.c',
 ]