[PATCH 1/3] media: ensure nonunique source is removed from pipeline when unlinked

David Woodhouse dwmw2 at infradead.org
Fri Mar 13 10:46:54 EDT 2015


---
 libpurple/mediamanager.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/libpurple/mediamanager.c b/libpurple/mediamanager.c
index 5911aaa..6b31289 100644
--- a/libpurple/mediamanager.c
+++ b/libpurple/mediamanager.c
@@ -422,6 +422,16 @@ request_pad_unlinked_cb(GstPad *pad, GstPad *peer, gpointer user_data)
 
 	gst_iterator_free(iter);
 }
+
+static void
+nonunique_src_unlinked_cb(GstPad *pad, GstPad *peer, gpointer user_data)
+{
+	GstElement *element = GST_ELEMENT_PARENT(pad);
+	gst_element_set_locked_state(element, TRUE);
+	gst_element_set_state(element, GST_STATE_NULL);
+	gst_bin_remove(GST_BIN(GST_ELEMENT_PARENT(element)), element);
+}
+
 #endif
 
 #ifdef USE_GSTREAMER
@@ -561,6 +571,10 @@ purple_media_manager_get_element(PurpleMediaManager *manager,
 		ret = purple_media_element_info_call_create(info,
 				media, session_id, participant);
 		if (element_type & PURPLE_MEDIA_ELEMENT_SRC) {
+			GstPad *pad = gst_element_get_static_pad(ret, "src");
+			g_signal_connect(pad, "unlinked",
+					G_CALLBACK(nonunique_src_unlinked_cb), NULL);
+			gst_object_unref(pad);
 			gst_object_ref(ret);
 			gst_bin_add(GST_BIN(purple_media_manager_get_pipeline(manager)),
 				ret);
-- 
2.1.0


-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse at intel.com                              Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5745 bytes
Desc: not available
URL: <https://pidgin.im/pipermail/devel/attachments/20150313/4455ecd3/attachment.bin>


More information about the Devel mailing list