diff options
author | Olivier CrĂȘte <olivier.crete@collabora.com> | 2013-07-22 15:26:21 +0200 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2013-07-22 16:29:18 +0200 |
commit | 7d5b8e37287699c434628c63a35258f0f9619fe3 (patch) | |
tree | 373fccfbeb33b9d1cd2322721c91579d93ef78e8 | |
parent | cef47d85294a0dca38631f938b81a3f0dd6891bd (diff) | |
download | gstreamer-plugins-bad-7d5b8e37287699c434628c63a35258f0f9619fe3.tar.gz |
h264parse: Don't run in an infinite loop on invalid streams
Instead return a stream error if the H.264 can't be parsed
-rw-r--r-- | gst/videoparsers/gsth264parse.c | 28 | ||||
-rw-r--r-- | gst/videoparsers/gsth264parse.h | 1 |
2 files changed, 21 insertions, 8 deletions
diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index d398dbb9a..349fc7532 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -239,6 +239,7 @@ gst_h264_parse_start (GstBaseParse * parse) h264parse->sei_pic_struct_pres_flag = FALSE; h264parse->sei_pic_struct = 0; h264parse->field_pic_flag = 0; + h264parse->have_error = TRUE; gst_base_parse_set_min_frame_size (parse, 6); @@ -751,16 +752,19 @@ gst_h264_parse_check_valid_frame (GstBaseParse * parse, } /* otherwise need more */ goto more; - case GST_H264_PARSER_BROKEN_LINK: - g_assert_not_reached (); - break; case GST_H264_PARSER_ERROR: - /* should not really occur either */ - GST_DEBUG_OBJECT (h264parse, "error parsing Nal Unit"); - /* fall-through */ + GST_ELEMENT_ERROR (h264parse, STREAM, FORMAT, + ("Error parsing H.264 stream"), ("Invalid H.264 stream")); + goto invalid_stream; + case GST_H264_PARSER_BROKEN_LINK: + GST_ELEMENT_ERROR (h264parse, STREAM, FORMAT, + ("Error parsing H.264 stream"), + ("The link to structure needed for the parsing couldn't be found")); + goto invalid_stream; case GST_H264_PARSER_NO_NAL: - g_assert_not_reached (); - break; + GST_ELEMENT_ERROR (h264parse, STREAM, FORMAT, + ("Error parsing H.264 stream"), ("No H.264 NAL unit found")); + goto invalid_stream; case GST_H264_PARSER_BROKEN_DATA: GST_WARNING_OBJECT (h264parse, "input stream is corrupt; " "it contains a NAL unit of length %u", nalu.size); @@ -844,6 +848,10 @@ skip: GST_DEBUG_OBJECT (h264parse, "skipping %d", *skipsize); gst_h264_parse_reset_frame (h264parse); return FALSE; + +invalid_stream: + h264parse->have_error = TRUE; + return TRUE; } /* byte together avc codec data based on collected pps and sps so far */ @@ -1322,6 +1330,9 @@ gst_h264_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame) h264parse = GST_H264_PARSE (parse); buffer = frame->buffer; + if (h264parse->have_error) + return GST_FLOW_ERROR; + gst_h264_parse_update_src_caps (h264parse, NULL); /* don't mess with timestamps if provided by upstream, @@ -1838,6 +1849,7 @@ gst_h264_parse_event (GstBaseParse * parse, GstEvent * event) case GST_EVENT_FLUSH_STOP: h264parse->dts = GST_CLOCK_TIME_NONE; h264parse->ts_trn_nb = GST_CLOCK_TIME_NONE; + h264parse->have_error = FALSE; break; case GST_EVENT_NEWSEGMENT: { diff --git a/gst/videoparsers/gsth264parse.h b/gst/videoparsers/gsth264parse.h index 9fa9d69b6..68ddba4d4 100644 --- a/gst/videoparsers/gsth264parse.h +++ b/gst/videoparsers/gsth264parse.h @@ -75,6 +75,7 @@ struct _GstH264Parse gint current_off; gboolean packetized_last; gboolean packetized_chunked; + gboolean have_error; GstClockTime last_report; gboolean push_codec; |