webrtcbin: fix blocking of receive bin
authorMathieu Duponchelle <mathieu@centricular.com>
Sat, 1 Feb 2020 00:37:08 +0000 (01:37 +0100)
committerMathieu Duponchelle <mathieu@centricular.com>
Sat, 1 Feb 2020 00:46:57 +0000 (01:46 +0100)
The receive bin should block buffers from reaching dtlsdec before
the dtls connection has started.

While there was code to block its sinkpads until receive_state
was different from BLOCK, nothing was ever setting it to BLOCK
in the first place. This commit corrects this by setting the
initial state to BLOCK, directly in the constructor.

In addition, now that blocking is effective, we want to only
block buffers and buffer lists, as that's what might trigger
errors, we want to still let events and queries go through,
not doing so causes immediate deadlocks when linking the
bin.

ext/webrtc/transportreceivebin.c

index 667fae6..16a0452 100644 (file)
@@ -215,13 +215,14 @@ transport_receive_bin_change_state (GstElement * element,
       receive->rtp_block =
           _create_pad_block (GST_ELEMENT (receive), pad, 0, NULL, NULL);
       receive->rtp_block->block_id =
-          gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_ALL_BOTH,
+          gst_pad_add_probe (pad,
+          GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST,
           (GstPadProbeCallback) pad_block, receive, NULL);
       gst_object_unref (pad);
 
       receive->rtp_src_probe_id = gst_pad_add_probe (receive->rtp_src,
-          GST_PAD_PROBE_TYPE_ALL_BOTH, (GstPadProbeCallback) src_probe_cb,
-          receive, NULL);
+          GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST,
+          (GstPadProbeCallback) src_probe_cb, receive, NULL);
 
       transport = receive->stream->rtcp_transport;
       dtlssrtpdec = transport->dtlssrtpdec;
@@ -229,13 +230,14 @@ transport_receive_bin_change_state (GstElement * element,
       receive->rtcp_block =
           _create_pad_block (GST_ELEMENT (receive), pad, 0, NULL, NULL);
       receive->rtcp_block->block_id =
-          gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_ALL_BOTH,
+          gst_pad_add_probe (pad,
+          GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST,
           (GstPadProbeCallback) pad_block, receive, NULL);
       gst_object_unref (pad);
 
       receive->rtcp_src_probe_id = gst_pad_add_probe (receive->rtcp_src,
-          GST_PAD_PROBE_TYPE_ALL_BOTH, (GstPadProbeCallback) src_probe_cb,
-          receive, NULL);
+          GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST,
+          (GstPadProbeCallback) src_probe_cb, receive, NULL);
 
       /* XXX: because nice needs the nicesrc internal main loop running in order
        * correctly STUN... */
@@ -448,6 +450,7 @@ transport_receive_bin_class_init (TransportReceiveBinClass * klass)
 static void
 transport_receive_bin_init (TransportReceiveBin * receive)
 {
+  receive->receive_state = RECEIVE_STATE_BLOCK;
   g_mutex_init (&receive->pad_block_lock);
   g_cond_init (&receive->pad_block_cond);
 }