changeset 29571:f0966e90ec44

Move get_local_candidates functionality over to the Fs2 media backend.
author maiku@pidgin.im
date Mon, 26 Oct 2009 22:50:23 +0000
parents cc0d1fbe9c71
children a7cad99144f0
files libpurple/media/backend-fs2.c libpurple/media/media.c
diffstat 2 files changed, 33 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/media/backend-fs2.c	Mon Oct 26 22:30:05 2009 +0000
+++ b/libpurple/media/backend-fs2.c	Mon Oct 26 22:50:23 2009 +0000
@@ -467,6 +467,20 @@
 	return candidate;
 }
 
+static GList *
+_candidate_list_from_fs(GList *candidates)
+{
+	GList *new_list = NULL;
+
+	for (; candidates; candidates = g_list_next(candidates)) {
+		new_list = g_list_prepend(new_list,
+			_candidate_from_fs(candidates->data));
+	}
+
+	new_list = g_list_reverse(new_list);
+	return new_list;
+}
+
 #if 0
 static FsCodec *
 _codec_to_fs(const PurpleMediaCodec *codec)
@@ -705,6 +719,7 @@
 		PurpleMediaCandidate *candidate;
 		FsParticipant *participant;
 		PurpleMediaBackendFs2Session *session;
+		PurpleMediaBackendFs2Stream *media_stream;
 		gchar *name;
 
 		value = gst_structure_get_value(msg->structure, "stream");
@@ -722,10 +737,10 @@
 		g_object_get(participant, "cname", &name, NULL);
 		g_object_unref(participant);
 
-#if 0
-		purple_media_insert_local_candidate(session, name,
+		media_stream = _get_stream(self, session->id, name);
+		media_stream->local_candidates = g_list_append(
+				media_stream->local_candidates,
 				fs_candidate_copy(local_candidate));
-#endif
 
 		candidate = _candidate_from_fs(local_candidate);
 		g_signal_emit_by_name(self, "new-candidate",
@@ -1401,7 +1416,18 @@
 purple_media_backend_fs2_get_local_candidates(PurpleMediaBackend *self,
 		const gchar *sess_id, const gchar *participant)
 {
-	return NULL;
+	PurpleMediaBackendFs2Stream *stream;
+	GList *candidates = NULL;
+
+	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(self), NULL);
+
+	stream = _get_stream(PURPLE_MEDIA_BACKEND_FS2(self),
+			sess_id, participant);
+
+	if (stream != NULL)
+		candidates = _candidate_list_from_fs(
+				stream->local_candidates);
+	return candidates;
 }
 
 static void
--- a/libpurple/media/media.c	Mon Oct 26 22:30:05 2009 +0000
+++ b/libpurple/media/media.c	Mon Oct 26 22:50:23 2009 +0000
@@ -1503,11 +1503,10 @@
                                   const gchar *participant)
 {
 #ifdef USE_VV
-	PurpleMediaStream *stream;
 	g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
-	stream = purple_media_get_stream(media, sess_id, participant);
-	return stream ? purple_media_candidate_list_copy(
-			stream->local_candidates) : NULL;
+
+	return purple_media_backend_get_local_candidates(media->priv->backend,
+			sess_id, participant);
 #else
 	return NULL;
 #endif