From 607ef6db60e9ec70b89e79ccc7bd56b73ec2dcb2 Mon Sep 17 00:00:00 2001 From: Johan Sternerup Date: Fri, 7 May 2021 08:12:25 +0200 Subject: webrtc: Split sctptransport into lib and implementation parts GstWebRTCSCTPTransport is now made into into an abstract base class that only contains property specifications matching the RTCSctpTransport interface of the W3C WebRTC specification, see https://w3c.github.io/webrtc-pc/#rtcsctptransport-interface. This class is put into the WebRTC library to expose it for applications and to allow for generation of bindings for non-dynamic languages using GObject introspection. The actual implementation is moved to the subclass WebRTCSCTPTransport located in the WebRTC plugin. Part-of: --- gst-libs/gst/webrtc/meson.build | 2 + gst-libs/gst/webrtc/sctptransport.c | 79 +++++++++++++++++++++++++++++++++++++ gst-libs/gst/webrtc/sctptransport.h | 42 ++++++++++++++++++++ gst-libs/gst/webrtc/webrtc-priv.h | 21 ++++++++++ gst-libs/gst/webrtc/webrtc_fwd.h | 3 ++ 5 files changed, 147 insertions(+) create mode 100644 gst-libs/gst/webrtc/sctptransport.c create mode 100644 gst-libs/gst/webrtc/sctptransport.h (limited to 'gst-libs/gst') diff --git a/gst-libs/gst/webrtc/meson.build b/gst-libs/gst/webrtc/meson.build index efdba6556..c363828b5 100644 --- a/gst-libs/gst/webrtc/meson.build +++ b/gst-libs/gst/webrtc/meson.build @@ -6,6 +6,7 @@ webrtc_sources = [ 'rtpsender.c', 'rtptransceiver.c', 'datachannel.c', + 'sctptransport.c', ] webrtc_headers = [ @@ -18,6 +19,7 @@ webrtc_headers = [ 'datachannel.h', 'webrtc_fwd.h', 'webrtc.h', + 'sctptransport.h', ] webrtc_enumtypes_headers = [ diff --git a/gst-libs/gst/webrtc/sctptransport.c b/gst-libs/gst/webrtc/sctptransport.c new file mode 100644 index 000000000..4d0495a46 --- /dev/null +++ b/gst-libs/gst/webrtc/sctptransport.c @@ -0,0 +1,79 @@ +/* GStreamer + * Copyright (C) 2018 Matthew Waters + * + * 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 "sctptransport.h" +#include "webrtc-priv.h" + +G_DEFINE_ABSTRACT_TYPE (GstWebRTCSCTPTransport, gst_webrtc_sctp_transport, + GST_TYPE_OBJECT); + +static void +gst_webrtc_sctp_transport_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) +{ + /* all properties should by handled by the plugin class */ + g_assert_not_reached (); +} + +static void +gst_webrtc_sctp_transport_class_init (GstWebRTCSCTPTransportClass * klass) +{ + GObjectClass *gobject_class = (GObjectClass *) klass; + guint property_id_dummy = 0; + + gobject_class->get_property = gst_webrtc_sctp_transport_get_property; + + g_object_class_install_property (gobject_class, + ++property_id_dummy, + g_param_spec_object ("transport", + "WebRTC DTLS Transport", + "DTLS transport used for this SCTP transport", + GST_TYPE_WEBRTC_DTLS_TRANSPORT, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (gobject_class, + ++property_id_dummy, + g_param_spec_enum ("state", + "WebRTC SCTP Transport state", "WebRTC SCTP Transport state", + GST_TYPE_WEBRTC_SCTP_TRANSPORT_STATE, + GST_WEBRTC_SCTP_TRANSPORT_STATE_NEW, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (gobject_class, + ++property_id_dummy, + g_param_spec_uint64 ("max-message-size", + "Maximum message size", + "Maximum message size as reported by the transport", 0, G_MAXUINT64, + 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (gobject_class, + ++property_id_dummy, + g_param_spec_uint ("max-channels", + "Maximum number of channels", "Maximum number of channels", + 0, G_MAXUINT16, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); +} + +static void +gst_webrtc_sctp_transport_init (GstWebRTCSCTPTransport * nice) +{ +} diff --git a/gst-libs/gst/webrtc/sctptransport.h b/gst-libs/gst/webrtc/sctptransport.h new file mode 100644 index 000000000..99a46eede --- /dev/null +++ b/gst-libs/gst/webrtc/sctptransport.h @@ -0,0 +1,42 @@ +/* GStreamer + * Copyright (C) 2018 Matthew Waters + * + * 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_WEBRTC_SCTP_TRANSPORT_H__ +#define __GST_WEBRTC_SCTP_TRANSPORT_H__ + +#include +#include + +G_BEGIN_DECLS + +GST_WEBRTC_API +GType gst_webrtc_sctp_transport_get_type(void); + +#define GST_TYPE_WEBRTC_SCTP_TRANSPORT (gst_webrtc_sctp_transport_get_type()) +#define GST_WEBRTC_SCTP_TRANSPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_WEBRTC_SCTP_TRANSPORT,GstWebRTCSCTPTransport)) +#define GST_IS_WEBRTC_SCTP_TRANSPORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_WEBRTC_SCTP_TRANSPORT)) +#define GST_WEBRTC_SCTP_TRANSPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass) ,GST_TYPE_WEBRTC_SCTP_TRANSPORT,GstWebRTCSCTPTransportClass)) +#define GST_IS_WEBRTC_SCTP_TRANSPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_WEBRTC_SCTP_TRANSPORT)) +#define GST_WEBRTC_SCTP_TRANSPORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_WEBRTC_SCTP_TRANSPORT,GstWebRTCSCTPTransportClass)) + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstWebRTCSCTPTransport, gst_object_unref) + +G_END_DECLS + +#endif /* __GST_WEBRTC_SCTP_TRANSPORT_H__ */ diff --git a/gst-libs/gst/webrtc/webrtc-priv.h b/gst-libs/gst/webrtc/webrtc-priv.h index cf8a081c2..7366006b7 100644 --- a/gst-libs/gst/webrtc/webrtc-priv.h +++ b/gst-libs/gst/webrtc/webrtc-priv.h @@ -289,6 +289,27 @@ GST_WEBRTC_API void gst_webrtc_data_channel_on_buffered_amount_low (GstWebRTCDataChannel * channel); +/** + * GstWebRTCSCTPTransport: + * + * Since: 1.20 + */ +struct _GstWebRTCSCTPTransport +{ + GstObject parent; +}; + +/** + * GstWebRTCSCTPTransportClass: + * + * Since: 1.20 + */ +struct _GstWebRTCSCTPTransportClass +{ + GstObjectClass parent_class; +}; + + G_END_DECLS #endif /* __GST_WEBRTC_PRIV_H__ */ diff --git a/gst-libs/gst/webrtc/webrtc_fwd.h b/gst-libs/gst/webrtc/webrtc_fwd.h index f3f9aebb8..189e7b36c 100644 --- a/gst-libs/gst/webrtc/webrtc_fwd.h +++ b/gst-libs/gst/webrtc/webrtc_fwd.h @@ -92,6 +92,9 @@ typedef struct _GstWebRTCRTPTransceiverClass GstWebRTCRTPTransceiverClass; typedef struct _GstWebRTCDataChannel GstWebRTCDataChannel; typedef struct _GstWebRTCDataChannelClass GstWebRTCDataChannelClass; +typedef struct _GstWebRTCSCTPTransport GstWebRTCSCTPTransport; +typedef struct _GstWebRTCSCTPTransportClass GstWebRTCSCTPTransportClass; + /** * GstWebRTCDTLSTransportState: * @GST_WEBRTC_DTLS_TRANSPORT_STATE_NEW: new -- cgit v1.2.1