rtmp2src: Answer scheduling query
authorEdward Hervey <edward@centricular.com>
Wed, 20 May 2020 08:54:21 +0000 (10:54 +0200)
committerEdward Hervey <bilboed@bilboed.com>
Wed, 20 May 2020 08:55:55 +0000 (10:55 +0200)
Just like for rtmpsrc, we must inform downstream that we are a
sequential (i.e. don't do random access efficiently) and
bandwith-limited (i.e. might need buffering downstream) element

Fixes buffering issues with playbin3

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

gst/rtmp2/gstrtmp2src.c

index 150b42f..c3603ae 100644 (file)
@@ -106,6 +106,7 @@ static gboolean gst_rtmp2_src_unlock (GstBaseSrc * src);
 static gboolean gst_rtmp2_src_unlock_stop (GstBaseSrc * src);
 static GstFlowReturn gst_rtmp2_src_create (GstBaseSrc * src, guint64 offset,
     guint size, GstBuffer ** outbuf);
+static gboolean gst_rtmp2_src_query (GstBaseSrc * src, GstQuery * query);
 
 /* Internal API */
 static void gst_rtmp2_src_task_func (gpointer user_data);
@@ -178,6 +179,7 @@ gst_rtmp2_src_class_init (GstRtmp2SrcClass * klass)
   base_src_class->unlock = GST_DEBUG_FUNCPTR (gst_rtmp2_src_unlock);
   base_src_class->unlock_stop = GST_DEBUG_FUNCPTR (gst_rtmp2_src_unlock_stop);
   base_src_class->create = GST_DEBUG_FUNCPTR (gst_rtmp2_src_create);
+  base_src_class->query = GST_DEBUG_FUNCPTR (gst_rtmp2_src_query);
 
   g_object_class_override_property (gobject_class, PROP_LOCATION, "location");
   g_object_class_override_property (gobject_class, PROP_SCHEME, "scheme");
@@ -694,6 +696,33 @@ out:
 }
 
 static gboolean
+gst_rtmp2_src_query (GstBaseSrc * basesrc, GstQuery * query)
+{
+  gboolean ret = FALSE;
+
+  switch (GST_QUERY_TYPE (query)) {
+    case GST_QUERY_SCHEDULING:{
+      gst_query_set_scheduling (query,
+          GST_SCHEDULING_FLAG_SEQUENTIAL |
+          GST_SCHEDULING_FLAG_BANDWIDTH_LIMITED, 1, -1, 0);
+      gst_query_add_scheduling_mode (query, GST_PAD_MODE_PUSH);
+
+      ret = TRUE;
+      break;
+    }
+    default:
+      ret = FALSE;
+      break;
+  }
+
+  if (!ret)
+    ret =
+        GST_BASE_SRC_CLASS (gst_rtmp2_src_parent_class)->query (basesrc, query);
+
+  return ret;
+}
+
+static gboolean
 main_loop_running_cb (GstRtmp2Src * self)
 {
   GST_TRACE_OBJECT (self, "Main loop running now");