baseparse: answer position query in stream time and try upstream first
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Mon, 26 Sep 2011 12:14:42 +0000 (13:14 +0100)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Fri, 30 Sep 2011 14:23:33 +0000 (15:23 +0100)
Let the demuxer have first say as well.

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

libs/gst/base/gstbaseparse.c

index 67e380a..f95c3aa 100644 (file)
@@ -3148,22 +3148,24 @@ gst_base_parse_query (GstPad * pad, GstQuery * query)
       GST_DEBUG_OBJECT (parse, "position query");
       gst_query_parse_position (query, &format, NULL);
 
-      GST_OBJECT_LOCK (parse);
-      if (format == GST_FORMAT_BYTES) {
-        dest_value = parse->priv->offset;
-        res = TRUE;
-      } else if (format == parse->segment.format &&
-          GST_CLOCK_TIME_IS_VALID (parse->segment.last_stop)) {
-        dest_value = parse->segment.last_stop;
-        res = TRUE;
-      }
-      GST_OBJECT_UNLOCK (parse);
-
-      if (res)
-        gst_query_set_position (query, format, dest_value);
-      else {
-        res = gst_pad_query_default (pad, query);
-        if (!res) {
+      /* try upstream first */
+      res = gst_pad_query_default (pad, query);
+      if (!res) {
+        /* Fall back on interpreting segment */
+        GST_OBJECT_LOCK (parse);
+        if (format == GST_FORMAT_BYTES) {
+          dest_value = parse->priv->offset;
+          res = TRUE;
+        } else if (format == parse->segment.format &&
+            GST_CLOCK_TIME_IS_VALID (parse->segment.last_stop)) {
+          dest_value = gst_segment_to_stream_time (&parse->segment,
+              parse->segment.format, parse->segment.last_stop);
+          res = TRUE;
+        }
+        GST_OBJECT_UNLOCK (parse);
+        if (res)
+          gst_query_set_position (query, format, dest_value);
+        else {
           /* no precise result, upstream no idea either, then best estimate */
           /* priv->offset is updated in both PUSH/PULL modes */
           res = gst_base_parse_convert (parse,