pidgin.vv: bce76151: Move sending session-initiate out of the...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Fri Mar 20 04:35:56 EDT 2009


-----------------------------------------------------------------
Revision: bce7615109967972375e76c0c9c0cd0e70f057e6
Ancestor: 0e2f31c8d0c187e9c1500e9823f23cdfc7e46543
Author: maiku at soc.pidgin.im
Date: 2009-03-19T23:03:43
Branch: im.pidgin.pidgin.vv
URL: http://d.pidgin.im/viewmtn/revision/info/bce7615109967972375e76c0c9c0cd0e70f057e6

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

ChangeLog: 

Move sending session-initiate out of the ready-new callback.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jingle/rtp.c	bae885e61e85dcc7174d0c9d943bf2fe853d8eaf
+++ libpurple/protocols/jabber/jingle/rtp.c	ae79c119162f552b36b1871b0085b712783e5623
@@ -335,6 +335,8 @@ jingle_rtp_transport_to_candidates(Jingl
 	}
 }
 
+static void jingle_rtp_send_initiate(JingleSession *session);
+
 static void
 jingle_rtp_accepted_cb(PurpleMedia *media, gchar *sid, gchar *name,
 		JingleSession *session)
@@ -372,6 +374,8 @@ jingle_rtp_candidates_prepared_cb(Purple
 
 	jingle_content_set_pending_transport(content, transport);
 	jingle_content_accept_transport(content);
+
+	jingle_rtp_send_initiate(session);
 }
 
 static void
@@ -380,6 +384,7 @@ jingle_rtp_codecs_changed_cb(PurpleMedia
 {
 	purple_debug_info("jingle-rtp", "jingle_rtp_codecs_changed_cb: "
 			"session_id: %s jingle_session: %p\n", sid, session);
+	jingle_rtp_send_initiate(session);
 }
 
 static void
@@ -434,15 +439,7 @@ jingle_rtp_ready_cb(PurpleMedia *media, 
 	purple_debug_info("rtp", "ready-new: session: %s name: %s\n", sid, name);
 
 	if (sid == NULL && name == NULL) {
-		if (jingle_session_is_initiator(session) == TRUE) {
-			JabberIq *iq = jingle_session_to_packet(
-					session, JINGLE_SESSION_INITIATE);
-			jabber_iq_set_callback(iq,
-					jingle_rtp_initiate_ack_cb, session);
-			jabber_iq_send(iq);
-			g_signal_connect(G_OBJECT(media), "new-candidate",
-					 G_CALLBACK(jingle_rtp_new_candidate_cb), session);
-		} else {
+		if (jingle_session_is_initiator(session) == FALSE) {
 			jabber_iq_send(jingle_session_to_packet(session, JINGLE_SESSION_ACCEPT));
 			g_signal_connect(G_OBJECT(media), "new-candidate",
 					 G_CALLBACK(jingle_rtp_new_candidate_cb), session);
@@ -465,6 +462,25 @@ jingle_rtp_state_changed_cb(PurpleMedia 
 	}
 }
 
+static void
+jingle_rtp_send_initiate(JingleSession *session)
+{
+	PurpleMedia *media = jingle_rtp_get_media(session);
+
+	if (jingle_session_is_initiator(session) == TRUE &&
+			purple_media_codecs_ready(media, NULL) &&
+			purple_media_candidates_prepared(media, NULL, NULL)) {
+		JabberIq *iq = jingle_session_to_packet(
+				session, JINGLE_SESSION_INITIATE);
+		jabber_iq_set_callback(iq,
+				jingle_rtp_initiate_ack_cb, session);
+		jabber_iq_send(iq);
+		g_signal_connect(G_OBJECT(media), "new-candidate",
+				G_CALLBACK(jingle_rtp_new_candidate_cb),
+				session);
+	}
+}
+
 static PurpleMedia *
 jingle_rtp_create_media(JingleContent *content)
 {


More information about the Commits mailing list