From d5e5ced7b71835fc23c8ccc413cb2b70da419acf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= <scerveau@collabora.com>
Date: Thu, 18 Feb 2021 10:17:20 +0100
Subject: [PATCH] mplex: allow per feature registration

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-bad/-/merge_requests/2038>
---
 ext/mplex/gstmplex.cc | 10 +++++++++-
 ext/mplex/gstmplex.hh |  2 ++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/ext/mplex/gstmplex.cc b/ext/mplex/gstmplex.cc
index 5df12d6d03..94b06dead1 100644
--- a/ext/mplex/gstmplex.cc
+++ b/ext/mplex/gstmplex.cc
@@ -115,9 +115,11 @@ static void gst_mplex_get_property (GObject * object,
     guint prop_id, GValue * value, GParamSpec * pspec);
 static void gst_mplex_set_property (GObject * object,
     guint prop_id, const GValue * value, GParamSpec * pspec);
+static gboolean mplex_element_init (GstPlugin * plugin);
 
 #define parent_class gst_mplex_parent_class
 G_DEFINE_TYPE (GstMplex, gst_mplex, GST_TYPE_ELEMENT);
+GST_ELEMENT_REGISTER_DEFINE_CUSTOM (mplex, mplex_element_init);
 
 static void
 gst_mplex_class_init (GstMplexClass * klass)
@@ -802,7 +804,7 @@ gst_mplex_log_callback (log_level_t level, const char *message)
 #endif
 
 static gboolean
-plugin_init (GstPlugin * plugin)
+mplex_element_init (GstPlugin * plugin)
 {
 #ifndef GST_DISABLE_GST_DEBUG
   old_handler = mjpeg_log_set_handler (gst_mplex_log_callback);
@@ -814,6 +816,12 @@ plugin_init (GstPlugin * plugin)
   return gst_element_register (plugin, "mplex", GST_RANK_NONE, GST_TYPE_MPLEX);
 }
 
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+  return GST_ELEMENT_REGISTER (mplex, plugin);
+}
+
 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
     GST_VERSION_MINOR,
     mplex,
diff --git a/ext/mplex/gstmplex.hh b/ext/mplex/gstmplex.hh
index 68a4257769..6c84664136 100644
--- a/ext/mplex/gstmplex.hh
+++ b/ext/mplex/gstmplex.hh
@@ -117,6 +117,8 @@ typedef struct _GstMplexClass {
 
 GType    gst_mplex_get_type    (void);
 
+GST_ELEMENT_REGISTER_DECLARE (mplex);
+
 G_END_DECLS
 
 #endif /* __GST_MPLEX_H__ */