changeset 26393:0083c73e004b

Move sending session-initiate out of the ready-new callback.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Thu, 19 Mar 2009 23:03:43 +0000
parents 17929a84c1fb
children c03975d856c9
files libpurple/protocols/jabber/jingle/rtp.c
diffstat 1 files changed, 25 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jingle/rtp.c	Thu Mar 19 22:57:53 2009 +0000
+++ b/libpurple/protocols/jabber/jingle/rtp.c	Thu Mar 19 23:03:43 2009 +0000
@@ -335,6 +335,8 @@
 	}
 }
 
+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_content_set_pending_transport(content, transport);
 	jingle_content_accept_transport(content);
+
+	jingle_rtp_send_initiate(session);
 }
 
 static void
@@ -380,6 +384,7 @@
 {
 	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 @@
 	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 @@
 	}
 }
 
+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)
 {