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.
This commit is contained in:
David I. Lehn 2002-05-10 08:16:18 +00:00
parent 01f172bedc
commit 321f046aaf
2 changed files with 35 additions and 0 deletions

View file

@ -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)
{

View file

@ -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);