annotate libpurple/protocols/jabber/jingle.c @ 25664:d0ac3c438b71

Check remote JID's capabilities for audio and video XEP support.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Sat, 31 May 2008 20:15:34 +0000
parents d048100a43ab
children e73b03097664
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1 /*
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
2 * purple - Jabber Protocol Plugin
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
3 *
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
7 * (at your option) any later version.
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
8 *
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
12 * GNU General Public License for more details.
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
13 *
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
15 * along with this program; if not, write to the Free Software
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
17 *
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
18 */
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
19
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
20 #include "config.h"
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
21 #include "purple.h"
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
22 #include "jingle.h"
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
23 #include "xmlnode.h"
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
24
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
25 #include <stdlib.h>
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
26 #include <string.h>
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
27 #include <glib.h>
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
28
25654
cbe97caec684 Use USE_VV instead of USE_FARSIGHT.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25648
diff changeset
29 #ifdef USE_VV
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
30
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
31 #include <gst/farsight/fs-candidate.h>
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
32
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
33 static gboolean
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
34 jabber_jingle_session_equal(gconstpointer a, gconstpointer b)
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
35 {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
36 purple_debug_info("jingle",
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
37 "jabber_jingle_session_equal, comparing %s and %s\n",
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
38 ((JingleSession *)a)->id,
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
39 ((JingleSession *)b)->id);
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
40 return !strcmp(((JingleSession *) a)->id, ((JingleSession *) b)->id);
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
41 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
42
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
43 static JingleSession *
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
44 jabber_jingle_session_create_internal(JabberStream *js,
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
45 const char *id)
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
46 {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
47 JingleSession *sess = g_new0(JingleSession, 1);
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
48 sess->js = js;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
50 if (id) {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
51 sess->id = g_strdup(id);
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
52 } else if (js) {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
53 /* init the session ID... */
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54 sess->id = jabber_get_next_id(js);
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
55 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
56
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
57 /* insert it into the hash table */
25648
16543025aed1 Moved jingle.c global variable "sessions" into JabberStream.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25647
diff changeset
58 if (!js->sessions) {
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
59 purple_debug_info("jingle", "Creating hash table for sessions\n");
25648
16543025aed1 Moved jingle.c global variable "sessions" into JabberStream.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25647
diff changeset
60 js->sessions = g_hash_table_new(g_str_hash, g_str_equal);
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
61 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
62 purple_debug_info("jingle", "inserting session with key: %s into table\n",
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
63 sess->id);
25648
16543025aed1 Moved jingle.c global variable "sessions" into JabberStream.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25647
diff changeset
64 g_hash_table_insert(js->sessions, sess->id, sess);
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
65
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
66 sess->session_started = FALSE;
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
67
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
68 return sess;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
69 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
70
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
71 JabberStream *
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
72 jabber_jingle_session_get_js(const JingleSession *sess)
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
73 {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
74 return sess->js;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
75 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
76
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
77 JingleSession *
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
78 jabber_jingle_session_create(JabberStream *js)
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
79 {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
80 JingleSession *sess = jabber_jingle_session_create_internal(js, NULL);
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
81 sess->is_initiator = TRUE;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
82 return sess;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
83 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
84
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
85 JingleSession *
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
86 jabber_jingle_session_create_by_id(JabberStream *js, const char *id)
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
87 {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
88 JingleSession *sess = jabber_jingle_session_create_internal(js, id);
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
89 sess->is_initiator = FALSE;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
90 return sess;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
91 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
92
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
93 const char *
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
94 jabber_jingle_session_get_id(const JingleSession *sess)
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
95 {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
96 return sess->id;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
97 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
98
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
99 void
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
100 jabber_jingle_session_destroy(JingleSession *sess)
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
101 {
25648
16543025aed1 Moved jingle.c global variable "sessions" into JabberStream.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25647
diff changeset
102 g_hash_table_remove(sess->js->sessions, sess->id);
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
103 g_free(sess->id);
25661
d048100a43ab Free the PurpleMedia object when the media session ends and fix ending
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25654
diff changeset
104 g_object_unref(sess->media);
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
105 g_free(sess);
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
106 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
107
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
108 JingleSession *
25648
16543025aed1 Moved jingle.c global variable "sessions" into JabberStream.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25647
diff changeset
109 jabber_jingle_session_find_by_id(JabberStream *js, const char *id)
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
110 {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
111 purple_debug_info("jingle", "find_by_id %s\n", id);
25648
16543025aed1 Moved jingle.c global variable "sessions" into JabberStream.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25647
diff changeset
112 purple_debug_info("jingle", "hash table: %p\n", js->sessions);
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
113 purple_debug_info("jingle", "hash table size %d\n",
25648
16543025aed1 Moved jingle.c global variable "sessions" into JabberStream.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25647
diff changeset
114 g_hash_table_size(js->sessions));
16543025aed1 Moved jingle.c global variable "sessions" into JabberStream.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25647
diff changeset
115 purple_debug_info("jingle", "lookup: %p\n", g_hash_table_lookup(js->sessions, id));
16543025aed1 Moved jingle.c global variable "sessions" into JabberStream.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25647
diff changeset
116 return (JingleSession *) g_hash_table_lookup(js->sessions, id);
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
117 }
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
118
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
119 JingleSession *jabber_jingle_session_find_by_jid(JabberStream *js, const char *jid)
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
120 {
25648
16543025aed1 Moved jingle.c global variable "sessions" into JabberStream.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25647
diff changeset
121 GList *values = g_hash_table_get_values(js->sessions);
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
122 GList *iter = values;
25661
d048100a43ab Free the PurpleMedia object when the media session ends and fix ending
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25654
diff changeset
123 gboolean use_bare = strchr(jid, '/') == NULL;
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
124
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
125 for (; iter; iter = iter->next) {
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
126 JingleSession *session = (JingleSession *)iter->data;
25661
d048100a43ab Free the PurpleMedia object when the media session ends and fix ending
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25654
diff changeset
127 gchar *cmp_jid = use_bare ? jabber_get_bare_jid(session->remote_jid)
d048100a43ab Free the PurpleMedia object when the media session ends and fix ending
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25654
diff changeset
128 : g_strdup(session->remote_jid);
d048100a43ab Free the PurpleMedia object when the media session ends and fix ending
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25654
diff changeset
129 if (!strcmp(jid, cmp_jid)) {
d048100a43ab Free the PurpleMedia object when the media session ends and fix ending
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25654
diff changeset
130 g_free(cmp_jid);
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
131 g_list_free(values);
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
132 return session;
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
133 }
25661
d048100a43ab Free the PurpleMedia object when the media session ends and fix ending
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25654
diff changeset
134 g_free(cmp_jid);
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
135 }
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
136
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
137 g_list_free(values);
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
138 return NULL;
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
139 }
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
140
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
141 GList *
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
142 jabber_jingle_get_codecs(const xmlnode *description)
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
143 {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
144 GList *codecs = NULL;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
145 xmlnode *codec_element = NULL;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
146 const char *encoding_name,*id, *clock_rate;
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
147 FsCodec *codec;
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
148
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
149 for (codec_element = xmlnode_get_child(description, "payload-type") ;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
150 codec_element ;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
151 codec_element = xmlnode_get_next_twin(codec_element)) {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
152 encoding_name = xmlnode_get_attrib(codec_element, "name");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
153 id = xmlnode_get_attrib(codec_element, "id");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
154 clock_rate = xmlnode_get_attrib(codec_element, "clockrate");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
155
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
156 codec = fs_codec_new(atoi(id), encoding_name,
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
157 FS_MEDIA_TYPE_AUDIO,
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
158 clock_rate ? atoi(clock_rate) : 0);
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
159 codecs = g_list_append(codecs, codec);
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
160 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
161 return codecs;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
162 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
163
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
164 GList *
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
165 jabber_jingle_get_candidates(const xmlnode *transport)
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
166 {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
167 GList *candidates = NULL;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
168 xmlnode *candidate = NULL;
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
169 FsCandidate *c;
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
170
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
171 for (candidate = xmlnode_get_child(transport, "candidate") ;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
172 candidate ;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
173 candidate = xmlnode_get_next_twin(candidate)) {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
174 const char *type = xmlnode_get_attrib(candidate, "type");
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
175 c = fs_candidate_new(xmlnode_get_attrib(candidate, "component"),
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
176 atoi(xmlnode_get_attrib(candidate, "component")),
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
177 strcmp(type, "host") == 0 ?
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
178 FS_CANDIDATE_TYPE_HOST :
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
179 strcmp(type, "prflx") == 0 ?
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
180 FS_CANDIDATE_TYPE_PRFLX :
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
181 FS_CANDIDATE_TYPE_RELAY,
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
182 strcmp(xmlnode_get_attrib(candidate, "protocol"),
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
183 "udp") == 0 ?
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
184 FS_NETWORK_PROTOCOL_UDP :
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
185 FS_NETWORK_PROTOCOL_TCP,
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
186 xmlnode_get_attrib(candidate, "ip"),
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
187 atoi(xmlnode_get_attrib(candidate, "port")));
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
188 candidates = g_list_append(candidates, c);
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
189 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
190
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
191 return candidates;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
192 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
193
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
194 PurpleMedia *
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
195 jabber_jingle_session_get_media(const JingleSession *sess)
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
196 {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
197 return sess->media;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
198 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
199
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
200 void
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
201 jabber_jingle_session_set_media(JingleSession *sess, PurpleMedia *media)
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
202 {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
203 sess->media = media;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
204 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
205
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
206 const char *
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
207 jabber_jingle_session_get_remote_jid(const JingleSession *sess)
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
208 {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
209 return sess->remote_jid;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
210 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
211
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
212 void
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
213 jabber_jingle_session_set_remote_jid(JingleSession *sess,
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
214 const char *remote_jid)
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
215 {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
216 sess->remote_jid = strdup(remote_jid);
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
217 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
218
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
219 const char *
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
220 jabber_jingle_session_get_initiator(const JingleSession *sess)
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
221 {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
222 return sess->initiator;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
223 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
224
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
225 void
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
226 jabber_jingle_session_set_initiator(JingleSession *sess,
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
227 const char *initiator)
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
228 {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
229 sess->initiator = g_strdup(initiator);
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
230 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
231
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
232 gboolean
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
233 jabber_jingle_session_is_initiator(const JingleSession *sess)
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
234 {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
235 return sess->is_initiator;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
236 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
237
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
238 static xmlnode *
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
239 jabber_jingle_session_create_jingle_element(const JingleSession *sess,
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
240 const char *action)
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
241 {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
242 xmlnode *jingle = xmlnode_new("jingle");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
243 xmlnode_set_namespace(jingle, "urn:xmpp:tmp:jingle");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
244 xmlnode_set_attrib(jingle, "action", action);
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
245 xmlnode_set_attrib(jingle, "initiator",
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
246 jabber_jingle_session_get_initiator(sess));
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
247 xmlnode_set_attrib(jingle, "responder",
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
248 jabber_jingle_session_is_initiator(sess) ?
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
249 jabber_jingle_session_get_remote_jid(sess) :
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
250 jabber_jingle_session_get_initiator(sess));
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
251 xmlnode_set_attrib(jingle, "sid", sess->id);
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
252
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
253 return jingle;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
254 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
255
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
256 xmlnode *
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
257 jabber_jingle_session_create_terminate(const JingleSession *sess,
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
258 const char *reasoncode,
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
259 const char *reasontext)
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
260 {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
261 xmlnode *jingle =
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
262 jabber_jingle_session_create_jingle_element(sess, "session-terminate");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
263 xmlnode_set_attrib(jingle, "resoncode", reasoncode);
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
264 if (reasontext) {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
265 xmlnode_set_attrib(jingle, "reasontext", reasontext);
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
266 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
267 xmlnode_set_attrib(jingle, "sid", sess->id);
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
268
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
269 return jingle;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
270 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
271
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
272 xmlnode *
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
273 jabber_jingle_session_create_description(const JingleSession *sess)
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
274 {
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
275 GList *codecs = purple_media_get_local_audio_codecs(sess->media);
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
276 xmlnode *description = xmlnode_new("description");
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
277
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
278 xmlnode_set_namespace(description, "urn:xmpp:tmp:jingle:apps:audio-rtp");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
279
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
280 /* get codecs */
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
281 for (; codecs ; codecs = codecs->next) {
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
282 FsCodec *codec = (FsCodec*)codecs->data;
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
283 char id[8], clockrate[10], channels[10];
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
284 xmlnode *payload = xmlnode_new_child(description, "payload-type");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
285
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
286 g_snprintf(id, sizeof(id), "%d", codec->id);
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
287 g_snprintf(clockrate, sizeof(clockrate), "%d", codec->clock_rate);
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
288 g_snprintf(channels, sizeof(channels), "%d", codec->channels);
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
289
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
290 xmlnode_set_attrib(payload, "name", codec->encoding_name);
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
291 xmlnode_set_attrib(payload, "id", id);
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
292 xmlnode_set_attrib(payload, "clockrate", clockrate);
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
293 xmlnode_set_attrib(payload, "channels", channels);
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
294 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
295
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
296 fs_codec_list_destroy(codecs);
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
297 return description;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
298 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
299
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
300 static guint
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
301 jabber_jingle_get_priority(guint type, guint network)
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
302 {
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
303 switch (type) {
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
304 case FS_CANDIDATE_TYPE_HOST:
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
305 return network == 0 ? 4096 : network == 1 ? 2048 : 1024;
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
306 break;
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
307 case FS_CANDIDATE_TYPE_PRFLX:
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
308 return 126;
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
309 break;
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
310 case FS_CANDIDATE_TYPE_RELAY:
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
311 return 100;
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
312 break;
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
313 default:
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
314 return 0; /* unknown type, should not happen */
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
315 }
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
316 }
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
317
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
318 static xmlnode *
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
319 jabber_jingle_session_create_candidate_info(FsCandidate *c, FsCandidate *remote)
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
320 {
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
321 char port[8];
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
322 char prio[8];
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
323 char component[8];
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
324 xmlnode *candidate = NULL;
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
325
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
326 candidate = xmlnode_new("candidate");
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
327
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
328 g_snprintf(port, sizeof(port), "%d", c->port);
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
329 g_snprintf(prio, sizeof(prio), "%d",
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
330 jabber_jingle_get_priority(c->type, 0));
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
331 g_snprintf(component, sizeof(component), "%d", c->component_id);
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
332
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
333 xmlnode_set_attrib(candidate, "component", component);
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
334 xmlnode_set_attrib(candidate, "foundation", "1"); /* what about this? */
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
335 xmlnode_set_attrib(candidate, "generation", "0"); /* ? */
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
336 xmlnode_set_attrib(candidate, "ip", c->ip);
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
337 xmlnode_set_attrib(candidate, "network", "0"); /* ? */
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
338 xmlnode_set_attrib(candidate, "port", port);
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
339 xmlnode_set_attrib(candidate, "priority", prio); /* Is this correct? */
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
340 xmlnode_set_attrib(candidate, "protocol",
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
341 c->proto == FS_NETWORK_PROTOCOL_UDP ?
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
342 "udp" : "tcp");
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
343 if (c->username)
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
344 xmlnode_set_attrib(candidate, "ufrag", c->username);
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
345 if (c->password)
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
346 xmlnode_set_attrib(candidate, "pwd", c->password);
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
347
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
348 xmlnode_set_attrib(candidate, "type",
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
349 c->type == FS_CANDIDATE_TYPE_HOST ?
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
350 "host" :
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
351 c->type == FS_CANDIDATE_TYPE_PRFLX ?
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
352 "prflx" :
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
353 c->type == FS_CANDIDATE_TYPE_RELAY ?
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
354 "relay" : NULL);
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
355
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
356 /* relay */
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
357 if (c->type == FS_CANDIDATE_TYPE_RELAY) {
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
358 /* set rel-addr and rel-port? How? */
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
359 }
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
360
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
361 if (remote) {
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
362 char remote_port[8];
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
363 g_snprintf(remote_port, sizeof(remote_port), "%d", remote->port);
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
364 xmlnode_set_attrib(candidate, "rem-addr", remote->ip);
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
365 xmlnode_set_attrib(candidate, "rem-port", remote_port);
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
366 }
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
367
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
368 return candidate;
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
369 }
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
370
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
371 /* split into two separate methods, one to generate session-accept
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
372 (includes codecs) and one to generate transport-info (includes transports
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
373 candidates) */
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
374 xmlnode *
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
375 jabber_jingle_session_create_session_accept(const JingleSession *sess)
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
376 {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
377 xmlnode *jingle =
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
378 jabber_jingle_session_create_jingle_element(sess, "session-accept");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
379 xmlnode *content = NULL;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
380 xmlnode *description = NULL;
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
381 xmlnode *transport = NULL;
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
382 xmlnode *candidate = NULL;
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
383
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
384
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
385 content = xmlnode_new_child(jingle, "content");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
386 xmlnode_set_attrib(content, "creator", "initiator");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
387 xmlnode_set_attrib(content, "name", "audio-content");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
388 xmlnode_set_attrib(content, "profile", "RTP/AVP");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
389
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
390 description = jabber_jingle_session_create_description(sess);
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
391 xmlnode_insert_child(content, description);
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
392
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
393 transport = xmlnode_new_child(content, "transport");
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
394 xmlnode_set_namespace(transport, "urn:xmpp:tmp:jingle:transports:ice-udp");
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
395 candidate = jabber_jingle_session_create_candidate_info(
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
396 purple_media_get_local_candidate(sess->media),
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
397 purple_media_get_remote_candidate(sess->media));
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
398 xmlnode_insert_child(transport, candidate);
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
399
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
400 return jingle;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
401 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
402
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
403
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
404 xmlnode *
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
405 jabber_jingle_session_create_transport_info(const JingleSession *sess)
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
406 {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
407 xmlnode *jingle =
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
408 jabber_jingle_session_create_jingle_element(sess, "transport-info");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
409 xmlnode *content = NULL;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
410 xmlnode *transport = NULL;
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
411 GList *candidates = purple_media_get_local_audio_candidates(sess->media);
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
412
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
413 content = xmlnode_new_child(jingle, "content");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
414 xmlnode_set_attrib(content, "creator", "initiator");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
415 xmlnode_set_attrib(content, "name", "audio-content");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
416 xmlnode_set_attrib(content, "profile", "RTP/AVP");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
417
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
418 transport = xmlnode_new_child(content, "transport");
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
419 xmlnode_set_namespace(transport, "urn:xmpp:tmp:jingle:transports:ice-udp");
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
420
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
421 /* get transport candidate */
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
422 for (; candidates ; candidates = candidates->next) {
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
423 FsCandidate *c = (FsCandidate *) candidates->data;
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
424
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
425 if (!strcmp(c->ip, "127.0.0.1")) {
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
426 continue;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
427 }
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
428
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
429 xmlnode_insert_child(transport,
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
430 jabber_jingle_session_create_candidate_info(c, NULL));
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
431 }
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
432 fs_candidate_list_destroy(candidates);
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
433
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
434 return jingle;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
435 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
436
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
437 xmlnode *
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
438 jabber_jingle_session_create_content_replace(const JingleSession *sess,
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
439 FsCandidate *native_candidate,
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
440 FsCandidate *remote_candidate)
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
441 {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
442 xmlnode *jingle =
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
443 jabber_jingle_session_create_jingle_element(sess, "content-replace");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
444 xmlnode *content = NULL;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
445 xmlnode *transport = NULL;
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
446
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
447 purple_debug_info("jingle", "creating content-modify for native candidate %s " \
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
448 ", remote candidate %s\n", native_candidate->candidate_id,
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
449 remote_candidate->candidate_id);
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
450
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
451 content = xmlnode_new_child(jingle, "content");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
452 xmlnode_set_attrib(content, "creator", "initiator");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
453 xmlnode_set_attrib(content, "name", "audio-content");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
454 xmlnode_set_attrib(content, "profile", "RTP/AVP");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
455
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
456 /* get top codec from codec_intersection to put here... */
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
457 /* later on this should probably handle changing codec */
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
458
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
459 xmlnode_insert_child(content, jabber_jingle_session_create_description(sess));
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
460
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
461 transport = xmlnode_new_child(content, "transport");
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
462 xmlnode_set_namespace(transport, "urn:xmpp:tmp:jingle:transports:ice-udp");
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
463 xmlnode_insert_child(transport,
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
464 jabber_jingle_session_create_candidate_info(native_candidate,
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
465 remote_candidate));
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
466
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
467 purple_debug_info("jingle", "End create content modify\n");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
468
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
469 return jingle;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
470 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
471
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
472 xmlnode *
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
473 jabber_jingle_session_create_content_accept(const JingleSession *sess)
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
474 {
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
475 xmlnode *jingle =
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
476 jabber_jingle_session_create_jingle_element(sess, "content-accept");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
477
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
478 xmlnode *content = xmlnode_new_child(jingle, "content");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
479 xmlnode *description = jabber_jingle_session_create_description(sess);
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
480
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
481 xmlnode_set_attrib(content, "creator", "initiator");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
482 xmlnode_set_attrib(content, "name", "audio-content");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
483 xmlnode_set_attrib(content, "profile", "RTP/AVP");
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
484
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25638
diff changeset
485 xmlnode_insert_child(content, description);
25638
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
486
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
487 return jingle;
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
488 }
9f36ed35615e Add the new jingle.c/h files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
489
25654
cbe97caec684 Use USE_VV instead of USE_FARSIGHT.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25648
diff changeset
490 #endif /* USE_VV */