diff options
author | Olivier CrĂȘte <olivier.crete@collabora.com> | 2021-03-31 11:56:10 -0400 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2021-04-12 18:37:27 -0400 |
commit | 913383166b675c9d46d892d19075c6fcfe094789 (patch) | |
tree | 57152c8aa5a3ef25a5526b9f6c2a15675a21a38d /ext/webrtc/gstwebrtcbin.c | |
parent | 572c2b6783559ec998f84d5505100ef2583f9be4 (diff) | |
download | gstreamer-plugins-bad-913383166b675c9d46d892d19075c6fcfe094789.tar.gz |
webrtcbin: Take PC lock around all entry points
All of those action signals change the internal state, so
protect it by using the PC_LOCK
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
Diffstat (limited to 'ext/webrtc/gstwebrtcbin.c')
-rw-r--r-- | ext/webrtc/gstwebrtcbin.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/ext/webrtc/gstwebrtcbin.c b/ext/webrtc/gstwebrtcbin.c index 927badc09..304129465 100644 --- a/ext/webrtc/gstwebrtcbin.c +++ b/ext/webrtc/gstwebrtcbin.c @@ -5508,6 +5508,8 @@ gst_webrtc_bin_add_transceiver (GstWebRTCBin * webrtc, g_return_val_if_fail (direction != GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_NONE, NULL); + PC_LOCK (webrtc); + trans = _create_webrtc_transceiver (webrtc, direction, -1); GST_LOG_OBJECT (webrtc, "Created new unassociated transceiver %" GST_PTR_FORMAT, trans); @@ -5518,6 +5520,8 @@ gst_webrtc_bin_add_transceiver (GstWebRTCBin * webrtc, _update_transceiver_kind_from_caps (rtp_trans, caps); } + PC_UNLOCK (webrtc); + return gst_object_ref (trans); } @@ -5533,6 +5537,8 @@ gst_webrtc_bin_get_transceivers (GstWebRTCBin * webrtc) GArray *arr = g_array_new (FALSE, TRUE, sizeof (GstWebRTCRTPTransceiver *)); int i; + PC_LOCK (webrtc); + g_array_set_clear_func (arr, (GDestroyNotify) _deref_and_unref); for (i = 0; i < webrtc->priv->transceivers->len; i++) { @@ -5541,6 +5547,7 @@ gst_webrtc_bin_get_transceivers (GstWebRTCBin * webrtc) gst_object_ref (trans); g_array_append_val (arr, trans); } + PC_UNLOCK (webrtc); return arr; } @@ -5550,6 +5557,8 @@ gst_webrtc_bin_get_transceiver (GstWebRTCBin * webrtc, guint idx) { GstWebRTCRTPTransceiver *trans = NULL; + PC_LOCK (webrtc); + if (idx >= webrtc->priv->transceivers->len) { GST_ERROR_OBJECT (webrtc, "No transceiver for idx %d", idx); goto done; @@ -5559,18 +5568,25 @@ gst_webrtc_bin_get_transceiver (GstWebRTCBin * webrtc, guint idx) gst_object_ref (trans); done: + PC_UNLOCK (webrtc); return trans; } static gboolean gst_webrtc_bin_add_turn_server (GstWebRTCBin * webrtc, const gchar * uri) { + gboolean ret; + g_return_val_if_fail (GST_IS_WEBRTC_BIN (webrtc), FALSE); g_return_val_if_fail (uri != NULL, FALSE); GST_DEBUG_OBJECT (webrtc, "Adding turn server: %s", uri); - return gst_webrtc_ice_add_turn_server (webrtc->priv->ice, uri); + PC_LOCK (webrtc); + ret = gst_webrtc_ice_add_turn_server (webrtc->priv->ice, uri); + PC_UNLOCK (webrtc); + + return ret; } static gboolean |