base: update for query API changes

This commit is contained in:
Tim-Philipp Müller 2011-07-27 00:26:43 +01:00
parent ef8ca3549e
commit 913e5e310c
3 changed files with 47 additions and 58 deletions

View file

@ -1258,14 +1258,13 @@ gst_base_parse_update_duration (GstBaseParse * baseparse)
peer = gst_pad_get_peer (parse->sinkpad); peer = gst_pad_get_peer (parse->sinkpad);
if (peer) { if (peer) {
GstFormat pformat = GST_FORMAT_BYTES;
gboolean qres = FALSE; gboolean qres = FALSE;
gint64 ptot, dest_value; gint64 ptot, dest_value;
qres = gst_pad_query_duration (peer, &pformat, &ptot); qres = gst_pad_query_duration (peer, GST_FORMAT_BYTES, &ptot);
gst_object_unref (GST_OBJECT (peer)); gst_object_unref (GST_OBJECT (peer));
if (qres) { if (qres) {
if (gst_base_parse_convert (parse, pformat, ptot, if (gst_base_parse_convert (parse, GST_FORMAT_BYTES, ptot,
GST_FORMAT_TIME, &dest_value)) { GST_FORMAT_TIME, &dest_value)) {
parse->priv->estimated_duration = dest_value; parse->priv->estimated_duration = dest_value;
GST_LOG_OBJECT (parse, GST_LOG_OBJECT (parse,
@ -1518,10 +1517,8 @@ gst_base_parse_check_seekability (GstBaseParse * parse)
/* try harder to query upstream size if we didn't get it the first time */ /* try harder to query upstream size if we didn't get it the first time */
if (seekable && stop == -1) { if (seekable && stop == -1) {
GstFormat fmt = GST_FORMAT_BYTES;
GST_DEBUG_OBJECT (parse, "doing duration query to fix up unset stop"); GST_DEBUG_OBJECT (parse, "doing duration query to fix up unset stop");
gst_pad_query_peer_duration (parse->sinkpad, &fmt, &stop); gst_pad_query_peer_duration (parse->sinkpad, GST_FORMAT_BYTES, &stop);
} }
/* if upstream doesn't know the size, it's likely that it's not seekable in /* if upstream doesn't know the size, it's likely that it's not seekable in
@ -1557,10 +1554,9 @@ done:
static void static void
gst_base_parse_check_upstream (GstBaseParse * parse) gst_base_parse_check_upstream (GstBaseParse * parse)
{ {
GstFormat fmt = GST_FORMAT_TIME;
gint64 stop; gint64 stop;
if (gst_pad_query_peer_duration (parse->sinkpad, &fmt, &stop)) if (gst_pad_query_peer_duration (parse->sinkpad, GST_FORMAT_TIME, &stop))
if (GST_CLOCK_TIME_IS_VALID (stop) && stop) { if (GST_CLOCK_TIME_IS_VALID (stop) && stop) {
/* upstream has one, accept it also, and no further updates */ /* upstream has one, accept it also, and no further updates */
gst_base_parse_set_duration (parse, GST_FORMAT_TIME, stop, 0); gst_base_parse_set_duration (parse, GST_FORMAT_TIME, stop, 0);
@ -2490,10 +2486,8 @@ gst_base_parse_handle_previous_fragment (GstBaseParse * parse)
if (parse->priv->exact_position) { if (parse->priv->exact_position) {
offset = gst_base_parse_find_offset (parse, ts, TRUE, NULL); offset = gst_base_parse_find_offset (parse, ts, TRUE, NULL);
} else { } else {
GstFormat dstformat = GST_FORMAT_BYTES;
if (!gst_pad_query_convert (parse->srcpad, GST_FORMAT_TIME, ts, if (!gst_pad_query_convert (parse->srcpad, GST_FORMAT_TIME, ts,
&dstformat, &offset)) { GST_FORMAT_BYTES, &offset)) {
GST_DEBUG_OBJECT (parse, "conversion failed, only BYTE based"); GST_DEBUG_OBJECT (parse, "conversion failed, only BYTE based");
} }
} }
@ -3559,7 +3553,6 @@ gst_base_parse_handle_seek (GstBaseParse * parse, GstEvent * event)
gboolean flush, update, res = TRUE, accurate; gboolean flush, update, res = TRUE, accurate;
gint64 cur, stop, seekpos, seekstop; gint64 cur, stop, seekpos, seekstop;
GstSegment seeksegment = { 0, }; GstSegment seeksegment = { 0, };
GstFormat dstformat;
GstClockTime start_ts; GstClockTime start_ts;
gst_event_parse_seek (event, &rate, &format, &flags, gst_event_parse_seek (event, &rate, &format, &flags,
@ -3626,12 +3619,11 @@ gst_base_parse_handle_seek (GstBaseParse * parse, GstEvent * event)
NULL); NULL);
} else { } else {
start_ts = seeksegment.position; start_ts = seeksegment.position;
dstformat = GST_FORMAT_BYTES;
if (!gst_pad_query_convert (parse->srcpad, format, seeksegment.position, if (!gst_pad_query_convert (parse->srcpad, format, seeksegment.position,
&dstformat, &seekpos)) GST_FORMAT_BYTES, &seekpos))
goto convert_failed; goto convert_failed;
if (!gst_pad_query_convert (parse->srcpad, format, seeksegment.stop, if (!gst_pad_query_convert (parse->srcpad, format, seeksegment.stop,
&dstformat, &seekstop)) GST_FORMAT_BYTES, &seekstop))
goto convert_failed; goto convert_failed;
} }

View file

@ -2073,8 +2073,8 @@ gst_base_sink_wait_clock (GstBaseSink * sink, GstClockTime time,
/* FIXME: Casting to GstClockEntry only works because the types /* FIXME: Casting to GstClockEntry only works because the types
* are the same */ * are the same */
if (G_LIKELY (sink->priv->cached_clock_id != NULL if (G_LIKELY (sink->priv->cached_clock_id != NULL
&& GST_CLOCK_ENTRY_CLOCK ((GstClockEntry *) sink-> && GST_CLOCK_ENTRY_CLOCK ((GstClockEntry *) sink->priv->
priv->cached_clock_id) == clock)) { cached_clock_id) == clock)) {
if (!gst_clock_single_shot_id_reinit (clock, sink->priv->cached_clock_id, if (!gst_clock_single_shot_id_reinit (clock, sink->priv->cached_clock_id,
time)) { time)) {
gst_clock_id_unref (sink->priv->cached_clock_id); gst_clock_id_unref (sink->priv->cached_clock_id);
@ -3727,16 +3727,15 @@ gst_base_sink_default_prepare_seek_segment (GstBaseSink * sink,
GstSeekType cur_type, stop_type; GstSeekType cur_type, stop_type;
gint64 cur, stop; gint64 cur, stop;
GstSeekFlags flags; GstSeekFlags flags;
GstFormat seek_format, dest_format; GstFormat seek_format;
gdouble rate; gdouble rate;
gboolean update; gboolean update;
gboolean res = TRUE; gboolean res = TRUE;
gst_event_parse_seek (event, &rate, &seek_format, &flags, gst_event_parse_seek (event, &rate, &seek_format, &flags,
&cur_type, &cur, &stop_type, &stop); &cur_type, &cur, &stop_type, &stop);
dest_format = segment->format;
if (seek_format == dest_format) { if (seek_format == segment->format) {
gst_segment_do_seek (segment, rate, seek_format, flags, gst_segment_do_seek (segment, rate, seek_format, flags,
cur_type, cur, stop_type, stop, &update); cur_type, cur, stop_type, stop, &update);
return TRUE; return TRUE;
@ -3745,7 +3744,7 @@ gst_base_sink_default_prepare_seek_segment (GstBaseSink * sink,
if (cur_type != GST_SEEK_TYPE_NONE) { if (cur_type != GST_SEEK_TYPE_NONE) {
/* FIXME: Handle seek_cur & seek_end by converting the input segment vals */ /* FIXME: Handle seek_cur & seek_end by converting the input segment vals */
res = res =
gst_pad_query_convert (sink->sinkpad, seek_format, cur, &dest_format, gst_pad_query_convert (sink->sinkpad, seek_format, cur, segment->format,
&cur); &cur);
cur_type = GST_SEEK_TYPE_SET; cur_type = GST_SEEK_TYPE_SET;
} }
@ -3753,13 +3752,13 @@ gst_base_sink_default_prepare_seek_segment (GstBaseSink * sink,
if (res && stop_type != GST_SEEK_TYPE_NONE) { if (res && stop_type != GST_SEEK_TYPE_NONE) {
/* FIXME: Handle seek_cur & seek_end by converting the input segment vals */ /* FIXME: Handle seek_cur & seek_end by converting the input segment vals */
res = res =
gst_pad_query_convert (sink->sinkpad, seek_format, stop, &dest_format, gst_pad_query_convert (sink->sinkpad, seek_format, stop,
&stop); segment->format, &stop);
stop_type = GST_SEEK_TYPE_SET; stop_type = GST_SEEK_TYPE_SET;
} }
/* And finally, configure our output segment in the desired format */ /* And finally, configure our output segment in the desired format */
gst_segment_do_seek (segment, rate, dest_format, flags, cur_type, cur, gst_segment_do_seek (segment, rate, segment->format, flags, cur_type, cur,
stop_type, stop, &update); stop_type, stop, &update);
if (!res) if (!res)
@ -4324,22 +4323,19 @@ gst_base_sink_pad_activate_pull (GstPad * pad, gboolean active)
bclass = GST_BASE_SINK_GET_CLASS (basesink); bclass = GST_BASE_SINK_GET_CLASS (basesink);
if (active) { if (active) {
GstFormat format;
gint64 duration; gint64 duration;
/* we mark we have a newsegment here because pull based /* we mark we have a newsegment here because pull based
* mode works just fine without having a newsegment before the * mode works just fine without having a newsegment before the
* first buffer */ * first buffer */
format = GST_FORMAT_BYTES; gst_segment_init (&basesink->segment, GST_FORMAT_BYTES);
gst_segment_init (&basesink->clip_segment, GST_FORMAT_BYTES);
gst_segment_init (&basesink->segment, format);
gst_segment_init (&basesink->clip_segment, format);
GST_OBJECT_LOCK (basesink); GST_OBJECT_LOCK (basesink);
basesink->have_newsegment = TRUE; basesink->have_newsegment = TRUE;
GST_OBJECT_UNLOCK (basesink); GST_OBJECT_UNLOCK (basesink);
/* get the peer duration in bytes */ /* get the peer duration in bytes */
result = gst_pad_query_peer_duration (pad, &format, &duration); result = gst_pad_query_peer_duration (pad, GST_FORMAT_BYTES, &duration);
if (result) { if (result) {
GST_DEBUG_OBJECT (basesink, GST_DEBUG_OBJECT (basesink,
"setting duration in bytes to %" G_GINT64_FORMAT, duration); "setting duration in bytes to %" G_GINT64_FORMAT, duration);
@ -4460,7 +4456,7 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format,
{ {
GstClock *clock = NULL; GstClock *clock = NULL;
gboolean res = FALSE; gboolean res = FALSE;
GstFormat oformat, tformat; GstFormat oformat;
GstSegment *segment; GstSegment *segment;
GstClockTime now, latency; GstClockTime now, latency;
GstClockTimeDiff base_time; GstClockTimeDiff base_time;
@ -4491,8 +4487,6 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format,
else else
segment = &basesink->segment; segment = &basesink->segment;
/* our intermediate time format */
tformat = GST_FORMAT_TIME;
/* get the format in the segment */ /* get the format in the segment */
oformat = segment->format; oformat = segment->format;
@ -4597,23 +4591,23 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format,
GST_TIME_ARGS (last)); GST_TIME_ARGS (last));
*cur = last; *cur = last;
} else { } else {
if (oformat != tformat) { if (oformat != GST_FORMAT_TIME) {
/* convert base, time and duration to time */ /* convert base, time and duration to time */
if (!gst_pad_query_convert (basesink->sinkpad, oformat, base, &tformat, if (!gst_pad_query_convert (basesink->sinkpad, oformat, base,
&base)) GST_FORMAT_TIME, &base))
goto convert_failed; goto convert_failed;
if (!gst_pad_query_convert (basesink->sinkpad, oformat, duration, if (!gst_pad_query_convert (basesink->sinkpad, oformat, duration,
&tformat, &duration)) GST_FORMAT_TIME, &duration))
goto convert_failed; goto convert_failed;
if (!gst_pad_query_convert (basesink->sinkpad, oformat, time, &tformat, if (!gst_pad_query_convert (basesink->sinkpad, oformat, time,
&time)) GST_FORMAT_TIME, &time))
goto convert_failed; goto convert_failed;
if (!gst_pad_query_convert (basesink->sinkpad, oformat, last, &tformat, if (!gst_pad_query_convert (basesink->sinkpad, oformat, last,
&last)) GST_FORMAT_TIME, &last))
goto convert_failed; goto convert_failed;
/* assume time format from now on */ /* assume time format from now on */
oformat = tformat; oformat = GST_FORMAT_TIME;
} }
if (!in_paused && with_clock) { if (!in_paused && with_clock) {
@ -4658,7 +4652,7 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format,
if (oformat != format) { if (oformat != format) {
/* convert to final format */ /* convert to final format */
if (!gst_pad_query_convert (basesink->sinkpad, oformat, *cur, &format, cur)) if (!gst_pad_query_convert (basesink->sinkpad, oformat, *cur, format, cur))
goto convert_failed; goto convert_failed;
} }
@ -4699,20 +4693,22 @@ gst_base_sink_get_duration (GstBaseSink * basesink, GstFormat format,
gboolean res = FALSE; gboolean res = FALSE;
if (basesink->pad_mode == GST_ACTIVATE_PULL) { if (basesink->pad_mode == GST_ACTIVATE_PULL) {
GstFormat uformat = GST_FORMAT_BYTES;
gint64 uduration; gint64 uduration;
/* get the duration in bytes, in pull mode that's all we are sure to /* get the duration in bytes, in pull mode that's all we are sure to
* know. We have to explicitly get this value from upstream instead of * know. We have to explicitly get this value from upstream instead of
* using our cached value because it might change. Duration caching * using our cached value because it might change. Duration caching
* should be done at a higher level. */ * should be done at a higher level. */
res = gst_pad_query_peer_duration (basesink->sinkpad, &uformat, &uduration); res =
gst_pad_query_peer_duration (basesink->sinkpad, GST_FORMAT_BYTES,
&uduration);
if (res) { if (res) {
basesink->segment.duration = uduration; basesink->segment.duration = uduration;
if (format != uformat) { if (format != GST_FORMAT_BYTES) {
/* convert to the requested format */ /* convert to the requested format */
res = gst_pad_query_convert (basesink->sinkpad, uformat, uduration, res =
&format, dur); gst_pad_query_convert (basesink->sinkpad, GST_FORMAT_BYTES,
uduration, format, dur);
} else { } else {
*dur = uduration; *dur = uduration;
} }
@ -4770,20 +4766,21 @@ default_element_query (GstElement * element, GstQuery * query)
/* we can handle a few things if upstream failed */ /* we can handle a few things if upstream failed */
if (format == GST_FORMAT_PERCENT) { if (format == GST_FORMAT_PERCENT) {
gint64 dur = 0; gint64 dur = 0;
GstFormat uformat = GST_FORMAT_TIME;
res = gst_base_sink_get_position (basesink, GST_FORMAT_TIME, &cur, res = gst_base_sink_get_position (basesink, GST_FORMAT_TIME, &cur,
&upstream); &upstream);
if (!res && upstream) { if (!res && upstream) {
res = gst_pad_query_peer_position (basesink->sinkpad, &uformat, res =
gst_pad_query_peer_position (basesink->sinkpad, GST_FORMAT_TIME,
&cur); &cur);
} }
if (res) { if (res) {
res = gst_base_sink_get_duration (basesink, GST_FORMAT_TIME, &dur, res = gst_base_sink_get_duration (basesink, GST_FORMAT_TIME, &dur,
&upstream); &upstream);
if (!res && upstream) { if (!res && upstream) {
res = gst_pad_query_peer_duration (basesink->sinkpad, &uformat, res =
&dur); gst_pad_query_peer_duration (basesink->sinkpad,
GST_FORMAT_TIME, &dur);
} }
} }
if (res) { if (res) {

View file

@ -900,7 +900,7 @@ gst_base_src_default_query (GstBaseSrc * src, GstQuery * query)
/* convert to requested format */ /* convert to requested format */
res = res =
gst_pad_query_convert (src->srcpad, seg_format, gst_pad_query_convert (src->srcpad, seg_format,
position, &format, &position); position, format, &position);
} else } else
res = TRUE; res = TRUE;
@ -949,7 +949,7 @@ gst_base_src_default_query (GstBaseSrc * src, GstQuery * query)
* but we cannot answer the query, we must return FALSE. */ * but we cannot answer the query, we must return FALSE. */
res = res =
gst_pad_query_convert (src->srcpad, seg_format, gst_pad_query_convert (src->srcpad, seg_format,
duration, &format, &duration); duration, format, &duration);
} else { } else {
/* The subclass did not configure a duration, we assume that the /* The subclass did not configure a duration, we assume that the
* media has an unknown duration then and we return TRUE to report * media has an unknown duration then and we return TRUE to report
@ -1086,13 +1086,13 @@ gst_base_src_default_query (GstBaseSrc * src, GstQuery * query)
* but report TRUE. */ * but report TRUE. */
if (format != GST_FORMAT_PERCENT && stop != -1) { if (format != GST_FORMAT_PERCENT && stop != -1) {
res = gst_pad_query_convert (src->srcpad, seg_format, res = gst_pad_query_convert (src->srcpad, seg_format,
stop, &format, &stop); stop, format, &stop);
} else { } else {
res = TRUE; res = TRUE;
} }
if (res && format != GST_FORMAT_PERCENT && start != -1) if (res && format != GST_FORMAT_PERCENT && start != -1)
res = gst_pad_query_convert (src->srcpad, seg_format, res = gst_pad_query_convert (src->srcpad, seg_format,
start, &format, &start); start, format, &start);
gst_query_set_buffering_range (query, format, start, stop, estimated); gst_query_set_buffering_range (query, format, start, stop, estimated);
break; break;
@ -1210,7 +1210,7 @@ gst_base_src_default_prepare_seek_segment (GstBaseSrc * src, GstEvent * event,
if (cur_type != GST_SEEK_TYPE_NONE) { if (cur_type != GST_SEEK_TYPE_NONE) {
/* FIXME: Handle seek_cur & seek_end by converting the input segment vals */ /* FIXME: Handle seek_cur & seek_end by converting the input segment vals */
res = res =
gst_pad_query_convert (src->srcpad, seek_format, cur, &dest_format, gst_pad_query_convert (src->srcpad, seek_format, cur, dest_format,
&cur); &cur);
cur_type = GST_SEEK_TYPE_SET; cur_type = GST_SEEK_TYPE_SET;
} }
@ -1218,7 +1218,7 @@ gst_base_src_default_prepare_seek_segment (GstBaseSrc * src, GstEvent * event,
if (res && stop_type != GST_SEEK_TYPE_NONE) { if (res && stop_type != GST_SEEK_TYPE_NONE) {
/* FIXME: Handle seek_cur & seek_end by converting the input segment vals */ /* FIXME: Handle seek_cur & seek_end by converting the input segment vals */
res = res =
gst_pad_query_convert (src->srcpad, seek_format, stop, &dest_format, gst_pad_query_convert (src->srcpad, seek_format, stop, dest_format,
&stop); &stop);
stop_type = GST_SEEK_TYPE_SET; stop_type = GST_SEEK_TYPE_SET;
} }