libpurple/protocols/jabber/jingle/rtp.c

Thu, 03 Oct 2019 11:16:08 +0200

author
Fabrice Bellet <fabrice@bellet.info>
date
Thu, 03 Oct 2019 11:16:08 +0200
branch
port-changes-from-branch-2.x.y-to-default
changeset 40269
334fd0d7c7e6
parent 40195
fb4b0ae193c0
child 40270
88bc25476614
permissions
-rw-r--r--

React only to the first stream info signal

26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
1 /**
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
2 * @file rtp.c
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
3 *
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
4 * purple
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
5 *
28322
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28161
diff changeset
6 * Purple is the legal property of its developers, whose names are too numerous
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28161
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28161
diff changeset
8 * source distribution.
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28161
diff changeset
9 *
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
13 * (at your option) any later version.
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
14 *
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
18 * GNU General Public License for more details.
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
19 *
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
23 */
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
24
35076
cadfc3f9a7cc jabber: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35061
diff changeset
25 #include "internal.h"
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
26
26215
9ecaa256d77b Fix compiling with --disable-vv.
Michael Ruprecht <maiku@pidgin.im>
parents: 26198
diff changeset
27 #ifdef USE_VV
9ecaa256d77b Fix compiling with --disable-vv.
Michael Ruprecht <maiku@pidgin.im>
parents: 26198
diff changeset
28
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
29 #include "jabber.h"
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
30 #include "jingle.h"
33650
19eaf308a449 Initial support for Google's P2P transport.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33631
diff changeset
31 #include "google/google_p2p.h"
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
32 #include "media.h"
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
33 #include "mediamanager.h"
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents: 26161
diff changeset
34 #include "iceudp.h"
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
35 #include "rawudp.h"
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
36 #include "rtp.h"
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
37 #include "session.h"
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
38 #include "debug.h"
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
39
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
40 #include <string.h>
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
41
39552
24d7baa6fcf9 Use G_DECLARE* in Jingle extensions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39494
diff changeset
42 struct _JingleRtp
24d7baa6fcf9 Use G_DECLARE* in Jingle extensions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39494
diff changeset
43 {
24d7baa6fcf9 Use G_DECLARE* in Jingle extensions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39494
diff changeset
44 JingleContent parent;
24d7baa6fcf9 Use G_DECLARE* in Jingle extensions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39494
diff changeset
45 };
24d7baa6fcf9 Use G_DECLARE* in Jingle extensions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39494
diff changeset
46
39494
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
47 typedef struct
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
48 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
49 gchar *media_type;
26405
4cf4d5dcc183 Add ssrc property to JingleRtp.
Michael Ruprecht <maiku@pidgin.im>
parents: 26404
diff changeset
50 gchar *ssrc;
39494
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
51 } JingleRtpPrivate;
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
52
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
53 static JingleContent *jingle_rtp_parse_internal(PurpleXmlNode *rtp);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
54 static PurpleXmlNode *jingle_rtp_to_xml_internal(JingleContent *rtp, PurpleXmlNode *content, JingleActionType action);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
55 static void jingle_rtp_handle_action_internal(JingleContent *content, PurpleXmlNode *jingle, JingleActionType action);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
56
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
57 static PurpleMedia *jingle_rtp_get_media(JingleSession *session);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
58
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
59 enum {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
60 PROP_0,
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
61 PROP_MEDIA_TYPE,
26405
4cf4d5dcc183 Add ssrc property to JingleRtp.
Michael Ruprecht <maiku@pidgin.im>
parents: 26404
diff changeset
62 PROP_SSRC,
35076
cadfc3f9a7cc jabber: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35061
diff changeset
63 PROP_LAST
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
64 };
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
65
35076
cadfc3f9a7cc jabber: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35061
diff changeset
66 static GParamSpec *properties[PROP_LAST];
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
67
39494
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
68 G_DEFINE_DYNAMIC_TYPE_EXTENDED(
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
69 JingleRtp,
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
70 jingle_rtp,
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
71 JINGLE_TYPE_CONTENT,
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
72 0,
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
73 G_ADD_PRIVATE_DYNAMIC(JingleRtp)
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
74 );
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
75
39494
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
76 /******************************************************************************
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
77 * Helpers
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
78 *****************************************************************************/
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
79 static JingleTransport *
33631
21775fb6957a Abstract candidate translation for JingleTransports.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32065
diff changeset
80 jingle_rtp_candidates_to_transport(JingleSession *session, const gchar *type, guint generation, GList *candidates)
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
81 {
33631
21775fb6957a Abstract candidate translation for JingleTransports.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32065
diff changeset
82 JingleTransport *transport;
21775fb6957a Abstract candidate translation for JingleTransports.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32065
diff changeset
83
21775fb6957a Abstract candidate translation for JingleTransports.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32065
diff changeset
84 transport = jingle_transport_create(type);
21775fb6957a Abstract candidate translation for JingleTransports.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32065
diff changeset
85 if (!transport)
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
86 return NULL;
26154
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
87
33631
21775fb6957a Abstract candidate translation for JingleTransports.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32065
diff changeset
88 for (; candidates; candidates = g_list_next(candidates)) {
21775fb6957a Abstract candidate translation for JingleTransports.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32065
diff changeset
89 PurpleMediaCandidate *candidate = candidates->data;
21775fb6957a Abstract candidate translation for JingleTransports.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32065
diff changeset
90 gchar *id = jabber_get_next_id(jingle_session_get_js(session));
21775fb6957a Abstract candidate translation for JingleTransports.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32065
diff changeset
91 jingle_transport_add_local_candidate(transport, id, generation, candidate);
21775fb6957a Abstract candidate translation for JingleTransports.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32065
diff changeset
92 g_free(id);
21775fb6957a Abstract candidate translation for JingleTransports.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32065
diff changeset
93 }
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents: 26161
diff changeset
94
33631
21775fb6957a Abstract candidate translation for JingleTransports.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32065
diff changeset
95 return transport;
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
96 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
97
26437
02b645aac6ee Stop sending multiple session-initiate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26433
diff changeset
98 static void jingle_rtp_ready(JingleSession *session);
26431
993517d98857 Move sending session-initiate out of the ready-new callback.
Michael Ruprecht <maiku@pidgin.im>
parents: 26428
diff changeset
99
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
100 static void
26418
58d9b79f7af6 Implement jingle_rtp_candidates_prepared_cb.
Michael Ruprecht <maiku@pidgin.im>
parents: 26417
diff changeset
101 jingle_rtp_candidates_prepared_cb(PurpleMedia *media,
58d9b79f7af6 Implement jingle_rtp_candidates_prepared_cb.
Michael Ruprecht <maiku@pidgin.im>
parents: 26417
diff changeset
102 gchar *sid, gchar *name, JingleSession *session)
26417
b73b6e73abe6 Add candidates-prepared signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26416
diff changeset
103 {
26418
58d9b79f7af6 Implement jingle_rtp_candidates_prepared_cb.
Michael Ruprecht <maiku@pidgin.im>
parents: 26417
diff changeset
104 JingleContent *content = jingle_session_find_content(
26422
457d5f0223b4 Use new find_content wildcard.
Michael Ruprecht <maiku@pidgin.im>
parents: 26420
diff changeset
105 session, sid, NULL);
26418
58d9b79f7af6 Implement jingle_rtp_candidates_prepared_cb.
Michael Ruprecht <maiku@pidgin.im>
parents: 26417
diff changeset
106 JingleTransport *oldtransport, *transport;
58d9b79f7af6 Implement jingle_rtp_candidates_prepared_cb.
Michael Ruprecht <maiku@pidgin.im>
parents: 26417
diff changeset
107 GList *candidates;
58d9b79f7af6 Implement jingle_rtp_candidates_prepared_cb.
Michael Ruprecht <maiku@pidgin.im>
parents: 26417
diff changeset
108
26417
b73b6e73abe6 Add candidates-prepared signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26416
diff changeset
109 purple_debug_info("jingle-rtp", "jingle_rtp_candidates_prepared_cb\n");
26418
58d9b79f7af6 Implement jingle_rtp_candidates_prepared_cb.
Michael Ruprecht <maiku@pidgin.im>
parents: 26417
diff changeset
110
58d9b79f7af6 Implement jingle_rtp_candidates_prepared_cb.
Michael Ruprecht <maiku@pidgin.im>
parents: 26417
diff changeset
111 if (content == NULL) {
58d9b79f7af6 Implement jingle_rtp_candidates_prepared_cb.
Michael Ruprecht <maiku@pidgin.im>
parents: 26417
diff changeset
112 purple_debug_error("jingle-rtp",
58d9b79f7af6 Implement jingle_rtp_candidates_prepared_cb.
Michael Ruprecht <maiku@pidgin.im>
parents: 26417
diff changeset
113 "jingle_rtp_candidates_prepared_cb: "
58d9b79f7af6 Implement jingle_rtp_candidates_prepared_cb.
Michael Ruprecht <maiku@pidgin.im>
parents: 26417
diff changeset
114 "Can't find session %s\n", sid);
58d9b79f7af6 Implement jingle_rtp_candidates_prepared_cb.
Michael Ruprecht <maiku@pidgin.im>
parents: 26417
diff changeset
115 return;
58d9b79f7af6 Implement jingle_rtp_candidates_prepared_cb.
Michael Ruprecht <maiku@pidgin.im>
parents: 26417
diff changeset
116 }
58d9b79f7af6 Implement jingle_rtp_candidates_prepared_cb.
Michael Ruprecht <maiku@pidgin.im>
parents: 26417
diff changeset
117
58d9b79f7af6 Implement jingle_rtp_candidates_prepared_cb.
Michael Ruprecht <maiku@pidgin.im>
parents: 26417
diff changeset
118 oldtransport = jingle_content_get_transport(content);
58d9b79f7af6 Implement jingle_rtp_candidates_prepared_cb.
Michael Ruprecht <maiku@pidgin.im>
parents: 26417
diff changeset
119 candidates = purple_media_get_local_candidates(media, sid, name);
33631
21775fb6957a Abstract candidate translation for JingleTransports.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32065
diff changeset
120 transport = jingle_rtp_candidates_to_transport(
21775fb6957a Abstract candidate translation for JingleTransports.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32065
diff changeset
121 session, jingle_transport_get_transport_type(oldtransport),
21775fb6957a Abstract candidate translation for JingleTransports.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32065
diff changeset
122 0, candidates);
26418
58d9b79f7af6 Implement jingle_rtp_candidates_prepared_cb.
Michael Ruprecht <maiku@pidgin.im>
parents: 26417
diff changeset
123
58d9b79f7af6 Implement jingle_rtp_candidates_prepared_cb.
Michael Ruprecht <maiku@pidgin.im>
parents: 26417
diff changeset
124 g_list_free(candidates);
58d9b79f7af6 Implement jingle_rtp_candidates_prepared_cb.
Michael Ruprecht <maiku@pidgin.im>
parents: 26417
diff changeset
125 g_object_unref(oldtransport);
58d9b79f7af6 Implement jingle_rtp_candidates_prepared_cb.
Michael Ruprecht <maiku@pidgin.im>
parents: 26417
diff changeset
126
58d9b79f7af6 Implement jingle_rtp_candidates_prepared_cb.
Michael Ruprecht <maiku@pidgin.im>
parents: 26417
diff changeset
127 jingle_content_set_pending_transport(content, transport);
58d9b79f7af6 Implement jingle_rtp_candidates_prepared_cb.
Michael Ruprecht <maiku@pidgin.im>
parents: 26417
diff changeset
128 jingle_content_accept_transport(content);
26431
993517d98857 Move sending session-initiate out of the ready-new callback.
Michael Ruprecht <maiku@pidgin.im>
parents: 26428
diff changeset
129
26437
02b645aac6ee Stop sending multiple session-initiate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26433
diff changeset
130 jingle_rtp_ready(session);
26417
b73b6e73abe6 Add candidates-prepared signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26416
diff changeset
131 }
b73b6e73abe6 Add candidates-prepared signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26416
diff changeset
132
b73b6e73abe6 Add candidates-prepared signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26416
diff changeset
133 static void
26265
66aee93241e2 Added codecs-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26264
diff changeset
134 jingle_rtp_codecs_changed_cb(PurpleMedia *media, gchar *sid,
66aee93241e2 Added codecs-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26264
diff changeset
135 JingleSession *session)
66aee93241e2 Added codecs-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26264
diff changeset
136 {
66aee93241e2 Added codecs-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26264
diff changeset
137 purple_debug_info("jingle-rtp", "jingle_rtp_codecs_changed_cb: "
66aee93241e2 Added codecs-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26264
diff changeset
138 "session_id: %s jingle_session: %p\n", sid, session);
26437
02b645aac6ee Stop sending multiple session-initiate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26433
diff changeset
139 jingle_rtp_ready(session);
26265
66aee93241e2 Added codecs-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26264
diff changeset
140 }
66aee93241e2 Added codecs-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26264
diff changeset
141
66aee93241e2 Added codecs-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26264
diff changeset
142 static void
26229
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26226
diff changeset
143 jingle_rtp_new_candidate_cb(PurpleMedia *media, gchar *sid, gchar *name, PurpleMediaCandidate *candidate, JingleSession *session)
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
144 {
33631
21775fb6957a Abstract candidate translation for JingleTransports.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32065
diff changeset
145 JingleContent *content = jingle_session_find_content(session, sid, NULL);
26416
1536df3f6fc7 Send any additional candidates found after session-initiate or
Michael Ruprecht <maiku@pidgin.im>
parents: 26410
diff changeset
146 JingleTransport *transport;
33631
21775fb6957a Abstract candidate translation for JingleTransports.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32065
diff changeset
147 gchar *id;
26416
1536df3f6fc7 Send any additional candidates found after session-initiate or
Michael Ruprecht <maiku@pidgin.im>
parents: 26410
diff changeset
148
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
149 purple_debug_info("jingle-rtp", "jingle_rtp_new_candidate_cb\n");
26416
1536df3f6fc7 Send any additional candidates found after session-initiate or
Michael Ruprecht <maiku@pidgin.im>
parents: 26410
diff changeset
150
1536df3f6fc7 Send any additional candidates found after session-initiate or
Michael Ruprecht <maiku@pidgin.im>
parents: 26410
diff changeset
151 if (content == NULL) {
1536df3f6fc7 Send any additional candidates found after session-initiate or
Michael Ruprecht <maiku@pidgin.im>
parents: 26410
diff changeset
152 purple_debug_error("jingle-rtp",
1536df3f6fc7 Send any additional candidates found after session-initiate or
Michael Ruprecht <maiku@pidgin.im>
parents: 26410
diff changeset
153 "jingle_rtp_new_candidate_cb: "
1536df3f6fc7 Send any additional candidates found after session-initiate or
Michael Ruprecht <maiku@pidgin.im>
parents: 26410
diff changeset
154 "Can't find session %s\n", sid);
1536df3f6fc7 Send any additional candidates found after session-initiate or
Michael Ruprecht <maiku@pidgin.im>
parents: 26410
diff changeset
155 return;
1536df3f6fc7 Send any additional candidates found after session-initiate or
Michael Ruprecht <maiku@pidgin.im>
parents: 26410
diff changeset
156 }
1536df3f6fc7 Send any additional candidates found after session-initiate or
Michael Ruprecht <maiku@pidgin.im>
parents: 26410
diff changeset
157
1536df3f6fc7 Send any additional candidates found after session-initiate or
Michael Ruprecht <maiku@pidgin.im>
parents: 26410
diff changeset
158 transport = jingle_content_get_transport(content);
1536df3f6fc7 Send any additional candidates found after session-initiate or
Michael Ruprecht <maiku@pidgin.im>
parents: 26410
diff changeset
159
33631
21775fb6957a Abstract candidate translation for JingleTransports.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32065
diff changeset
160 id = jabber_get_next_id(jingle_session_get_js(session));
21775fb6957a Abstract candidate translation for JingleTransports.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32065
diff changeset
161 jingle_transport_add_local_candidate(transport, id, 1, candidate);
21775fb6957a Abstract candidate translation for JingleTransports.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32065
diff changeset
162 g_free(id);
26416
1536df3f6fc7 Send any additional candidates found after session-initiate or
Michael Ruprecht <maiku@pidgin.im>
parents: 26410
diff changeset
163
1536df3f6fc7 Send any additional candidates found after session-initiate or
Michael Ruprecht <maiku@pidgin.im>
parents: 26410
diff changeset
164 g_object_unref(transport);
1536df3f6fc7 Send any additional candidates found after session-initiate or
Michael Ruprecht <maiku@pidgin.im>
parents: 26410
diff changeset
165
33631
21775fb6957a Abstract candidate translation for JingleTransports.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32065
diff changeset
166 jabber_iq_send(jingle_session_to_packet(session, JINGLE_TRANSPORT_INFO));
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
167 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
168
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
169 static void
26694
3d9ac30490ab Fix merge for ./jingle/
Paul Aurich <darkrain42@pidgin.im>
parents: 26620
diff changeset
170 jingle_rtp_initiate_ack_cb(JabberStream *js, const char *from,
3d9ac30490ab Fix merge for ./jingle/
Paul Aurich <darkrain42@pidgin.im>
parents: 26620
diff changeset
171 JabberIqType type, const char *id,
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
172 PurpleXmlNode *packet, gpointer data)
26311
0baf4bc1b441 Wait to send transport-info until the session-initiate ack is received.
Michael Ruprecht <maiku@pidgin.im>
parents: 26303
diff changeset
173 {
0baf4bc1b441 Wait to send transport-info until the session-initiate ack is received.
Michael Ruprecht <maiku@pidgin.im>
parents: 26303
diff changeset
174 JingleSession *session = data;
0baf4bc1b441 Wait to send transport-info until the session-initiate ack is received.
Michael Ruprecht <maiku@pidgin.im>
parents: 26303
diff changeset
175
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
176 if (type == JABBER_IQ_ERROR || purple_xmlnode_get_child(packet, "error")) {
26311
0baf4bc1b441 Wait to send transport-info until the session-initiate ack is received.
Michael Ruprecht <maiku@pidgin.im>
parents: 26303
diff changeset
177 purple_media_end(jingle_rtp_get_media(session), NULL, NULL);
26312
dcbb96abceae Free the session as well on error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26311
diff changeset
178 g_object_unref(session);
26311
0baf4bc1b441 Wait to send transport-info until the session-initiate ack is received.
Michael Ruprecht <maiku@pidgin.im>
parents: 26303
diff changeset
179 return;
0baf4bc1b441 Wait to send transport-info until the session-initiate ack is received.
Michael Ruprecht <maiku@pidgin.im>
parents: 26303
diff changeset
180 }
0baf4bc1b441 Wait to send transport-info until the session-initiate ack is received.
Michael Ruprecht <maiku@pidgin.im>
parents: 26303
diff changeset
181 }
0baf4bc1b441 Wait to send transport-info until the session-initiate ack is received.
Michael Ruprecht <maiku@pidgin.im>
parents: 26303
diff changeset
182
0baf4bc1b441 Wait to send transport-info until the session-initiate ack is received.
Michael Ruprecht <maiku@pidgin.im>
parents: 26303
diff changeset
183 static void
26449
9e381dc6ed24 Rename state-changed enum and values.
Michael Ruprecht <maiku@pidgin.im>
parents: 26441
diff changeset
184 jingle_rtp_state_changed_cb(PurpleMedia *media, PurpleMediaState state,
26193
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26192
diff changeset
185 gchar *sid, gchar *name, JingleSession *session)
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26192
diff changeset
186 {
26449
9e381dc6ed24 Rename state-changed enum and values.
Michael Ruprecht <maiku@pidgin.im>
parents: 26441
diff changeset
187 purple_debug_info("jingle-rtp", "state-changed: state %d "
27974
2021706e911d Fixes for some potential printf("%s", NULL) type of problems from Maiku
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 26746
diff changeset
188 "id: %s name: %s\n", state, sid ? sid : "(null)",
2021706e911d Fixes for some potential printf("%s", NULL) type of problems from Maiku
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 26746
diff changeset
189 name ? name : "(null)");
26441
46a5bb7783e7 Use stream-info instead of state-changed for hangup and reject.
Michael Ruprecht <maiku@pidgin.im>
parents: 26437
diff changeset
190 }
26194
b8aab50491f4 Use the state-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26193
diff changeset
191
26441
46a5bb7783e7 Use stream-info instead of state-changed for hangup and reject.
Michael Ruprecht <maiku@pidgin.im>
parents: 26437
diff changeset
192 static void
46a5bb7783e7 Use stream-info instead of state-changed for hangup and reject.
Michael Ruprecht <maiku@pidgin.im>
parents: 26437
diff changeset
193 jingle_rtp_stream_info_cb(PurpleMedia *media, PurpleMediaInfoType type,
26496
11e1e5221460 Create purple_media_stream_info. Add local parameter to stream-info signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26495
diff changeset
194 gchar *sid, gchar *name, gboolean local,
11e1e5221460 Create purple_media_stream_info. Add local parameter to stream-info signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26495
diff changeset
195 JingleSession *session)
26441
46a5bb7783e7 Use stream-info instead of state-changed for hangup and reject.
Michael Ruprecht <maiku@pidgin.im>
parents: 26437
diff changeset
196 {
46a5bb7783e7 Use stream-info instead of state-changed for hangup and reject.
Michael Ruprecht <maiku@pidgin.im>
parents: 26437
diff changeset
197 purple_debug_info("jingle-rtp", "stream-info: type %d "
27974
2021706e911d Fixes for some potential printf("%s", NULL) type of problems from Maiku
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 26746
diff changeset
198 "id: %s name: %s\n", type, sid ? sid : "(null)",
2021706e911d Fixes for some potential printf("%s", NULL) type of problems from Maiku
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 26746
diff changeset
199 name ? name : "(null)");
26746
2a2d45ac9774 Switch media to store accounts rather than connections.
Michael Ruprecht <maiku@pidgin.im>
parents: 26696
diff changeset
200
2a2d45ac9774 Switch media to store accounts rather than connections.
Michael Ruprecht <maiku@pidgin.im>
parents: 26696
diff changeset
201 g_return_if_fail(JINGLE_IS_SESSION(session));
2a2d45ac9774 Switch media to store accounts rather than connections.
Michael Ruprecht <maiku@pidgin.im>
parents: 26696
diff changeset
202
29614
35ca95d87e11 Fix so emitting more HANGUP signals doesn't cause an assertion.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
203 if (type == PURPLE_MEDIA_INFO_HANGUP ||
35ca95d87e11 Fix so emitting more HANGUP signals doesn't cause an assertion.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
204 type == PURPLE_MEDIA_INFO_REJECT) {
26404
3947a428b87d Add functions for more easily creating session-terminate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26330
diff changeset
205 jabber_iq_send(jingle_session_terminate_packet(
29614
35ca95d87e11 Fix so emitting more HANGUP signals doesn't cause an assertion.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
206 session, type == PURPLE_MEDIA_INFO_HANGUP ?
35ca95d87e11 Fix so emitting more HANGUP signals doesn't cause an assertion.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
207 "success" : "decline"));
35ca95d87e11 Fix so emitting more HANGUP signals doesn't cause an assertion.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
208
35ca95d87e11 Fix so emitting more HANGUP signals doesn't cause an assertion.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
209 g_signal_handlers_disconnect_by_func(G_OBJECT(media),
35ca95d87e11 Fix so emitting more HANGUP signals doesn't cause an assertion.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
210 G_CALLBACK(jingle_rtp_state_changed_cb),
35ca95d87e11 Fix so emitting more HANGUP signals doesn't cause an assertion.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
211 session);
35ca95d87e11 Fix so emitting more HANGUP signals doesn't cause an assertion.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
212 g_signal_handlers_disconnect_by_func(G_OBJECT(media),
35ca95d87e11 Fix so emitting more HANGUP signals doesn't cause an assertion.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
213 G_CALLBACK(jingle_rtp_stream_info_cb),
35ca95d87e11 Fix so emitting more HANGUP signals doesn't cause an assertion.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
214 session);
35ca95d87e11 Fix so emitting more HANGUP signals doesn't cause an assertion.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
215 g_signal_handlers_disconnect_by_func(G_OBJECT(media),
35ca95d87e11 Fix so emitting more HANGUP signals doesn't cause an assertion.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
216 G_CALLBACK(jingle_rtp_new_candidate_cb),
35ca95d87e11 Fix so emitting more HANGUP signals doesn't cause an assertion.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
217 session);
35ca95d87e11 Fix so emitting more HANGUP signals doesn't cause an assertion.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
218
26441
46a5bb7783e7 Use stream-info instead of state-changed for hangup and reject.
Michael Ruprecht <maiku@pidgin.im>
parents: 26437
diff changeset
219 g_object_unref(session);
40269
334fd0d7c7e6 React only to the first stream info signal
Fabrice Bellet <fabrice@bellet.info>
parents: 40195
diff changeset
220 /* The same signal is emited *four* times in case of acceptance
334fd0d7c7e6 React only to the first stream info signal
Fabrice Bellet <fabrice@bellet.info>
parents: 40195
diff changeset
221 * by purple_media_stream_info() (stream acceptance, session
334fd0d7c7e6 React only to the first stream info signal
Fabrice Bellet <fabrice@bellet.info>
parents: 40195
diff changeset
222 * acceptance, participant acceptance, and conference acceptance).
334fd0d7c7e6 React only to the first stream info signal
Fabrice Bellet <fabrice@bellet.info>
parents: 40195
diff changeset
223 * We only react to the first one, where sid and name are given
334fd0d7c7e6 React only to the first stream info signal
Fabrice Bellet <fabrice@bellet.info>
parents: 40195
diff changeset
224 * non-null values.
334fd0d7c7e6 React only to the first stream info signal
Fabrice Bellet <fabrice@bellet.info>
parents: 40195
diff changeset
225 */
334fd0d7c7e6 React only to the first stream info signal
Fabrice Bellet <fabrice@bellet.info>
parents: 40195
diff changeset
226 } else if (type == PURPLE_MEDIA_INFO_ACCEPT && sid && name &&
28111
61de2e173be9 Remove the "accepted" signal from PurpleMedia as it was redundant.
Michael Ruprecht <maiku@pidgin.im>
parents: 27974
diff changeset
227 jingle_session_is_initiator(session) == FALSE) {
40269
334fd0d7c7e6 React only to the first stream info signal
Fabrice Bellet <fabrice@bellet.info>
parents: 40195
diff changeset
228
28111
61de2e173be9 Remove the "accepted" signal from PurpleMedia as it was redundant.
Michael Ruprecht <maiku@pidgin.im>
parents: 27974
diff changeset
229 jingle_rtp_ready(session);
26194
b8aab50491f4 Use the state-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26193
diff changeset
230 }
26193
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26192
diff changeset
231 }
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26192
diff changeset
232
26431
993517d98857 Move sending session-initiate out of the ready-new callback.
Michael Ruprecht <maiku@pidgin.im>
parents: 26428
diff changeset
233 static void
26437
02b645aac6ee Stop sending multiple session-initiate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26433
diff changeset
234 jingle_rtp_ready(JingleSession *session)
26431
993517d98857 Move sending session-initiate out of the ready-new callback.
Michael Ruprecht <maiku@pidgin.im>
parents: 26428
diff changeset
235 {
993517d98857 Move sending session-initiate out of the ready-new callback.
Michael Ruprecht <maiku@pidgin.im>
parents: 26428
diff changeset
236 PurpleMedia *media = jingle_rtp_get_media(session);
993517d98857 Move sending session-initiate out of the ready-new callback.
Michael Ruprecht <maiku@pidgin.im>
parents: 26428
diff changeset
237
26437
02b645aac6ee Stop sending multiple session-initiate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26433
diff changeset
238 if (purple_media_candidates_prepared(media, NULL, NULL) &&
26431
993517d98857 Move sending session-initiate out of the ready-new callback.
Michael Ruprecht <maiku@pidgin.im>
parents: 26428
diff changeset
239 purple_media_codecs_ready(media, NULL) &&
26437
02b645aac6ee Stop sending multiple session-initiate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26433
diff changeset
240 (jingle_session_is_initiator(session) == TRUE ||
02b645aac6ee Stop sending multiple session-initiate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26433
diff changeset
241 purple_media_accepted(media, NULL, NULL))) {
02b645aac6ee Stop sending multiple session-initiate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26433
diff changeset
242 if (jingle_session_is_initiator(session)) {
02b645aac6ee Stop sending multiple session-initiate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26433
diff changeset
243 JabberIq *iq = jingle_session_to_packet(
02b645aac6ee Stop sending multiple session-initiate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26433
diff changeset
244 session, JINGLE_SESSION_INITIATE);
02b645aac6ee Stop sending multiple session-initiate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26433
diff changeset
245 jabber_iq_set_callback(iq,
02b645aac6ee Stop sending multiple session-initiate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26433
diff changeset
246 jingle_rtp_initiate_ack_cb, session);
02b645aac6ee Stop sending multiple session-initiate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26433
diff changeset
247 jabber_iq_send(iq);
02b645aac6ee Stop sending multiple session-initiate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26433
diff changeset
248 } else {
02b645aac6ee Stop sending multiple session-initiate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26433
diff changeset
249 jabber_iq_send(jingle_session_to_packet(session,
02b645aac6ee Stop sending multiple session-initiate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26433
diff changeset
250 JINGLE_SESSION_ACCEPT));
02b645aac6ee Stop sending multiple session-initiate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26433
diff changeset
251 }
02b645aac6ee Stop sending multiple session-initiate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26433
diff changeset
252
02b645aac6ee Stop sending multiple session-initiate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26433
diff changeset
253 g_signal_handlers_disconnect_by_func(G_OBJECT(media),
02b645aac6ee Stop sending multiple session-initiate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26433
diff changeset
254 G_CALLBACK(jingle_rtp_candidates_prepared_cb),
26431
993517d98857 Move sending session-initiate out of the ready-new callback.
Michael Ruprecht <maiku@pidgin.im>
parents: 26428
diff changeset
255 session);
26437
02b645aac6ee Stop sending multiple session-initiate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26433
diff changeset
256 g_signal_handlers_disconnect_by_func(G_OBJECT(media),
02b645aac6ee Stop sending multiple session-initiate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26433
diff changeset
257 G_CALLBACK(jingle_rtp_codecs_changed_cb),
02b645aac6ee Stop sending multiple session-initiate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26433
diff changeset
258 session);
26433
3213aeff8bdb Move sending session-accept out of the ready-new signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26431
diff changeset
259 g_signal_connect(G_OBJECT(media), "new-candidate",
3213aeff8bdb Move sending session-accept out of the ready-new signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26431
diff changeset
260 G_CALLBACK(jingle_rtp_new_candidate_cb),
3213aeff8bdb Move sending session-accept out of the ready-new signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26431
diff changeset
261 session);
3213aeff8bdb Move sending session-accept out of the ready-new signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26431
diff changeset
262 }
3213aeff8bdb Move sending session-accept out of the ready-new signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26431
diff changeset
263 }
3213aeff8bdb Move sending session-accept out of the ready-new signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26431
diff changeset
264
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
265 static PurpleMedia *
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
266 jingle_rtp_create_media(JingleContent *content)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
267 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
268 JingleSession *session = jingle_content_get_session(content);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
269 JabberStream *js = jingle_session_get_js(session);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
270 gchar *remote_jid = jingle_session_get_remote_jid(session);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
271
26746
2a2d45ac9774 Switch media to store accounts rather than connections.
Michael Ruprecht <maiku@pidgin.im>
parents: 26696
diff changeset
272 PurpleMedia *media = purple_media_manager_create_media(
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30764
diff changeset
273 purple_media_manager_get(),
26746
2a2d45ac9774 Switch media to store accounts rather than connections.
Michael Ruprecht <maiku@pidgin.im>
parents: 26696
diff changeset
274 purple_connection_get_account(js->gc),
2a2d45ac9774 Switch media to store accounts rather than connections.
Michael Ruprecht <maiku@pidgin.im>
parents: 26696
diff changeset
275 "fsrtpconference", remote_jid,
2a2d45ac9774 Switch media to store accounts rather than connections.
Michael Ruprecht <maiku@pidgin.im>
parents: 26696
diff changeset
276 jingle_session_is_initiator(session));
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
277 g_free(remote_jid);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
278
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
279 if (!media) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
280 purple_debug_error("jingle-rtp", "Couldn't create media session\n");
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
281 return NULL;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
282 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
283
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
284 purple_media_set_protocol_data(media, session);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
285
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
286 /* connect callbacks */
26417
b73b6e73abe6 Add candidates-prepared signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26416
diff changeset
287 g_signal_connect(G_OBJECT(media), "candidates-prepared",
b73b6e73abe6 Add candidates-prepared signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26416
diff changeset
288 G_CALLBACK(jingle_rtp_candidates_prepared_cb), session);
26265
66aee93241e2 Added codecs-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26264
diff changeset
289 g_signal_connect(G_OBJECT(media), "codecs-changed",
66aee93241e2 Added codecs-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26264
diff changeset
290 G_CALLBACK(jingle_rtp_codecs_changed_cb), session);
26193
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26192
diff changeset
291 g_signal_connect(G_OBJECT(media), "state-changed",
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26192
diff changeset
292 G_CALLBACK(jingle_rtp_state_changed_cb), session);
26441
46a5bb7783e7 Use stream-info instead of state-changed for hangup and reject.
Michael Ruprecht <maiku@pidgin.im>
parents: 26437
diff changeset
293 g_signal_connect(G_OBJECT(media), "stream-info",
46a5bb7783e7 Use stream-info instead of state-changed for hangup and reject.
Michael Ruprecht <maiku@pidgin.im>
parents: 26437
diff changeset
294 G_CALLBACK(jingle_rtp_stream_info_cb), session);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
295
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
296 g_object_unref(session);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
297 return media;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
298 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
299
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
300 static gboolean
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
301 jingle_rtp_init_media(JingleContent *content)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
302 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
303 JingleSession *session = jingle_content_get_session(content);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
304 PurpleMedia *media = jingle_rtp_get_media(session);
26514
058053cffc0e Add purple_media_is_initiator.
Michael Ruprecht <maiku@pidgin.im>
parents: 26501
diff changeset
305 gchar *creator;
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
306 gchar *media_type;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
307 gchar *remote_jid;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
308 gchar *senders;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
309 gchar *name;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
310 const gchar *transmitter;
26226
dcb05990f479 Make FsStreamDirection and FsMediaType conversion functions static.
Michael Ruprecht <maiku@pidgin.im>
parents: 26215
diff changeset
311 gboolean is_audio;
26514
058053cffc0e Add purple_media_is_initiator.
Michael Ruprecht <maiku@pidgin.im>
parents: 26501
diff changeset
312 gboolean is_creator;
26226
dcb05990f479 Make FsStreamDirection and FsMediaType conversion functions static.
Michael Ruprecht <maiku@pidgin.im>
parents: 26215
diff changeset
313 PurpleMediaSessionType type;
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
314 JingleTransport *transport;
26286
443041606e32 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <malu@pidgin.im>
parents: 26266
diff changeset
315 GParameter *params = NULL;
443041606e32 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <malu@pidgin.im>
parents: 26266
diff changeset
316 guint num_params;
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
317
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
318 /* maybe this create ought to just be in initiate and handle initiate */
32064
883a1b407408 Minor optimization
Mark Doliner <markdoliner@pidgin.im>
parents: 31294
diff changeset
319 if (media == NULL) {
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
320 media = jingle_rtp_create_media(content);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
321
32064
883a1b407408 Minor optimization
Mark Doliner <markdoliner@pidgin.im>
parents: 31294
diff changeset
322 if (media == NULL)
883a1b407408 Minor optimization
Mark Doliner <markdoliner@pidgin.im>
parents: 31294
diff changeset
323 return FALSE;
883a1b407408 Minor optimization
Mark Doliner <markdoliner@pidgin.im>
parents: 31294
diff changeset
324 }
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
325
39915
7b19c6362c4e Remove redundant frees.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39552
diff changeset
326 media_type = jingle_rtp_get_media_type(content);
7b19c6362c4e Remove redundant frees.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39552
diff changeset
327 if (media_type == NULL) {
7b19c6362c4e Remove redundant frees.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39552
diff changeset
328 g_object_unref(session);
7b19c6362c4e Remove redundant frees.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39552
diff changeset
329 return FALSE;
7b19c6362c4e Remove redundant frees.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39552
diff changeset
330 }
7b19c6362c4e Remove redundant frees.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39552
diff changeset
331
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
332 name = jingle_content_get_name(content);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
333 remote_jid = jingle_session_get_remote_jid(session);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
334 senders = jingle_content_get_senders(content);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
335 transport = jingle_content_get_transport(content);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
336
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
337 if (JINGLE_IS_RAWUDP(transport))
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
338 transmitter = "rawudp";
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents: 26161
diff changeset
339 else if (JINGLE_IS_ICEUDP(transport))
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents: 26161
diff changeset
340 transmitter = "nice";
33650
19eaf308a449 Initial support for Google's P2P transport.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33631
diff changeset
341 else if (JINGLE_IS_GOOGLE_P2P(transport))
19eaf308a449 Initial support for Google's P2P transport.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33631
diff changeset
342 transmitter = "nice";
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
343 else
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
344 transmitter = "notransmitter";
26410
5952dcb9ce6c Plug some memory leaks related to transports.
Michael Ruprecht <maiku@pidgin.im>
parents: 26407
diff changeset
345 g_object_unref(transport);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
346
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 33789
diff changeset
347 is_audio = purple_strequal(media_type, "audio");
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
348
32065
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
349 if (purple_strequal(senders, "both"))
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
350 type = is_audio ? PURPLE_MEDIA_AUDIO
26226
dcb05990f479 Make FsStreamDirection and FsMediaType conversion functions static.
Michael Ruprecht <maiku@pidgin.im>
parents: 26215
diff changeset
351 : PURPLE_MEDIA_VIDEO;
32065
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
352 else if (purple_strequal(senders, "initiator") ==
28161
4368c139d67f Fix unidirectional media sessions and add a colorspace before the video sink.
Michael Ruprecht <maiku@pidgin.im>
parents: 28111
diff changeset
353 jingle_session_is_initiator(session))
32065
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
354 type = is_audio ? PURPLE_MEDIA_SEND_AUDIO
26226
dcb05990f479 Make FsStreamDirection and FsMediaType conversion functions static.
Michael Ruprecht <maiku@pidgin.im>
parents: 26215
diff changeset
355 : PURPLE_MEDIA_SEND_VIDEO;
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
356 else
32065
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
357 type = is_audio ? PURPLE_MEDIA_RECV_AUDIO
26226
dcb05990f479 Make FsStreamDirection and FsMediaType conversion functions static.
Michael Ruprecht <maiku@pidgin.im>
parents: 26215
diff changeset
358 : PURPLE_MEDIA_RECV_VIDEO;
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
359
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30764
diff changeset
360 params =
28567
b5ea98ed9e32 Can now generate a relayed candidate for the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 28333
diff changeset
361 jingle_get_params(jingle_session_get_js(session), NULL, 0, 0, 0,
b5ea98ed9e32 Can now generate a relayed candidate for the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 28333
diff changeset
362 NULL, NULL, &num_params);
26514
058053cffc0e Add purple_media_is_initiator.
Michael Ruprecht <maiku@pidgin.im>
parents: 26501
diff changeset
363
058053cffc0e Add purple_media_is_initiator.
Michael Ruprecht <maiku@pidgin.im>
parents: 26501
diff changeset
364 creator = jingle_content_get_creator(content);
32065
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
365 if (creator == NULL) {
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
366 g_free(name);
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
367 g_free(media_type);
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
368 g_free(remote_jid);
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
369 g_free(senders);
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
370 g_free(params);
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
371 g_object_unref(session);
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
372 return FALSE;
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
373 }
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
374
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 33789
diff changeset
375 if (purple_strequal(creator, "initiator"))
26514
058053cffc0e Add purple_media_is_initiator.
Michael Ruprecht <maiku@pidgin.im>
parents: 26501
diff changeset
376 is_creator = jingle_session_is_initiator(session);
058053cffc0e Add purple_media_is_initiator.
Michael Ruprecht <maiku@pidgin.im>
parents: 26501
diff changeset
377 else
058053cffc0e Add purple_media_is_initiator.
Michael Ruprecht <maiku@pidgin.im>
parents: 26501
diff changeset
378 is_creator = !jingle_session_is_initiator(session);
058053cffc0e Add purple_media_is_initiator.
Michael Ruprecht <maiku@pidgin.im>
parents: 26501
diff changeset
379 g_free(creator);
058053cffc0e Add purple_media_is_initiator.
Michael Ruprecht <maiku@pidgin.im>
parents: 26501
diff changeset
380
28330
07902a9634f9 More gracefully handle stream creation errors with Jingle calls.
Michael Ruprecht <maiku@pidgin.im>
parents: 28161
diff changeset
381 if(!purple_media_add_stream(media, name, remote_jid,
07902a9634f9 More gracefully handle stream creation errors with Jingle calls.
Michael Ruprecht <maiku@pidgin.im>
parents: 28161
diff changeset
382 type, is_creator, transmitter, num_params, params)) {
07902a9634f9 More gracefully handle stream creation errors with Jingle calls.
Michael Ruprecht <maiku@pidgin.im>
parents: 28161
diff changeset
383 purple_media_end(media, NULL, NULL);
32065
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
384 /* TODO: How much clean-up is necessary here? (does calling
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
385 purple_media_end lead to cleaning up Jingle structs?) */
28330
07902a9634f9 More gracefully handle stream creation errors with Jingle calls.
Michael Ruprecht <maiku@pidgin.im>
parents: 28161
diff changeset
386 return FALSE;
07902a9634f9 More gracefully handle stream creation errors with Jingle calls.
Michael Ruprecht <maiku@pidgin.im>
parents: 28161
diff changeset
387 }
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
388
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
389 g_free(name);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
390 g_free(media_type);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
391 g_free(remote_jid);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
392 g_free(senders);
26286
443041606e32 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <malu@pidgin.im>
parents: 26266
diff changeset
393 g_free(params);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
394 g_object_unref(session);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
395
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
396 return TRUE;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
397 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
398
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
399 static GList *
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
400 jingle_rtp_parse_codecs(PurpleXmlNode *description)
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
401 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
402 GList *codecs = NULL;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
403 PurpleXmlNode *codec_element = NULL;
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
404 const char *encoding_name,*id, *clock_rate;
26232
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26229
diff changeset
405 PurpleMediaCodec *codec;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
406 const gchar *media = purple_xmlnode_get_attrib(description, "media");
32065
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
407 PurpleMediaSessionType type;
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
408
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
409 if (media == NULL) {
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
410 purple_debug_warning("jingle-rtp", "missing media type\n");
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
411 return NULL;
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
412 }
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
413
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 33789
diff changeset
414 if (purple_strequal(media, "video")) {
32065
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
415 type = PURPLE_MEDIA_VIDEO;
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 33789
diff changeset
416 } else if (purple_strequal(media, "audio")) {
32065
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
417 type = PURPLE_MEDIA_AUDIO;
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
418 } else {
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
419 purple_debug_warning("jingle-rtp", "unknown media type: %s\n",
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
420 media);
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
421 return NULL;
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
422 }
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
423
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
424 for (codec_element = purple_xmlnode_get_child(description, "payload-type") ;
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
425 codec_element ;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
426 codec_element = purple_xmlnode_get_next_twin(codec_element)) {
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
427 PurpleXmlNode *param;
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
428 gchar *codec_str;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
429 encoding_name = purple_xmlnode_get_attrib(codec_element, "name");
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
430
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
431 id = purple_xmlnode_get_attrib(codec_element, "id");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
432 clock_rate = purple_xmlnode_get_attrib(codec_element, "clockrate");
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
433
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30764
diff changeset
434 codec = purple_media_codec_new(atoi(id), encoding_name,
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30764
diff changeset
435 type,
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
436 clock_rate ? atoi(clock_rate) : 0);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
437
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
438 for (param = purple_xmlnode_get_child(codec_element, "parameter");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
439 param; param = purple_xmlnode_get_next_twin(param)) {
26232
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26229
diff changeset
440 purple_media_codec_add_optional_parameter(codec,
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
441 purple_xmlnode_get_attrib(param, "name"),
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
442 purple_xmlnode_get_attrib(param, "value"));
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
443 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
444
26232
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26229
diff changeset
445 codec_str = purple_media_codec_to_string(codec);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
446 purple_debug_info("jingle-rtp", "received codec: %s\n", codec_str);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
447 g_free(codec_str);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
448
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
449 codecs = g_list_append(codecs, codec);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
450 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
451 return codecs;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
452 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
453
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
454 static void
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
455 jingle_rtp_add_payloads(PurpleXmlNode *description, GList *codecs)
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
456 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
457 for (; codecs ; codecs = codecs->next) {
26232
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26229
diff changeset
458 PurpleMediaCodec *codec = (PurpleMediaCodec*)codecs->data;
26618
9e9e610ca1a1 Hide and gobjectify PurpleMediaCodec.
Michael Ruprecht <maiku@pidgin.im>
parents: 26617
diff changeset
459 GList *iter = purple_media_codec_get_optional_parameters(codec);
9e9e610ca1a1 Hide and gobjectify PurpleMediaCodec.
Michael Ruprecht <maiku@pidgin.im>
parents: 26617
diff changeset
460 gchar *id, *name, *clockrate, *channels;
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
461 gchar *codec_str;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
462 PurpleXmlNode *payload = purple_xmlnode_new_child(description, "payload-type");
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30764
diff changeset
463
26618
9e9e610ca1a1 Hide and gobjectify PurpleMediaCodec.
Michael Ruprecht <maiku@pidgin.im>
parents: 26617
diff changeset
464 id = g_strdup_printf("%d",
9e9e610ca1a1 Hide and gobjectify PurpleMediaCodec.
Michael Ruprecht <maiku@pidgin.im>
parents: 26617
diff changeset
465 purple_media_codec_get_id(codec));
9e9e610ca1a1 Hide and gobjectify PurpleMediaCodec.
Michael Ruprecht <maiku@pidgin.im>
parents: 26617
diff changeset
466 name = purple_media_codec_get_encoding_name(codec);
9e9e610ca1a1 Hide and gobjectify PurpleMediaCodec.
Michael Ruprecht <maiku@pidgin.im>
parents: 26617
diff changeset
467 clockrate = g_strdup_printf("%d",
9e9e610ca1a1 Hide and gobjectify PurpleMediaCodec.
Michael Ruprecht <maiku@pidgin.im>
parents: 26617
diff changeset
468 purple_media_codec_get_clock_rate(codec));
9e9e610ca1a1 Hide and gobjectify PurpleMediaCodec.
Michael Ruprecht <maiku@pidgin.im>
parents: 26617
diff changeset
469 channels = g_strdup_printf("%d",
9e9e610ca1a1 Hide and gobjectify PurpleMediaCodec.
Michael Ruprecht <maiku@pidgin.im>
parents: 26617
diff changeset
470 purple_media_codec_get_channels(codec));
9e9e610ca1a1 Hide and gobjectify PurpleMediaCodec.
Michael Ruprecht <maiku@pidgin.im>
parents: 26617
diff changeset
471
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
472 purple_xmlnode_set_attrib(payload, "name", name);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
473 purple_xmlnode_set_attrib(payload, "id", id);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
474 purple_xmlnode_set_attrib(payload, "clockrate", clockrate);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
475 purple_xmlnode_set_attrib(payload, "channels", channels);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
476
26618
9e9e610ca1a1 Hide and gobjectify PurpleMediaCodec.
Michael Ruprecht <maiku@pidgin.im>
parents: 26617
diff changeset
477 g_free(channels);
9e9e610ca1a1 Hide and gobjectify PurpleMediaCodec.
Michael Ruprecht <maiku@pidgin.im>
parents: 26617
diff changeset
478 g_free(clockrate);
9e9e610ca1a1 Hide and gobjectify PurpleMediaCodec.
Michael Ruprecht <maiku@pidgin.im>
parents: 26617
diff changeset
479 g_free(name);
9e9e610ca1a1 Hide and gobjectify PurpleMediaCodec.
Michael Ruprecht <maiku@pidgin.im>
parents: 26617
diff changeset
480 g_free(id);
9e9e610ca1a1 Hide and gobjectify PurpleMediaCodec.
Michael Ruprecht <maiku@pidgin.im>
parents: 26617
diff changeset
481
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
482 for (; iter; iter = g_list_next(iter)) {
26617
514bdfc137d5 Use PurpleMediaKeyPair. Remove PurpleMediaCodecParameter.
Michael Ruprecht <maiku@pidgin.im>
parents: 26514
diff changeset
483 PurpleKeyValuePair *mparam = iter->data;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
484 PurpleXmlNode *param = purple_xmlnode_new_child(payload, "parameter");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
485 purple_xmlnode_set_attrib(param, "name", mparam->key);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
486 purple_xmlnode_set_attrib(param, "value", mparam->value);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
487 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
488
26232
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26229
diff changeset
489 codec_str = purple_media_codec_to_string(codec);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
490 purple_debug_info("jingle", "adding codec: %s\n", codec_str);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
491 g_free(codec_str);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
492 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
493 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
494
39494
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
495 /******************************************************************************
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
496 * JingleContent Implementation
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
497 *****************************************************************************/
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
498 static PurpleXmlNode *
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
499 jingle_rtp_to_xml_internal(JingleContent *rtp, PurpleXmlNode *content, JingleActionType action)
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
500 {
39494
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
501 PurpleXmlNode *node = JINGLE_CONTENT_CLASS(jingle_rtp_parent_class)->to_xml(rtp, content, action);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
502 PurpleXmlNode *description = purple_xmlnode_get_child(node, "description");
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
503 if (description != NULL) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
504 JingleSession *session = jingle_content_get_session(rtp);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
505 PurpleMedia *media = jingle_rtp_get_media(session);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
506 gchar *media_type = jingle_rtp_get_media_type(rtp);
26405
4cf4d5dcc183 Add ssrc property to JingleRtp.
Michael Ruprecht <maiku@pidgin.im>
parents: 26404
diff changeset
507 gchar *ssrc = jingle_rtp_get_ssrc(rtp);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
508 gchar *name = jingle_content_get_name(rtp);
26160
46bc5e18d59c Combine get_*_codecs functions to mirror Farsight 2.
Michael Ruprecht <maiku@pidgin.im>
parents: 26156
diff changeset
509 GList *codecs = purple_media_get_codecs(media, name);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
510
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
511 purple_xmlnode_set_attrib(description, "media", media_type);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
512
26405
4cf4d5dcc183 Add ssrc property to JingleRtp.
Michael Ruprecht <maiku@pidgin.im>
parents: 26404
diff changeset
513 if (ssrc != NULL)
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
514 purple_xmlnode_set_attrib(description, "ssrc", ssrc);
26405
4cf4d5dcc183 Add ssrc property to JingleRtp.
Michael Ruprecht <maiku@pidgin.im>
parents: 26404
diff changeset
515
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
516 g_free(media_type);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
517 g_free(name);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
518 g_object_unref(session);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
519
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
520 jingle_rtp_add_payloads(description, codecs);
26428
77d845d3e0c3 Plug memory leak.
Michael Ruprecht <maiku@pidgin.im>
parents: 26422
diff changeset
521 purple_media_codec_list_free(codecs);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
522 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
523 return node;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
524 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
525
39494
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
526 static JingleContent *
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
527 jingle_rtp_parse_internal(PurpleXmlNode *rtp)
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
528 {
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
529 JingleContent *content = JINGLE_CONTENT_CLASS(jingle_rtp_parent_class)->parse(rtp);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
530 PurpleXmlNode *description = purple_xmlnode_get_child(rtp, "description");
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
531 const gchar *media_type = purple_xmlnode_get_attrib(description, "media");
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
532 const gchar *ssrc = purple_xmlnode_get_attrib(description, "ssrc");
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
533 purple_debug_info("jingle-rtp", "rtp parse\n");
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
534 g_object_set(content, "media-type", media_type, NULL);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
535 if (ssrc != NULL)
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
536 g_object_set(content, "ssrc", ssrc, NULL);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
537 return content;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
538 }
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
539
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
540 static void
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
541 jingle_rtp_handle_action_internal(JingleContent *content, PurpleXmlNode *xmlcontent, JingleActionType action)
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
542 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
543 switch (action) {
26407
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26405
diff changeset
544 case JINGLE_SESSION_ACCEPT:
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
545 case JINGLE_SESSION_INITIATE: {
32065
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
546 JingleSession *session;
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
547 JingleTransport *transport;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
548 PurpleXmlNode *description;
32065
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
549 GList *candidates;
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
550 GList *codecs;
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
551 gchar *name;
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
552 gchar *remote_jid;
26407
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26405
diff changeset
553 PurpleMedia *media;
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
554
32065
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
555 session = jingle_content_get_session(content);
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
556
26407
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26405
diff changeset
557 if (action == JINGLE_SESSION_INITIATE &&
32065
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
558 !jingle_rtp_init_media(content)) {
26156
1ba69535986d Fix crash when remote client reconnects and tries to restart the media session.
Michael Ruprecht <maiku@pidgin.im>
parents: 26154
diff changeset
559 /* XXX: send error */
26404
3947a428b87d Add functions for more easily creating session-terminate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26330
diff changeset
560 jabber_iq_send(jingle_session_terminate_packet(
3947a428b87d Add functions for more easily creating session-terminate packets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26330
diff changeset
561 session, "general-error"));
26156
1ba69535986d Fix crash when remote client reconnects and tries to restart the media session.
Michael Ruprecht <maiku@pidgin.im>
parents: 26154
diff changeset
562 g_object_unref(session);
1ba69535986d Fix crash when remote client reconnects and tries to restart the media session.
Michael Ruprecht <maiku@pidgin.im>
parents: 26154
diff changeset
563 break;
1ba69535986d Fix crash when remote client reconnects and tries to restart the media session.
Michael Ruprecht <maiku@pidgin.im>
parents: 26154
diff changeset
564 }
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
565
32065
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
566 transport = jingle_transport_parse(
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
567 purple_xmlnode_get_child(xmlcontent, "transport"));
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
568 description = purple_xmlnode_get_child(xmlcontent, "description");
33631
21775fb6957a Abstract candidate translation for JingleTransports.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32065
diff changeset
569 candidates = jingle_transport_get_remote_candidates(transport);
32065
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
570 codecs = jingle_rtp_parse_codecs(description);
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
571 name = jingle_content_get_name(content);
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
572 remote_jid = jingle_session_get_remote_jid(session);
15eb0e242206 Fix crashes and memory leaks when receiving malformed voice
Mark Doliner <markdoliner@pidgin.im>
parents: 32064
diff changeset
573
26407
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26405
diff changeset
574 media = jingle_rtp_get_media(session);
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26405
diff changeset
575 purple_media_set_remote_codecs(media,
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26405
diff changeset
576 name, remote_jid, codecs);
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26405
diff changeset
577 purple_media_add_remote_candidates(media,
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26405
diff changeset
578 name, remote_jid, candidates);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
579
26501
c186275f46aa Remove purple_media_accept.
Michael Ruprecht <maiku@pidgin.im>
parents: 26499
diff changeset
580 if (action == JINGLE_SESSION_ACCEPT)
c186275f46aa Remove purple_media_accept.
Michael Ruprecht <maiku@pidgin.im>
parents: 26499
diff changeset
581 purple_media_stream_info(media,
c186275f46aa Remove purple_media_accept.
Michael Ruprecht <maiku@pidgin.im>
parents: 26499
diff changeset
582 PURPLE_MEDIA_INFO_ACCEPT,
c186275f46aa Remove purple_media_accept.
Michael Ruprecht <maiku@pidgin.im>
parents: 26499
diff changeset
583 name, remote_jid, FALSE);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
584
26407
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26405
diff changeset
585 g_free(remote_jid);
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26405
diff changeset
586 g_free(name);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
587 g_object_unref(session);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
588 break;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
589 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
590 case JINGLE_SESSION_TERMINATE: {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
591 JingleSession *session = jingle_content_get_session(content);
26192
ca6d9f19c4b6 Remove PurpleMedias from JabberStream's list when a media session ends.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
592 PurpleMedia *media = jingle_rtp_get_media(session);
ca6d9f19c4b6 Remove PurpleMedias from JabberStream's list when a media session ends.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
593
ca6d9f19c4b6 Remove PurpleMedias from JabberStream's list when a media session ends.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
594 if (media != NULL) {
26264
c062fc1f212f Added purple_media_end and removed the purple_media_got_hangup.
Michael Ruprecht <maiku@pidgin.im>
parents: 26248
diff changeset
595 purple_media_end(media, NULL, NULL);
26192
ca6d9f19c4b6 Remove PurpleMedias from JabberStream's list when a media session ends.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
596 }
ca6d9f19c4b6 Remove PurpleMedias from JabberStream's list when a media session ends.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
597
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
598 g_object_unref(session);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
599 break;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
600 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
601 case JINGLE_TRANSPORT_INFO: {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
602 JingleSession *session = jingle_content_get_session(content);
26154
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
603 JingleTransport *transport = jingle_transport_parse(
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
604 purple_xmlnode_get_child(xmlcontent, "transport"));
33631
21775fb6957a Abstract candidate translation for JingleTransports.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32065
diff changeset
605 GList *candidates = jingle_transport_get_remote_candidates(transport);
26407
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26405
diff changeset
606 gchar *name = jingle_content_get_name(content);
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26405
diff changeset
607 gchar *remote_jid =
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26405
diff changeset
608 jingle_session_get_remote_jid(session);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
609
26407
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26405
diff changeset
610 purple_media_add_remote_candidates(
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26405
diff changeset
611 jingle_rtp_get_media(session),
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26405
diff changeset
612 name, remote_jid, candidates);
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26405
diff changeset
613
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26405
diff changeset
614 g_free(remote_jid);
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26405
diff changeset
615 g_free(name);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
616 g_object_unref(session);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
617 break;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
618 }
28869
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
619 case JINGLE_DESCRIPTION_INFO: {
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
620 JingleSession *session =
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
621 jingle_content_get_session(content);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33796
diff changeset
622 PurpleXmlNode *description = purple_xmlnode_get_child(
28869
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
623 xmlcontent, "description");
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
624 GList *codecs, *iter, *iter2, *remote_codecs =
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
625 jingle_rtp_parse_codecs(description);
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
626 gchar *name = jingle_content_get_name(content);
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
627 gchar *remote_jid =
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
628 jingle_session_get_remote_jid(session);
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
629 PurpleMedia *media;
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
630
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
631 media = jingle_rtp_get_media(session);
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
632
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
633 /*
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
634 * This may have problems if description-info is
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
635 * received without the optional parameters for a
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
636 * codec with configuration info (such as THEORA
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
637 * or H264). The local configuration info may be
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
638 * set for the remote codec.
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
639 *
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
640 * As of 2.6.3 there's no API to support getting
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
641 * the remote codecs specifically, just the
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
642 * intersection. Another option may be to cache
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
643 * the remote codecs received in initiate/accept.
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
644 */
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
645 codecs = purple_media_get_codecs(media, name);
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
646
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
647 for (iter = codecs; iter; iter = g_list_next(iter)) {
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
648 guint id;
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
649
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
650 id = purple_media_codec_get_id(iter->data);
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
651 iter2 = remote_codecs;
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
652
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
653 for (; iter2; iter2 = g_list_next(iter2)) {
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
654 if (purple_media_codec_get_id(
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
655 iter2->data) != id)
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
656 continue;
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
657
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
658 g_object_unref(iter->data);
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
659 iter->data = iter2->data;
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
660 remote_codecs = g_list_delete_link(
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
661 remote_codecs, iter2);
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
662 break;
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
663 }
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
664 }
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
665
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
666 codecs = g_list_concat(codecs, remote_codecs);
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
667
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
668 purple_media_set_remote_codecs(media,
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
669 name, remote_jid, codecs);
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
670
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
671 purple_media_codec_list_free (codecs);
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
672 g_free(remote_jid);
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
673 g_free(name);
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
674 g_object_unref(session);
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
675 break;
c18c0ba16b64 Handle Jingle's description-info method.
Michael Ruprecht <maiku@pidgin.im>
parents: 28333
diff changeset
676 }
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
677 default:
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
678 break;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
679 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
680 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
681
39494
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
682
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
683 /******************************************************************************
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
684 * GObject Stuff
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
685 *****************************************************************************/
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
686 static void
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
687 jingle_rtp_init (JingleRtp *rtp)
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
688 {
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
689 }
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
690
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
691 static void
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
692 jingle_rtp_finalize (GObject *rtp)
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
693 {
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
694 JingleRtpPrivate *priv = jingle_rtp_get_instance_private(JINGLE_RTP(rtp));
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
695 purple_debug_info("jingle-rtp","jingle_rtp_finalize\n");
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
696
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
697 g_free(priv->media_type);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
698 g_free(priv->ssrc);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
699
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
700 G_OBJECT_CLASS(jingle_rtp_parent_class)->finalize(rtp);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
701 }
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
702
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
703 static void
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
704 jingle_rtp_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
705 {
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
706 JingleRtp *rtp = JINGLE_RTP(object);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
707 JingleRtpPrivate *priv = jingle_rtp_get_instance_private(rtp);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
708
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
709 switch (prop_id) {
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
710 case PROP_MEDIA_TYPE:
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
711 g_free(priv->media_type);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
712 priv->media_type = g_value_dup_string(value);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
713 break;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
714 case PROP_SSRC:
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
715 g_free(priv->ssrc);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
716 priv->ssrc = g_value_dup_string(value);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
717 break;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
718 default:
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
719 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
720 break;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
721 }
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
722 }
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
723
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
724 static void
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
725 jingle_rtp_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
726 {
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
727 JingleRtp *rtp = JINGLE_RTP(object);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
728 JingleRtpPrivate *priv = jingle_rtp_get_instance_private(rtp);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
729
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
730 switch (prop_id) {
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
731 case PROP_MEDIA_TYPE:
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
732 g_value_set_string(value, priv->media_type);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
733 break;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
734 case PROP_SSRC:
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
735 g_value_set_string(value, priv->ssrc);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
736 break;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
737 default:
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
738 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
739 break;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
740 }
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
741 }
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
742
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
743
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
744 static void
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
745 jingle_rtp_class_finalize(JingleRtpClass *klass) {
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
746 }
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
747
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
748 static void
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
749 jingle_rtp_class_init (JingleRtpClass *klass)
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
750 {
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
751 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
752 JingleContentClass *content_class = JINGLE_CONTENT_CLASS(klass);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
753
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
754 obj_class->finalize = jingle_rtp_finalize;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
755 obj_class->set_property = jingle_rtp_set_property;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
756 obj_class->get_property = jingle_rtp_get_property;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
757
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
758 content_class->to_xml = jingle_rtp_to_xml_internal;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
759 content_class->parse = jingle_rtp_parse_internal;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
760 content_class->description_type = JINGLE_APP_RTP;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
761 content_class->handle_action = jingle_rtp_handle_action_internal;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
762
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
763 properties[PROP_MEDIA_TYPE] = g_param_spec_string("media-type",
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
764 "Media Type",
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
765 "The media type (\"audio\" or \"video\") for this rtp session.",
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
766 NULL,
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
767 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
768
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
769 properties[PROP_SSRC] = g_param_spec_string("ssrc",
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
770 "ssrc",
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
771 "The ssrc for this rtp session.",
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
772 NULL,
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
773 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
774
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
775 g_object_class_install_properties(obj_class, PROP_LAST, properties);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
776 }
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
777
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
778 /******************************************************************************
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
779 * Public API
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
780 *****************************************************************************/
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
781 void
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
782 jingle_rtp_register(PurplePlugin *plugin) {
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
783 jingle_rtp_register_type(G_TYPE_MODULE(plugin));
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
784 }
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
785
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
786 gchar *
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
787 jingle_rtp_get_media_type(JingleContent *content)
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
788 {
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
789 gchar *media_type;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
790 g_object_get(content, "media-type", &media_type, NULL);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
791 return media_type;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
792 }
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
793
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
794 gchar *
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
795 jingle_rtp_get_ssrc(JingleContent *content)
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
796 {
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
797 gchar *ssrc;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
798 g_object_get(content, "ssrc", &ssrc, NULL);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
799 return ssrc;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
800 }
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
801
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
802 static PurpleMedia *
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
803 jingle_rtp_get_media(JingleSession *session)
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
804 {
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
805 JabberStream *js = jingle_session_get_js(session);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
806 PurpleMedia *media = NULL;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
807 GList *iter = purple_media_manager_get_media_by_account(
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
808 purple_media_manager_get(),
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
809 purple_connection_get_account(js->gc));
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
810
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
811 for (; iter; iter = g_list_delete_link(iter, iter)) {
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
812 JingleSession *media_session =
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
813 purple_media_get_protocol_data(iter->data);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
814 if (media_session == session) {
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
815 media = iter->data;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
816 break;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
817 }
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
818 }
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
819 if (iter != NULL)
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
820 g_list_free(iter);
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
821
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
822 return media;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
823 }
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
824
26495
52846ebe1c7d Don't assume a PurpleMedia instance will be created immediately.
Michael Ruprecht <maiku@pidgin.im>
parents: 26449
diff changeset
825 gboolean
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30764
diff changeset
826 jingle_rtp_initiate_media(JabberStream *js, const gchar *who,
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
827 PurpleMediaSessionType type)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
828 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
829 /* create content negotiation */
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
830 JingleSession *session;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
831 JingleContent *content;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
832 JingleTransport *transport;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
833 JabberBuddy *jb;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
834 JabberBuddyResource *jbr;
38693
12476654da77 jabber: Avoid a use-after-free in an error path
Debarshi Ray <rishi@gnu.org>
parents: 38258
diff changeset
835 gboolean ret = FALSE;
26170
829055c78478 Choose the transport type according to the responder's caps.
Michael Ruprecht <maiku@pidgin.im>
parents: 26166
diff changeset
836 const gchar *transport_type;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30764
diff changeset
837
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26620
diff changeset
838 gchar *resource = NULL, *me = NULL, *sid = NULL;
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
839
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
840 /* construct JID to send to */
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
841 jb = jabber_buddy_find(js, who, FALSE);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
842 if (!jb) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
843 purple_debug_error("jingle-rtp", "Could not find Jabber buddy\n");
38693
12476654da77 jabber: Avoid a use-after-free in an error path
Debarshi Ray <rishi@gnu.org>
parents: 38258
diff changeset
844 goto out;
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
845 }
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26620
diff changeset
846
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26620
diff changeset
847 resource = jabber_get_resource(who);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26620
diff changeset
848 jbr = jabber_buddy_find_resource(jb, resource);
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26620
diff changeset
849
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
850 if (!jbr) {
33789
48af26131376 Prevent NULL pointer deref when initating a rtp session with an unrecognized resource
Daniel Atallah <datallah@pidgin.im>
parents: 32065
diff changeset
851 purple_debug_error("jingle-rtp", "Could not find buddy's resource - %s\n", resource);
38693
12476654da77 jabber: Avoid a use-after-free in an error path
Debarshi Ray <rishi@gnu.org>
parents: 38258
diff changeset
852 goto out;
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
853 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
854
26170
829055c78478 Choose the transport type according to the responder's caps.
Michael Ruprecht <maiku@pidgin.im>
parents: 26166
diff changeset
855 if (jabber_resource_has_capability(jbr, JINGLE_TRANSPORT_ICEUDP)) {
829055c78478 Choose the transport type according to the responder's caps.
Michael Ruprecht <maiku@pidgin.im>
parents: 26166
diff changeset
856 transport_type = JINGLE_TRANSPORT_ICEUDP;
829055c78478 Choose the transport type according to the responder's caps.
Michael Ruprecht <maiku@pidgin.im>
parents: 26166
diff changeset
857 } else if (jabber_resource_has_capability(jbr, JINGLE_TRANSPORT_RAWUDP)) {
829055c78478 Choose the transport type according to the responder's caps.
Michael Ruprecht <maiku@pidgin.im>
parents: 26166
diff changeset
858 transport_type = JINGLE_TRANSPORT_RAWUDP;
33650
19eaf308a449 Initial support for Google's P2P transport.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33631
diff changeset
859 } else if (jabber_resource_has_capability(jbr, NS_GOOGLE_TRANSPORT_P2P)) {
19eaf308a449 Initial support for Google's P2P transport.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33631
diff changeset
860 transport_type = NS_GOOGLE_TRANSPORT_P2P;
26170
829055c78478 Choose the transport type according to the responder's caps.
Michael Ruprecht <maiku@pidgin.im>
parents: 26166
diff changeset
861 } else {
829055c78478 Choose the transport type according to the responder's caps.
Michael Ruprecht <maiku@pidgin.im>
parents: 26166
diff changeset
862 purple_debug_error("jingle-rtp", "Resource doesn't support "
829055c78478 Choose the transport type according to the responder's caps.
Michael Ruprecht <maiku@pidgin.im>
parents: 26166
diff changeset
863 "the same transport types\n");
38693
12476654da77 jabber: Avoid a use-after-free in an error path
Debarshi Ray <rishi@gnu.org>
parents: 38258
diff changeset
864 goto out;
26170
829055c78478 Choose the transport type according to the responder's caps.
Michael Ruprecht <maiku@pidgin.im>
parents: 26166
diff changeset
865 }
829055c78478 Choose the transport type according to the responder's caps.
Michael Ruprecht <maiku@pidgin.im>
parents: 26166
diff changeset
866
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
867 /* set ourselves as initiator */
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
868 me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, js->user->resource);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
869
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
870 sid = jabber_get_next_id(js);
26643
401d7a92ecb1 Add a resource selector when initiating media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26620
diff changeset
871 session = jingle_session_create(js, sid, me, who, TRUE);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
872
26149
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
873
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
874 if (type & PURPLE_MEDIA_AUDIO) {
39494
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
875 JingleRtpPrivate *priv = NULL;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
876
26170
829055c78478 Choose the transport type according to the responder's caps.
Michael Ruprecht <maiku@pidgin.im>
parents: 26166
diff changeset
877 transport = jingle_transport_create(transport_type);
26149
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
878 content = jingle_content_create(JINGLE_APP_RTP, "initiator",
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
879 "session", "audio-session", "both", transport);
39494
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
880
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
881 priv = jingle_rtp_get_instance_private(JINGLE_RTP(content));
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
882
26149
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
883 jingle_session_add_content(session, content);
39494
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
884 priv->media_type = g_strdup("audio");
26149
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
885 jingle_rtp_init_media(content);
35076
cadfc3f9a7cc jabber: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35061
diff changeset
886 g_object_notify_by_pspec(G_OBJECT(content), properties[PROP_MEDIA_TYPE]);
26149
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
887 }
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
888 if (type & PURPLE_MEDIA_VIDEO) {
39494
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
889 JingleRtpPrivate *priv = NULL;
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
890
26170
829055c78478 Choose the transport type according to the responder's caps.
Michael Ruprecht <maiku@pidgin.im>
parents: 26166
diff changeset
891 transport = jingle_transport_create(transport_type);
26149
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
892 content = jingle_content_create(JINGLE_APP_RTP, "initiator",
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
893 "session", "video-session", "both", transport);
39494
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
894
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
895 priv = jingle_rtp_get_instance_private(JINGLE_RTP(content));
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
896
26149
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
897 jingle_session_add_content(session, content);
39494
f68a311bc10d Update most things to use G_DEFINE_DYNAMIC_TYPE and a host of other updates
Gary Kramlich <grim@reaperworld.com>
parents: 38854
diff changeset
898 priv->media_type = g_strdup("video");
26149
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
899 jingle_rtp_init_media(content);
35076
cadfc3f9a7cc jabber: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35061
diff changeset
900 g_object_notify_by_pspec(G_OBJECT(content), properties[PROP_MEDIA_TYPE]);
26149
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
901 }
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
902
26495
52846ebe1c7d Don't assume a PurpleMedia instance will be created immediately.
Michael Ruprecht <maiku@pidgin.im>
parents: 26449
diff changeset
903 if (jingle_rtp_get_media(session) == NULL) {
38693
12476654da77 jabber: Avoid a use-after-free in an error path
Debarshi Ray <rishi@gnu.org>
parents: 38258
diff changeset
904 goto out;
26495
52846ebe1c7d Don't assume a PurpleMedia instance will be created immediately.
Michael Ruprecht <maiku@pidgin.im>
parents: 26449
diff changeset
905 }
52846ebe1c7d Don't assume a PurpleMedia instance will be created immediately.
Michael Ruprecht <maiku@pidgin.im>
parents: 26449
diff changeset
906
38693
12476654da77 jabber: Avoid a use-after-free in an error path
Debarshi Ray <rishi@gnu.org>
parents: 38258
diff changeset
907 ret = TRUE;
12476654da77 jabber: Avoid a use-after-free in an error path
Debarshi Ray <rishi@gnu.org>
parents: 38258
diff changeset
908
12476654da77 jabber: Avoid a use-after-free in an error path
Debarshi Ray <rishi@gnu.org>
parents: 38258
diff changeset
909 out:
12476654da77 jabber: Avoid a use-after-free in an error path
Debarshi Ray <rishi@gnu.org>
parents: 38258
diff changeset
910 g_free(me);
12476654da77 jabber: Avoid a use-after-free in an error path
Debarshi Ray <rishi@gnu.org>
parents: 38258
diff changeset
911 g_free(resource);
12476654da77 jabber: Avoid a use-after-free in an error path
Debarshi Ray <rishi@gnu.org>
parents: 38258
diff changeset
912 g_free(sid);
12476654da77 jabber: Avoid a use-after-free in an error path
Debarshi Ray <rishi@gnu.org>
parents: 38258
diff changeset
913 return ret;
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
914 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
915
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
916 void
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
917 jingle_rtp_terminate_session(JabberStream *js, const gchar *who)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
918 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
919 JingleSession *session;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
920 /* XXX: This may cause file transfers and xml sessions to stop as well */
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
921 session = jingle_session_find_by_jid(js, who);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
922
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
923 if (session) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
924 PurpleMedia *media = jingle_rtp_get_media(session);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
925 if (media) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
926 purple_debug_info("jingle-rtp", "hanging up media\n");
26499
759bf410db86 Remove purple_media_hangup.
Michael Ruprecht <maiku@pidgin.im>
parents: 26496
diff changeset
927 purple_media_stream_info(media,
759bf410db86 Remove purple_media_hangup.
Michael Ruprecht <maiku@pidgin.im>
parents: 26496
diff changeset
928 PURPLE_MEDIA_INFO_HANGUP,
759bf410db86 Remove purple_media_hangup.
Michael Ruprecht <maiku@pidgin.im>
parents: 26496
diff changeset
929 NULL, NULL, TRUE);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
930 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
931 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
932 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
933
26215
9ecaa256d77b Fix compiling with --disable-vv.
Michael Ruprecht <maiku@pidgin.im>
parents: 26198
diff changeset
934 #endif /* USE_VV */

mercurial