maiku.vv: f846f6d1: Fix support for audio and video (at the ...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Sun Nov 2 22:10:24 EST 2008


-----------------------------------------------------------------
Revision: f846f6d1666fd01c7635eac6c3bf876b2946e93a
Ancestor: 12f3ee326edcf1cb6ebbe2e5a79987d5c5fe50f3
Author: maiku at soc.pidgin.im
Date: 2008-11-03T03:07:07
Branch: im.pidgin.maiku.vv
URL: http://d.pidgin.im/viewmtn/revision/info/f846f6d1666fd01c7635eac6c3bf876b2946e93a

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

ChangeLog: 

Fix support for audio and video (at the same time) sessions.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jingle/content.c	01b3233f21296d737dddacfa12fe1162c9cfeee8
+++ libpurple/protocols/jabber/jingle/content.c	eac84f1b7d3f1e93228f9d271e7a0db3ace99fac
@@ -447,9 +447,9 @@ void
 }
 
 void
-jingle_content_handle_action(JingleContent *content, xmlnode *jingle, JingleActionType action)
+jingle_content_handle_action(JingleContent *content, xmlnode *xmlcontent, JingleActionType action)
 {
 	g_return_if_fail(JINGLE_IS_CONTENT(content));
-	JINGLE_CONTENT_GET_CLASS(content)->handle_action(content, jingle, action);
+	JINGLE_CONTENT_GET_CLASS(content)->handle_action(content, xmlcontent, action);
 }
 
============================================================
--- libpurple/protocols/jabber/jingle/content.h	4ffbaaf6762b87423a3abe7200e4bb8e3a82d850
+++ libpurple/protocols/jabber/jingle/content.h	55efaff440a66616506f409bce7400496aeaf47f
@@ -53,7 +53,7 @@ struct _JingleContentClass
 
 	xmlnode *(*to_xml) (JingleContent *content, xmlnode *jingle, JingleActionType action);
 	JingleContent *(*parse) (xmlnode *content);
-	void (*handle_action) (JingleContent *content, xmlnode *jingle, JingleActionType action);
+	void (*handle_action) (JingleContent *content, xmlnode *xmlcontent, JingleActionType action);
 	const gchar *description_type;
 };
 
@@ -105,7 +105,7 @@ xmlnode *jingle_content_to_xml(JingleCon
 
 JingleContent *jingle_content_parse(xmlnode *content);
 xmlnode *jingle_content_to_xml(JingleContent *content, xmlnode *jingle, JingleActionType action);
-void jingle_content_handle_action(JingleContent *content, xmlnode *jingle, JingleActionType action);
+void jingle_content_handle_action(JingleContent *content, xmlnode *xmlcontent, JingleActionType action);
 
 #ifdef __cplusplus
 }
============================================================
--- libpurple/protocols/jabber/jingle/jingle.c	1b1d91fa356e399ad194bf6fde29fcc74576f48c
+++ libpurple/protocols/jabber/jingle/jingle.c	526e917669020a8e1cc1926132007a72acc972ae
@@ -213,12 +213,13 @@ jingle_handle_session_accept(JingleSessi
 	for (; content; content = xmlnode_get_next_twin(content)) {
 		const gchar *name = xmlnode_get_attrib(content, "name");
 		const gchar *creator = xmlnode_get_attrib(content, "creator");
-		JingleContent *content = jingle_session_find_content(session, name, creator);
-		if (content == NULL) {
+		JingleContent *parsed_content =
+				jingle_session_find_content(session, name, creator);
+		if (parsed_content == NULL) {
 			purple_debug_error("jingle", "Error parsing content\n");
 			/* XXX: send error */
 		} else {
-			jingle_content_handle_action(content, jingle,
+			jingle_content_handle_action(parsed_content, content,
 					JINGLE_SESSION_ACCEPT);
 		}
 	}
@@ -243,7 +244,7 @@ jingle_handle_session_initiate(JingleSes
 			/* XXX: send error */
 		} else {
 			jingle_session_add_content(session, parsed_content);
-			jingle_content_handle_action(parsed_content, jingle,
+			jingle_content_handle_action(parsed_content, content,
 					JINGLE_SESSION_INITIATE);
 		}
 	}
@@ -287,12 +288,13 @@ jingle_handle_transport_info(JingleSessi
 	for (; content; content = xmlnode_get_next_twin(content)) {
 		const gchar *name = xmlnode_get_attrib(content, "name");
 		const gchar *creator = xmlnode_get_attrib(content, "creator");
-		JingleContent *content = jingle_session_find_content(session, name, creator);
-		if (content == NULL) {
+		JingleContent *parsed_content = 
+				jingle_session_find_content(session, name, creator);
+		if (parsed_content == NULL) {
 			purple_debug_error("jingle", "Error parsing content\n");
 			/* XXX: send error */
 		} else {
-			jingle_content_handle_action(content, jingle,
+			jingle_content_handle_action(parsed_content, content,
 					JINGLE_TRANSPORT_INFO);
 		}
 	}
============================================================
--- libpurple/protocols/jabber/jingle/rtp.c	b3afef010bee009483e908551e727ceb422348ce
+++ libpurple/protocols/jabber/jingle/rtp.c	c3742196fcf24f9e70822c3f154811b6e906da16
@@ -409,9 +409,6 @@ jingle_rtp_init_media(JingleContent *con
 	g_free(senders);
 	g_object_unref(session);
 
-	/* needs to be after all the streams have been added */
-	purple_media_ready(media);
-
 	return TRUE;
 }
 
@@ -523,25 +520,30 @@ static void
 }
 
 static void
-jingle_rtp_handle_action_internal(JingleContent *content, xmlnode *jingle, JingleActionType action)
+jingle_rtp_handle_action_internal(JingleContent *content, xmlnode *xmlcontent, JingleActionType action)
 {
 	switch (action) {
 		case JINGLE_SESSION_ACCEPT: {
 			JingleSession *session = jingle_content_get_session(content);
-			xmlnode *description = xmlnode_get_child(jingle, "content/description");
+			xmlnode *description = xmlnode_get_child(xmlcontent, "description");
 			GList *codecs = jingle_rtp_parse_codecs(description);
 
 			purple_media_set_remote_codecs(jingle_rtp_get_media(session),
 					jingle_content_get_name(content),
 					jingle_session_get_remote_jid(session), codecs);
 
+			/* This needs to be for the entire session, not a single content */
+			/* very hacky */
+			if (xmlnode_get_next_twin(xmlcontent) == NULL)
+				purple_media_got_accept(jingle_rtp_get_media(session));
+
 			g_object_unref(session);
 			break;
 		}
 		case JINGLE_SESSION_INITIATE: {
 			JingleSession *session = jingle_content_get_session(content);
-			xmlnode *description = xmlnode_get_child(jingle, "content/description");
-			xmlnode *transport = xmlnode_get_child(jingle, "content/transport");
+			xmlnode *description = xmlnode_get_child(xmlcontent, "description");
+			xmlnode *transport = xmlnode_get_child(xmlcontent, "transport");
 			FsCandidate *candidate = jingle_rtp_transport_to_candidate(transport);
 			GList *candidates = g_list_append(NULL, candidate);
 			GList *codecs = jingle_rtp_parse_codecs(description);
@@ -563,6 +565,10 @@ jingle_rtp_handle_action_internal(Jingle
 					jingle_session_get_remote_jid(session),
 					candidates);
 
+			/* very hacky */
+			if (xmlnode_get_next_twin(xmlcontent) == NULL)
+				purple_media_ready(jingle_rtp_get_media(session));
+
 			g_object_unref(session);
 			break;
 		}
@@ -574,7 +580,7 @@ jingle_rtp_handle_action_internal(Jingle
 		}
 		case JINGLE_TRANSPORT_INFO: {
 			JingleSession *session = jingle_content_get_session(content);
-			xmlnode *transport = xmlnode_get_child(jingle, "content/transport");
+			xmlnode *transport = xmlnode_get_child(xmlcontent, "transport");
 			FsCandidate *candidate = jingle_rtp_transport_to_candidate(transport);
 			GList *candidates = g_list_append(NULL, candidate);
 
@@ -588,7 +594,6 @@ jingle_rtp_handle_action_internal(Jingle
 					jingle_content_get_name(content),
 					jingle_session_get_remote_jid(session),
 					candidates);
-			purple_media_got_accept(jingle_rtp_get_media(session));
 			g_object_unref(session);
 			break;
 		}
@@ -634,16 +639,25 @@ jingle_rtp_initiate_media(JabberStream *
 	session = jingle_session_create(js, sid, me, jid, TRUE);
 	g_free(sid);
 
-	transport = jingle_transport_create(JINGLE_TRANSPORT_RAWUDP);
-	content = jingle_content_create(JINGLE_APP_RTP, "initiator", "session", "test-session", "both", transport);
-	jingle_session_add_content(session, content);
-	if (purple_media_to_fs_media_type(type) == FS_MEDIA_TYPE_AUDIO)
+
+	if (type & PURPLE_MEDIA_AUDIO) {
+		transport = jingle_transport_create(JINGLE_TRANSPORT_RAWUDP);
+		content = jingle_content_create(JINGLE_APP_RTP, "initiator",
+				"session", "audio-session", "both", transport);
+		jingle_session_add_content(session, content);
 		JINGLE_RTP(content)->priv->media_type = g_strdup("audio");
-	else
+		jingle_rtp_init_media(content);
+	}
+	if (type & PURPLE_MEDIA_VIDEO) {
+		transport = jingle_transport_create(JINGLE_TRANSPORT_RAWUDP);
+		content = jingle_content_create(JINGLE_APP_RTP, "initiator",
+				"session", "video-session", "both", transport);
+		jingle_session_add_content(session, content);
 		JINGLE_RTP(content)->priv->media_type = g_strdup("video");
+		jingle_rtp_init_media(content);
+	}
 
-	jingle_rtp_init_media(content);
-
+	purple_media_ready(jingle_rtp_get_media(session));
 	purple_media_wait(jingle_rtp_get_media(session));
 
 	g_free(jid);


More information about the Commits mailing list