h264parse: Don't push NALs before we have HEADERS

Otherwise we may endup pushing incomplete caps, which cause a renegotiation.
Note that this has the effect that caps are no longer pushed twice in presence
of valid framerate in the headers.
This commit is contained in:
Nicolas Dufresne 2019-06-12 22:19:04 -04:00 committed by Nicolas Dufresne
parent ff137a2059
commit 1ea21ad922

View file

@ -231,7 +231,6 @@ gst_h264_parse_reset_frame (GstH264Parse * h264parse)
h264parse->bidirectional = FALSE; h264parse->bidirectional = FALSE;
h264parse->header = FALSE; h264parse->header = FALSE;
h264parse->frame_start = FALSE; h264parse->frame_start = FALSE;
h264parse->aud_insert = FALSE;
h264parse->have_sps_in_frame = FALSE; h264parse->have_sps_in_frame = FALSE;
h264parse->have_pps_in_frame = FALSE; h264parse->have_pps_in_frame = FALSE;
gst_adapter_clear (h264parse->frame_out); gst_adapter_clear (h264parse->frame_out);
@ -323,6 +322,8 @@ gst_h264_parse_start (GstBaseParse * parse)
h264parse->sei_pic_struct_pres_flag = FALSE; h264parse->sei_pic_struct_pres_flag = FALSE;
h264parse->sei_pic_struct = 0; h264parse->sei_pic_struct = 0;
h264parse->field_pic_flag = 0; h264parse->field_pic_flag = 0;
h264parse->aud_needed = TRUE;
h264parse->aud_insert = FALSE;
gst_base_parse_set_min_frame_size (parse, 4); gst_base_parse_set_min_frame_size (parse, 4);
@ -1512,6 +1513,13 @@ gst_h264_parse_handle_frame (GstBaseParse * parse,
h264parse->aud_needed = FALSE; h264parse->aud_needed = FALSE;
} }
/* Do not push immediatly if we don't have all headers. This ensure that
* our caps are complete, avoiding a renegotiation */
if (h264parse->align == GST_H264_PARSE_ALIGN_NAL &&
!GST_H264_PARSE_STATE_VALID (h264parse,
GST_H264_PARSE_STATE_VALID_PICTURE_HEADERS))
frame->flags |= GST_BASE_PARSE_FRAME_FLAG_QUEUE;
/* if no next nal, we reached the end of this buffer */ /* if no next nal, we reached the end of this buffer */
if (nonext) { if (nonext) {
/* If there is a marker flag, or input is AU, we know this is complete */ /* If there is a marker flag, or input is AU, we know this is complete */
@ -3050,6 +3058,7 @@ gst_h264_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
} else { } else {
buffer = frame->buffer; buffer = frame->buffer;
} }
h264parse->aud_insert = FALSE;
if ((event = check_pending_key_unit_event (h264parse->force_key_unit_event, if ((event = check_pending_key_unit_event (h264parse->force_key_unit_event,
&parse->segment, GST_BUFFER_TIMESTAMP (buffer), &parse->segment, GST_BUFFER_TIMESTAMP (buffer),