gst: udpate for position/duration/convert query API changes

This commit is contained in:
Tim-Philipp Müller 2011-07-28 10:54:38 +01:00
parent f94ea7299a
commit b843f8f99c
10 changed files with 50 additions and 92 deletions

View file

@ -1184,10 +1184,9 @@ gst_flac_parse_generate_headers (GstFlacParse * flacparse)
{
gint64 duration;
GstFormat fmt = GST_FORMAT_TIME;
if (gst_pad_query_peer_duration (GST_BASE_PARSE_SINK_PAD (GST_BASE_PARSE
(flacparse)), &fmt, &duration) && fmt == GST_FORMAT_TIME) {
if (gst_pad_query_peer_duration (GST_BASE_PARSE_SINK_PAD (flacparse),
GST_FORMAT_TIME, &duration)) {
duration = GST_CLOCK_TIME_TO_FRAMES (duration, flacparse->samplerate);
data[17] |= (duration >> 32) & 0xff;

View file

@ -582,7 +582,6 @@ gst_mpeg_audio_parse_handle_first_frame (GstMpegAudioParse * mp3parse,
gint offset_xing, offset_vbri;
guint64 avail;
gint64 upstream_total_bytes = 0;
GstFormat fmt = GST_FORMAT_BYTES;
guint32 read_id_xing = 0, read_id_vbri = 0;
guint8 *data, *origdata;
gsize bufsize;
@ -623,9 +622,8 @@ gst_mpeg_audio_parse_handle_first_frame (GstMpegAudioParse * mp3parse,
}
/* obtain real upstream total bytes */
fmt = GST_FORMAT_BYTES;
if (!gst_pad_query_peer_duration (GST_BASE_PARSE_SINK_PAD (GST_BASE_PARSE
(mp3parse)), &fmt, &upstream_total_bytes))
if (!gst_pad_query_peer_duration (GST_BASE_PARSE_SINK_PAD (mp3parse),
GST_FORMAT_BYTES, &upstream_total_bytes))
upstream_total_bytes = 0;
if (read_id_xing == xing_id || read_id_xing == info_id) {

View file

@ -533,12 +533,12 @@ gst_au_parse_src_query (GstPad * pad, GstQuery * query)
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_DURATION:{
GstFormat bformat = GST_FORMAT_BYTES;
GstFormat format;
gint64 len, val;
gst_query_parse_duration (query, &format, NULL);
if (!gst_pad_query_peer_duration (auparse->sinkpad, &bformat, &len)) {
if (!gst_pad_query_peer_duration (auparse->sinkpad, GST_FORMAT_BYTES,
&len)) {
GST_DEBUG_OBJECT (auparse, "failed to query upstream length");
break;
}
@ -546,7 +546,9 @@ gst_au_parse_src_query (GstPad * pad, GstQuery * query)
len -= auparse->offset;
GST_OBJECT_UNLOCK (auparse);
ret = gst_au_parse_src_convert (auparse, bformat, len, format, &val);
ret =
gst_au_parse_src_convert (auparse, GST_FORMAT_BYTES, len, format,
&val);
if (ret) {
gst_query_set_duration (query, format, val);
@ -554,12 +556,12 @@ gst_au_parse_src_query (GstPad * pad, GstQuery * query)
break;
}
case GST_QUERY_POSITION:{
GstFormat bformat = GST_FORMAT_BYTES;
GstFormat format;
gint64 pos, val;
gst_query_parse_position (query, &format, NULL);
if (!gst_pad_query_peer_position (auparse->sinkpad, &bformat, &pos)) {
if (!gst_pad_query_peer_position (auparse->sinkpad, GST_FORMAT_BYTES,
&pos)) {
GST_DEBUG_OBJECT (auparse, "failed to query upstream position");
break;
}

View file

@ -531,7 +531,7 @@ gst_avi_demux_handle_src_query (GstPad * pad, GstQuery * query)
if (stream->idx_n >= 0)
gst_query_set_duration (query, fmt, stream->idx_n);
else if (gst_pad_query_convert (pad, GST_FORMAT_TIME,
duration, &fmt, &dur))
duration, fmt, &dur))
gst_query_set_duration (query, fmt, dur);
break;
}
@ -2931,7 +2931,6 @@ gst_avi_demux_stream_scan (GstAviDemux * avi)
{
GstFlowReturn res;
GstAviStream *stream;
GstFormat format;
guint64 pos = 0;
guint64 length;
gint64 tmplength;
@ -2944,8 +2943,7 @@ gst_avi_demux_stream_scan (GstAviDemux * avi)
GST_DEBUG_OBJECT (avi, "Creating index");
/* get the size of the file */
format = GST_FORMAT_BYTES;
if (!gst_pad_query_peer_duration (avi->sinkpad, &format, &tmplength))
if (!gst_pad_query_peer_duration (avi->sinkpad, GST_FORMAT_BYTES, &tmplength))
return FALSE;
length = tmplength;
@ -3107,10 +3105,8 @@ gst_avi_demux_check_seekability (GstAviDemux * avi)
/* try harder to query upstream size if we didn't get it the first time */
if (seekable && stop == -1) {
GstFormat fmt = GST_FORMAT_BYTES;
GST_DEBUG_OBJECT (avi, "doing duration query to fix up unset stop");
gst_pad_query_peer_duration (avi->sinkpad, &fmt, &stop);
gst_pad_query_peer_duration (avi->sinkpad, GST_FORMAT_BYTES, &stop);
}
/* if upstream doesn't know the size, it's likely that it's not seekable in
@ -3983,7 +3979,7 @@ gst_avi_demux_do_seek (GstAviDemux * avi, GstSegment * segment)
GstAviStream *stream;
seek_time = segment->position;
keyframe = !!(segment->flags & GST_SEEK_FLAG_KEY_UNIT);
keyframe = ! !(segment->flags & GST_SEEK_FLAG_KEY_UNIT);
GST_DEBUG_OBJECT (avi, "seek to: %" GST_TIME_FORMAT
" keyframe seeking:%d", GST_TIME_ARGS (seek_time), keyframe);
@ -4070,17 +4066,16 @@ gst_avi_demux_handle_seek (GstAviDemux * avi, GstPad * pad, GstEvent * event)
/* we have to have a format as the segment format. Try to convert
* if not. */
if (format != GST_FORMAT_TIME) {
GstFormat fmt = GST_FORMAT_TIME;
gboolean res = TRUE;
if (cur_type != GST_SEEK_TYPE_NONE)
res = gst_pad_query_convert (pad, format, cur, &fmt, &cur);
res = gst_pad_query_convert (pad, format, cur, GST_FORMAT_TIME, &cur);
if (res && stop_type != GST_SEEK_TYPE_NONE)
res = gst_pad_query_convert (pad, format, stop, &fmt, &stop);
res = gst_pad_query_convert (pad, format, stop, GST_FORMAT_TIME, &stop);
if (!res)
goto no_format;
format = fmt;
format = GST_FORMAT_TIME;
}
GST_DEBUG_OBJECT (avi,
"seek requested: rate %g cur %" GST_TIME_FORMAT " stop %"
@ -4204,19 +4199,18 @@ avi_demux_handle_seek_push (GstAviDemux * avi, GstPad * pad, GstEvent * event)
&cur_type, &cur, &stop_type, &stop);
if (format != GST_FORMAT_TIME) {
GstFormat fmt = GST_FORMAT_TIME;
gboolean res = TRUE;
if (cur_type != GST_SEEK_TYPE_NONE)
res = gst_pad_query_convert (pad, format, cur, &fmt, &cur);
res = gst_pad_query_convert (pad, format, cur, GST_FORMAT_TIME, &cur);
if (res && stop_type != GST_SEEK_TYPE_NONE)
res = gst_pad_query_convert (pad, format, stop, &fmt, &stop);
res = gst_pad_query_convert (pad, format, stop, GST_FORMAT_TIME, &stop);
if (!res) {
GST_DEBUG_OBJECT (avi, "unsupported format given, seek aborted.");
return FALSE;
}
format = fmt;
format = GST_FORMAT_TIME;
}
/* let gst_segment handle any tricky stuff */
@ -4225,7 +4219,7 @@ avi_demux_handle_seek_push (GstAviDemux * avi, GstPad * pad, GstEvent * event)
gst_segment_do_seek (&seeksegment, rate, format, flags,
cur_type, cur, stop_type, stop, &update);
keyframe = !!(flags & GST_SEEK_FLAG_KEY_UNIT);
keyframe = ! !(flags & GST_SEEK_FLAG_KEY_UNIT);
cur = seeksegment.position;
GST_DEBUG_OBJECT (avi,
@ -4819,7 +4813,6 @@ gst_avi_demux_stream_data (GstAviDemux * avi)
guint32 size = 0;
gint stream_nr = 0;
GstFlowReturn res = GST_FLOW_OK;
GstFormat format = GST_FORMAT_TIME;
if (G_UNLIKELY (avi->have_eos)) {
/* Clean adapter, we're done */
@ -4975,9 +4968,8 @@ gst_avi_demux_stream_data (GstAviDemux * avi)
gst_buffer_unref (buf);
} else {
/* get time of this buffer */
gst_pad_query_position (stream->pad, &format, (gint64 *) & next_ts);
if (G_UNLIKELY (format != GST_FORMAT_TIME))
goto wrong_format;
gst_pad_query_position (stream->pad, GST_FORMAT_TIME,
(gint64 *) & next_ts);
gst_avi_demux_add_assoc (avi, stream, next_ts, offset, FALSE);
@ -4994,9 +4986,8 @@ gst_avi_demux_stream_data (GstAviDemux * avi)
/* invert the picture if needed */
buf = gst_avi_demux_invert (stream, buf);
gst_pad_query_position (stream->pad, &format, (gint64 *) & dur_ts);
if (G_UNLIKELY (format != GST_FORMAT_TIME))
goto wrong_format;
gst_pad_query_position (stream->pad, GST_FORMAT_TIME,
(gint64 *) & dur_ts);
GST_BUFFER_TIMESTAMP (buf) = next_ts;
GST_BUFFER_DURATION (buf) = dur_ts - next_ts;
@ -5035,17 +5026,7 @@ gst_avi_demux_stream_data (GstAviDemux * avi)
}
}
done:
return res;
/* ERRORS */
wrong_format:
{
GST_DEBUG_OBJECT (avi, "format %s != GST_FORMAT_TIME",
gst_format_get_name (format));
res = GST_FLOW_ERROR;
goto done;
}
}
/*

View file

@ -118,16 +118,15 @@ gst_navseek_init (GstNavSeek * navseek)
static void
gst_navseek_seek (GstNavSeek * navseek, gint64 offset)
{
GstFormat peer_format = GST_FORMAT_TIME;
gboolean ret;
GstPad *peer_pad;
gint64 peer_value;
/* Query for the current time then attempt to set to time + offset */
peer_pad = gst_pad_get_peer (GST_BASE_TRANSFORM (navseek)->sinkpad);
ret = gst_pad_query_position (peer_pad, &peer_format, &peer_value);
ret = gst_pad_query_position (peer_pad, GST_FORMAT_TIME, &peer_value);
if (ret && peer_format == GST_FORMAT_TIME) {
if (ret) {
GstEvent *event;
peer_value += offset;
@ -147,15 +146,14 @@ gst_navseek_seek (GstNavSeek * navseek, gint64 offset)
static void
gst_navseek_change_playback_rate (GstNavSeek * navseek, gdouble rate)
{
GstFormat peer_format = GST_FORMAT_TIME;
gboolean ret;
GstPad *peer_pad;
gint64 current_position;
peer_pad = gst_pad_get_peer (GST_BASE_TRANSFORM (navseek)->sinkpad);
ret = gst_pad_query_position (peer_pad, &peer_format, &current_position);
ret = gst_pad_query_position (peer_pad, GST_FORMAT_TIME, &current_position);
if (ret && peer_format == GST_FORMAT_TIME) {
if (ret) {
GstEvent *event;
gint64 start;
gint64 stop;

View file

@ -240,8 +240,8 @@ gst_progress_report_do_query (GstProgressReport * filter, GstFormat format,
if (filter->do_query || !buf) {
GST_LOG_OBJECT (filter, "using upstream query");
if (!gst_pad_query_peer_position (sink_pad, &format, &cur) ||
!gst_pad_query_peer_duration (sink_pad, &format, &total)) {
if (!gst_pad_query_peer_position (sink_pad, format, &cur) ||
!gst_pad_query_peer_duration (sink_pad, format, &total)) {
return FALSE;
}
} else {

View file

@ -119,11 +119,11 @@ gst_flv_demux_parse_and_add_index_entry (GstFlvDemux * demux, GstClockTime ts,
gboolean key;
gst_index_entry_assoc_map (entry, GST_FORMAT_TIME, &time);
key = !!(GST_INDEX_ASSOC_FLAGS (entry) & GST_ASSOCIATION_FLAG_KEY_UNIT);
key = ! !(GST_INDEX_ASSOC_FLAGS (entry) & GST_ASSOCIATION_FLAG_KEY_UNIT);
GST_LOG_OBJECT (demux, "position already mapped to time %" GST_TIME_FORMAT
", keyframe %d", GST_TIME_ARGS (time), key);
/* there is not really a way to delete the existing one */
if (time != ts || key != !!keyframe)
if (time != ts || key != ! !keyframe)
GST_DEBUG_OBJECT (demux, "metadata mismatch");
#endif
return;
@ -214,10 +214,8 @@ gst_flv_demux_check_seekability (GstFlvDemux * demux)
/* try harder to query upstream size if we didn't get it the first time */
if (demux->upstream_seekable && stop == -1) {
GstFormat fmt = GST_FORMAT_BYTES;
GST_DEBUG_OBJECT (demux, "doing duration query to fix up unset stop");
gst_pad_query_peer_duration (demux->sinkpad, &fmt, &stop);
gst_pad_query_peer_duration (demux->sinkpad, GST_FORMAT_BYTES, &stop);
}
/* if upstream doesn't know the size, it's likely that it's not seekable in
@ -2194,15 +2192,13 @@ static GstFlowReturn
gst_flv_demux_create_index (GstFlvDemux * demux, gint64 pos, GstClockTime ts)
{
gint64 size;
GstFormat fmt = GST_FORMAT_BYTES;
size_t tag_size;
guint64 old_offset;
GstBuffer *buffer;
GstClockTime tag_time;
GstFlowReturn ret = GST_FLOW_OK;
if (G_UNLIKELY (!gst_pad_query_peer_duration (demux->sinkpad, &fmt, &size) ||
fmt != GST_FORMAT_BYTES))
if (!gst_pad_query_peer_duration (demux->sinkpad, GST_FORMAT_BYTES, &size))
return GST_FLOW_OK;
GST_DEBUG_OBJECT (demux, "building index at %" G_GINT64_FORMAT
@ -2240,13 +2236,11 @@ static gint64
gst_flv_demux_get_metadata (GstFlvDemux * demux)
{
gint64 ret = 0, offset;
GstFormat fmt = GST_FORMAT_BYTES;
size_t tag_size, size;
GstBuffer *buffer = NULL;
guint8 *data;
if (G_UNLIKELY (!gst_pad_query_peer_duration (demux->sinkpad, &fmt, &offset)
|| fmt != GST_FORMAT_BYTES))
if (!gst_pad_query_peer_duration (demux->sinkpad, GST_FORMAT_BYTES, &offset))
goto exit;
ret = offset;
@ -2497,7 +2491,7 @@ flv_demux_handle_seek_push (GstFlvDemux * demux, GstEvent * event)
if (format != GST_FORMAT_TIME)
goto wrong_format;
flush = !!(flags & GST_SEEK_FLAG_FLUSH);
flush = ! !(flags & GST_SEEK_FLAG_FLUSH);
/* FIXME : the keyframe flag is never used ! */
/* Work on a copy until we are sure the seek succeeded. */
@ -2586,7 +2580,6 @@ gst_flv_demux_handle_seek_push (GstFlvDemux * demux, GstEvent * event)
if (!demux->indexed) {
guint64 seek_offset = 0;
gboolean building_index;
GstFormat fmt;
GST_OBJECT_LOCK (demux);
/* handle the seek in the chain function */
@ -2603,13 +2596,10 @@ gst_flv_demux_handle_seek_push (GstFlvDemux * demux, GstEvent * event)
building_index = demux->building_index;
if (!building_index) {
demux->building_index = TRUE;
fmt = GST_FORMAT_BYTES;
if (!demux->file_size
&& !gst_pad_query_peer_duration (demux->sinkpad, &fmt,
&& !gst_pad_query_peer_duration (demux->sinkpad, GST_FORMAT_BYTES,
&demux->file_size)) {
GST_WARNING_OBJECT (demux,
"Cannot obtain file size - %" G_GINT64_FORMAT ", format %u",
demux->file_size, fmt);
GST_WARNING_OBJECT (demux, "Failed to query upstream file size");
GST_OBJECT_UNLOCK (demux);
return FALSE;
}
@ -2662,7 +2652,7 @@ gst_flv_demux_handle_seek_pull (GstFlvDemux * demux, GstEvent * event,
demux->seeking = seeking;
GST_OBJECT_UNLOCK (demux);
flush = !!(flags & GST_SEEK_FLAG_FLUSH);
flush = ! !(flags & GST_SEEK_FLAG_FLUSH);
/* FIXME : the keyframe flag is never used */
if (flush) {

View file

@ -767,17 +767,13 @@ gst_flv_mux_create_metadata (GstFlvMux * mux)
if (mux->duration == GST_CLOCK_TIME_NONE) {
GSList *l;
GstFormat fmt = GST_FORMAT_TIME;
guint64 dur;
for (l = mux->collect->data; l; l = l->next) {
GstCollectData *cdata = l->data;
fmt = GST_FORMAT_TIME;
if (gst_pad_query_peer_duration (cdata->pad, &fmt, (gint64 *) & dur) &&
fmt == GST_FORMAT_TIME && dur != GST_CLOCK_TIME_NONE) {
if (gst_pad_query_peer_duration (cdata->pad, GST_FORMAT_TIME,
(gint64 *) & dur) && dur != GST_CLOCK_TIME_NONE) {
if (mux->duration == GST_CLOCK_TIME_NONE)
mux->duration = dur;
else

View file

@ -1184,7 +1184,6 @@ gst_qtdemux_convert_seek (GstPad * pad, GstFormat * format,
GstSeekType cur_type, gint64 * cur, GstSeekType stop_type, gint64 * stop)
{
gboolean res;
GstFormat fmt;
g_return_val_if_fail (format != NULL, FALSE);
g_return_val_if_fail (cur != NULL, FALSE);
@ -1193,12 +1192,11 @@ gst_qtdemux_convert_seek (GstPad * pad, GstFormat * format,
if (*format == GST_FORMAT_TIME)
return TRUE;
fmt = GST_FORMAT_TIME;
res = TRUE;
if (cur_type != GST_SEEK_TYPE_NONE)
res = gst_pad_query_convert (pad, *format, *cur, &fmt, cur);
res = gst_pad_query_convert (pad, *format, *cur, GST_FORMAT_TIME, cur);
if (res && stop_type != GST_SEEK_TYPE_NONE)
res = gst_pad_query_convert (pad, *format, *stop, &fmt, stop);
res = gst_pad_query_convert (pad, *format, *stop, GST_FORMAT_TIME, stop);
if (res)
*format = GST_FORMAT_TIME;
@ -7457,7 +7455,6 @@ too_many_streams:
static void
gst_qtdemux_guess_bitrate (GstQTDemux * qtdemux)
{
GstFormat format = GST_FORMAT_BYTES;
QtDemuxStream *stream = NULL;
gint64 size, duration, sys_bitrate, sum_bitrate = 0;
gint i;
@ -7468,8 +7465,7 @@ gst_qtdemux_guess_bitrate (GstQTDemux * qtdemux)
GST_DEBUG_OBJECT (qtdemux, "Looking for streams with unknown bitrate");
if (!gst_pad_query_peer_duration (qtdemux->sinkpad, &format, &size) ||
format != GST_FORMAT_BYTES) {
if (!gst_pad_query_peer_duration (qtdemux->sinkpad, GST_FORMAT_BYTES, &size)) {
GST_DEBUG_OBJECT (qtdemux,
"Size in bytes of the stream not known - bailing");
return;

View file

@ -782,11 +782,11 @@ gst_wavparse_perform_seek (GstWavParse * wav, GstEvent * event)
if (cur_type != GST_SEEK_TYPE_NONE)
res =
gst_pad_query_convert (wav->srcpad, format, cur,
&wav->segment.format, &cur);
wav->segment.format, &cur);
if (res && stop_type != GST_SEEK_TYPE_NONE)
res =
gst_pad_query_convert (wav->srcpad, format, stop,
&wav->segment.format, &stop);
wav->segment.format, &stop);
if (!res)
goto no_format;
@ -921,7 +921,7 @@ gst_wavparse_perform_seek (GstWavParse * wav, GstEvent * event)
/* make sure filesize is not exceeded due to rounding errors or so,
* same precaution as in _stream_headers */
bformat = GST_FORMAT_BYTES;
if (gst_pad_query_peer_duration (wav->sinkpad, &bformat, &upstream_size))
if (gst_pad_query_peer_duration (wav->sinkpad, bformat, &upstream_size))
wav->end_offset = MIN (wav->end_offset, upstream_size);
/* this is the range of bytes we will use for playback */
@ -1133,7 +1133,6 @@ gst_wavparse_stream_headers (GstWavParse * wav)
GstCaps *caps = NULL;
gchar *codec_name = NULL;
GstEvent **event_p;
GstFormat bformat;
gint64 upstream_size = 0;
/* search for "_fmt" chunk, which should be first */
@ -1278,8 +1277,7 @@ gst_wavparse_stream_headers (GstWavParse * wav)
}
bformat = GST_FORMAT_BYTES;
gst_pad_query_peer_duration (wav->sinkpad, &bformat, &upstream_size);
gst_pad_query_peer_duration (wav->sinkpad, GST_FORMAT_BYTES, &upstream_size);
GST_DEBUG_OBJECT (wav, "upstream size %" G_GUINT64_FORMAT, upstream_size);
/* loop headers until we get data */