cpw.maiku.media_refactor: e304d357: Move set_remote_codecs functionality to ...

maiku at pidgin.im maiku at pidgin.im
Mon Oct 26 22:46:24 EDT 2009


-----------------------------------------------------------------
Revision: e304d357a545ca3ba7cd478718a20339d59aa81d
Ancestor: c2b8b126ffcbdd61c424e9ae7c4699b9584846b4
Author: maiku at pidgin.im
Date: 2009-10-26T23:10:53
Branch: im.pidgin.cpw.maiku.media_refactor
URL: http://d.pidgin.im/viewmtn/revision/info/e304d357a545ca3ba7cd478718a20339d59aa81d

Modified files:
        libpurple/media/backend-fs2.c libpurple/media/media.c

ChangeLog: 

Move set_remote_codecs functionality to the Fs2 media backend.

-------------- next part --------------
============================================================
--- libpurple/media/backend-fs2.c	d1ba4749187bf014825776e6b2a156bfb22ce7f5
+++ libpurple/media/backend-fs2.c	7c7b9a553cbef719dac6eabb0616740b1d1faa5c
@@ -481,7 +481,6 @@ _candidate_list_from_fs(GList *candidate
 	return new_list;
 }
 
-#if 0
 static FsCodec *
 _codec_to_fs(const PurpleMediaCodec *codec)
 {
@@ -519,7 +518,6 @@ _codec_to_fs(const PurpleMediaCodec *cod
 	g_free(encoding_name);
 	return new_codec;
 }
-#endif
 
 static PurpleMediaCodec *
 _codec_from_fs(const FsCodec *codec)
@@ -558,7 +556,6 @@ _codec_list_from_fs(GList *codecs)
 	return new_list;
 }
 
-#if 0
 static GList *
 _codec_list_to_fs(GList *codecs)
 {
@@ -572,7 +569,6 @@ _codec_list_to_fs(GList *codecs)
 	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 @@ purple_media_backend_fs2_set_remote_code
 		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
============================================================
--- libpurple/media/media.c	d3dd1422e736937fabd525adcc3f183d9b40e0d6
+++ libpurple/media/media.c	508fe8bec94834129043754fda14bd7a827d0a71
@@ -658,59 +658,6 @@ purple_media_codec_to_fs(const PurpleMed
 	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 @@ purple_media_set_remote_codecs(PurpleMed
                                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


More information about the Commits mailing list