Mercurial > pidgin
annotate libpurple/media/media.c @ 29210:2b2b930281a0
Add a way to set and get which media backend type to use.
author | maiku@pidgin.im |
---|---|
date | Wed, 28 Oct 2009 20:06:21 +0000 |
parents | f66dec812ba9 |
children | 7c87e62790a6 |
rev | line source |
---|---|
29140 | 1 /** |
2 * @file media.c Media API | |
3 * @ingroup core | |
4 */ | |
5 | |
6 /* purple | |
7 * | |
8 * Purple is the legal property of its developers, whose names are too numerous | |
9 * to list here. Please refer to the COPYRIGHT file distributed with this | |
10 * source distribution. | |
11 * | |
12 * This program is free software; you can redistribute it and/or modify | |
13 * it under the terms of the GNU General Public License as published by | |
14 * the Free Software Foundation; either version 2 of the License, or | |
15 * (at your option) any later version. | |
16 * | |
17 * This program is distributed in the hope that it will be useful, | |
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 * GNU General Public License for more details. | |
21 * | |
22 * You should have received a copy of the GNU General Public License | |
23 * along with this program; if not, write to the Free Software | |
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA | |
25 */ | |
26 | |
27 #include "internal.h" | |
28 | |
29 #include "account.h" | |
30 #include "media.h" | |
29155
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29151
diff
changeset
|
31 #include "media/backend-fs2.h" |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29151
diff
changeset
|
32 #include "media/backend-iface.h" |
29140 | 33 #include "mediamanager.h" |
34 | |
35 #include "debug.h" | |
36 | |
37 #ifdef USE_GSTREAMER | |
38 #include "marshallers.h" | |
39 #include "media-gst.h" | |
40 #endif | |
41 | |
42 #ifdef USE_VV | |
43 | |
44 /** @copydoc _PurpleMediaSession */ | |
45 typedef struct _PurpleMediaSession PurpleMediaSession; | |
46 /** @copydoc _PurpleMediaStream */ | |
47 typedef struct _PurpleMediaStream PurpleMediaStream; | |
48 /** @copydoc _PurpleMediaClass */ | |
49 typedef struct _PurpleMediaClass PurpleMediaClass; | |
50 /** @copydoc _PurpleMediaPrivate */ | |
51 typedef struct _PurpleMediaPrivate PurpleMediaPrivate; | |
52 | |
53 /** The media class */ | |
54 struct _PurpleMediaClass | |
55 { | |
56 GObjectClass parent_class; /**< The parent class. */ | |
57 }; | |
58 | |
59 /** The media class's private data */ | |
60 struct _PurpleMedia | |
61 { | |
62 GObject parent; /**< The parent of this object. */ | |
63 PurpleMediaPrivate *priv; /**< The private data of this object. */ | |
64 }; | |
65 | |
66 struct _PurpleMediaSession | |
67 { | |
68 gchar *id; | |
69 PurpleMedia *media; | |
70 PurpleMediaSessionType type; | |
71 gboolean initiator; | |
72 }; | |
73 | |
74 struct _PurpleMediaStream | |
75 { | |
76 PurpleMediaSession *session; | |
77 gchar *participant; | |
78 | |
79 GList *local_candidates; | |
80 GList *remote_candidates; | |
81 | |
82 gboolean initiator; | |
83 gboolean accepted; | |
84 gboolean candidates_prepared; | |
85 | |
86 GList *active_local_candidates; | |
87 GList *active_remote_candidates; | |
88 }; | |
89 #endif | |
90 | |
91 struct _PurpleMediaPrivate | |
92 { | |
93 #ifdef USE_VV | |
94 PurpleMediaManager *manager; | |
95 PurpleAccount *account; | |
29155
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29151
diff
changeset
|
96 PurpleMediaBackend *backend; |
29151
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29144
diff
changeset
|
97 gchar *conference_type; |
29140 | 98 gboolean initiator; |
99 gpointer prpl_data; | |
100 | |
101 GHashTable *sessions; /* PurpleMediaSession table */ | |
29205
78ac6e4d3de9
Add a list of participants back to PurpleMedia.
maiku@pidgin.im
parents:
29203
diff
changeset
|
102 GList *participants; |
29140 | 103 GList *streams; /* PurpleMediaStream table */ |
104 #else | |
105 gpointer dummy; | |
106 #endif | |
107 }; | |
108 | |
109 #ifdef USE_VV | |
110 #define PURPLE_MEDIA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_MEDIA, PurpleMediaPrivate)) | |
111 | |
112 static void purple_media_class_init (PurpleMediaClass *klass); | |
113 static void purple_media_init (PurpleMedia *media); | |
114 static void purple_media_dispose (GObject *object); | |
115 static void purple_media_finalize (GObject *object); | |
116 static void purple_media_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); | |
117 static void purple_media_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); | |
118 | |
29160
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29159
diff
changeset
|
119 static void purple_media_new_local_candidate_cb(PurpleMediaBackend *backend, |
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29159
diff
changeset
|
120 const gchar *sess_id, const gchar *participant, |
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29159
diff
changeset
|
121 PurpleMediaCandidate *candidate, PurpleMedia *media); |
29163
1fdc75c94c22
Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents:
29162
diff
changeset
|
122 static void purple_media_candidates_prepared_cb(PurpleMediaBackend *backend, |
1fdc75c94c22
Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents:
29162
diff
changeset
|
123 const gchar *sess_id, const gchar *name, PurpleMedia *media); |
29162
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
124 static void purple_media_candidate_pair_established_cb( |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
125 PurpleMediaBackend *backend, |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
126 const gchar *sess_id, const gchar *name, |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
127 PurpleMediaCandidate *local_candidate, |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
128 PurpleMediaCandidate *remote_candidate, |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
129 PurpleMedia *media); |
29161
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29160
diff
changeset
|
130 static void purple_media_codecs_changed_cb(PurpleMediaBackend *backend, |
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29160
diff
changeset
|
131 const gchar *sess_id, PurpleMedia *media); |
29140 | 132 |
133 static GObjectClass *parent_class = NULL; | |
134 | |
135 | |
136 | |
137 enum { | |
138 S_ERROR, | |
139 CANDIDATES_PREPARED, | |
140 CODECS_CHANGED, | |
141 LEVEL, | |
142 NEW_CANDIDATE, | |
143 STATE_CHANGED, | |
144 STREAM_INFO, | |
145 LAST_SIGNAL | |
146 }; | |
147 static guint purple_media_signals[LAST_SIGNAL] = {0}; | |
148 | |
149 enum { | |
150 PROP_0, | |
151 PROP_MANAGER, | |
152 PROP_ACCOUNT, | |
29151
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29144
diff
changeset
|
153 PROP_CONFERENCE_TYPE, |
29140 | 154 PROP_INITIATOR, |
155 PROP_PRPL_DATA, | |
156 }; | |
157 #endif | |
158 | |
159 | |
160 GType | |
161 purple_media_get_type() | |
162 { | |
163 #ifdef USE_VV | |
164 static GType type = 0; | |
165 | |
166 if (type == 0) { | |
167 static const GTypeInfo info = { | |
168 sizeof(PurpleMediaClass), | |
169 NULL, | |
170 NULL, | |
171 (GClassInitFunc) purple_media_class_init, | |
172 NULL, | |
173 NULL, | |
174 sizeof(PurpleMedia), | |
175 0, | |
176 (GInstanceInitFunc) purple_media_init, | |
177 NULL | |
178 }; | |
179 type = g_type_register_static(G_TYPE_OBJECT, "PurpleMedia", &info, 0); | |
180 } | |
181 return type; | |
182 #else | |
183 return G_TYPE_NONE; | |
184 #endif | |
185 } | |
186 | |
187 #ifdef USE_VV | |
188 static void | |
189 purple_media_class_init (PurpleMediaClass *klass) | |
190 { | |
191 GObjectClass *gobject_class = (GObjectClass*)klass; | |
192 parent_class = g_type_class_peek_parent(klass); | |
193 | |
194 gobject_class->dispose = purple_media_dispose; | |
195 gobject_class->finalize = purple_media_finalize; | |
196 gobject_class->set_property = purple_media_set_property; | |
197 gobject_class->get_property = purple_media_get_property; | |
198 | |
199 g_object_class_install_property(gobject_class, PROP_MANAGER, | |
200 g_param_spec_object("manager", | |
201 "Purple Media Manager", | |
202 "The media manager that contains this media session.", | |
203 PURPLE_TYPE_MEDIA_MANAGER, | |
204 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); | |
205 | |
206 g_object_class_install_property(gobject_class, PROP_ACCOUNT, | |
207 g_param_spec_pointer("account", | |
208 "PurpleAccount", | |
209 "The account this media session is on.", | |
210 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); | |
211 | |
29151
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29144
diff
changeset
|
212 g_object_class_install_property(gobject_class, PROP_CONFERENCE_TYPE, |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29144
diff
changeset
|
213 g_param_spec_string("conference-type", |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29144
diff
changeset
|
214 "Conference Type", |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29144
diff
changeset
|
215 "The type of conference that this media object " |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29144
diff
changeset
|
216 "has been created to provide.", |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29144
diff
changeset
|
217 NULL, |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29144
diff
changeset
|
218 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29144
diff
changeset
|
219 |
29140 | 220 g_object_class_install_property(gobject_class, PROP_INITIATOR, |
221 g_param_spec_boolean("initiator", | |
222 "initiator", | |
223 "If the local user initiated the conference.", | |
224 FALSE, | |
225 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); | |
226 | |
227 g_object_class_install_property(gobject_class, PROP_PRPL_DATA, | |
228 g_param_spec_pointer("prpl-data", | |
229 "gpointer", | |
230 "Data the prpl plugin set on the media session.", | |
231 G_PARAM_READWRITE)); | |
232 | |
233 purple_media_signals[S_ERROR] = g_signal_new("error", G_TYPE_FROM_CLASS(klass), | |
234 G_SIGNAL_RUN_LAST, 0, NULL, NULL, | |
235 g_cclosure_marshal_VOID__STRING, | |
236 G_TYPE_NONE, 1, G_TYPE_STRING); | |
237 purple_media_signals[CANDIDATES_PREPARED] = g_signal_new("candidates-prepared", G_TYPE_FROM_CLASS(klass), | |
238 G_SIGNAL_RUN_LAST, 0, NULL, NULL, | |
239 purple_smarshal_VOID__STRING_STRING, | |
240 G_TYPE_NONE, 2, G_TYPE_STRING, | |
241 G_TYPE_STRING); | |
242 purple_media_signals[CODECS_CHANGED] = g_signal_new("codecs-changed", G_TYPE_FROM_CLASS(klass), | |
243 G_SIGNAL_RUN_LAST, 0, NULL, NULL, | |
244 g_cclosure_marshal_VOID__STRING, | |
245 G_TYPE_NONE, 1, G_TYPE_STRING); | |
246 purple_media_signals[LEVEL] = g_signal_new("level", G_TYPE_FROM_CLASS(klass), | |
247 G_SIGNAL_RUN_LAST, 0, NULL, NULL, | |
248 purple_smarshal_VOID__STRING_STRING_DOUBLE, | |
249 G_TYPE_NONE, 3, G_TYPE_STRING, | |
250 G_TYPE_STRING, G_TYPE_DOUBLE); | |
251 purple_media_signals[NEW_CANDIDATE] = g_signal_new("new-candidate", G_TYPE_FROM_CLASS(klass), | |
252 G_SIGNAL_RUN_LAST, 0, NULL, NULL, | |
253 purple_smarshal_VOID__POINTER_POINTER_OBJECT, | |
254 G_TYPE_NONE, 3, G_TYPE_POINTER, | |
255 G_TYPE_POINTER, PURPLE_TYPE_MEDIA_CANDIDATE); | |
256 purple_media_signals[STATE_CHANGED] = g_signal_new("state-changed", G_TYPE_FROM_CLASS(klass), | |
257 G_SIGNAL_RUN_LAST, 0, NULL, NULL, | |
258 purple_smarshal_VOID__ENUM_STRING_STRING, | |
259 G_TYPE_NONE, 3, PURPLE_MEDIA_TYPE_STATE, | |
260 G_TYPE_STRING, G_TYPE_STRING); | |
261 purple_media_signals[STREAM_INFO] = g_signal_new("stream-info", G_TYPE_FROM_CLASS(klass), | |
262 G_SIGNAL_RUN_LAST, 0, NULL, NULL, | |
263 purple_smarshal_VOID__ENUM_STRING_STRING_BOOLEAN, | |
264 G_TYPE_NONE, 4, PURPLE_MEDIA_TYPE_INFO_TYPE, | |
265 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN); | |
266 g_type_class_add_private(klass, sizeof(PurpleMediaPrivate)); | |
267 } | |
268 | |
269 | |
270 static void | |
271 purple_media_init (PurpleMedia *media) | |
272 { | |
273 media->priv = PURPLE_MEDIA_GET_PRIVATE(media); | |
274 memset(media->priv, 0, sizeof(*media->priv)); | |
275 } | |
276 | |
277 static void | |
278 purple_media_stream_free(PurpleMediaStream *stream) | |
279 { | |
280 if (stream == NULL) | |
281 return; | |
282 | |
283 g_free(stream->participant); | |
284 | |
285 if (stream->local_candidates) | |
29165
cb843608e183
Store local_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29163
diff
changeset
|
286 purple_media_candidate_list_free(stream->local_candidates); |
29140 | 287 if (stream->remote_candidates) |
29166
18571ea6e44a
Store remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29165
diff
changeset
|
288 purple_media_candidate_list_free(stream->remote_candidates); |
29140 | 289 |
290 if (stream->active_local_candidates) | |
29167
7713312c4ab0
Store active_local_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29166
diff
changeset
|
291 purple_media_candidate_list_free( |
7713312c4ab0
Store active_local_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29166
diff
changeset
|
292 stream->active_local_candidates); |
29140 | 293 if (stream->active_remote_candidates) |
29168
1156bf88b4d3
Store active_remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29167
diff
changeset
|
294 purple_media_candidate_list_free( |
1156bf88b4d3
Store active_remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29167
diff
changeset
|
295 stream->active_remote_candidates); |
29140 | 296 |
297 g_free(stream); | |
298 } | |
299 | |
300 static void | |
301 purple_media_session_free(PurpleMediaSession *session) | |
302 { | |
303 if (session == NULL) | |
304 return; | |
305 | |
306 g_free(session->id); | |
307 g_free(session); | |
308 } | |
309 | |
310 static void | |
311 purple_media_dispose(GObject *media) | |
312 { | |
313 PurpleMediaPrivate *priv = PURPLE_MEDIA_GET_PRIVATE(media); | |
314 | |
315 purple_debug_info("media","purple_media_dispose\n"); | |
316 | |
317 purple_media_manager_remove_media(priv->manager, PURPLE_MEDIA(media)); | |
318 | |
29155
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29151
diff
changeset
|
319 if (priv->backend) { |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29151
diff
changeset
|
320 g_object_unref(priv->backend); |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29151
diff
changeset
|
321 priv->backend = NULL; |
29140 | 322 } |
323 | |
29157
e85df0170905
Decouple the media_bus_call from the backend. It will still be needed even
maiku@pidgin.im
parents:
29156
diff
changeset
|
324 if (priv->manager) { |
29140 | 325 g_object_unref(priv->manager); |
326 priv->manager = NULL; | |
327 } | |
328 | |
329 G_OBJECT_CLASS(parent_class)->dispose(media); | |
330 } | |
331 | |
332 static void | |
333 purple_media_finalize(GObject *media) | |
334 { | |
335 PurpleMediaPrivate *priv = PURPLE_MEDIA_GET_PRIVATE(media); | |
336 purple_debug_info("media","purple_media_finalize\n"); | |
337 | |
338 for (; priv->streams; priv->streams = g_list_delete_link(priv->streams, priv->streams)) | |
339 purple_media_stream_free(priv->streams->data); | |
340 | |
29205
78ac6e4d3de9
Add a list of participants back to PurpleMedia.
maiku@pidgin.im
parents:
29203
diff
changeset
|
341 for (; priv->participants; priv->participants = g_list_delete_link( |
78ac6e4d3de9
Add a list of participants back to PurpleMedia.
maiku@pidgin.im
parents:
29203
diff
changeset
|
342 priv->participants, priv->participants)) |
78ac6e4d3de9
Add a list of participants back to PurpleMedia.
maiku@pidgin.im
parents:
29203
diff
changeset
|
343 g_free(priv->participants->data); |
78ac6e4d3de9
Add a list of participants back to PurpleMedia.
maiku@pidgin.im
parents:
29203
diff
changeset
|
344 |
29140 | 345 if (priv->sessions) { |
346 GList *sessions = g_hash_table_get_values(priv->sessions); | |
347 for (; sessions; sessions = g_list_delete_link(sessions, sessions)) { | |
348 purple_media_session_free(sessions->data); | |
349 } | |
350 g_hash_table_destroy(priv->sessions); | |
351 } | |
352 | |
353 G_OBJECT_CLASS(parent_class)->finalize(media); | |
354 } | |
355 | |
356 static void | |
357 purple_media_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) | |
358 { | |
359 PurpleMedia *media; | |
360 g_return_if_fail(PURPLE_IS_MEDIA(object)); | |
361 | |
362 media = PURPLE_MEDIA(object); | |
363 | |
364 switch (prop_id) { | |
365 case PROP_MANAGER: | |
29155
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29151
diff
changeset
|
366 media->priv->manager = g_value_dup_object(value); |
29140 | 367 break; |
368 case PROP_ACCOUNT: | |
369 media->priv->account = g_value_get_pointer(value); | |
370 break; | |
29151
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29144
diff
changeset
|
371 case PROP_CONFERENCE_TYPE: |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29144
diff
changeset
|
372 media->priv->conference_type = |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29144
diff
changeset
|
373 g_value_dup_string(value); |
29155
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29151
diff
changeset
|
374 media->priv->backend = g_object_new( |
29210
2b2b930281a0
Add a way to set and get which media backend type to use.
maiku@pidgin.im
parents:
29208
diff
changeset
|
375 purple_media_manager_get_backend_type( |
2b2b930281a0
Add a way to set and get which media backend type to use.
maiku@pidgin.im
parents:
29208
diff
changeset
|
376 purple_media_manager_get()), |
29155
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29151
diff
changeset
|
377 "conference-type", |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29151
diff
changeset
|
378 media->priv->conference_type, |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29151
diff
changeset
|
379 "media", media, |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29151
diff
changeset
|
380 NULL); |
29160
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29159
diff
changeset
|
381 g_signal_connect(media->priv->backend, |
29162
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
382 "active-candidate-pair", |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
383 G_CALLBACK( |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
384 purple_media_candidate_pair_established_cb), |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
385 media); |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
386 g_signal_connect(media->priv->backend, |
29163
1fdc75c94c22
Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents:
29162
diff
changeset
|
387 "candidates-prepared", |
1fdc75c94c22
Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents:
29162
diff
changeset
|
388 G_CALLBACK( |
1fdc75c94c22
Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents:
29162
diff
changeset
|
389 purple_media_candidates_prepared_cb), |
1fdc75c94c22
Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents:
29162
diff
changeset
|
390 media); |
1fdc75c94c22
Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents:
29162
diff
changeset
|
391 g_signal_connect(media->priv->backend, |
29161
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29160
diff
changeset
|
392 "codecs-changed", |
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29160
diff
changeset
|
393 G_CALLBACK( |
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29160
diff
changeset
|
394 purple_media_codecs_changed_cb), |
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29160
diff
changeset
|
395 media); |
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29160
diff
changeset
|
396 g_signal_connect(media->priv->backend, |
29160
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29159
diff
changeset
|
397 "new-candidate", |
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29159
diff
changeset
|
398 G_CALLBACK( |
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29159
diff
changeset
|
399 purple_media_new_local_candidate_cb), |
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29159
diff
changeset
|
400 media); |
29151
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29144
diff
changeset
|
401 break; |
29140 | 402 case PROP_INITIATOR: |
403 media->priv->initiator = g_value_get_boolean(value); | |
404 break; | |
405 case PROP_PRPL_DATA: | |
406 media->priv->prpl_data = g_value_get_pointer(value); | |
407 break; | |
408 default: | |
409 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | |
410 break; | |
411 } | |
412 } | |
413 | |
414 static void | |
415 purple_media_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) | |
416 { | |
417 PurpleMedia *media; | |
418 g_return_if_fail(PURPLE_IS_MEDIA(object)); | |
419 | |
420 media = PURPLE_MEDIA(object); | |
421 | |
422 switch (prop_id) { | |
423 case PROP_MANAGER: | |
424 g_value_set_object(value, media->priv->manager); | |
425 break; | |
426 case PROP_ACCOUNT: | |
427 g_value_set_pointer(value, media->priv->account); | |
428 break; | |
29151
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29144
diff
changeset
|
429 case PROP_CONFERENCE_TYPE: |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29144
diff
changeset
|
430 g_value_set_string(value, |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29144
diff
changeset
|
431 media->priv->conference_type); |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29144
diff
changeset
|
432 break; |
29140 | 433 case PROP_INITIATOR: |
434 g_value_set_boolean(value, media->priv->initiator); | |
435 break; | |
436 case PROP_PRPL_DATA: | |
437 g_value_set_pointer(value, media->priv->prpl_data); | |
438 break; | |
439 default: | |
440 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | |
441 break; | |
442 } | |
443 | |
444 } | |
445 | |
446 static PurpleMediaSession* | |
447 purple_media_get_session(PurpleMedia *media, const gchar *sess_id) | |
448 { | |
449 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
450 return (PurpleMediaSession*) (media->priv->sessions) ? | |
451 g_hash_table_lookup(media->priv->sessions, sess_id) : NULL; | |
452 } | |
453 | |
454 static PurpleMediaStream* | |
455 purple_media_get_stream(PurpleMedia *media, const gchar *session, const gchar *participant) | |
456 { | |
457 GList *streams; | |
458 | |
459 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
460 | |
461 streams = media->priv->streams; | |
462 | |
463 for (; streams; streams = g_list_next(streams)) { | |
464 PurpleMediaStream *stream = streams->data; | |
465 if (!strcmp(stream->session->id, session) && | |
466 !strcmp(stream->participant, participant)) | |
467 return stream; | |
468 } | |
469 | |
470 return NULL; | |
471 } | |
472 | |
473 static GList * | |
474 purple_media_get_streams(PurpleMedia *media, const gchar *session, | |
475 const gchar *participant) | |
476 { | |
477 GList *streams; | |
478 GList *ret = NULL; | |
479 | |
480 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
481 | |
482 streams = media->priv->streams; | |
483 | |
484 for (; streams; streams = g_list_next(streams)) { | |
485 PurpleMediaStream *stream = streams->data; | |
486 if ((session == NULL || | |
487 !strcmp(stream->session->id, session)) && | |
488 (participant == NULL || | |
489 !strcmp(stream->participant, participant))) | |
490 ret = g_list_append(ret, stream); | |
491 } | |
492 | |
493 return ret; | |
494 } | |
495 | |
496 static void | |
497 purple_media_add_session(PurpleMedia *media, PurpleMediaSession *session) | |
498 { | |
499 g_return_if_fail(PURPLE_IS_MEDIA(media)); | |
500 g_return_if_fail(session != NULL); | |
501 | |
502 if (!media->priv->sessions) { | |
503 purple_debug_info("media", "Creating hash table for sessions\n"); | |
504 media->priv->sessions = g_hash_table_new(g_str_hash, g_str_equal); | |
505 } | |
506 g_hash_table_insert(media->priv->sessions, g_strdup(session->id), session); | |
507 } | |
508 | |
29174 | 509 #if 0 |
29140 | 510 static gboolean |
511 purple_media_remove_session(PurpleMedia *media, PurpleMediaSession *session) | |
512 { | |
513 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE); | |
514 return g_hash_table_remove(media->priv->sessions, session->id); | |
515 } | |
29174 | 516 #endif |
29140 | 517 |
518 static PurpleMediaStream * | |
29186 | 519 purple_media_insert_stream(PurpleMediaSession *session, |
520 const gchar *name, gboolean initiator) | |
29140 | 521 { |
522 PurpleMediaStream *media_stream; | |
523 | |
524 g_return_val_if_fail(session != NULL, NULL); | |
525 | |
526 media_stream = g_new0(PurpleMediaStream, 1); | |
527 media_stream->participant = g_strdup(name); | |
528 media_stream->session = session; | |
29186 | 529 media_stream->initiator = initiator; |
29140 | 530 |
531 session->media->priv->streams = | |
532 g_list_append(session->media->priv->streams, media_stream); | |
533 | |
534 return media_stream; | |
535 } | |
536 | |
537 static void | |
538 purple_media_insert_local_candidate(PurpleMediaSession *session, const gchar *name, | |
29165
cb843608e183
Store local_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29163
diff
changeset
|
539 PurpleMediaCandidate *candidate) |
29140 | 540 { |
541 PurpleMediaStream *stream; | |
542 | |
543 g_return_if_fail(session != NULL); | |
544 | |
545 stream = purple_media_get_stream(session->media, session->id, name); | |
546 stream->local_candidates = g_list_append(stream->local_candidates, candidate); | |
547 } | |
548 #endif | |
549 | |
550 GList * | |
551 purple_media_get_session_ids(PurpleMedia *media) | |
552 { | |
553 #ifdef USE_VV | |
554 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
555 return media->priv->sessions != NULL ? | |
556 g_hash_table_get_keys(media->priv->sessions) : NULL; | |
557 #else | |
558 return NULL; | |
559 #endif | |
560 } | |
561 | |
562 #ifdef USE_GSTREAMER | |
563 GstElement * | |
564 purple_media_get_src(PurpleMedia *media, const gchar *sess_id) | |
565 { | |
566 #ifdef USE_VV | |
567 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
29189
eadb9e309b87
Move all src and sink creation in PurpleMedia to the Fs2 media backend.
maiku@pidgin.im
parents:
29188
diff
changeset
|
568 |
eadb9e309b87
Move all src and sink creation in PurpleMedia to the Fs2 media backend.
maiku@pidgin.im
parents:
29188
diff
changeset
|
569 if (PURPLE_IS_MEDIA_BACKEND_FS2(media->priv->backend)) |
eadb9e309b87
Move all src and sink creation in PurpleMedia to the Fs2 media backend.
maiku@pidgin.im
parents:
29188
diff
changeset
|
570 return purple_media_backend_fs2_get_src( |
eadb9e309b87
Move all src and sink creation in PurpleMedia to the Fs2 media backend.
maiku@pidgin.im
parents:
29188
diff
changeset
|
571 PURPLE_MEDIA_BACKEND_FS2( |
eadb9e309b87
Move all src and sink creation in PurpleMedia to the Fs2 media backend.
maiku@pidgin.im
parents:
29188
diff
changeset
|
572 media->priv->backend), sess_id); |
eadb9e309b87
Move all src and sink creation in PurpleMedia to the Fs2 media backend.
maiku@pidgin.im
parents:
29188
diff
changeset
|
573 |
eadb9e309b87
Move all src and sink creation in PurpleMedia to the Fs2 media backend.
maiku@pidgin.im
parents:
29188
diff
changeset
|
574 g_return_val_if_reached(NULL); |
29140 | 575 #else |
576 return NULL; | |
577 #endif | |
578 } | |
579 #endif /* USE_GSTREAMER */ | |
580 | |
581 PurpleAccount * | |
582 purple_media_get_account(PurpleMedia *media) | |
583 { | |
584 #ifdef USE_VV | |
585 PurpleAccount *account; | |
586 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
587 g_object_get(G_OBJECT(media), "account", &account, NULL); | |
588 return account; | |
589 #else | |
590 return NULL; | |
591 #endif | |
592 } | |
593 | |
594 gpointer | |
595 purple_media_get_prpl_data(PurpleMedia *media) | |
596 { | |
597 #ifdef USE_VV | |
598 gpointer prpl_data; | |
599 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
600 g_object_get(G_OBJECT(media), "prpl-data", &prpl_data, NULL); | |
601 return prpl_data; | |
602 #else | |
603 return NULL; | |
604 #endif | |
605 } | |
606 | |
607 void | |
608 purple_media_set_prpl_data(PurpleMedia *media, gpointer prpl_data) | |
609 { | |
610 #ifdef USE_VV | |
611 g_return_if_fail(PURPLE_IS_MEDIA(media)); | |
612 g_object_set(G_OBJECT(media), "prpl-data", prpl_data, NULL); | |
613 #endif | |
614 } | |
615 | |
616 void | |
617 purple_media_error(PurpleMedia *media, const gchar *error, ...) | |
618 { | |
619 #ifdef USE_VV | |
620 va_list args; | |
621 gchar *message; | |
622 | |
623 g_return_if_fail(PURPLE_IS_MEDIA(media)); | |
624 | |
625 va_start(args, error); | |
626 message = g_strdup_vprintf(error, args); | |
627 va_end(args); | |
628 | |
629 purple_debug_error("media", "%s\n", message); | |
630 g_signal_emit(media, purple_media_signals[S_ERROR], 0, message); | |
631 | |
632 g_free(message); | |
633 #endif | |
634 } | |
635 | |
636 void | |
637 purple_media_end(PurpleMedia *media, | |
638 const gchar *session_id, const gchar *participant) | |
639 { | |
640 #ifdef USE_VV | |
29201
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
641 GList *iter, *sessions = NULL, *participants = NULL; |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
642 |
29140 | 643 g_return_if_fail(PURPLE_IS_MEDIA(media)); |
29201
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
644 |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
645 iter = purple_media_get_streams(media, session_id, participant); |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
646 |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
647 /* Free matching streams */ |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
648 for (; iter; iter = g_list_delete_link(iter, iter)) { |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
649 PurpleMediaStream *stream = iter->data; |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
650 |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
651 g_signal_emit(media, purple_media_signals[STATE_CHANGED], |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
652 0, PURPLE_MEDIA_STATE_END, |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
653 stream->session->id, stream->participant); |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
654 |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
655 media->priv->streams = |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
656 g_list_remove(media->priv->streams, stream); |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
657 |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
658 if (g_list_find(sessions, stream->session) == NULL) |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
659 sessions = g_list_prepend(sessions, stream->session); |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
660 |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
661 if (g_list_find_custom(participants, stream->participant, |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
662 (GCompareFunc)strcmp) == NULL) |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
663 participants = g_list_prepend(participants, |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
664 g_strdup(stream->participant)); |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
665 |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
666 purple_media_stream_free(stream); |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
667 } |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
668 |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
669 iter = media->priv->streams; |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
670 |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
671 /* Reduce to list of sessions to remove */ |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
672 for (; iter; iter = g_list_next(iter)) { |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
673 PurpleMediaStream *stream = iter->data; |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
674 |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
675 sessions = g_list_remove(sessions, stream->session); |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
676 } |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
677 |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
678 /* Free sessions with no streams left */ |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
679 for (; sessions; sessions = g_list_delete_link(sessions, sessions)) { |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
680 PurpleMediaSession *session = sessions->data; |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
681 |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
682 g_signal_emit(media, purple_media_signals[STATE_CHANGED], |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
683 0, PURPLE_MEDIA_STATE_END, |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
684 session->id, NULL); |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
685 |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
686 g_hash_table_remove(media->priv->sessions, session->id); |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
687 purple_media_session_free(session); |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
688 } |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
689 |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
690 iter = media->priv->streams; |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
691 |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
692 /* Reduce to list of participants to remove */ |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
693 for (; iter; iter = g_list_next(iter)) { |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
694 PurpleMediaStream *stream = iter->data; |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
695 GList *tmp; |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
696 |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
697 tmp = g_list_find_custom(participants, |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
698 stream->participant, (GCompareFunc)strcmp); |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
699 |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
700 if (tmp != NULL) { |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
701 g_free(tmp->data); |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
702 participants = g_list_delete_link(participants, tmp); |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
703 } |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
704 } |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
705 |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
706 /* Remove participants with no streams left (just emit the signal) */ |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
707 for (; participants; participants = |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
708 g_list_delete_link(participants, participants)) { |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
709 gchar *participant = participants->data; |
29206
80bdae3ea957
Free participants properly in purple_media_end.
maiku@pidgin.im
parents:
29205
diff
changeset
|
710 GList *link = g_list_find_custom(media->priv->participants, |
80bdae3ea957
Free participants properly in purple_media_end.
maiku@pidgin.im
parents:
29205
diff
changeset
|
711 participant, (GCompareFunc)strcmp); |
80bdae3ea957
Free participants properly in purple_media_end.
maiku@pidgin.im
parents:
29205
diff
changeset
|
712 |
29201
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
713 g_signal_emit(media, purple_media_signals[STATE_CHANGED], |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
714 0, PURPLE_MEDIA_STATE_END, |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
715 NULL, participant); |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
716 |
29206
80bdae3ea957
Free participants properly in purple_media_end.
maiku@pidgin.im
parents:
29205
diff
changeset
|
717 if (link != NULL) { |
80bdae3ea957
Free participants properly in purple_media_end.
maiku@pidgin.im
parents:
29205
diff
changeset
|
718 g_free(link->data); |
80bdae3ea957
Free participants properly in purple_media_end.
maiku@pidgin.im
parents:
29205
diff
changeset
|
719 media->priv->participants = g_list_delete_link( |
80bdae3ea957
Free participants properly in purple_media_end.
maiku@pidgin.im
parents:
29205
diff
changeset
|
720 media->priv->participants, link); |
80bdae3ea957
Free participants properly in purple_media_end.
maiku@pidgin.im
parents:
29205
diff
changeset
|
721 } |
80bdae3ea957
Free participants properly in purple_media_end.
maiku@pidgin.im
parents:
29205
diff
changeset
|
722 |
29201
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
723 g_free(participant); |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
724 } |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
725 |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
726 /* Free the conference if no sessions left */ |
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
727 if (g_hash_table_size(media->priv->sessions) == 0) { |
29140 | 728 g_signal_emit(media, purple_media_signals[STATE_CHANGED], |
729 0, PURPLE_MEDIA_STATE_END, | |
730 NULL, NULL); | |
731 g_object_unref(media); | |
29201
918d4043cc33
Emit PURPLE_MEDIA_END state-changed signals for each stream, session, and
maiku@pidgin.im
parents:
29200
diff
changeset
|
732 return; |
29140 | 733 } |
734 #endif | |
735 } | |
736 | |
737 void | |
738 purple_media_stream_info(PurpleMedia *media, PurpleMediaInfoType type, | |
739 const gchar *session_id, const gchar *participant, | |
740 gboolean local) | |
741 { | |
742 #ifdef USE_VV | |
743 g_return_if_fail(PURPLE_IS_MEDIA(media)); | |
744 | |
745 if (type == PURPLE_MEDIA_INFO_ACCEPT) { | |
29202
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
746 GList *streams, *sessions = NULL, *participants = NULL; |
29140 | 747 |
748 g_return_if_fail(PURPLE_IS_MEDIA(media)); | |
749 | |
750 streams = purple_media_get_streams(media, | |
751 session_id, participant); | |
752 | |
29202
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
753 /* Emit stream acceptance */ |
29140 | 754 for (; streams; streams = |
755 g_list_delete_link(streams, streams)) { | |
756 PurpleMediaStream *stream = streams->data; | |
29182
a27e41f373db
Handle part of accepting a stream in the Fs2 media backend.
maiku@pidgin.im
parents:
29181
diff
changeset
|
757 |
29140 | 758 stream->accepted = TRUE; |
29202
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
759 |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
760 g_signal_emit(media, |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
761 purple_media_signals[STREAM_INFO], |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
762 0, type, stream->session->id, |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
763 stream->participant, local); |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
764 |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
765 if (g_list_find(sessions, stream->session) == NULL) |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
766 sessions = g_list_prepend(sessions, |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
767 stream->session); |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
768 |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
769 if (g_list_find_custom(participants, |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
770 stream->participant, |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
771 (GCompareFunc)strcmp) == NULL) |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
772 participants = g_list_prepend(participants, |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
773 g_strdup(stream->participant)); |
29140 | 774 } |
29202
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
775 |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
776 /* Emit session acceptance */ |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
777 for (; sessions; sessions = |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
778 g_list_delete_link(sessions, sessions)) { |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
779 PurpleMediaSession *session = sessions->data; |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
780 |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
781 if (purple_media_accepted(media, session->id, NULL)) |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
782 g_signal_emit(media, purple_media_signals[ |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
783 STREAM_INFO], 0, |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
784 PURPLE_MEDIA_INFO_ACCEPT, |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
785 session->id, NULL, local); |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
786 } |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
787 |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
788 /* Emit participant acceptance */ |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
789 for (; participants; participants = g_list_delete_link( |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
790 participants, participants)) { |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
791 gchar *participant = participants->data; |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
792 |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
793 if (purple_media_accepted(media, NULL, participant)) |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
794 g_signal_emit(media, purple_media_signals[ |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
795 STREAM_INFO], 0, |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
796 PURPLE_MEDIA_INFO_ACCEPT, |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
797 NULL, participant, local); |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
798 |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
799 g_free(participant); |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
800 } |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
801 |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
802 /* Emit conference acceptance */ |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
803 if (purple_media_accepted(media, NULL, NULL)) |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
804 g_signal_emit(media, |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
805 purple_media_signals[STREAM_INFO], |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
806 0, PURPLE_MEDIA_INFO_ACCEPT, |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
807 NULL, NULL, local); |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
808 |
ecdf669adac9
Have PURPLE_MEDIA_INFO_ACCEPT in stream-info emit for each accepted stream,
maiku@pidgin.im
parents:
29201
diff
changeset
|
809 return; |
29203
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
810 } else if (type == PURPLE_MEDIA_INFO_HANGUP || |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
811 type == PURPLE_MEDIA_INFO_REJECT) { |
29207
bcee1aab1c01
Keep track of participants better in purple_media_stream_info.
maiku@pidgin.im
parents:
29206
diff
changeset
|
812 GList *streams; |
29203
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
813 |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
814 g_return_if_fail(PURPLE_IS_MEDIA(media)); |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
815 |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
816 streams = purple_media_get_streams(media, |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
817 session_id, participant); |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
818 |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
819 /* Emit for stream */ |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
820 for (; streams; streams = |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
821 g_list_delete_link(streams, streams)) { |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
822 PurpleMediaStream *stream = streams->data; |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
823 |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
824 g_signal_emit(media, |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
825 purple_media_signals[STREAM_INFO], |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
826 0, type, stream->session->id, |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
827 stream->participant, local); |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
828 } |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
829 |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
830 if (session_id != NULL && participant != NULL) { |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
831 /* Everything that needs to be emitted has been */ |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
832 } else if (session_id == NULL && participant == NULL) { |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
833 /* Emit for everything in the conference */ |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
834 GList *sessions = g_hash_table_get_values( |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
835 media->priv->sessions); |
29207
bcee1aab1c01
Keep track of participants better in purple_media_stream_info.
maiku@pidgin.im
parents:
29206
diff
changeset
|
836 GList *participants = media->priv->participants; |
29203
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
837 |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
838 /* Emit for sessions */ |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
839 for (; sessions; sessions = g_list_delete_link( |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
840 sessions, sessions)) { |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
841 PurpleMediaSession *session = sessions->data; |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
842 |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
843 g_signal_emit(media, purple_media_signals[ |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
844 STREAM_INFO], 0, type, |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
845 session->id, NULL, local); |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
846 } |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
847 |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
848 /* Emit for participants */ |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
849 for (; participants; participants = |
29207
bcee1aab1c01
Keep track of participants better in purple_media_stream_info.
maiku@pidgin.im
parents:
29206
diff
changeset
|
850 g_list_next(participants)) { |
29203
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
851 gchar *participant = participants->data; |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
852 |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
853 g_signal_emit(media, purple_media_signals[ |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
854 STREAM_INFO], 0, type, |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
855 NULL, participant, local); |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
856 } |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
857 |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
858 /* Emit for conference */ |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
859 g_signal_emit(media, |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
860 purple_media_signals[STREAM_INFO], |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
861 0, type, NULL, NULL, local); |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
862 } else if (session_id != NULL) { |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
863 /* Emit just the specific session */ |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
864 PurpleMediaSession *session = |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
865 purple_media_get_session( |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
866 media, session_id); |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
867 |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
868 if (session == NULL) { |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
869 purple_debug_warning("media", |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
870 "Couldn't find session" |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
871 " to hangup/reject.\n"); |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
872 } else { |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
873 g_signal_emit(media, purple_media_signals[ |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
874 STREAM_INFO], 0, type, |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
875 session->id, NULL, local); |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
876 } |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
877 } else if (participant != NULL) { |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
878 /* Emit just the specific participant */ |
29207
bcee1aab1c01
Keep track of participants better in purple_media_stream_info.
maiku@pidgin.im
parents:
29206
diff
changeset
|
879 if (!g_list_find_custom(media->priv->participants, |
29203
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
880 participant, (GCompareFunc)strcmp)) { |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
881 purple_debug_warning("media", |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
882 "Couldn't find participant" |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
883 " to hangup/reject.\n"); |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
884 } else { |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
885 g_signal_emit(media, purple_media_signals[ |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
886 STREAM_INFO], 0, type, NULL, |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
887 participant, local); |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
888 } |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
889 } |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
890 |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
891 purple_media_end(media, session_id, participant); |
86c23178a4fc
Emit stream-info for each stream, session, and participant for hangup and
maiku@pidgin.im
parents:
29202
diff
changeset
|
892 return; |
29140 | 893 } |
894 | |
895 g_signal_emit(media, purple_media_signals[STREAM_INFO], | |
896 0, type, session_id, participant, local); | |
897 #endif | |
898 } | |
899 | |
900 #ifdef USE_VV | |
901 static void | |
29160
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29159
diff
changeset
|
902 purple_media_new_local_candidate_cb(PurpleMediaBackend *backend, |
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29159
diff
changeset
|
903 const gchar *sess_id, const gchar *participant, |
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29159
diff
changeset
|
904 PurpleMediaCandidate *candidate, PurpleMedia *media) |
29140 | 905 { |
29160
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29159
diff
changeset
|
906 PurpleMediaSession *session = |
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29159
diff
changeset
|
907 purple_media_get_session(media, sess_id); |
29140 | 908 |
29160
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29159
diff
changeset
|
909 purple_media_insert_local_candidate(session, participant, |
29165
cb843608e183
Store local_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29163
diff
changeset
|
910 purple_media_candidate_copy(candidate)); |
29140 | 911 |
912 g_signal_emit(session->media, purple_media_signals[NEW_CANDIDATE], | |
29160
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29159
diff
changeset
|
913 0, session->id, participant, candidate); |
29140 | 914 } |
915 | |
916 static void | |
29163
1fdc75c94c22
Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents:
29162
diff
changeset
|
917 purple_media_candidates_prepared_cb(PurpleMediaBackend *backend, |
1fdc75c94c22
Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents:
29162
diff
changeset
|
918 const gchar *sess_id, const gchar *name, PurpleMedia *media) |
29140 | 919 { |
920 PurpleMediaStream *stream_data; | |
921 | |
29163
1fdc75c94c22
Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents:
29162
diff
changeset
|
922 g_return_if_fail(PURPLE_IS_MEDIA(media)); |
29140 | 923 |
29163
1fdc75c94c22
Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents:
29162
diff
changeset
|
924 stream_data = purple_media_get_stream(media, sess_id, name); |
29140 | 925 stream_data->candidates_prepared = TRUE; |
926 | |
29163
1fdc75c94c22
Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents:
29162
diff
changeset
|
927 g_signal_emit(media, purple_media_signals[CANDIDATES_PREPARED], |
1fdc75c94c22
Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents:
29162
diff
changeset
|
928 0, sess_id, name); |
29140 | 929 } |
930 | |
931 /* callback called when a pair of transport candidates (local and remote) | |
932 * has been established */ | |
933 static void | |
29162
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
934 purple_media_candidate_pair_established_cb(PurpleMediaBackend *backend, |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
935 const gchar *sess_id, const gchar *name, |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
936 PurpleMediaCandidate *local_candidate, |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
937 PurpleMediaCandidate *remote_candidate, |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
938 PurpleMedia *media) |
29140 | 939 { |
940 PurpleMediaStream *stream; | |
941 GList *iter; | |
29162
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
942 guint id; |
29140 | 943 |
29162
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
944 g_return_if_fail(PURPLE_IS_MEDIA(media)); |
29140 | 945 |
29162
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
946 stream = purple_media_get_stream(media, sess_id, name); |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
947 id = purple_media_candidate_get_component_id(local_candidate); |
29140 | 948 |
949 iter = stream->active_local_candidates; | |
950 for(; iter; iter = g_list_next(iter)) { | |
29167
7713312c4ab0
Store active_local_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29166
diff
changeset
|
951 PurpleMediaCandidate *c = iter->data; |
7713312c4ab0
Store active_local_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29166
diff
changeset
|
952 if (id == purple_media_candidate_get_component_id(c)) { |
7713312c4ab0
Store active_local_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29166
diff
changeset
|
953 g_object_unref(c); |
29140 | 954 stream->active_local_candidates = |
955 g_list_delete_link(iter, iter); | |
956 stream->active_local_candidates = g_list_prepend( | |
957 stream->active_local_candidates, | |
29167
7713312c4ab0
Store active_local_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29166
diff
changeset
|
958 purple_media_candidate_copy( |
29162
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
959 local_candidate)); |
29140 | 960 break; |
961 } | |
962 } | |
963 if (iter == NULL) | |
964 stream->active_local_candidates = g_list_prepend( | |
965 stream->active_local_candidates, | |
29167
7713312c4ab0
Store active_local_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29166
diff
changeset
|
966 purple_media_candidate_copy( |
29162
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
967 local_candidate)); |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
968 |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
969 id = purple_media_candidate_get_component_id(local_candidate); |
29140 | 970 |
971 iter = stream->active_remote_candidates; | |
972 for(; iter; iter = g_list_next(iter)) { | |
29168
1156bf88b4d3
Store active_remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29167
diff
changeset
|
973 PurpleMediaCandidate *c = iter->data; |
1156bf88b4d3
Store active_remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29167
diff
changeset
|
974 if (id == purple_media_candidate_get_component_id(c)) { |
1156bf88b4d3
Store active_remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29167
diff
changeset
|
975 g_object_unref(c); |
29140 | 976 stream->active_remote_candidates = |
977 g_list_delete_link(iter, iter); | |
978 stream->active_remote_candidates = g_list_prepend( | |
979 stream->active_remote_candidates, | |
29168
1156bf88b4d3
Store active_remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29167
diff
changeset
|
980 purple_media_candidate_copy( |
29162
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
981 remote_candidate)); |
29140 | 982 break; |
983 } | |
984 } | |
985 if (iter == NULL) | |
986 stream->active_remote_candidates = g_list_prepend( | |
987 stream->active_remote_candidates, | |
29168
1156bf88b4d3
Store active_remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29167
diff
changeset
|
988 purple_media_candidate_copy( |
29162
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29161
diff
changeset
|
989 remote_candidate)); |
29140 | 990 |
991 purple_debug_info("media", "candidate pair established\n"); | |
992 } | |
993 | |
29161
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29160
diff
changeset
|
994 static void |
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29160
diff
changeset
|
995 purple_media_codecs_changed_cb(PurpleMediaBackend *backend, |
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29160
diff
changeset
|
996 const gchar *sess_id, PurpleMedia *media) |
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29160
diff
changeset
|
997 { |
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29160
diff
changeset
|
998 g_signal_emit(media, purple_media_signals[CODECS_CHANGED], 0, sess_id); |
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29160
diff
changeset
|
999 } |
29140 | 1000 #endif /* USE_VV */ |
1001 | |
1002 gboolean | |
1003 purple_media_add_stream(PurpleMedia *media, const gchar *sess_id, | |
1004 const gchar *who, PurpleMediaSessionType type, | |
1005 gboolean initiator, const gchar *transmitter, | |
1006 guint num_params, GParameter *params) | |
1007 { | |
1008 #ifdef USE_VV | |
1009 PurpleMediaSession *session; | |
1010 PurpleMediaStream *stream = NULL; | |
1011 | |
1012 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE); | |
1013 | |
29155
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29151
diff
changeset
|
1014 if (!purple_media_backend_add_stream(media->priv->backend, |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29151
diff
changeset
|
1015 sess_id, who, type, initiator, transmitter, |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29151
diff
changeset
|
1016 num_params, params)) { |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29151
diff
changeset
|
1017 purple_debug_error("media", "Error adding stream.\n"); |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29151
diff
changeset
|
1018 return FALSE; |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29151
diff
changeset
|
1019 } |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29151
diff
changeset
|
1020 |
29140 | 1021 session = purple_media_get_session(media, sess_id); |
1022 | |
1023 if (!session) { | |
1024 session = g_new0(PurpleMediaSession, 1); | |
1025 session->id = g_strdup(sess_id); | |
1026 session->media = media; | |
1027 session->type = type; | |
1028 session->initiator = initiator; | |
1029 | |
1030 purple_media_add_session(media, session); | |
1031 g_signal_emit(media, purple_media_signals[STATE_CHANGED], | |
1032 0, PURPLE_MEDIA_STATE_NEW, | |
1033 session->id, NULL); | |
1034 } | |
1035 | |
29208 | 1036 if (!g_list_find_custom(media->priv->participants, |
1037 who, (GCompareFunc)strcmp)) { | |
1038 media->priv->participants = g_list_prepend( | |
1039 media->priv->participants, g_strdup(who)); | |
1040 | |
1041 g_signal_emit_by_name(media, "state-changed", | |
1042 PURPLE_MEDIA_STATE_NEW, NULL, who); | |
1043 } | |
1044 | |
29185
f65689100cfe
Move odd direction changing functionality to the Fs2 media backend.
maiku@pidgin.im
parents:
29184
diff
changeset
|
1045 if (purple_media_get_stream(media, sess_id, who) == NULL) { |
29186 | 1046 stream = purple_media_insert_stream(session, who, initiator); |
29140 | 1047 |
1048 g_signal_emit(media, purple_media_signals[STATE_CHANGED], | |
1049 0, PURPLE_MEDIA_STATE_NEW, | |
1050 session->id, who); | |
1051 } | |
1052 | |
1053 return TRUE; | |
1054 #else | |
1055 return FALSE; | |
1056 #endif /* USE_VV */ | |
1057 } | |
1058 | |
1059 PurpleMediaManager * | |
1060 purple_media_get_manager(PurpleMedia *media) | |
1061 { | |
1062 PurpleMediaManager *ret; | |
1063 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
1064 g_object_get(media, "manager", &ret, NULL); | |
1065 return ret; | |
1066 } | |
1067 | |
1068 PurpleMediaSessionType | |
1069 purple_media_get_session_type(PurpleMedia *media, const gchar *sess_id) | |
1070 { | |
1071 #ifdef USE_VV | |
1072 PurpleMediaSession *session; | |
1073 g_return_val_if_fail(PURPLE_IS_MEDIA(media), PURPLE_MEDIA_NONE); | |
1074 session = purple_media_get_session(media, sess_id); | |
1075 return session->type; | |
1076 #else | |
1077 return PURPLE_MEDIA_NONE; | |
1078 #endif | |
1079 } | |
1080 /* XXX: Should wait until codecs-ready is TRUE before using this function */ | |
1081 GList * | |
1082 purple_media_get_codecs(PurpleMedia *media, const gchar *sess_id) | |
1083 { | |
1084 #ifdef USE_VV | |
1085 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
1086 | |
29175
9c1810122f21
Transfer get_codecs functionality to the Fs2 media backend.
maiku@pidgin.im
parents:
29174
diff
changeset
|
1087 return purple_media_backend_get_codecs(media->priv->backend, sess_id); |
29140 | 1088 #else |
1089 return NULL; | |
1090 #endif | |
1091 } | |
1092 | |
1093 GList * | |
1094 purple_media_get_local_candidates(PurpleMedia *media, const gchar *sess_id, | |
1095 const gchar *participant) | |
1096 { | |
1097 #ifdef USE_VV | |
1098 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
29177
f0966e90ec44
Move get_local_candidates functionality over to the Fs2 media backend.
maiku@pidgin.im
parents:
29175
diff
changeset
|
1099 |
f0966e90ec44
Move get_local_candidates functionality over to the Fs2 media backend.
maiku@pidgin.im
parents:
29175
diff
changeset
|
1100 return purple_media_backend_get_local_candidates(media->priv->backend, |
f0966e90ec44
Move get_local_candidates functionality over to the Fs2 media backend.
maiku@pidgin.im
parents:
29175
diff
changeset
|
1101 sess_id, participant); |
29140 | 1102 #else |
1103 return NULL; | |
1104 #endif | |
1105 } | |
1106 | |
1107 void | |
1108 purple_media_add_remote_candidates(PurpleMedia *media, const gchar *sess_id, | |
1109 const gchar *participant, | |
1110 GList *remote_candidates) | |
1111 { | |
1112 #ifdef USE_VV | |
1113 PurpleMediaStream *stream; | |
1114 | |
1115 g_return_if_fail(PURPLE_IS_MEDIA(media)); | |
1116 stream = purple_media_get_stream(media, sess_id, participant); | |
1117 | |
1118 if (stream == NULL) { | |
1119 purple_debug_error("media", | |
1120 "purple_media_add_remote_candidates: " | |
1121 "couldn't find stream %s %s.\n", | |
1122 sess_id ? sess_id : "(null)", | |
1123 participant ? participant : "(null)"); | |
1124 return; | |
1125 } | |
1126 | |
1127 stream->remote_candidates = g_list_concat(stream->remote_candidates, | |
29166
18571ea6e44a
Store remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29165
diff
changeset
|
1128 purple_media_candidate_list_copy(remote_candidates)); |
29140 | 1129 |
29182
a27e41f373db
Handle part of accepting a stream in the Fs2 media backend.
maiku@pidgin.im
parents:
29181
diff
changeset
|
1130 purple_media_backend_add_remote_candidates(media->priv->backend, |
a27e41f373db
Handle part of accepting a stream in the Fs2 media backend.
maiku@pidgin.im
parents:
29181
diff
changeset
|
1131 sess_id, participant, remote_candidates); |
29140 | 1132 #endif |
1133 } | |
1134 | |
1135 #if 0 | |
1136 /* | |
1137 * These two functions aren't being used and I'd rather not lock in the API | |
1138 * until they are needed. If they ever are. | |
1139 */ | |
1140 | |
1141 GList * | |
1142 purple_media_get_active_local_candidates(PurpleMedia *media, | |
1143 const gchar *sess_id, const gchar *participant) | |
1144 { | |
1145 #ifdef USE_VV | |
1146 PurpleMediaStream *stream; | |
1147 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
1148 stream = purple_media_get_stream(media, sess_id, participant); | |
29167
7713312c4ab0
Store active_local_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29166
diff
changeset
|
1149 return purple_media_candidate_list_copy( |
29140 | 1150 stream->active_local_candidates); |
1151 #else | |
1152 return NULL; | |
1153 #endif | |
1154 } | |
1155 | |
1156 GList * | |
1157 purple_media_get_active_remote_candidates(PurpleMedia *media, | |
1158 const gchar *sess_id, const gchar *participant) | |
1159 { | |
1160 #ifdef USE_VV | |
1161 PurpleMediaStream *stream; | |
1162 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
1163 stream = purple_media_get_stream(media, sess_id, participant); | |
29168
1156bf88b4d3
Store active_remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29167
diff
changeset
|
1164 return purple_media_candidate_list_copy( |
29140 | 1165 stream->active_remote_candidates); |
1166 #else | |
1167 return NULL; | |
1168 #endif | |
1169 } | |
1170 #endif | |
1171 | |
1172 gboolean | |
1173 purple_media_set_remote_codecs(PurpleMedia *media, const gchar *sess_id, | |
1174 const gchar *participant, GList *codecs) | |
1175 { | |
1176 #ifdef USE_VV | |
1177 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE); | |
1178 | |
29179
a39696686dd6
Move set_remote_codecs functionality to the Fs2 media backend.
maiku@pidgin.im
parents:
29177
diff
changeset
|
1179 return purple_media_backend_set_remote_codecs(media->priv->backend, |
a39696686dd6
Move set_remote_codecs functionality to the Fs2 media backend.
maiku@pidgin.im
parents:
29177
diff
changeset
|
1180 sess_id, participant, codecs); |
29140 | 1181 #else |
1182 return FALSE; | |
1183 #endif | |
1184 } | |
1185 | |
1186 gboolean | |
1187 purple_media_candidates_prepared(PurpleMedia *media, | |
1188 const gchar *session_id, const gchar *participant) | |
1189 { | |
1190 #ifdef USE_VV | |
1191 GList *streams; | |
1192 gboolean prepared = TRUE; | |
1193 | |
1194 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE); | |
1195 | |
1196 streams = purple_media_get_streams(media, session_id, participant); | |
1197 | |
1198 for (; streams; streams = g_list_delete_link(streams, streams)) { | |
1199 PurpleMediaStream *stream = streams->data; | |
1200 if (stream->candidates_prepared == FALSE) { | |
1201 g_list_free(streams); | |
1202 prepared = FALSE; | |
1203 break; | |
1204 } | |
1205 } | |
1206 | |
1207 return prepared; | |
1208 #else | |
1209 return FALSE; | |
1210 #endif | |
1211 } | |
1212 | |
1213 gboolean | |
1214 purple_media_set_send_codec(PurpleMedia *media, const gchar *sess_id, PurpleMediaCodec *codec) | |
1215 { | |
1216 #ifdef USE_VV | |
1217 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE); | |
1218 | |
29181
ec5ed142f551
Move set_remote_codec functionality to the Fs2 media backend.
maiku@pidgin.im
parents:
29179
diff
changeset
|
1219 return purple_media_backend_set_send_codec( |
ec5ed142f551
Move set_remote_codec functionality to the Fs2 media backend.
maiku@pidgin.im
parents:
29179
diff
changeset
|
1220 media->priv->backend, sess_id, codec); |
29140 | 1221 #else |
1222 return FALSE; | |
1223 #endif | |
1224 } | |
1225 | |
1226 gboolean | |
1227 purple_media_codecs_ready(PurpleMedia *media, const gchar *sess_id) | |
1228 { | |
1229 #ifdef USE_VV | |
1230 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE); | |
1231 | |
29187
f351e87b7af0
Add codecs_ready to the media backend interface.
maiku@pidgin.im
parents:
29186
diff
changeset
|
1232 return purple_media_backend_codecs_ready( |
f351e87b7af0
Add codecs_ready to the media backend interface.
maiku@pidgin.im
parents:
29186
diff
changeset
|
1233 media->priv->backend, sess_id); |
29140 | 1234 #else |
1235 return FALSE; | |
1236 #endif | |
1237 } | |
1238 | |
1239 gboolean | |
1240 purple_media_is_initiator(PurpleMedia *media, | |
1241 const gchar *sess_id, const gchar *participant) | |
1242 { | |
1243 #ifdef USE_VV | |
1244 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE); | |
1245 | |
1246 if (sess_id == NULL && participant == NULL) | |
1247 return media->priv->initiator; | |
1248 else if (sess_id != NULL && participant == NULL) { | |
1249 PurpleMediaSession *session = | |
1250 purple_media_get_session(media, sess_id); | |
1251 return session != NULL ? session->initiator : FALSE; | |
1252 } else if (sess_id != NULL && participant != NULL) { | |
1253 PurpleMediaStream *stream = purple_media_get_stream( | |
1254 media, sess_id, participant); | |
1255 return stream != NULL ? stream->initiator : FALSE; | |
1256 } | |
1257 #endif | |
1258 return FALSE; | |
1259 } | |
1260 | |
1261 gboolean | |
1262 purple_media_accepted(PurpleMedia *media, const gchar *sess_id, | |
1263 const gchar *participant) | |
1264 { | |
1265 #ifdef USE_VV | |
1266 gboolean accepted = TRUE; | |
1267 | |
1268 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE); | |
1269 | |
1270 if (sess_id == NULL && participant == NULL) { | |
1271 GList *streams = media->priv->streams; | |
1272 | |
1273 for (; streams; streams = g_list_next(streams)) { | |
1274 PurpleMediaStream *stream = streams->data; | |
1275 if (stream->accepted == FALSE) { | |
1276 accepted = FALSE; | |
1277 break; | |
1278 } | |
1279 } | |
1280 } else if (sess_id != NULL && participant == NULL) { | |
1281 GList *streams = purple_media_get_streams( | |
1282 media, sess_id, NULL); | |
1283 for (; streams; streams = | |
1284 g_list_delete_link(streams, streams)) { | |
1285 PurpleMediaStream *stream = streams->data; | |
1286 if (stream->accepted == FALSE) { | |
1287 g_list_free(streams); | |
1288 accepted = FALSE; | |
1289 break; | |
1290 } | |
1291 } | |
1292 } else if (sess_id != NULL && participant != NULL) { | |
1293 PurpleMediaStream *stream = purple_media_get_stream( | |
1294 media, sess_id, participant); | |
1295 if (stream == NULL || stream->accepted == FALSE) | |
1296 accepted = FALSE; | |
1297 } | |
1298 | |
1299 return accepted; | |
1300 #else | |
1301 return FALSE; | |
1302 #endif | |
1303 } | |
1304 | |
1305 void purple_media_set_input_volume(PurpleMedia *media, | |
1306 const gchar *session_id, double level) | |
1307 { | |
1308 #ifdef USE_VV | |
1309 g_return_if_fail(PURPLE_IS_MEDIA(media)); | |
29191
95f918df7f09
Move volume setting functionality to the Fs2 media backend.
maiku@pidgin.im
parents:
29190
diff
changeset
|
1310 g_return_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(media->priv->backend)); |
29140 | 1311 |
29191
95f918df7f09
Move volume setting functionality to the Fs2 media backend.
maiku@pidgin.im
parents:
29190
diff
changeset
|
1312 purple_media_backend_fs2_set_input_volume( |
95f918df7f09
Move volume setting functionality to the Fs2 media backend.
maiku@pidgin.im
parents:
29190
diff
changeset
|
1313 PURPLE_MEDIA_BACKEND_FS2( |
95f918df7f09
Move volume setting functionality to the Fs2 media backend.
maiku@pidgin.im
parents:
29190
diff
changeset
|
1314 media->priv->backend), |
95f918df7f09
Move volume setting functionality to the Fs2 media backend.
maiku@pidgin.im
parents:
29190
diff
changeset
|
1315 session_id, level); |
29140 | 1316 #endif |
1317 } | |
1318 | |
1319 void purple_media_set_output_volume(PurpleMedia *media, | |
1320 const gchar *session_id, const gchar *participant, | |
1321 double level) | |
1322 { | |
1323 #ifdef USE_VV | |
1324 g_return_if_fail(PURPLE_IS_MEDIA(media)); | |
29191
95f918df7f09
Move volume setting functionality to the Fs2 media backend.
maiku@pidgin.im
parents:
29190
diff
changeset
|
1325 g_return_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(media->priv->backend)); |
29140 | 1326 |
29191
95f918df7f09
Move volume setting functionality to the Fs2 media backend.
maiku@pidgin.im
parents:
29190
diff
changeset
|
1327 purple_media_backend_fs2_set_output_volume( |
95f918df7f09
Move volume setting functionality to the Fs2 media backend.
maiku@pidgin.im
parents:
29190
diff
changeset
|
1328 PURPLE_MEDIA_BACKEND_FS2( |
95f918df7f09
Move volume setting functionality to the Fs2 media backend.
maiku@pidgin.im
parents:
29190
diff
changeset
|
1329 media->priv->backend), |
95f918df7f09
Move volume setting functionality to the Fs2 media backend.
maiku@pidgin.im
parents:
29190
diff
changeset
|
1330 session_id, participant, level); |
29140 | 1331 #endif |
1332 } | |
1333 | |
1334 gulong | |
1335 purple_media_set_output_window(PurpleMedia *media, const gchar *session_id, | |
1336 const gchar *participant, gulong window_id) | |
1337 { | |
1338 #ifdef USE_VV | |
1339 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE); | |
1340 | |
1341 return purple_media_manager_set_output_window(media->priv->manager, | |
1342 media, session_id, participant, window_id); | |
1343 #else | |
1344 return 0; | |
1345 #endif | |
1346 } | |
1347 | |
1348 void | |
1349 purple_media_remove_output_windows(PurpleMedia *media) | |
1350 { | |
1351 #ifdef USE_VV | |
1352 GList *iter = media->priv->streams; | |
1353 for (; iter; iter = g_list_next(iter)) { | |
1354 PurpleMediaStream *stream = iter->data; | |
1355 purple_media_manager_remove_output_windows( | |
1356 media->priv->manager, media, | |
1357 stream->session->id, stream->participant); | |
1358 } | |
1359 | |
1360 iter = purple_media_get_session_ids(media); | |
1361 for (; iter; iter = g_list_delete_link(iter, iter)) { | |
1362 gchar *session_name = iter->data; | |
1363 purple_media_manager_remove_output_windows( | |
1364 media->priv->manager, media, | |
1365 session_name, NULL); | |
1366 } | |
1367 #endif | |
1368 } | |
1369 | |
1370 #ifdef USE_GSTREAMER | |
1371 GstElement * | |
1372 purple_media_get_tee(PurpleMedia *media, | |
1373 const gchar *session_id, const gchar *participant) | |
1374 { | |
1375 #ifdef USE_VV | |
1376 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
1377 | |
29189
eadb9e309b87
Move all src and sink creation in PurpleMedia to the Fs2 media backend.
maiku@pidgin.im
parents:
29188
diff
changeset
|
1378 if (PURPLE_IS_MEDIA_BACKEND_FS2(media->priv->backend)) |
eadb9e309b87
Move all src and sink creation in PurpleMedia to the Fs2 media backend.
maiku@pidgin.im
parents:
29188
diff
changeset
|
1379 return purple_media_backend_fs2_get_tee( |
eadb9e309b87
Move all src and sink creation in PurpleMedia to the Fs2 media backend.
maiku@pidgin.im
parents:
29188
diff
changeset
|
1380 PURPLE_MEDIA_BACKEND_FS2( |
eadb9e309b87
Move all src and sink creation in PurpleMedia to the Fs2 media backend.
maiku@pidgin.im
parents:
29188
diff
changeset
|
1381 media->priv->backend), |
29140 | 1382 session_id, participant); |
1383 g_return_val_if_reached(NULL); | |
1384 #else | |
1385 return NULL; | |
1386 #endif | |
1387 } | |
1388 #endif /* USE_GSTREAMER */ | |
1389 |