From 86c009e7aa9e9900dfac13be654301a39fd38a7d Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Tue, 12 Jan 2021 19:12:42 +0100 Subject: [PATCH] webrtc: expose transport property on sender and receiver As advised by !1366#note_629558 , the nice transport should be accessed through: > transceiver->sender/receiver->transport/rtcp_transport->icetransport All the objects on the path can be accessed through properties except sender/receiver->transport. This patch addresses that. Part-of: --- ext/webrtc/webrtctransceiver.c | 9 +++++++-- gst-libs/gst/webrtc/rtpreceiver.c | 21 +++++++++++++++++++++ gst-libs/gst/webrtc/rtpsender.c | 22 +++++++++++++++++++++- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/ext/webrtc/webrtctransceiver.c b/ext/webrtc/webrtctransceiver.c index db012f3922..aa9f1e2a05 100644 --- a/ext/webrtc/webrtctransceiver.c +++ b/ext/webrtc/webrtctransceiver.c @@ -59,12 +59,17 @@ webrtc_transceiver_set_transport (WebRTCTransceiver * trans, gst_object_replace ((GstObject **) & trans->stream, (GstObject *) stream); - if (rtp_trans->sender) + if (rtp_trans->sender) { gst_object_replace ((GstObject **) & rtp_trans->sender->transport, (GstObject *) stream->transport); - if (rtp_trans->receiver) + g_object_notify (G_OBJECT (rtp_trans->sender), "transport"); + } + + if (rtp_trans->receiver) { gst_object_replace ((GstObject **) & rtp_trans->receiver->transport, (GstObject *) stream->transport); + g_object_notify (G_OBJECT (rtp_trans->receiver), "transport"); + } } GstWebRTCDTLSTransport * diff --git a/gst-libs/gst/webrtc/rtpreceiver.c b/gst-libs/gst/webrtc/rtpreceiver.c index fb8f6e658c..5f4c4d4e50 100644 --- a/gst-libs/gst/webrtc/rtpreceiver.c +++ b/gst-libs/gst/webrtc/rtpreceiver.c @@ -49,6 +49,7 @@ enum enum { PROP_0, + PROP_TRANSPORT, }; //static guint gst_webrtc_rtp_receiver_signals[LAST_SIGNAL] = { 0 }; @@ -68,7 +69,13 @@ static void gst_webrtc_rtp_receiver_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { + GstWebRTCRTPReceiver *receiver = GST_WEBRTC_RTP_RECEIVER (object); switch (prop_id) { + case PROP_TRANSPORT: + GST_OBJECT_LOCK (receiver); + g_value_set_object (value, receiver->transport); + GST_OBJECT_UNLOCK (receiver); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -95,6 +102,20 @@ gst_webrtc_rtp_receiver_class_init (GstWebRTCRTPReceiverClass * klass) gobject_class->get_property = gst_webrtc_rtp_receiver_get_property; gobject_class->set_property = gst_webrtc_rtp_receiver_set_property; gobject_class->finalize = gst_webrtc_rtp_receiver_finalize; + + /** + * GstWebRTCRTPReceiver:transport: + * + * The DTLS transport for this receiver + * + * Since: 1.20 + */ + g_object_class_install_property (gobject_class, + PROP_TRANSPORT, + g_param_spec_object ("transport", "Transport", + "The DTLS transport for this receiver", + GST_TYPE_WEBRTC_DTLS_TRANSPORT, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); } static void diff --git a/gst-libs/gst/webrtc/rtpsender.c b/gst-libs/gst/webrtc/rtpsender.c index 388c48d171..90221dd56c 100644 --- a/gst-libs/gst/webrtc/rtpsender.c +++ b/gst-libs/gst/webrtc/rtpsender.c @@ -51,7 +51,8 @@ enum enum { PROP_0, - PROP_PRIORITY + PROP_PRIORITY, + PROP_TRANSPORT, }; //static guint gst_webrtc_rtp_sender_signals[LAST_SIGNAL] = { 0 }; @@ -106,6 +107,11 @@ gst_webrtc_rtp_sender_get_property (GObject * object, guint prop_id, g_value_set_uint (value, sender->priority); GST_OBJECT_UNLOCK (sender); break; + case PROP_TRANSPORT: + GST_OBJECT_LOCK (sender); + g_value_set_object (value, sender->transport); + GST_OBJECT_UNLOCK (sender); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -147,6 +153,20 @@ gst_webrtc_rtp_sender_class_init (GstWebRTCRTPSenderClass * klass) "The priority from which to set the DSCP field on packets", GST_TYPE_WEBRTC_PRIORITY_TYPE, GST_WEBRTC_PRIORITY_TYPE_LOW, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + /** + * GstWebRTCRTPSender:transport: + * + * The DTLS transport for this sender + * + * Since: 1.20 + */ + g_object_class_install_property (gobject_class, + PROP_TRANSPORT, + g_param_spec_object ("transport", "Transport", + "The DTLS transport for this sender", + GST_TYPE_WEBRTC_DTLS_TRANSPORT, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); } static void