soc.2008.vv: bb8f798d: Free the PurpleMedia object when the med...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Sat May 31 02:51:01 EDT 2008


-----------------------------------------------------------------
Revision: bb8f798d1ef29d6376415e99e72a083d4b43b779
Ancestor: 78d37699f72ea160678190b207683ea77baab3fa
Author: maiku at soc.pidgin.im
Date: 2008-05-31T04:01:18
Branch: im.pidgin.soc.2008.vv
URL: http://d.pidgin.im/viewmtn/revision/info/bb8f798d1ef29d6376415e99e72a083d4b43b779

Modified files:
        libpurple/media.c libpurple/protocols/jabber/jingle.c

ChangeLog: 

Free the PurpleMedia object when the media session ends and fix ending 
the session when the conversation is closed.

-------------- next part --------------
============================================================
--- libpurple/media.c	078c9d0d3a2a12ad4e4a8b2cbaf9a770a5270c7f
+++ libpurple/media.c	b642d75b03c700a0d585d5914c35806e39bc7f32
@@ -253,6 +253,62 @@ purple_media_finalize (GObject *media)
 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);
 }
 
============================================================
--- libpurple/protocols/jabber/jingle.c	6bca5215d244b580fdc278600498dfdaacb1bc8f
+++ libpurple/protocols/jabber/jingle.c	87806795592d1b81365a624f4bdd3a948afe5525
@@ -101,6 +101,7 @@ jabber_jingle_session_destroy(JingleSess
 {
 	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 @@ JingleSession *jabber_jingle_session_fin
 {
 	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);


More information about the Commits mailing list