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.
This commit is contained in:
Vincent Penquerc'h 2015-02-23 11:30:36 +00:00
parent 969cf47a82
commit acaf534714

View file

@ -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 /* submit a page to an oggpad, this function will then submit all
* the packets in the page. * 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 */ /* keep track of time in push mode */
if (!ogg->pullmode) { if (!ogg->pullmode) {
result = gst_ogg_pad_handle_push_mode_state (pad, page); 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->group_id = G_MAXUINT;
ogg->push_disable_seeking = FALSE; ogg->push_disable_seeking = FALSE;
if (!ogg->pullmode) { gst_ogg_demux_query_duration_push (ogg);
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_PUSH_UNLOCK (ogg); GST_PUSH_UNLOCK (ogg);
gst_segment_init (&ogg->segment, GST_FORMAT_TIME); gst_segment_init (&ogg->segment, GST_FORMAT_TIME);
break; break;
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
break;
default: default:
break; break;
} }