libpurple/protocols/jabber/jingle/rtp.c

Thu, 13 Nov 2008 04:00:29 +0000

author
Michael Ruprecht <maiku@pidgin.im>
date
Thu, 13 Nov 2008 04:00:29 +0000
branch
vv
changeset 26161
7fb369b925b5
parent 26160
46bc5e18d59c
child 26166
ad7d09fef256
permissions
-rw-r--r--

Fix a few GLib warnings when trying to start a second media session.

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 *
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
6 * 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
7 * 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
8 * 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
9 * (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
10 *
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
11 * 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
12 * 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
13 * 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
14 * 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
15 *
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
16 * 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
17 * 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
18 * 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
19 */
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
20
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
21 #include "config.h"
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
22
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
23 #include "jabber.h"
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
24 #include "jingle.h"
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
25 #include "media.h"
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
26 #include "mediamanager.h"
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
27 #include "rawudp.h"
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
28 #include "rtp.h"
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
29 #include "session.h"
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
30 #include "debug.h"
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
31
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
32 #include <string.h>
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
33
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
34 struct _JingleRtpPrivate
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
35 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
36 gchar *media_type;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
37 gboolean candidates_ready;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
38 gboolean codecs_ready;
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
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
41 #define JINGLE_RTP_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), JINGLE_TYPE_RTP, JingleRtpPrivate))
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
42
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
43 static void jingle_rtp_class_init (JingleRtpClass *klass);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
44 static void jingle_rtp_init (JingleRtp *rtp);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
45 static void jingle_rtp_finalize (GObject *object);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
46 static void jingle_rtp_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
47 static void jingle_rtp_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
48 static JingleContent *jingle_rtp_parse_internal(xmlnode *rtp);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
49 static xmlnode *jingle_rtp_to_xml_internal(JingleContent *rtp, xmlnode *content, JingleActionType action);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
50 static void jingle_rtp_handle_action_internal(JingleContent *content, xmlnode *jingle, JingleActionType action);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
51
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
52 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
53
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
54 static JingleContentClass *parent_class = NULL;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
55 #if 0
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
56 enum {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
57 LAST_SIGNAL
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 static guint jingle_rtp_signals[LAST_SIGNAL] = {0};
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
60 #endif
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
61
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
62 enum {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
63 PROP_0,
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
64 PROP_MEDIA_TYPE,
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
65 };
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
66
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
67 GType
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
68 jingle_rtp_get_type()
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
69 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
70 static GType type = 0;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
71
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
72 if (type == 0) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
73 static const GTypeInfo info = {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
74 sizeof(JingleRtpClass),
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
75 NULL,
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
76 NULL,
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
77 (GClassInitFunc) jingle_rtp_class_init,
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
78 NULL,
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
79 NULL,
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
80 sizeof(JingleRtp),
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
81 0,
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
82 (GInstanceInitFunc) jingle_rtp_init,
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
83 NULL
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
84 };
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
85 type = g_type_register_static(JINGLE_TYPE_CONTENT, "JingleRtp", &info, 0);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
86 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
87 return type;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
88 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
89
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
90 static void
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
91 jingle_rtp_class_init (JingleRtpClass *klass)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
92 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
93 GObjectClass *gobject_class = (GObjectClass*)klass;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
94 parent_class = g_type_class_peek_parent(klass);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
95
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
96 gobject_class->finalize = jingle_rtp_finalize;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
97 gobject_class->set_property = jingle_rtp_set_property;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
98 gobject_class->get_property = jingle_rtp_get_property;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
99 klass->parent_class.to_xml = jingle_rtp_to_xml_internal;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
100 klass->parent_class.parse = jingle_rtp_parse_internal;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
101 klass->parent_class.description_type = JINGLE_APP_RTP;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
102 klass->parent_class.handle_action = jingle_rtp_handle_action_internal;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
103
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
104 g_object_class_install_property(gobject_class, PROP_MEDIA_TYPE,
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
105 g_param_spec_string("media-type",
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
106 "Media Type",
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
107 "The media type (\"audio\" or \"video\") for this rtp session.",
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
108 NULL,
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
109 G_PARAM_READWRITE));
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
110 g_type_class_add_private(klass, sizeof(JingleRtpPrivate));
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
111 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
112
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
113 static void
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
114 jingle_rtp_init (JingleRtp *rtp)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
115 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
116 rtp->priv = JINGLE_RTP_GET_PRIVATE(rtp);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
117 memset(rtp->priv, 0, sizeof(rtp->priv));
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
118 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
119
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
120 static void
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
121 jingle_rtp_finalize (GObject *rtp)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
122 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
123 JingleRtpPrivate *priv = JINGLE_RTP_GET_PRIVATE(rtp);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
124 purple_debug_info("jingle-rtp","jingle_rtp_finalize\n");
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
125
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
126 g_free(priv->media_type);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
127 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
128
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
129 static void
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
130 jingle_rtp_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
131 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
132 JingleRtp *rtp;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
133 g_return_if_fail(JINGLE_IS_RTP(object));
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
134
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
135 rtp = JINGLE_RTP(object);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
136
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
137 switch (prop_id) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
138 case PROP_MEDIA_TYPE:
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
139 g_free(rtp->priv->media_type);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
140 rtp->priv->media_type = g_value_dup_string(value);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
141 break;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
142 default:
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
143 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
144 break;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
145 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
146 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
148 static void
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
149 jingle_rtp_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
150 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
151 JingleRtp *rtp;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
152 g_return_if_fail(JINGLE_IS_RTP(object));
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
153
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
154 rtp = JINGLE_RTP(object);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
155
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
156 switch (prop_id) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
157 case PROP_MEDIA_TYPE:
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
158 g_value_set_string(value, rtp->priv->media_type);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
159 break;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
160 default:
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
161 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
162 break;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
163 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
164 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
165
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
166 static gboolean
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
167 jingle_rtp_ready_to_initiate(JingleSession *session, PurpleMedia *media)
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 if (jingle_session_is_initiator(session)) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
170 GList *iter = jingle_session_get_contents(session);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
171 for (; iter; iter = g_list_next(iter)) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
172 JingleContent *content = iter->data;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
173 gchar *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
174 if (!JINGLE_IS_RTP(content)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
175 || JINGLE_RTP_GET_PRIVATE(content)->codecs_ready == FALSE
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
176 || JINGLE_RTP_GET_PRIVATE(content)->candidates_ready == FALSE) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
177 g_free(name);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
178 return FALSE;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
179 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
180 g_free(name);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
181 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
182 return TRUE;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
183 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
184 return FALSE;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
185 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
186
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
187 gchar *
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
188 jingle_rtp_get_media_type(JingleContent *content)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
189 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
190 gchar *media_type;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
191 g_object_get(content, "media-type", &media_type, NULL);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
192 return media_type;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
193 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
194
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
195 static PurpleMedia *
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
196 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
197 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
198 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
199 gchar *sid = jingle_session_get_sid(session);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
200
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
201 PurpleMedia *media = (PurpleMedia *) (js->medias) ?
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
202 g_hash_table_lookup(js->medias, sid) : NULL;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
203 g_free(sid);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
204
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
205 return media;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
206 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
207
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
208 static JingleTransport *
26154
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
209 jingle_rtp_candidates_to_transport(JingleSession *session, GType 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
210 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
211 if (type == JINGLE_TYPE_RAWUDP) {
26154
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
212 gchar *id = jabber_get_next_id(jingle_session_get_js(session));
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
213 JingleTransport *transport = jingle_transport_create(JINGLE_TRANSPORT_RAWUDP);
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
214 JingleRawUdpCandidate *rawudp_candidate;
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
215 for (; candidates; candidates = g_list_next(candidates)) {
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
216 FsCandidate *candidate = candidates->data;
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
217 id = jabber_get_next_id(jingle_session_get_js(session));
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
218 rawudp_candidate = jingle_rawudp_candidate_new(id,
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
219 generation, candidate->component_id,
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
220 candidate->ip, candidate->port);
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
221 jingle_rawudp_add_local_candidate(JINGLE_RAWUDP(transport), rawudp_candidate);
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
222 }
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
223 g_free(id);
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
224 return transport;
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
225 #if 0
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
226 } else if (type == JINGLE_TYPE_ICEUDP) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
227 return NULL;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
228 #endif
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
229 } else {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
230 return NULL;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
231 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
232 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
233
26154
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
234 static GList *
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
235 jingle_rtp_transport_to_candidates(JingleTransport *transport)
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
236 {
26154
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
237 const gchar *type = jingle_transport_get_transport_type(transport);
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
238 GList *ret = NULL;
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
239 if (!strcmp(type, JINGLE_TRANSPORT_RAWUDP)) {
26154
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
240 GList *candidates = jingle_rawudp_get_remote_candidates(JINGLE_RAWUDP(transport));
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
241
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
242 for (; candidates; candidates = g_list_delete_link(candidates, candidates)) {
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
243 JingleRawUdpCandidate *candidate = candidates->data;
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
244 ret = g_list_append(ret, fs_candidate_new("", candidate->component,
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
245 FS_CANDIDATE_TYPE_SRFLX, FS_NETWORK_PROTOCOL_UDP,
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
246 candidate->ip, candidate->port));
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
247 }
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
248
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
249 return ret;
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
250 #if 0
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
251 } else if (type == JINGLE_TRANSPORT_ICEUDP) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
252 return NULL;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
253 #endif
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
254 } else {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
255 return NULL;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
256 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
257 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
258
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
259 static void
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
260 jingle_rtp_accept_cb(PurpleMedia *media, JingleSession *session)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
261 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
262 jabber_iq_send(jingle_session_to_packet(session, JINGLE_TRANSPORT_INFO));
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
263 jabber_iq_send(jingle_session_to_packet(session, JINGLE_SESSION_ACCEPT));
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
264 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
265
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
266 static void
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
267 jingle_rtp_reject_cb(PurpleMedia *media, JingleSession *session)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
268 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
269 jabber_iq_send(jingle_session_to_packet(session, JINGLE_SESSION_TERMINATE));
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
270 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
271 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
272
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
273 static void
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
274 jingle_rtp_hangup_cb(PurpleMedia *media, JingleSession *session)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
275 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
276 jabber_iq_send(jingle_session_to_packet(session, JINGLE_SESSION_TERMINATE));
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
277 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
278 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
279
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
280 static void
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
281 jingle_rtp_new_candidate_cb(PurpleMedia *media, gchar *sid, gchar *name, FsCandidate *candidate, JingleSession *session)
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 purple_debug_info("jingle-rtp", "jingle_rtp_new_candidate_cb\n");
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
284 }
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 static void
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
287 jingle_rtp_candidates_prepared_cb(PurpleMedia *media, gchar *sid, gchar *name, JingleSession *session)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
288 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
289 JingleContent *content = jingle_session_find_content(session, sid, "initiator");
26154
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
290 GList *candidates = purple_media_get_local_candidates(media, sid, name);
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
291 JingleTransport *transport =
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
292 JINGLE_TRANSPORT(jingle_rtp_candidates_to_transport(
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
293 session, JINGLE_TYPE_RAWUDP, 0, candidates));
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
294 g_list_free(candidates);
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
295
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
296 JINGLE_RTP_GET_PRIVATE(content)->candidates_ready = TRUE;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
297
26154
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
298 jingle_content_set_pending_transport(content, transport);
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
299 jingle_content_accept_transport(content);
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
300
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
301 if (jingle_rtp_ready_to_initiate(session, media))
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
302 jabber_iq_send(jingle_session_to_packet(session, JINGLE_SESSION_INITIATE));
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
303 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
304
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
305 static void
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
306 jingle_rtp_candidate_pair_established_cb(PurpleMedia *media, FsCandidate *local_candidate, FsCandidate *remote_candidate, JingleSession *session)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
307 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
308
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
309 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
310
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
311 static void
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
312 jingle_rtp_codecs_ready_cb(PurpleMedia *media, gchar *sid, JingleSession *session)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
313 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
314 JingleContent *content = jingle_session_find_content(session, sid, "initiator");
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
315
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
316 if (content == NULL)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
317 content = jingle_session_find_content(session, sid, "responder");
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
318
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
319 if (JINGLE_RTP_GET_PRIVATE(content)->codecs_ready == FALSE) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
320 JINGLE_RTP_GET_PRIVATE(content)->codecs_ready =
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
321 purple_media_codecs_ready(media, sid);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
322
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
323 if (jingle_rtp_ready_to_initiate(session, media))
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
324 jabber_iq_send(jingle_session_to_packet(session, JINGLE_SESSION_INITIATE));
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
325 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
326 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
327
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
328 static PurpleMedia *
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
329 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
330 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
331 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
332 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
333 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
334 gchar *sid = jingle_session_get_sid(session);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
335
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
336 PurpleMedia *media = purple_media_manager_create_media(purple_media_manager_get(),
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
337 js->gc, "fsrtpconference", remote_jid);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
338 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
339
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
340 if (!media) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
341 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
342 return NULL;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
343 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
344
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
345 /* insert it into the hash table */
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
346 if (!js->medias) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
347 purple_debug_info("jingle-rtp", "Creating hash table for media\n");
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
348 js->medias = g_hash_table_new(g_str_hash, g_str_equal);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
349 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
350 purple_debug_info("jingle-rtp", "inserting media with sid: %s into table\n", sid);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
351 g_hash_table_insert(js->medias, sid, media);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
352
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
353 /* connect callbacks */
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
354 g_signal_connect(G_OBJECT(media), "accepted",
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
355 G_CALLBACK(jingle_rtp_accept_cb), session);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
356 g_signal_connect(G_OBJECT(media), "reject",
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
357 G_CALLBACK(jingle_rtp_reject_cb), session);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
358 g_signal_connect(G_OBJECT(media), "hangup",
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
359 G_CALLBACK(jingle_rtp_hangup_cb), session);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
360 g_signal_connect(G_OBJECT(media), "new-candidate",
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
361 G_CALLBACK(jingle_rtp_new_candidate_cb), session);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
362 g_signal_connect(G_OBJECT(media), "candidates-prepared",
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
363 G_CALLBACK(jingle_rtp_candidates_prepared_cb), session);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
364 g_signal_connect(G_OBJECT(media), "candidate-pair",
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
365 G_CALLBACK(jingle_rtp_candidate_pair_established_cb), session);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
366 g_signal_connect(G_OBJECT(media), "codecs-ready",
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
367 G_CALLBACK(jingle_rtp_codecs_ready_cb), session);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
368
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
369 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
370 return media;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
371 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
372
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
373 static gboolean
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
374 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
375 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
376 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
377 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
378 gchar *media_type;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
379 gchar *remote_jid;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
380 gchar *senders;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
381 gchar *name;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
382 const gchar *transmitter;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
383 FsMediaType type;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
384 FsStreamDirection direction;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
385 JingleTransport *transport;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
386
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
387 /* maybe this create ought to just be in initiate and handle initiate */
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
388 if (media == NULL)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
389 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
390
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
391 if (media == NULL)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
392 return FALSE;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
393
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
394 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
395 media_type = jingle_rtp_get_media_type(content);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
396 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
397 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
398 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
399
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
400 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
401 transmitter = "rawudp";
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
402 else
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
403 transmitter = "notransmitter";
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
404
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
405 if (!strcmp(media_type, "audio"))
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
406 type = FS_MEDIA_TYPE_AUDIO;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
407 else
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
408 type = FS_MEDIA_TYPE_VIDEO;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
409
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
410 if (!strcmp(senders, "both"))
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
411 direction = FS_DIRECTION_BOTH;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
412 else if (!strcmp(senders, "initiator")
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
413 && jingle_session_is_initiator(session))
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
414 direction = FS_DIRECTION_SEND;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
415 else
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
416 direction = FS_DIRECTION_RECV;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
417
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
418 purple_media_add_stream(media, name, remote_jid,
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
419 purple_media_from_fs(type, direction),
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
420 transmitter, 0, NULL);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
421
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
422
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
423 g_free(name);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
424 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
425 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
426 g_free(senders);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
427 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
428
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
429 return TRUE;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
430 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
431
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
432 static GList *
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
433 jingle_rtp_parse_codecs(xmlnode *description)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
434 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
435 GList *codecs = NULL;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
436 xmlnode *codec_element = NULL;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
437 const char *encoding_name,*id, *clock_rate;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
438 FsCodec *codec;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
439 const gchar *media = xmlnode_get_attrib(description, "media");
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
440 FsMediaType type = !strcmp(media, "video") ? FS_MEDIA_TYPE_VIDEO :
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
441 !strcmp(media, "audio") ? FS_MEDIA_TYPE_AUDIO : 0;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
442
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
443 for (codec_element = xmlnode_get_child(description, "payload-type") ;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
444 codec_element ;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
445 codec_element = xmlnode_get_next_twin(codec_element)) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
446 xmlnode *param;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
447 gchar *codec_str;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
448 encoding_name = xmlnode_get_attrib(codec_element, "name");
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
449
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
450 id = xmlnode_get_attrib(codec_element, "id");
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
451 clock_rate = xmlnode_get_attrib(codec_element, "clockrate");
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 codec = fs_codec_new(atoi(id), encoding_name,
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
454 type,
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
455 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
456
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
457 for (param = xmlnode_get_child(codec_element, "parameter");
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
458 param; param = xmlnode_get_next_twin(param)) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
459 fs_codec_add_optional_parameter(codec,
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
460 xmlnode_get_attrib(param, "name"),
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
461 xmlnode_get_attrib(param, "value"));
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
462 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
463
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
464 codec_str = fs_codec_to_string(codec);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
465 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
466 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
467
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
468 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
469 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
470 return codecs;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
471 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
472
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
473 static JingleContent *
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
474 jingle_rtp_parse_internal(xmlnode *rtp)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
475 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
476 JingleContent *content = parent_class->parse(rtp);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
477 xmlnode *description = xmlnode_get_child(rtp, "description");
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
478 const gchar *media_type = xmlnode_get_attrib(description, "media");
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
479 purple_debug_info("jingle-rtp", "rtp parse\n");
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
480 g_object_set(content, "media-type", media_type, NULL);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
481 return content;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
482 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
483
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
484 static void
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
485 jingle_rtp_add_payloads(xmlnode *description, GList *codecs)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
486 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
487 for (; codecs ; codecs = codecs->next) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
488 FsCodec *codec = (FsCodec*)codecs->data;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
489 GList *iter = codec->optional_params;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
490 char id[8], clockrate[10], channels[10];
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
491 gchar *codec_str;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
492 xmlnode *payload = xmlnode_new_child(description, "payload-type");
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 g_snprintf(id, sizeof(id), "%d", codec->id);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
495 g_snprintf(clockrate, sizeof(clockrate), "%d", codec->clock_rate);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
496 g_snprintf(channels, sizeof(channels), "%d", codec->channels);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
497
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
498 xmlnode_set_attrib(payload, "name", codec->encoding_name);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
499 xmlnode_set_attrib(payload, "id", id);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
500 xmlnode_set_attrib(payload, "clockrate", clockrate);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
501 xmlnode_set_attrib(payload, "channels", channels);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
502
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
503 for (; iter; iter = g_list_next(iter)) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
504 FsCodecParameter *fsparam = iter->data;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
505 xmlnode *param = xmlnode_new_child(payload, "parameter");
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
506 xmlnode_set_attrib(param, "name", fsparam->name);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
507 xmlnode_set_attrib(param, "value", fsparam->value);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
508 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
509
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
510 codec_str = fs_codec_to_string(codec);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
511 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
512 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
513 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
514 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
515
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
516 static xmlnode *
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
517 jingle_rtp_to_xml_internal(JingleContent *rtp, xmlnode *content, JingleActionType action)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
518 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
519 xmlnode *node = parent_class->to_xml(rtp, content, action);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
520 xmlnode *description = xmlnode_get_child(node, "description");
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
521 if (description != NULL) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
522 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
523 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
524 gchar *media_type = jingle_rtp_get_media_type(rtp);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
525 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
526 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
527
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
528 xmlnode_set_attrib(description, "media", media_type);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
529
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
530 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
531 g_free(name);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
532 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
533
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
534 jingle_rtp_add_payloads(description, codecs);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
535 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
536 return node;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
537 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
538
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
539 static void
26149
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
540 jingle_rtp_handle_action_internal(JingleContent *content, xmlnode *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
541 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
542 switch (action) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
543 case JINGLE_SESSION_ACCEPT: {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
544 JingleSession *session = jingle_content_get_session(content);
26149
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
545 xmlnode *description = xmlnode_get_child(xmlcontent, "description");
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
546 GList *codecs = jingle_rtp_parse_codecs(description);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
547
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
548 purple_media_set_remote_codecs(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
549 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
550 jingle_session_get_remote_jid(session), codecs);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
551
26149
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
552 /* This needs to be for the entire session, not a single content */
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
553 /* very hacky */
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
554 if (xmlnode_get_next_twin(xmlcontent) == NULL)
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
555 purple_media_got_accept(jingle_rtp_get_media(session));
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
556
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
557 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
558 break;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
559 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
560 case JINGLE_SESSION_INITIATE: {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
561 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
562 JingleTransport *transport = jingle_transport_parse(
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
563 xmlnode_get_child(xmlcontent, "transport"));
26149
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
564 xmlnode *description = xmlnode_get_child(xmlcontent, "description");
26154
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
565 GList *candidates = jingle_rtp_transport_to_candidates(transport);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
566 GList *codecs = jingle_rtp_parse_codecs(description);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
567
26156
1ba69535986d Fix crash when remote client reconnects and tries to restart the media session.
Michael Ruprecht <maiku@pidgin.im>
parents: 26154
diff changeset
568 if (jingle_rtp_init_media(content) == FALSE) {
1ba69535986d Fix crash when remote client reconnects and tries to restart the media session.
Michael Ruprecht <maiku@pidgin.im>
parents: 26154
diff changeset
569 /* XXX: send error */
1ba69535986d Fix crash when remote client reconnects and tries to restart the media session.
Michael Ruprecht <maiku@pidgin.im>
parents: 26154
diff changeset
570 jabber_iq_send(jingle_session_to_packet(session,
1ba69535986d Fix crash when remote client reconnects and tries to restart the media session.
Michael Ruprecht <maiku@pidgin.im>
parents: 26154
diff changeset
571 JINGLE_SESSION_TERMINATE));
1ba69535986d Fix crash when remote client reconnects and tries to restart the media session.
Michael Ruprecht <maiku@pidgin.im>
parents: 26154
diff changeset
572 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
573 break;
1ba69535986d Fix crash when remote client reconnects and tries to restart the media session.
Michael Ruprecht <maiku@pidgin.im>
parents: 26154
diff changeset
574 }
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
575
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
576 purple_media_set_remote_codecs(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
577 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
578 jingle_session_get_remote_jid(session), codecs);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
579
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
580 purple_media_add_remote_candidates(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
581 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
582 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
583 candidates);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
584
26149
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
585 /* very hacky */
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
586 if (xmlnode_get_next_twin(xmlcontent) == NULL)
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
587 purple_media_ready(jingle_rtp_get_media(session));
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
588
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
589 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
590 break;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
591 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
592 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
593 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
594 purple_media_got_hangup(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
595 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
596 break;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
597 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
598 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
599 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
600 JingleTransport *transport = jingle_transport_parse(
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
601 xmlnode_get_child(xmlcontent, "transport"));
78fa18d44718 Update Jingle raw-udp to latest spec version.
Michael Ruprecht <maiku@pidgin.im>
parents: 26149
diff changeset
602 GList *candidates = jingle_rtp_transport_to_candidates(transport);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
603
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
604 purple_media_add_remote_candidates(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
605 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
606 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
607 candidates);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
608 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
609 break;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
610 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
611 default:
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
612 break;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
613 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
614 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
615
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
616 PurpleMedia *
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
617 jingle_rtp_initiate_media(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
618 PurpleMediaSessionType type)
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
619 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
620 /* create content negotiation */
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
621 JingleSession *session;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
622 JingleContent *content;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
623 JingleTransport *transport;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
624 JabberBuddy *jb;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
625 JabberBuddyResource *jbr;
26161
7fb369b925b5 Fix a few GLib warnings when trying to start a second media session.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
626 PurpleMedia *media;
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
627
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
628 gchar *jid = NULL, *me = NULL, *sid = NULL;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
629
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
630 /* 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
631 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
632 if (!jb) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
633 purple_debug_error("jingle-rtp", "Could not find Jabber buddy\n");
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
634 return NULL;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
635 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
636 jbr = jabber_buddy_find_resource(jb, NULL);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
637 if (!jbr) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
638 purple_debug_error("jingle-rtp", "Could not find buddy's resource\n");
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
639 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
640
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
641 if ((strchr(who, '/') == NULL) && jbr && (jbr->name != NULL)) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
642 jid = g_strdup_printf("%s/%s", who, jbr->name);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
643 } else {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
644 jid = g_strdup(who);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
645 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
646
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
647 /* 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
648 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
649
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
650 sid = jabber_get_next_id(js);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
651 session = jingle_session_create(js, sid, me, jid, TRUE);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
652 g_free(sid);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
653
26149
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
654
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
655 if (type & PURPLE_MEDIA_AUDIO) {
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
656 transport = jingle_transport_create(JINGLE_TRANSPORT_RAWUDP);
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
657 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
658 "session", "audio-session", "both", transport);
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
659 jingle_session_add_content(session, content);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
660 JINGLE_RTP(content)->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
661 jingle_rtp_init_media(content);
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
662 }
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
663 if (type & PURPLE_MEDIA_VIDEO) {
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
664 transport = jingle_transport_create(JINGLE_TRANSPORT_RAWUDP);
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
665 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
666 "session", "video-session", "both", transport);
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
667 jingle_session_add_content(session, content);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
668 JINGLE_RTP(content)->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
669 jingle_rtp_init_media(content);
92b095c37277 Fix support for audio and video (at the same time) sessions.
Michael Ruprecht <maiku@pidgin.im>
parents: 26147
diff changeset
670 }
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
671
26161
7fb369b925b5 Fix a few GLib warnings when trying to start a second media session.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
672 if ((media = jingle_rtp_get_media(session)) == NULL) {
7fb369b925b5 Fix a few GLib warnings when trying to start a second media session.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
673 return NULL;
7fb369b925b5 Fix a few GLib warnings when trying to start a second media session.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
674 }
7fb369b925b5 Fix a few GLib warnings when trying to start a second media session.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
675
7fb369b925b5 Fix a few GLib warnings when trying to start a second media session.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
676 purple_media_ready(media);
7fb369b925b5 Fix a few GLib warnings when trying to start a second media session.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
677 purple_media_wait(media);
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
678
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
679 g_free(jid);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
680 g_free(me);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
681
26161
7fb369b925b5 Fix a few GLib warnings when trying to start a second media session.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
682 return media;
26147
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
683 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
684
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
685 void
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
686 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
687 {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
688 JingleSession *session;
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
689 /* 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
690 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
691
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
692 if (session) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
693 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
694 if (media) {
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
695 purple_debug_info("jingle-rtp", "hanging up media\n");
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
696 purple_media_hangup(media);
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
697 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
698 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
699 }
791ee9c9a75e Add files I missed committing before and remove a few unnecessary functions.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
700

mercurial