From 229377fb6bee4f6dafa4f120eb2ca9a65e8110e3 Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Fri, 16 Dec 2011 15:27:24 +0000 Subject: [PATCH] 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 file changed, 21 insertions(+), 1 deletion(-) diff --git a/ext/ogg/gstoggdemux.c b/ext/ogg/gstoggdemux.c index b9cb31bef9..a06aec8f39 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;