Commit 80fc5687 authored by Wim Taymans's avatar Wim Taymans
Browse files

buffer: add pts/dts to buffers

parent b8e1506b
......@@ -66,9 +66,9 @@
* is typically done before pushing out a buffer using gst_pad_push() so that
* the downstream element knows the type of the buffer.
*
* A buffer will usually have a timestamp, and a duration, but neither of these
* A buffer will usually have timestamps, and a duration, but neither of these
* are guaranteed (they may be set to #GST_CLOCK_TIME_NONE). Whenever a
* meaningful value can be given for these, they should be set. The timestamp
* meaningful value can be given for these, they should be set. The timestamps
* and duration are measured in nanoseconds (they are #GstClockTime values).
*
* A buffer can also have one or both of a start and an end offset. These are
......@@ -276,14 +276,16 @@ gst_buffer_copy_into (GstBuffer * dest, GstBuffer * src,
if (flags & GST_BUFFER_COPY_TIMESTAMPS) {
if (offset == 0) {
GST_BUFFER_TIMESTAMP (dest) = GST_BUFFER_TIMESTAMP (src);
GST_BUFFER_PTS (dest) = GST_BUFFER_PTS (src);
GST_BUFFER_DTS (dest) = GST_BUFFER_DTS (src);
GST_BUFFER_OFFSET (dest) = GST_BUFFER_OFFSET (src);
if (size == bufsize) {
GST_BUFFER_DURATION (dest) = GST_BUFFER_DURATION (src);
GST_BUFFER_OFFSET_END (dest) = GST_BUFFER_OFFSET_END (src);
}
} else {
GST_BUFFER_TIMESTAMP (dest) = GST_CLOCK_TIME_NONE;
GST_BUFFER_PTS (dest) = GST_CLOCK_TIME_NONE;
GST_BUFFER_DTS (dest) = GST_CLOCK_TIME_NONE;
GST_BUFFER_DURATION (dest) = GST_CLOCK_TIME_NONE;
GST_BUFFER_OFFSET (dest) = GST_BUFFER_OFFSET_NONE;
GST_BUFFER_OFFSET_END (dest) = GST_BUFFER_OFFSET_NONE;
......@@ -429,7 +431,8 @@ gst_buffer_init (GstBufferImpl * buffer, gsize size)
(GstMiniObjectFreeFunction) _gst_buffer_free;
GST_BUFFER (buffer)->pool = NULL;
GST_BUFFER_TIMESTAMP (buffer) = GST_CLOCK_TIME_NONE;
GST_BUFFER_PTS (buffer) = GST_CLOCK_TIME_NONE;
GST_BUFFER_DTS (buffer) = GST_CLOCK_TIME_NONE;
GST_BUFFER_DURATION (buffer) = GST_CLOCK_TIME_NONE;
GST_BUFFER_OFFSET (buffer) = GST_BUFFER_OFFSET_NONE;
GST_BUFFER_OFFSET_END (buffer) = GST_BUFFER_OFFSET_NONE;
......@@ -1438,7 +1441,8 @@ gst_buffer_span (GstBuffer * buf1, gsize offset, GstBuffer * buf2, gsize size)
/* if the offset is 0, the new buffer has the same timestamp as buf1 */
if (offset == 0) {
GST_BUFFER_OFFSET (newbuf) = GST_BUFFER_OFFSET (buf1);
GST_BUFFER_TIMESTAMP (newbuf) = GST_BUFFER_TIMESTAMP (buf1);
GST_BUFFER_PTS (newbuf) = GST_BUFFER_PTS (buf1);
GST_BUFFER_DTS (newbuf) = GST_BUFFER_DTS (buf1);
/* if we completely merged the two buffers (appended), we can
* calculate the duration too. Also make sure we's not messing with
......
......@@ -80,15 +80,27 @@ typedef struct _GstBufferPool GstBufferPool;
*/
#define GST_BUFFER_FLAG_UNSET(buf,flag) GST_MINI_OBJECT_FLAG_UNSET (buf, flag)
/**
* GST_BUFFER_TIMESTAMP:
* GST_BUFFER_PTS:
* @buf: a #GstBuffer.:
*
* The timestamp in nanoseconds (as a #GstClockTime) of the data in the buffer.
* Value will be %GST_CLOCK_TIME_NONE if the timestamp is unknown.
* The presentation timestamp (pts) in nanoseconds (as a #GstClockTime)
* of the data in the buffer. This is the timestamp when the media should be
* presented to the user.
* Value will be %GST_CLOCK_TIME_NONE if the pts is unknown.
*/
#define GST_BUFFER_PTS(buf) (GST_BUFFER_CAST(buf)->pts)
/**
* GST_BUFFER_DTS:
* @buf: a #GstBuffer.:
*
* The decoding timestamp (dts) in nanoseconds (as a #GstClockTime)
* of the data in the buffer. This is the timestamp when the media should be
* decoded or processed otherwise.
* Value will be %GST_CLOCK_TIME_NONE if the dts is unknown.
*/
#define GST_BUFFER_TIMESTAMP(buf) (GST_BUFFER_CAST(buf)->timestamp)
#define GST_BUFFER_DTS(buf) (GST_BUFFER_CAST(buf)->dts)
/**
* GST_BUFFER_DURATION:
* @buf: a #GstBuffer.
......@@ -127,12 +139,19 @@ typedef struct _GstBufferPool GstBufferPool;
*/
#define GST_BUFFER_DURATION_IS_VALID(buffer) (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DURATION (buffer)))
/**
* GST_BUFFER_TIMESTAMP_IS_VALID:
* GST_BUFFER_PTS_IS_VALID:
* @buffer: a #GstBuffer
*
* Tests if the pts is known.
*/
#define GST_BUFFER_PTS_IS_VALID(buffer) (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_PTS (buffer)))
/**
* GST_BUFFER_DTS_IS_VALID:
* @buffer: a #GstBuffer
*
* Tests if the timestamp is known.
* Tests if the dts is known.
*/
#define GST_BUFFER_TIMESTAMP_IS_VALID(buffer) (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_TIMESTAMP (buffer)))
#define GST_BUFFER_DTS_IS_VALID(buffer) (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DTS (buffer)))
/**
* GST_BUFFER_OFFSET_IS_VALID:
* @buffer: a #GstBuffer
......@@ -231,7 +250,8 @@ struct _GstBuffer {
GstBufferPool *pool;
/* timestamp */
GstClockTime timestamp;
GstClockTime pts;
GstClockTime dts;
GstClockTime duration;
/* media specific offset */
......@@ -365,8 +385,8 @@ gst_buffer_copy (const GstBuffer * buf)
* GstBufferCopyFlags:
* @GST_BUFFER_COPY_NONE: copy nothing
* @GST_BUFFER_COPY_FLAGS: flag indicating that buffer flags should be copied
* @GST_BUFFER_COPY_TIMESTAMPS: flag indicating that buffer timestamp, duration,
* offset and offset_end should be copied
* @GST_BUFFER_COPY_TIMESTAMPS: flag indicating that buffer pts, dts,
* duration, offset and offset_end should be copied
* @GST_BUFFER_COPY_MEMORY: flag indicating that buffer memory should be copied
* and appended to already existing memory
* @GST_BUFFER_COPY_MERGE: flag indicating that buffer memory should be
......
......@@ -854,7 +854,8 @@ default_reset_buffer (GstBufferPool * pool, GstBuffer * buffer,
{
GST_BUFFER_FLAGS (buffer) = 0;
GST_BUFFER_TIMESTAMP (buffer) = GST_CLOCK_TIME_NONE;
GST_BUFFER_PTS (buffer) = GST_CLOCK_TIME_NONE;
GST_BUFFER_DTS (buffer) = GST_CLOCK_TIME_NONE;
GST_BUFFER_DURATION (buffer) = GST_CLOCK_TIME_NONE;
GST_BUFFER_OFFSET (buffer) = GST_BUFFER_OFFSET_NONE;
GST_BUFFER_OFFSET_END (buffer) = GST_BUFFER_OFFSET_NONE;
......
......@@ -629,10 +629,11 @@ gst_debug_print_object (gpointer ptr)
gchar *ret;
ret =
g_strdup_printf ("%p, ts %" GST_TIME_FORMAT
g_strdup_printf ("%p, pts %" GST_TIME_FORMAT ", dts %" GST_TIME_FORMAT
", dur %" GST_TIME_FORMAT ", size %" G_GSIZE_FORMAT ", offset %"
G_GUINT64_FORMAT ", offset_end %" G_GUINT64_FORMAT, buf,
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
GST_TIME_ARGS (GST_BUFFER_PTS (buf)),
GST_TIME_ARGS (GST_BUFFER_DTS (buf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)), gst_buffer_get_size (buf),
GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf));
return ret;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment