changeset 29573:a39696686dd6

Move set_remote_codecs functionality to the Fs2 media backend.
author maiku@pidgin.im
date Mon, 26 Oct 2009 23:10:53 +0000
parents a7cad99144f0
children 90c48f1e479a
files libpurple/media/backend-fs2.c libpurple/media/media.c
diffstat 2 files changed, 26 insertions(+), 79 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/media/backend-fs2.c	Mon Oct 26 22:59:13 2009 +0000
+++ b/libpurple/media/backend-fs2.c	Mon Oct 26 23:10:53 2009 +0000
@@ -481,7 +481,6 @@
 	return new_list;
 }
 
-#if 0
 static FsCodec *
 _codec_to_fs(const PurpleMediaCodec *codec)
 {
@@ -519,7 +518,6 @@
 	g_free(encoding_name);
 	return new_codec;
 }
-#endif
 
 static PurpleMediaCodec *
 _codec_from_fs(const FsCodec *codec)
@@ -558,7 +556,6 @@
 	return new_list;
 }
 
-#if 0
 static GList *
 _codec_list_to_fs(GList *codecs)
 {
@@ -572,7 +569,6 @@
 	new_list = g_list_reverse(new_list);
 	return new_list;
 }
-#endif
 
 static PurpleMediaBackendFs2Session *
 _get_session(PurpleMediaBackendFs2 *self, const gchar *sess_id)
@@ -1435,7 +1431,30 @@
 		const gchar *sess_id, const gchar *participant,
 		GList *codecs)
 {
-	return FALSE;
+	PurpleMediaBackendFs2Stream *stream;
+	GList *fscodecs;
+	GError *err = NULL;
+
+	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(self), FALSE);
+	stream = _get_stream(PURPLE_MEDIA_BACKEND_FS2(self),
+			sess_id, participant);
+
+	if (stream == NULL)
+		return FALSE;
+
+	fscodecs = _codec_list_to_fs(codecs);
+	fs_stream_set_remote_codecs(stream->stream, fscodecs, &err);
+	fs_codec_list_destroy(fscodecs);
+
+	if (err) {
+		purple_debug_error("backend-fs2",
+				"Error setting remote codecs: %s\n",
+				err->message);
+		g_error_free(err);
+		return FALSE;
+	}
+
+	return TRUE;
 }
 
 static void
--- a/libpurple/media/media.c	Mon Oct 26 22:59:13 2009 +0000
+++ b/libpurple/media/media.c	Mon Oct 26 23:10:53 2009 +0000
@@ -658,59 +658,6 @@
 	return new_codec;
 }
 
-static PurpleMediaCodec *
-purple_media_codec_from_fs(const FsCodec *codec)
-{
-	PurpleMediaCodec *new_codec;
-	GList *iter;
-
-	if (codec == NULL)
-		return NULL;
-
-	new_codec = purple_media_codec_new(codec->id, codec->encoding_name,
-			purple_media_from_fs(codec->media_type,
-			FS_DIRECTION_BOTH), codec->clock_rate);
-	g_object_set(new_codec, "channels", codec->channels, NULL);
-
-	for (iter = codec->optional_params; iter; iter = g_list_next(iter)) {
-		FsCodecParameter *param = (FsCodecParameter*)iter->data;
-		purple_media_codec_add_optional_parameter(new_codec,
-				param->name, param->value);
-	}
-
-	return new_codec;
-}
-
-static GList *
-purple_media_codec_list_from_fs(GList *codecs)
-{
-	GList *new_list = NULL;
-
-	for (; codecs; codecs = g_list_next(codecs)) {
-		new_list = g_list_prepend(new_list,
-				purple_media_codec_from_fs(
-				codecs->data));
-	}
-
-	new_list = g_list_reverse(new_list);
-	return new_list;
-}
-
-static GList *
-purple_media_codec_list_to_fs(GList *codecs)
-{
-	GList *new_list = NULL;
-
-	for (; codecs; codecs = g_list_next(codecs)) {
-		new_list = g_list_prepend(new_list,
-				purple_media_codec_to_fs(
-				codecs->data));
-	}
-
-	new_list = g_list_reverse(new_list);
-	return new_list;
-}
-
 static PurpleMediaSession*
 purple_media_get_session(PurpleMedia *media, const gchar *sess_id)
 {
@@ -1585,29 +1532,10 @@
                                const gchar *participant, GList *codecs)
 {
 #ifdef USE_VV
-	PurpleMediaStream *stream;
-	FsStream *fsstream;
-	GList *fscodecs;
-	GError *err = NULL;
-
 	g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
-	stream = purple_media_get_stream(media, sess_id, participant);
-
-	if (stream == NULL)
-		return FALSE;
 
-	fsstream = stream->stream;
-	fscodecs = purple_media_codec_list_to_fs(codecs);
-	fs_stream_set_remote_codecs(fsstream, fscodecs, &err);
-	fs_codec_list_destroy(fscodecs);
-
-	if (err) {
-		purple_debug_error("media", "Error setting remote codecs: %s\n",
-				   err->message);
-		g_error_free(err);
-		return FALSE;
-	}
-	return TRUE;
+	return purple_media_backend_set_remote_codecs(media->priv->backend,
+			sess_id, participant, codecs);
 #else
 	return FALSE;
 #endif