Mercurial > pidgin.yaz
annotate libpurple/protocols/jabber/google/google_session.c @ 30967:52803883f33f
refactor out the relay credential fetching code to its own module
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Sun, 05 Sep 2010 08:35:37 +0000 |
parents | 75045bed7704 |
children | 1d55c7e1006e |
rev | line source |
---|---|
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
1 /** |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
2 * Purple is the legal property of its developers, whose names are too numerous |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
3 * to list here. Please refer to the COPYRIGHT file distributed with this |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
4 * source distribution. |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
5 * |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
6 * This program is free software; you can redistribute it and/or modify |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
9 * (at your option) any later version. |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
10 * |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
11 * This program is distributed in the hope that it will be useful, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
14 * GNU General Public License for more details. |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
15 * |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
16 * You should have received a copy of the GNU General Public License |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
17 * along with this program; if not, write to the Free Software |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
19 */ |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
20 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
21 #include "internal.h" |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
22 #include "debug.h" |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
23 #include "google_session.h" |
30967
52803883f33f
refactor out the relay credential fetching code to its own module
Marcus Lundblad <ml@update.uu.se>
parents:
30966
diff
changeset
|
24 #include "relay.h" |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
25 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
26 #include "jingle/jingle.h" |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
27 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
28 #ifdef USE_VV |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
29 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
30 typedef struct { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
31 PurpleMedia *media; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
32 gboolean video; |
30964
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
33 GList *remote_audio_candidates; /* list of PurpleMediaCandidate */ |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
34 GList *remote_video_candidates; /* list of PurpleMediaCandidate */ |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
35 gboolean added_streams; /* this indicates if the streams have been |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
36 to media (ie. after getting relay credentials */ |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
37 } GoogleAVSessionData; |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
38 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
39 static gboolean |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
40 google_session_id_equal(gconstpointer a, gconstpointer b) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
41 { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
42 GoogleSessionId *c = (GoogleSessionId*)a; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
43 GoogleSessionId *d = (GoogleSessionId*)b; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
44 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
45 return !strcmp(c->id, d->id) && !strcmp(c->initiator, d->initiator); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
46 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
47 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
48 static void |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
49 google_session_destroy(GoogleSession *session) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
50 { |
30964
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
51 GoogleAVSessionData *session_data = |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
52 (GoogleAVSessionData *) session->session_data; |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
53 g_free(session->id.id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
54 g_free(session->id.initiator); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
55 g_free(session->remote_jid); |
30964
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
56 |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
57 if (session_data->remote_audio_candidates) |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
58 purple_media_candidate_list_free(session_data->remote_audio_candidates); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
59 |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
60 if (session_data->remote_video_candidates) |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
61 purple_media_candidate_list_free(session_data->remote_video_candidates); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
62 |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
63 g_free(session->session_data); |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
64 g_free(session); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
65 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
66 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
67 static xmlnode * |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
68 google_session_create_xmlnode(GoogleSession *session, const char *type) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
69 { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
70 xmlnode *node = xmlnode_new("session"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
71 xmlnode_set_namespace(node, NS_GOOGLE_SESSION); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
72 xmlnode_set_attrib(node, "id", session->id.id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
73 xmlnode_set_attrib(node, "initiator", session->id.initiator); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
74 xmlnode_set_attrib(node, "type", type); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
75 return node; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
76 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
77 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
78 static void |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
79 google_session_send_candidates(PurpleMedia *media, gchar *session_id, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
80 gchar *participant, GoogleSession *session) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
81 { |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
82 PurpleMedia *session_media = |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
83 ((GoogleAVSessionData *) session->session_data)->media; |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
84 GList *candidates = |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
85 purple_media_get_local_candidates(session_media, session_id, |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
86 session->remote_jid); |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
87 GList *iter; |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
88 PurpleMediaCandidate *transport; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
89 gboolean video = FALSE; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
90 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
91 if (!strcmp(session_id, "google-video")) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
92 video = TRUE; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
93 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
94 for (iter = candidates; iter; iter = iter->next) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
95 JabberIq *iq; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
96 gchar *ip, *port, *username, *password; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
97 gchar pref[16]; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
98 PurpleMediaCandidateType type; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
99 xmlnode *sess; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
100 xmlnode *candidate; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
101 guint component_id; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
102 transport = PURPLE_MEDIA_CANDIDATE(iter->data); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
103 component_id = purple_media_candidate_get_component_id( |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
104 transport); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
105 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
106 iq = jabber_iq_new(session->js, JABBER_IQ_SET); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
107 sess = google_session_create_xmlnode(session, "candidates"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
108 xmlnode_insert_child(iq->node, sess); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
109 xmlnode_set_attrib(iq->node, "to", session->remote_jid); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
110 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
111 candidate = xmlnode_new("candidate"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
112 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
113 ip = purple_media_candidate_get_ip(transport); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
114 port = g_strdup_printf("%d", |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
115 purple_media_candidate_get_port(transport)); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
116 g_ascii_dtostr(pref, 16, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
117 purple_media_candidate_get_priority(transport) / 1000.0); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
118 username = purple_media_candidate_get_username(transport); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
119 password = purple_media_candidate_get_password(transport); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
120 type = purple_media_candidate_get_candidate_type(transport); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
121 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
122 xmlnode_set_attrib(candidate, "address", ip); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
123 xmlnode_set_attrib(candidate, "port", port); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
124 xmlnode_set_attrib(candidate, "name", |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
125 component_id == PURPLE_MEDIA_COMPONENT_RTP ? |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
126 video ? "video_rtp" : "rtp" : |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
127 component_id == PURPLE_MEDIA_COMPONENT_RTCP ? |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
128 video ? "video_rtcp" : "rtcp" : "none"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
129 xmlnode_set_attrib(candidate, "username", username); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
130 /* |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
131 * As of this writing, Farsight 2 in Google compatibility |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
132 * mode doesn't provide a password. The Gmail client |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
133 * requires this to be set. |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
134 */ |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
135 xmlnode_set_attrib(candidate, "password", |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
136 password != NULL ? password : ""); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
137 xmlnode_set_attrib(candidate, "preference", pref); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
138 xmlnode_set_attrib(candidate, "protocol", |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
139 purple_media_candidate_get_protocol(transport) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
140 == PURPLE_MEDIA_NETWORK_PROTOCOL_UDP ? |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
141 "udp" : "tcp"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
142 xmlnode_set_attrib(candidate, "type", type == |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
143 PURPLE_MEDIA_CANDIDATE_TYPE_HOST ? "local" : |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
144 type == |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
145 PURPLE_MEDIA_CANDIDATE_TYPE_SRFLX ? "stun" : |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
146 type == |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
147 PURPLE_MEDIA_CANDIDATE_TYPE_RELAY ? "relay" : |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
148 NULL); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
149 xmlnode_set_attrib(candidate, "generation", "0"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
150 xmlnode_set_attrib(candidate, "network", "0"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
151 xmlnode_insert_child(sess, candidate); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
152 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
153 g_free(ip); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
154 g_free(port); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
155 g_free(username); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
156 g_free(password); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
157 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
158 jabber_iq_send(iq); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
159 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
160 purple_media_candidate_list_free(candidates); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
161 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
162 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
163 static void |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
164 google_session_ready(GoogleSession *session) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
165 { |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
166 PurpleMedia *media = |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
167 ((GoogleAVSessionData *)session->session_data)->media; |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
168 gboolean video = |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
169 ((GoogleAVSessionData *)session->session_data)->video; |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
170 if (purple_media_codecs_ready(media, NULL) && |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
171 purple_media_candidates_prepared(media, NULL, NULL)) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
172 gchar *me = g_strdup_printf("%s@%s/%s", |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
173 session->js->user->node, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
174 session->js->user->domain, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
175 session->js->user->resource); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
176 JabberIq *iq; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
177 xmlnode *sess, *desc, *payload; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
178 GList *codecs, *iter; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
179 gboolean is_initiator = !strcmp(session->id.initiator, me); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
180 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
181 if (!is_initiator && |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
182 !purple_media_accepted(media, NULL, NULL)) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
183 g_free(me); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
184 return; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
185 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
186 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
187 iq = jabber_iq_new(session->js, JABBER_IQ_SET); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
188 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
189 if (is_initiator) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
190 xmlnode_set_attrib(iq->node, "to", session->remote_jid); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
191 xmlnode_set_attrib(iq->node, "from", session->id.initiator); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
192 sess = google_session_create_xmlnode(session, "initiate"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
193 } else { |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
194 google_session_send_candidates(media, |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
195 "google-voice", session->remote_jid, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
196 session); |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
197 google_session_send_candidates(media, |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
198 "google-video", session->remote_jid, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
199 session); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
200 xmlnode_set_attrib(iq->node, "to", session->remote_jid); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
201 xmlnode_set_attrib(iq->node, "from", me); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
202 sess = google_session_create_xmlnode(session, "accept"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
203 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
204 xmlnode_insert_child(iq->node, sess); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
205 desc = xmlnode_new_child(sess, "description"); |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
206 if (video) |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
207 xmlnode_set_namespace(desc, NS_GOOGLE_SESSION_VIDEO); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
208 else |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
209 xmlnode_set_namespace(desc, NS_GOOGLE_SESSION_PHONE); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
210 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
211 codecs = purple_media_get_codecs(media, "google-video"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
212 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
213 for (iter = codecs; iter; iter = g_list_next(iter)) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
214 PurpleMediaCodec *codec = (PurpleMediaCodec*)iter->data; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
215 gchar *id = g_strdup_printf("%d", |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
216 purple_media_codec_get_id(codec)); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
217 gchar *encoding_name = |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
218 purple_media_codec_get_encoding_name(codec); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
219 payload = xmlnode_new_child(desc, "payload-type"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
220 xmlnode_set_attrib(payload, "id", id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
221 xmlnode_set_attrib(payload, "name", encoding_name); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
222 xmlnode_set_attrib(payload, "width", "320"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
223 xmlnode_set_attrib(payload, "height", "200"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
224 xmlnode_set_attrib(payload, "framerate", "30"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
225 g_free(encoding_name); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
226 g_free(id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
227 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
228 purple_media_codec_list_free(codecs); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
229 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
230 codecs = purple_media_get_codecs(media, "google-voice"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
231 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
232 for (iter = codecs; iter; iter = g_list_next(iter)) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
233 PurpleMediaCodec *codec = (PurpleMediaCodec*)iter->data; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
234 gchar *id = g_strdup_printf("%d", |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
235 purple_media_codec_get_id(codec)); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
236 gchar *encoding_name = |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
237 purple_media_codec_get_encoding_name(codec); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
238 gchar *clock_rate = g_strdup_printf("%d", |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
239 purple_media_codec_get_clock_rate(codec)); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
240 payload = xmlnode_new_child(desc, "payload-type"); |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
241 if (video) |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
242 xmlnode_set_namespace(payload, NS_GOOGLE_SESSION_PHONE); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
243 xmlnode_set_attrib(payload, "id", id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
244 /* |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
245 * Hack to make Gmail accept speex as the codec. |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
246 * It shouldn't have to be case sensitive. |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
247 */ |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
248 if (purple_strequal(encoding_name, "SPEEX")) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
249 xmlnode_set_attrib(payload, "name", "speex"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
250 else |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
251 xmlnode_set_attrib(payload, "name", encoding_name); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
252 xmlnode_set_attrib(payload, "clockrate", clock_rate); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
253 g_free(clock_rate); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
254 g_free(encoding_name); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
255 g_free(id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
256 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
257 purple_media_codec_list_free(codecs); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
258 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
259 jabber_iq_send(iq); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
260 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
261 if (is_initiator) { |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
262 google_session_send_candidates(media, |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
263 "google-voice", session->remote_jid, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
264 session); |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
265 google_session_send_candidates(media, |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
266 "google-video", session->remote_jid, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
267 session); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
268 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
269 |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
270 g_signal_handlers_disconnect_by_func(G_OBJECT(media), |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
271 G_CALLBACK(google_session_ready), session); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
272 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
273 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
274 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
275 static void |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
276 google_session_state_changed_cb(PurpleMedia *media, PurpleMediaState state, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
277 gchar *sid, gchar *name, GoogleSession *session) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
278 { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
279 if (sid == NULL && name == NULL) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
280 if (state == PURPLE_MEDIA_STATE_END) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
281 google_session_destroy(session); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
282 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
283 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
284 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
285 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
286 static void |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
287 google_session_stream_info_cb(PurpleMedia *media, PurpleMediaInfoType type, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
288 gchar *sid, gchar *name, gboolean local, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
289 GoogleSession *session) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
290 { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
291 if (sid != NULL || name != NULL) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
292 return; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
293 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
294 if (type == PURPLE_MEDIA_INFO_HANGUP) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
295 xmlnode *sess; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
296 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
297 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
298 xmlnode_set_attrib(iq->node, "to", session->remote_jid); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
299 sess = google_session_create_xmlnode(session, "terminate"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
300 xmlnode_insert_child(iq->node, sess); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
301 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
302 jabber_iq_send(iq); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
303 } else if (type == PURPLE_MEDIA_INFO_REJECT) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
304 xmlnode *sess; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
305 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
306 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
307 xmlnode_set_attrib(iq->node, "to", session->remote_jid); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
308 sess = google_session_create_xmlnode(session, "reject"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
309 xmlnode_insert_child(iq->node, sess); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
310 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
311 jabber_iq_send(iq); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
312 } else if (type == PURPLE_MEDIA_INFO_ACCEPT && local == TRUE) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
313 google_session_ready(session); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
314 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
315 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
316 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
317 static GParameter * |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
318 jabber_google_session_get_params(JabberStream *js, const gchar *relay_ip, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
319 guint16 relay_udp, guint16 relay_tcp, guint16 relay_ssltcp, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
320 const gchar *relay_username, const gchar *relay_password, guint *num) |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
321 { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
322 guint num_params; |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
323 GParameter *params = |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
324 jingle_get_params(js, relay_ip, relay_udp, relay_tcp, relay_ssltcp, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
325 relay_username, relay_password, &num_params); |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
326 GParameter *new_params = g_new0(GParameter, num_params + 1); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
327 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
328 memcpy(new_params, params, sizeof(GParameter) * num_params); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
329 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
330 purple_debug_info("jabber", "setting Google jingle compatibility param\n"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
331 new_params[num_params].name = "compatibility-mode"; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
332 g_value_init(&new_params[num_params].value, G_TYPE_UINT); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
333 g_value_set_uint(&new_params[num_params].value, 1); /* NICE_COMPATIBILITY_GOOGLE */ |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
334 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
335 g_free(params); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
336 *num = num_params + 1; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
337 return new_params; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
338 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
339 |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
340 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
341 static void |
30967
52803883f33f
refactor out the relay credential fetching code to its own module
Marcus Lundblad <ml@update.uu.se>
parents:
30966
diff
changeset
|
342 jabber_google_relay_response_session_initiate_cb(GoogleSession *session, |
52803883f33f
refactor out the relay credential fetching code to its own module
Marcus Lundblad <ml@update.uu.se>
parents:
30966
diff
changeset
|
343 const gchar *relay_ip, guint relay_udp, guint relay_tcp, guint relay_ssltcp, |
52803883f33f
refactor out the relay credential fetching code to its own module
Marcus Lundblad <ml@update.uu.se>
parents:
30966
diff
changeset
|
344 const gchar *relay_username, const gchar *relay_password) |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
345 { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
346 GParameter *params; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
347 guint num_params; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
348 JabberStream *js = session->js; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
349 GoogleAVSessionData *session_data = |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
350 (GoogleAVSessionData *) session->session_data; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
351 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
352 session_data->media = purple_media_manager_create_media( |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
353 purple_media_manager_get(), |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
354 purple_connection_get_account(js->gc), |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
355 "fsrtpconference", session->remote_jid, TRUE); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
356 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
357 purple_media_set_prpl_data(session_data->media, session); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
358 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
359 g_signal_connect_swapped(G_OBJECT(session_data->media), |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
360 "candidates-prepared", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
361 G_CALLBACK(google_session_ready), session); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
362 g_signal_connect_swapped(G_OBJECT(session_data->media), "codecs-changed", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
363 G_CALLBACK(google_session_ready), session); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
364 g_signal_connect(G_OBJECT(session_data->media), "state-changed", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
365 G_CALLBACK(google_session_state_changed_cb), session); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
366 g_signal_connect(G_OBJECT(session_data->media), "stream-info", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
367 G_CALLBACK(google_session_stream_info_cb), session); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
368 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
369 params = |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
370 jabber_google_session_get_params(js, relay_ip, relay_udp, relay_tcp, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
371 relay_ssltcp, relay_username, relay_password, &num_params); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
372 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
373 if (purple_media_add_stream(session_data->media, "google-voice", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
374 session->remote_jid, PURPLE_MEDIA_AUDIO, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
375 TRUE, "nice", num_params, params) == FALSE || |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
376 (session_data->video && purple_media_add_stream( |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
377 session_data->media, "google-video", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
378 session->remote_jid, PURPLE_MEDIA_VIDEO, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
379 TRUE, "nice", num_params, params) == FALSE)) { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
380 purple_media_error(session_data->media, "Error adding stream."); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
381 purple_media_end(session_data->media, NULL, NULL); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
382 g_free(params); |
30964
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
383 } else { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
384 session_data->added_streams = TRUE; |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
385 } |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
386 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
387 g_free(params); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
388 } |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
389 |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
390 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
391 gboolean |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
392 jabber_google_session_initiate(JabberStream *js, const gchar *who, PurpleMediaSessionType type) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
393 { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
394 GoogleSession *session; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
395 JabberBuddy *jb; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
396 JabberBuddyResource *jbr; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
397 gchar *jid; |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
398 GoogleAVSessionData *session_data = NULL; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
399 |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
400 /* construct JID to send to */ |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
401 jb = jabber_buddy_find(js, who, FALSE); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
402 if (!jb) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
403 purple_debug_error("jingle-rtp", |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
404 "Could not find Jabber buddy\n"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
405 return FALSE; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
406 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
407 jbr = jabber_buddy_find_resource(jb, NULL); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
408 if (!jbr) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
409 purple_debug_error("jingle-rtp", |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
410 "Could not find buddy's resource\n"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
411 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
412 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
413 if ((strchr(who, '/') == NULL) && jbr && (jbr->name != NULL)) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
414 jid = g_strdup_printf("%s/%s", who, jbr->name); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
415 } else { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
416 jid = g_strdup(who); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
417 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
418 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
419 session = g_new0(GoogleSession, 1); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
420 session->id.id = jabber_get_next_id(js); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
421 session->id.initiator = g_strdup_printf("%s@%s/%s", js->user->node, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
422 js->user->domain, js->user->resource); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
423 session->state = SENT_INITIATE; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
424 session->js = js; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
425 session->remote_jid = jid; |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
426 session_data = g_new0(GoogleAVSessionData, 1); |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
427 session->session_data = session_data; |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
428 |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
429 if (type & PURPLE_MEDIA_VIDEO) |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
430 session_data->video = TRUE; |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
431 |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
432 /* if we got a relay token and relay host in google:jingleinfo, issue an |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
433 HTTP request to get that data */ |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
434 if (js->google_relay_host && js->google_relay_token) { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
435 jabber_google_do_relay_request(js, session, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
436 jabber_google_relay_response_session_initiate_cb); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
437 } else { |
30967
52803883f33f
refactor out the relay credential fetching code to its own module
Marcus Lundblad <ml@update.uu.se>
parents:
30966
diff
changeset
|
438 jabber_google_relay_response_session_initiate_cb(session, NULL, 0, 0, 0, |
52803883f33f
refactor out the relay credential fetching code to its own module
Marcus Lundblad <ml@update.uu.se>
parents:
30966
diff
changeset
|
439 NULL, NULL); |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
440 } |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
441 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
442 /* we don't actually know yet wether it succeeded... maybe this is very |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
443 wrong... */ |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
444 return TRUE; |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
445 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
446 |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
447 static void |
30967
52803883f33f
refactor out the relay credential fetching code to its own module
Marcus Lundblad <ml@update.uu.se>
parents:
30966
diff
changeset
|
448 jabber_google_relay_response_session_handle_initiate_cb(GoogleSession *session, |
52803883f33f
refactor out the relay credential fetching code to its own module
Marcus Lundblad <ml@update.uu.se>
parents:
30966
diff
changeset
|
449 const gchar *relay_ip, guint relay_udp, guint relay_tcp, guint relay_ssltcp, |
52803883f33f
refactor out the relay credential fetching code to its own module
Marcus Lundblad <ml@update.uu.se>
parents:
30966
diff
changeset
|
450 const gchar *relay_username, const gchar *relay_password) |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
451 { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
452 GParameter *params; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
453 guint num_params; |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
454 JabberStream *js = session->js; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
455 xmlnode *codec_element; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
456 xmlnode *desc_element; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
457 const gchar *xmlns; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
458 PurpleMediaCodec *codec; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
459 GList *video_codecs = NULL; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
460 GList *codecs = NULL; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
461 JabberIq *result; |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
462 GoogleAVSessionData *session_data = |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
463 (GoogleAVSessionData *) session->session_data; |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
464 |
30967
52803883f33f
refactor out the relay credential fetching code to its own module
Marcus Lundblad <ml@update.uu.se>
parents:
30966
diff
changeset
|
465 params = |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
466 jabber_google_session_get_params(js, relay_ip, relay_udp, relay_tcp, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
467 relay_ssltcp, relay_username, relay_password, &num_params); |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
468 |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
469 if (purple_media_add_stream(session_data->media, "google-voice", |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
470 session->remote_jid, PURPLE_MEDIA_AUDIO, FALSE, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
471 "nice", num_params, params) == FALSE || |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
472 (session_data->video && purple_media_add_stream( |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
473 session_data->media, "google-video", |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
474 session->remote_jid, PURPLE_MEDIA_VIDEO, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
475 FALSE, "nice", num_params, params) == FALSE)) { |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
476 purple_media_error(session_data->media, "Error adding stream."); |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
477 purple_media_stream_info(session_data->media, |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
478 PURPLE_MEDIA_INFO_REJECT, NULL, NULL, TRUE); |
30964
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
479 } else { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
480 /* successfully added stream(s) */ |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
481 session_data->added_streams = TRUE; |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
482 |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
483 if (session_data->remote_audio_candidates) { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
484 purple_media_add_remote_candidates(session_data->media, |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
485 "google-voice", session->remote_jid, |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
486 session_data->remote_audio_candidates); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
487 purple_media_candidate_list_free(session_data->remote_audio_candidates); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
488 session_data->remote_audio_candidates = NULL; |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
489 } |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
490 if (session_data->remote_video_candidates) { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
491 purple_media_add_remote_candidates(session_data->media, |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
492 "google-video", session->remote_jid, |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
493 session_data->remote_video_candidates); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
494 purple_media_candidate_list_free(session_data->remote_video_candidates); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
495 session_data->remote_video_candidates = NULL; |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
496 } |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
497 } |
30964
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
498 |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
499 g_free(params); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
500 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
501 for (codec_element = xmlnode_get_child(desc_element, "payload-type"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
502 codec_element; codec_element = codec_element->next) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
503 const char *id, *encoding_name, *clock_rate, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
504 *width, *height, *framerate; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
505 gboolean video; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
506 if (codec_element->name && |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
507 strcmp(codec_element->name, "payload-type")) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
508 continue; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
509 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
510 xmlns = xmlnode_get_namespace(codec_element); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
511 encoding_name = xmlnode_get_attrib(codec_element, "name"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
512 id = xmlnode_get_attrib(codec_element, "id"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
513 |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
514 if (!session_data->video || |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
515 (xmlns && !strcmp(xmlns, NS_GOOGLE_SESSION_PHONE))) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
516 clock_rate = xmlnode_get_attrib( |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
517 codec_element, "clockrate"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
518 video = FALSE; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
519 } else { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
520 width = xmlnode_get_attrib(codec_element, "width"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
521 height = xmlnode_get_attrib(codec_element, "height"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
522 framerate = xmlnode_get_attrib( |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
523 codec_element, "framerate"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
524 clock_rate = "90000"; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
525 video = TRUE; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
526 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
527 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
528 if (id) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
529 codec = purple_media_codec_new(atoi(id), encoding_name, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
530 video ? PURPLE_MEDIA_VIDEO : |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
531 PURPLE_MEDIA_AUDIO, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
532 clock_rate ? atoi(clock_rate) : 0); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
533 if (video) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
534 video_codecs = g_list_append( |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
535 video_codecs, codec); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
536 else |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
537 codecs = g_list_append(codecs, codec); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
538 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
539 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
540 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
541 if (codecs) |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
542 purple_media_set_remote_codecs(session_data->media, "google-voice", |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
543 session->remote_jid, codecs); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
544 if (video_codecs) |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
545 purple_media_set_remote_codecs(session_data->media, "google-video", |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
546 session->remote_jid, video_codecs); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
547 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
548 purple_media_codec_list_free(codecs); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
549 purple_media_codec_list_free(video_codecs); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
550 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
551 result = jabber_iq_new(js, JABBER_IQ_RESULT); |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
552 jabber_iq_set_id(result, session->iq_id); |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
553 xmlnode_set_attrib(result->node, "to", session->remote_jid); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
554 jabber_iq_send(result); |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
555 } |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
556 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
557 static gboolean |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
558 google_session_handle_initiate(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id) |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
559 { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
560 xmlnode *desc_element; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
561 const gchar *xmlns; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
562 GoogleAVSessionData *session_data = |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
563 (GoogleAVSessionData *) session->session_data; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
564 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
565 if (session->state != UNINIT) { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
566 purple_debug_error("jabber", "Received initiate for active session.\n"); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
567 return FALSE; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
568 } |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
569 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
570 desc_element = xmlnode_get_child(sess, "description"); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
571 xmlns = xmlnode_get_namespace(desc_element); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
572 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
573 if (purple_strequal(xmlns, NS_GOOGLE_SESSION_PHONE)) |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
574 session_data->video = FALSE; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
575 else if (purple_strequal(xmlns, NS_GOOGLE_SESSION_VIDEO)) |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
576 session_data->video = TRUE; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
577 else { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
578 purple_debug_error("jabber", "Received initiate with " |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
579 "invalid namespace %s.\n", xmlns); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
580 return FALSE; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
581 } |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
582 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
583 session_data->media = purple_media_manager_create_media( |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
584 purple_media_manager_get(), |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
585 purple_connection_get_account(js->gc), |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
586 "fsrtpconference", session->remote_jid, FALSE); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
587 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
588 purple_media_set_prpl_data(session_data->media, session); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
589 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
590 g_signal_connect_swapped(G_OBJECT(session_data->media), |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
591 "candidates-prepared", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
592 G_CALLBACK(google_session_ready), session); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
593 g_signal_connect_swapped(G_OBJECT(session_data->media), "codecs-changed", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
594 G_CALLBACK(google_session_ready), session); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
595 g_signal_connect(G_OBJECT(session_data->media), "state-changed", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
596 G_CALLBACK(google_session_state_changed_cb), session); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
597 g_signal_connect(G_OBJECT(session_data->media), "stream-info", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
598 G_CALLBACK(google_session_stream_info_cb), session); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
599 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
600 session->iq_id = g_strdup(iq_id); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
601 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
602 if (js->google_relay_host && js->google_relay_token) { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
603 jabber_google_do_relay_request(js, session, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
604 jabber_google_relay_response_session_handle_initiate_cb); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
605 } else { |
30967
52803883f33f
refactor out the relay credential fetching code to its own module
Marcus Lundblad <ml@update.uu.se>
parents:
30966
diff
changeset
|
606 jabber_google_relay_response_session_handle_initiate_cb(session, NULL, |
52803883f33f
refactor out the relay credential fetching code to its own module
Marcus Lundblad <ml@update.uu.se>
parents:
30966
diff
changeset
|
607 0, 0, 0, NULL, NULL); |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
608 } |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
609 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
610 return TRUE; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
611 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
612 |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
613 |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
614 static void |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
615 google_session_handle_candidates(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
616 { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
617 JabberIq *result; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
618 GList *list = NULL, *video_list = NULL; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
619 xmlnode *cand; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
620 static int name = 0; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
621 char n[4]; |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
622 GoogleAVSessionData *session_data = |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
623 (GoogleAVSessionData *) session->session_data; |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
624 |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
625 for (cand = xmlnode_get_child(sess, "candidate"); cand; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
626 cand = xmlnode_get_next_twin(cand)) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
627 PurpleMediaCandidate *info; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
628 const gchar *cname = xmlnode_get_attrib(cand, "name"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
629 const gchar *type = xmlnode_get_attrib(cand, "type"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
630 const gchar *protocol = xmlnode_get_attrib(cand, "protocol"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
631 const gchar *address = xmlnode_get_attrib(cand, "address"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
632 const gchar *port = xmlnode_get_attrib(cand, "port"); |
30919
54461ce5f7e0
jabber: priority is called preference in Google mode
Marcus Lundblad <ml@update.uu.se>
parents:
30918
diff
changeset
|
633 const gchar *preference = xmlnode_get_attrib(cand, "preference"); |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
634 guint component_id; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
635 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
636 if (cname && type && address && port) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
637 PurpleMediaCandidateType candidate_type; |
30919
54461ce5f7e0
jabber: priority is called preference in Google mode
Marcus Lundblad <ml@update.uu.se>
parents:
30918
diff
changeset
|
638 guint prio = preference ? atof(preference) * 1000 : 0; |
30918
e97788414900
jabber: set priority on remote candidates for Google-style vv
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
639 |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
640 g_snprintf(n, sizeof(n), "S%d", name++); |
30918
e97788414900
jabber: set priority on remote candidates for Google-style vv
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
641 |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
642 if (g_str_equal(type, "local")) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
643 candidate_type = PURPLE_MEDIA_CANDIDATE_TYPE_HOST; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
644 else if (g_str_equal(type, "stun")) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
645 candidate_type = PURPLE_MEDIA_CANDIDATE_TYPE_PRFLX; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
646 else if (g_str_equal(type, "relay")) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
647 candidate_type = PURPLE_MEDIA_CANDIDATE_TYPE_RELAY; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
648 else |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
649 candidate_type = PURPLE_MEDIA_CANDIDATE_TYPE_HOST; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
650 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
651 if (purple_strequal(cname, "rtcp") || |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
652 purple_strequal(cname, "video_rtcp")) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
653 component_id = PURPLE_MEDIA_COMPONENT_RTCP; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
654 else |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
655 component_id = PURPLE_MEDIA_COMPONENT_RTP; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
656 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
657 info = purple_media_candidate_new(n, component_id, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
658 candidate_type, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
659 purple_strequal(protocol, "udp") ? |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
660 PURPLE_MEDIA_NETWORK_PROTOCOL_UDP : |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
661 PURPLE_MEDIA_NETWORK_PROTOCOL_TCP, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
662 address, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
663 atoi(port)); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
664 g_object_set(info, "username", xmlnode_get_attrib(cand, "username"), |
30918
e97788414900
jabber: set priority on remote candidates for Google-style vv
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
665 "password", xmlnode_get_attrib(cand, "password"), |
e97788414900
jabber: set priority on remote candidates for Google-style vv
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
666 "priority", prio, NULL); |
30964
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
667 if (!strncmp(cname, "video_", 6)) { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
668 if (session_data->added_streams) { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
669 video_list = g_list_append(video_list, info); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
670 } else { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
671 session_data->remote_video_candidates = |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
672 g_list_append(session_data->remote_video_candidates, |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
673 info); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
674 } |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
675 } else { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
676 if (session_data->added_streams) { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
677 list = g_list_append(list, info); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
678 } else { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
679 session_data->remote_audio_candidates = |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
680 g_list_append(session_data->remote_audio_candidates, |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
681 info); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
682 } |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
683 } |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
684 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
685 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
686 |
30964
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
687 if (list) { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
688 purple_media_add_remote_candidates(session_data->media, "google-voice", |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
689 session->remote_jid, list); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
690 purple_media_candidate_list_free(list); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
691 } |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
692 if (video_list) { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
693 purple_media_add_remote_candidates(session_data->media, "google-video", |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
694 session->remote_jid, video_list); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
695 purple_media_candidate_list_free(video_list); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
696 } |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
697 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
698 result = jabber_iq_new(js, JABBER_IQ_RESULT); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
699 jabber_iq_set_id(result, iq_id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
700 xmlnode_set_attrib(result->node, "to", session->remote_jid); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
701 jabber_iq_send(result); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
702 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
703 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
704 static void |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
705 google_session_handle_accept(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
706 { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
707 xmlnode *desc_element = xmlnode_get_child(sess, "description"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
708 xmlnode *codec_element = xmlnode_get_child( |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
709 desc_element, "payload-type"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
710 GList *codecs = NULL, *video_codecs = NULL; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
711 JabberIq *result = NULL; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
712 const gchar *xmlns = xmlnode_get_namespace(desc_element); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
713 gboolean video = (xmlns && !strcmp(xmlns, NS_GOOGLE_SESSION_VIDEO)); |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
714 GoogleAVSessionData *session_data = |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
715 (GoogleAVSessionData *) session->session_data; |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
716 |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
717 for (; codec_element; codec_element = codec_element->next) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
718 const gchar *xmlns, *encoding_name, *id, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
719 *clock_rate, *width, *height, *framerate; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
720 gboolean video_codec = FALSE; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
721 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
722 if (!purple_strequal(codec_element->name, "payload-type")) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
723 continue; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
724 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
725 xmlns = xmlnode_get_namespace(codec_element); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
726 encoding_name = xmlnode_get_attrib(codec_element, "name"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
727 id = xmlnode_get_attrib(codec_element, "id"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
728 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
729 if (!video || purple_strequal(xmlns, NS_GOOGLE_SESSION_PHONE)) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
730 clock_rate = xmlnode_get_attrib( |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
731 codec_element, "clockrate"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
732 else { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
733 clock_rate = "90000"; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
734 width = xmlnode_get_attrib(codec_element, "width"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
735 height = xmlnode_get_attrib(codec_element, "height"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
736 framerate = xmlnode_get_attrib( |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
737 codec_element, "framerate"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
738 video_codec = TRUE; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
739 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
740 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
741 if (id && encoding_name) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
742 PurpleMediaCodec *codec = purple_media_codec_new( |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
743 atoi(id), encoding_name, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
744 video_codec ? PURPLE_MEDIA_VIDEO : |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
745 PURPLE_MEDIA_AUDIO, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
746 clock_rate ? atoi(clock_rate) : 0); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
747 if (video_codec) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
748 video_codecs = g_list_append( |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
749 video_codecs, codec); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
750 else |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
751 codecs = g_list_append(codecs, codec); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
752 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
753 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
754 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
755 if (codecs) |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
756 purple_media_set_remote_codecs(session_data->media, "google-voice", |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
757 session->remote_jid, codecs); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
758 if (video_codecs) |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
759 purple_media_set_remote_codecs(session_data->media, "google-video", |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
760 session->remote_jid, video_codecs); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
761 |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
762 purple_media_stream_info(session_data->media, PURPLE_MEDIA_INFO_ACCEPT, |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
763 NULL, NULL, FALSE); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
764 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
765 result = jabber_iq_new(js, JABBER_IQ_RESULT); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
766 jabber_iq_set_id(result, iq_id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
767 xmlnode_set_attrib(result->node, "to", session->remote_jid); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
768 jabber_iq_send(result); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
769 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
770 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
771 static void |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
772 google_session_handle_reject(JabberStream *js, GoogleSession *session, xmlnode *sess) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
773 { |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
774 GoogleAVSessionData *session_data = |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
775 (GoogleAVSessionData *) session->session_data; |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
776 purple_media_end(session_data->media, NULL, NULL); |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
777 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
778 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
779 static void |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
780 google_session_handle_terminate(JabberStream *js, GoogleSession *session, xmlnode *sess) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
781 { |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
782 GoogleAVSessionData *session_data = |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
783 (GoogleAVSessionData *) session->session_data; |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
784 purple_media_end(session_data->media, NULL, NULL); |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
785 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
786 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
787 static void |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
788 google_session_parse_iq(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
789 { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
790 const char *type = xmlnode_get_attrib(sess, "type"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
791 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
792 if (!strcmp(type, "initiate")) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
793 google_session_handle_initiate(js, session, sess, iq_id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
794 } else if (!strcmp(type, "accept")) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
795 google_session_handle_accept(js, session, sess, iq_id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
796 } else if (!strcmp(type, "reject")) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
797 google_session_handle_reject(js, session, sess); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
798 } else if (!strcmp(type, "terminate")) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
799 google_session_handle_terminate(js, session, sess); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
800 } else if (!strcmp(type, "candidates")) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
801 google_session_handle_candidates(js, session, sess, iq_id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
802 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
803 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
804 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
805 void |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
806 jabber_google_session_parse(JabberStream *js, const char *from, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
807 JabberIqType type, const char *iq_id, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
808 xmlnode *session_node) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
809 { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
810 GoogleSession *session = NULL; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
811 GoogleSessionId id; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
812 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
813 xmlnode *desc_node; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
814 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
815 GList *iter = NULL; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
816 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
817 if (type != JABBER_IQ_SET) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
818 return; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
819 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
820 id.id = (gchar*)xmlnode_get_attrib(session_node, "id"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
821 if (!id.id) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
822 return; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
823 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
824 id.initiator = (gchar*)xmlnode_get_attrib(session_node, "initiator"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
825 if (!id.initiator) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
826 return; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
827 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
828 iter = purple_media_manager_get_media_by_account( |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
829 purple_media_manager_get(), |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
830 purple_connection_get_account(js->gc)); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
831 for (; iter; iter = g_list_delete_link(iter, iter)) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
832 GoogleSession *gsession = |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
833 purple_media_get_prpl_data(iter->data); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
834 if (google_session_id_equal(&(gsession->id), &id)) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
835 session = gsession; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
836 break; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
837 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
838 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
839 if (iter != NULL) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
840 g_list_free(iter); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
841 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
842 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
843 if (session) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
844 google_session_parse_iq(js, session, session_node, iq_id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
845 return; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
846 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
847 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
848 /* If the session doesn't exist, this has to be an initiate message */ |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
849 if (strcmp(xmlnode_get_attrib(session_node, "type"), "initiate")) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
850 return; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
851 desc_node = xmlnode_get_child(session_node, "description"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
852 if (!desc_node) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
853 return; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
854 session = g_new0(GoogleSession, 1); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
855 session->id.id = g_strdup(id.id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
856 session->id.initiator = g_strdup(id.initiator); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
857 session->state = UNINIT; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
858 session->js = js; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
859 session->remote_jid = g_strdup(session->id.initiator); |
30912
f3bc8afc0944
jabber: Missed intialising session_data here.
Marcus Lundblad <ml@update.uu.se>
parents:
30907
diff
changeset
|
860 session->session_data = g_new0(GoogleAVSessionData, 1); |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
861 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
862 google_session_handle_initiate(js, session, session_node, iq_id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
863 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
864 #endif /* USE_VV */ |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
865 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
866 |