Query API update.

Original commit message from CVS:
* 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):
Query API update.
This commit is contained in:
Wim Taymans 2005-10-19 15:55:33 +00:00
parent cdbb4ae9ca
commit f88e6c08fd
13 changed files with 110 additions and 55 deletions

View file

@ -1,3 +1,29 @@
2005-10-19 Wim Taymans <wim@fluendo.com>
reviewed by: <delete if not using a buddy>
* 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 <tim at centricular dot net>
* gst/typefind/gsttypefindfunctions.c: (utf8_type_find),

View file

@ -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);
}
}

View file

@ -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;

View file

@ -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;
}

View file

@ -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;

View file

@ -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;

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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);

View file

@ -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));
}

View file

@ -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));
}

View file

@ -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;
}

View file

@ -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);
}
}