changeset 26313:96ffb196d18d

Move sending session-accept out of the ready-new signal.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Fri, 20 Mar 2009 00:24:06 +0000
parents c03975d856c9
children 2ad89aff8d68
files libpurple/protocols/jabber/jingle/rtp.c
diffstat 1 files changed, 21 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jingle/rtp.c	Thu Mar 19 23:26:20 2009 +0000
+++ b/libpurple/protocols/jabber/jingle/rtp.c	Fri Mar 20 00:24:06 2009 +0000
@@ -336,12 +336,14 @@
 }
 
 static void jingle_rtp_send_initiate(JingleSession *session);
+static void jingle_rtp_send_accept(JingleSession *session);
 
 static void
 jingle_rtp_accepted_cb(PurpleMedia *media, gchar *sid, gchar *name,
 		JingleSession *session)
 {
 	purple_debug_info("jingle-rtp", "jingle_rtp_accepted_cb\n");
+	jingle_rtp_send_accept(session);
 }
 
 static void
@@ -376,6 +378,7 @@
 	jingle_content_accept_transport(content);
 
 	jingle_rtp_send_initiate(session);
+	jingle_rtp_send_accept(session);
 }
 
 static void
@@ -385,6 +388,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);
+	jingle_rtp_send_accept(session);
 }
 
 static void
@@ -434,20 +438,6 @@
 }
 
 static void
-jingle_rtp_ready_cb(PurpleMedia *media, gchar *sid, gchar *name, JingleSession *session)
-{
-	purple_debug_info("rtp", "ready-new: session: %s name: %s\n", sid, name);
-
-	if (sid == NULL && name == NULL) {
-		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);
-		}
-	}
-}
-
-static void
 jingle_rtp_state_changed_cb(PurpleMedia *media, PurpleMediaStateChangedType type,
 		gchar *sid, gchar *name, JingleSession *session)
 {
@@ -481,6 +471,23 @@
 	}
 }
 
+static void
+jingle_rtp_send_accept(JingleSession *session)
+{
+	PurpleMedia *media = jingle_rtp_get_media(session);
+
+	if (jingle_session_is_initiator(session) == FALSE &&
+			purple_media_codecs_ready(media, NULL) &&
+			purple_media_accepted(media, NULL, NULL) &&
+			purple_media_candidates_prepared(media, NULL, NULL)) {
+		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);
+	}
+}
+
 static PurpleMedia *
 jingle_rtp_create_media(JingleContent *content)
 {
@@ -507,8 +514,6 @@
 				 G_CALLBACK(jingle_rtp_candidates_prepared_cb), session);
 	g_signal_connect(G_OBJECT(media), "codecs-changed",
 				 G_CALLBACK(jingle_rtp_codecs_changed_cb), session);
-	g_signal_connect(G_OBJECT(media), "ready-new",
-				 G_CALLBACK(jingle_rtp_ready_cb), session);
 	g_signal_connect(G_OBJECT(media), "state-changed",
 				 G_CALLBACK(jingle_rtp_state_changed_cb), session);