diff --git a/ChangeLog b/ChangeLog index 4839536614..ce00afb7e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-09-09 Tim-Philipp Müller + + * ext/dvdread/dvdreadsrc.c: (gst_dvd_read_src_read): + Add convert query (needed for later when we just operate in time + format and let the base source class handle all the seeking stuff). + 2006-09-07 Stefan Kost * gst/asfdemux/gstasfdemux.c: @@ -17,13 +23,13 @@ 2006-09-01 Michael Smith + Patch by: Michal Benes : + * ext/a52dec/gsta52dec.c: (gst_a52dec_mode_get_type), (gst_a52dec_class_init), (gst_a52dec_init), (gst_a52dec_channels), (gst_a52dec_handle_frame), (gst_a52dec_change_state), (gst_a52dec_set_property), (gst_a52dec_get_property): * ext/a52dec/gsta52dec.h: - Patch from from Michal Benes : - Add two things to a52dec: configure the exact output format for ac3 decoding through properties, if desired. By default, configure an output format preferred by downstream. Now @@ -48,7 +54,7 @@ 2006-08-27 Stefan Kost * gst/mpegstream/gstmpegpacketize.c: (gst_mpeg_packetize_new): - fix build for debug disabled + Fix build for debug disabled 2006-08-22 Tim-Philipp Müller diff --git a/ext/dvdread/dvdreadsrc.c b/ext/dvdread/dvdreadsrc.c index c915980df9..d2b17a9d74 100644 --- a/ext/dvdread/dvdreadsrc.c +++ b/ext/dvdread/dvdreadsrc.c @@ -1339,6 +1339,103 @@ gst_dvd_read_src_do_position_query (GstDvdReadSrc * src, GstQuery * query) return TRUE; } +static gboolean +gst_dvd_read_src_do_convert_query (GstBaseSrc * basesrc, GstQuery * query) +{ + GstDvdReadSrc *src = GST_DVD_READ_SRC (basesrc); + GstFormat src_format, dest_format; + gboolean ret = FALSE; + gint64 src_val, dest_val; + + gst_query_parse_convert (query, &src_format, &src_val, &dest_format, NULL); + + if (src_format == dest_format) { + dest_val = src_val; + ret = TRUE; + goto done; + } + + /* Formats to consider: TIME, DEFAULT, BYTES, title, chapter, sector. + * Note: title and chapter are counted as starting from 0 here, just like + * in the context of seek events. Another note: DEFAULT format is undefined */ + + if (src_format == GST_FORMAT_BYTES) { + src_format = sector_format; + src_val /= DVD_VIDEO_LB_LEN; + } + + if (src_format == sector_format) { + /* SECTOR => xyz */ + if (dest_format == GST_FORMAT_TIME && src_val < G_MAXUINT) { + dest_val = gst_dvd_read_src_get_time_for_sector (src, (guint) src_val); + ret = (dest_val >= 0); + } else if (dest_format == GST_FORMAT_BYTES) { + dest_val = src_val * DVD_VIDEO_LB_LEN; + ret = TRUE; + } else { + ret = FALSE; + } + } else if (src_format == title_format) { + /* TITLE => xyz */ + if (dest_format == GST_FORMAT_TIME) { + /* not really true, but we use this to trick the base source into + * handling seeks in title-format for us (the source won't know that + * we changed the title in this case) (changing titles should really + * be done with an interface rather than a seek, but for now we're + * stuck with this mechanism. Fix in 0.11) */ + dest_val = (GstClockTime) 0; + ret = TRUE; + } else { + ret = FALSE; + } + } else if (src_format == chapter_format) { + /* CHAPTER => xyz */ + if (dest_format == GST_FORMAT_TIME) { + if (src->num_chapters >= 0 && src_val < src->num_chapters) { + dest_val = src->chapter_starts[src_val]; + ret = TRUE; + } + } else if (dest_format == sector_format) { + } else { + ret = FALSE; + } + } else if (src_format == GST_FORMAT_TIME) { + /* TIME => xyz */ + if (dest_format == sector_format || dest_format == GST_FORMAT_BYTES) { + dest_val = gst_dvd_read_src_get_sector_from_time (src, src_val); + ret = (dest_val >= 0); + if (dest_format == GST_FORMAT_BYTES) + dest_val *= DVD_VIDEO_LB_LEN; + } else if (dest_format == chapter_format) { + if (src->chapter_starts != NULL) { + gint i; + + for (i = src->num_chapters - 1; i >= 0; --i) { + if (src->chapter_starts && src->chapter_starts[i] >= src_val) { + dest_val = i; + ret = TRUE; + break; + } + } + } else { + ret = FALSE; + } + } else { + ret = FALSE; + } + } else { + ret = FALSE; + } + +done: + + if (ret) { + gst_query_set_convert (query, src_format, src_val, dest_format, dest_val); + } + + return ret; +} + static gboolean gst_dvd_read_src_src_query (GstBaseSrc * basesrc, GstQuery * query) { @@ -1369,6 +1466,11 @@ gst_dvd_read_src_src_query (GstBaseSrc * basesrc, GstQuery * query) res = gst_dvd_read_src_do_position_query (src, query); GST_OBJECT_UNLOCK (src); break; + case GST_QUERY_CONVERT: + GST_OBJECT_LOCK (src); + res = gst_dvd_read_src_do_convert_query (src, query); + GST_OBJECT_UNLOCK (src); + break; default: res = GST_BASE_SRC_CLASS (parent_class)->query (basesrc, query); break;