srtp: 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>
This commit is contained in:
Stéphane Cerveau 2021-02-24 12:52:08 +01:00 committed by GStreamer Marge Bot
parent bbe0258e1d
commit 4f16edf0d0
9 changed files with 162 additions and 56 deletions

View 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)

View file

@ -115,8 +115,8 @@
*
*/
#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);
}

View 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

41
ext/srtp/gstsrtpelement.c Normal file
View file

@ -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);
}
}

View file

@ -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__ */

View file

@ -106,6 +106,7 @@
* 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);
}

View 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__ */

45
ext/srtp/gstsrtpplugin.c Normal file
View file

@ -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)

View file

@ -1,5 +1,7 @@
srtp_sources = [
'gstsrtp.c',
'gstsrtpelement.c',
'gstsrtpplugin.c',
'gstsrtpdec.c',
'gstsrtpenc.c',
]