buffer: Add a GST_BUFFER_DTS_OR_PTS macro

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
This commit is contained in:
Edward Hervey 2015-10-26 07:59:54 +01:00 committed by Edward Hervey
parent f0ee10d778
commit 41e1bea7ef
2 changed files with 9 additions and 0 deletions

View 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

View 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.