changeset 26046:99055b8db16b

Choose the transport type according to the responder's caps.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Sat, 06 Dec 2008 02:20:09 +0000
parents a62d10cce27a
children 1ce297c8923b 25e2ab1fff1d
files libpurple/protocols/jabber/jabber.c libpurple/protocols/jabber/jingle/rtp.c
diffstat 2 files changed, 22 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jabber.c	Tue Nov 25 02:59:47 2008 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Sat Dec 06 02:20:09 2008 +0000
@@ -2431,6 +2431,15 @@
 		purple_debug_error("jabber", "Could not find buddy\n");
 		return FALSE;
 	}
+
+	if (!jabber_buddy_has_capability(jb, JINGLE_TRANSPORT_ICEUDP) &&
+			!jabber_buddy_has_capability(jb,
+			JINGLE_TRANSPORT_RAWUDP)) {
+		purple_debug_error("jingle-rtp", "Buddy doesn't support "
+				"the same transport types\n");
+		return FALSE;
+	}
+
 	/* XMPP will only support two-way media, AFAIK... */
 	if (type == (PURPLE_MEDIA_AUDIO | PURPLE_MEDIA_VIDEO)) {
 		purple_debug_info("jabber", 
--- a/libpurple/protocols/jabber/jingle/rtp.c	Tue Nov 25 02:59:47 2008 +0000
+++ b/libpurple/protocols/jabber/jingle/rtp.c	Sat Dec 06 02:20:09 2008 +0000
@@ -666,6 +666,7 @@
 	JabberBuddy *jb;
 	JabberBuddyResource *jbr;
 	PurpleMedia *media;
+	const gchar *transport_type;
 	
 	gchar *jid = NULL, *me = NULL, *sid = NULL;
 
@@ -680,6 +681,16 @@
 		purple_debug_error("jingle-rtp", "Could not find buddy's resource\n");
 	}
 
+	if (jabber_resource_has_capability(jbr, JINGLE_TRANSPORT_ICEUDP)) {
+		transport_type = JINGLE_TRANSPORT_ICEUDP;
+	} else if (jabber_resource_has_capability(jbr, JINGLE_TRANSPORT_RAWUDP)) {
+		transport_type = JINGLE_TRANSPORT_RAWUDP;
+	} else {
+		purple_debug_error("jingle-rtp", "Resource doesn't support "
+				"the same transport types\n");
+		return NULL;
+	}
+
 	if ((strchr(who, '/') == NULL) && jbr && (jbr->name != NULL)) {
 		jid = g_strdup_printf("%s/%s", who, jbr->name);
 	} else {
@@ -695,7 +706,7 @@
 
 
 	if (type & PURPLE_MEDIA_AUDIO) {
-		transport = jingle_transport_create(JINGLE_TRANSPORT_ICEUDP);
+		transport = jingle_transport_create(transport_type);
 		content = jingle_content_create(JINGLE_APP_RTP, "initiator",
 				"session", "audio-session", "both", transport);
 		jingle_session_add_content(session, content);
@@ -703,7 +714,7 @@
 		jingle_rtp_init_media(content);
 	}
 	if (type & PURPLE_MEDIA_VIDEO) {
-		transport = jingle_transport_create(JINGLE_TRANSPORT_ICEUDP);
+		transport = jingle_transport_create(transport_type);
 		content = jingle_content_create(JINGLE_APP_RTP, "initiator",
 				"session", "video-session", "both", transport);
 		jingle_session_add_content(session, content);