summaryrefslogtreecommitdiff
path: root/ext/webrtc/gstwebrtcbin.c
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2021-03-31 11:49:36 -0400
committerOlivier CrĂȘte <olivier.crete@collabora.com>2021-04-12 18:37:27 -0400
commit572c2b6783559ec998f84d5505100ef2583f9be4 (patch)
treeb4cbe63a5d8feb62f97591446e60e780a2119519 /ext/webrtc/gstwebrtcbin.c
parent4a48e291ffae9c73c0c0e7507e18a64652abbc24 (diff)
downloadgstreamer-plugins-bad-572c2b6783559ec998f84d5505100ef2583f9be4.tar.gz
webrtcbin: Take PC_LOCK when requesting new pad
This is needed to avoid having the state change under us. 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.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/ext/webrtc/gstwebrtcbin.c b/ext/webrtc/gstwebrtcbin.c
index 18e722243..927badc09 100644
--- a/ext/webrtc/gstwebrtcbin.c
+++ b/ext/webrtc/gstwebrtcbin.c
@@ -6356,7 +6356,8 @@ gst_webrtc_bin_request_new_pad (GstElement * element, GstPadTemplate * templ,
return NULL;
}
- GST_OBJECT_LOCK (webrtc);
+ PC_LOCK (webrtc);
+
if (name == NULL || strlen (name) < 6 || !g_str_has_prefix (name, "sink_")) {
/* no name given when requesting the pad, use next available int */
serial = webrtc->priv->max_sink_pad_serial++;
@@ -6365,7 +6366,6 @@ gst_webrtc_bin_request_new_pad (GstElement * element, GstPadTemplate * templ,
serial = g_ascii_strtoull (&name[5], NULL, 10);
lock_mline = TRUE;
}
- GST_OBJECT_UNLOCK (webrtc);
if (lock_mline) {
GstWebRTCBinPad *pad2;
@@ -6383,7 +6383,7 @@ gst_webrtc_bin_request_new_pad (GstElement * element, GstPadTemplate * templ,
" existing m-line %d, but the transceiver's direction is %s",
name, serial, direction);
g_free (direction);
- return NULL;
+ goto error_out;
}
/* Reject transceivers that already have a pad allocated */
@@ -6393,7 +6393,7 @@ gst_webrtc_bin_request_new_pad (GstElement * element, GstPadTemplate * templ,
" but the transceiver associated with this m-line already has pad"
" %s", name, serial, GST_PAD_NAME (pad2));
gst_object_unref (pad2);
- return NULL;
+ goto error_out;
}
if (caps) {
@@ -6403,7 +6403,7 @@ gst_webrtc_bin_request_new_pad (GstElement * element, GstPadTemplate * templ,
" existing m-line %d, but requested caps %" GST_PTR_FORMAT
" don't match existing codec preferences %" GST_PTR_FORMAT,
name, serial, caps, trans->codec_preferences);
- return NULL;
+ goto error_out;
}
if (trans->kind != GST_WEBRTC_KIND_UNKNOWN) {
@@ -6414,7 +6414,7 @@ gst_webrtc_bin_request_new_pad (GstElement * element, GstPadTemplate * templ,
" existing m-line %d, but requested caps %" GST_PTR_FORMAT
" don't match transceiver kind %d",
name, serial, caps, trans->kind);
- return NULL;
+ goto error_out;
}
}
}
@@ -6486,7 +6486,6 @@ gst_webrtc_bin_request_new_pad (GstElement * element, GstPadTemplate * templ,
webrtc->priv->pending_sink_transceivers =
g_list_append (webrtc->priv->pending_sink_transceivers,
gst_object_ref (pad));
- _add_pad (webrtc, pad);
if (lock_mline) {
WebRTCTransceiver *wtrans = WEBRTC_TRANSCEIVER (trans);
@@ -6494,7 +6493,15 @@ gst_webrtc_bin_request_new_pad (GstElement * element, GstPadTemplate * templ,
trans->mline = serial;
}
+ PC_UNLOCK (webrtc);
+
+ _add_pad (webrtc, pad);
+
return GST_PAD (pad);
+
+error_out:
+ PC_UNLOCK (webrtc);
+ return NULL;
}
static void