changeset 29173:983af0970bb2

Transfer setting Farsight 2's remote candidates to the Fs2 media backend.
author maiku@pidgin.im
date Mon, 26 Oct 2009 22:14:25 +0000
parents f600903f7811
children d9d0674dfbb3
files libpurple/media/backend-fs2.c libpurple/media/media.c
diffstat 2 files changed, 51 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/media/backend-fs2.c	Mon Oct 26 21:35:11 2009 +0000
+++ b/libpurple/media/backend-fs2.c	Mon Oct 26 22:14:25 2009 +0000
@@ -381,9 +381,10 @@
 	}
 	return result;
 }
+#endif
 
 static FsCandidate *
-purple_media_candidate_to_fs(PurpleMediaCandidate *candidate)
+_candidate_to_fs(PurpleMediaCandidate *candidate)
 {
 	FsCandidate *fscandidate;
 	gchar *foundation;
@@ -432,7 +433,20 @@
 	g_free(ip);
 	return fscandidate;
 }
-#endif
+
+static GList *
+_candidate_list_to_fs(GList *candidates)
+{
+	GList *new_list = NULL;
+
+	for (; candidates; candidates = g_list_next(candidates)) {
+		new_list = g_list_prepend(new_list,
+				_candidate_to_fs(candidates->data));
+	}
+
+	new_list = g_list_reverse(new_list);
+	return new_list;
+}
 
 static PurpleMediaCandidate *
 purple_media_candidate_from_fs(FsCandidate *fscandidate)
@@ -1232,6 +1246,38 @@
 		const gchar *sess_id, const gchar *participant,
 		GList *remote_candidates)
 {
+	PurpleMediaBackendFs2Private *priv;
+	PurpleMediaBackendFs2Stream *stream;
+	GError *err = NULL;
+
+	g_return_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(self));
+
+	priv = PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+	stream = _get_stream(PURPLE_MEDIA_BACKEND_FS2(self),
+			sess_id, participant);
+
+	if (stream == NULL) {
+		purple_debug_error("backend-fs2",
+				"purple_media_add_remote_candidates: "
+				"couldn't find stream %s %s.\n",
+				sess_id ? sess_id : "(null)",
+				participant ? participant : "(null)");
+		return;
+	}
+
+	stream->remote_candidates = g_list_concat(stream->remote_candidates,
+			_candidate_list_to_fs(remote_candidates));
+
+	if (purple_media_accepted(priv->media, sess_id, participant)) {
+		fs_stream_set_remote_candidates(stream->stream,
+				stream->remote_candidates, &err);
+
+		if (err) {
+			purple_debug_error("backend-fs2", "Error adding remote"
+					" candidates: %s\n", err->message);
+			g_error_free(err);
+		}
+	}
 }
 
 static GList *
--- a/libpurple/media/media.c	Mon Oct 26 21:35:11 2009 +0000
+++ b/libpurple/media/media.c	Mon Oct 26 22:14:25 2009 +0000
@@ -1531,7 +1531,6 @@
 {
 #ifdef USE_VV
 	PurpleMediaStream *stream;
-	GError *err = NULL;
 
 	g_return_if_fail(PURPLE_IS_MEDIA(media));
 	stream = purple_media_get_stream(media, sess_id, participant);
@@ -1549,17 +1548,9 @@
 			purple_media_candidate_list_copy(remote_candidates));
 
 	if (stream->accepted == TRUE) {
-		GList *candidates = purple_media_candidate_list_to_fs(
-				stream->remote_candidates);
-		fs_stream_set_remote_candidates(stream->stream,
-				candidates, &err);
-		fs_candidate_list_destroy(candidates);
-
-		if (err) {
-			purple_debug_error("media", "Error adding remote"
-					" candidates: %s\n", err->message);
-			g_error_free(err);
-		}
+		purple_media_backend_add_remote_candidates(
+				media->priv->backend, sess_id, participant,
+				remote_candidates);
 	}
 #endif
 }