rtpssrcdemux: Block pad while it is announced.

Block the RTP pad and associated RTCP pads while they are being
announced. This it to prevent a race where one is announced and
before the callback has connected it, the other one gets a buffer.

We can't use the "padlock" of ssrcdemux because it causes deadlocks.
This commit is contained in:
Olivier Crête 2012-08-06 18:02:50 -07:00
parent 81440b7e2f
commit 2e21ace12c

View file

@ -225,6 +225,7 @@ find_or_create_demux_pad_for_ssrc (GstRtpSsrcDemux * demux, guint32 ssrc,
GstCaps *caps; GstCaps *caps;
struct ForwardEventData fdata; struct ForwardEventData fdata;
GstPad *retpad; GstPad *retpad;
gulong rtp_block, rtcp_block;
GST_DEBUG_OBJECT (demux, "creating pad for SSRC %08x", ssrc); GST_DEBUG_OBJECT (demux, "creating pad for SSRC %08x", ssrc);
@ -313,13 +314,23 @@ find_or_create_demux_pad_for_ssrc (GstRtpSsrcDemux * demux, guint32 ssrc,
} }
gst_object_ref (rtp_pad); gst_object_ref (rtp_pad);
gst_object_ref (rtcp_pad);
rtp_block = gst_pad_add_probe (rtp_pad, GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM,
NULL, NULL, NULL);
rtcp_block = gst_pad_add_probe (rtcp_pad, GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM,
NULL, NULL, NULL);
GST_PAD_UNLOCK (demux); GST_PAD_UNLOCK (demux);
g_signal_emit (G_OBJECT (demux), g_signal_emit (G_OBJECT (demux),
gst_rtp_ssrc_demux_signals[SIGNAL_NEW_SSRC_PAD], 0, ssrc, rtp_pad); gst_rtp_ssrc_demux_signals[SIGNAL_NEW_SSRC_PAD], 0, ssrc, rtp_pad);
gst_pad_remove_probe (rtp_pad, rtp_block);
gst_pad_remove_probe (rtcp_pad, rtcp_block);
gst_object_unref (rtp_pad); gst_object_unref (rtp_pad);
gst_object_unref (rtcp_pad);
return retpad; return retpad;
} }