audioparsers: allow per feature registration
authorStéphane Cerveau <scerveau@collabora.com>
Mon, 15 Feb 2021 12:00:38 +0000 (13:00 +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/audioparsers/gstaacparse.c
gst/audioparsers/gstac3parse.c
gst/audioparsers/gstamrparse.c
gst/audioparsers/gstaudioparserselements.h [new file with mode: 0644]
gst/audioparsers/gstdcaparse.c
gst/audioparsers/gstflacparse.c
gst/audioparsers/gstmpegaudioparse.c
gst/audioparsers/gstsbcparse.c
gst/audioparsers/gstwavpackparse.c
gst/audioparsers/plugin.c

index 2b54a53..b282873 100644 (file)
@@ -46,6 +46,7 @@
 
 #include <gst/base/gstbitreader.h>
 #include <gst/pbutils/pbutils.h>
+#include "gstaudioparserselements.h"
 #include "gstaacparse.h"
 
 
@@ -108,6 +109,8 @@ static gboolean gst_aac_parse_read_audio_specific_config (GstAacParse *
 
 #define gst_aac_parse_parent_class parent_class
 G_DEFINE_TYPE (GstAacParse, gst_aac_parse, GST_TYPE_BASE_PARSE);
+GST_ELEMENT_REGISTER_DEFINE (aacparse, "aacparse",
+    GST_RANK_PRIMARY + 1, GST_TYPE_AAC_PARSE);
 
 /**
  * gst_aac_parse_class_init:
index d797aa0..64b3ca3 100644 (file)
@@ -45,6 +45,7 @@
 
 #include <string.h>
 
+#include "gstaudioparserselements.h"
 #include "gstac3parse.h"
 #include <gst/base/base.h>
 #include <gst/pbutils/pbutils.h>
@@ -173,6 +174,8 @@ static gboolean gst_ac3_parse_set_sink_caps (GstBaseParse * parse,
 
 #define gst_ac3_parse_parent_class parent_class
 G_DEFINE_TYPE (GstAc3Parse, gst_ac3_parse, GST_TYPE_BASE_PARSE);
+GST_ELEMENT_REGISTER_DEFINE (ac3parse, "ac3parse",
+    GST_RANK_PRIMARY + 1, GST_TYPE_AC3_PARSE);
 
 static void
 gst_ac3_parse_class_init (GstAc3ParseClass * klass)
index 190f707..0ef612e 100644 (file)
@@ -42,6 +42,7 @@
 
 #include <string.h>
 
+#include "gstaudioparserselements.h"
 #include "gstamrparse.h"
 #include <gst/pbutils/pbutils.h>
 
@@ -85,6 +86,8 @@ static GstFlowReturn gst_amr_parse_pre_push_frame (GstBaseParse * parse,
     GstBaseParseFrame * frame);
 
 G_DEFINE_TYPE (GstAmrParse, gst_amr_parse, GST_TYPE_BASE_PARSE);
+GST_ELEMENT_REGISTER_DEFINE (amrparse, "amrparse",
+    GST_RANK_PRIMARY + 1, GST_TYPE_AMR_PARSE);
 
 /**
  * gst_amr_parse_class_init:
diff --git a/gst/audioparsers/gstaudioparserselements.h b/gst/audioparsers/gstaudioparserselements.h
new file mode 100644 (file)
index 0000000..2cf1369
--- /dev/null
@@ -0,0 +1,39 @@
+/* GStreamer audio parsers
+ * Copyright (C) 2009 Tim-Philipp Müller <tim centricular net>
+ * 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_AUDIOPARSERS_ELEMENTS_H__
+#define __GST_AUDIOPARSERS_ELEMENTS_H__
+
+#include <gst/gst.h>
+
+G_BEGIN_DECLS
+
+GST_ELEMENT_REGISTER_DECLARE (aacparse);
+GST_ELEMENT_REGISTER_DECLARE (amrparse);
+GST_ELEMENT_REGISTER_DECLARE (ac3parse);
+GST_ELEMENT_REGISTER_DECLARE (dcaparse);
+GST_ELEMENT_REGISTER_DECLARE (flacparse);
+GST_ELEMENT_REGISTER_DECLARE (mpegaudioparse);
+GST_ELEMENT_REGISTER_DECLARE (sbcparse);
+GST_ELEMENT_REGISTER_DECLARE (wavpackparse);
+
+G_END_DECLS
+
+#endif /* __GST_AUDIOPARSERS_ELEMENTS_H__ */
index fd7c1f0..e9c8702 100644 (file)
@@ -47,6 +47,7 @@
 
 #include <string.h>
 
+#include "gstaudioparserselements.h"
 #include "gstdcaparse.h"
 #include <gst/base/base.h>
 #include <gst/pbutils/pbutils.h>
@@ -85,6 +86,8 @@ static gboolean gst_dca_parse_set_sink_caps (GstBaseParse * parse,
 
 #define gst_dca_parse_parent_class parent_class
 G_DEFINE_TYPE (GstDcaParse, gst_dca_parse, GST_TYPE_BASE_PARSE);
+GST_ELEMENT_REGISTER_DEFINE (dcaparse, "dcaparse",
+    GST_RANK_PRIMARY + 1, GST_TYPE_DCA_PARSE);
 
 static void
 gst_dca_parse_class_init (GstDcaParseClass * klass)
index 5004d45..8fca410 100644 (file)
@@ -52,6 +52,7 @@
 #include "config.h"
 #endif
 
+#include "gstaudioparserselements.h"
 #include "gstflacparse.h"
 
 #include <string.h>
@@ -216,6 +217,8 @@ static gboolean gst_flac_parse_set_sink_caps (GstBaseParse * parse,
 
 #define gst_flac_parse_parent_class parent_class
 G_DEFINE_TYPE (GstFlacParse, gst_flac_parse, GST_TYPE_BASE_PARSE);
+GST_ELEMENT_REGISTER_DEFINE (flacparse, "flacparse",
+    GST_RANK_PRIMARY + 1, GST_TYPE_FLAC_PARSE);
 
 static void
 gst_flac_parse_class_init (GstFlacParseClass * klass)
index f4cb1cc..f5e0fc2 100644 (file)
@@ -48,6 +48,7 @@
 
 #include <string.h>
 
+#include "gstaudioparserselements.h"
 #include "gstmpegaudioparse.h"
 #include <gst/base/gstbytereader.h>
 #include <gst/pbutils/pbutils.h>
@@ -108,6 +109,8 @@ static void gst_mpeg_audio_parse_handle_first_frame (GstMpegAudioParse *
 
 #define gst_mpeg_audio_parse_parent_class parent_class
 G_DEFINE_TYPE (GstMpegAudioParse, gst_mpeg_audio_parse, GST_TYPE_BASE_PARSE);
+GST_ELEMENT_REGISTER_DEFINE (mpegaudioparse, "mpegaudioparse",
+    GST_RANK_PRIMARY + 2, GST_TYPE_MPEG_AUDIO_PARSE);
 
 #define GST_TYPE_MPEG_AUDIO_CHANNEL_MODE  \
     (gst_mpeg_audio_channel_mode_get_type())
index 494f9cb..3fa8bb4 100644 (file)
@@ -36,6 +36,7 @@
 #include "config.h"
 #endif
 
+#include "gstaudioparserselements.h"
 #include "gstsbcparse.h"
 
 #include <string.h>
@@ -81,6 +82,8 @@ static gsize gst_sbc_parse_header (const guint8 * data, guint * rate,
 
 #define parent_class gst_sbc_parse_parent_class
 G_DEFINE_TYPE (GstSbcParse, gst_sbc_parse, GST_TYPE_BASE_PARSE);
+GST_ELEMENT_REGISTER_DEFINE (sbcparse, "sbcparse",
+    GST_RANK_PRIMARY + 1, GST_TYPE_SBC_PARSE);
 
 static void
 gst_sbc_parse_class_init (GstSbcParseClass * klass)
index 3e37f8a..16b9b4e 100644 (file)
@@ -39,6 +39,7 @@
 
 #include <string.h>
 
+#include "gstaudioparserselements.h"
 #include "gstwavpackparse.h"
 
 #include <gst/base/base.h>
@@ -76,6 +77,8 @@ static GstFlowReturn gst_wavpack_parse_pre_push_frame (GstBaseParse * parse,
 
 #define gst_wavpack_parse_parent_class parent_class
 G_DEFINE_TYPE (GstWavpackParse, gst_wavpack_parse, GST_TYPE_BASE_PARSE);
+GST_ELEMENT_REGISTER_DEFINE (wavpackparse, "wavpackparse",
+    GST_RANK_PRIMARY + 1, GST_TYPE_WAVPACK_PARSE);
 
 static void
 gst_wavpack_parse_class_init (GstWavpackParseClass * klass)
index 8cbfe60..0126af6 100644 (file)
 #include "config.h"
 #endif
 
-#include "gstaacparse.h"
-#include "gstamrparse.h"
-#include "gstac3parse.h"
-#include "gstdcaparse.h"
-#include "gstflacparse.h"
-#include "gstmpegaudioparse.h"
-#include "gstsbcparse.h"
-#include "gstwavpackparse.h"
+#include "gstaudioparserselements.h"
 
 static gboolean
 plugin_init (GstPlugin * plugin)
 {
-  gboolean ret;
+  gboolean ret = FALSE;
 
-  ret = gst_element_register (plugin, "aacparse",
-      GST_RANK_PRIMARY + 1, GST_TYPE_AAC_PARSE);
-  ret &= gst_element_register (plugin, "amrparse",
-      GST_RANK_PRIMARY + 1, GST_TYPE_AMR_PARSE);
-  ret &= gst_element_register (plugin, "ac3parse",
-      GST_RANK_PRIMARY + 1, GST_TYPE_AC3_PARSE);
-  ret &= gst_element_register (plugin, "dcaparse",
-      GST_RANK_PRIMARY + 1, GST_TYPE_DCA_PARSE);
-  ret &= gst_element_register (plugin, "flacparse",
-      GST_RANK_PRIMARY + 1, GST_TYPE_FLAC_PARSE);
-  ret &= gst_element_register (plugin, "mpegaudioparse",
-      GST_RANK_PRIMARY + 2, GST_TYPE_MPEG_AUDIO_PARSE);
-  ret &= gst_element_register (plugin, "sbcparse",
-      GST_RANK_PRIMARY + 1, GST_TYPE_SBC_PARSE);
-  ret &= gst_element_register (plugin, "wavpackparse",
-      GST_RANK_PRIMARY + 1, GST_TYPE_WAVPACK_PARSE);
+  ret |= GST_ELEMENT_REGISTER (aacparse, plugin);
+  ret |= GST_ELEMENT_REGISTER (amrparse, plugin);
+  ret |= GST_ELEMENT_REGISTER (ac3parse, plugin);
+  ret |= GST_ELEMENT_REGISTER (dcaparse, plugin);
+  ret |= GST_ELEMENT_REGISTER (flacparse, plugin);
+  ret |= GST_ELEMENT_REGISTER (mpegaudioparse, plugin);
+  ret |= GST_ELEMENT_REGISTER (sbcparse, plugin);
+  ret |= GST_ELEMENT_REGISTER (wavpackparse, plugin);
 
   return ret;
 }