From: Edward Hervey Date: Thu, 19 May 2011 10:55:30 +0000 (+0200) Subject: legacyh264parse: Delay pushing buffers until we have width/height X-Git-Tag: 1.19.3~507^2~16050^2~60 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=219c90ce3447ed6374aae32ba9af375394a8a865;p=platform%2Fupstream%2Fgstreamer.git legacyh264parse: Delay pushing buffers until we have width/height --- diff --git a/gst/h264parse/gsth264parse.c b/gst/h264parse/gsth264parse.c index 9c751a1..514a739 100644 --- a/gst/h264parse/gsth264parse.c +++ b/gst/h264parse/gsth264parse.c @@ -1602,6 +1602,8 @@ gst_h264_parse_push_codec_buffer (GstH264Parse * h264parse, GstBuffer * nal, static GstFlowReturn gst_h264_parse_push_buffer (GstH264Parse * h264parse, GstBuffer * buf) { + GstFlowReturn res = GST_FLOW_OK; + /* We can send pending events if this is the first call, since we now have * caps for the srcpad */ if (G_UNLIKELY (h264parse->pending_segment != NULL)) { @@ -1619,6 +1621,33 @@ gst_h264_parse_push_buffer (GstH264Parse * h264parse, GstBuffer * buf) } } + if (G_UNLIKELY (h264parse->width == 0 || h264parse->height == 0)) { + GST_DEBUG ("Delaying actual push until we are configured"); + h264parse->gather = g_list_append (h264parse->gather, buf); + goto beach; + } + + if (G_UNLIKELY (h264parse->gather)) { + GList *pendingbuffers = h264parse->gather; + GList *tmp; + + GST_DEBUG ("Pushing out pending buffers"); + + /* Yes, we're recursively calling in... */ + h264parse->gather = NULL; + for (tmp = pendingbuffers; tmp; tmp = tmp->next) { + res = gst_h264_parse_push_buffer (h264parse, (GstBuffer *) tmp->data); + if (res != GST_FLOW_OK && res != GST_FLOW_NOT_LINKED) + break; + } + g_list_free (pendingbuffers); + + if (res != GST_FLOW_OK && res != GST_FLOW_NOT_LINKED) { + gst_buffer_unref (buf); + goto beach; + } + } + /* start of picture is good time to slip in codec_data NALUs * (when outputting NALS and transforming to bytestream) */ if (G_UNLIKELY (h264parse->codec_nals && h264parse->picture_start)) { @@ -1740,7 +1769,10 @@ gst_h264_parse_push_buffer (GstH264Parse * h264parse, GstBuffer * buf) } gst_buffer_set_caps (buf, h264parse->src_caps); - return gst_pad_push (h264parse->srcpad, buf); + res = gst_pad_push (h264parse->srcpad, buf); + +beach: + return res; } /* takes over ownership of nal and returns fresh buffer */