Commit 4a7d3974 authored by Nicolas Dufresne's avatar Nicolas Dufresne
Browse files

h264parse: Set PTS/DTS and DISCONT on crafted NAL

When we inject a NAL in the bitstream before another one, make
sure to pass both DTS and PTS. Also make sure to transfer the
DISCONT flag properly.
parent 818d853b
......@@ -2193,7 +2193,7 @@ gst_h264_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
* No ownership is taken of @nal */
static GstFlowReturn
gst_h264_parse_push_codec_buffer (GstH264Parse * h264parse,
GstBuffer * nal, GstClockTime ts)
GstBuffer * nal, GstBuffer * buffer)
{
GstMapInfo map;
......@@ -2202,7 +2202,13 @@ gst_h264_parse_push_codec_buffer (GstH264Parse * h264parse,
map.data, map.size);
gst_buffer_unmap (nal, &map);
GST_BUFFER_TIMESTAMP (nal) = ts;
if (h264parse->discont) {
GST_BUFFER_FLAG_SET (nal, GST_BUFFER_FLAG_DISCONT);
h264parse->discont = FALSE;
}
GST_BUFFER_PTS (nal) = GST_BUFFER_PTS (buffer);
GST_BUFFER_DTS (nal) = GST_BUFFER_DTS (buffer);
GST_BUFFER_DURATION (nal) = 0;
return gst_pad_push (GST_BASE_PARSE_SRC_PAD (h264parse), nal);
......@@ -2310,7 +2316,6 @@ gst_h264_parse_handle_sps_pps_nals (GstH264Parse * h264parse,
GstBuffer *codec_nal;
gint i;
gboolean send_done = FALSE;
GstClockTime timestamp = GST_BUFFER_TIMESTAMP (buffer);
if (h264parse->align == GST_H264_PARSE_ALIGN_NAL) {
/* send separate config NAL buffers */
......@@ -2318,14 +2323,14 @@ gst_h264_parse_handle_sps_pps_nals (GstH264Parse * h264parse,
for (i = 0; i < GST_H264_MAX_SPS_COUNT; i++) {
if ((codec_nal = h264parse->sps_nals[i])) {
GST_DEBUG_OBJECT (h264parse, "sending SPS nal");
gst_h264_parse_push_codec_buffer (h264parse, codec_nal, timestamp);
gst_h264_parse_push_codec_buffer (h264parse, codec_nal, buffer);
send_done = TRUE;
}
}
for (i = 0; i < GST_H264_MAX_PPS_COUNT; i++) {
if ((codec_nal = h264parse->pps_nals[i])) {
GST_DEBUG_OBJECT (h264parse, "sending PPS nal");
gst_h264_parse_push_codec_buffer (h264parse, codec_nal, timestamp);
gst_h264_parse_push_codec_buffer (h264parse, codec_nal, buffer);
send_done = TRUE;
}
}
......@@ -2445,8 +2450,7 @@ gst_h264_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
gst_buffer_fill (aud_buffer, 0, (guint8 *) (au_delim + 4), 2);
buffer = frame->buffer;
gst_h264_parse_push_codec_buffer (h264parse, aud_buffer,
GST_BUFFER_TIMESTAMP (buffer));
gst_h264_parse_push_codec_buffer (h264parse, aud_buffer, buffer);
gst_buffer_unref (aud_buffer);
}
} else {
......
Supports Markdown
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