changeset 29161:cc978a1a4bd1

Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
author maiku@pidgin.im
date Fri, 23 Oct 2009 23:12:57 +0000
parents 2460e6774e08
children 74e75fc3481e
files libpurple/media/backend-fs2.c libpurple/media/media.c
diffstat 2 files changed, 16 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/media/backend-fs2.c	Fri Oct 23 22:20:45 2009 +0000
+++ b/libpurple/media/backend-fs2.c	Fri Oct 23 23:12:57 2009 +0000
@@ -663,13 +663,10 @@
 			"farsight-codecs-changed")) {
 		const GValue *value;
 		FsSession *fssession;
-#if 0
 		GList *sessions;
-#endif
 
 		value = gst_structure_get_value(msg->structure, "session");
 		fssession = g_value_get_object(value);
-#if 0
 		sessions = g_hash_table_get_values(priv->sessions);
 
 		for (; sessions; sessions =
@@ -681,14 +678,12 @@
 				continue;
 
 			session_id = g_strdup(session->id);
-			g_signal_emit(media,
-					purple_media_backend_fs2_signals[
-					CODECS_CHANGED], 0, session_id);
+			g_signal_emit_by_name(self, "codecs-changed",
+					session_id);
 			g_free(session_id);
 			g_list_free(sessions);
 			break;
 		}
-#endif
 	}
 }
 
--- a/libpurple/media/media.c	Fri Oct 23 22:20:45 2009 +0000
+++ b/libpurple/media/media.c	Fri Oct 23 23:12:57 2009 +0000
@@ -146,6 +146,8 @@
 static void purple_media_candidate_pair_established_cb(FsStream *stream,
 		FsCandidate *native_candidate, FsCandidate *remote_candidate,
 		PurpleMediaSession *session);
+static void purple_media_codecs_changed_cb(PurpleMediaBackend *backend,
+		const gchar *sess_id, PurpleMedia *media);
 static gboolean media_bus_call(GstBus *bus,
 		GstMessage *msg, PurpleMedia *media);
 
@@ -440,6 +442,11 @@
 					"media", media,
 					NULL);
 			g_signal_connect(media->priv->backend,
+					"codecs-changed",
+					G_CALLBACK(
+					purple_media_codecs_changed_cb),
+					media);
+			g_signal_connect(media->priv->backend,
 					"new-candidate",
 					G_CALLBACK(
 					purple_media_new_local_candidate_cb),
@@ -1072,20 +1079,6 @@
 				FsCandidate *remote_candidate = g_value_get_boxed(gst_structure_get_value(msg->structure, "remote-candidate"));
 				PurpleMediaSession *session = purple_media_session_from_fs_stream(media, stream);
 				purple_media_candidate_pair_established_cb(stream, local_candidate, remote_candidate, session);
-			} else if (gst_structure_has_name(msg->structure,
-					"farsight-codecs-changed")) {
-				GList *sessions = g_hash_table_get_values(PURPLE_MEDIA(media)->priv->sessions);
-				FsSession *fssession = g_value_get_object(gst_structure_get_value(msg->structure, "session"));
-				for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
-					PurpleMediaSession *session = sessions->data;
-					if (session->session == fssession) {
-						gchar *session_id = g_strdup(session->id);
-						g_signal_emit(media, purple_media_signals[CODECS_CHANGED], 0, session_id);
-						g_free(session_id);
-						g_list_free(sessions);
-						break;
-					}
-				}
 			}
 			break;
 		}
@@ -1362,6 +1355,13 @@
 	purple_debug_info("media", "candidate pair established\n");
 }
 
+static void
+purple_media_codecs_changed_cb(PurpleMediaBackend *backend,
+		const gchar *sess_id, PurpleMedia *media)
+{
+	g_signal_emit(media, purple_media_signals[CODECS_CHANGED], 0, sess_id);
+}
+
 static gboolean
 purple_media_connected_cb(PurpleMediaStream *stream)
 {