Slightly better timestamp handling use pad_query for _tell

Original commit message from CVS:
Slightly better timestamp handling
use pad_query for _tell
This commit is contained in:
Wim Taymans 2002-05-31 23:39:09 +00:00
parent 9940947219
commit e89f26944a
2 changed files with 18 additions and 7 deletions

View file

@ -130,15 +130,16 @@ gst_bytestream_get_next_buf (GstByteStream * bs)
bs_print ("get_next_buf: pulling buffer");
nextbuf = gst_pad_pull (bs->pad);
if (GST_IS_EVENT (nextbuf))
{
bs->event = GST_EVENT (nextbuf);
return FALSE;
}
if (GST_IS_EVENT (nextbuf)) {
bs->event = GST_EVENT (nextbuf);
return FALSE;
}
if (!nextbuf)
return FALSE;
bs->last_ts = GST_BUFFER_TIMESTAMP (nextbuf);
bs_print ("get_next_buf: got buffer of %d bytes", GST_BUFFER_SIZE (nextbuf));
/* first see if there are any buffers in the list at all */
@ -256,7 +257,7 @@ gst_bytestream_peek (GstByteStream * bs, GstBuffer **buf, guint32 len)
retbuf = gst_buffer_new ();
GST_BUFFER_SIZE (retbuf) = len;
GST_BUFFER_DATA (retbuf) = gst_bytestream_assemble (bs, len);
GST_BUFFER_TIMESTAMP (retbuf) = gst_bytestream_get_timestamp (bs);
GST_BUFFER_TIMESTAMP (retbuf) = bs->last_ts;
if (GST_BUFFER_OFFSET (headbuf) != -1)
GST_BUFFER_OFFSET (retbuf) = GST_BUFFER_OFFSET (headbuf) + (GST_BUFFER_SIZE (headbuf) - bs->headbufavail);
}
@ -462,8 +463,17 @@ gst_bytestream_seek (GstByteStream *bs, gint64 offset, GstSeekType method)
guint64
gst_bytestream_tell (GstByteStream *bs)
{
GstFormat format;
gint64 value;
g_return_val_if_fail (bs != NULL, 0);
return bs->offset;
format = GST_FORMAT_BYTES;
if (gst_pad_query (GST_PAD_PEER (bs->pad), GST_PAD_QUERY_POSITION, &format, &value))
return value;
return -1;
}
guint32

View file

@ -43,6 +43,7 @@ struct _GstByteStream {
/* this is needed for gst_bytestream_tell */
guint64 offset;
guint64 last_ts;
/* if we are in the seek state (waiting for DISCONT) */
gboolean in_seek;