+2005-10-19 Wim Taymans <wim@fluendo.com>
+
+ * ext/dv/gstdvdemux.c: (gst_dvdemux_get_src_query_types),
+ (gst_dvdemux_src_query):
+ * ext/flac/gstflacdec.c: (gst_flacdec_length),
+ (gst_flacdec_src_query):
+ * ext/raw1394/gstdv1394src.c: (gst_dv1394src_query):
+ * ext/speex/gstspeexdec.c: (speex_dec_src_query):
+ * gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_query):
+ * gst/debug/gstnavseek.c: (gst_navseek_seek):
+ * gst/debug/progressreport.c: (gst_progress_report_report):
+ * gst/matroska/ebml-read.c: (gst_ebml_read_get_length):
+ * gst/matroska/matroska-demux.c:
+ (gst_matroska_demux_handle_src_query):
+ * gst/matroska/matroska-mux.c: (gst_matroska_mux_start):
+ * gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
+ (gst_wavparse_stream_headers), (gst_wavparse_stream_data),
+ (gst_wavparse_pad_convert), (gst_wavparse_pad_query),
+ (gst_wavparse_srcpad_event):
+ API change fix.
+
2005-10-19 Tim-Philipp Müller <tim at centricular dot net>
* gst/goom/filters.c:
{
static const GstQueryType src_query_types[] = {
GST_QUERY_POSITION,
+ GST_QUERY_DURATION,
GST_QUERY_CONVERT,
0
};
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_POSITION:
+ {
+ GstFormat format;
+ gint64 cur;
+
+ /* get target format */
+ gst_query_parse_position (query, &format, NULL);
+
+ /* bring the position to the requested format. */
+ if (!(res = gst_pad_query_convert (pad,
+ GST_FORMAT_TIME, dvdemux->timestamp, &format, &cur)))
+ goto error;
+ gst_query_set_position (query, format, cur);
+ break;
+ }
+ case GST_QUERY_DURATION:
{
GstFormat format;
GstFormat format2;
- gint64 cur, end;
+ gint64 end;
GstPad *peer;
/* get target format */
- gst_query_parse_position (query, &format, NULL, NULL);
+ gst_query_parse_duration (query, &format, NULL);
- /* change query to perform on peer */
- gst_query_set_position (query, GST_FORMAT_BYTES, -1, -1);
+ /* change query to bytes to perform on peer */
+ gst_query_set_duration (query, GST_FORMAT_BYTES, -1);
if ((peer = gst_pad_get_peer (dvdemux->sinkpad))) {
/* ask peer for total length */
}
/* get peer total length */
- gst_query_parse_position (query, NULL, NULL, &end);
+ gst_query_parse_duration (query, NULL, &end);
+
+ gst_object_unref (peer);
/* convert end to requested format */
if (end != -1) {
format2 = format;
if (!(res = gst_pad_query_convert (dvdemux->sinkpad,
GST_FORMAT_BYTES, end, &format2, &end))) {
- gst_object_unref (peer);
goto error;
}
}
- gst_object_unref (peer);
} else {
end = -1;
}
- /* bring the position to the requested format. */
- if (!(res = gst_pad_query_convert (pad,
- GST_FORMAT_TIME, dvdemux->timestamp, &format, &cur)))
- goto error;
- if (!(res = gst_pad_query_convert (pad, format2, end, &format, &end)))
- goto error;
- gst_query_set_position (query, format, cur, end);
+ gst_query_set_duration (query, format, end);
break;
}
case GST_QUERY_CONVERT:
if (!(peer = gst_pad_get_peer (flacdec->sinkpad)))
return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR;
- gst_pad_query_position (peer, &fmt, NULL, &len);
+ gst_pad_query_duration (peer, &fmt, &len);
gst_object_unref (peer);
if (fmt != GST_FORMAT_BYTES || len == -1)
return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR;
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_POSITION:{
- gint64 len, pos;
+ gint64 pos;
+ GstFormat fmt = GST_FORMAT_TIME;
+
+ pos = flacdec->total_samples;
+
+ if (gst_flacdec_convert_src (flacdec->srcpad,
+ GST_FORMAT_DEFAULT, pos, &fmt, &pos))
+ gst_query_set_position (query, GST_FORMAT_TIME, pos);
+ else
+ res = FALSE;
+ break;
+ }
+ case GST_QUERY_DURATION:{
+ gint64 len;
GstFormat fmt = GST_FORMAT_TIME;
if (flacdec->stream_samples == 0)
len = flacdec->total_samples;
else
len = flacdec->stream_samples;
- pos = flacdec->total_samples;
if (gst_flacdec_convert_src (flacdec->srcpad,
- GST_FORMAT_DEFAULT, len, &fmt, &len) &&
- gst_flacdec_convert_src (flacdec->srcpad,
- GST_FORMAT_DEFAULT, pos, &fmt, &pos))
- gst_query_set_position (query, GST_FORMAT_TIME, pos, len);
+ GST_FORMAT_DEFAULT, len, &fmt, &len))
+ gst_query_set_duration (query, GST_FORMAT_TIME, len);
else
res = FALSE;
break;
GstFormat format;
gint64 current;
- gst_query_parse_position (query, &format, NULL, NULL);
+ gst_query_parse_position (query, &format, NULL);
/* bring our current frame to the requested format */
res = gst_pad_query_convert (pad,
GST_FORMAT_DEFAULT, src->frame_sequence, &format, ¤t);
- gst_query_set_position (query, format, current, -1);
+ gst_query_set_position (query, format, current);
break;
}
case GST_QUERY_CONVERT:
static gboolean
speex_dec_src_query (GstPad * pad, GstQuery * query)
{
- gint64 samples_out = 0, total_samples;
GstSpeexDec *dec = GST_SPEEXDEC (GST_OBJECT_PARENT (pad));
- GstFormat my_format = GST_FORMAT_TIME;
- GstPad *peer;
- if (GST_QUERY_TYPE (query) != GST_QUERY_POSITION)
- return FALSE;
- if (!(peer = gst_pad_get_peer (dec->sinkpad)))
- return FALSE;
- gst_pad_query_position (peer, &my_format, NULL, &total_samples);
- gst_object_unref (peer);
- samples_out = dec->samples_out;
- speex_dec_convert (dec->srcpad, GST_FORMAT_DEFAULT, samples_out,
- &my_format, &samples_out);
- speex_dec_convert (dec->srcpad, GST_FORMAT_DEFAULT, total_samples,
- &my_format, &total_samples);
- gst_query_set_position (query, GST_FORMAT_TIME, samples_out, total_samples);
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_POSITION:
+ {
+ gint64 cur;
+ GstFormat format;
+
+ gst_query_parse_position (query, &format, NULL);
+
+ speex_dec_convert (dec->srcpad, GST_FORMAT_DEFAULT, dec->samples_out,
+ &format, &cur);
+
+ gst_query_set_position (query, format, cur);
+ break;
+ }
+ case GST_QUERY_DURATION:
+ {
+ GstPad *peer;
+ GstFormat my_format = GST_FORMAT_TIME;
+ gint64 total_samples;
+
+ if (!(peer = gst_pad_get_peer (dec->sinkpad)))
+ return FALSE;
+
+ gst_pad_query_duration (peer, &my_format, &total_samples);
+ gst_object_unref (peer);
+
+ speex_dec_convert (dec->srcpad, GST_FORMAT_DEFAULT, total_samples,
+ &my_format, &total_samples);
+
+ gst_query_set_duration (query, GST_FORMAT_TIME, total_samples);
+ break;
+ }
+ default:
+ return FALSE;
+ break;
+ }
return TRUE;
}
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_POSITION:{
- gint64 len, pos = 0;
+ gint64 pos = 0;
- len = (((gfloat) stream->strh->scale) * stream->strh->length /
- stream->strh->rate) * GST_SECOND;
if (stream->strh->type == GST_RIFF_FCC_auds) {
if (!stream->strh->samplesize) {
pos = GST_SECOND * stream->current_frame *
}
}
if (res)
- gst_query_set_position (query, GST_FORMAT_TIME, pos, len);
+ gst_query_set_position (query, GST_FORMAT_TIME, pos);
+ break;
+ }
+ case GST_QUERY_DURATION:
+ {
+ gint64 len;
+
+ len = (((gfloat) stream->strh->scale) * stream->strh->length /
+ stream->strh->rate) * GST_SECOND;
+ gst_query_set_duration (query, GST_FORMAT_TIME, len);
break;
}
default:
/* 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, NULL);
+ ret = gst_pad_query_position (peer_pad, &peer_format, &peer_value);
if (ret && peer_format == GST_FORMAT_TIME) {
GstEvent *event;
format = try_formats[i];
- if (gst_pad_query_position (peer_pad, &format, &cur_progress,
- &total_progress)) {
+ if (gst_pad_query_position (peer_pad, &format, &cur_progress) &&
+ gst_pad_query_duration (peer_pad, &format, &total_progress)) {
switch (format) {
case GST_FORMAT_BYTES:
format_name = "bytes";
gst_ebml_read_get_length (GstEbmlRead * ebml)
{
GstFormat fmt = GST_FORMAT_BYTES;
- gint64 pos, end;
+ gint64 end;
- if (!gst_pad_query_position (GST_PAD_PEER (ebml->sinkpad), &fmt, &pos, &end))
+ if (!gst_pad_query_duration (GST_PAD_PEER (ebml->sinkpad), &fmt, &end))
g_return_val_if_reached (0); ///// FIXME /////////
if (fmt != GST_FORMAT_BYTES || end < 0)
{
GstFormat format;
- gst_query_parse_position (query, &format, NULL, NULL);
+ gst_query_parse_position (query, &format, NULL);
if (format != GST_FORMAT_TIME) {
GST_DEBUG ("only query position on TIME is supported");
}
GST_LOCK (demux);
+ gst_query_set_position (query, GST_FORMAT_TIME, demux->pos);
+ GST_UNLOCK (demux);
+
+ res = TRUE;
+ break;
+ }
+ case GST_QUERY_DURATION:
+ {
+ GstFormat format;
+
+ gst_query_parse_position (query, &format, NULL);
- /* mabe we should only fill in the total time and let
- * decoders fill in the current position? (like oggdemux) */
- gst_query_set_position (query, GST_FORMAT_TIME, demux->pos,
- demux->duration);
+ if (format != GST_FORMAT_TIME) {
+ GST_DEBUG ("only query duration on TIME is supported");
+ break;
+ }
+ GST_LOCK (demux);
+ gst_query_set_duration (query, GST_FORMAT_TIME, demux->duration);
GST_UNLOCK (demux);
res = TRUE;
thepad = collect_pad->collect.pad;
/* Query the total length of the track. */
- query = gst_query_new_position (GST_FORMAT_TIME);
+ query = gst_query_new_duration (GST_FORMAT_TIME);
if (gst_pad_query (GST_PAD_PEER (thepad), query)) {
GstFormat format;
- gint64 cur, trackduration;
+ gint64 trackduration;
- gst_query_parse_position (query, &format, &cur, &trackduration);
+ gst_query_parse_duration (query, &format, &trackduration);
if ((gdouble) trackduration > duration) {
duration = (gdouble) trackduration;
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_POSITION:
{
- gint64 curb, endb;
- gint64 cur, end;
+ gint64 curb;
+ gint64 cur;
GstFormat format;
gboolean res = TRUE;
curb = wav->offset - wav->datastart;
- endb = wav->datasize;
- gst_query_parse_position (query, &format, NULL, NULL);
+ gst_query_parse_position (query, &format, NULL);
switch (format) {
case GST_FORMAT_TIME:
res &=
gst_wavparse_pad_convert (pad, GST_FORMAT_BYTES, curb,
&format, &cur);
+ break;
+ default:
+ format = GST_FORMAT_BYTES;
+ cur = curb;
+ break;
+ }
+ if (res)
+ gst_query_set_position (query, format, cur);
+ break;
+ }
+ case GST_QUERY_DURATION:
+ {
+ gint64 endb;
+ gint64 end;
+ GstFormat format;
+ gboolean res = TRUE;
+
+ endb = wav->datasize;
+ gst_query_parse_duration (query, &format, NULL);
+
+ switch (format) {
+ case GST_FORMAT_TIME:
res &=
gst_wavparse_pad_convert (pad, GST_FORMAT_BYTES, endb,
&format, &end);
break;
default:
format = GST_FORMAT_BYTES;
- cur = curb;
end = endb;
break;
}
if (res)
- gst_query_set_position (query, format, cur, end);
+ gst_query_set_duration (query, format, end);
break;
}
case GST_QUERY_CONVERT: