Mercurial > pidgin.yaz
changeset 26369:26cf297796a5
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.
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Tue, 17 Mar 2009 11:57:22 +0000 |
parents | d8a7c7d9ac8a |
children | c8d8624efd04 |
files | libpurple/protocols/jabber/jingle/iceudp.c libpurple/protocols/jabber/jingle/jingle.h libpurple/protocols/jabber/jingle/rtp.c |
diffstat | 3 files changed, 41 insertions(+), 58 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jingle/iceudp.c Tue Mar 17 10:13:10 2009 +0000 +++ b/libpurple/protocols/jabber/jingle/iceudp.c Tue Mar 17 11:57:22 2009 +0000 @@ -332,21 +332,19 @@ { 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;
--- a/libpurple/protocols/jabber/jingle/jingle.h Tue Mar 17 10:13:10 2009 +0000 +++ b/libpurple/protocols/jabber/jingle/jingle.h Tue Mar 17 11:57:22 2009 +0000 @@ -42,7 +42,7 @@ #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 {
--- a/libpurple/protocols/jabber/jingle/rtp.c Tue Mar 17 10:13:10 2009 +0000 +++ b/libpurple/protocols/jabber/jingle/rtp.c Tue Mar 17 11:57:22 2009 +0000 @@ -343,9 +343,6 @@ g_object_unref(session); return; } - - jabber_iq_send(jingle_session_to_packet(session, - JINGLE_TRANSPORT_INFO)); } static void @@ -355,21 +352,12 @@ 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(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 @@ 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 @@ 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 @@ 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; }