webrtcbin: don't hold the webrtc lock over on-new-transceiver emission

Could potentially produce a deadlock if the direction is changed in the
callback.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5045>
This commit is contained in:
Matthew Waters 2023-07-17 15:39:59 +10:00 committed by GStreamer Marge Bot
parent 77e01571c8
commit 6af8b3dd80

View file

@ -2480,9 +2480,6 @@ _create_webrtc_transceiver (GstWebRTCBin * webrtc,
gst_object_unref (sender);
gst_object_unref (receiver);
g_signal_emit (webrtc, gst_webrtc_bin_signals[ON_NEW_TRANSCEIVER_SIGNAL],
0, trans);
return trans;
}
@ -4651,6 +4648,11 @@ _create_answer_task (GstWebRTCBin * webrtc, const GstStructure * options,
trans = _create_webrtc_transceiver (webrtc, answer_dir, i, kind, NULL);
rtp_trans = GST_WEBRTC_RTP_TRANSCEIVER (trans);
PC_UNLOCK (webrtc);
g_signal_emit (webrtc,
gst_webrtc_bin_signals[ON_NEW_TRANSCEIVER_SIGNAL], 0, rtp_trans);
PC_LOCK (webrtc);
GST_LOG_OBJECT (webrtc, "Created new transceiver %" GST_PTR_FORMAT
" for mline %u with media kind %d", trans, i, kind);
@ -6214,6 +6216,10 @@ _update_transceivers_from_sdp (GstWebRTCBin * webrtc, SDPSource source,
_get_direction_from_media (media), i, kind, NULL);
webrtc_transceiver_set_transport (t, stream);
trans = GST_WEBRTC_RTP_TRANSCEIVER (t);
PC_UNLOCK (webrtc);
g_signal_emit (webrtc,
gst_webrtc_bin_signals[ON_NEW_TRANSCEIVER_SIGNAL], 0, trans);
PC_LOCK (webrtc);
}
_update_transceiver_from_sdp_media (webrtc, sdp->sdp, i, stream,
@ -7090,6 +7096,9 @@ gst_webrtc_bin_add_transceiver (GstWebRTCBin * webrtc,
PC_UNLOCK (webrtc);
g_signal_emit (webrtc, gst_webrtc_bin_signals[ON_NEW_TRANSCEIVER_SIGNAL], 0,
trans);
return gst_object_ref (trans);
}
@ -8119,7 +8128,7 @@ gst_webrtc_bin_request_new_pad (GstElement * element, GstPadTemplate * templ,
const gchar * name, const GstCaps * caps)
{
GstWebRTCBin *webrtc = GST_WEBRTC_BIN (element);
GstWebRTCRTPTransceiver *trans = NULL;
GstWebRTCRTPTransceiver *trans = NULL, *created_trans = NULL;
GstWebRTCBinPad *pad = NULL;
guint serial;
gboolean lock_mline = FALSE;
@ -8247,7 +8256,8 @@ gst_webrtc_bin_request_new_pad (GstElement * element, GstPadTemplate * templ,
}
if (!trans) {
trans = GST_WEBRTC_RTP_TRANSCEIVER (_create_webrtc_transceiver (webrtc,
trans = created_trans =
GST_WEBRTC_RTP_TRANSCEIVER (_create_webrtc_transceiver (webrtc,
GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_SENDRECV, -1,
webrtc_kind_from_caps (caps), NULL));
GST_LOG_OBJECT (webrtc, "Created new transceiver %" GST_PTR_FORMAT, trans);
@ -8287,6 +8297,10 @@ gst_webrtc_bin_request_new_pad (GstElement * element, GstPadTemplate * templ,
PC_UNLOCK (webrtc);
if (created_trans)
g_signal_emit (webrtc, gst_webrtc_bin_signals[ON_NEW_TRANSCEIVER_SIGNAL],
0, created_trans);
_add_pad (webrtc, pad);
return GST_PAD (pad);