From b2e773936456b5493808e11f2840ce51f17cfb02 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 12 Jan 2020 16:25:01 +0200 Subject: [PATCH] webrtc/dtlstransport: Proxy DTLS connection state from the DTLS elements to the transport Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/758 --- gst-libs/gst/webrtc/dtlstransport.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/webrtc/dtlstransport.c b/gst-libs/gst/webrtc/dtlstransport.c index ea7671f..0d2bfa4 100644 --- a/gst-libs/gst/webrtc/dtlstransport.c +++ b/gst-libs/gst/webrtc/dtlstransport.c @@ -146,6 +146,36 @@ gst_webrtc_dtls_transport_finalize (GObject * object) } static void +on_connection_state_changed (GObject * obj, GParamSpec * pspec, + gpointer user_data) +{ + GstWebRTCDTLSTransport *webrtc = GST_WEBRTC_DTLS_TRANSPORT (user_data); + gint state; + + g_object_get (obj, "connection-state", &state, NULL); + switch (state) { + case 0: + webrtc->state = GST_WEBRTC_DTLS_TRANSPORT_STATE_NEW; + break; + case 1: + webrtc->state = GST_WEBRTC_DTLS_TRANSPORT_STATE_CLOSED; + break; + default: + case 2: + webrtc->state = GST_WEBRTC_DTLS_TRANSPORT_STATE_FAILED; + break; + case 3: + webrtc->state = GST_WEBRTC_DTLS_TRANSPORT_STATE_CONNECTING; + break; + case 4: + webrtc->state = GST_WEBRTC_DTLS_TRANSPORT_STATE_CONNECTED; + break; + } + + g_object_notify (G_OBJECT (webrtc), "state"); +} + +static void gst_webrtc_dtls_transport_constructed (GObject * object) { GstWebRTCDTLSTransport *webrtc = GST_WEBRTC_DTLS_TRANSPORT (object); @@ -165,6 +195,9 @@ gst_webrtc_dtls_transport_constructed (GObject * object) g_object_set (webrtc->dtlssrtpdec, "connection-id", connection_id, NULL); g_free (connection_id); + g_signal_connect (webrtc->dtlssrtpenc, "notify::connection-state", + G_CALLBACK (on_connection_state_changed), webrtc); + G_OBJECT_CLASS (parent_class)->constructed (object); } @@ -191,7 +224,6 @@ gst_webrtc_dtls_transport_class_init (GstWebRTCDTLSTransportClass * klass) GST_TYPE_WEBRTC_ICE_TRANSPORT, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - /* FIXME: implement */ g_object_class_install_property (gobject_class, PROP_STATE, g_param_spec_enum ("state", "DTLS state", -- 2.7.4