h264parse: reset the parser information when caps changes

This prevents it from going into passthrough after receiving 2
byte-stream caps (different ones) as it would keep the have_pps and
have_sps set to true and would just go into passthrough without
updating its caps.

This patch makes it reset its stream information to restart properly
when new caps are received.

https://bugzilla.gnome.org/show_bug.cgi?id=745409
This commit is contained in:
Thiago Santos 2015-03-03 11:42:09 -03:00
parent 87f8d7890c
commit 14f6fcdbd8

View file

@ -195,8 +195,10 @@ gst_h264_parse_reset_frame (GstH264Parse * h264parse)
} }
static void static void
gst_h264_parse_reset (GstH264Parse * h264parse) gst_h264_parse_reset_stream_info (GstH264Parse * h264parse)
{ {
gint i;
h264parse->width = 0; h264parse->width = 0;
h264parse->height = 0; h264parse->height = 0;
h264parse->fps_num = 0; h264parse->fps_num = 0;
@ -205,19 +207,32 @@ gst_h264_parse_reset (GstH264Parse * h264parse)
h264parse->upstream_par_d = -1; h264parse->upstream_par_d = -1;
h264parse->parsed_par_n = 0; h264parse->parsed_par_n = 0;
h264parse->parsed_par_d = 0; h264parse->parsed_par_d = 0;
gst_buffer_replace (&h264parse->codec_data, NULL); h264parse->have_pps = FALSE;
gst_buffer_replace (&h264parse->codec_data_in, NULL); h264parse->have_sps = FALSE;
h264parse->nal_length_size = 4;
h264parse->packetized = FALSE;
h264parse->transform = FALSE;
h264parse->align = GST_H264_PARSE_ALIGN_NONE; h264parse->align = GST_H264_PARSE_ALIGN_NONE;
h264parse->format = GST_H264_PARSE_FORMAT_NONE; h264parse->format = GST_H264_PARSE_FORMAT_NONE;
h264parse->last_report = GST_CLOCK_TIME_NONE; h264parse->transform = FALSE;
h264parse->nal_length_size = 4;
h264parse->packetized = FALSE;
h264parse->push_codec = FALSE; h264parse->push_codec = FALSE;
h264parse->have_pps = FALSE;
h264parse->have_sps = FALSE; gst_buffer_replace (&h264parse->codec_data, NULL);
gst_buffer_replace (&h264parse->codec_data_in, NULL);
gst_h264_parse_reset_frame (h264parse);
for (i = 0; i < GST_H264_MAX_SPS_COUNT; i++)
gst_buffer_replace (&h264parse->sps_nals[i], NULL);
for (i = 0; i < GST_H264_MAX_PPS_COUNT; i++)
gst_buffer_replace (&h264parse->pps_nals[i], NULL);
}
static void
gst_h264_parse_reset (GstH264Parse * h264parse)
{
h264parse->last_report = GST_CLOCK_TIME_NONE;
h264parse->dts = GST_CLOCK_TIME_NONE; h264parse->dts = GST_CLOCK_TIME_NONE;
h264parse->ts_trn_nb = GST_CLOCK_TIME_NONE; h264parse->ts_trn_nb = GST_CLOCK_TIME_NONE;
@ -230,7 +245,7 @@ gst_h264_parse_reset (GstH264Parse * h264parse)
h264parse->discont = FALSE; h264parse->discont = FALSE;
gst_h264_parse_reset_frame (h264parse); gst_h264_parse_reset_stream_info (h264parse);
} }
static gboolean static gboolean
@ -257,17 +272,11 @@ gst_h264_parse_start (GstBaseParse * parse)
static gboolean static gboolean
gst_h264_parse_stop (GstBaseParse * parse) gst_h264_parse_stop (GstBaseParse * parse)
{ {
guint i;
GstH264Parse *h264parse = GST_H264_PARSE (parse); GstH264Parse *h264parse = GST_H264_PARSE (parse);
GST_DEBUG_OBJECT (parse, "stop"); GST_DEBUG_OBJECT (parse, "stop");
gst_h264_parse_reset (h264parse); gst_h264_parse_reset (h264parse);
for (i = 0; i < GST_H264_MAX_SPS_COUNT; i++)
gst_buffer_replace (&h264parse->sps_nals[i], NULL);
for (i = 0; i < GST_H264_MAX_PPS_COUNT; i++)
gst_buffer_replace (&h264parse->pps_nals[i], NULL);
gst_h264_nal_parser_free (h264parse->nalparser); gst_h264_nal_parser_free (h264parse->nalparser);
return TRUE; return TRUE;
@ -2079,12 +2088,20 @@ gst_h264_parse_set_caps (GstBaseParse * parse, GstCaps * caps)
guint format, align, off; guint format, align, off;
GstH264NalUnit nalu; GstH264NalUnit nalu;
GstH264ParserResult parseres; GstH264ParserResult parseres;
GstCaps *old_caps;
h264parse = GST_H264_PARSE (parse); h264parse = GST_H264_PARSE (parse);
/* reset */ /* reset */
h264parse->push_codec = FALSE; h264parse->push_codec = FALSE;
old_caps = gst_pad_get_current_caps (GST_BASE_PARSE_SINK_PAD (parse));
if (old_caps) {
if (!gst_caps_is_equal (old_caps, caps))
gst_h264_parse_reset_stream_info (h264parse);
gst_caps_unref (old_caps);
}
str = gst_caps_get_structure (caps, 0); str = gst_caps_get_structure (caps, 0);
/* accept upstream info if provided */ /* accept upstream info if provided */