changeset 26085:d6741612b1d0

merge of '8abcc61528a93f4c18a6e1f200a7ba69f1694c28' and '96b230451345d5543554f1d018ab450c76820d01'
author Mike Ruprecht <maiku@soc.pidgin.im>
date Thu, 05 Feb 2009 00:15:33 +0000
parents 218f052b9bf5 (diff) 0e8814c437b2 (current diff)
children af42303654a5
files
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/media.c	Wed Feb 04 09:27:27 2009 +0000
+++ b/libpurple/media.c	Thu Feb 05 00:15:33 2009 +0000
@@ -2390,12 +2390,30 @@
 
 	if (session_id != NULL && participant == NULL) {
 		PurpleMediaSession *session;
+		GstPad *pad, *peer;
+
 		session = purple_media_get_session(media, session_id);
 
 		if (session == NULL)
 			return FALSE;
 
 		sink = session->sink;
+
+		if (!GST_IS_ELEMENT(sink))
+			return FALSE;
+
+		pad = gst_element_get_static_pad(sink, "ghostsink");
+		peer = gst_pad_get_peer(pad);
+		gst_object_unref(pad);
+
+		gst_element_release_request_pad(GST_ELEMENT_PARENT(peer), peer);
+		gst_object_unref(peer);
+
+		gst_element_set_state(sink, GST_STATE_NULL);
+
+		gst_bin_remove(GST_BIN(GST_ELEMENT_PARENT(sink)), sink);
+		session->sink = NULL;
+		return TRUE;	
 	} else if (session_id != NULL && participant != NULL) {
 		PurpleMediaStream *stream;
 		stream = purple_media_get_stream(media,
@@ -2413,6 +2431,13 @@
 
 	/* Remove sink */
 	parent = GST_ELEMENT(gst_element_get_parent(sink));
+
+	if (parent == NULL) {
+		/* It's not added and therefore not linked */
+		gst_object_unref(sink);
+		return FALSE;
+	}
+
 	pad = gst_element_get_static_pad(sink, "ghostsink");
 
 	if (pad == NULL) {