oss: allow per feature registration
authorStéphane Cerveau <scerveau@collabora.com>
Tue, 16 Feb 2021 15:11:36 +0000 (16:11 +0100)
committerStéphane Cerveau <scerveau@collabora.com>
Mon, 29 Mar 2021 10:45:23 +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>

sys/oss/gstossaudio.c
sys/oss/gstossaudioelement.c [new file with mode: 0644]
sys/oss/gstossaudioelements.h [new file with mode: 0644]
sys/oss/gstosssink.c
sys/oss/gstosssrc.c
sys/oss/meson.build

index 7194e2e..5d476b4 100644 (file)
 #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;
-  }
-
-  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 */
+  gboolean ret = FALSE;
+
+  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 (file)
index 0000000..1793bca
--- /dev/null
@@ -0,0 +1,47 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ *
+ * 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 (file)
index 0000000..4770a76
--- /dev/null
@@ -0,0 +1,39 @@
+/* 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_OSS_ELEMENTS_H__
+#define __GST_OSS_ELEMENTS_H__
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gst/gst.h>
+
+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__ */
index 75b2cf7..bae8edf 100644 (file)
@@ -66,6 +66,7 @@
 #endif /* HAVE_OSS_INCLUDE_IN_SYS */
 
 #include "common.h"
+#include "gstossaudioelements.h"
 #include "gstosssink.h"
 
 #include <gst/gst-i18n-plugin.h>
@@ -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)
index c4c55f9..a34e1ee 100644 (file)
@@ -60,6 +60,7 @@
 #endif /* HAVE_OSS_INCLUDE_IN_SYS */
 
 #include "common.h"
+#include "gstossaudioelements.h"
 #include "gstosssrc.h"
 
 #include <gst/gst-i18n-plugin.h>
@@ -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);
index 8f8e81c..51cc4d3 100644 (file)
@@ -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],