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 444069f04442fee36d5ca48ae918b6e8456828b9..6ba32544973fc4024cfdd6fc160aaa8ba81f00c1 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 20154aa723070e76089e6c4dc46d82f307e13a73..4343b6ad1af3b1101b5eb638443ac759d62e5031 100644 (file)
@@ -93,6 +93,14 @@ typedef struct _GstBufferPool GstBufferPool;
  * Value will be %GST_CLOCK_TIME_NONE if the dts is unknown.
  */
 #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.