srtp: allow per feature registration
authorStéphane Cerveau <scerveau@collabora.com>
Wed, 24 Feb 2021 11:52:08 +0000 (12:52 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 23 Mar 2021 14:19:17 +0000 (14:19 +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-bad/-/merge_requests/2038>

ext/srtp/gstsrtp.c
ext/srtp/gstsrtpdec.c
ext/srtp/gstsrtpdec.h
ext/srtp/gstsrtpelement.c [new file with mode: 0644]
ext/srtp/gstsrtpelements.h [new file with mode: 0644]
ext/srtp/gstsrtpenc.c
ext/srtp/gstsrtpenc.h
ext/srtp/gstsrtpplugin.c [new file with mode: 0644]
ext/srtp/meson.build

index b607b2c..5a34945 100644 (file)
@@ -297,26 +297,3 @@ cipher_key_size (GstSrtpCipherType cipher)
 
   return size;
 }
-
-static gboolean
-plugin_init (GstPlugin * plugin)
-{
-  srtp_init ();
-
-  if (!gst_srtp_enc_plugin_init (plugin))
-    return FALSE;
-
-  if (!gst_srtp_dec_plugin_init (plugin))
-    return FALSE;
-
-  gst_type_mark_as_plugin_api (GST_TYPE_SRTP_AUTH_TYPE, 0);
-  gst_type_mark_as_plugin_api (GST_TYPE_SRTP_CIPHER_TYPE, 0);
-
-  return TRUE;
-}
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
-    GST_VERSION_MINOR,
-    srtp,
-    "GStreamer SRTP",
-    plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
index 6d19299..f688d62 100644 (file)
  *
  */
 
+#include "gstsrtpelements.h"
 #include "gstsrtpdec.h"
-
 #include <gst/rtp/gstrtpbuffer.h>
 #include <string.h>
 
@@ -177,7 +177,11 @@ GST_STATIC_PAD_TEMPLATE ("rtcp_src",
 
 static guint gst_srtp_dec_signals[LAST_SIGNAL] = { 0 };
 
-G_DEFINE_TYPE (GstSrtpDec, gst_srtp_dec, GST_TYPE_ELEMENT);
+G_DEFINE_TYPE_WITH_CODE (GstSrtpDec, gst_srtp_dec, GST_TYPE_ELEMENT,
+    GST_DEBUG_CATEGORY_INIT (gst_srtp_dec_debug, "srtpdec", 0, "SRTP dec");
+    );
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (srtpdec, "srtpdec", GST_RANK_NONE,
+    GST_TYPE_SRTP_DEC, srtp_element_init (plugin));
 
 static void gst_srtp_dec_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
@@ -1570,17 +1574,3 @@ gst_srtp_dec_change_state (GstElement * element, GstStateChange transition)
   }
   return res;
 }
-
-
-/* entry point to initialize the plug-in
- * initialize the plug-in itself
- * register the element factories and other features
- */
-gboolean
-gst_srtp_dec_plugin_init (GstPlugin * srtpdec)
-{
-  GST_DEBUG_CATEGORY_INIT (gst_srtp_dec_debug, "srtpdec", 0, "SRTP dec");
-
-  return gst_element_register (srtpdec, "srtpdec", GST_RANK_NONE,
-      GST_TYPE_SRTP_DEC);
-}
index ba8bcff..5b46f6c 100644 (file)
@@ -98,7 +98,6 @@ struct _GstSrtpDecClass
 
 GType gst_srtp_dec_get_type (void);
 
-gboolean gst_srtp_dec_plugin_init (GstPlugin * plugin);
 
 G_END_DECLS
 
diff --git a/ext/srtp/gstsrtpelement.c b/ext/srtp/gstsrtpelement.c
new file mode 100644 (file)
index 0000000..231b70d
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * GStreamer - GStreamer SRTP encoder and decoder
+ *
+ * Copyright 2009-2013 Collabora Ltd.
+ *  @author: Gabriel Millaire <gabriel.millaire@collabora.co.uk>
+ *  @author: Olivier Crete <olivier.crete@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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
+#include "gstsrtpelements.h"
+
+
+void
+srtp_element_init (GstPlugin * plugin)
+{
+  static gsize res = FALSE;
+
+  if (g_once_init_enter (&res)) {
+    srtp_init ();
+    gst_type_mark_as_plugin_api (GST_TYPE_SRTP_AUTH_TYPE, 0);
+    gst_type_mark_as_plugin_api (GST_TYPE_SRTP_CIPHER_TYPE, 0);
+    g_once_init_leave (&res, TRUE);
+  }
+}
diff --git a/ext/srtp/gstsrtpelements.h b/ext/srtp/gstsrtpelements.h
new file mode 100644 (file)
index 0000000..0a223fb
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * GStreamer - GStreamer SRTP encoder
+ *
+ * Copyright 2011-2013 Collabora Ltd.
+ *  @author: Olivier Crete <olivier.crete@collabora.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Alternatively, the contents of this file may be used under the
+ * GNU Lesser General Public License Version 2.1 (the "LGPL"), in
+ * which case the following provisions apply instead of the ones
+ * mentioned above:
+ *
+ * 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#ifndef __GST_SRTP_ELEMENTS_H__
+#define __GST_SRTP_ELEMENTS_H__
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "gstsrtp.h"
+#include "gstsrtpenums.h"
+#include "gstsrtp-enumtypes.h"
+
+#include <gst/gst.h>
+
+void srtp_element_init (GstPlugin * plugin);
+
+GST_ELEMENT_REGISTER_DECLARE (srtpdec);
+GST_ELEMENT_REGISTER_DECLARE (srtpenc);
+
+#endif /* __GST_SRTP_ELEMENTS_H__ */
index d677afc..5e17f2c 100644 (file)
  * will be added to every buffer.
  */
 
+#include "gstsrtpelements.h"
 #include "gstsrtpenc.h"
 
 #include <gst/rtp/gstrtpbuffer.h>
@@ -201,7 +202,10 @@ GST_STATIC_PAD_TEMPLATE ("rtcp_src_%u",
     GST_STATIC_CAPS ("application/x-srtcp")
     );
 
-G_DEFINE_TYPE (GstSrtpEnc, gst_srtp_enc, GST_TYPE_ELEMENT);
+G_DEFINE_TYPE_WITH_CODE (GstSrtpEnc, gst_srtp_enc, GST_TYPE_ELEMENT,
+    GST_DEBUG_CATEGORY_INIT (gst_srtp_enc_debug, "srtpenc", 0, "SRTP Enc"););
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (srtpenc, "srtpenc", GST_RANK_NONE,
+    GST_TYPE_SRTP_ENC, srtp_element_init (plugin));
 
 static guint gst_srtp_enc_signals[LAST_SIGNAL] = { 0 };
 
@@ -1492,16 +1496,3 @@ gst_srtp_enc_sink_event_rtcp (GstPad * pad, GstObject * parent,
 {
   return gst_srtp_enc_sink_event (pad, parent, event, TRUE);
 }
-
-/* entry point to initialize the plug-in
- * initialize the plug-in itself
- * register the element factories and other features
- */
-gboolean
-gst_srtp_enc_plugin_init (GstPlugin * srtpenc)
-{
-  GST_DEBUG_CATEGORY_INIT (gst_srtp_enc_debug, "srtpenc", 0, "SRTP Enc");
-
-  return gst_element_register (srtpenc, "srtpenc", GST_RANK_NONE,
-      GST_TYPE_SRTP_ENC);
-}
index df2f8fd..ed02df4 100644 (file)
@@ -95,8 +95,6 @@ struct _GstSrtpEncClass
 
 GType gst_srtp_enc_get_type (void);
 
-gboolean gst_srtp_enc_plugin_init (GstPlugin * plugin);
-
 G_END_DECLS
 
 #endif /* __GST_SRTPENC_H__ */
diff --git a/ext/srtp/gstsrtpplugin.c b/ext/srtp/gstsrtpplugin.c
new file mode 100644 (file)
index 0000000..7fb6269
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * GStreamer - GStreamer SRTP encoder and decoder
+ *
+ * Copyright 2009-2013 Collabora Ltd.
+ *  @author: Gabriel Millaire <gabriel.millaire@collabora.co.uk>
+ *  @author: Olivier Crete <olivier.crete@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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
+#include "gstsrtpelements.h"
+
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+  gboolean ret = FALSE;
+
+  ret |= GST_ELEMENT_REGISTER (srtpenc, plugin);
+  ret |= GST_ELEMENT_REGISTER (srtpdec, plugin);
+
+  return ret;
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+    GST_VERSION_MINOR,
+    srtp,
+    "GStreamer SRTP",
+    plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
index affdac3..7f94719 100644 (file)
@@ -1,5 +1,7 @@
 srtp_sources = [
   'gstsrtp.c',
+  'gstsrtpelement.c',
+  'gstsrtpplugin.c',
   'gstsrtpdec.c',
   'gstsrtpenc.c',
 ]