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