diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2018-11-06 23:02:21 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2018-11-07 23:23:58 +0200 |
commit | 4de11b56853f17f8f78ba2d613d2e8a39b94e333 (patch) | |
tree | 5d108771948f9489a3f2baf7a68f333a4dd5a354 | |
parent | 3a8bb77f1a95b3337a5e40c934e291c1487a1549 (diff) | |
download | gstreamer-plugins-good-4de11b56853f17f8f78ba2d613d2e8a39b94e333.tar.gz |
rtpbin: Sink jitterbuffer/storage before passing as parameters to signals
Otherwise signal handlers from bindings will take ownership of them as
they are still floating, and we won't own a reference inside rtpbin
anymore.
Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/issues/515
-rw-r--r-- | gst/rtpmanager/gstrtpbin.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gst/rtpmanager/gstrtpbin.c b/gst/rtpmanager/gstrtpbin.c index ad99c5b85..06dcabac4 100644 --- a/gst/rtpmanager/gstrtpbin.c +++ b/gst/rtpmanager/gstrtpbin.c @@ -784,6 +784,9 @@ create_session (GstRtpBin * rtpbin, gint id) if (!(storage = gst_element_factory_make ("rtpstorage", NULL))) goto no_storage; + /* need to sink the storage or otherwise signal handlers from bindings will + * take ownership of it and we don't own it anymore */ + gst_object_ref_sink (storage); g_signal_emit (rtpbin, gst_rtp_bin_signals[SIGNAL_NEW_STORAGE], 0, storage, id); @@ -849,6 +852,10 @@ create_session (GstRtpBin * rtpbin, gint id) gst_bin_add (GST_BIN_CAST (rtpbin), sess->rtcp_funnel); gst_bin_add (GST_BIN_CAST (rtpbin), storage); + /* unref the storage again, the bin has a reference now and + * we don't need it anymore */ + gst_object_unref (storage); + GST_OBJECT_LOCK (rtpbin); target = GST_STATE_TARGET (rtpbin); GST_OBJECT_UNLOCK (rtpbin); @@ -1834,6 +1841,9 @@ create_stream (GstRtpBinSession * session, guint32 ssrc) g_object_set (buffer, "max-ts-offset-adjustment", rtpbin->max_ts_offset_adjustment, NULL); + /* need to sink the jitterbufer or otherwise signal handlers from bindings will + * take ownership of it and we don't own it anymore */ + gst_object_ref_sink (buffer); g_signal_emit (rtpbin, gst_rtp_bin_signals[SIGNAL_NEW_JITTERBUFFER], 0, buffer, session->id, ssrc); @@ -1841,6 +1851,10 @@ create_stream (GstRtpBinSession * session, guint32 ssrc) gst_bin_add (GST_BIN_CAST (rtpbin), demux); gst_bin_add (GST_BIN_CAST (rtpbin), buffer); + /* unref the jitterbuffer again, the bin has a reference now and + * we don't need it anymore */ + gst_object_unref (buffer); + /* link stuff */ if (demux) gst_element_link_pads_full (buffer, "src", demux, "sink", |