cpw.maiku.media_refactor: 78c5d416: Transfer get_codecs functionality to the...

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


-----------------------------------------------------------------
Revision: 78c5d416a5b35570258403f735d346a29f76c79d
Ancestor: bc18fbb50a41c0ae343bb691ad04912982770f70
Author: maiku at pidgin.im
Date: 2009-10-26T22:26:51
Branch: im.pidgin.cpw.maiku.media_refactor
URL: http://d.pidgin.im/viewmtn/revision/info/78c5d416a5b35570258403f735d346a29f76c79d

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

ChangeLog: 

Transfer get_codecs functionality to the Fs2 media backend.

-------------- next part --------------
============================================================
--- libpurple/media/backend-fs2.c	81746e66610263ca39fa09f465ba5c21ddf7463b
+++ libpurple/media/backend-fs2.c	d8edd69e0e3f064e4da5f627e855432b07af3326
@@ -363,7 +363,6 @@ _session_type_to_fs_stream_direction(Pur
 		return FS_DIRECTION_NONE;
 }
 
-#if 0
 static PurpleMediaSessionType
 _session_type_from_fs(FsMediaType type, FsStreamDirection direction)
 {
@@ -381,7 +380,6 @@ _session_type_from_fs(FsMediaType type, 
 	}
 	return result;
 }
-#endif
 
 static FsCandidate *
 _candidate_to_fs(PurpleMediaCandidate *candidate)
@@ -469,6 +467,99 @@ purple_media_candidate_from_fs(FsCandida
 	return candidate;
 }
 
+#if 0
+static FsCodec *
+_codec_to_fs(const PurpleMediaCodec *codec)
+{
+	FsCodec *new_codec;
+	gint id;
+	char *encoding_name;
+	PurpleMediaSessionType media_type;
+	guint clock_rate;
+	guint channels;
+	GList *iter;
+
+	if (codec == NULL)
+		return NULL;
+
+	g_object_get(G_OBJECT(codec),
+			"id", &id,
+			"encoding-name", &encoding_name,
+			"media-type", &media_type,
+			"clock-rate", &clock_rate,
+			"channels", &channels,
+			"optional-params", &iter,
+			NULL);
+
+	new_codec = fs_codec_new(id, encoding_name,
+			_session_type_to_fs_media_type(media_type),
+			clock_rate);
+	new_codec->channels = channels;
+
+	for (; iter; iter = g_list_next(iter)) {
+		PurpleKeyValuePair *param = (PurpleKeyValuePair*)iter->data;
+		fs_codec_add_optional_parameter(new_codec,
+				param->key, param->value);
+	}
+
+	g_free(encoding_name);
+	return new_codec;
+}
+#endif
+
+static PurpleMediaCodec *
+_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,
+			_session_type_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 *
+_codec_list_from_fs(GList *codecs)
+{
+	GList *new_list = NULL;
+
+	for (; codecs; codecs = g_list_next(codecs)) {
+		new_list = g_list_prepend(new_list,
+				_codec_from_fs(codecs->data));
+	}
+
+	new_list = g_list_reverse(new_list);
+	return new_list;
+}
+
+#if 0
+static GList *
+_codec_list_to_fs(GList *codecs)
+{
+	GList *new_list = NULL;
+
+	for (; codecs; codecs = g_list_next(codecs)) {
+		new_list = g_list_prepend(new_list,
+				_codec_to_fs(codecs->data));
+	}
+
+	new_list = g_list_reverse(new_list);
+	return new_list;
+}
+#endif
+
 static PurpleMediaBackendFs2Session *
 _get_session(PurpleMediaBackendFs2 *self, const gchar *sess_id)
 {
@@ -1284,7 +1375,26 @@ purple_media_backend_fs2_get_codecs(Purp
 purple_media_backend_fs2_get_codecs(PurpleMediaBackend *self,
 		const gchar *sess_id)
 {
-	return NULL;
+	PurpleMediaBackendFs2Private *priv;
+	PurpleMediaBackendFs2Session *session;
+	GList *fscodecs;
+	GList *codecs;
+
+	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(self), NULL);
+
+	priv = PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+
+	session = _get_session(PURPLE_MEDIA_BACKEND_FS2(self), sess_id);
+
+	if (session == NULL)
+		return NULL;
+
+	g_object_get(G_OBJECT(session->session),
+		     "codecs", &fscodecs, NULL);
+	codecs = _codec_list_from_fs(fscodecs);
+	fs_codec_list_destroy(fscodecs);
+
+	return codecs;
 }
 
 static GList *
============================================================
--- libpurple/media/media.c	c9319cfbbb9400de043a3b78cff06063ac9d821b
+++ libpurple/media/media.c	e057db519e0242489955c573b8a46dbf80037c5f
@@ -1490,22 +1490,9 @@ purple_media_get_codecs(PurpleMedia *med
 purple_media_get_codecs(PurpleMedia *media, const gchar *sess_id)
 {
 #ifdef USE_VV
-	GList *fscodecs;
-	GList *codecs;
-	PurpleMediaSession *session;
-
 	g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
 
-	session = purple_media_get_session(media, sess_id);
-
-	if (session == NULL)
-		return NULL;
-
-	g_object_get(G_OBJECT(session->session),
-		     "codecs", &fscodecs, NULL);
-	codecs = purple_media_codec_list_from_fs(fscodecs);
-	fs_codec_list_destroy(fscodecs);
-	return codecs;
+	return purple_media_backend_get_codecs(media->priv->backend, sess_id);
 #else
 	return NULL;
 #endif


More information about the Commits mailing list