GNOME Bugzilla – Bug 683920
rmdemux can not set caps on its own pad
Last modified: 2012-09-14 08:20:00 UTC
In function gst_rmdemux_add_stream, it will create video and audio pad, and will set caps of them. static void gst_rmdemux_add_stream (GstRMDemux * rmdemux, GstRMDemuxStream * stream) { if (stream->subtype == GST_RMDEMUX_STREAM_VIDEO) { char *name = g_strdup_printf ("video_%u", rmdemux->n_video_streams); stream->pad = gst_pad_new_from_static_template (&gst_rmdemux_videosrc_template, name); ...... } else if (stream->subtype == GST_RMDEMUX_STREAM_AUDIO) { char *name = g_strdup_printf ("audio_%u", rmdemux->n_audio_streams); stream->pad = gst_pad_new_from_static_template (&gst_rmdemux_audiosrc_template, name); } ...... gst_pad_use_fixed_caps (stream->pad); gst_pad_set_caps (stream->pad, stream_caps); gst_pad_set_event_function (stream->pad, ..... } gst_pad_new_from_static_template --> gst_pad_init will set pad flag to flushing by call GST_PAD_SET_FLUSHING (pad); And gst_pad_set_caps will failed if the pad flag is flushing. So we should add GST_PAD_UNSET_FLUSHING(stream->pad) after the pad is created.
What's the problem? there is a gst_pad_set_active (stream->pad, TRUE); before the events are pushed.
The code is like this. //================= static void gst_rmdemux_add_stream (GstRMDemux * rmdemux, GstRMDemuxStream * stream) { ...... gst_pad_use_fixed_caps (stream->pad); gst_pad_set_caps (stream->pad, stream_caps); gst_pad_set_event_function (stream->pad, GST_DEBUG_FUNCPTR (gst_rmdemux_src_event)); gst_pad_set_query_function (stream->pad, GST_DEBUG_FUNCPTR (gst_rmdemux_src_query)); GST_DEBUG_OBJECT (rmdemux, "adding pad %s with caps %" GST_PTR_FORMAT ", stream_id=%d", GST_PAD_NAME (stream->pad), stream_caps, stream->id); gst_pad_set_active (stream->pad, TRUE); gst_element_add_pad (GST_ELEMENT_CAST (rmdemux), stream->pad); ...... } It pushs the caps event before setting the pad to active. So maybe bring "gst_pad_set_active (stream->pad, TRUE);" before "gst_pad_set_caps (stream->pad, stream_caps);".
This was fixed ages ago as far as I can tell, it's even included in the 0.11.93 release from August: commit 1c07373c2bfccef2dd289177e52ceb97003b6d43 Author: Tim-Philipp Müller <tim.muller@collabora.co.uk> Date: Wed Jul 18 16:46:46 2012 +0100 rmdemux: set/send caps after activating the source pads Makes sure the caps event isn't dropped immediately. diff --git a/gst/realmedia/rmdemux.c b/gst/realmedia/rmdemux.c index 28481a4..6fde1f4 100644 --- a/gst/realmedia/rmdemux.c +++ b/gst/realmedia/rmdemux.c @@ -1479,7 +1479,6 @@ gst_rmdemux_add_stream (GstRMDemux * rmdemux, GstRMDemuxStream * stream) gst_pad_use_fixed_caps (stream->pad); - gst_pad_set_caps (stream->pad, stream_caps); gst_pad_set_event_function (stream->pad, GST_DEBUG_FUNCPTR (gst_rmdemux_src_event)); gst_pad_set_query_function (stream->pad, @@ -1488,6 +1487,7 @@ gst_rmdemux_add_stream (GstRMDemux * rmdemux, GstRMDemuxStream * stream) GST_DEBUG_OBJECT (rmdemux, "adding pad %s with caps %" GST_PTR_FORMAT ", stream_id=%d", GST_PAD_NAME (stream->pad), stream_caps, stream->id); gst_pad_set_active (stream->pad, TRUE); + gst_pad_set_caps (stream->pad, stream_caps); gst_element_add_pad (GST_ELEMENT_CAST (rmdemux), stream->pad); gst_pad_push_event (stream->pad, gst_event_new_stream_start ());
(In reply to comment #3) > This was fixed ages ago as far as I can tell, it's even included in the 0.11.93 > release from August: > > > commit 1c07373c2bfccef2dd289177e52ceb97003b6d43 > Author: Tim-Philipp Müller <tim.muller@collabora.co.uk> > Date: Wed Jul 18 16:46:46 2012 +0100 > > rmdemux: set/send caps after activating the source pads > > Makes sure the caps event isn't dropped immediately. > > diff --git a/gst/realmedia/rmdemux.c b/gst/realmedia/rmdemux.c > index 28481a4..6fde1f4 100644 > --- a/gst/realmedia/rmdemux.c > +++ b/gst/realmedia/rmdemux.c > @@ -1479,7 +1479,6 @@ gst_rmdemux_add_stream (GstRMDemux * rmdemux, > GstRMDemuxStream * stream) > > gst_pad_use_fixed_caps (stream->pad); > > - gst_pad_set_caps (stream->pad, stream_caps); > gst_pad_set_event_function (stream->pad, > GST_DEBUG_FUNCPTR (gst_rmdemux_src_event)); > gst_pad_set_query_function (stream->pad, > @@ -1488,6 +1487,7 @@ gst_rmdemux_add_stream (GstRMDemux * rmdemux, > GstRMDemuxStream * stream) > GST_DEBUG_OBJECT (rmdemux, "adding pad %s with caps %" GST_PTR_FORMAT > ", stream_id=%d", GST_PAD_NAME (stream->pad), stream_caps, > stream->id); > gst_pad_set_active (stream->pad, TRUE); > + gst_pad_set_caps (stream->pad, stream_caps); > gst_element_add_pad (GST_ELEMENT_CAST (rmdemux), stream->pad); > gst_pad_push_event (stream->pad, gst_event_new_stream_start ()); OK, thank you Tim. May I ask that when the gstreamer 0.11 stable version will be release ? Or when planing to release ?
> OK, thank you Tim. May I ask that when the gstreamer 0.11 stable version will > be release ? Or when planing to release ? You can use the 0.11.9x releases. The current release is 0.11.94. Otherwise http://gstreamer.freedesktop.org/wiki/ReleasePlanning2012 1.0.0 will be the 'stable' release (bu 0.11.94 is already 99.99% stable).