diff --git a/ChangeLog b/ChangeLog index b4a7f57c3e..0ce37837af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +2005-10-19 Wim Taymans + + reviewed by: + + * examples/seeking/seek.c: (make_avi_msmpeg4v3_mp3_pipeline), + (query_positions_elems), (query_positions_pads), (update_scale), + (do_seek), (set_update_scale), (message_received), (main): + * ext/ogg/gstoggdemux.c: (gst_ogg_pad_src_query), + (gst_ogg_demux_perform_seek), (gst_ogg_demux_find_chains), + (gst_ogg_demux_loop): + * ext/ogg/gstogmparse.c: (gst_ogm_parse_sink_query): + * ext/theora/theoradec.c: (theora_dec_src_query), + (theora_dec_sink_event): + * ext/vorbis/vorbisdec.c: (vorbis_dec_src_query), + (vorbis_dec_sink_event), (vorbis_handle_data_packet): + * gst/adder/gstadder.c: (gst_adder_query): + * gst/audiotestsrc/gstaudiotestsrc.c: (gst_audiotestsrc_src_query): + * gst/playback/test3.c: (update_scale): + * gst/playback/test5.c: (new_pad), (no_more_pads), (start_finding), + (dump_element_stats), (main): + * gst/playback/test6.c: (main): + * gst/sine/gstsinesrc.c: (gst_sinesrc_src_query): + * gst/videotestsrc/gstvideotestsrc.c: + (gst_videotestsrc_class_init), (gst_videotestsrc_negotiate), + (gst_videotestsrc_newsegment): + 2005-10-19 Tim-Philipp Müller * gst/typefind/gsttypefindfunctions.c: (utf8_type_find), diff --git a/examples/seeking/seek.c b/examples/seeking/seek.c index 952460b168..101c663a19 100644 --- a/examples/seeking/seek.c +++ b/examples/seeking/seek.c @@ -871,7 +871,8 @@ query_positions_elems () format = seek_formats[i].format; - if (gst_element_query_position (element, &format, &position, &total)) { + if (gst_element_query_position (element, &format, &position) && + gst_element_query_duration (element, &format, &total)) { g_print ("%s %13" G_GINT64_FORMAT " / %13" G_GINT64_FORMAT " | ", seek_formats[i].name, position, total); } else { @@ -902,7 +903,8 @@ query_positions_pads () format = seek_formats[i].format; - if (gst_pad_query_position (pad, &format, &position, &total)) { + if (gst_pad_query_position (pad, &format, &position) && + gst_pad_query_duration (pad, &format, &total)) { g_print ("%s %13" G_GINT64_FORMAT " / %13" G_GINT64_FORMAT " | ", seek_formats[i].name, position, total); } else { @@ -932,13 +934,15 @@ update_scale (gpointer data) if (seekable_elements) { GstElement *element = GST_ELEMENT (seekable_elements->data); - gst_element_query_position (element, &format, &position, &duration); + gst_element_query_position (element, &format, &position); + gst_element_query_duration (element, &format, &duration); } } else { if (seekable_pads) { GstPad *pad = GST_PAD (seekable_pads->data); - gst_pad_query_position (pad, &format, &position, &duration); + gst_pad_query_position (pad, &format, &position); + gst_pad_query_duration (pad, &format, &duration); } } diff --git a/ext/ogg/gstoggdemux.c b/ext/ogg/gstoggdemux.c index 06e2e81833..83d9c1a8e7 100644 --- a/ext/ogg/gstoggdemux.c +++ b/ext/ogg/gstoggdemux.c @@ -364,19 +364,19 @@ gst_ogg_pad_src_query (GstPad * pad, GstQuery * query) cur = GST_OGG_PAD (pad); switch (GST_QUERY_TYPE (query)) { - case GST_QUERY_POSITION: + case GST_QUERY_DURATION: { GstFormat format; - gst_query_parse_position (query, &format, NULL, NULL); + gst_query_parse_duration (query, &format, NULL); /* can only get position in time */ if (format != GST_FORMAT_TIME) { - GST_DEBUG ("only query position on TIME is supported"); + GST_DEBUG ("only query duration on TIME is supported"); res = FALSE; goto done; } /* can only return the total time position */ - gst_query_set_position (query, GST_FORMAT_TIME, -1, ogg->total_time); + gst_query_set_duration (query, GST_FORMAT_TIME, ogg->total_time); break; } case GST_QUERY_CONVERT: @@ -2020,7 +2020,7 @@ gst_ogg_demux_find_chains (GstOggDemux * ogg) /* find length to read last page, we store this for later use. */ format = GST_FORMAT_BYTES; - res = gst_pad_query_position (peer, &format, NULL, &ogg->length); + res = gst_pad_query_duration (peer, &format, &ogg->length); gst_object_unref (peer); if (!res) goto no_length; diff --git a/ext/ogg/gstogmparse.c b/ext/ogg/gstogmparse.c index 05aebefd5b..0a1a3389b8 100644 --- a/ext/ogg/gstogmparse.c +++ b/ext/ogg/gstogmparse.c @@ -497,7 +497,7 @@ gst_ogm_parse_sink_query (GstPad * pad, GstQuery * query) { gint64 val; - gst_query_parse_position (query, &format, NULL, NULL); + gst_query_parse_position (query, &format, NULL); if (format != GST_FORMAT_DEFAULT && format != GST_FORMAT_TIME) return FALSE; @@ -505,7 +505,7 @@ gst_ogm_parse_sink_query (GstPad * pad, GstQuery * query) if ((res = gst_ogm_parse_sink_convert (pad, GST_FORMAT_DEFAULT, ogm->next_granulepos, &format, &val))) { /* don't know the total length here.. */ - gst_query_set_position (query, format, val, -1); + gst_query_set_position (query, format, val); } break; } diff --git a/ext/theora/theoradec.c b/ext/theora/theoradec.c index dc031aa89c..91c317cfa8 100644 --- a/ext/theora/theoradec.c +++ b/ext/theora/theoradec.c @@ -426,26 +426,18 @@ theora_dec_src_query (GstPad * pad, GstQuery * query) switch (GST_QUERY_TYPE (query)) { case GST_QUERY_POSITION: { - gint64 granulepos, total, value; + gint64 granulepos, value; GstFormat my_format, format; gint64 time; - /* forward to peer for total */ - if (!(res = gst_pad_query (GST_PAD_PEER (dec->sinkpad), query))) - goto error; - /* we can convert a granule position to everything */ granulepos = dec->granulepos; GST_LOG_OBJECT (dec, "query %p: we have current granule: %lld", query, granulepos); - /* parse total time from peer and format */ - gst_query_parse_position (query, &format, NULL, &total); - - GST_LOG_OBJECT (dec, - "query %p: peer returned total: %lld (format %u)", - query, total, format); + /* parse format */ + gst_query_parse_position (query, &format, NULL); /* and convert to the final format in two steps with time as the * intermediate step */ @@ -464,14 +456,18 @@ theora_dec_src_query (GstPad * pad, GstQuery * query) theora_dec_src_convert (pad, my_format, time, &format, &value))) goto error; - gst_query_set_position (query, format, value, total); + gst_query_set_position (query, format, value); GST_LOG_OBJECT (dec, - "query %p: we return %lld and %lld (format %u)", - query, value, total, format); + "query %p: we return %lld (format %u)", query, value, format); break; } + case GST_QUERY_DURATION: + /* forward to peer for total */ + if (!(res = gst_pad_query (GST_PAD_PEER (dec->sinkpad), query))) + goto error; + break; case GST_QUERY_CONVERT: { GstFormat src_fmt, dest_fmt; diff --git a/ext/vorbis/vorbisdec.c b/ext/vorbis/vorbisdec.c index 39a59488c0..8559cda713 100644 --- a/ext/vorbis/vorbisdec.c +++ b/ext/vorbis/vorbisdec.c @@ -278,15 +278,11 @@ vorbis_dec_src_query (GstPad * pad, GstQuery * query) case GST_QUERY_POSITION: { GstFormat format; - gint64 value, total; - - /* query peer for total length */ - if (!(res = gst_pad_query (GST_PAD_PEER (dec->sinkpad), query))) - goto error; + gint64 value; granulepos = dec->granulepos; - gst_query_parse_position (query, &format, NULL, &total); + gst_query_parse_position (query, &format, NULL); /* and convert to the final format */ if (!(res = @@ -296,7 +292,7 @@ vorbis_dec_src_query (GstPad * pad, GstQuery * query) value = (value - dec->segment_start) + dec->segment_base; - gst_query_set_position (query, format, value, total); + gst_query_set_position (query, format, value); GST_LOG_OBJECT (dec, "query %u: peer returned granulepos: %llu - we return %llu (format %u)", @@ -304,6 +300,13 @@ vorbis_dec_src_query (GstPad * pad, GstQuery * query) break; } + case GST_QUERY_DURATION: + { + /* query peer for total length */ + if (!(res = gst_pad_query (GST_PAD_PEER (dec->sinkpad), query))) + goto error; + break; + } case GST_QUERY_CONVERT: { GstFormat src_fmt, dest_fmt; diff --git a/gst/adder/gstadder.c b/gst/adder/gstadder.c index 9b75919cf3..5f3eb925c2 100644 --- a/gst/adder/gstadder.c +++ b/gst/adder/gstadder.c @@ -210,26 +210,30 @@ gst_adder_query (GstPad * pad, GstQuery * query) gboolean res = FALSE; switch (GST_QUERY_TYPE (query)) { - /* FIXME: what to do about the length? query all pads upstream and - * pick the longest length? or the shortest length? or what? */ case GST_QUERY_POSITION: { GstFormat format; - gst_query_parse_position (query, &format, NULL, NULL); + gst_query_parse_position (query, &format, NULL); - if (format == GST_FORMAT_TIME) { - gst_query_set_position (query, GST_FORMAT_TIME, adder->timestamp, - GST_CLOCK_TIME_NONE); - res = TRUE; - } else if (format == GST_FORMAT_DEFAULT) { - gst_query_set_position (query, GST_FORMAT_DEFAULT, adder->offset, - GST_BUFFER_OFFSET_NONE); - res = TRUE; + switch (format) { + case GST_FORMAT_TIME: + gst_query_set_position (query, GST_FORMAT_TIME, adder->timestamp); + res = TRUE; + break; + case GST_FORMAT_DEFAULT: + gst_query_set_position (query, GST_FORMAT_DEFAULT, adder->offset); + res = TRUE; + break; + default: + break; } - break; } + /* FIXME: what to do about the length? query all pads upstream and + * pick the longest length? or the shortest length? or what? */ + case GST_QUERY_DURATION: + break; default: break; } diff --git a/gst/audiotestsrc/gstaudiotestsrc.c b/gst/audiotestsrc/gstaudiotestsrc.c index 69926d0ae3..2de2551fea 100644 --- a/gst/audiotestsrc/gstaudiotestsrc.c +++ b/gst/audiotestsrc/gstaudiotestsrc.c @@ -254,7 +254,7 @@ gst_audiotestsrc_src_query (GstPad * pad, GstQuery * query) GstFormat format; gint64 current; - gst_query_parse_position (query, &format, NULL, NULL); + gst_query_parse_position (query, &format, NULL); switch (format) { case GST_FORMAT_TIME: @@ -273,10 +273,19 @@ gst_audiotestsrc_src_query (GstPad * pad, GstQuery * query) break; } if (res) { - gst_query_set_position (query, format, current, -1); + gst_query_set_position (query, format, current); } break; } + case GST_QUERY_DURATION: + { + GstFormat format; + + /* unlimited length */ + gst_query_parse_position (query, &format, NULL); + gst_query_set_duration (query, format, -1); + break; + } default: break; } diff --git a/gst/playback/test3.c b/gst/playback/test3.c index da2bf9f5ec..1529062b02 100644 --- a/gst/playback/test3.c +++ b/gst/playback/test3.c @@ -27,7 +27,8 @@ update_scale (GstElement * element) gint64 position; GstFormat format = GST_FORMAT_TIME; - gst_element_query_position (element, &format, &position, &duration); + gst_element_query_position (element, &format, &position); + gst_element_query_duration (element, &format, &duration); g_print ("%" G_GINT64_FORMAT " %" G_GINT64_FORMAT "\n", duration, position); diff --git a/gst/playback/test5.c b/gst/playback/test5.c index a2c945a6c2..c483c5bdaf 100644 --- a/gst/playback/test5.c +++ b/gst/playback/test5.c @@ -72,7 +72,7 @@ dump_element_stats (GstElement * element) if (gst_pad_query (pad, query)) { gint64 duration; - gst_query_parse_position (query, NULL, NULL, &duration); + gst_query_parse_duration (query, NULL, &duration); g_print (" duration: %" GST_TIME_FORMAT "\n", GST_TIME_ARGS (duration)); } diff --git a/gst/playback/test6.c b/gst/playback/test6.c index 6ca4c598d2..06fdfdba50 100644 --- a/gst/playback/test6.c +++ b/gst/playback/test6.c @@ -78,7 +78,7 @@ main (gint argc, gchar * argv[]) if (gst_pad_query (pad, query)) { gint64 duration; - gst_query_parse_position (query, NULL, NULL, &duration); + gst_query_parse_duration (query, NULL, &duration); g_print (" duration: %" GST_TIME_FORMAT "\n", GST_TIME_ARGS (duration)); } diff --git a/gst/sine/gstsinesrc.c b/gst/sine/gstsinesrc.c index 919b1706c7..ce04be1a7b 100644 --- a/gst/sine/gstsinesrc.c +++ b/gst/sine/gstsinesrc.c @@ -202,7 +202,7 @@ gst_sinesrc_src_query (GstPad * pad, GstQuery * query) GstFormat format; gint64 current; - gst_query_parse_position (query, &format, NULL, NULL); + gst_query_parse_position (query, &format, NULL); switch (format) { case GST_FORMAT_TIME: @@ -221,10 +221,18 @@ gst_sinesrc_src_query (GstPad * pad, GstQuery * query) break; } if (res) { - gst_query_set_position (query, format, current, -1); + gst_query_set_position (query, format, current); } break; } + case GST_QUERY_DURATION: + { + GstFormat format; + + gst_query_parse_position (query, &format, NULL); + gst_query_set_position (query, format, -1); + break; + } default: break; } diff --git a/tests/examples/seek/seek.c b/tests/examples/seek/seek.c index 952460b168..101c663a19 100644 --- a/tests/examples/seek/seek.c +++ b/tests/examples/seek/seek.c @@ -871,7 +871,8 @@ query_positions_elems () format = seek_formats[i].format; - if (gst_element_query_position (element, &format, &position, &total)) { + if (gst_element_query_position (element, &format, &position) && + gst_element_query_duration (element, &format, &total)) { g_print ("%s %13" G_GINT64_FORMAT " / %13" G_GINT64_FORMAT " | ", seek_formats[i].name, position, total); } else { @@ -902,7 +903,8 @@ query_positions_pads () format = seek_formats[i].format; - if (gst_pad_query_position (pad, &format, &position, &total)) { + if (gst_pad_query_position (pad, &format, &position) && + gst_pad_query_duration (pad, &format, &total)) { g_print ("%s %13" G_GINT64_FORMAT " / %13" G_GINT64_FORMAT " | ", seek_formats[i].name, position, total); } else { @@ -932,13 +934,15 @@ update_scale (gpointer data) if (seekable_elements) { GstElement *element = GST_ELEMENT (seekable_elements->data); - gst_element_query_position (element, &format, &position, &duration); + gst_element_query_position (element, &format, &position); + gst_element_query_duration (element, &format, &duration); } } else { if (seekable_pads) { GstPad *pad = GST_PAD (seekable_pads->data); - gst_pad_query_position (pad, &format, &position, &duration); + gst_pad_query_position (pad, &format, &position); + gst_pad_query_duration (pad, &format, &duration); } }