gst/: API change fix.

Original commit message from CVS:
* gst/qtdemux/qtdemux.c: (gst_qtdemux_get_src_query_types),
(gst_qtdemux_handle_src_query):
* gst/speed/gstspeed.c: (speed_get_query_types), (speed_src_query):
* gst/tta/gstttaparse.c: (gst_tta_parse_src_event),
(gst_tta_parse_get_query_types), (gst_tta_parse_query):
API change fix.
This commit is contained in:
Wim Taymans 2005-10-19 15:58:01 +00:00
parent 8d8b51648a
commit f7d63a74e0
4 changed files with 96 additions and 27 deletions

View file

@ -1,3 +1,12 @@
2005-10-19 Wim Taymans <wim@fluendo.com>
* gst/qtdemux/qtdemux.c: (gst_qtdemux_get_src_query_types),
(gst_qtdemux_handle_src_query):
* gst/speed/gstspeed.c: (speed_get_query_types), (speed_src_query):
* gst/tta/gstttaparse.c: (gst_tta_parse_src_event),
(gst_tta_parse_get_query_types), (gst_tta_parse_query):
API change fix.
2005-10-19 Tim-Philipp Müller <tim at centricular dot net> 2005-10-19 Tim-Philipp Müller <tim at centricular dot net>
* configure.ac: * configure.ac:

View file

@ -312,6 +312,7 @@ gst_qtdemux_get_src_query_types (GstPad * pad)
{ {
static const GstQueryType src_types[] = { static const GstQueryType src_types[] = {
GST_QUERY_POSITION, GST_QUERY_POSITION,
GST_QUERY_DURATION,
0 0
}; };
@ -326,9 +327,14 @@ gst_qtdemux_handle_src_query (GstPad * pad, GstQuery * query)
switch (GST_QUERY_TYPE (query)) { switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_POSITION: case GST_QUERY_POSITION:
if (qtdemux->duration != 0 && qtdemux->timescale != 0 && if (GST_CLOCK_TIME_IS_VALID (qtdemux->last_ts)) {
GST_CLOCK_TIME_IS_VALID (qtdemux->last_ts)) { gst_query_set_position (query, GST_FORMAT_TIME, qtdemux->last_ts);
gst_query_set_position (query, GST_FORMAT_TIME, qtdemux->last_ts, res = TRUE;
}
break;
case GST_QUERY_DURATION:
if (qtdemux->duration != 0 && qtdemux->timescale != 0) {
gst_query_set_duration (query, GST_FORMAT_TIME,
(guint64) qtdemux->duration * GST_SECOND / qtdemux->timescale); (guint64) qtdemux->duration * GST_SECOND / qtdemux->timescale);
res = TRUE; res = TRUE;
} }

View file

@ -182,6 +182,7 @@ speed_get_query_types (GstPad * pad)
{ {
static const GstQueryType src_query_types[] = { static const GstQueryType src_query_types[] = {
GST_QUERY_POSITION, GST_QUERY_POSITION,
GST_QUERY_DURATION,
0 0
}; };
@ -334,38 +335,81 @@ speed_src_query (GstPad * pad, GstQuery * query)
{ {
GstFormat format; GstFormat format;
GstFormat rformat = GST_FORMAT_TIME; GstFormat rformat = GST_FORMAT_TIME;
gint64 cur, end; gint64 cur;
GstPad *peer; GstPad *peer;
GstFormat conv_format = GST_FORMAT_TIME; GstFormat conv_format = GST_FORMAT_TIME;
/* save requested format */ /* save requested format */
gst_query_parse_position (query, &format, NULL, NULL); gst_query_parse_position (query, &format, NULL);
/* query peer for total length in bytes */
gst_query_set_position (query, GST_FORMAT_TIME, -1, -1);
/* query peer for current position in time */
gst_query_set_position (query, GST_FORMAT_TIME, -1);
if ((peer = gst_pad_get_peer (filter->sinkpad)) == NULL) if ((peer = gst_pad_get_peer (filter->sinkpad)) == NULL)
goto error; goto error;
if (!gst_pad_query_position (peer, &rformat, &cur, &end)) { if (!gst_pad_query_position (peer, &rformat, &cur)) {
GST_LOG_OBJECT (filter, "query on peer pad failed"); GST_LOG_OBJECT (filter, "query on peer pad failed");
gst_object_unref (peer); gst_object_unref (peer);
goto error; goto error;
} }
gst_object_unref (peer); gst_object_unref (peer);
if (rformat == GST_FORMAT_BYTES)
GST_LOG_OBJECT (filter, "peer pad returned current=%lld bytes", cur);
else if (rformat == GST_FORMAT_TIME)
GST_LOG_OBJECT (filter, "peer pad returned time=%lld", cur);
/* convert to time format */
if (!gst_speed_convert (pad, rformat, cur, &conv_format, &cur)) {
ret = FALSE;
break;
}
/* adjust for speed factor */
cur /= filter->speed;
/* convert to time format */
if (!gst_speed_convert (pad, conv_format, cur, &format, &cur)) {
ret = FALSE;
break;
}
gst_query_set_position (query, format, cur);
GST_LOG_OBJECT (filter,
"position query: we return %llu (format %u)", cur, format);
break;
}
case GST_QUERY_DURATION:
{
GstFormat format;
GstFormat rformat = GST_FORMAT_TIME;
gint64 end;
GstPad *peer;
GstFormat conv_format = GST_FORMAT_TIME;
/* save requested format */
gst_query_parse_duration (query, &format, NULL);
/* query peer for total length in time */
gst_query_set_duration (query, GST_FORMAT_TIME, -1);
if ((peer = gst_pad_get_peer (filter->sinkpad)) == NULL)
goto error;
if (!gst_pad_query_duration (peer, &rformat, &end)) {
GST_LOG_OBJECT (filter, "query on peer pad failed");
gst_object_unref (peer);
goto error;
}
gst_object_unref (peer);
if (rformat == GST_FORMAT_BYTES) if (rformat == GST_FORMAT_BYTES)
GST_LOG_OBJECT (filter, "peer pad returned total=%lld bytes", end); GST_LOG_OBJECT (filter, "peer pad returned total=%lld bytes", end);
else if (rformat == GST_FORMAT_TIME) else if (rformat == GST_FORMAT_TIME)
GST_LOG_OBJECT (filter, "peer pad returned time=%lld", end); GST_LOG_OBJECT (filter, "peer pad returned time=%lld", end);
/* convert to time format */
if (!gst_speed_convert (pad, rformat, cur, &conv_format, &cur)) {
ret = FALSE;
break;
}
/* convert to time format */ /* convert to time format */
if (!gst_speed_convert (pad, rformat, end, &conv_format, &end)) { if (!gst_speed_convert (pad, rformat, end, &conv_format, &end)) {
ret = FALSE; ret = FALSE;
@ -373,25 +417,18 @@ speed_src_query (GstPad * pad, GstQuery * query)
} }
/* adjust for speed factor */ /* adjust for speed factor */
cur /= filter->speed;
end /= filter->speed; end /= filter->speed;
/* convert to time format */
if (!gst_speed_convert (pad, conv_format, cur, &format, &cur)) {
ret = FALSE;
break;
}
/* convert to time format */ /* convert to time format */
if (!gst_speed_convert (pad, conv_format, end, &format, &end)) { if (!gst_speed_convert (pad, conv_format, end, &format, &end)) {
ret = FALSE; ret = FALSE;
break; break;
} }
gst_query_set_position (query, format, cur, end); gst_query_set_duration (query, format, end);
GST_LOG_OBJECT (filter, GST_LOG_OBJECT (filter,
"position query: peer returned total: %llu - we return %llu (format %u)", "duration query: we return %llu (format %u)", end, format);
end, cur, format);
break; break;
} }

View file

@ -238,6 +238,7 @@ gst_tta_parse_get_query_types (GstPad * pad)
{ {
static const GstQueryType types[] = { static const GstQueryType types[] = {
GST_QUERY_POSITION, GST_QUERY_POSITION,
GST_QUERY_DURATION,
0 0
}; };
@ -253,23 +254,39 @@ gst_tta_parse_query (GstPad * pad, GstQuery * query)
case GST_QUERY_POSITION: case GST_QUERY_POSITION:
{ {
GstFormat format; GstFormat format;
gint64 cur, end; gint64 cur;
gst_query_parse_position (query, &format, NULL, NULL); gst_query_parse_position (query, &format, NULL);
switch (format) { switch (format) {
case GST_FORMAT_TIME: case GST_FORMAT_TIME:
cur = ttaparse->index[ttaparse->current_frame].time; cur = ttaparse->index[ttaparse->current_frame].time;
break;
default:
format = GST_FORMAT_BYTES;
cur = ttaparse->index[ttaparse->current_frame].pos;
break;
}
gst_query_set_position (query, format, cur);
break;
}
case GST_QUERY_DURATION:
{
GstFormat format;
gint64 end;
gst_query_parse_duration (query, &format, NULL);
switch (format) {
case GST_FORMAT_TIME:
end = ((gdouble) ttaparse->data_length / end = ((gdouble) ttaparse->data_length /
(gdouble) ttaparse->samplerate) * GST_SECOND; (gdouble) ttaparse->samplerate) * GST_SECOND;
break; break;
default: default:
format = GST_FORMAT_BYTES; format = GST_FORMAT_BYTES;
cur = ttaparse->index[ttaparse->current_frame].pos;
end = ttaparse->index[ttaparse->num_frames].pos + end = ttaparse->index[ttaparse->num_frames].pos +
ttaparse->index[ttaparse->num_frames].size; ttaparse->index[ttaparse->num_frames].size;
break; break;
} }
gst_query_set_position (query, format, cur, end); gst_query_set_duration (query, format, end);
break; break;
} }
default: default: