changeset 23862:3ffe166a355e

Set the proper send codec in Farsight.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Wed, 23 Jul 2008 20:10:18 +0000
parents a1acca6ff789
children 4eae2d40f11b
files libpurple/media.c libpurple/media.h libpurple/protocols/jabber/jingle.c
diffstat 3 files changed, 35 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/media.c	Sat Jul 19 03:10:38 2008 +0000
+++ b/libpurple/media.c	Wed Jul 23 20:10:18 2008 +0000
@@ -1237,4 +1237,20 @@
 	return TRUE;
 }
 
+gboolean
+purple_media_set_send_codec(PurpleMedia *media, const gchar *sess_id, FsCodec *codec)
+{
+	PurpleMediaSession *session = purple_media_get_session(media, sess_id);
+	GError *err = NULL;
+
+	fs_session_set_send_codec(session->session, codec, &err);
+
+	if (err) {
+		purple_debug_error("media", "Error setting send codec\n");
+		g_error_free(err);
+		return FALSE;
+	}
+	return TRUE;
+}
+
 #endif  /* USE_VV */
--- a/libpurple/media.h	Sat Jul 19 03:10:38 2008 +0000
+++ b/libpurple/media.h	Wed Jul 23 20:10:18 2008 +0000
@@ -147,6 +147,8 @@
 
 gboolean purple_media_candidates_prepared(PurpleMedia *media, const gchar *name);
 
+gboolean purple_media_set_send_codec(PurpleMedia *media, const gchar *sess_id, FsCodec *codec);
+
 G_END_DECLS
 
 #endif  /* USE_VV */
--- a/libpurple/protocols/jabber/jingle.c	Sat Jul 19 03:10:38 2008 +0000
+++ b/libpurple/protocols/jabber/jingle.c	Wed Jul 23 20:10:18 2008 +0000
@@ -1196,6 +1196,10 @@
 
 			/* we have found a suitable codec, but we will not start the stream
 			   just yet, wait for transport negotiation to complete... */
+			purple_media_set_send_codec(
+					jabber_jingle_session_get_media(session),
+					xmlnode_get_attrib(content, "name"),
+					codec_intersection->data);
 		}
 		/* if we also got transport candidates, add them to our streams
 		   list of known remote candidates */
@@ -1288,6 +1292,8 @@
 
 	for (content = xmlnode_get_child(jingle, "content"); content;
 			content = xmlnode_get_next_twin(content)) {
+		GList *codec_intersection = NULL;
+
 		/* init media */
 		if (!content) {
 			purple_debug_error("jingle", "jingle tag must contain content tag\n");
@@ -1307,9 +1313,18 @@
 		purple_media_set_remote_codecs(session->media,
 					       xmlnode_get_attrib(content, "name"),
 					       initiator, codecs);
+
+		codec_intersection = purple_media_get_negotiated_codecs(session->media,
+				xmlnode_get_attrib(content, "name"));
 		purple_debug_info("jingle", "codec intersection: %i\n",
-				g_list_length(purple_media_get_negotiated_codecs(session->media,
-				xmlnode_get_attrib(content, "name"))));
+				g_list_length(codec_intersection));
+
+		if (g_list_length(codec_intersection) > 0) {
+			purple_media_set_send_codec(
+					jabber_jingle_session_get_media(session),
+					xmlnode_get_attrib(content, "name"),
+					codec_intersection->data);
+		}
 	}
 	jabber_iq_send(jabber_jingle_session_create_ack(session, jingle));
 	jabber_iq_send(jabber_jingle_session_create_session_info(session, "ringing"));