webrtc: Move dtlssrtpenc state management
Move the errant piece of dtlssrtpenc state change
management from dtlstransport in the Webrtc libs,
into the transportsendbin that does the rest of
the element management so it's all in one place.
diff --git a/ext/webrtc/transportsendbin.c b/ext/webrtc/transportsendbin.c
index 3a9b5c6..021ede6 100644
--- a/ext/webrtc/transportsendbin.c
+++ b/ext/webrtc/transportsendbin.c
@@ -304,6 +304,17 @@
}
static void
+_on_notify_dtls_client_status (GstElement * dtlssrtpenc,
+ GParamSpec * pspec, TransportSendBin * send)
+{
+ GST_DEBUG_OBJECT (send,
+ "DTLS-SRTP encoder configured. Unlocking it and changing state %"
+ GST_PTR_FORMAT, dtlssrtpenc);
+ gst_element_set_locked_state (dtlssrtpenc, FALSE);
+ gst_element_sync_state_with_parent (dtlssrtpenc);
+}
+
+static void
_on_notify_ice_connection_state (GstWebRTCICETransport * transport,
GParamSpec * pspec, TransportSendBin * send)
{
@@ -356,6 +367,9 @@
/* unblock the encoder once the key is set */
g_signal_connect (transport->dtlssrtpenc, "on-key-set",
G_CALLBACK (_on_dtls_enc_key_set), send);
+ /* Bring the encoder up to current state only once the is-client prop is set */
+ g_signal_connect (transport->dtlssrtpenc, "notify::is-client",
+ G_CALLBACK (_on_notify_dtls_client_status), send);
gst_bin_add (GST_BIN (send), GST_ELEMENT (transport->dtlssrtpenc));
/* unblock ice sink once it signals a connection */
@@ -386,6 +400,9 @@
/* unblock the encoder once the key is set */
g_signal_connect (transport->dtlssrtpenc, "on-key-set",
G_CALLBACK (_on_dtls_enc_key_set), send);
+ /* Bring the encoder up to current state only once the is-client prop is set */
+ g_signal_connect (transport->dtlssrtpenc, "notify::is-client",
+ G_CALLBACK (_on_notify_dtls_client_status), send);
gst_bin_add (GST_BIN (send), GST_ELEMENT (transport->dtlssrtpenc));
/* unblock ice sink once it signals a connection */
diff --git a/gst-libs/gst/webrtc/dtlstransport.c b/gst-libs/gst/webrtc/dtlstransport.c
index 9c06253..c3b2d51 100644
--- a/gst-libs/gst/webrtc/dtlstransport.c
+++ b/gst-libs/gst/webrtc/dtlstransport.c
@@ -84,8 +84,6 @@
case PROP_CLIENT:
g_object_set_property (G_OBJECT (webrtc->dtlssrtpenc), "is-client",
value);
- gst_element_set_locked_state (webrtc->dtlssrtpenc, FALSE);
- gst_element_sync_state_with_parent (webrtc->dtlssrtpenc);
break;
case PROP_CERTIFICATE:
g_object_set_property (G_OBJECT (webrtc->dtlssrtpdec), "pem", value);