changeset 26097:84ea07648377

Add the id attribute to ice-udp according to the XEP.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Thu, 05 Feb 2009 09:36:23 +0000
parents ee3f63fbd071
children 4a245ffb4051
files libpurple/protocols/jabber/jingle/iceudp.c libpurple/protocols/jabber/jingle/iceudp.h libpurple/protocols/jabber/jingle/rtp.c
diffstat 3 files changed, 22 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jingle/iceudp.c	Thu Feb 05 08:52:52 2009 +0000
+++ b/libpurple/protocols/jabber/jingle/iceudp.c	Thu Feb 05 09:36:23 2009 +0000
@@ -57,6 +57,7 @@
 	new_candidate->component = candidate->component;
 	new_candidate->foundation = g_strdup(candidate->foundation);
 	new_candidate->generation = candidate->generation;
+	new_candidate->id = g_strdup(candidate->id);
 	new_candidate->ip = g_strdup(candidate->ip);
 	new_candidate->network = candidate->network;
 	new_candidate->port = candidate->port;
@@ -74,6 +75,7 @@
 jingle_iceudp_candidate_free(JingleIceUdpCandidate *candidate)
 {
 	g_free(candidate->foundation);
+	g_free(candidate->id);
 	g_free(candidate->ip);
 	g_free(candidate->protocol);
 	g_free(candidate->type);
@@ -97,14 +99,16 @@
 
 JingleIceUdpCandidate *
 jingle_iceudp_candidate_new(guint component, const gchar *foundation,
-		guint generation, const gchar *ip, guint network,
-		guint port, guint priority, const gchar *protocol,
-		const gchar *type, const gchar *username, const gchar *password)
+		guint generation, const gchar *id, const gchar *ip,
+		guint network, guint port, guint priority,
+		const gchar *protocol, const gchar *type,
+		const gchar *username, const gchar *password)
 {
 	JingleIceUdpCandidate *candidate = g_new0(JingleIceUdpCandidate, 1);
 	candidate->component = component;
 	candidate->foundation = g_strdup(foundation);
 	candidate->generation = generation;
+	candidate->id = g_strdup(id);
 	candidate->ip = g_strdup(ip);
 	candidate->network = network;
 	candidate->port = port;
@@ -233,8 +237,7 @@
 
 	for (; iter; iter = g_list_next(iter)) {
 		JingleIceUdpCandidate *c = iter->data;
-		if ((c->component == candidate->component) &&
-				!strcmp(c->foundation, candidate->foundation)) {
+		if (!strcmp(c->id, candidate->id)) {
 			guint generation = c->generation + 1;
 
 			g_boxed_free(JINGLE_TYPE_ICEUDP_CANDIDATE, c);
@@ -261,13 +264,12 @@
 
 static JingleIceUdpCandidate *
 jingle_iceudp_get_remote_candidate_by_id(JingleIceUdp *iceudp,
-		guint component, const gchar *foundation)
+		const gchar *id)
 {
 	GList *iter = iceudp->priv->remote_candidates;
 	for (; iter; iter = g_list_next(iter)) {
 		JingleIceUdpCandidate *candidate = iter->data;
-		if ((candidate->component == component) &&
-				!strcmp(candidate->foundation, foundation)) {
+		if (!strcmp(candidate->id, id)) {
 			return candidate;
 		}
 	}
@@ -280,7 +282,7 @@
 	JingleIceUdpPrivate *priv = JINGLE_ICEUDP_GET_PRIVATE(iceudp);
 	JingleIceUdpCandidate *iceudp_candidate =
 			jingle_iceudp_get_remote_candidate_by_id(iceudp,
-					candidate->component, candidate->foundation);
+					candidate->id);
 	if (iceudp_candidate != NULL) {
 		priv->remote_candidates = g_list_remove(
 				priv->remote_candidates, iceudp_candidate);
@@ -304,6 +306,7 @@
 				atoi(xmlnode_get_attrib(candidate, "component")),
 				xmlnode_get_attrib(candidate, "foundation"),
 				atoi(xmlnode_get_attrib(candidate, "generation")),
+				xmlnode_get_attrib(candidate, "id"),
 				xmlnode_get_attrib(candidate, "ip"),
 				atoi(xmlnode_get_attrib(candidate, "network")),
 				atoi(xmlnode_get_attrib(candidate, "port")),
@@ -347,6 +350,7 @@
 			xmlnode_set_attrib(xmltransport, "component", component);
 			xmlnode_set_attrib(xmltransport, "foundation", candidate->foundation);
 			xmlnode_set_attrib(xmltransport, "generation", generation);
+			xmlnode_set_attrib(xmltransport, "id", candidate->id);
 			xmlnode_set_attrib(xmltransport, "ip", candidate->ip);
 			xmlnode_set_attrib(xmltransport, "network", network);
 			xmlnode_set_attrib(xmltransport, "port", port);
--- a/libpurple/protocols/jabber/jingle/iceudp.h	Thu Feb 05 08:52:52 2009 +0000
+++ b/libpurple/protocols/jabber/jingle/iceudp.h	Thu Feb 05 09:36:23 2009 +0000
@@ -66,6 +66,7 @@
 	guint component;
 	gchar *foundation;
 	guint generation;
+	gchar *id;
 	gchar *ip;
 	guint network;
 	guint port;
@@ -91,9 +92,10 @@
 GType jingle_iceudp_get_type(void);
 
 JingleIceUdpCandidate *jingle_iceudp_candidate_new(guint component,
-		const gchar *foundation, guint generation, const gchar *ip,
-		guint network, guint port, guint priority, const gchar *protocol,
-		const gchar *type, const gchar *username, const gchar *password);
+		const gchar *foundation, guint generation, const gchar *id,
+		const gchar *ip, guint network, guint port, guint priority,
+		const gchar *protocol, const gchar *type,
+		const gchar *username, const gchar *password);
 void jingle_iceudp_add_local_candidate(JingleIceUdp *iceudp, JingleIceUdpCandidate *candidate);
 GList *jingle_iceudp_get_remote_candidates(JingleIceUdp *iceudp);
 
--- a/libpurple/protocols/jabber/jingle/rtp.c	Thu Feb 05 08:52:52 2009 +0000
+++ b/libpurple/protocols/jabber/jingle/rtp.c	Thu Feb 05 09:36:23 2009 +0000
@@ -207,8 +207,10 @@
 		JingleIceUdpCandidate *iceudp_candidate;
 		for (; candidates; candidates = g_list_next(candidates)) {
 			PurpleMediaCandidate *candidate = candidates->data;
+			gchar *id = jabber_get_next_id(
+					jingle_session_get_js(session));
 			iceudp_candidate = jingle_iceudp_candidate_new(candidate->component_id,
-					candidate->foundation, generation, candidate->ip,
+					candidate->foundation, generation, id, candidate->ip,
 					0, candidate->port, candidate->priority, "udp",
 					candidate->type == PURPLE_MEDIA_CANDIDATE_TYPE_HOST ? "host" :
 					candidate->type == PURPLE_MEDIA_CANDIDATE_TYPE_SRFLX ? "srflx" :
@@ -216,6 +218,7 @@
 					candidate->type == PURPLE_MEDIA_CANDIDATE_TYPE_RELAY ? "relay" : "",
 					candidate->username, candidate->password);
 			jingle_iceudp_add_local_candidate(JINGLE_ICEUDP(transport), iceudp_candidate);
+			g_free(id);
 		}
 		return transport;
 	} else {