From 321f046aafda89cd20876a4d7541c71f42f5eb3b Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Fri, 10 May 2002 08:16:18 +0000 Subject: [PATCH] Added gst_bytestream_get_timestamp() call to get timestamp of data at the front of the stream. If no data in stream,... Original commit message from CVS: Added gst_bytestream_get_timestamp() call to get timestamp of data at the front of the stream. If no data in stream, loads 1 byte to get a new buffer and uses its timestamp. Does nothing to handle readers that try to read data lengths that span buffers with multiple timestamps. _get_timestamp() now used when creating new buffers. --- libs/gst/bytestream/bytestream.c | 34 ++++++++++++++++++++++++++++++++++ libs/gst/bytestream/bytestream.h | 1 + 2 files changed, 35 insertions(+) diff --git a/libs/gst/bytestream/bytestream.c b/libs/gst/bytestream/bytestream.c index 4660329..9803756 100644 --- a/libs/gst/bytestream/bytestream.c +++ b/libs/gst/bytestream/bytestream.c @@ -236,6 +236,7 @@ gst_bytestream_peek (GstByteStream * bs, 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); if (GST_BUFFER_OFFSET (headbuf) != -1) GST_BUFFER_OFFSET (retbuf) = GST_BUFFER_OFFSET (headbuf) + (GST_BUFFER_SIZE (headbuf) - bs->headbufavail); } @@ -465,6 +466,39 @@ gst_bytestream_get_status (GstByteStream *bs, } } +/** + * gst_bytestream_get_timestamp + * @bs: a bytestream + * + * Get the timestamp of the first data in the bytestream. If no data + * exists 1 byte is read to load a new buffer. + * + * This function will not check input buffer boundries. It is possible + * the next read could span two or more input buffers with different + * timestamps. + */ +guint64 +gst_bytestream_get_timestamp (GstByteStream *bs) +{ + GstBuffer *headbuf; + + g_return_val_if_fail (bs != NULL, 0); + + bs_print ("get_timestamp: asking for %d bytes\n", len); + + /* make sure we have a buffer */ + if (bs->listavail == 0) { + bs_print ("gst_timestamp: fetching a buffer\n"); + if (!gst_bytestream_fill_bytes (bs, 1)) + return 0; + } + + /* extract the head buffer */ + headbuf = GST_BUFFER (bs->buflist->data); + + return GST_BUFFER_TIMESTAMP (headbuf); +} + void gst_bytestream_print_status (GstByteStream * bs) { diff --git a/libs/gst/bytestream/bytestream.h b/libs/gst/bytestream/bytestream.h index ab4c9fe..b92405e 100644 --- a/libs/gst/bytestream/bytestream.h +++ b/libs/gst/bytestream/bytestream.h @@ -53,6 +53,7 @@ guint8* gst_bytestream_peek_bytes (GstByteStream *bs, guint32 len); gboolean gst_bytestream_flush (GstByteStream *bs, guint32 len); void gst_bytestream_flush_fast (GstByteStream *bs, guint32 len); void gst_bytestream_get_status (GstByteStream *bs, guint32 *avail_out, GstEvent **event_out); +guint64 gst_bytestream_get_timestamp (GstByteStream *bs); void gst_bytestream_print_status (GstByteStream *bs); -- 2.7.4