diff options
| author | Wim Taymans <wim.taymans@collabora.co.uk> | 2009-06-29 18:48:33 +0200 | 
|---|---|---|
| committer | Tim-Philipp Müller <tim.muller@collabora.co.uk> | 2009-08-11 02:30:46 +0100 | 
| commit | 512ba93159d8c859ed515d0eb8c70a880d68a605 (patch) | |
| tree | 3564ca5791a82896432bee800b49b0018229a850 /gst | |
| parent | d7a8663e055234ddad2c9cdc645279a733d1787e (diff) | |
rtpbin: do better cleanup of the src ghostpads
Connect to the pad-removed signal of the ptdemux elements so that we remove the
ghostpads for them. Fixes cleanup when going to NULL as well as when releasing
the sinkpads.
Fixes #561752
Diffstat (limited to 'gst')
| -rw-r--r-- | gst/rtpmanager/gstrtpbin.c | 44 | 
1 files changed, 30 insertions, 14 deletions
diff --git a/gst/rtpmanager/gstrtpbin.c b/gst/rtpmanager/gstrtpbin.c index ea391cf1..c09b0ab9 100644 --- a/gst/rtpmanager/gstrtpbin.c +++ b/gst/rtpmanager/gstrtpbin.c @@ -288,10 +288,9 @@ struct _GstRtpBinStream    /* the PT demuxer of the SSRC */    GstElement *demux;    gulong demux_newpad_sig; +  gulong demux_padremoved_sig;    gulong demux_ptreq_sig;    gulong demux_pt_change_sig; -  /* ghostpads from the ptdemuxer */ -  GSList *pads;    /* if we have calculated a valid unix_delta for this stream */    gboolean have_sync; @@ -1152,7 +1151,6 @@ static void  free_stream (GstRtpBinStream * stream)  {    GstRtpBinSession *session; -  GSList *walk;    session = stream->session; @@ -1165,17 +1163,13 @@ free_stream (GstRtpBinStream * stream)    gst_element_set_state (stream->demux, GST_STATE_NULL);    gst_element_set_state (stream->buffer, GST_STATE_NULL); +  /* now remove this signal, we need this while going to NULL because it to  +   * do some cleanups */ +  g_signal_handler_disconnect (stream->demux, stream->demux_padremoved_sig); +    gst_bin_remove (GST_BIN_CAST (session->bin), stream->buffer);    gst_bin_remove (GST_BIN_CAST (session->bin), stream->demux); -  for (walk = stream->pads; walk; walk = g_slist_next (walk)) { -    GstPad *gpad = GST_PAD_CAST (walk->data); - -    gst_pad_set_active (gpad, FALSE); -    gst_element_remove_pad (GST_ELEMENT_CAST (session->bin), gpad); -  } -  g_slist_free (stream->pads); -    g_free (stream);  } @@ -1744,13 +1738,11 @@ new_payload_found (GstElement * element, guint pt, GstPad * pad,        stream->session->id, stream->ssrc, pt);    gpad = gst_ghost_pad_new_from_template (padname, pad, templ);    g_free (padname); +  g_object_set_data (G_OBJECT (pad), "GstRTPBin.ghostpad", gpad);    gst_pad_set_caps (gpad, GST_PAD_CAPS (pad));    gst_pad_set_active (gpad, TRUE);    gst_element_add_pad (GST_ELEMENT_CAST (rtpbin), gpad); - -  stream->pads = g_slist_prepend (stream->pads, gpad); -    GST_RTP_BIN_SHUTDOWN_UNLOCK (rtpbin);    return; @@ -1762,6 +1754,27 @@ shutdown:    }  } +static void +payload_pad_removed (GstElement * element, GstPad * pad, +    GstRtpBinStream * stream) +{ +  GstRtpBin *rtpbin; +  GstPad *gpad; + +  rtpbin = stream->bin; + +  GST_DEBUG ("payload pad removed"); + +  GST_RTP_BIN_DYN_LOCK (rtpbin); +  if ((gpad = g_object_get_data (G_OBJECT (pad), "GstRTPBin.ghostpad"))) { +    g_object_set_data (G_OBJECT (pad), "GstRTPBin.ghostpad", NULL); + +    gst_pad_set_active (gpad, FALSE); +    gst_element_remove_pad (GST_ELEMENT_CAST (rtpbin), gpad); +  } +  GST_RTP_BIN_DYN_UNLOCK (rtpbin); +} +  static GstCaps *  pt_map_requested (GstElement * element, guint pt, GstRtpBinSession * session)  { @@ -1869,6 +1882,9 @@ new_ssrc_pad_found (GstElement * element, guint ssrc, GstPad * pad,     * new pad by ghosting it. */    stream->demux_newpad_sig = g_signal_connect (stream->demux,        "new-payload-type", (GCallback) new_payload_found, stream); +  stream->demux_padremoved_sig = g_signal_connect (stream->demux, +      "pad-removed", (GCallback) payload_pad_removed, stream); +    /* connect to the request-pt-map signal. This signal will be emited by the     * demuxer so that it can apply a proper caps on the buffers for the     * depayloaders. */  | 
