[0.10] gst-plugins-base: oggdemux: assume live stream if byte size cannot be determined

Tim Müller tpm at kemper.freedesktop.org
Thu Jan 12 09:48:34 PST 2012


Module: gst-plugins-base
Branch: 0.10
Commit: c79dedf63374126a96a089e5cfcd47b112305186
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-base/commit/?id=c79dedf63374126a96a089e5cfcd47b112305186

Author: Vincent Penquerc'h <vincent.penquerch at collabora.co.uk>
Date:   Fri Dec 16 15:27:24 2011 +0000

oggdemux: assume live stream if byte size cannot be determined

This prevents trying to seek and failing, then ending up unable
to stream because we can't get back at the headers.
A more robust way would be to find a good place to reinject the
headers when a seek fails, but I can't seem to get this to work.

---

 ext/ogg/gstoggdemux.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/ext/ogg/gstoggdemux.c b/ext/ogg/gstoggdemux.c
index b9cb31b..a06aec8 100644
--- a/ext/ogg/gstoggdemux.c
+++ b/ext/ogg/gstoggdemux.c
@@ -331,6 +331,8 @@ gst_ogg_pad_src_query (GstPad * pad, GstQuery * query)
         if (ogg->pullmode) {
           seekable = TRUE;
           stop = ogg->total_time;
+        } else if (ogg->push_disable_seeking) {
+          seekable = FALSE;
         } else if (ogg->current_chain->streams->len) {
           gint i;
 
@@ -3274,6 +3276,10 @@ gst_ogg_demux_check_duration_push (GstOggDemux * ogg, GstSeekFlags flags,
         ogg->push_byte_length = length;
         GST_DEBUG_OBJECT (ogg,
             "File byte length %" G_GINT64_FORMAT, ogg->push_byte_length);
+      } else {
+        GST_DEBUG_OBJECT (ogg, "File byte length unknown, assuming live");
+        ogg->push_disable_seeking = TRUE;
+        return TRUE;
       }
       format = GST_FORMAT_TIME;
       res = gst_pad_query_duration (peer, &format, &length);
@@ -4562,8 +4568,22 @@ gst_ogg_demux_change_state (GstElement * element, GstStateChange transition)
       ogg->push_byte_length = -1;
       ogg->push_time_length = GST_CLOCK_TIME_NONE;
       ogg->push_time_offset = GST_CLOCK_TIME_NONE;
-      ogg->push_disable_seeking = FALSE;
       ogg->push_state = PUSH_PLAYING;
+
+      ogg->push_disable_seeking = FALSE;
+      if (!ogg->pullmode) {
+        GstPad *peer;
+        if ((peer = gst_pad_get_peer (ogg->sinkpad)) != NULL) {
+          GstFormat format = GST_FORMAT_BYTES;
+          gint64 length = -1;
+          if (!gst_pad_query_duration (peer, &format, &length) || length <= 0) {
+            GST_DEBUG_OBJECT (ogg,
+                "Unable to determine stream size, assuming live, seeking disabled");
+            ogg->push_disable_seeking = TRUE;
+          }
+        }
+      }
+
       GST_PUSH_UNLOCK (ogg);
       gst_segment_init (&ogg->segment, GST_FORMAT_TIME);
       break;



More information about the gstreamer-commits mailing list