changeset 25661:d048100a43ab

Free the PurpleMedia object when the media session ends and fix ending the session when the conversation is closed.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Sat, 31 May 2008 04:01:18 +0000
parents 10f5a529d2a6
children 28ab41065172
files libpurple/media.c libpurple/protocols/jabber/jingle.c
diffstat 2 files changed, 63 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/media.c	Wed May 28 21:13:36 2008 +0000
+++ b/libpurple/media.c	Sat May 31 04:01:18 2008 +0000
@@ -253,6 +253,62 @@
 static void
 purple_media_finalize (GObject *media)
 {
+	PurpleMediaPrivate *priv = PURPLE_MEDIA_GET_PRIVATE(media);
+	GList *iter;
+	purple_debug_info("media","purple_media_finalize\n");
+
+	g_free(priv->name);
+
+	if (priv->audio_pipeline) {
+		gst_element_set_state(priv->audio_pipeline, GST_STATE_NULL);
+		gst_object_unref(priv->audio_pipeline);
+	}
+	if (priv->video_pipeline) {
+		gst_element_set_state(priv->video_pipeline, GST_STATE_NULL);
+		gst_object_unref(priv->video_pipeline);
+	}
+
+	if (priv->audio_src)
+		gst_object_unref(priv->audio_src);
+	if (priv->audio_sink)
+		gst_object_unref(priv->audio_sink);
+	if (priv->video_src)
+		gst_object_unref(priv->video_src);
+	if (priv->video_sink)
+		gst_object_unref(priv->video_sink);
+
+	for (iter = priv->audio_streams; iter; iter = g_list_next(iter)) {
+		g_object_unref(iter->data);
+	}
+	g_list_free(priv->audio_streams);
+
+	for (iter = priv->video_streams; iter; iter = g_list_next(iter)) {
+		g_object_unref(iter->data);
+	}
+	g_list_free(priv->video_streams);
+
+	if (priv->audio_session)
+		g_object_unref(priv->audio_session);
+	if (priv->video_session)
+		g_object_unref(priv->video_session);
+
+	for (iter = priv->participants; iter; iter = g_list_next(iter)) {
+		g_object_unref(iter->data);
+	}
+	g_list_free(priv->participants);
+
+	for (iter = priv->local_candidates; iter; iter = g_list_next(iter)) {
+		g_free(iter->data);
+	}
+	g_list_free(priv->local_candidates);
+
+	if (priv->local_candidate)
+		g_free(priv->local_candidate);
+	if (priv->remote_candidate)
+		g_free(priv->remote_candidate);
+
+	gst_object_unref(priv->conference);
+
 	parent_class->finalize(media);
 }
 
--- a/libpurple/protocols/jabber/jingle.c	Wed May 28 21:13:36 2008 +0000
+++ b/libpurple/protocols/jabber/jingle.c	Sat May 31 04:01:18 2008 +0000
@@ -101,6 +101,7 @@
 {
 	g_hash_table_remove(sess->js->sessions, sess->id);
 	g_free(sess->id);
+	g_object_unref(sess->media);
 	g_free(sess);
 }
 
@@ -119,13 +120,18 @@
 {
 	GList *values = g_hash_table_get_values(js->sessions);
 	GList *iter = values;
+	gboolean use_bare = strchr(jid, '/') == NULL;
 
 	for (; iter; iter = iter->next) {
 		JingleSession *session = (JingleSession *)iter->data;
-		if (session->js == js && !strcmp(jid, session->remote_jid)) {
+		gchar *cmp_jid = use_bare ? jabber_get_bare_jid(session->remote_jid)
+					  : g_strdup(session->remote_jid);
+		if (!strcmp(jid, cmp_jid)) {
+			g_free(cmp_jid);
 			g_list_free(values);
 			return session;
 		}
+		g_free(cmp_jid);
 	}
 
 	g_list_free(values);