h264parse: Don't abort on invalid streams

Just return an error
This commit is contained in:
Olivier Crête 2013-07-22 14:56:32 +02:00
parent ed16c9c560
commit 6a1896d805

View file

@ -832,15 +832,19 @@ gst_h264_parse_handle_frame (GstBaseParse * parse,
/* otherwise need more */ /* otherwise need more */
goto more; goto more;
case GST_H264_PARSER_BROKEN_LINK: case GST_H264_PARSER_BROKEN_LINK:
g_assert_not_reached (); GST_ELEMENT_ERROR (h264parse, STREAM, FORMAT,
break; ("Error parsing H.264 stream"),
("The link to structure needed for the parsing couldn't be found"));
goto invalid_stream;
case GST_H264_PARSER_ERROR: case GST_H264_PARSER_ERROR:
/* should not really occur either */ /* should not really occur either */
GST_DEBUG_OBJECT (h264parse, "error parsing Nal Unit"); GST_ELEMENT_ERROR (h264parse, STREAM, FORMAT,
/* fall-through */ ("Error parsing H.264 stream"), ("Invalid H.264 stream"));
goto invalid_stream;
case GST_H264_PARSER_NO_NAL: case GST_H264_PARSER_NO_NAL:
g_assert_not_reached (); GST_ELEMENT_ERROR (h264parse, STREAM, FORMAT,
break; ("Error parsing H.264 stream"), ("No H.264 NAL unit found"));
goto invalid_stream;
case GST_H264_PARSER_BROKEN_DATA: case GST_H264_PARSER_BROKEN_DATA:
GST_WARNING_OBJECT (h264parse, "input stream is corrupt; " GST_WARNING_OBJECT (h264parse, "input stream is corrupt; "
"it contains a NAL unit of length %u", nalu.size); "it contains a NAL unit of length %u", nalu.size);
@ -887,7 +891,9 @@ gst_h264_parse_handle_frame (GstBaseParse * parse,
(h264parse->have_sps && h264parse->have_pps)) { (h264parse->have_sps && h264parse->have_pps)) {
gst_h264_parse_process_nal (h264parse, &nalu); gst_h264_parse_process_nal (h264parse, &nalu);
} else { } else {
GST_WARNING_OBJECT (h264parse, "no SPS/PPS yet, nal Type: %d, Size: %u will be dropped", nalu.type, nalu.size); GST_WARNING_OBJECT (h264parse,
"no SPS/PPS yet, nal Type: %d, Size: %u will be dropped", nalu.type,
nalu.size);
*skipsize = nalu.size; *skipsize = nalu.size;
goto skip; goto skip;
} }
@ -928,6 +934,10 @@ skip:
GST_DEBUG_OBJECT (h264parse, "skipping %d", *skipsize); GST_DEBUG_OBJECT (h264parse, "skipping %d", *skipsize);
gst_h264_parse_reset_frame (h264parse); gst_h264_parse_reset_frame (h264parse);
goto out; goto out;
invalid_stream:
gst_buffer_unmap (buffer, &map);
return GST_FLOW_ERROR;
} }
/* byte together avc codec data based on collected pps and sps so far */ /* byte together avc codec data based on collected pps and sps so far */