ptdemux: set caps after activating the pad
authorWim Taymans <wim.taymans@collabora.co.uk>
Wed, 7 Mar 2012 13:55:08 +0000 (14:55 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Wed, 7 Mar 2012 14:02:44 +0000 (15:02 +0100)
Set the caps after we activated the pad or else it will just fail.

gst/rtpmanager/gstrtpptdemux.c

index 06a28c5..bef52d0 100644 (file)
@@ -383,11 +383,6 @@ gst_rtp_pt_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
     g_free (padname);
     gst_pad_set_event_function (srcpad, gst_rtp_pt_demux_src_event);
 
-    caps = gst_caps_make_writable (caps);
-    gst_caps_set_simple (caps, "payload", G_TYPE_INT, pt, NULL);
-    gst_pad_set_caps (srcpad, caps);
-    gst_caps_unref (caps);
-
     GST_DEBUG ("Adding pt=%d to the list.", pt);
     rtpdemuxpad = g_slice_new0 (GstRtpPtDemuxPad);
     rtpdemuxpad->pt = pt;
@@ -399,6 +394,12 @@ gst_rtp_pt_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
     GST_OBJECT_UNLOCK (rtpdemux);
 
     gst_pad_set_active (srcpad, TRUE);
+
+    caps = gst_caps_make_writable (caps);
+    gst_caps_set_simple (caps, "payload", G_TYPE_INT, pt, NULL);
+    gst_pad_set_caps (srcpad, caps);
+    gst_caps_unref (caps);
+
     gst_pad_sticky_events_foreach (rtpdemux->sink, forward_sticky_events,
         srcpad);
     gst_element_add_pad (GST_ELEMENT_CAST (rtpdemux), srcpad);
@@ -491,6 +492,8 @@ gst_rtp_pt_demux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
     case GST_EVENT_CAPS:
     {
       gst_rtp_pt_demux_clear_pt_map (rtpdemux);
+      /* don't forward the event, we cleared the ptmap and on the next buffer we
+       * will add the pt to the caps and push a new caps event */
       gst_event_unref (event);
       res = TRUE;
       break;