buffer: Add a GST_BUFFER_DTS_OR_PTS macro
authorEdward Hervey <edward@centricular.com>
Mon, 26 Oct 2015 06:59:54 +0000 (07:59 +0100)
committerEdward Hervey <bilboed@bilboed.com>
Tue, 27 Oct 2015 07:33:23 +0000 (08:33 +0100)
API: GST_BUFFER_DTS_OR_PTS

Many scenarios/elements require dealing with streams of buffers that
might have DTS set (i.e. encoded data, potentially reordered)

To simplify getting the increasing "timestamp" of those buffers, create
a macro that will return the DTS if valid, and if not the PTS

docs/gst/gstreamer-sections.txt
gst/gstbuffer.h

index 444069f..6ba3254 100644 (file)
@@ -175,6 +175,7 @@ GST_BUFFER_FLAG_UNSET
 
 GST_BUFFER_PTS
 GST_BUFFER_DTS
+GST_BUFFER_DTS_OR_PTS
 GST_BUFFER_DURATION
 GST_BUFFER_OFFSET
 GST_BUFFER_OFFSET_END
index 20154aa..4343b6a 100644 (file)
@@ -94,6 +94,14 @@ typedef struct _GstBufferPool GstBufferPool;
  */
 #define GST_BUFFER_DTS(buf)                     (GST_BUFFER_CAST(buf)->dts)
 /**
+ * GST_BUFFER_DTS_OR_PTS:
+ * @buf: a #GstBuffer.:
+ *
+ * Returns the buffer decoding timestamp (dts) if valid, else the buffer
+ * presentation time (pts)
+ */
+#define GST_BUFFER_DTS_OR_PTS(buf)              (GST_BUFFER_DTS_IS_VALID(buf) ? GST_BUFFER_DTS(buf) : GST_BUFFER_PTS (buf))
+/**
  * GST_BUFFER_DURATION:
  * @buf: a #GstBuffer.
  *