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.
This commit is contained in:
Nicolas Dufresne 2018-09-25 16:16:42 -04:00 committed by Nicolas Dufresne
parent 596dfbdf37
commit ea99aee881

View file

@ -2578,7 +2578,7 @@ discard:
* 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;
GstBuffer *wrapped_nal;
@ -2588,7 +2588,8 @@ gst_h264_parse_push_codec_buffer (GstH264Parse * h264parse,
map.data, map.size);
gst_buffer_unmap (nal, &map);
GST_BUFFER_TIMESTAMP (wrapped_nal) = ts;
GST_BUFFER_PTS (wrapped_nal) = GST_BUFFER_PTS (buffer);
GST_BUFFER_DTS (wrapped_nal) = GST_BUFFER_DTS (buffer);
GST_BUFFER_DURATION (wrapped_nal) = 0;
return gst_pad_push (GST_BASE_PARSE_SRC_PAD (h264parse), wrapped_nal);
@ -2696,7 +2697,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->have_sps_in_frame && h264parse->have_pps_in_frame) {
GST_DEBUG_OBJECT (h264parse, "SPS/PPS exist in frame, will not insert");
@ -2709,14 +2709,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;
}
}
@ -3007,8 +3007,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 {