pidgin.vv: 23b9058d: Implement *_remove_output_window and *_r...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Mon Feb 2 06:40:28 EST 2009


-----------------------------------------------------------------
Revision: 23b9058df46a6336d6a8e18ae93a4f3e96959fe7
Ancestor: ea95803dbb84a2724c0ca489b0c7bc9ceca3e1ff
Author: maiku at soc.pidgin.im
Date: 2009-02-02T09:58:14
Branch: im.pidgin.pidgin.vv
URL: http://d.pidgin.im/viewmtn/revision/info/23b9058df46a6336d6a8e18ae93a4f3e96959fe7

Modified files:
        libpurple/media.c libpurple/media.h pidgin/gtkmedia.c

ChangeLog: 

Implement *_remove_output_window and *_remove_output_windows.

-------------- next part --------------
============================================================
--- libpurple/media.c	071de82d3a209571bc4f2eeb117806c49858f3ca
+++ libpurple/media.c	59822cc843ea80104526dc3e262a3c79572a6a34
@@ -2374,4 +2374,87 @@ purple_media_set_output_window(PurpleMed
 	return FALSE;
 }
 
+static void
+dummy_block_cb(GstPad *pad, gboolean blocked, gpointer user_data)
+{
+}
+
+gboolean
+purple_media_remove_output_window(PurpleMedia *media, const gchar *session_id,
+		const gchar *participant)
+{	
+	GstElement *parent, *fakesink, *sink;
+	GstPad *pad, *peer;
+
+	g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
+
+	if (session_id != NULL && participant == NULL) {
+		PurpleMediaSession *session;
+		session = purple_media_get_session(media, session_id);
+
+		if (session == NULL)
+			return FALSE;
+
+		sink = session->sink;
+	} else if (session_id != NULL && participant != NULL) {
+		PurpleMediaStream *stream;
+		stream = purple_media_get_stream(media,
+				session_id, participant);
+
+		if (stream == NULL)
+			return FALSE;
+
+		sink = stream->sink;
+	} else
+		return FALSE;
+
+	if (!GST_IS_ELEMENT(sink))
+		return FALSE;
+
+	/* Remove sink */
+	parent = GST_ELEMENT(gst_element_get_parent(sink));
+	pad = gst_element_get_static_pad(sink, "ghostsink");
+
+	if (pad == NULL) {
+		/* It's already a fakesink */
+		gst_object_unref(parent);
+		return FALSE;
+	}
+
+	peer = gst_pad_get_peer(pad);
+	gst_object_unref(pad);
+	gst_pad_set_blocked_async(peer, TRUE, dummy_block_cb, NULL);
+	gst_element_set_state(sink, GST_STATE_NULL);
+	gst_bin_remove(GST_BIN(parent), sink);
+
+	/* Add fakesink */
+	fakesink = gst_element_factory_make("fakesink", NULL);
+	gst_bin_add(GST_BIN(parent), fakesink);
+	gst_element_sync_state_with_parent(fakesink);
+	gst_object_unref(parent);
+	pad = gst_element_get_static_pad(fakesink, "sink");
+	gst_pad_link(peer, pad);
+	gst_object_unref(pad);
+	gst_pad_set_blocked_async(peer, FALSE, dummy_block_cb, NULL);
+	gst_object_unref(peer);
+	return TRUE;
+}
+
+void
+purple_media_remove_output_windows(PurpleMedia *media)
+{
+	GList *iter = media->priv->streams;
+	for (; iter; iter = g_list_next(iter)) {
+		PurpleMediaStream *stream = iter->data;
+		purple_media_remove_output_window(media,
+				stream->session->id, stream->participant);
+	}
+
+	iter = purple_media_get_session_names(media);
+	for (; iter; iter = g_list_delete_link(iter, iter)) {
+		gchar *session_name = iter->data;
+		purple_media_remove_output_window(media, session_name, NULL);
+	}
+}
+
 #endif  /* USE_VV */
============================================================
--- libpurple/media.h	ef1272970939b78d4d0bb6a748333c9e543c501b
+++ libpurple/media.h	001a7b2df4b9909c9d645205379ecf1b82c577a4
@@ -642,6 +642,9 @@ gboolean purple_media_set_output_window(
 gboolean purple_media_set_output_window(PurpleMedia *media,
 		const gchar *session_id, const gchar *participant,
 		gulong window_id);
+gboolean purple_media_remove_output_window(PurpleMedia *media,
+		const gchar *session_id, const gchar *participant);
+void purple_media_remove_output_windows(PurpleMedia *media);
 
 #ifdef __cplusplus
 }
============================================================
--- pidgin/gtkmedia.c	8ffd886e2707377a7a610b53cfbc2f728c2085aa
+++ pidgin/gtkmedia.c	fe6544279ad4988c86aed5e7714efccde455517d
@@ -285,20 +285,7 @@ pidgin_media_dispose(GObject *media)
 	purple_debug_info("gtkmedia", "pidgin_media_dispose\n");
 
 	if (gtkmedia->priv->media) {
-		GstElement *videosendbin = NULL, *videorecvbin = NULL;
-
-		purple_media_get_elements(gtkmedia->priv->media, NULL, NULL,
-					  &videosendbin, &videorecvbin);
-
-		if (videorecvbin) {
-			gst_element_set_locked_state(videorecvbin, TRUE);
-			gst_element_set_state(videorecvbin, GST_STATE_NULL);
-		}
-		if (videosendbin) {
-			gst_element_set_locked_state(videosendbin, TRUE);
-			gst_element_set_state(videosendbin, GST_STATE_NULL);
-		}
-
+		purple_media_remove_output_windows(gtkmedia->priv->media);
 		pidgin_media_disconnect_levels(gtkmedia->priv->media, gtkmedia);
 		g_object_unref(gtkmedia->priv->media);
 		gtkmedia->priv->media = NULL;


More information about the Commits mailing list