changeset 26382:7fe896a5f4db

merge of 'bf07e6251df10e4c8c39545c4ff401db5b447c37' and 'c73207d75d40242b33089c1072b93ff301ab15b6'
author Mike Ruprecht <maiku@soc.pidgin.im>
date Thu, 19 Mar 2009 09:54:02 +0000
parents d784e9ea7f50 (diff) 045be0c868a6 (current diff)
children 08e4ad2fcd63
files libpurple/protocols/jabber/jingle/rtp.c
diffstat 2 files changed, 47 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/media.c	Thu Mar 19 09:53:56 2009 +0000
+++ b/libpurple/media.c	Thu Mar 19 09:54:02 2009 +0000
@@ -126,6 +126,7 @@
 enum {
 	ERROR,
 	ACCEPTED,
+	CANDIDATES_PREPARED,
 	CODECS_CHANGED,
 	NEW_CANDIDATE,
 	READY_NEW,
@@ -234,6 +235,11 @@
 					 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
 					 purple_smarshal_VOID__STRING_STRING,
 					 G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
+	purple_media_signals[CANDIDATES_PREPARED] = g_signal_new("candidates-prepared", G_TYPE_FROM_CLASS(klass),
+					 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+					 purple_smarshal_VOID__STRING_STRING,
+					 G_TYPE_NONE, 2, G_TYPE_STRING,
+					 G_TYPE_STRING);
 	purple_media_signals[CODECS_CHANGED] = g_signal_new("codecs-changed", G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
 					 g_cclosure_marshal_VOID__STRING,
@@ -1724,6 +1730,10 @@
 	stream_data = purple_media_get_stream(session->media, session->id, name);
 	stream_data->candidates_prepared = TRUE;
 
+	g_signal_emit(session->media,
+			purple_media_signals[CANDIDATES_PREPARED],
+			0, session->id, name);
+
 	purple_media_emit_ready(session->media, session, name);
 	g_free(name);
 }
--- a/libpurple/protocols/jabber/jingle/rtp.c	Thu Mar 19 09:53:56 2009 +0000
+++ b/libpurple/protocols/jabber/jingle/rtp.c	Thu Mar 19 09:54:02 2009 +0000
@@ -343,6 +343,41 @@
 }
 
 static void
+jingle_rtp_candidates_prepared_cb(PurpleMedia *media,
+		gchar *sid, gchar *name, JingleSession *session)
+{
+	JingleContent *content = jingle_session_find_content(
+			session, sid, "initiator");
+	JingleTransport *oldtransport, *transport;
+	GList *candidates;
+
+	purple_debug_info("jingle-rtp", "jingle_rtp_candidates_prepared_cb\n");
+
+	if (content == NULL)
+		jingle_session_find_content(session, sid, "responder");
+
+	if (content == NULL) {
+		purple_debug_error("jingle-rtp",
+				"jingle_rtp_candidates_prepared_cb: "
+				"Can't find session %s\n", sid);
+		return;
+	}
+
+	oldtransport = jingle_content_get_transport(content);
+	candidates = purple_media_get_local_candidates(media, sid, name);
+	transport = JINGLE_TRANSPORT(jingle_rtp_candidates_to_transport(
+			session, JINGLE_IS_RAWUDP(oldtransport) ?
+				JINGLE_TYPE_RAWUDP : JINGLE_TYPE_ICEUDP,
+			0, candidates));
+
+	g_list_free(candidates);
+	g_object_unref(oldtransport);
+
+	jingle_content_set_pending_transport(content, transport);
+	jingle_content_accept_transport(content);
+}
+
+static void
 jingle_rtp_codecs_changed_cb(PurpleMedia *media, gchar *sid,
 		JingleSession *session)
 {
@@ -419,20 +454,6 @@
 			g_signal_connect(G_OBJECT(media), "new-candidate",
 					 G_CALLBACK(jingle_rtp_new_candidate_cb), session);
 		}
-	} else if (sid != NULL && name != NULL) {
-		JingleContent *content = jingle_session_find_content(session, sid, "initiator");
-		JingleTransport *oldtransport = jingle_content_get_transport(content);
-		GList *candidates = purple_media_get_local_candidates(media, sid, name);
-		JingleTransport *transport =
-				JINGLE_TRANSPORT(jingle_rtp_candidates_to_transport(
-				session, JINGLE_IS_RAWUDP(oldtransport) ?
-					JINGLE_TYPE_RAWUDP : JINGLE_TYPE_ICEUDP,
-				0, candidates));
-		g_list_free(candidates);
-		g_object_unref(oldtransport);
-
-		jingle_content_set_pending_transport(content, transport);
-		jingle_content_accept_transport(content);
 	}
 }
 
@@ -473,6 +494,8 @@
 	/* connect callbacks */
 	g_signal_connect(G_OBJECT(media), "accepted",
 				 G_CALLBACK(jingle_rtp_accepted_cb), session);
+	g_signal_connect(G_OBJECT(media), "candidates-prepared",
+				 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",