summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Ruprecht <maiku@pidgin.im>2008-11-03 03:07:07 +0000
committerMichael Ruprecht <maiku@pidgin.im>2008-11-03 03:07:07 +0000
commitebb6889882cb039c466fdc8f9a1243e6663712b8 (patch)
tree30be188f7ae31d0943a2df9c2915a842c1cb225e
parent4fc0eeab4456e5d129b4fb853e7f127686c133c1 (diff)
downloadpidgin-ebb6889882cb039c466fdc8f9a1243e6663712b8.tar.gz
Fix support for audio and video (at the same time) sessions.
-rw-r--r--libpurple/protocols/jabber/jingle/content.c4
-rw-r--r--libpurple/protocols/jabber/jingle/content.h4
-rw-r--r--libpurple/protocols/jabber/jingle/jingle.c16
-rw-r--r--libpurple/protocols/jabber/jingle/rtp.c46
4 files changed, 43 insertions, 27 deletions
diff --git a/libpurple/protocols/jabber/jingle/content.c b/libpurple/protocols/jabber/jingle/content.c
index d7e57c0479..7645feb908 100644
--- a/libpurple/protocols/jabber/jingle/content.c
+++ b/libpurple/protocols/jabber/jingle/content.c
@@ -447,9 +447,9 @@ jingle_content_to_xml(JingleContent *content, xmlnode *jingle, JingleActionType
}
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);
}
diff --git a/libpurple/protocols/jabber/jingle/content.h b/libpurple/protocols/jabber/jingle/content.h
index 777b6b7488..6a19cb864c 100644
--- a/libpurple/protocols/jabber/jingle/content.h
+++ b/libpurple/protocols/jabber/jingle/content.h
@@ -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 @@ void jingle_content_modify(JingleContent *content, const gchar *senders);
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
}
diff --git a/libpurple/protocols/jabber/jingle/jingle.c b/libpurple/protocols/jabber/jingle/jingle.c
index 0caee1cab9..15158e002e 100644
--- a/libpurple/protocols/jabber/jingle/jingle.c
+++ b/libpurple/protocols/jabber/jingle/jingle.c
@@ -213,12 +213,13 @@ jingle_handle_session_accept(JingleSession *session, xmlnode *jingle)
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(JingleSession *session, xmlnode *jingle)
/* 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(JingleSession *session, xmlnode *jingle)
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);
}
}
diff --git a/libpurple/protocols/jabber/jingle/rtp.c b/libpurple/protocols/jabber/jingle/rtp.c
index c7e49a9976..c32af11ec4 100644
--- a/libpurple/protocols/jabber/jingle/rtp.c
+++ b/libpurple/protocols/jabber/jingle/rtp.c
@@ -409,9 +409,6 @@ jingle_rtp_init_media(JingleContent *content)
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 @@ jingle_rtp_to_xml_internal(JingleContent *rtp, xmlnode *content, JingleActionTyp
}
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(JingleContent *content, xmlnode *jingle, Jingl
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(JingleContent *content, xmlnode *jingle, Jingl
}
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(JingleContent *content, xmlnode *jingle, Jingl
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 *js, const gchar *who,
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);