vorbis: allow per feature registration
authorStéphane Cerveau <scerveau@collabora.com>
Fri, 11 Dec 2020 16:56:13 +0000 (17:56 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 16 Mar 2021 17:58:59 +0000 (17:58 +0000)
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-base/-/merge_requests/1029>

ext/vorbis/gstivorbisdec.c
ext/vorbis/gstvorbis.c
ext/vorbis/gstvorbisdec.c
ext/vorbis/gstvorbiselement.c [new file with mode: 0644]
ext/vorbis/gstvorbiselements.h [new file with mode: 0644]
ext/vorbis/gstvorbisenc.c
ext/vorbis/gstvorbisparse.c
ext/vorbis/gstvorbistag.c
ext/vorbis/meson.build

index a47a094..3dc2a60 100644 (file)
 #include "config.h"
 #endif
 
-#include "gstvorbisdec.h"
+#include "gstvorbiselements.h"
 
 GST_DEBUG_CATEGORY (ivorbisdec_debug);
 
 static gboolean
 plugin_init (GstPlugin * plugin)
 {
-
-  if (!gst_element_register (plugin, "ivorbisdec", GST_RANK_SECONDARY,
-          gst_vorbis_dec_get_type ()))
-    return FALSE;
+  gboolean ret = FALSE;
 
   GST_DEBUG_CATEGORY_INIT (ivorbisdec_debug, "ivorbisdec", 0,
       "vorbis decoding element (integer decoder)");
 
-  return TRUE;
+  ret |= GST_ELEMENT_REGISTER (ivorbisdec, plugin);
+
+  return ret;
 }
 
 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
index 67254a8..51b9a76 100644 (file)
 #include "config.h"
 #endif
 
-#include "gst/tag/tag.h"
-
-#include "gstvorbisenc.h"
-#include "gstvorbisdec.h"
-#include "gstvorbisparse.h"
-#include "gstvorbistag.h"
-
-GST_DEBUG_CATEGORY (vorbisenc_debug);
-GST_DEBUG_CATEGORY (vorbisdec_debug);
-GST_DEBUG_CATEGORY (vorbisparse_debug);
-GST_DEBUG_CATEGORY (vorbistag_debug);
+#include "gstvorbiselements.h"
 
 static gboolean
 plugin_init (GstPlugin * plugin)
 {
-  if (!gst_element_register (plugin, "vorbisenc", GST_RANK_PRIMARY,
-          GST_TYPE_VORBISENC))
-    return FALSE;
-
-  if (!gst_element_register (plugin, "vorbisdec", GST_RANK_PRIMARY,
-          gst_vorbis_dec_get_type ()))
-    return FALSE;
-
-  if (!gst_element_register (plugin, "vorbisparse", GST_RANK_NONE,
-          gst_vorbis_parse_get_type ()))
-    return FALSE;
-
-  if (!gst_element_register (plugin, "vorbistag", GST_RANK_NONE,
-          gst_vorbis_tag_get_type ()))
-    return FALSE;
-
-  GST_DEBUG_CATEGORY_INIT (vorbisenc_debug, "vorbisenc", 0,
-      "vorbis encoding element");
-  GST_DEBUG_CATEGORY_INIT (vorbisdec_debug, "vorbisdec", 0,
-      "vorbis decoding element");
-  GST_DEBUG_CATEGORY_INIT (vorbisparse_debug, "vorbisparse", 0,
-      "vorbis parsing element");
-  GST_DEBUG_CATEGORY_INIT (vorbistag_debug, "vorbistag", 0,
-      "vorbis tagging element");
+  gboolean ret = FALSE;
 
-  gst_tag_register_musicbrainz_tags ();
+  ret |= GST_ELEMENT_REGISTER (vorbisenc, plugin);
+  ret |= GST_ELEMENT_REGISTER (vorbisdec, plugin);
+  ret |= GST_ELEMENT_REGISTER (vorbisparse, plugin);
+  ret |= GST_ELEMENT_REGISTER (vorbistag, plugin);
 
-  return TRUE;
+  return ret;
 }
 
 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
index bb865d7..817b17f 100644 (file)
@@ -44,6 +44,7 @@
 #include <gst/audio/audio.h>
 #include <gst/tag/tag.h>
 
+#include "gstvorbiselements.h"
 #include "gstvorbiscommon.h"
 
 #ifndef TREMOR
@@ -69,6 +70,11 @@ GST_STATIC_PAD_TEMPLATE ("sink",
 
 #define gst_vorbis_dec_parent_class parent_class
 G_DEFINE_TYPE (GstVorbisDec, gst_vorbis_dec, GST_TYPE_AUDIO_DECODER);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (vorbisdec, "vorbisdec",
+    GST_RANK_PRIMARY, GST_TYPE_VORBIS_DEC, vorbis_element_init (plugin));
+
+GST_ELEMENT_REGISTER_DEFINE (ivorbisdec, "ivorbisdec",
+    GST_RANK_SECONDARY, GST_TYPE_VORBIS_DEC);
 
 static void vorbis_dec_finalize (GObject * object);
 
diff --git a/ext/vorbis/gstvorbiselement.c b/ext/vorbis/gstvorbiselement.c
new file mode 100644 (file)
index 0000000..1ff85a5
--- /dev/null
@@ -0,0 +1,43 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd.
+ *   @Author: Stéphane Cerveau <scerveau@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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "gstvorbiselements.h"
+#include "gst/tag/tag.h"
+
+GST_DEBUG_CATEGORY (vorbisenc_debug);
+GST_DEBUG_CATEGORY (vorbisdec_debug);
+GST_DEBUG_CATEGORY (vorbisparse_debug);
+GST_DEBUG_CATEGORY (vorbistag_debug);
+
+void
+vorbis_element_init (GstPlugin * plugin)
+{
+  static gsize res = FALSE;
+
+  if (g_once_init_enter (&res)) {
+    gst_tag_register_musicbrainz_tags ();
+    g_once_init_leave (&res, TRUE);
+  }
+}
diff --git a/ext/vorbis/gstvorbiselements.h b/ext/vorbis/gstvorbiselements.h
new file mode 100644 (file)
index 0000000..218ddb9
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd.
+ *   @Author: Stéphane Cerveau <scerveau@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_VORBIS_ELEMENTS_H__
+#define __GST_VORBIS_ELEMENTS_H__
+
+#include <gst/gst.h>
+
+G_BEGIN_DECLS
+
+G_GNUC_INTERNAL void vorbis_element_init (GstPlugin * plugin);
+
+GST_ELEMENT_REGISTER_DECLARE (vorbisenc);
+GST_ELEMENT_REGISTER_DECLARE (vorbisdec);
+GST_ELEMENT_REGISTER_DECLARE (vorbisparse);
+GST_ELEMENT_REGISTER_DECLARE (vorbistag);
+GST_ELEMENT_REGISTER_DECLARE (ivorbisdec);
+
+G_END_DECLS
+
+#endif /* __GST_VORBIS_ELEMENTS_H__ */
index 1c0b2c2..b2cb66c 100644 (file)
@@ -52,6 +52,7 @@
 #include <gst/audio/audio.h>
 #include "gstvorbisenc.h"
 
+#include "gstvorbiselements.h"
 #include "gstvorbiscommon.h"
 
 GST_DEBUG_CATEGORY_EXTERN (vorbisenc_debug);
@@ -108,6 +109,8 @@ static void gst_vorbis_enc_flush (GstAudioEncoder * vorbisenc);
 #define gst_vorbis_enc_parent_class parent_class
 G_DEFINE_TYPE_WITH_CODE (GstVorbisEnc, gst_vorbis_enc,
     GST_TYPE_AUDIO_ENCODER, G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL));
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (vorbisenc, "vorbisenc",
+    GST_RANK_PRIMARY, GST_TYPE_VORBISENC, vorbis_element_init (plugin));
 
 static void
 gst_vorbis_enc_class_init (GstVorbisEncClass * klass)
index ada2b5b..20dd67e 100644 (file)
@@ -53,6 +53,7 @@
 #  include "config.h"
 #endif
 
+#include "gstvorbiselements.h"
 #include "gstvorbisparse.h"
 
 GST_DEBUG_CATEGORY_EXTERN (vorbisparse_debug);
@@ -74,6 +75,8 @@ GST_STATIC_PAD_TEMPLATE ("src",
 
 #define gst_vorbis_parse_parent_class parent_class
 G_DEFINE_TYPE (GstVorbisParse, gst_vorbis_parse, GST_TYPE_ELEMENT);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (vorbisparse, "vorbisparse",
+    GST_RANK_NONE, GST_TYPE_VORBIS_PARSE, vorbis_element_init (plugin));
 
 static GstFlowReturn vorbis_parse_chain (GstPad * pad, GstObject * parent,
     GstBuffer * buffer);
index 19ddb3e..6613c27 100644 (file)
@@ -55,6 +55,7 @@
 
 #include <vorbis/codec.h>
 
+#include "gstvorbiselements.h"
 #include "gstvorbistag.h"
 
 
@@ -67,6 +68,8 @@ static GstFlowReturn gst_vorbis_tag_parse_packet (GstVorbisParse * parse,
 #define gst_vorbis_tag_parent_class parent_class
 G_DEFINE_TYPE_WITH_CODE (GstVorbisTag, gst_vorbis_tag,
     GST_TYPE_VORBIS_PARSE, G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL));
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (vorbistag, "vorbistag",
+    GST_RANK_NONE, GST_TYPE_VORBIS_TAG, vorbis_element_init (plugin));
 
 static void
 gst_vorbis_tag_class_init (GstVorbisTagClass * klass)
index 4600106..a55249a 100644 (file)
@@ -1,5 +1,6 @@
 vorbis_sources = [
   'gstvorbis.c',
+  'gstvorbiselement.c',
   'gstvorbisdec.c',
   'gstvorbisdeclib.c',
   'gstvorbisenc.c',
@@ -10,6 +11,7 @@ vorbis_sources = [
 
 vorbisidec_sources = [
   'gstivorbisdec.c',
+  'gstvorbiselement.c',
   'gstvorbisdec.c',
   'gstvorbisdeclib.c',
   'gstvorbiscommon.c',