pidgin.vv: 27ee907e: Update Jingle Ice-Udp according to the X...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Tue Mar 17 08:10:40 EDT 2009


-----------------------------------------------------------------
Revision: 27ee907e5f16134f707e1df5b8f10098285b9241
Ancestor: b7579b4bc8103a92e947c945e22390d9e547cc65
Author: maiku at soc.pidgin.im
Date: 2009-03-17T11:57:22
Branch: im.pidgin.pidgin.vv
URL: http://d.pidgin.im/viewmtn/revision/info/27ee907e5f16134f707e1df5b8f10098285b9241

Modified files:
        libpurple/protocols/jabber/jingle/iceudp.c
        libpurple/protocols/jabber/jingle/jingle.h
        libpurple/protocols/jabber/jingle/rtp.c

ChangeLog: 

Update Jingle Ice-Udp according to the XEP.
This mainly includes sending and receiving candidates in 
session-initiate and session-accept packets. It also includes a few 
memory leak fixes.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jingle/iceudp.c	b3926f714def77ee4879e676e5885f6ccd95320f
+++ libpurple/protocols/jabber/jingle/iceudp.c	dc94d05ea55e9125dd86c56b86bcf81f1aa3b7c0
@@ -332,22 +332,20 @@ jingle_iceudp_to_xml_internal(JingleTran
 {
 	xmlnode *node = parent_class->to_xml(transport, content, action);
 
-	if (action == JINGLE_SESSION_INITIATE || action == JINGLE_TRANSPORT_INFO ||
-			action == JINGLE_CONTENT_ADD || action == JINGLE_TRANSPORT_REPLACE) {
-		JingleIceUdpPrivate *icetransport =
-				JINGLE_ICEUDP_GET_PRIVATE(transport);
-		if (icetransport && icetransport->local_candidates) {
-			JingleIceUdpCandidate *candidate =
-					icetransport->local_candidates->data;
+	if (action == JINGLE_SESSION_INITIATE ||
+			action == JINGLE_SESSION_ACCEPT ||
+			action == JINGLE_TRANSPORT_INFO ||
+			action == JINGLE_CONTENT_ADD ||
+			action == JINGLE_TRANSPORT_REPLACE) {
+		JingleIceUdpPrivate *priv = JINGLE_ICEUDP_GET_PRIVATE(transport);
+		GList *iter = priv->local_candidates;
+
+		if (iter && iter->data) {
+			JingleIceUdpCandidate *candidate = iter->data;
 			xmlnode_set_attrib(node, "pwd", candidate->password);
 			xmlnode_set_attrib(node, "ufrag", candidate->username);
 		}
-	}
 
-	if (action == JINGLE_TRANSPORT_INFO || action == JINGLE_SESSION_ACCEPT) {
-		JingleIceUdpPrivate *priv = JINGLE_ICEUDP_GET_PRIVATE(transport);
-		GList *iter = priv->local_candidates;
-
 		for (; iter; iter = g_list_next(iter)) {
 			JingleIceUdpCandidate *candidate = iter->data;
 
============================================================
--- libpurple/protocols/jabber/jingle/jingle.h	e52f8275df4cb5394acdb0a469a7878de152bb70
+++ libpurple/protocols/jabber/jingle/jingle.h	08a0b73b64cecc07b99a2e12454a8bc658d2e757
@@ -42,7 +42,7 @@ extern "C" {
 #define JINGLE_DTMF "urn:xmpp:jingle:dtmf:0"
 #define JINGLE_TRANSPORT_S5B "urn:xmpp:jingle:transports:s5b:0"
 #define JINGLE_TRANSPORT_IBB "urn:xmpp:jingle:transports:ibb:0"
-#define JINGLE_TRANSPORT_ICEUDP "urn:xmpp:jingle:transports:ice-udp:0"
+#define JINGLE_TRANSPORT_ICEUDP "urn:xmpp:jingle:transports:ice-udp:1"
 #define JINGLE_TRANSPORT_RAWUDP "urn:xmpp:jingle:transports:raw-udp:1"
 
 typedef enum {
============================================================
--- libpurple/protocols/jabber/jingle/rtp.c	3716601e56d154c708f0abc247cfc317b987e1c9
+++ libpurple/protocols/jabber/jingle/rtp.c	83221e9abd29bff12665fe8dc8917623d76a4e3c
@@ -343,9 +343,6 @@ jingle_rtp_initiate_ack_cb(JabberStream 
 		g_object_unref(session);
 		return;
 	}
-
-	jabber_iq_send(jingle_session_to_packet(session,
-			JINGLE_TRANSPORT_INFO));
 }
 
 static void
@@ -355,21 +352,12 @@ jingle_rtp_ready_cb(PurpleMedia *media, 
 
 	if (sid == NULL && name == NULL) {
 		if (jingle_session_is_initiator(session) == TRUE) {
-			GList *contents = jingle_session_get_contents(session);
 			JabberIq *iq = jingle_session_to_packet(
 					session, JINGLE_SESSION_INITIATE);
-
-			if (contents->data) {
-				JingleTransport *transport =
-						jingle_content_get_transport(contents->data);
-				if (JINGLE_IS_ICEUDP(transport))
-					jabber_iq_set_callback(iq,
-							jingle_rtp_initiate_ack_cb, session);
-			}
-
+			jabber_iq_set_callback(iq,
+					jingle_rtp_initiate_ack_cb, session);
 			jabber_iq_send(iq);
 		} else {
-			jabber_iq_send(jingle_session_to_packet(session, JINGLE_TRANSPORT_INFO));
 			jabber_iq_send(jingle_session_to_packet(session, JINGLE_SESSION_ACCEPT));
 		}
 	} else if (sid != NULL && name != NULL) {
@@ -621,23 +609,7 @@ jingle_rtp_handle_action_internal(Jingle
 jingle_rtp_handle_action_internal(JingleContent *content, xmlnode *xmlcontent, JingleActionType action)
 {
 	switch (action) {
-		case JINGLE_SESSION_ACCEPT: {
-			JingleSession *session = jingle_content_get_session(content);
-			xmlnode *description = xmlnode_get_child(xmlcontent, "description");
-			GList *codecs = jingle_rtp_parse_codecs(description);
-
-			purple_media_set_remote_codecs(jingle_rtp_get_media(session),
-					jingle_content_get_name(content),
-					jingle_session_get_remote_jid(session), codecs);
-
-			/* This needs to be for the entire session, not a single content */
-			/* very hacky */
-			if (xmlnode_get_next_twin(xmlcontent) == NULL)
-				purple_media_accept(jingle_rtp_get_media(session));
-
-			g_object_unref(session);
-			break;
-		}
+		case JINGLE_SESSION_ACCEPT:
 		case JINGLE_SESSION_INITIATE: {
 			JingleSession *session = jingle_content_get_session(content);
 			JingleTransport *transport = jingle_transport_parse(
@@ -645,8 +617,13 @@ jingle_rtp_handle_action_internal(Jingle
 			xmlnode *description = xmlnode_get_child(xmlcontent, "description");
 			GList *candidates = jingle_rtp_transport_to_candidates(transport);
 			GList *codecs = jingle_rtp_parse_codecs(description);
+			gchar *name = jingle_content_get_name(content);
+			gchar *remote_jid =
+					jingle_session_get_remote_jid(session);
+			PurpleMedia *media;
 
-			if (jingle_rtp_init_media(content) == FALSE) {
+			if (action == JINGLE_SESSION_INITIATE &&
+					jingle_rtp_init_media(content) == FALSE) {
 				/* XXX: send error */
 				jabber_iq_send(jingle_session_terminate_packet(
 						session, "general-error"));
@@ -654,17 +631,20 @@ jingle_rtp_handle_action_internal(Jingle
 				break;
 			}
 
-			purple_media_set_remote_codecs(jingle_rtp_get_media(session),
-					jingle_content_get_name(content),
-					jingle_session_get_remote_jid(session), codecs);
+			media = jingle_rtp_get_media(session);
+			purple_media_set_remote_codecs(media,
+					name, remote_jid, codecs);
+			purple_media_add_remote_candidates(media,
+					name, remote_jid, candidates);
 
-			if (JINGLE_IS_RAWUDP(transport)) {
-				purple_media_add_remote_candidates(jingle_rtp_get_media(session),
-						jingle_content_get_name(content),
-						jingle_session_get_remote_jid(session),
-						candidates);
-			}
+			/* This needs to be for the entire session, not a single content */
+			/* very hacky */
+			if (action == JINGLE_SESSION_ACCEPT &&
+					xmlnode_get_next_twin(xmlcontent) == NULL)
+				purple_media_accept(media);
 
+			g_free(remote_jid);
+			g_free(name);
 			g_object_unref(session);
 			break;
 		}
@@ -684,11 +664,16 @@ jingle_rtp_handle_action_internal(Jingle
 			JingleTransport *transport = jingle_transport_parse(
 					xmlnode_get_child(xmlcontent, "transport"));
 			GList *candidates = jingle_rtp_transport_to_candidates(transport);
+			gchar *name = jingle_content_get_name(content);
+			gchar *remote_jid =
+					jingle_session_get_remote_jid(session);
 
-			purple_media_add_remote_candidates(jingle_rtp_get_media(session),
-					jingle_content_get_name(content),
-					jingle_session_get_remote_jid(session),
-					candidates);
+			purple_media_add_remote_candidates(
+					jingle_rtp_get_media(session),
+					name, remote_jid, candidates);
+
+			g_free(remote_jid);
+			g_free(name);
 			g_object_unref(session);
 			break;
 		}


More information about the Commits mailing list