discoverer: Don't wait for subtitle streams to preroll
authorArun Raghavan <arun.raghavan@collabora.co.uk>
Wed, 3 Nov 2010 09:07:07 +0000 (14:37 +0530)
committerArun Raghavan <arun.raghavan@collabora.co.uk>
Tue, 8 Mar 2011 17:32:18 +0000 (23:02 +0530)
Subtitle streams being parse can cause the pipeline to wait indefinitely
to PREROLL. This makes subtitle streams got to PAUSED even if no data is
available. This should not be a cause for concern as we don't expect to
get much data for subtitle streams other than language tags from the
container.

https://bugzilla.gnome.org/show_bug.cgi?id=632291

gst-libs/gst/pbutils/gstdiscoverer.c

index 4a7d72d..58d3e52 100644 (file)
@@ -443,6 +443,15 @@ uridecodebin_pad_added_cb (GstElement * uridecodebin, GstPad * pad,
 {
   PrivateStream *ps;
   GstPad *sinkpad = NULL;
+  GstCaps *caps;
+  static GstCaps *subs_caps = NULL;
+
+  if (!subs_caps) {
+    subs_caps = gst_caps_from_string ("text/plain; text/x-pango-markup; "
+        "subpicture/x-pgs; subpicture/x-dvb; application/x-subtitle-unknown; "
+        "application/x-ssa; application/x-ass; subtitle/x-kate; "
+        "video/x-dvd-subpicture; ");
+  }
 
   GST_DEBUG_OBJECT (dc, "pad %s:%s", GST_DEBUG_PAD_NAME (pad));
 
@@ -459,6 +468,16 @@ uridecodebin_pad_added_cb (GstElement * uridecodebin, GstPad * pad,
   g_object_set (ps->sink, "silent", TRUE, NULL);
   g_object_set (ps->queue, "max-size-buffers", 1, "silent", TRUE, NULL);
 
+  caps = gst_pad_get_caps_reffed (pad);
+
+  if (gst_caps_can_intersect (caps, subs_caps)) {
+    /* Subtitle streams are sparse and don't provide any information - don't
+     * wait for data to preroll */
+    g_object_set (ps->sink, "async", FALSE, NULL);
+  }
+
+  gst_caps_unref (caps);
+
   gst_bin_add_many (dc->priv->pipeline, ps->queue, ps->sink, NULL);
 
   if (!gst_element_link_pads_full (ps->queue, "src", ps->sink, "sink",