From a0e934e72e0c5a633a70b98775a4012c46c41290 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Thu, 18 Apr 2013 07:49:54 -0300 Subject: [PATCH] qtdemux: push new caps events when caps change Whenever the demuxer has a new caps on a stream, it should set the new_caps variable to true and a new caps event will be pushed before the next buffer --- gst/isomp4/qtdemux.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c index 54bb05f368..b5ffbe5db5 100644 --- a/gst/isomp4/qtdemux.c +++ b/gst/isomp4/qtdemux.c @@ -200,6 +200,8 @@ struct _QtDemuxStream GstCaps *caps; guint32 fourcc; + gboolean new_caps; + /* if the stream has a redirect URI in its headers, we store it here */ gchar *redirect_uri; @@ -447,6 +449,8 @@ static void gst_qtdemux_stream_free (GstQTDemux * qtdemux, QtDemuxStream * stream); static void gst_qtdemux_stream_clear (QtDemuxStream * stream); static GstFlowReturn qtdemux_prepare_streams (GstQTDemux * qtdemux); +static void qtdemux_do_allocation (GstQTDemux * qtdemux, + QtDemuxStream * stream); static void gst_qtdemux_class_init (GstQTDemuxClass * klass) @@ -1702,6 +1706,7 @@ gst_qtdemux_setcaps (GstQTDemux * demux, GstCaps * caps) if (!stream->caps || !gst_caps_is_equal_fixed (mediacaps, stream->caps)) { GST_DEBUG_OBJECT (demux, "We have a new caps %" GST_PTR_FORMAT, mediacaps); + stream->new_caps = TRUE; } gst_caps_replace (&stream->caps, (GstCaps *) mediacaps); structure = gst_caps_get_structure (mediacaps, 0); @@ -4047,6 +4052,10 @@ gst_qtdemux_loop_state_movie (GstQTDemux * qtdemux) } stream = qtdemux->streams[index]; + if (stream->new_caps) { + gst_qtdemux_configure_stream (qtdemux, stream); + qtdemux_do_allocation (qtdemux, stream); + } /* fetch info for the current sample of this stream */ if (G_UNLIKELY (!gst_qtdemux_prepare_current_sample (qtdemux, stream, &offset, @@ -4751,6 +4760,10 @@ gst_qtdemux_chain (GstPad * sinkpad, GstObject * parent, GstBuffer * inbuf) if (G_UNLIKELY (stream == NULL || i == demux->n_streams)) goto unknown_stream; + if (stream->new_caps) { + gst_qtdemux_configure_stream (demux, stream); + } + /* Put data in a buffer, set timestamps, caps, ... */ outbuf = gst_adapter_take_buffer (demux->adapter, demux->neededbytes); GST_DEBUG_OBJECT (demux, "stream : %" GST_FOURCC_FORMAT, @@ -5578,7 +5591,7 @@ gst_qtdemux_configure_stream (GstQTDemux * qtdemux, QtDemuxStream * stream) gst_pad_push_event (stream->pad, gst_event_new_stream_start (stream_id)); g_free (stream_id); gst_pad_set_caps (stream->pad, stream->caps); - + stream->new_caps = FALSE; } return TRUE; }