From a9c923d585affc85262e41b4790d378294706d7a Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Tue, 27 Oct 2015 08:48:07 +0100 Subject: [PATCH] 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 --- plugins/elements/gstqueue.c | 16 +++++++++------- plugins/elements/gstqueue2.c | 13 ++++++++----- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/plugins/elements/gstqueue.c b/plugins/elements/gstqueue.c index 1d55522..44714e8 100644 --- a/plugins/elements/gstqueue.c +++ b/plugins/elements/gstqueue.c @@ -601,7 +601,7 @@ apply_buffer (GstQueue * queue, GstBuffer * buffer, GstSegment * segment, { GstClockTime duration, timestamp; - timestamp = GST_BUFFER_TIMESTAMP (buffer); + timestamp = GST_BUFFER_DTS_OR_PTS (buffer); duration = GST_BUFFER_DURATION (buffer); /* 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) { GstClockTime *timestamp = user_data; + GstClockTime btime; - GST_TRACE ("buffer %u has ts %" GST_TIME_FORMAT - " duration %" GST_TIME_FORMAT, idx, - GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (*buf)), + GST_TRACE ("buffer %u has pts %" GST_TIME_FORMAT " dts %" GST_TIME_FORMAT + " duration %" GST_TIME_FORMAT, idx, GST_TIME_ARGS (GST_BUFFER_DTS (*buf)), + GST_TIME_ARGS (GST_BUFFER_PTS (*buf)), GST_TIME_ARGS (GST_BUFFER_DURATION (*buf))); - if (GST_BUFFER_TIMESTAMP_IS_VALID (*buf)) - *timestamp = GST_BUFFER_TIMESTAMP (*buf); + btime = GST_BUFFER_DTS_OR_PTS (*buf); + if (GST_CLOCK_TIME_IS_VALID (btime)) + *timestamp = btime; if (GST_BUFFER_DURATION_IS_VALID (*buf)) *timestamp += GST_BUFFER_DURATION (*buf); @@ -1146,7 +1148,7 @@ gst_queue_chain_buffer_or_list (GstPad * pad, GstObject * parent, GstClockTime duration, timestamp; GstBuffer *buffer = GST_BUFFER_CAST (obj); - timestamp = GST_BUFFER_TIMESTAMP (buffer); + timestamp = GST_BUFFER_DTS_OR_PTS (buffer); duration = GST_BUFFER_DURATION (buffer); GST_CAT_LOG_OBJECT (queue_dataflow, queue, "received buffer %p of size %" diff --git a/plugins/elements/gstqueue2.c b/plugins/elements/gstqueue2.c index 656066e..f6b1c70 100644 --- a/plugins/elements/gstqueue2.c +++ b/plugins/elements/gstqueue2.c @@ -750,7 +750,7 @@ apply_buffer (GstQueue2 * queue, GstBuffer * buffer, GstSegment * segment, { GstClockTime duration, timestamp; - timestamp = GST_BUFFER_TIMESTAMP (buffer); + timestamp = GST_BUFFER_DTS_OR_PTS (buffer); duration = GST_BUFFER_DURATION (buffer); /* 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) { 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, - 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))); - if (GST_BUFFER_TIMESTAMP_IS_VALID (*buf)) - *timestamp = GST_BUFFER_TIMESTAMP (*buf); + btime = GST_BUFFER_DTS_OR_PTS (*buf); + if (GST_CLOCK_TIME_IS_VALID (btime)) + *timestamp = btime; if (GST_BUFFER_DURATION_IS_VALID (*buf)) *timestamp += GST_BUFFER_DURATION (*buf); -- 2.7.4