changeset 24990:607d82dce00e

Have XMPP use the new ready signal.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Sun, 04 Jan 2009 09:56:54 +0000
parents 7caa7e2ce870
children b0e6a64cbf2e
files libpurple/media.c libpurple/protocols/jabber/jingle/rtp.c
diffstat 2 files changed, 20 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/media.c	Sun Jan 04 07:42:12 2009 +0000
+++ b/libpurple/media.c	Sun Jan 04 09:56:54 2009 +0000
@@ -642,7 +642,8 @@
 	GList *sessions;
 	gboolean conf_ready = TRUE;
 
-	if ((session != NULL) && ((session->accepted == FALSE) ||
+	if ((session != NULL) && ((media->priv->initiator == FALSE &&
+			session->accepted == FALSE) ||
 			(purple_media_codecs_ready(media, session->id) == FALSE)))
 		return;
 
@@ -652,28 +653,31 @@
 		PurpleMediaSession *session_data = sessions->data;
 		GList *streams = purple_media_get_streams(media,
 				session_data->id, NULL);
+		gboolean session_ready = TRUE;
 
-		if ((session_data->accepted == FALSE) ||
+		if ((media->priv->initiator == FALSE &&
+				session_data->accepted == FALSE) ||
 				(purple_media_codecs_ready(
 				media, session_data->id) == FALSE))
 			conf_ready = FALSE;
 
 		for (; streams; streams = g_list_delete_link(streams, streams)) {
 			PurpleMediaStream *stream = streams->data;
-			if (stream->candidates_prepared == TRUE &&
-					session_data == session)
+			if (stream->candidates_prepared == FALSE) {
+				session_ready = FALSE;
+				conf_ready = FALSE;
+			} else if (session_data == session)
 				g_signal_emit(media, purple_media_signals[READY_NEW],
 						0, session_data->id, stream->participant);
 		}
 
-		if (session == session_data || session == NULL)
+		if (session_ready == TRUE &&
+				(session == session_data || session == NULL))
 			g_signal_emit(media, purple_media_signals[READY_NEW],
 					0, session_data->id, NULL);
 	}
 
 	if (conf_ready == TRUE) {
-		g_list_free(sessions);
-	} else {
 		g_signal_emit(media, purple_media_signals[READY_NEW],
 				0, NULL, NULL);
 	}
--- a/libpurple/protocols/jabber/jingle/rtp.c	Sun Jan 04 07:42:12 2009 +0000
+++ b/libpurple/protocols/jabber/jingle/rtp.c	Sun Jan 04 09:56:54 2009 +0000
@@ -164,27 +164,6 @@
 	}
 }
 
-static gboolean
-jingle_rtp_ready_to_initiate(JingleSession *session, PurpleMedia *media)
-{
-	if (jingle_session_is_initiator(session)) {
-		GList *iter = jingle_session_get_contents(session);
-		for (; iter; iter = g_list_next(iter)) {
-			JingleContent *content = iter->data;
-			gchar *name = jingle_content_get_name(content);
-			if (!JINGLE_IS_RTP(content)
-					|| JINGLE_RTP_GET_PRIVATE(content)->codecs_ready == FALSE
-					|| JINGLE_RTP_GET_PRIVATE(content)->candidates_ready == FALSE) {
-				g_free(name);
-				return FALSE;
-			}
-			g_free(name);
-		}
-		return TRUE;
-	}
-	return FALSE;
-}
-
 gchar *
 jingle_rtp_get_media_type(JingleContent *content)
 {
@@ -328,12 +307,6 @@
 
 	jingle_content_set_pending_transport(content, transport);
 	jingle_content_accept_transport(content);
-
-	if (jingle_rtp_ready_to_initiate(session, media)) {
-		jabber_iq_send(jingle_session_to_packet(session, JINGLE_SESSION_INITIATE));
-		if (JINGLE_IS_ICEUDP(transport))
-			jabber_iq_send(jingle_session_to_packet(session, JINGLE_TRANSPORT_INFO));
-	}
 }
 
 static void
@@ -343,31 +316,24 @@
 }
 
 static void
-jingle_rtp_codecs_ready_cb(PurpleMedia *media, gchar *sid, JingleSession *session)
+jingle_rtp_ready_cb(PurpleMedia *media, gchar *sid, gchar *name, JingleSession *session)
 {
-	JingleContent *content = jingle_session_find_content(session, sid, "initiator");
-
-	if (content == NULL)
-		content = jingle_session_find_content(session, sid, "responder");
+	purple_debug_info("rtp", "ready-new: session: %s name: %s\n", sid, name);
 
-	if (JINGLE_RTP_GET_PRIVATE(content)->codecs_ready == FALSE) {
-		JINGLE_RTP_GET_PRIVATE(content)->codecs_ready =
-				purple_media_codecs_ready(media, sid);
+	if (sid == NULL && name == NULL && jingle_session_is_initiator(session) == TRUE) {
+		GList *contents = jingle_session_get_contents(session);
 
-		if (jingle_rtp_ready_to_initiate(session, media)) {
+		jabber_iq_send(jingle_session_to_packet(session, JINGLE_SESSION_INITIATE));
+
+		for (; contents; contents = g_list_next(contents)) {
+			JingleContent *content = (JingleContent *)contents->data;
 			JingleTransport *transport = jingle_content_get_transport(content);
-			jabber_iq_send(jingle_session_to_packet(session, JINGLE_SESSION_INITIATE));
 			if (JINGLE_IS_ICEUDP(transport))
 				jabber_iq_send(jingle_session_to_packet(session, JINGLE_TRANSPORT_INFO));
 		}
 	}
 }
 
-static void
-jingle_rtp_ready_new_cb(PurpleMedia *media, gchar *sid, gchar *name, JingleSession *session) {
-	purple_debug_info("rtp", "ready-new: session: %s name: %s\n", sid, name);
-}
-
 static PurpleMedia *
 jingle_rtp_create_media(JingleContent *content)
 {
@@ -407,10 +373,8 @@
 				 G_CALLBACK(jingle_rtp_candidates_prepared_cb), session);
 	g_signal_connect(G_OBJECT(media), "candidate-pair",
 				 G_CALLBACK(jingle_rtp_candidate_pair_established_cb), session);
-	g_signal_connect(G_OBJECT(media), "codecs-ready",
-				 G_CALLBACK(jingle_rtp_codecs_ready_cb), session);
 	g_signal_connect(G_OBJECT(media), "ready-new",
-				 G_CALLBACK(jingle_rtp_ready_new_cb), session);
+				 G_CALLBACK(jingle_rtp_ready_cb), session);
 
 	g_object_unref(session);
 	return media;