webrtc receivebin: Drop serialized queries before receive queue
authorOlivier Crête <olivier.crete@collabora.com>
Tue, 29 Jun 2021 01:13:56 +0000 (21:13 -0400)
committerOlivier Crête <olivier.crete@collabora.com>
Tue, 29 Jun 2021 04:42:20 +0000 (00:42 -0400)
If they're not dropped, they can be blocked in the queue even if it is
leaky in the case where there is a buffer being pushed downstream. Since
in webrtc, it's unlikely that there will be a special allocator to
receive RTP packets, there is almost no downside to just ignoring the
queries.

Also drop queries if they get caught in the pad probe after the queue.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2363>

ext/webrtc/transportreceivebin.c

index b1e3da0..8f8a444 100644 (file)
@@ -96,7 +96,7 @@ pad_block (GstPad * pad, GstPadProbeInfo * info, TransportReceiveBin * receive)
    * them. Sticky events would be forwarded again later once we unblock
    * and we don't want to forward them here already because that might
    * cause a spurious GST_FLOW_FLUSHING */
-  if (GST_IS_EVENT (info->data))
+  if (GST_IS_EVENT (info->data) || GST_IS_QUERY (info->data))
     return GST_PAD_PROBE_DROP;
 
   /* But block on any actual data-flow so we don't accidentally send that
@@ -294,6 +294,18 @@ rtp_queue_overrun (GstElement * queue, TransportReceiveBin * receive)
   GST_WARNING_OBJECT (receive, "Internal receive queue overrun. Dropping data");
 }
 
+static GstPadProbeReturn
+drop_serialized_queries (GstPad * pad, GstPadProbeInfo * info,
+    TransportReceiveBin * receive)
+{
+  GstQuery *query = GST_PAD_PROBE_INFO_QUERY (info);
+
+  if (GST_QUERY_IS_SERIALIZED (query))
+    return GST_PAD_PROBE_DROP;
+  else
+    return GST_PAD_PROBE_PASS;
+}
+
 static void
 transport_receive_bin_constructed (GObject * object)
 {
@@ -321,6 +333,11 @@ transport_receive_bin_constructed (GObject * object)
   g_signal_connect (receive->queue, "overrun", G_CALLBACK (rtp_queue_overrun),
       receive);
 
+  pad = gst_element_get_static_pad (receive->queue, "sink");
+  gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM,
+      (GstPadProbeCallback) drop_serialized_queries, receive, NULL);
+  gst_object_unref (pad);
+
   gst_bin_add (GST_BIN (receive), GST_ELEMENT (receive->queue));
   gst_bin_add (GST_BIN (receive), GST_ELEMENT (capsfilter));
   if (!gst_element_link_pads (capsfilter, "src", receive->queue, "sink"))