baseparse: make seeking in DEFAULT format work if the subclass can convert for us

We only deal in TIME format ourselves, but if the subclass can handle
converting other formats into TIME format, we can support that too.

Fixes seeking in DEFAULT (sample) format with flacparse,
and the flacdec unit test.
This commit is contained in:
Tim-Philipp Müller 2012-08-19 17:51:00 +01:00
parent fc0d6ce23a
commit b94e46b8b4

View file

@ -3762,9 +3762,21 @@ gst_base_parse_handle_seek (GstBaseParse * parse, GstEvent * event)
GST_TIME_FORMAT, gst_format_get_name (format), rate,
start_type, GST_TIME_ARGS (start), stop_type, GST_TIME_ARGS (stop));
/* we can only handle TIME */
if (format != GST_FORMAT_TIME)
goto done;
/* we can only handle TIME, so check if subclass can convert
* to TIME format if it's some other format (such as DEFAULT) */
if (format != GST_FORMAT_TIME) {
if (!gst_base_parse_convert (parse, format, start, GST_FORMAT_TIME, &start)
|| !gst_base_parse_convert (parse, format, stop, GST_FORMAT_TIME,
&stop))
goto no_convert_to_time;
GST_INFO_OBJECT (parse, "converted %s format to start time "
"%" GST_TIME_FORMAT " and stop time %" GST_TIME_FORMAT,
gst_format_get_name (format), GST_TIME_ARGS (start),
GST_TIME_ARGS (stop));
format = GST_FORMAT_TIME;
}
/* no negative rates in push mode (unless upstream takes care of that, but
* we've already tried upstream and it didn't handle the seek request) */
@ -3985,6 +3997,13 @@ wrong_type:
res = FALSE;
goto done;
}
no_convert_to_time:
{
GST_DEBUG_OBJECT (parse, "seek in %s format was requested, but subclass "
"couldn't convert that into TIME format", gst_format_get_name (format));
res = FALSE;
goto done;
}
convert_failed:
{
GST_DEBUG_OBJECT (parse, "conversion TIME to BYTES failed.");