queue/queue2: Use GST_BUFFER_DTS_OR_PTS

The input of queue/queue2 might have DTS set, in which cas we want
to take that into account (instead of the PTS) to calculate position
and queue levels.

https://bugzilla.gnome.org/show_bug.cgi?id=756507
This commit is contained in:
Edward Hervey 2015-10-27 08:48:07 +01:00
parent 692c0dc060
commit a9c923d585
2 changed files with 17 additions and 12 deletions

View file

@ -601,7 +601,7 @@ apply_buffer (GstQueue * queue, GstBuffer * buffer, GstSegment * segment,
{ {
GstClockTime duration, timestamp; GstClockTime duration, timestamp;
timestamp = GST_BUFFER_TIMESTAMP (buffer); timestamp = GST_BUFFER_DTS_OR_PTS (buffer);
duration = GST_BUFFER_DURATION (buffer); duration = GST_BUFFER_DURATION (buffer);
/* if no timestamp is set, assume it's continuous with the previous /* if no timestamp is set, assume it's continuous with the previous
@ -631,14 +631,16 @@ static gboolean
buffer_list_apply_time (GstBuffer ** buf, guint idx, gpointer user_data) buffer_list_apply_time (GstBuffer ** buf, guint idx, gpointer user_data)
{ {
GstClockTime *timestamp = user_data; GstClockTime *timestamp = user_data;
GstClockTime btime;
GST_TRACE ("buffer %u has ts %" GST_TIME_FORMAT GST_TRACE ("buffer %u has pts %" GST_TIME_FORMAT " dts %" GST_TIME_FORMAT
" duration %" GST_TIME_FORMAT, idx, " duration %" GST_TIME_FORMAT, idx, GST_TIME_ARGS (GST_BUFFER_DTS (*buf)),
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (*buf)), GST_TIME_ARGS (GST_BUFFER_PTS (*buf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (*buf))); GST_TIME_ARGS (GST_BUFFER_DURATION (*buf)));
if (GST_BUFFER_TIMESTAMP_IS_VALID (*buf)) btime = GST_BUFFER_DTS_OR_PTS (*buf);
*timestamp = GST_BUFFER_TIMESTAMP (*buf); if (GST_CLOCK_TIME_IS_VALID (btime))
*timestamp = btime;
if (GST_BUFFER_DURATION_IS_VALID (*buf)) if (GST_BUFFER_DURATION_IS_VALID (*buf))
*timestamp += GST_BUFFER_DURATION (*buf); *timestamp += GST_BUFFER_DURATION (*buf);
@ -1146,7 +1148,7 @@ gst_queue_chain_buffer_or_list (GstPad * pad, GstObject * parent,
GstClockTime duration, timestamp; GstClockTime duration, timestamp;
GstBuffer *buffer = GST_BUFFER_CAST (obj); GstBuffer *buffer = GST_BUFFER_CAST (obj);
timestamp = GST_BUFFER_TIMESTAMP (buffer); timestamp = GST_BUFFER_DTS_OR_PTS (buffer);
duration = GST_BUFFER_DURATION (buffer); duration = GST_BUFFER_DURATION (buffer);
GST_CAT_LOG_OBJECT (queue_dataflow, queue, "received buffer %p of size %" GST_CAT_LOG_OBJECT (queue_dataflow, queue, "received buffer %p of size %"

View file

@ -750,7 +750,7 @@ apply_buffer (GstQueue2 * queue, GstBuffer * buffer, GstSegment * segment,
{ {
GstClockTime duration, timestamp; GstClockTime duration, timestamp;
timestamp = GST_BUFFER_TIMESTAMP (buffer); timestamp = GST_BUFFER_DTS_OR_PTS (buffer);
duration = GST_BUFFER_DURATION (buffer); duration = GST_BUFFER_DURATION (buffer);
/* if no timestamp is set, assume it's continuous with the previous /* if no timestamp is set, assume it's continuous with the previous
@ -780,14 +780,17 @@ static gboolean
buffer_list_apply_time (GstBuffer ** buf, guint idx, gpointer data) buffer_list_apply_time (GstBuffer ** buf, guint idx, gpointer data)
{ {
GstClockTime *timestamp = data; GstClockTime *timestamp = data;
GstClockTime btime;
GST_TRACE ("buffer %u has ts %" GST_TIME_FORMAT GST_TRACE ("buffer %u has pts %" GST_TIME_FORMAT " dts %" GST_TIME_FORMAT
" duration %" GST_TIME_FORMAT, idx, " duration %" GST_TIME_FORMAT, idx,
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_TIME_ARGS (GST_BUFFER_DURATION (*buf)));
if (GST_BUFFER_TIMESTAMP_IS_VALID (*buf)) btime = GST_BUFFER_DTS_OR_PTS (*buf);
*timestamp = GST_BUFFER_TIMESTAMP (*buf); if (GST_CLOCK_TIME_IS_VALID (btime))
*timestamp = btime;
if (GST_BUFFER_DURATION_IS_VALID (*buf)) if (GST_BUFFER_DURATION_IS_VALID (*buf))
*timestamp += GST_BUFFER_DURATION (*buf); *timestamp += GST_BUFFER_DURATION (*buf);