gst/: Use gst_pad_query_peer_duration() utility function here.

Original commit message from CVS:
* gst/apetag/gsttagdemux.c: (gst_tag_demux_get_upstream_size):
* gst/id3demux/gstid3demux.c: (id3demux_get_upstream_size):
Use gst_pad_query_peer_duration() utility function here.
This commit is contained in:
Tim-Philipp Müller 2006-06-11 18:20:39 +00:00
parent 5a027ffd66
commit 1a79337544
3 changed files with 17 additions and 33 deletions

View file

@ -1,3 +1,9 @@
2006-06-11 Tim-Philipp Müller <tim at centricular dot net>
* gst/apetag/gsttagdemux.c: (gst_tag_demux_get_upstream_size):
* gst/id3demux/gstid3demux.c: (id3demux_get_upstream_size):
Use gst_pad_query_peer_duration() utility function here.
2006-06-11 Thomas Vander Stichele <thomas at apestaart dot org> 2006-06-11 Thomas Vander Stichele <thomas at apestaart dot org>
* autogen.sh: * autogen.sh:

View file

@ -665,27 +665,21 @@ gst_tag_demux_sink_event (GstPad * pad, GstEvent * event)
static gboolean static gboolean
gst_tag_demux_get_upstream_size (GstTagDemux * tagdemux) gst_tag_demux_get_upstream_size (GstTagDemux * tagdemux)
{ {
GstPad *peer = NULL;
GstFormat format; GstFormat format;
gint64 result; gint64 len;
gboolean res = FALSE;
/* Short-cut if we already queried upstream */ /* Short-cut if we already queried upstream */
if (tagdemux->priv->upstream_size > 0) if (tagdemux->priv->upstream_size > 0)
return TRUE; return TRUE;
if ((peer = gst_pad_get_peer (tagdemux->priv->sinkpad)) == NULL)
return FALSE;
format = GST_FORMAT_BYTES; format = GST_FORMAT_BYTES;
if (gst_pad_query_duration (peer, &format, &result) && if (!gst_pad_query_peer_duration (tagdemux->priv->sinkpad, &format, &len) ||
format == GST_FORMAT_BYTES && result > 0) { len <= 0) {
tagdemux->priv->upstream_size = result; return FALSE;
res = TRUE;
} }
gst_object_unref (peer); tagdemux->priv->upstream_size = len;
return res; return TRUE;
} }
static gboolean static gboolean

View file

@ -600,37 +600,21 @@ gst_id3demux_get_property (GObject * object, guint prop_id,
static gboolean static gboolean
id3demux_get_upstream_size (GstID3Demux * id3demux) id3demux_get_upstream_size (GstID3Demux * id3demux)
{ {
GstQuery *query;
GstPad *peer = NULL;
GstFormat format; GstFormat format;
gint64 result; gint64 result;
gboolean res = FALSE;
/* Short-cut if we already queried upstream */ /* Short-cut if we already queried upstream */
if (id3demux->upstream_size > 0) if (id3demux->upstream_size > 0)
return TRUE; return TRUE;
if ((peer = gst_pad_get_peer (id3demux->sinkpad)) == NULL) format = GST_FORMAT_BYTES;
if (!gst_pad_query_peer_duration (id3demux->sinkpad, &format, &result) ||
result < 0) {
return FALSE; return FALSE;
}
query = gst_query_new_duration (GST_FORMAT_BYTES);
gst_query_set_duration (query, GST_FORMAT_BYTES, -1);
if (!gst_pad_query (peer, query))
goto out;
gst_query_parse_duration (query, &format, &result);
gst_query_unref (query);
if (format != GST_FORMAT_BYTES || result == -1)
goto out;
id3demux->upstream_size = result; id3demux->upstream_size = result;
res = TRUE; return TRUE;
out:
gst_object_unref (peer);
return res;
} }
static gboolean static gboolean