Commit 1f721317 authored by Nicolas Dufresne's avatar Nicolas Dufresne

rtph264pay: Fix reading timestamps from adapter

The code was reading the timestamp from the adapter before pushing the
new buffer into it. As a side effect, if the adapter was empty, we'd end
up using an older timestamp. In alignment=au, it means that all
timestamp was likely one frame in the past, while in alignment=nal, with
multiple slices per frame, the first slice would have the timestamp of
the previous one.
parent 4add820c
...@@ -820,7 +820,9 @@ gst_rtp_h264_pay_payload_nal (GstRTPBasePayload * basepayload, ...@@ -820,7 +820,9 @@ gst_rtp_h264_pay_payload_nal (GstRTPBasePayload * basepayload,
break; break;
} }
GST_DEBUG_OBJECT (rtph264pay, "Processing Buffer with NAL TYPE=%d", nalType); GST_DEBUG_OBJECT (rtph264pay,
"Processing Buffer with NAL TYPE=%d %" GST_TIME_FORMAT,
nalType, GST_TIME_ARGS (pts));
/* should set src caps before pushing stuff, /* should set src caps before pushing stuff,
* and if we did not see enough SPS/PPS, that may not be the case */ * and if we did not see enough SPS/PPS, that may not be the case */
...@@ -1046,8 +1048,6 @@ gst_rtp_h264_pay_handle_buffer (GstRTPBasePayload * basepayload, ...@@ -1046,8 +1048,6 @@ gst_rtp_h264_pay_handle_buffer (GstRTPBasePayload * basepayload,
rtph264pay->discont = GST_BUFFER_IS_DISCONT (buffer); rtph264pay->discont = GST_BUFFER_IS_DISCONT (buffer);
GST_DEBUG_OBJECT (basepayload, "got %" G_GSIZE_FORMAT " bytes", size); GST_DEBUG_OBJECT (basepayload, "got %" G_GSIZE_FORMAT " bytes", size);
} else { } else {
dts = gst_adapter_prev_dts (rtph264pay->adapter, NULL);
pts = gst_adapter_prev_pts (rtph264pay->adapter, NULL);
if (buffer) { if (buffer) {
if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT)) { if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT)) {
if (gst_adapter_available (rtph264pay->adapter) == 0) if (gst_adapter_available (rtph264pay->adapter) == 0)
...@@ -1069,13 +1069,13 @@ gst_rtp_h264_pay_handle_buffer (GstRTPBasePayload * basepayload, ...@@ -1069,13 +1069,13 @@ gst_rtp_h264_pay_handle_buffer (GstRTPBasePayload * basepayload,
delayed_discont = TRUE; delayed_discont = TRUE;
} }
if (!GST_CLOCK_TIME_IS_VALID (dts))
dts = GST_BUFFER_DTS (buffer);
if (!GST_CLOCK_TIME_IS_VALID (pts))
pts = GST_BUFFER_PTS (buffer);
gst_adapter_push (rtph264pay->adapter, buffer); gst_adapter_push (rtph264pay->adapter, buffer);
} }
/* We want to use the first TS used to construct the following NAL */
dts = gst_adapter_prev_dts (rtph264pay->adapter, NULL);
pts = gst_adapter_prev_pts (rtph264pay->adapter, NULL);
size = gst_adapter_available (rtph264pay->adapter); size = gst_adapter_available (rtph264pay->adapter);
/* Nothing to do here if the adapter is empty, e.g. on EOS */ /* Nothing to do here if the adapter is empty, e.g. on EOS */
if (size == 0) if (size == 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment