From acaf534714e380886ffc2f17b874513dd6ddafdc Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Mon, 23 Feb 2015 11:30:36 +0000 Subject: [PATCH] oggdemux: try harder to query duration from upstream READY->PAUSED can be too early as souphttpsrc can get the HTTP headers after this. Try again in the chain function. Also use seeking query to disable seeking if upstream reports being unseekable. --- ext/ogg/gstoggdemux.c | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/ext/ogg/gstoggdemux.c b/ext/ogg/gstoggdemux.c index 6a51d29..c34f90f 100644 --- a/ext/ogg/gstoggdemux.c +++ b/ext/ogg/gstoggdemux.c @@ -1822,6 +1822,36 @@ choked: } } +static void +gst_ogg_demux_query_duration_push (GstOggDemux * ogg) +{ + if (!ogg->pullmode && ogg->push_byte_length == -1) { + GstQuery *query; + gboolean seekable = FALSE; + + query = gst_query_new_seeking (GST_FORMAT_BYTES); + if (gst_pad_peer_query (ogg->sinkpad, query)) + gst_query_parse_seeking (query, NULL, &seekable, NULL, NULL); + gst_query_unref (query); + + if (seekable) { + gint64 length = -1; + if (!gst_element_query_duration (GST_ELEMENT (ogg), GST_FORMAT_BYTES, + &length) + || length <= 0) { + GST_DEBUG_OBJECT (ogg, + "Unable to determine stream size, assuming live, seeking disabled"); + ogg->push_disable_seeking = TRUE; + } else { + ogg->push_disable_seeking = FALSE; + } + } else { + GST_DEBUG_OBJECT (ogg, "Stream is not seekable, seeking disabled"); + ogg->push_disable_seeking = TRUE; + } + } +} + /* submit a page to an oggpad, this function will then submit all * the packets in the page. */ @@ -1860,6 +1890,8 @@ gst_ogg_pad_submit_page (GstOggPad * pad, ogg_page * page) } } + gst_ogg_demux_query_duration_push (ogg); + /* keep track of time in push mode */ if (!ogg->pullmode) { result = gst_ogg_pad_handle_push_mode_state (pad, page); @@ -4832,25 +4864,10 @@ gst_ogg_demux_change_state (GstElement * element, GstStateChange transition) ogg->group_id = G_MAXUINT; ogg->push_disable_seeking = FALSE; - if (!ogg->pullmode) { - GstPad *peer; - if ((peer = gst_pad_get_peer (ogg->sinkpad)) != NULL) { - gint64 length = -1; - if (!gst_pad_query_duration (peer, GST_FORMAT_BYTES, &length) - || length <= 0) { - GST_DEBUG_OBJECT (ogg, - "Unable to determine stream size, assuming live, seeking disabled"); - ogg->push_disable_seeking = TRUE; - } - gst_object_unref (peer); - } - } - + gst_ogg_demux_query_duration_push (ogg); GST_PUSH_UNLOCK (ogg); gst_segment_init (&ogg->segment, GST_FORMAT_TIME); break; - case GST_STATE_CHANGE_PAUSED_TO_PLAYING: - break; default: break; } -- 2.7.4