From b94e46b8b416b0636bb8cb11e8355b717b6d1b33 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Sun, 19 Aug 2012 17:51:00 +0100 Subject: [PATCH] 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. --- libs/gst/base/gstbaseparse.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c index 5f4118f..c42d3c6 100644 --- a/libs/gst/base/gstbaseparse.c +++ b/libs/gst/base/gstbaseparse.c @@ -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."); -- 2.7.4