libpurple/protocols/jabber/jingle.c

Fri, 05 Sep 2008 02:18:15 +0000

author
Michael Ruprecht <maiku@pidgin.im>
date
Fri, 05 Sep 2008 02:18:15 +0000
branch
maiku.vv
changeset 26137
0688cf5221c9
parent 26136
ed796f2ff697
child 26140
ea79b877e92b
permissions
-rw-r--r--

Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
This will make codecs that need extra configuration, such as THEORA and
H264, work consistently.

22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
1 /*
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
2 * purple - Jabber Protocol Plugin
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
3 *
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
7 * (at your option) any later version.
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
8 *
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
12 * GNU General Public License for more details.
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
13 *
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
15 * along with this program; if not, write to the Free Software
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
17 *
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
18 */
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
19
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
20 #include "config.h"
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
21 #include "purple.h"
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
22 #include "jingle.h"
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
23 #include "xmlnode.h"
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
24 #include "iq.h"
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
25
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
26 #include <stdlib.h>
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
27 #include <string.h>
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
28 #include <glib.h>
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
29
23704
9b88c9b23aed Use USE_VV instead of USE_FARSIGHT.
Michael Ruprecht <maiku@pidgin.im>
parents: 23698
diff changeset
30 #ifdef USE_VV
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
31
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
32 #include <gst/farsight/fs-candidate.h>
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
33
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
34 #define JINGLE "urn:xmpp:tmp:jingle"
23725
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
35 #define JINGLE_RTP "urn:xmpp:tmp:jingle:apps:rtp"
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
36 #define JINGLE_RTP_INFO "urn:xmpp:tmp:jingle:apps:rtp:info"
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
37 #define TRANSPORT_ICEUDP "urn:xmpp:tmp:jingle:transports:ice-udp"
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
38
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
39 typedef enum {
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
40 PENDING,
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
41 GOT_ACK,
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
42 ACCEPTED,
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
43 ACTIVE
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
44 } JingleSessionState;
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
45
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
46 typedef struct {
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
47 char *id;
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
48 JabberStream *js;
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
49 PurpleMedia *media;
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
50 char *remote_jid;
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
51 char *initiator;
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
52 gboolean is_initiator;
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
53 JingleSessionState state;
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
54 GHashTable *contents; /* JingleSessionContent table */
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
55 } JingleSession;
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
56
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
57 typedef struct {
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
58 gchar *name;
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
59 JingleSession *session;
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
60 gchar *creator;
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
61 gchar *sender;
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
62 gchar *transport_type;
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
63 gchar *type;
23725
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
64 gchar *subtype;
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
65 } JingleSessionContent;
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
66
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
67 static void
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
68 jabber_jingle_session_content_create_internal(JingleSession *session,
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
69 const gchar *name,
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
70 const gchar *creator,
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
71 const gchar *sender,
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
72 const gchar *transport_type,
23725
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
73 const gchar *type,
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
74 const gchar *subtype)
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
75 {
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
76 JingleSessionContent *content = g_new0(JingleSessionContent, 1);
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
77 content->session = session;
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
78 content->name = g_strdup(name);
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
79 content->creator = g_strdup(creator);
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
80 content->sender = g_strdup(sender);
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
81 content->transport_type = g_strdup(transport_type);
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
82 content->type = g_strdup(type);
23725
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
83 content->subtype = g_strdup(subtype);
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
84
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
85 if (!session->contents) {
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
86 purple_debug_info("jingle", "Creating hash table for contents\n");
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
87 session->contents = g_hash_table_new(g_str_hash, g_str_equal);
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
88 }
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
89 purple_debug_info("jingle", "inserting content with name == \"%s\" into table\n",
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
90 content->name);
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
91 g_hash_table_insert(session->contents, content->name, content);
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
92 }
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
93
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
94 static void
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
95 jabber_jingle_session_destroy_content(JingleSessionContent *content)
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
96 {
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
97 purple_debug_info("jingle", "destroying content with name == \"%s\"\n",
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
98 content->name);
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
99 g_hash_table_remove(content->session->contents, content->name);
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
100 g_free(content->name);
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
101 g_free(content->creator);
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
102 g_free(content->sender);
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
103 g_free(content->transport_type);
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
104 g_free(content->type);
23725
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
105 g_free(content->subtype);
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
106 g_free(content);
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
107 }
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
108
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
109 static const gchar *
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
110 jabber_jingle_session_content_get_name(const JingleSessionContent *jsc)
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
111 {
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
112 return jsc->name;
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
113 }
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
114
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
115 static JingleSession *
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
116 jabber_jingle_session_content_get_session(const JingleSessionContent *jsc)
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
117 {
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
118 return jsc->session;
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
119 }
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
120
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
121 static const gchar *
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
122 jabber_jingle_session_content_get_creator(const JingleSessionContent *jsc)
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
123 {
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
124 return jsc->creator;
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
125 }
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
126
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
127 static const gchar *
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
128 jabber_jingle_session_content_get_sender(const JingleSessionContent *jsc)
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
129 {
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
130 return jsc->sender;
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
131 }
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
132
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
133 static const gchar *
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
134 jabber_jingle_session_content_get_transport_type(const JingleSessionContent *jsc)
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
135 {
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
136 return jsc->transport_type;
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
137 }
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
138
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
139 static gboolean
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
140 jabber_jingle_session_content_is_transport_type(const JingleSessionContent *jsc,
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
141 const gchar *transport_type)
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
142 {
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
143 return !strcmp(jabber_jingle_session_content_get_transport_type(jsc),
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
144 transport_type);
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
145 }
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
146
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
147 static const gchar *
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
148 jabber_jingle_session_content_get_type(const JingleSessionContent *jsc)
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
149 {
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
150 return jsc->type;
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
151 }
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
152
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
153 static gboolean
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
154 jabber_jingle_session_content_is_type(const JingleSessionContent *jsc,
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
155 const gchar *type)
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
156 {
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
157 return !strcmp(jabber_jingle_session_content_get_type(jsc), type);
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
158 }
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
159
23725
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
160 static gchar *
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
161 jabber_jingle_session_content_get_subtype(const JingleSessionContent *jsc)
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
162 {
23725
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
163 return jsc->subtype;
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
164 }
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
165
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
166 static gboolean
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
167 jabber_jingle_session_content_is_vv_type(const JingleSessionContent *jsc,
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
168 const gchar *media_type)
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
169 {
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
170 return jabber_jingle_session_content_is_type(jsc, JINGLE_RTP) &&
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
171 !strcmp(jabber_jingle_session_content_get_subtype(jsc),
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
172 media_type);
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
173 }
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
174
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
175 static void
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
176 jabber_jingle_session_content_set_sender(JingleSessionContent *jsc,
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
177 const char *sender)
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
178 {
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
179 if (jsc->sender)
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
180 g_free(jsc->sender);
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
181 jsc->sender = g_strdup(sender);
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
182 }
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
183
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
184 static gboolean
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
185 jabber_jingle_session_equal(gconstpointer a, gconstpointer b)
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
186 {
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
187 purple_debug_info("jingle",
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
188 "jabber_jingle_session_equal, comparing %s and %s\n",
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
189 ((JingleSession *)a)->id,
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
190 ((JingleSession *)b)->id);
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
191 return !strcmp(((JingleSession *) a)->id, ((JingleSession *) b)->id);
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
192 }
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
193
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
194 static JingleSession *
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
195 jabber_jingle_session_create_internal(JabberStream *js,
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
196 const char *id)
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
197 {
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
198 JingleSession *sess = g_new0(JingleSession, 1);
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
199 sess->js = js;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
200
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
201 if (id) {
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
202 sess->id = g_strdup(id);
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
203 } else if (js) {
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
204 /* init the session ID... */
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
205 sess->id = jabber_get_next_id(js);
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
206 }
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
207
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
208 /* insert it into the hash table */
23698
0815965bd80b Moved jingle.c global variable "sessions" into JabberStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
209 if (!js->sessions) {
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
210 purple_debug_info("jingle", "Creating hash table for sessions\n");
23698
0815965bd80b Moved jingle.c global variable "sessions" into JabberStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
211 js->sessions = g_hash_table_new(g_str_hash, g_str_equal);
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
212 }
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
213 purple_debug_info("jingle", "inserting session with key: %s into table\n",
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
214 sess->id);
23698
0815965bd80b Moved jingle.c global variable "sessions" into JabberStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
215 g_hash_table_insert(js->sessions, sess->id, sess);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
216
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
217 sess->state = PENDING;
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
218
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
219 return sess;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
220 }
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
221
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
222 static JabberStream *
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
223 jabber_jingle_session_get_js(const JingleSession *sess)
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
224 {
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
225 return sess->js;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
226 }
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
227
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
228 static JingleSession *
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
229 jabber_jingle_session_create(JabberStream *js)
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
230 {
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
231 JingleSession *sess = jabber_jingle_session_create_internal(js, NULL);
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
232 sess->is_initiator = TRUE;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
233 return sess;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
234 }
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
235
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
236 static JingleSession *
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
237 jabber_jingle_session_create_by_id(JabberStream *js, const char *id)
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
238 {
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
239 JingleSession *sess = jabber_jingle_session_create_internal(js, id);
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
240 sess->is_initiator = FALSE;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
241 return sess;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
242 }
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
243
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
244 static const char *
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
245 jabber_jingle_session_get_id(const JingleSession *sess)
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
246 {
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
247 return sess->id;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
248 }
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
249
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
250 static void
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
251 jabber_jingle_session_destroy(JingleSession *sess)
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
252 {
23752
d573c980437e Fixed some memory leak issues involving GLists.
Michael Ruprecht <maiku@pidgin.im>
parents: 23750
diff changeset
253 GList *contents;
23698
0815965bd80b Moved jingle.c global variable "sessions" into JabberStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
254 g_hash_table_remove(sess->js->sessions, sess->id);
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
255 g_free(sess->id);
26116
41f7d4545566 Fixed a ton of memory leaks.
Michael Ruprecht <maiku@pidgin.im>
parents: 26113
diff changeset
256 g_free(sess->remote_jid);
41f7d4545566 Fixed a ton of memory leaks.
Michael Ruprecht <maiku@pidgin.im>
parents: 26113
diff changeset
257 g_free(sess->initiator);
23745
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
258
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
259 if (sess->media)
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
260 g_object_unref(sess->media);
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
261
23752
d573c980437e Fixed some memory leak issues involving GLists.
Michael Ruprecht <maiku@pidgin.im>
parents: 23750
diff changeset
262 for (contents = g_hash_table_get_values(sess->contents); contents;
d573c980437e Fixed some memory leak issues involving GLists.
Michael Ruprecht <maiku@pidgin.im>
parents: 23750
diff changeset
263 contents = g_list_delete_link(contents, contents))
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
264 jabber_jingle_session_destroy_content(contents->data);
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
265
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
266 g_free(sess);
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
267 }
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
268
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
269 static JingleSession *
23698
0815965bd80b Moved jingle.c global variable "sessions" into JabberStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
270 jabber_jingle_session_find_by_id(JabberStream *js, const char *id)
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
271 {
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
272 purple_debug_info("jingle", "find_by_id %s\n", id);
23732
3fc0e49509bb Fix assertion.
Michael Ruprecht <maiku@pidgin.im>
parents: 23731
diff changeset
273 purple_debug_info("jingle", "lookup: %p\n", (js->sessions) ?
3fc0e49509bb Fix assertion.
Michael Ruprecht <maiku@pidgin.im>
parents: 23731
diff changeset
274 g_hash_table_lookup(js->sessions, id) : NULL);
3fc0e49509bb Fix assertion.
Michael Ruprecht <maiku@pidgin.im>
parents: 23731
diff changeset
275 return (JingleSession *) (js->sessions) ?
3fc0e49509bb Fix assertion.
Michael Ruprecht <maiku@pidgin.im>
parents: 23731
diff changeset
276 g_hash_table_lookup(js->sessions, id) : NULL;
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
277 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
278
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
279 static JingleSession *
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
280 jabber_jingle_session_find_by_jid(JabberStream *js, const char *jid)
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
281 {
26110
86dfa5f98a31 Remove warning.
Michael Ruprecht <maiku@pidgin.im>
parents: 26109
diff changeset
282 GList *values = (js->sessions) ?
86dfa5f98a31 Remove warning.
Michael Ruprecht <maiku@pidgin.im>
parents: 26109
diff changeset
283 g_hash_table_get_values(js->sessions) : NULL;
23711
c5058fc31d26 Free the PurpleMedia object when the media session ends and fix ending
Michael Ruprecht <maiku@pidgin.im>
parents: 23704
diff changeset
284 gboolean use_bare = strchr(jid, '/') == NULL;
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
285
23752
d573c980437e Fixed some memory leak issues involving GLists.
Michael Ruprecht <maiku@pidgin.im>
parents: 23750
diff changeset
286 for (; values; values = g_list_delete_link(values, values)) {
d573c980437e Fixed some memory leak issues involving GLists.
Michael Ruprecht <maiku@pidgin.im>
parents: 23750
diff changeset
287 JingleSession *session = (JingleSession *)values->data;
23711
c5058fc31d26 Free the PurpleMedia object when the media session ends and fix ending
Michael Ruprecht <maiku@pidgin.im>
parents: 23704
diff changeset
288 gchar *cmp_jid = use_bare ? jabber_get_bare_jid(session->remote_jid)
c5058fc31d26 Free the PurpleMedia object when the media session ends and fix ending
Michael Ruprecht <maiku@pidgin.im>
parents: 23704
diff changeset
289 : g_strdup(session->remote_jid);
c5058fc31d26 Free the PurpleMedia object when the media session ends and fix ending
Michael Ruprecht <maiku@pidgin.im>
parents: 23704
diff changeset
290 if (!strcmp(jid, cmp_jid)) {
c5058fc31d26 Free the PurpleMedia object when the media session ends and fix ending
Michael Ruprecht <maiku@pidgin.im>
parents: 23704
diff changeset
291 g_free(cmp_jid);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
292 g_list_free(values);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
293 return session;
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
294 }
23711
c5058fc31d26 Free the PurpleMedia object when the media session ends and fix ending
Michael Ruprecht <maiku@pidgin.im>
parents: 23704
diff changeset
295 g_free(cmp_jid);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
296 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
297
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
298 return NULL;
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
299 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
300
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
301 static GList *
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
302 jabber_jingle_get_codecs(xmlnode *description)
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
303 {
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
304 GList *codecs = NULL;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
305 xmlnode *codec_element = NULL;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
306 const char *encoding_name,*id, *clock_rate;
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
307 FsCodec *codec;
23725
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
308 const gchar *media = xmlnode_get_attrib(description, "media");
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
309 FsMediaType type = !strcmp(media, "video") ? FS_MEDIA_TYPE_VIDEO :
26121
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26116
diff changeset
310 !strcmp(media, "audio") ? FS_MEDIA_TYPE_AUDIO : 0;
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
311
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
312 for (codec_element = xmlnode_get_child(description, "payload-type") ;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
313 codec_element ;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
314 codec_element = xmlnode_get_next_twin(codec_element)) {
26136
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
315 xmlnode *param;
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
316 gchar *codec_str;
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
317 encoding_name = xmlnode_get_attrib(codec_element, "name");
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
318
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
319 id = xmlnode_get_attrib(codec_element, "id");
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
320 clock_rate = xmlnode_get_attrib(codec_element, "clockrate");
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
321
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
322 codec = fs_codec_new(atoi(id), encoding_name,
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
323 type,
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
324 clock_rate ? atoi(clock_rate) : 0);
26136
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
325
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
326 for (param = xmlnode_get_child(codec_element, "parameter");
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
327 param; param = xmlnode_get_next_twin(param)) {
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
328 fs_codec_add_optional_parameter(codec,
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
329 xmlnode_get_attrib(param, "name"),
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
330 xmlnode_get_attrib(param, "value"));
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
331 }
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
332
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
333 codec_str = fs_codec_to_string(codec);
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
334 purple_debug_fatal("jingle", "received codec: %s\n", codec_str);
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
335 g_free(codec_str);
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
336
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
337 codecs = g_list_append(codecs, codec);
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
338 }
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
339 return codecs;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
340 }
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
341
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
342 static GList *
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
343 jabber_jingle_get_candidates(const xmlnode *transport)
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
344 {
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
345 GList *candidates = NULL;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
346 xmlnode *candidate = NULL;
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
347 FsCandidate *c;
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
348
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
349 for (candidate = xmlnode_get_child(transport, "candidate") ;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
350 candidate ;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
351 candidate = xmlnode_get_next_twin(candidate)) {
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
352 const char *type = xmlnode_get_attrib(candidate, "type");
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
353 c = fs_candidate_new(xmlnode_get_attrib(candidate, "component"),
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
354 atoi(xmlnode_get_attrib(candidate, "component")),
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
355 strcmp(type, "host") == 0 ?
23719
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
356 FS_CANDIDATE_TYPE_HOST :
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
357 strcmp(type, "prflx") == 0 ?
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
358 FS_CANDIDATE_TYPE_PRFLX :
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
359 strcmp(type, "relay") == 0 ?
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
360 FS_CANDIDATE_TYPE_RELAY :
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
361 strcmp(type, "srflx") == 0 ?
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
362 FS_CANDIDATE_TYPE_SRFLX : 0,
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
363 strcmp(xmlnode_get_attrib(candidate, "protocol"),
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
364 "udp") == 0 ?
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
365 FS_NETWORK_PROTOCOL_UDP :
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
366 FS_NETWORK_PROTOCOL_TCP,
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
367 xmlnode_get_attrib(candidate, "ip"),
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
368 atoi(xmlnode_get_attrib(candidate, "port")));
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
369 candidates = g_list_append(candidates, c);
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
370 }
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
371
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
372 return candidates;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
373 }
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
374
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
375 static JingleSessionContent *
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
376 jabber_jingle_session_get_content(const JingleSession *session,
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
377 const char *name)
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
378 {
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
379 return (JingleSession *) name ?
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
380 g_hash_table_lookup(session->contents, name) : NULL;
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
381 }
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
382
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
383 static GList *
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
384 jabber_jingle_session_get_contents(const JingleSession *session)
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
385 {
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
386 return g_hash_table_get_values(session->contents);
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
387 }
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
388
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
389 static PurpleMedia *
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
390 jabber_jingle_session_get_media(const JingleSession *sess)
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
391 {
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
392 return sess->media;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
393 }
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
394
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
395 static void
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
396 jabber_jingle_session_set_media(JingleSession *sess, PurpleMedia *media)
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
397 {
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
398 sess->media = media;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
399 }
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
400
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
401 static const char *
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
402 jabber_jingle_session_get_remote_jid(const JingleSession *sess)
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
403 {
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
404 return sess->remote_jid;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
405 }
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
406
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
407 static void
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
408 jabber_jingle_session_set_remote_jid(JingleSession *sess,
26116
41f7d4545566 Fixed a ton of memory leaks.
Michael Ruprecht <maiku@pidgin.im>
parents: 26113
diff changeset
409 const char *remote_jid)
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
410 {
26116
41f7d4545566 Fixed a ton of memory leaks.
Michael Ruprecht <maiku@pidgin.im>
parents: 26113
diff changeset
411 if (sess->remote_jid)
41f7d4545566 Fixed a ton of memory leaks.
Michael Ruprecht <maiku@pidgin.im>
parents: 26113
diff changeset
412 g_free(sess->remote_jid);
41f7d4545566 Fixed a ton of memory leaks.
Michael Ruprecht <maiku@pidgin.im>
parents: 26113
diff changeset
413 sess->remote_jid = g_strdup(remote_jid);
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
414 }
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
415
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
416 static JingleSessionState
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
417 jabber_jingle_session_get_state(JingleSession *sess)
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
418 {
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
419 return sess->state;
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
420 }
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
421
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
422 static void
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
423 jabber_jingle_session_set_state(JingleSession *sess,
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
424 JingleSessionState state)
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
425 {
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
426 sess->state = state;
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
427 }
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
428
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
429
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
430 static const char *
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
431 jabber_jingle_session_get_initiator(const JingleSession *sess)
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
432 {
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
433 return sess->initiator;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
434 }
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
435
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
436 static void
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
437 jabber_jingle_session_set_initiator(JingleSession *sess,
26116
41f7d4545566 Fixed a ton of memory leaks.
Michael Ruprecht <maiku@pidgin.im>
parents: 26113
diff changeset
438 const char *initiator)
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
439 {
26116
41f7d4545566 Fixed a ton of memory leaks.
Michael Ruprecht <maiku@pidgin.im>
parents: 26113
diff changeset
440 if (sess->initiator)
41f7d4545566 Fixed a ton of memory leaks.
Michael Ruprecht <maiku@pidgin.im>
parents: 26113
diff changeset
441 g_free(sess->initiator);
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
442 sess->initiator = g_strdup(initiator);
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
443 }
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
444
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
445 static gboolean
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
446 jabber_jingle_session_is_initiator(const JingleSession *sess)
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
447 {
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
448 return sess->is_initiator;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
449 }
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
450
23719
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
451 static void
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
452 jabber_jingle_session_add_payload_types(const JingleSessionContent *jsc,
23731
a913de187f53 Send negotiated codecs in session-accept opposed to all local codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 23730
diff changeset
453 xmlnode *description,
a913de187f53 Send negotiated codecs in session-accept opposed to all local codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 23730
diff changeset
454 GList *codecs)
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
455 {
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
456 for (; codecs ; codecs = codecs->next) {
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
457 FsCodec *codec = (FsCodec*)codecs->data;
26136
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
458 GList *iter = codec->optional_params;
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
459 char id[8], clockrate[10], channels[10];
26136
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
460 gchar *codec_str;
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
461 xmlnode *payload = xmlnode_new_child(description, "payload-type");
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
462
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
463 g_snprintf(id, sizeof(id), "%d", codec->id);
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
464 g_snprintf(clockrate, sizeof(clockrate), "%d", codec->clock_rate);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
465 g_snprintf(channels, sizeof(channels), "%d", codec->channels);
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
466
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
467 xmlnode_set_attrib(payload, "name", codec->encoding_name);
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
468 xmlnode_set_attrib(payload, "id", id);
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
469 xmlnode_set_attrib(payload, "clockrate", clockrate);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
470 xmlnode_set_attrib(payload, "channels", channels);
26136
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
471
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
472 for (; iter; iter = g_list_next(iter)) {
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
473 FsCodecParameter *fsparam = iter->data;
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
474 xmlnode *param = xmlnode_new_child(payload, "parameter");
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
475 xmlnode_set_attrib(param, "name", fsparam->name);
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
476 xmlnode_set_attrib(param, "value", fsparam->value);
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
477 }
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
478
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
479 codec_str = fs_codec_to_string(codec);
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
480 purple_debug_fatal("jingle", "adding codec: %s\n", codec_str);
ed796f2ff697 Send and receive optional codec parameters in Jingle RTP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
481 g_free(codec_str);
23719
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
482 }
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
483 }
23719
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
484
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
485 static xmlnode *
23719
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
486 jabber_jingle_session_add_description_vv(const JingleSessionContent *jsc,
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
487 xmlnode *description)
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
488 {
23725
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
489 xmlnode_set_attrib(description, "media",
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
490 jabber_jingle_session_content_get_subtype(jsc));
23719
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
491 return description;
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
492 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
493
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
494 static xmlnode *
23719
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
495 jabber_jingle_session_add_description(const JingleSessionContent *jsc,
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
496 xmlnode *content)
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
497 {
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
498 xmlnode *description = xmlnode_new_child(content, "description");
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
499 xmlnode_set_namespace(description,
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
500 jabber_jingle_session_content_get_type(jsc));
23719
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
501
23725
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
502 if (jabber_jingle_session_content_is_type(jsc, JINGLE_RTP))
23719
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
503 return jabber_jingle_session_add_description_vv(jsc, description);
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
504 else
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
505 return description;
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
506 }
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
507
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
508 static xmlnode *
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
509 jabber_jingle_session_add_candidate_iceudp(xmlnode *transport,
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
510 FsCandidate *c,
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
511 FsCandidate *remote)
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
512 {
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
513 char port[8];
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
514 char prio[8];
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
515 char component[8];
23719
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
516 xmlnode *candidate = xmlnode_new_child(transport, "candidate");
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
517
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
518 g_snprintf(port, sizeof(port), "%d", c->port);
23719
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
519 g_snprintf(prio, sizeof(prio), "%d", c->priority);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
520 g_snprintf(component, sizeof(component), "%d", c->component_id);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
521
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
522 xmlnode_set_attrib(candidate, "component", component);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
523 xmlnode_set_attrib(candidate, "foundation", "1"); /* what about this? */
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
524 xmlnode_set_attrib(candidate, "generation", "0"); /* ? */
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
525 xmlnode_set_attrib(candidate, "ip", c->ip);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
526 xmlnode_set_attrib(candidate, "network", "0"); /* ? */
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
527 xmlnode_set_attrib(candidate, "port", port);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
528 xmlnode_set_attrib(candidate, "priority", prio); /* Is this correct? */
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
529 xmlnode_set_attrib(candidate, "protocol",
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
530 c->proto == FS_NETWORK_PROTOCOL_UDP ?
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
531 "udp" : "tcp");
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
532 if (c->username)
23719
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
533 xmlnode_set_attrib(transport, "ufrag", c->username);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
534 if (c->password)
23719
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
535 xmlnode_set_attrib(transport, "pwd", c->password);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
536
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
537 xmlnode_set_attrib(candidate, "type",
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
538 c->type == FS_CANDIDATE_TYPE_HOST ?
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
539 "host" :
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
540 c->type == FS_CANDIDATE_TYPE_PRFLX ?
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
541 "prflx" :
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
542 c->type == FS_CANDIDATE_TYPE_RELAY ?
23719
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
543 "relay" :
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
544 c->type == FS_CANDIDATE_TYPE_SRFLX ?
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
545 "srflx" : NULL);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
546
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
547 /* relay */
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
548 if (c->type == FS_CANDIDATE_TYPE_RELAY) {
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
549 /* set rel-addr and rel-port? How? */
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
550 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
551
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
552 if (remote) {
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
553 char remote_port[8];
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
554 g_snprintf(remote_port, sizeof(remote_port), "%d", remote->port);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
555 xmlnode_set_attrib(candidate, "rem-addr", remote->ip);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
556 xmlnode_set_attrib(candidate, "rem-port", remote_port);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
557 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
558
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
559 return candidate;
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
560 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
561
23719
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
562 static xmlnode *
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
563 jabber_jingle_session_add_transport(const JingleSessionContent *jsc,
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
564 xmlnode *content)
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
565 {
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
566 xmlnode *transport = xmlnode_new_child(content, "transport");
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
567 const gchar *transport_type = jabber_jingle_session_content_get_transport_type(jsc);
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
568 xmlnode_set_namespace(transport, transport_type);
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
569 return transport;
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
570 }
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
571
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
572 static xmlnode *
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
573 jabber_jingle_session_add_content(const JingleSessionContent *jsc,
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
574 xmlnode *jingle)
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
575 {
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
576 xmlnode *content = xmlnode_new_child(jingle, "content");
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
577 xmlnode_set_attrib(content, "creator",
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
578 jabber_jingle_session_content_get_creator(jsc));
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
579 xmlnode_set_attrib(content, "name",
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
580 jabber_jingle_session_content_get_name(jsc));
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
581 xmlnode_set_attrib(content, "sender",
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
582 jabber_jingle_session_content_get_sender(jsc));
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
583 return content;
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
584 }
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
585
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
586
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
587 static xmlnode *
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
588 jabber_jingle_session_add_jingle(const JingleSession *sess,
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
589 JabberIq *iq, const char *action)
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
590 {
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
591 xmlnode *jingle = iq ? xmlnode_new_child(iq->node, "jingle") :
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
592 xmlnode_new("jingle");
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
593 xmlnode_set_namespace(jingle, JINGLE);
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
594 xmlnode_set_attrib(jingle, "action", action);
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
595 xmlnode_set_attrib(jingle, "initiator",
23719
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
596 jabber_jingle_session_get_initiator(sess));
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
597 if (jabber_jingle_session_is_initiator(sess))
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
598 xmlnode_set_attrib(jingle, "responder",
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
599 jabber_jingle_session_get_remote_jid(sess));
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
600 else {
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
601 gchar *responder = g_strdup_printf("%s@%s/%s",
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
602 sess->js->user->node,
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
603 sess->js->user->domain,
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
604 sess->js->user->resource);
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
605 xmlnode_set_attrib(jingle, "responder", responder);
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
606 g_free(responder);
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
607 }
23719
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
608 xmlnode_set_attrib(jingle, "sid", jabber_jingle_session_get_id(sess));
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
609
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
610 return jingle;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
611 }
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
612
23719
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
613 static JabberIq *
23749
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
614 jabber_jingle_session_create_ack(JingleSession *session, xmlnode *jingle)
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
615 {
23749
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
616 JabberIq *result = jabber_iq_new(
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
617 jabber_jingle_session_get_js(session),
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
618 JABBER_IQ_RESULT);
23750
57baab09bf45 Added xmlnode_get_parent.
Michael Ruprecht <maiku@pidgin.im>
parents: 23749
diff changeset
619 xmlnode *packet = xmlnode_get_parent(jingle);
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
620 jabber_iq_set_id(result, xmlnode_get_attrib(packet, "id"));
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
621 xmlnode_set_attrib(result->node, "from", xmlnode_get_attrib(packet, "to"));
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
622 xmlnode_set_attrib(result->node, "to", xmlnode_get_attrib(packet, "from"));
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
623 return result;
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
624 }
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
625
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
626 static JabberIq *
23719
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
627 jabber_jingle_session_create_iq(const JingleSession *session)
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
628 {
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
629 JabberIq *result = jabber_iq_new(jabber_jingle_session_get_js(session),
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
630 JABBER_IQ_SET);
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
631 gchar *from = g_strdup_printf("%s@%s/%s", session->js->user->node,
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
632 session->js->user->domain,
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
633 session->js->user->resource);
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
634 xmlnode_set_attrib(result->node, "from", from);
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
635 g_free(from);
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
636 xmlnode_set_attrib(result->node, "to",
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
637 jabber_jingle_session_get_remote_jid(session));
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
638 return result;
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
639 }
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
640 #if 0
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
641 static xmlnode *
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
642 jabber_jingle_session_create_content_accept(const JingleSession *sess)
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
643 {
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
644 xmlnode *jingle =
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
645 jabber_jingle_session_add_jingle(sess, NULL, "content-accept");
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
646
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
647 xmlnode *content = xmlnode_new_child(jingle, "content");
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
648 xmlnode *description = jabber_jingle_session_create_description(sess);
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
649
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
650 xmlnode_set_attrib(content, "creator", "initiator");
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
651 xmlnode_set_attrib(content, "name", "audio-content");
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
652 xmlnode_set_attrib(content, "profile", "RTP/AVP");
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
653
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
654 xmlnode_insert_child(content, description);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
655
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
656 return jingle;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
657 }
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
658
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
659 static xmlnode *
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
660 jabber_jingle_session_create_content_replace(const JingleSession *sess,
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
661 FsCandidate *native_candidate,
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
662 FsCandidate *remote_candidate)
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
663 {
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
664 xmlnode *jingle =
23719
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
665 jabber_jingle_session_add_jingle(sess, NULL, "content-replace");
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
666 xmlnode *content = NULL;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
667 xmlnode *transport = NULL;
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
668
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
669 purple_debug_info("jingle", "creating content-modify for native candidate %s " \
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
670 ", remote candidate %s\n", native_candidate->candidate_id,
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
671 remote_candidate->candidate_id);
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
672
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
673 content = xmlnode_new_child(jingle, "content");
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
674 xmlnode_set_attrib(content, "creator", "initiator");
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
675 xmlnode_set_attrib(content, "name", "audio-content");
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
676 xmlnode_set_attrib(content, "profile", "RTP/AVP");
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
677
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
678 /* get top codec from codec_intersection to put here... */
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
679 /* later on this should probably handle changing codec */
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
680
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
681 xmlnode_insert_child(content, jabber_jingle_session_create_description(sess));
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
682
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
683 transport = xmlnode_new_child(content, "transport");
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
684 xmlnode_set_namespace(transport, TRANSPORT_ICEUDP);
23719
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
685 jabber_jingle_session_add_candidate_iceudp(transport, native_candidate,
444a2ca670af Added functions to help with the creation of Jingle packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 23718
diff changeset
686 remote_candidate);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22649
diff changeset
687
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
688 purple_debug_info("jingle", "End create content modify\n");
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
689
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
690 return jingle;
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
691 }
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
692 #endif
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
693
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
694 static JabberIq *
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
695 jabber_jingle_session_create_session_accept(const JingleSession *session)
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
696 {
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
697 PurpleMedia *media = jabber_jingle_session_get_media(session);
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
698 const gchar *remote_jid = jabber_jingle_session_get_remote_jid(session);
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
699 JabberIq *request = jabber_jingle_session_create_iq(session);
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
700 xmlnode *jingle =
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
701 jabber_jingle_session_add_jingle(session, request,
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
702 "session-accept");
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
703 GList *contents = jabber_jingle_session_get_contents(session);
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
704
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
705 for (; contents; contents = contents->next) {
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
706 JingleSessionContent *jsc = contents->data;
23731
a913de187f53 Send negotiated codecs in session-accept opposed to all local codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 23730
diff changeset
707 const gchar *content_name = jabber_jingle_session_content_get_name(jsc);
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
708 xmlnode *content = jabber_jingle_session_add_content(jsc, jingle);
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
709 xmlnode *description = jabber_jingle_session_add_description(jsc, content);
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
710 xmlnode *transport = jabber_jingle_session_add_transport(jsc, content);
23731
a913de187f53 Send negotiated codecs in session-accept opposed to all local codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 23730
diff changeset
711 if (jabber_jingle_session_content_is_type(jsc, JINGLE_RTP)) {
a913de187f53 Send negotiated codecs in session-accept opposed to all local codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 23730
diff changeset
712 GList *codecs = purple_media_get_negotiated_codecs(media,
a913de187f53 Send negotiated codecs in session-accept opposed to all local codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 23730
diff changeset
713 content_name);
a913de187f53 Send negotiated codecs in session-accept opposed to all local codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 23730
diff changeset
714 jabber_jingle_session_add_payload_types(jsc, description, codecs);
a913de187f53 Send negotiated codecs in session-accept opposed to all local codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 23730
diff changeset
715 fs_codec_list_destroy(codecs);
a913de187f53 Send negotiated codecs in session-accept opposed to all local codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 23730
diff changeset
716 }
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
717 if (jabber_jingle_session_content_is_transport_type(jsc, TRANSPORT_ICEUDP)) {
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
718 jabber_jingle_session_add_candidate_iceudp(transport,
23731
a913de187f53 Send negotiated codecs in session-accept opposed to all local codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 23730
diff changeset
719 purple_media_get_local_candidate(media, content_name,
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
720 remote_jid),
23731
a913de187f53 Send negotiated codecs in session-accept opposed to all local codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 23730
diff changeset
721 purple_media_get_remote_candidate(media, content_name,
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
722 remote_jid));
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
723 }
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
724 }
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
725
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
726 return request;
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
727 }
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
728
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
729 static JabberIq *
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
730 jabber_jingle_session_create_session_info(const JingleSession *session,
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
731 const gchar *type)
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
732 {
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
733 JabberIq *request = jabber_jingle_session_create_iq(session);
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
734 xmlnode *jingle =
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
735 jabber_jingle_session_add_jingle(session, request,
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
736 "session-info");
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
737 xmlnode *info = xmlnode_new_child(jingle, type);
23725
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
738 xmlnode_set_namespace(info, JINGLE_RTP_INFO);
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
739 return request;
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
740 }
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
741
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
742 static JabberIq *
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
743 jabber_jingle_session_create_session_initiate(const JingleSession *session)
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
744 {
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
745 JabberIq *request = jabber_jingle_session_create_iq(session);
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
746 xmlnode *jingle =
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
747 jabber_jingle_session_add_jingle(session, request,
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
748 "session-initiate");
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
749 GList *contents = jabber_jingle_session_get_contents(session);
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
750
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
751 for (; contents; contents = contents->next) {
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
752 JingleSessionContent *jsc = contents->data;
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
753 xmlnode *content = jabber_jingle_session_add_content(jsc, jingle);
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
754 xmlnode *description = jabber_jingle_session_add_description(jsc, content);
23731
a913de187f53 Send negotiated codecs in session-accept opposed to all local codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 23730
diff changeset
755 if (jabber_jingle_session_content_is_type(jsc, JINGLE_RTP)) {
a913de187f53 Send negotiated codecs in session-accept opposed to all local codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 23730
diff changeset
756 PurpleMedia *media = jabber_jingle_session_get_media(session);
a913de187f53 Send negotiated codecs in session-accept opposed to all local codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 23730
diff changeset
757 const gchar *content_name =
a913de187f53 Send negotiated codecs in session-accept opposed to all local codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 23730
diff changeset
758 jabber_jingle_session_content_get_name(jsc);
a913de187f53 Send negotiated codecs in session-accept opposed to all local codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 23730
diff changeset
759 GList *codecs = purple_media_get_local_codecs(media, content_name);
a913de187f53 Send negotiated codecs in session-accept opposed to all local codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 23730
diff changeset
760 jabber_jingle_session_add_payload_types(jsc, description, codecs);
a913de187f53 Send negotiated codecs in session-accept opposed to all local codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 23730
diff changeset
761 fs_codec_list_destroy(codecs);
a913de187f53 Send negotiated codecs in session-accept opposed to all local codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 23730
diff changeset
762 }
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
763 jabber_jingle_session_add_transport(jsc, content);
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
764 }
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
765
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
766 return request;
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
767 }
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
768
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
769 static JabberIq *
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
770 jabber_jingle_session_create_session_terminate(const JingleSession *sess,
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
771 const char *reasoncode,
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
772 const char *reasontext)
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
773 {
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
774 JabberIq *request = jabber_jingle_session_create_iq(sess);
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
775 xmlnode *jingle =
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
776 jabber_jingle_session_add_jingle(sess, request,
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
777 "session-terminate");
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
778 xmlnode *reason = xmlnode_new_child(jingle, "reason");
26104
fa46c1601fa3 Update Jingle implementation per recent standard changes.
Michael Ruprecht <maiku@pidgin.im>
parents: 26102
diff changeset
779 xmlnode_new_child(reason, reasoncode);
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
780 if (reasontext) {
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
781 xmlnode *text = xmlnode_new_child(reason, "text");
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
782 xmlnode_insert_data(text, reasontext, strlen(reasontext));
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
783 }
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
784
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
785 return request;
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
786 }
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
787
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
788 static JabberIq *
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
789 jabber_jingle_session_create_transport_info(const JingleSessionContent *jsc,
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
790 FsCandidate *candidate)
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
791 {
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
792 JingleSession *session =
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
793 jabber_jingle_session_content_get_session(jsc);
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
794 JabberIq *request = jabber_jingle_session_create_iq(session);
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
795 xmlnode *jingle =
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
796 jabber_jingle_session_add_jingle(session, request,
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
797 "transport-info");
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
798 xmlnode *content = jabber_jingle_session_add_content(jsc, jingle);
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
799 xmlnode *transport = jabber_jingle_session_add_transport(jsc, content);
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
800 jabber_jingle_session_add_candidate_iceudp(transport, candidate, NULL);
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
801 return request;
22649
d29483a90e40 Add the new jingle.c/h files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
802 }
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
803 #if 0
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
804 static void
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
805 jabber_jingle_session_send_content_accept(JingleSession *session)
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
806 {
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
807 JabberIq *result = jabber_iq_new(jabber_jingle_session_get_js(session),
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
808 JABBER_IQ_SET);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
809 xmlnode *jingle = jabber_jingle_session_create_content_accept(session);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
810 xmlnode_set_attrib(result->node, "to",
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
811 jabber_jingle_session_get_remote_jid(session));
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
812
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
813 xmlnode_insert_child(result->node, jingle);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
814 jabber_iq_send(result);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
815 }
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
816 #endif
26137
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
817
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
818 static void
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
819 jabber_jingle_session_accept(JingleSession *session)
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
820 {
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
821 if (jabber_jingle_session_get_state(session) == ACCEPTED &&
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
822 purple_media_candidates_prepared(
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
823 jabber_jingle_session_get_media(session),
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
824 jabber_jingle_session_get_remote_jid(session))) {
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
825 jabber_iq_send(jabber_jingle_session_create_session_accept(session));
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
826
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
827 purple_debug_info("jingle", "Sent session accept.\n");
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
828 jabber_jingle_session_set_state(session, ACTIVE);
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
829 }
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
830 }
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
831
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
832 static void
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
833 jabber_jingle_session_send_session_accept(JingleSession *session)
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
834 {
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
835 /* create transport-info packages */
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
836 PurpleMedia *media = jabber_jingle_session_get_media(session);
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
837 GList *contents = jabber_jingle_session_get_contents(session);
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
838 const gchar *remote_jid = jabber_jingle_session_get_remote_jid(session);
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
839 for (; contents; contents = contents->next) {
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
840 JingleSessionContent *jsc = contents->data;
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
841 GList *candidates = purple_media_get_local_candidates(
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
842 media,
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
843 jabber_jingle_session_content_get_name(jsc),
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
844 remote_jid);
23723
3f244db116fc merge of '15285d082f6cc90fa25cd27ccdac3b602e8a1f18'
Michael Ruprecht <maiku@pidgin.im>
parents: 23721 23722
diff changeset
845 purple_debug_info("jingle",
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
846 "jabber_session_candidates_prepared: %d candidates\n",
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
847 g_list_length(candidates));
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
848 for (; candidates; candidates = candidates->next) {
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
849 FsCandidate *candidate = candidates->data;
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
850 JabberIq *result = jabber_jingle_session_create_transport_info(jsc,
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
851 candidate);
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
852 jabber_iq_send(result);
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
853 }
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
854 fs_candidate_list_destroy(candidates);
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
855
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
856 purple_debug_info("jingle", "codec intersection: %i\n",
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
857 g_list_length(purple_media_get_negotiated_codecs(media,
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
858 jabber_jingle_session_content_get_name(jsc))));
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
859 }
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
860
26137
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
861 jabber_jingle_session_set_state(session, ACCEPTED);
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
862 jabber_jingle_session_accept(session);
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
863 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
864
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
865 static void
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
866 jabber_jingle_session_send_session_reject(JingleSession *session)
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
867 {
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
868 jabber_iq_send(jabber_jingle_session_create_session_terminate(session,
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
869 "decline", NULL));
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
870 jabber_jingle_session_destroy(session);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
871 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
872
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
873 static void
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
874 jabber_jingle_session_send_session_terminate(JingleSession *session)
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
875 {
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
876 jabber_iq_send(jabber_jingle_session_create_session_terminate(session,
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
877 "no-error", NULL));
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
878 jabber_jingle_session_destroy(session);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
879 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
880
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
881 static void
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
882 jabber_jingle_session_content_create_media(JingleSession *session,
26108
8d0fd2f195aa Changed PurpleMediaStreamType to PurpleMediaSessionType.
Michael Ruprecht <maiku@pidgin.im>
parents: 26104
diff changeset
883 PurpleMediaSessionType type)
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
884 {
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
885 gchar sender[10] = "";
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
886
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
887 if (type & PURPLE_MEDIA_AUDIO) {
26113
ad871f934f18 Decouple stream direction. Allows send only or recv only streams.
Michael Ruprecht <maiku@pidgin.im>
parents: 26111
diff changeset
888 if ((type & PURPLE_MEDIA_AUDIO) == PURPLE_MEDIA_SEND_AUDIO)
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
889 strcpy(sender, "initiator");
26113
ad871f934f18 Decouple stream direction. Allows send only or recv only streams.
Michael Ruprecht <maiku@pidgin.im>
parents: 26111
diff changeset
890 else if ((type & PURPLE_MEDIA_AUDIO) == PURPLE_MEDIA_RECV_AUDIO)
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
891 strcpy(sender, "responder");
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
892 else
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
893 strcpy(sender, "both");
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
894 jabber_jingle_session_content_create_internal(session,
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
895 "audio-content", "initiator", sender,
23725
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
896 TRANSPORT_ICEUDP, JINGLE_RTP, "audio");
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
897 }
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
898 if (type & PURPLE_MEDIA_VIDEO) {
26113
ad871f934f18 Decouple stream direction. Allows send only or recv only streams.
Michael Ruprecht <maiku@pidgin.im>
parents: 26111
diff changeset
899 if ((type & PURPLE_MEDIA_VIDEO) == PURPLE_MEDIA_SEND_VIDEO)
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
900 strcpy(sender, "initiator");
26113
ad871f934f18 Decouple stream direction. Allows send only or recv only streams.
Michael Ruprecht <maiku@pidgin.im>
parents: 26111
diff changeset
901 else if ((type & PURPLE_MEDIA_VIDEO) == PURPLE_MEDIA_RECV_VIDEO)
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
902 strcpy(sender, "responder");
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
903 else
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
904 strcpy(sender, "both");
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
905 jabber_jingle_session_content_create_internal(session,
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
906 "video-content", "initiator", sender,
23725
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
907 TRANSPORT_ICEUDP, JINGLE_RTP, "video");
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
908 }
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
909 }
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
910
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
911 static void
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
912 jabber_jingle_session_content_create_parse(JingleSession *session,
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
913 xmlnode *content)
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
914 {
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
915 xmlnode *description = xmlnode_get_child(content, "description");
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
916 xmlnode *transport = xmlnode_get_child(content, "transport");
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
917
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
918 const gchar *creator = xmlnode_get_attrib(content, "creator");
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
919 const gchar *sender = xmlnode_get_attrib(content, "sender");
23725
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
920 const gchar *subtype = xmlnode_get_attrib(description, "media");
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
921
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
922 jabber_jingle_session_content_create_internal(session,
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
923 xmlnode_get_attrib(content, "name"),
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
924 creator ? creator : "initiator",
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
925 sender ? sender : "both",
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
926 xmlnode_get_namespace(transport),
23725
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
927 xmlnode_get_namespace(description),
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
928 subtype);
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
929 }
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
930
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
931 static void
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
932 jabber_jingle_session_new_candidate_cb(PurpleMedia *media,
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
933 const gchar *session_id,
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
934 const gchar *name,
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
935 FsCandidate *candidate,
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
936 JingleSession *session)
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
937 {
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
938 if (jabber_jingle_session_get_state(session) == GOT_ACK ||
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
939 jabber_jingle_session_get_state(session) == ACTIVE) {
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
940 JingleSessionContent *jsc = jabber_jingle_session_get_content(session,
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
941 session_id);
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
942 jabber_iq_send(jabber_jingle_session_create_transport_info(jsc,
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
943 candidate));
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
944 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
945 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
946
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
947 /* callback called when a pair of transport candidates (local and remote)
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
948 has been established */
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
949 static void
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
950 jabber_jingle_session_candidate_pair_established_cb(PurpleMedia *media,
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
951 FsCandidate *native_candidate,
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
952 FsCandidate *remote_candidate,
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
953 JingleSession *session)
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
954 {
26137
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
955 if (!jabber_jingle_session_is_initiator(session)) {
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
956 jabber_jingle_session_accept(session);
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
957 }
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
958 }
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
959
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
960 static void
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
961 jabber_jingle_session_initiate_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
962 {
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
963 const char *from = xmlnode_get_attrib(packet, "from");
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
964 JingleSession *session = jabber_jingle_session_find_by_jid(js, from);
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
965 PurpleMedia *media;
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
966 GList *contents;
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
967
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
968 if (!session) {
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
969 /* respond with an error here */
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
970 purple_debug_error("jingle", "Received session-initiate ack"
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
971 " to nonexistent session\n");
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
972 return;
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
973 }
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
974
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
975 media = session->media;
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
976
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
977 if (!strcmp(xmlnode_get_attrib(packet, "type"), "error")) {
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
978 purple_media_got_hangup(media);
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
979 return;
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
980 }
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
981
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
982 /* catch errors */
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
983 if (xmlnode_get_child(packet, "error")) {
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
984 purple_media_got_hangup(media);
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
985 return;
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
986 }
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
987
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
988 /* create transport-info packages */
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
989 contents = jabber_jingle_session_get_contents(session);
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
990 for (; contents; contents = contents->next) {
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
991 JingleSessionContent *jsc = contents->data;
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
992 GList *candidates = purple_media_get_local_candidates(
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
993 jabber_jingle_session_get_media(session),
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
994 jabber_jingle_session_content_get_name(jsc),
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
995 jabber_jingle_session_get_remote_jid(session));
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
996 purple_debug_info("jingle",
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
997 "jabber_session_candidates_prepared: %d candidates\n",
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
998 g_list_length(candidates));
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
999 for (; candidates; candidates = candidates->next) {
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1000 FsCandidate *candidate = candidates->data;
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1001 JabberIq *result = jabber_jingle_session_create_transport_info(jsc,
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1002 candidate);
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1003 jabber_iq_send(result);
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1004 }
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1005 fs_candidate_list_destroy(candidates);
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1006 }
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1007
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1008 jabber_jingle_session_set_state(session, GOT_ACK);
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1009 }
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1010
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1011 static void
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1012 jabber_jingle_session_codecs_ready_cb(PurpleMedia *media,
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1013 const gchar *sess_id,
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1014 JingleSession *session)
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1015 {
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1016 GList *contents = jabber_jingle_session_get_contents(session);
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1017 for (; contents; contents = g_list_delete_link(contents, contents)) {
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1018 JingleSessionContent *jsc = contents->data;
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1019 if (!purple_media_codecs_ready(media,
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1020 jabber_jingle_session_content_get_name(jsc))) {
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1021 break;
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1022 }
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1023 }
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1024
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1025 if (contents != NULL)
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1026 g_list_free(contents);
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1027 else if (jabber_jingle_session_is_initiator(session)
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1028 && jabber_jingle_session_get_state(session) == PENDING) {
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1029 JabberIq *request;
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1030
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1031 /* create request */
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1032 request = jabber_jingle_session_create_session_initiate(session);
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1033 jabber_iq_set_callback(request, jabber_jingle_session_initiate_result_cb, NULL);
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1034
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1035 /* send request to other part */
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1036 jabber_iq_send(request);
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1037 } else {
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1038 jabber_jingle_session_accept(session);
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1039 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1040 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1041
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1042 static gboolean
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1043 jabber_jingle_session_initiate_media_internal(JingleSession *session,
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1044 const char *initiator,
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1045 const char *remote_jid)
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1046 {
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1047 PurpleMedia *media = NULL;
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1048 GList *contents = jabber_jingle_session_get_contents(session);
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1049
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1050 media = purple_media_manager_create_media(purple_media_manager_get(),
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1051 session->js->gc, "fsrtpconference", remote_jid);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1052
26111
d25772351a75 Stop additional media sessions within a single conversation for grouped contacts.
Michael Ruprecht <maiku@pidgin.im>
parents: 26110
diff changeset
1053 jabber_jingle_session_set_remote_jid(session, remote_jid);
d25772351a75 Stop additional media sessions within a single conversation for grouped contacts.
Michael Ruprecht <maiku@pidgin.im>
parents: 26110
diff changeset
1054 jabber_jingle_session_set_initiator(session, initiator);
d25772351a75 Stop additional media sessions within a single conversation for grouped contacts.
Michael Ruprecht <maiku@pidgin.im>
parents: 26110
diff changeset
1055
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1056 if (!media) {
26111
d25772351a75 Stop additional media sessions within a single conversation for grouped contacts.
Michael Ruprecht <maiku@pidgin.im>
parents: 26110
diff changeset
1057 purple_debug_error("jingle", "Couldn't create media session\n");
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1058 return FALSE;
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1059 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1060
26129
18c8f2cfb52b Properly free PurpleMedia when there's an error creating an FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26121
diff changeset
1061 jabber_jingle_session_set_media(session, media);
18c8f2cfb52b Properly free PurpleMedia when there's an error creating an FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26121
diff changeset
1062
23752
d573c980437e Fixed some memory leak issues involving GLists.
Michael Ruprecht <maiku@pidgin.im>
parents: 23750
diff changeset
1063 for (; contents; contents = g_list_delete_link(contents, contents)) {
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1064 JingleSessionContent *jsc = contents->data;
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1065 gboolean result = FALSE;
26113
ad871f934f18 Decouple stream direction. Allows send only or recv only streams.
Michael Ruprecht <maiku@pidgin.im>
parents: 26111
diff changeset
1066 const gchar *sender = jabber_jingle_session_content_get_sender(jsc);
ad871f934f18 Decouple stream direction. Allows send only or recv only streams.
Michael Ruprecht <maiku@pidgin.im>
parents: 26111
diff changeset
1067 FsStreamDirection direction = FS_DIRECTION_NONE;
ad871f934f18 Decouple stream direction. Allows send only or recv only streams.
Michael Ruprecht <maiku@pidgin.im>
parents: 26111
diff changeset
1068
ad871f934f18 Decouple stream direction. Allows send only or recv only streams.
Michael Ruprecht <maiku@pidgin.im>
parents: 26111
diff changeset
1069 if (!strcmp(sender, "initiator"))
ad871f934f18 Decouple stream direction. Allows send only or recv only streams.
Michael Ruprecht <maiku@pidgin.im>
parents: 26111
diff changeset
1070 direction = FS_DIRECTION_SEND;
ad871f934f18 Decouple stream direction. Allows send only or recv only streams.
Michael Ruprecht <maiku@pidgin.im>
parents: 26111
diff changeset
1071 else if(!strcmp(sender, "responder"))
ad871f934f18 Decouple stream direction. Allows send only or recv only streams.
Michael Ruprecht <maiku@pidgin.im>
parents: 26111
diff changeset
1072 direction = FS_DIRECTION_RECV;
ad871f934f18 Decouple stream direction. Allows send only or recv only streams.
Michael Ruprecht <maiku@pidgin.im>
parents: 26111
diff changeset
1073 else
ad871f934f18 Decouple stream direction. Allows send only or recv only streams.
Michael Ruprecht <maiku@pidgin.im>
parents: 26111
diff changeset
1074 direction = FS_DIRECTION_BOTH;
ad871f934f18 Decouple stream direction. Allows send only or recv only streams.
Michael Ruprecht <maiku@pidgin.im>
parents: 26111
diff changeset
1075
ad871f934f18 Decouple stream direction. Allows send only or recv only streams.
Michael Ruprecht <maiku@pidgin.im>
parents: 26111
diff changeset
1076 if (!jabber_jingle_session_is_initiator(session)
ad871f934f18 Decouple stream direction. Allows send only or recv only streams.
Michael Ruprecht <maiku@pidgin.im>
parents: 26111
diff changeset
1077 && direction != FS_DIRECTION_BOTH) {
ad871f934f18 Decouple stream direction. Allows send only or recv only streams.
Michael Ruprecht <maiku@pidgin.im>
parents: 26111
diff changeset
1078 if (direction == FS_DIRECTION_SEND)
ad871f934f18 Decouple stream direction. Allows send only or recv only streams.
Michael Ruprecht <maiku@pidgin.im>
parents: 26111
diff changeset
1079 direction = FS_DIRECTION_RECV;
ad871f934f18 Decouple stream direction. Allows send only or recv only streams.
Michael Ruprecht <maiku@pidgin.im>
parents: 26111
diff changeset
1080 else
ad871f934f18 Decouple stream direction. Allows send only or recv only streams.
Michael Ruprecht <maiku@pidgin.im>
parents: 26111
diff changeset
1081 direction = FS_DIRECTION_SEND;
ad871f934f18 Decouple stream direction. Allows send only or recv only streams.
Michael Ruprecht <maiku@pidgin.im>
parents: 26111
diff changeset
1082 }
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1083
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1084 /* these will need to be changed to "nice" once the libnice transmitter is finished */
23725
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
1085 if (jabber_jingle_session_content_is_vv_type(jsc, "audio")) {
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1086 result = purple_media_add_stream(media, "audio-content", remote_jid,
26113
ad871f934f18 Decouple stream direction. Allows send only or recv only streams.
Michael Ruprecht <maiku@pidgin.im>
parents: 26111
diff changeset
1087 purple_media_from_fs(FS_MEDIA_TYPE_AUDIO, direction),
26133
a12ffee5bd73 Add params to purple_media_add_stream to allow for different libNice
Michael Ruprecht <maiku@pidgin.im>
parents: 26129
diff changeset
1088 "rawudp", 0, NULL);
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1089 purple_debug_info("jingle", "Created Jingle audio session\n");
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1090 }
23725
4788666dd0b9 Added the "media" attribute to the Jingle description element according
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
1091 else if (jabber_jingle_session_content_is_vv_type(jsc, "video")) {
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1092 result = purple_media_add_stream(media, "video-content", remote_jid,
26113
ad871f934f18 Decouple stream direction. Allows send only or recv only streams.
Michael Ruprecht <maiku@pidgin.im>
parents: 26111
diff changeset
1093 purple_media_from_fs(FS_MEDIA_TYPE_VIDEO, direction),
26133
a12ffee5bd73 Add params to purple_media_add_stream to allow for different libNice
Michael Ruprecht <maiku@pidgin.im>
parents: 26129
diff changeset
1094 "rawudp", 0, NULL);
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1095 purple_debug_info("jingle", "Created Jingle video session\n");
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1096 }
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1097
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1098 if (!result) {
23723
3f244db116fc merge of '15285d082f6cc90fa25cd27ccdac3b602e8a1f18'
Michael Ruprecht <maiku@pidgin.im>
parents: 23721 23722
diff changeset
1099 purple_debug_error("jingle", "Couldn't create stream\n");
26129
18c8f2cfb52b Properly free PurpleMedia when there's an error creating an FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26121
diff changeset
1100 purple_media_hangup(media);
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1101 return FALSE;
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1102 }
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1103 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1104
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1105 /* connect callbacks */
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1106 g_signal_connect_swapped(G_OBJECT(media), "accepted",
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1107 G_CALLBACK(jabber_jingle_session_send_session_accept), session);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1108 g_signal_connect_swapped(G_OBJECT(media), "reject",
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1109 G_CALLBACK(jabber_jingle_session_send_session_reject), session);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1110 g_signal_connect_swapped(G_OBJECT(media), "hangup",
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1111 G_CALLBACK(jabber_jingle_session_send_session_terminate), session);
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
1112 g_signal_connect(G_OBJECT(media), "new-candidate",
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
1113 G_CALLBACK(jabber_jingle_session_new_candidate_cb), session);
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1114 g_signal_connect(G_OBJECT(media), "candidate-pair",
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
1115 G_CALLBACK(jabber_jingle_session_candidate_pair_established_cb), session);
26137
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1116 g_signal_connect(G_OBJECT(media), "codecs-ready",
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26136
diff changeset
1117 G_CALLBACK(jabber_jingle_session_codecs_ready_cb), session);
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1118
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1119 purple_media_ready(media);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1120
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1121 return TRUE;
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1122 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1123
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1124 PurpleMedia *
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
1125 jabber_jingle_session_initiate_media(JabberStream *js, const char *who,
26108
8d0fd2f195aa Changed PurpleMediaStreamType to PurpleMediaSessionType.
Michael Ruprecht <maiku@pidgin.im>
parents: 26104
diff changeset
1126 PurpleMediaSessionType type)
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1127 {
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1128 /* create content negotiation */
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1129 JingleSession *session;
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1130 JabberBuddy *jb;
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1131 JabberBuddyResource *jbr;
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1132
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1133 char *jid = NULL, *me = NULL;
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1134
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1135 /* construct JID to send to */
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1136 jb = jabber_buddy_find(js, who, FALSE);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1137 if (!jb) {
23722
8a66272172b1 Corrected debug labels s/"jabber"/"jingle"/
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
1138 purple_debug_error("jingle", "Could not find Jabber buddy\n");
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1139 return NULL;
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1140 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1141 jbr = jabber_buddy_find_resource(jb, NULL);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1142 if (!jbr) {
23722
8a66272172b1 Corrected debug labels s/"jabber"/"jingle"/
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
1143 purple_debug_error("jingle", "Could not find buddy's resource\n");
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1144 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1145
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1146 if ((strchr(who, '/') == NULL) && jbr && (jbr->name != NULL)) {
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1147 jid = g_strdup_printf("%s/%s", who, jbr->name);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1148 } else {
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1149 jid = g_strdup(who);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1150 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1151
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1152 session = jabber_jingle_session_create(js);
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1153 jabber_jingle_session_content_create_media(session, type);
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1154
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1155 /* set ourselves as initiator */
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1156 me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, js->user->resource);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1157
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1158 if (!jabber_jingle_session_initiate_media_internal(session, me, jid)) {
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1159 g_free(jid);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1160 g_free(me);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1161 jabber_jingle_session_destroy(session);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1162 return NULL;
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1163 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1164
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1165 g_free(jid);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1166 g_free(me);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1167
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1168 return session->media;
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1169 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1170
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1171 void
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
1172 jabber_jingle_session_terminate_session_media(JabberStream *js, const gchar *who)
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
1173 {
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
1174 JingleSession *session;
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
1175
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
1176 session = jabber_jingle_session_find_by_jid(js, who);
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1177
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
1178 if (session)
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
1179 purple_media_hangup(session->media);
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
1180 }
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
1181
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
1182 void
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
1183 jabber_jingle_session_terminate_sessions(JabberStream *js)
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
1184 {
23735
0e3d49bba6f6 Fix assertion.
Michael Ruprecht <maiku@pidgin.im>
parents: 23733
diff changeset
1185 GList *values = js->sessions ?
0e3d49bba6f6 Fix assertion.
Michael Ruprecht <maiku@pidgin.im>
parents: 23733
diff changeset
1186 g_hash_table_get_values(js->sessions) : NULL;
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
1187
23752
d573c980437e Fixed some memory leak issues involving GLists.
Michael Ruprecht <maiku@pidgin.im>
parents: 23750
diff changeset
1188 for (; values; values = g_list_delete_link(values, values)) {
23717
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
1189 JingleSession *session = (JingleSession *)values->data;
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
1190 purple_media_hangup(session->media);
5a7e463b226d Further decoupled Jingle code from jabber.c:
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
1191 }
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1192 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1193
23748
bc578c4d64f2 Hide unnecessarily exposed Jingle handler functions
Michael Ruprecht <maiku@pidgin.im>
parents: 23747
diff changeset
1194 static void
23749
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1195 jabber_jingle_session_handle_content_replace(JingleSession *session, xmlnode *jingle)
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1196 {
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1197 #if 0
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1198 xmlnode *jingle = xmlnode_get_child(packet, "jingle");
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1199 const char *sid = xmlnode_get_attrib(jingle, "sid");
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1200 JingleSession *session = jabber_jingle_session_find_by_id(js, sid);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1201
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1202 if (!jabber_jingle_session_is_initiator(session) && session->session_started) {
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1203 JabberIq *result = jabber_iq_new(js, JABBER_IQ_RESULT);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1204 JabberIq *accept = jabber_iq_new(js, JABBER_IQ_SET);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1205 xmlnode *content_accept = NULL;
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1206
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1207 /* send acknowledement */
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1208 xmlnode_set_attrib(result->node, "id", xmlnode_get_attrib(packet, "id"));
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1209 xmlnode_set_attrib(result->node, "to", xmlnode_get_attrib(packet, "from"));
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1210 jabber_iq_send(result);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1211
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1212 /* send content-accept */
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1213 content_accept = jabber_jingle_session_create_content_accept(session);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1214 xmlnode_set_attrib(accept->node, "id", xmlnode_get_attrib(packet, "id"));
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1215 xmlnode_set_attrib(accept->node, "to", xmlnode_get_attrib(packet, "from"));
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1216 xmlnode_insert_child(accept->node, content_accept);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1217
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1218 jabber_iq_send(accept);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1219 }
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1220 #endif
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1221 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1222
23748
bc578c4d64f2 Hide unnecessarily exposed Jingle handler functions
Michael Ruprecht <maiku@pidgin.im>
parents: 23747
diff changeset
1223 static void
23749
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1224 jabber_jingle_session_handle_session_accept(JingleSession *session, xmlnode *jingle)
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1225 {
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1226 xmlnode *content = xmlnode_get_child(jingle, "content");
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1227 const char *action = xmlnode_get_attrib(jingle, "action");
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1228 GList *remote_codecs = NULL;
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1229 GList *remote_transports = NULL;
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1230 GList *codec_intersection;
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1231 FsCodec *top = NULL;
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1232 xmlnode *description = NULL;
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1233 xmlnode *transport = NULL;
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1234
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1235 /* We should probably check validity of the incoming XML... */
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1236
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1237 for (content = xmlnode_get_child(jingle, "content"); content;
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1238 content = xmlnode_get_next_twin(content)) {
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1239 description = xmlnode_get_child(content, "description");
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1240 transport = xmlnode_get_child(content, "transport");
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1241
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1242 /* fetch codecs from remote party */
23723
3f244db116fc merge of '15285d082f6cc90fa25cd27ccdac3b602e8a1f18'
Michael Ruprecht <maiku@pidgin.im>
parents: 23721 23722
diff changeset
1243 purple_debug_info("jingle", "get codecs from session-accept\n");
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1244 remote_codecs = jabber_jingle_get_codecs(description);
23723
3f244db116fc merge of '15285d082f6cc90fa25cd27ccdac3b602e8a1f18'
Michael Ruprecht <maiku@pidgin.im>
parents: 23721 23722
diff changeset
1245 purple_debug_info("jingle", "get transport candidates from session accept\n");
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1246 remote_transports = jabber_jingle_get_candidates(transport);
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1247
23723
3f244db116fc merge of '15285d082f6cc90fa25cd27ccdac3b602e8a1f18'
Michael Ruprecht <maiku@pidgin.im>
parents: 23721 23722
diff changeset
1248 purple_debug_info("jingle", "Got %d codecs from responder\n",
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1249 g_list_length(remote_codecs));
23723
3f244db116fc merge of '15285d082f6cc90fa25cd27ccdac3b602e8a1f18'
Michael Ruprecht <maiku@pidgin.im>
parents: 23721 23722
diff changeset
1250 purple_debug_info("jingle", "Got %d transport candidates from responder\n",
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1251 g_list_length(remote_transports));
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1252
23723
3f244db116fc merge of '15285d082f6cc90fa25cd27ccdac3b602e8a1f18'
Michael Ruprecht <maiku@pidgin.im>
parents: 23721 23722
diff changeset
1253 purple_debug_info("jingle", "Setting remote codecs on stream\n");
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1254
23745
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
1255 if (!purple_media_set_remote_codecs(session->media,
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
1256 xmlnode_get_attrib(content, "name"),
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
1257 jabber_jingle_session_get_remote_jid(session),
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
1258 remote_codecs)) {
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
1259 purple_media_reject(jabber_jingle_session_get_media(session));
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
1260 return;
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
1261 }
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1262
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1263 codec_intersection = purple_media_get_negotiated_codecs(session->media,
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1264 xmlnode_get_attrib(content, "name"));
23723
3f244db116fc merge of '15285d082f6cc90fa25cd27ccdac3b602e8a1f18'
Michael Ruprecht <maiku@pidgin.im>
parents: 23721 23722
diff changeset
1265 purple_debug_info("jingle", "codec_intersection contains %d elems\n",
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1266 g_list_length(codec_intersection));
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1267 /* get the top codec */
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1268 if (g_list_length(codec_intersection) > 0) {
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1269 top = (FsCodec *) codec_intersection->data;
23723
3f244db116fc merge of '15285d082f6cc90fa25cd27ccdac3b602e8a1f18'
Michael Ruprecht <maiku@pidgin.im>
parents: 23721 23722
diff changeset
1270 purple_debug_info("jingle", "Found a suitable codec on stream = %d\n",
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1271 top->id);
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1272
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1273 /* we have found a suitable codec, but we will not start the stream
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1274 just yet, wait for transport negotiation to complete... */
26102
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26098
diff changeset
1275 purple_media_set_send_codec(
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26098
diff changeset
1276 jabber_jingle_session_get_media(session),
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26098
diff changeset
1277 xmlnode_get_attrib(content, "name"),
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26098
diff changeset
1278 codec_intersection->data);
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1279 }
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1280 /* if we also got transport candidates, add them to our streams
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1281 list of known remote candidates */
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1282 if (g_list_length(remote_transports) > 0) {
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1283 purple_media_add_remote_candidates(session->media,
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1284 xmlnode_get_attrib(content, "name"),
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1285 jabber_jingle_session_get_remote_jid(session),
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1286 remote_transports);
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1287 fs_candidate_list_destroy(remote_transports);
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1288 }
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1289 if (g_list_length(codec_intersection) == 0 &&
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1290 g_list_length(remote_transports)) {
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1291 /* we didn't get any candidates and the codec intersection is empty,
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1292 this means this was not a content-accept message and we couldn't
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1293 find any suitable codecs, should return error and hang up */
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1294
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1295 }
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1296
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1297 fs_codec_list_destroy(codec_intersection);
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1298
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1299 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1300
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1301 if (!strcmp(action, "session-accept")) {
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1302 purple_media_got_accept(jabber_jingle_session_get_media(session));
26098
687b599c3a31 Add two missed newlines for debug messages.
Michael Ruprecht <maiku@pidgin.im>
parents: 26096
diff changeset
1303 purple_debug_info("jingle", "Got session-accept\n");
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1304 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1305
23749
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1306 jabber_iq_send(jabber_jingle_session_create_ack(session, jingle));
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1307
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23725
diff changeset
1308 jabber_jingle_session_set_state(session, ACTIVE);
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1309 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1310
23748
bc578c4d64f2 Hide unnecessarily exposed Jingle handler functions
Michael Ruprecht <maiku@pidgin.im>
parents: 23747
diff changeset
1311 static void
23749
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1312 jabber_jingle_session_handle_session_info(JingleSession *session, xmlnode *jingle)
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
1313 {
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
1314 purple_debug_info("jingle", "got session-info\n");
23749
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1315 jabber_iq_send(jabber_jingle_session_create_ack(session, jingle));
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
1316 }
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
1317
23748
bc578c4d64f2 Hide unnecessarily exposed Jingle handler functions
Michael Ruprecht <maiku@pidgin.im>
parents: 23747
diff changeset
1318 static void
23749
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1319 jabber_jingle_session_handle_session_initiate(JingleSession *session, xmlnode *jingle)
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1320 {
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1321 xmlnode *content = NULL;
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1322 xmlnode *description = NULL;
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
1323 xmlnode *transport = NULL;
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1324 const char *initiator = NULL;
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1325 GList *codecs = NULL;
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1326
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1327 if (!jingle) {
26098
687b599c3a31 Add two missed newlines for debug messages.
Michael Ruprecht <maiku@pidgin.im>
parents: 26096
diff changeset
1328 purple_debug_error("jingle", "Malformed request\n");
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1329 return;
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1330 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1331
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1332 initiator = xmlnode_get_attrib(jingle, "initiator");
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1333
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1334 for (content = xmlnode_get_child(jingle, "content"); content;
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1335 content = xmlnode_get_next_twin(content)) {
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1336 /* init media */
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1337 if (!content) {
23723
3f244db116fc merge of '15285d082f6cc90fa25cd27ccdac3b602e8a1f18'
Michael Ruprecht <maiku@pidgin.im>
parents: 23721 23722
diff changeset
1338 purple_debug_error("jingle", "jingle tag must contain content tag\n");
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1339 /* should send error here */
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1340 return;
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1341 }
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1342
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1343 description = xmlnode_get_child(content, "description");
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1344
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1345 if (!description) {
23723
3f244db116fc merge of '15285d082f6cc90fa25cd27ccdac3b602e8a1f18'
Michael Ruprecht <maiku@pidgin.im>
parents: 23721 23722
diff changeset
1346 purple_debug_error("jingle", "content tag must contain description tag\n");
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1347 /* we should create an error iq here */
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1348 return;
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1349 }
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1350
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1351 transport = xmlnode_get_child(content, "transport");
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1352
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1353 if (!transport) {
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1354 purple_debug_error("jingle", "content tag must contain transport tag\n");
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1355 /* we should create an error iq here */
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1356 return;
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1357 }
23718
a18432f6cf64 Added JingleSessionContent structure to store content information
Michael Ruprecht <maiku@pidgin.im>
parents: 23717
diff changeset
1358
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1359 jabber_jingle_session_content_create_parse(session, content);
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1360 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1361
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1362 if (!jabber_jingle_session_initiate_media_internal(session, initiator, initiator)) {
23722
8a66272172b1 Corrected debug labels s/"jabber"/"jingle"/
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
1363 purple_debug_error("jingle", "Couldn't start media session with %s\n", initiator);
26111
d25772351a75 Stop additional media sessions within a single conversation for grouped contacts.
Michael Ruprecht <maiku@pidgin.im>
parents: 26110
diff changeset
1364 jabber_jingle_session_send_session_reject(session);
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1365 return;
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1366 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1367
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1368 for (content = xmlnode_get_child(jingle, "content"); content;
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1369 content = xmlnode_get_next_twin(content)) {
26102
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26098
diff changeset
1370 GList *codec_intersection = NULL;
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26098
diff changeset
1371
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1372 /* init media */
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1373 if (!content) {
23723
3f244db116fc merge of '15285d082f6cc90fa25cd27ccdac3b602e8a1f18'
Michael Ruprecht <maiku@pidgin.im>
parents: 23721 23722
diff changeset
1374 purple_debug_error("jingle", "jingle tag must contain content tag\n");
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1375 /* should send error here */
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1376 return;
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1377 }
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1378
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1379 description = xmlnode_get_child(content, "description");
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1380
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1381 if (!description) {
23723
3f244db116fc merge of '15285d082f6cc90fa25cd27ccdac3b602e8a1f18'
Michael Ruprecht <maiku@pidgin.im>
parents: 23721 23722
diff changeset
1382 purple_debug_error("jingle", "content tag must contain description tag\n");
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1383 /* we should create an error iq here */
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1384 return;
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1385 }
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1386 codecs = jabber_jingle_get_codecs(description);
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1387
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1388 purple_media_set_remote_codecs(session->media,
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1389 xmlnode_get_attrib(content, "name"),
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1390 initiator, codecs);
26102
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26098
diff changeset
1391
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26098
diff changeset
1392 codec_intersection = purple_media_get_negotiated_codecs(session->media,
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26098
diff changeset
1393 xmlnode_get_attrib(content, "name"));
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1394 purple_debug_info("jingle", "codec intersection: %i\n",
26102
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26098
diff changeset
1395 g_list_length(codec_intersection));
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26098
diff changeset
1396
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26098
diff changeset
1397 if (g_list_length(codec_intersection) > 0) {
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26098
diff changeset
1398 purple_media_set_send_codec(
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26098
diff changeset
1399 jabber_jingle_session_get_media(session),
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26098
diff changeset
1400 xmlnode_get_attrib(content, "name"),
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26098
diff changeset
1401 codec_intersection->data);
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26098
diff changeset
1402 }
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1403 }
23749
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1404 jabber_iq_send(jabber_jingle_session_create_ack(session, jingle));
23720
6d4abd450c18 Added functions to help create Jingle packets. Revised some of the Jingle flow.
Michael Ruprecht <maiku@pidgin.im>
parents: 23719
diff changeset
1405 jabber_iq_send(jabber_jingle_session_create_session_info(session, "ringing"));
23737
91165a8fcbd9 Notify the user which type of media session the remote user wants to initiate.
Michael Ruprecht <maiku@pidgin.im>
parents: 23735
diff changeset
1406
91165a8fcbd9 Notify the user which type of media session the remote user wants to initiate.
Michael Ruprecht <maiku@pidgin.im>
parents: 23735
diff changeset
1407 purple_media_got_request(jabber_jingle_session_get_media(session));
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1408 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1409
23748
bc578c4d64f2 Hide unnecessarily exposed Jingle handler functions
Michael Ruprecht <maiku@pidgin.im>
parents: 23747
diff changeset
1410 static void
23749
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1411 jabber_jingle_session_handle_session_terminate(JingleSession *session, xmlnode *jingle)
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1412 {
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1413 if (!session) {
23722
8a66272172b1 Corrected debug labels s/"jabber"/"jingle"/
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
1414 purple_debug_error("jingle", "jabber_handle_session_terminate couldn't find session\n");
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1415 return;
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1416 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1417
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1418 /* maybe we should look at the reasoncode to determine if it was
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1419 a hangup or a reject, and call different callbacks to purple_media */
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1420 purple_media_got_hangup(jabber_jingle_session_get_media(session));
23749
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1421 jabber_iq_send(jabber_jingle_session_create_ack(session, jingle));
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1422 jabber_jingle_session_destroy(session);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1423 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1424
23748
bc578c4d64f2 Hide unnecessarily exposed Jingle handler functions
Michael Ruprecht <maiku@pidgin.im>
parents: 23747
diff changeset
1425 static void
23749
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1426 jabber_jingle_session_handle_transport_info(JingleSession *session, xmlnode *jingle)
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1427 {
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1428 xmlnode *content = xmlnode_get_child(jingle, "content");
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1429 xmlnode *transport = xmlnode_get_child(content, "transport");
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1430 GList *remote_candidates = jabber_jingle_get_candidates(transport);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1431
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1432 if (!session)
23722
8a66272172b1 Corrected debug labels s/"jabber"/"jingle"/
Michael Ruprecht <maiku@pidgin.im>
parents: 23716
diff changeset
1433 purple_debug_error("jingle", "jabber_handle_session_candidates couldn't find session\n");
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1434
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1435 /* send acknowledement */
23749
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1436 jabber_iq_send(jabber_jingle_session_create_ack(session, jingle));
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1437
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1438 /* add candidates to our list of remote candidates */
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1439 if (g_list_length(remote_candidates) > 0) {
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1440 purple_media_add_remote_candidates(session->media,
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1441 xmlnode_get_attrib(content, "name"),
23750
57baab09bf45 Added xmlnode_get_parent.
Michael Ruprecht <maiku@pidgin.im>
parents: 23749
diff changeset
1442 xmlnode_get_attrib(xmlnode_get_parent(jingle), "from"),
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23720
diff changeset
1443 remote_candidates);
23716
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1444 fs_candidate_list_destroy(remote_candidates);
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1445 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1446 }
e1a9c55075ba Moved Jingle message handlers from jabber.c to jingle.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1447
23747
86aacf5be74e Further decouple Jingle from iq.c
Michael Ruprecht <maiku@pidgin.im>
parents: 23745
diff changeset
1448 void
86aacf5be74e Further decouple Jingle from iq.c
Michael Ruprecht <maiku@pidgin.im>
parents: 23745
diff changeset
1449 jabber_jingle_session_parse(JabberStream *js, xmlnode *packet)
86aacf5be74e Further decouple Jingle from iq.c
Michael Ruprecht <maiku@pidgin.im>
parents: 23745
diff changeset
1450 {
86aacf5be74e Further decouple Jingle from iq.c
Michael Ruprecht <maiku@pidgin.im>
parents: 23745
diff changeset
1451 const gchar *type = xmlnode_get_attrib(packet, "type");
23749
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1452 xmlnode *jingle;
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1453 const gchar *action;
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1454 const char *sid;
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1455 JingleSession *session;
23747
86aacf5be74e Further decouple Jingle from iq.c
Michael Ruprecht <maiku@pidgin.im>
parents: 23745
diff changeset
1456
23749
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1457 if (!type || strcmp(type, "set")) {
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1458 /* send iq error here */
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1459 return;
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1460 }
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1461
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1462 /* is this a Jingle package? */
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1463 if (!(jingle = xmlnode_get_child(packet, "jingle"))) {
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1464 /* send iq error here */
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1465 return;
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1466 }
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1467
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1468 if (!(action = xmlnode_get_attrib(jingle, "action"))) {
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1469 /* send iq error here */
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1470 return;
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1471 }
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1472
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1473 purple_debug_info("jabber", "got Jingle package action = %s\n",
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1474 action);
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1475
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1476 if (!(sid = xmlnode_get_attrib(jingle, "sid"))) {
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1477 /* send iq error here */
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1478 return;
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1479 }
23747
86aacf5be74e Further decouple Jingle from iq.c
Michael Ruprecht <maiku@pidgin.im>
parents: 23745
diff changeset
1480
23749
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1481 if (!(session = jabber_jingle_session_find_by_id(js, sid))
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1482 && strcmp(action, "session-initiate")) {
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1483 purple_debug_error("jingle", "jabber_jingle_session_parse couldn't find session\n");
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1484 /* send iq error here */
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1485 return;
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1486 }
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1487
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1488 if (!strcmp(action, "session-initiate")) {
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1489 if (session) {
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1490 /* This should only happen if you start a session with yourself */
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1491 purple_debug_error("jingle", "Jingle session with "
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1492 "id={%s} already exists\n", sid);
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1493 /* send iq error */
26109
309784550529 Prevent multiple voice and video sessions within the same conversation.
Michael Ruprecht <maiku@pidgin.im>
parents: 26108
diff changeset
1494 } else if ((session = jabber_jingle_session_find_by_jid(js,
309784550529 Prevent multiple voice and video sessions within the same conversation.
Michael Ruprecht <maiku@pidgin.im>
parents: 26108
diff changeset
1495 xmlnode_get_attrib(packet, "from")))) {
309784550529 Prevent multiple voice and video sessions within the same conversation.
Michael Ruprecht <maiku@pidgin.im>
parents: 26108
diff changeset
1496 purple_debug_fatal("jingle", "Jingle session with "
309784550529 Prevent multiple voice and video sessions within the same conversation.
Michael Ruprecht <maiku@pidgin.im>
parents: 26108
diff changeset
1497 "jid={%s} already exists\n",
309784550529 Prevent multiple voice and video sessions within the same conversation.
Michael Ruprecht <maiku@pidgin.im>
parents: 26108
diff changeset
1498 xmlnode_get_attrib(packet, "from"));
309784550529 Prevent multiple voice and video sessions within the same conversation.
Michael Ruprecht <maiku@pidgin.im>
parents: 26108
diff changeset
1499 /* send jingle redirect packet */
309784550529 Prevent multiple voice and video sessions within the same conversation.
Michael Ruprecht <maiku@pidgin.im>
parents: 26108
diff changeset
1500 return;
23749
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1501 } else {
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1502 session = jabber_jingle_session_create_by_id(js, sid);
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1503 jabber_jingle_session_handle_session_initiate(session, jingle);
23747
86aacf5be74e Further decouple Jingle from iq.c
Michael Ruprecht <maiku@pidgin.im>
parents: 23745
diff changeset
1504 }
23749
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1505 } else if (!strcmp(action, "session-accept")
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1506 || !strcmp(action, "content-accept")) {
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1507 jabber_jingle_session_handle_session_accept(session, jingle);
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1508 } else if (!strcmp(action, "session-info")) {
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1509 jabber_jingle_session_handle_session_info(session, jingle);
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1510 } else if (!strcmp(action, "session-terminate")) {
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1511 jabber_jingle_session_handle_session_terminate(session, jingle);
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1512 } else if (!strcmp(action, "transport-info")) {
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1513 jabber_jingle_session_handle_transport_info(session, jingle);
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1514 } else if (!strcmp(action, "content-replace")) {
526619469cc1 Simplify the Jingle handlers by moving repetitive code into the parse function.
Michael Ruprecht <maiku@pidgin.im>
parents: 23748
diff changeset
1515 jabber_jingle_session_handle_content_replace(session, jingle);
23747
86aacf5be74e Further decouple Jingle from iq.c
Michael Ruprecht <maiku@pidgin.im>
parents: 23745
diff changeset
1516 }
86aacf5be74e Further decouple Jingle from iq.c
Michael Ruprecht <maiku@pidgin.im>
parents: 23745
diff changeset
1517 }
86aacf5be74e Further decouple Jingle from iq.c
Michael Ruprecht <maiku@pidgin.im>
parents: 23745
diff changeset
1518
23704
9b88c9b23aed Use USE_VV instead of USE_FARSIGHT.
Michael Ruprecht <maiku@pidgin.im>
parents: 23698
diff changeset
1519 #endif /* USE_VV */
23724
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23723
diff changeset
1520

mercurial