Mercurial > pidgin.yaz
annotate libpurple/media/media.c @ 29576:a27e41f373db
Handle part of accepting a stream in the Fs2 media backend.
author | maiku@pidgin.im |
---|---|
date | Tue, 27 Oct 2009 00:13:39 +0000 |
parents | ec5ed142f551 |
children | 3bab2237724d |
rev | line source |
---|---|
29534 | 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 <string.h> | |
28 | |
29 #include "internal.h" | |
30 | |
31 #include "account.h" | |
32 #include "media.h" | |
29549
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
33 #include "media/backend-fs2.h" |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
34 #include "media/backend-iface.h" |
29534 | 35 #include "mediamanager.h" |
36 #include "network.h" | |
37 | |
38 #include "debug.h" | |
39 | |
40 #ifdef USE_GSTREAMER | |
41 #include "marshallers.h" | |
42 #include "media-gst.h" | |
43 #endif | |
44 | |
45 #ifdef USE_VV | |
46 | |
47 #include <gst/farsight/fs-conference-iface.h> | |
48 #include <gst/farsight/fs-element-added-notifier.h> | |
49 | |
50 /** @copydoc _PurpleMediaSession */ | |
51 typedef struct _PurpleMediaSession PurpleMediaSession; | |
52 /** @copydoc _PurpleMediaStream */ | |
53 typedef struct _PurpleMediaStream PurpleMediaStream; | |
54 /** @copydoc _PurpleMediaClass */ | |
55 typedef struct _PurpleMediaClass PurpleMediaClass; | |
56 /** @copydoc _PurpleMediaPrivate */ | |
57 typedef struct _PurpleMediaPrivate PurpleMediaPrivate; | |
58 | |
59 /** The media class */ | |
60 struct _PurpleMediaClass | |
61 { | |
62 GObjectClass parent_class; /**< The parent class. */ | |
63 }; | |
64 | |
65 /** The media class's private data */ | |
66 struct _PurpleMedia | |
67 { | |
68 GObject parent; /**< The parent of this object. */ | |
69 PurpleMediaPrivate *priv; /**< The private data of this object. */ | |
70 }; | |
71 | |
72 struct _PurpleMediaSession | |
73 { | |
74 gchar *id; | |
75 PurpleMedia *media; | |
76 GstElement *src; | |
77 GstElement *tee; | |
78 FsSession *session; | |
79 | |
80 PurpleMediaSessionType type; | |
81 gboolean initiator; | |
82 }; | |
83 | |
84 struct _PurpleMediaStream | |
85 { | |
86 PurpleMediaSession *session; | |
87 gchar *participant; | |
88 FsStream *stream; | |
89 GstElement *src; | |
90 GstElement *tee; | |
91 GstElement *volume; | |
92 GstElement *level; | |
93 | |
94 GList *local_candidates; | |
95 GList *remote_candidates; | |
96 | |
97 gboolean initiator; | |
98 gboolean accepted; | |
99 gboolean candidates_prepared; | |
100 | |
101 GList *active_local_candidates; | |
102 GList *active_remote_candidates; | |
103 | |
104 guint connected_cb_id; | |
105 }; | |
106 #endif | |
107 | |
108 struct _PurpleMediaPrivate | |
109 { | |
110 #ifdef USE_VV | |
111 PurpleMediaManager *manager; | |
112 PurpleAccount *account; | |
29549
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
113 PurpleMediaBackend *backend; |
29534 | 114 FsConference *conference; |
29545
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29538
diff
changeset
|
115 gchar *conference_type; |
29551
e85df0170905
Decouple the media_bus_call from the backend. It will still be needed even
maiku@pidgin.im
parents:
29550
diff
changeset
|
116 gulong gst_bus_handler_id; |
29534 | 117 gboolean initiator; |
118 gpointer prpl_data; | |
119 | |
120 GHashTable *sessions; /* PurpleMediaSession table */ | |
121 | |
122 GList *streams; /* PurpleMediaStream table */ | |
123 | |
124 GstElement *confbin; | |
125 #else | |
126 gpointer dummy; | |
127 #endif | |
128 }; | |
129 | |
130 #ifdef USE_VV | |
131 #define PURPLE_MEDIA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_MEDIA, PurpleMediaPrivate)) | |
132 | |
133 static void purple_media_class_init (PurpleMediaClass *klass); | |
134 static void purple_media_init (PurpleMedia *media); | |
135 static void purple_media_dispose (GObject *object); | |
136 static void purple_media_finalize (GObject *object); | |
137 static void purple_media_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); | |
138 static void purple_media_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); | |
139 | |
29554
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29553
diff
changeset
|
140 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:
29553
diff
changeset
|
141 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:
29553
diff
changeset
|
142 PurpleMediaCandidate *candidate, PurpleMedia *media); |
29557
1fdc75c94c22
Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents:
29556
diff
changeset
|
143 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:
29556
diff
changeset
|
144 const gchar *sess_id, const gchar *name, PurpleMedia *media); |
29556
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29555
diff
changeset
|
145 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:
29555
diff
changeset
|
146 PurpleMediaBackend *backend, |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29555
diff
changeset
|
147 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:
29555
diff
changeset
|
148 PurpleMediaCandidate *local_candidate, |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29555
diff
changeset
|
149 PurpleMediaCandidate *remote_candidate, |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29555
diff
changeset
|
150 PurpleMedia *media); |
29555
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29554
diff
changeset
|
151 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:
29554
diff
changeset
|
152 const gchar *sess_id, PurpleMedia *media); |
29534 | 153 static gboolean media_bus_call(GstBus *bus, |
154 GstMessage *msg, PurpleMedia *media); | |
155 | |
156 static GObjectClass *parent_class = NULL; | |
157 | |
158 | |
159 | |
160 enum { | |
161 S_ERROR, | |
162 CANDIDATES_PREPARED, | |
163 CODECS_CHANGED, | |
164 LEVEL, | |
165 NEW_CANDIDATE, | |
166 STATE_CHANGED, | |
167 STREAM_INFO, | |
168 LAST_SIGNAL | |
169 }; | |
170 static guint purple_media_signals[LAST_SIGNAL] = {0}; | |
171 | |
172 enum { | |
173 PROP_0, | |
174 PROP_MANAGER, | |
175 PROP_ACCOUNT, | |
29550
846a475a1573
Deprecate the conference property of PurpleMedia.
maiku@pidgin.im
parents:
29549
diff
changeset
|
176 #ifndef PURPLE_DISABLE_DEPRECATED |
29534 | 177 PROP_CONFERENCE, |
29550
846a475a1573
Deprecate the conference property of PurpleMedia.
maiku@pidgin.im
parents:
29549
diff
changeset
|
178 #endif |
29545
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29538
diff
changeset
|
179 PROP_CONFERENCE_TYPE, |
29534 | 180 PROP_INITIATOR, |
181 PROP_PRPL_DATA, | |
182 }; | |
183 #endif | |
184 | |
185 | |
186 GType | |
187 purple_media_get_type() | |
188 { | |
189 #ifdef USE_VV | |
190 static GType type = 0; | |
191 | |
192 if (type == 0) { | |
193 static const GTypeInfo info = { | |
194 sizeof(PurpleMediaClass), | |
195 NULL, | |
196 NULL, | |
197 (GClassInitFunc) purple_media_class_init, | |
198 NULL, | |
199 NULL, | |
200 sizeof(PurpleMedia), | |
201 0, | |
202 (GInstanceInitFunc) purple_media_init, | |
203 NULL | |
204 }; | |
205 type = g_type_register_static(G_TYPE_OBJECT, "PurpleMedia", &info, 0); | |
206 } | |
207 return type; | |
208 #else | |
209 return G_TYPE_NONE; | |
210 #endif | |
211 } | |
212 | |
213 #ifdef USE_VV | |
214 static void | |
215 purple_media_class_init (PurpleMediaClass *klass) | |
216 { | |
217 GObjectClass *gobject_class = (GObjectClass*)klass; | |
218 parent_class = g_type_class_peek_parent(klass); | |
219 | |
220 gobject_class->dispose = purple_media_dispose; | |
221 gobject_class->finalize = purple_media_finalize; | |
222 gobject_class->set_property = purple_media_set_property; | |
223 gobject_class->get_property = purple_media_get_property; | |
224 | |
225 g_object_class_install_property(gobject_class, PROP_MANAGER, | |
226 g_param_spec_object("manager", | |
227 "Purple Media Manager", | |
228 "The media manager that contains this media session.", | |
229 PURPLE_TYPE_MEDIA_MANAGER, | |
230 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); | |
231 | |
232 g_object_class_install_property(gobject_class, PROP_ACCOUNT, | |
233 g_param_spec_pointer("account", | |
234 "PurpleAccount", | |
235 "The account this media session is on.", | |
236 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); | |
237 | |
29550
846a475a1573
Deprecate the conference property of PurpleMedia.
maiku@pidgin.im
parents:
29549
diff
changeset
|
238 #ifndef PURPLE_DISABLE_DEPRECATED |
29534 | 239 g_object_class_install_property(gobject_class, PROP_CONFERENCE, |
240 g_param_spec_object("conference", | |
241 "Farsight conference", | |
242 "The FsConference associated with this media.", | |
243 FS_TYPE_CONFERENCE, | |
244 G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE)); | |
29550
846a475a1573
Deprecate the conference property of PurpleMedia.
maiku@pidgin.im
parents:
29549
diff
changeset
|
245 #endif |
29534 | 246 |
29545
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29538
diff
changeset
|
247 g_object_class_install_property(gobject_class, PROP_CONFERENCE_TYPE, |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29538
diff
changeset
|
248 g_param_spec_string("conference-type", |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29538
diff
changeset
|
249 "Conference Type", |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29538
diff
changeset
|
250 "The type of conference that this media object " |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29538
diff
changeset
|
251 "has been created to provide.", |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29538
diff
changeset
|
252 NULL, |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29538
diff
changeset
|
253 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29538
diff
changeset
|
254 |
29534 | 255 g_object_class_install_property(gobject_class, PROP_INITIATOR, |
256 g_param_spec_boolean("initiator", | |
257 "initiator", | |
258 "If the local user initiated the conference.", | |
259 FALSE, | |
260 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); | |
261 | |
262 g_object_class_install_property(gobject_class, PROP_PRPL_DATA, | |
263 g_param_spec_pointer("prpl-data", | |
264 "gpointer", | |
265 "Data the prpl plugin set on the media session.", | |
266 G_PARAM_READWRITE)); | |
267 | |
268 purple_media_signals[S_ERROR] = g_signal_new("error", G_TYPE_FROM_CLASS(klass), | |
269 G_SIGNAL_RUN_LAST, 0, NULL, NULL, | |
270 g_cclosure_marshal_VOID__STRING, | |
271 G_TYPE_NONE, 1, G_TYPE_STRING); | |
272 purple_media_signals[CANDIDATES_PREPARED] = g_signal_new("candidates-prepared", G_TYPE_FROM_CLASS(klass), | |
273 G_SIGNAL_RUN_LAST, 0, NULL, NULL, | |
274 purple_smarshal_VOID__STRING_STRING, | |
275 G_TYPE_NONE, 2, G_TYPE_STRING, | |
276 G_TYPE_STRING); | |
277 purple_media_signals[CODECS_CHANGED] = g_signal_new("codecs-changed", G_TYPE_FROM_CLASS(klass), | |
278 G_SIGNAL_RUN_LAST, 0, NULL, NULL, | |
279 g_cclosure_marshal_VOID__STRING, | |
280 G_TYPE_NONE, 1, G_TYPE_STRING); | |
281 purple_media_signals[LEVEL] = g_signal_new("level", G_TYPE_FROM_CLASS(klass), | |
282 G_SIGNAL_RUN_LAST, 0, NULL, NULL, | |
283 purple_smarshal_VOID__STRING_STRING_DOUBLE, | |
284 G_TYPE_NONE, 3, G_TYPE_STRING, | |
285 G_TYPE_STRING, G_TYPE_DOUBLE); | |
286 purple_media_signals[NEW_CANDIDATE] = g_signal_new("new-candidate", G_TYPE_FROM_CLASS(klass), | |
287 G_SIGNAL_RUN_LAST, 0, NULL, NULL, | |
288 purple_smarshal_VOID__POINTER_POINTER_OBJECT, | |
289 G_TYPE_NONE, 3, G_TYPE_POINTER, | |
290 G_TYPE_POINTER, PURPLE_TYPE_MEDIA_CANDIDATE); | |
291 purple_media_signals[STATE_CHANGED] = g_signal_new("state-changed", G_TYPE_FROM_CLASS(klass), | |
292 G_SIGNAL_RUN_LAST, 0, NULL, NULL, | |
293 purple_smarshal_VOID__ENUM_STRING_STRING, | |
294 G_TYPE_NONE, 3, PURPLE_MEDIA_TYPE_STATE, | |
295 G_TYPE_STRING, G_TYPE_STRING); | |
296 purple_media_signals[STREAM_INFO] = g_signal_new("stream-info", G_TYPE_FROM_CLASS(klass), | |
297 G_SIGNAL_RUN_LAST, 0, NULL, NULL, | |
298 purple_smarshal_VOID__ENUM_STRING_STRING_BOOLEAN, | |
299 G_TYPE_NONE, 4, PURPLE_MEDIA_TYPE_INFO_TYPE, | |
300 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN); | |
301 g_type_class_add_private(klass, sizeof(PurpleMediaPrivate)); | |
302 } | |
303 | |
304 | |
305 static void | |
306 purple_media_init (PurpleMedia *media) | |
307 { | |
308 media->priv = PURPLE_MEDIA_GET_PRIVATE(media); | |
309 memset(media->priv, 0, sizeof(*media->priv)); | |
310 } | |
311 | |
312 static void | |
313 purple_media_stream_free(PurpleMediaStream *stream) | |
314 { | |
315 if (stream == NULL) | |
316 return; | |
317 | |
318 /* Remove the connected_cb timeout */ | |
319 if (stream->connected_cb_id != 0) | |
320 purple_timeout_remove(stream->connected_cb_id); | |
321 | |
322 g_free(stream->participant); | |
323 | |
324 if (stream->local_candidates) | |
29559
cb843608e183
Store local_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29557
diff
changeset
|
325 purple_media_candidate_list_free(stream->local_candidates); |
29534 | 326 if (stream->remote_candidates) |
29560
18571ea6e44a
Store remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29559
diff
changeset
|
327 purple_media_candidate_list_free(stream->remote_candidates); |
29534 | 328 |
329 if (stream->active_local_candidates) | |
29561
7713312c4ab0
Store active_local_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29560
diff
changeset
|
330 purple_media_candidate_list_free( |
7713312c4ab0
Store active_local_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29560
diff
changeset
|
331 stream->active_local_candidates); |
29534 | 332 if (stream->active_remote_candidates) |
29562
1156bf88b4d3
Store active_remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29561
diff
changeset
|
333 purple_media_candidate_list_free( |
1156bf88b4d3
Store active_remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29561
diff
changeset
|
334 stream->active_remote_candidates); |
29534 | 335 |
336 g_free(stream); | |
337 } | |
338 | |
339 static void | |
340 purple_media_session_free(PurpleMediaSession *session) | |
341 { | |
342 if (session == NULL) | |
343 return; | |
344 | |
345 g_free(session->id); | |
346 g_free(session); | |
347 } | |
348 | |
349 static void | |
350 purple_media_dispose(GObject *media) | |
351 { | |
352 PurpleMediaPrivate *priv = PURPLE_MEDIA_GET_PRIVATE(media); | |
353 GList *iter = NULL; | |
354 | |
355 purple_debug_info("media","purple_media_dispose\n"); | |
356 | |
357 purple_media_manager_remove_media(priv->manager, PURPLE_MEDIA(media)); | |
358 | |
29549
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
359 if (priv->backend) { |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
360 g_object_unref(priv->backend); |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
361 priv->backend = NULL; |
29534 | 362 } |
363 | |
364 for (iter = priv->streams; iter; iter = g_list_next(iter)) { | |
365 PurpleMediaStream *stream = iter->data; | |
366 if (stream->stream) { | |
367 g_object_unref(stream->stream); | |
368 stream->stream = NULL; | |
369 } | |
370 } | |
371 | |
29551
e85df0170905
Decouple the media_bus_call from the backend. It will still be needed even
maiku@pidgin.im
parents:
29550
diff
changeset
|
372 if (priv->gst_bus_handler_id != 0) { |
29534 | 373 GstElement *pipeline = purple_media_manager_get_pipeline( |
374 priv->manager); | |
375 GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline)); | |
29551
e85df0170905
Decouple the media_bus_call from the backend. It will still be needed even
maiku@pidgin.im
parents:
29550
diff
changeset
|
376 g_signal_handler_disconnect(bus, priv->gst_bus_handler_id); |
29534 | 377 gst_object_unref(bus); |
29551
e85df0170905
Decouple the media_bus_call from the backend. It will still be needed even
maiku@pidgin.im
parents:
29550
diff
changeset
|
378 priv->gst_bus_handler_id = 0; |
e85df0170905
Decouple the media_bus_call from the backend. It will still be needed even
maiku@pidgin.im
parents:
29550
diff
changeset
|
379 } |
29534 | 380 |
29551
e85df0170905
Decouple the media_bus_call from the backend. It will still be needed even
maiku@pidgin.im
parents:
29550
diff
changeset
|
381 if (priv->manager) { |
29534 | 382 g_object_unref(priv->manager); |
383 priv->manager = NULL; | |
384 } | |
385 | |
386 G_OBJECT_CLASS(parent_class)->dispose(media); | |
387 } | |
388 | |
389 static void | |
390 purple_media_finalize(GObject *media) | |
391 { | |
392 PurpleMediaPrivate *priv = PURPLE_MEDIA_GET_PRIVATE(media); | |
393 purple_debug_info("media","purple_media_finalize\n"); | |
394 | |
395 for (; priv->streams; priv->streams = g_list_delete_link(priv->streams, priv->streams)) | |
396 purple_media_stream_free(priv->streams->data); | |
397 | |
398 if (priv->sessions) { | |
399 GList *sessions = g_hash_table_get_values(priv->sessions); | |
400 for (; sessions; sessions = g_list_delete_link(sessions, sessions)) { | |
401 purple_media_session_free(sessions->data); | |
402 } | |
403 g_hash_table_destroy(priv->sessions); | |
404 } | |
405 | |
406 G_OBJECT_CLASS(parent_class)->finalize(media); | |
407 } | |
408 | |
409 static void | |
410 purple_media_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) | |
411 { | |
412 PurpleMedia *media; | |
413 g_return_if_fail(PURPLE_IS_MEDIA(object)); | |
414 | |
415 media = PURPLE_MEDIA(object); | |
416 | |
417 switch (prop_id) { | |
418 case PROP_MANAGER: | |
29549
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
419 media->priv->manager = g_value_dup_object(value); |
29534 | 420 break; |
421 case PROP_ACCOUNT: | |
422 media->priv->account = g_value_get_pointer(value); | |
423 break; | |
29550
846a475a1573
Deprecate the conference property of PurpleMedia.
maiku@pidgin.im
parents:
29549
diff
changeset
|
424 #ifndef PURPLE_DISABLE_DEPRECATED |
29534 | 425 case PROP_CONFERENCE: { |
426 if (media->priv->conference) | |
427 gst_object_unref(media->priv->conference); | |
29549
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
428 media->priv->conference = g_value_dup_object(value); |
29534 | 429 break; |
430 } | |
29550
846a475a1573
Deprecate the conference property of PurpleMedia.
maiku@pidgin.im
parents:
29549
diff
changeset
|
431 #endif |
29545
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29538
diff
changeset
|
432 case PROP_CONFERENCE_TYPE: |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29538
diff
changeset
|
433 media->priv->conference_type = |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29538
diff
changeset
|
434 g_value_dup_string(value); |
29549
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
435 /* Will eventually get this type from the media manager */ |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
436 media->priv->backend = g_object_new( |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
437 PURPLE_TYPE_MEDIA_BACKEND_FS2, |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
438 "conference-type", |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
439 media->priv->conference_type, |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
440 "media", media, |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
441 NULL); |
29554
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29553
diff
changeset
|
442 g_signal_connect(media->priv->backend, |
29556
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29555
diff
changeset
|
443 "active-candidate-pair", |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29555
diff
changeset
|
444 G_CALLBACK( |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29555
diff
changeset
|
445 purple_media_candidate_pair_established_cb), |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29555
diff
changeset
|
446 media); |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29555
diff
changeset
|
447 g_signal_connect(media->priv->backend, |
29557
1fdc75c94c22
Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents:
29556
diff
changeset
|
448 "candidates-prepared", |
1fdc75c94c22
Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents:
29556
diff
changeset
|
449 G_CALLBACK( |
1fdc75c94c22
Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents:
29556
diff
changeset
|
450 purple_media_candidates_prepared_cb), |
1fdc75c94c22
Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents:
29556
diff
changeset
|
451 media); |
1fdc75c94c22
Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents:
29556
diff
changeset
|
452 g_signal_connect(media->priv->backend, |
29555
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29554
diff
changeset
|
453 "codecs-changed", |
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29554
diff
changeset
|
454 G_CALLBACK( |
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29554
diff
changeset
|
455 purple_media_codecs_changed_cb), |
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29554
diff
changeset
|
456 media); |
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29554
diff
changeset
|
457 g_signal_connect(media->priv->backend, |
29554
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29553
diff
changeset
|
458 "new-candidate", |
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29553
diff
changeset
|
459 G_CALLBACK( |
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29553
diff
changeset
|
460 purple_media_new_local_candidate_cb), |
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29553
diff
changeset
|
461 media); |
29545
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29538
diff
changeset
|
462 break; |
29534 | 463 case PROP_INITIATOR: |
464 media->priv->initiator = g_value_get_boolean(value); | |
465 break; | |
466 case PROP_PRPL_DATA: | |
467 media->priv->prpl_data = g_value_get_pointer(value); | |
468 break; | |
469 default: | |
470 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | |
471 break; | |
472 } | |
473 } | |
474 | |
475 static void | |
476 purple_media_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) | |
477 { | |
478 PurpleMedia *media; | |
479 g_return_if_fail(PURPLE_IS_MEDIA(object)); | |
480 | |
481 media = PURPLE_MEDIA(object); | |
482 | |
483 switch (prop_id) { | |
484 case PROP_MANAGER: | |
485 g_value_set_object(value, media->priv->manager); | |
486 break; | |
487 case PROP_ACCOUNT: | |
488 g_value_set_pointer(value, media->priv->account); | |
489 break; | |
29550
846a475a1573
Deprecate the conference property of PurpleMedia.
maiku@pidgin.im
parents:
29549
diff
changeset
|
490 #ifndef PURPLE_DISABLE_DEPRECATED |
29534 | 491 case PROP_CONFERENCE: |
492 g_value_set_object(value, media->priv->conference); | |
493 break; | |
29550
846a475a1573
Deprecate the conference property of PurpleMedia.
maiku@pidgin.im
parents:
29549
diff
changeset
|
494 #endif |
29545
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29538
diff
changeset
|
495 case PROP_CONFERENCE_TYPE: |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29538
diff
changeset
|
496 g_value_set_string(value, |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29538
diff
changeset
|
497 media->priv->conference_type); |
30e8ab2a4bc2
Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents:
29538
diff
changeset
|
498 break; |
29534 | 499 case PROP_INITIATOR: |
500 g_value_set_boolean(value, media->priv->initiator); | |
501 break; | |
502 case PROP_PRPL_DATA: | |
503 g_value_set_pointer(value, media->priv->prpl_data); | |
504 break; | |
505 default: | |
506 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | |
507 break; | |
508 } | |
509 | |
510 } | |
511 | |
512 static FsMediaType | |
513 purple_media_to_fs_media_type(PurpleMediaSessionType type) | |
514 { | |
515 if (type & PURPLE_MEDIA_AUDIO) | |
516 return FS_MEDIA_TYPE_AUDIO; | |
517 else if (type & PURPLE_MEDIA_VIDEO) | |
518 return FS_MEDIA_TYPE_VIDEO; | |
519 else | |
520 return 0; | |
521 } | |
522 | |
523 static FsStreamDirection | |
524 purple_media_to_fs_stream_direction(PurpleMediaSessionType type) | |
525 { | |
526 if ((type & PURPLE_MEDIA_AUDIO) == PURPLE_MEDIA_AUDIO || | |
527 (type & PURPLE_MEDIA_VIDEO) == PURPLE_MEDIA_VIDEO) | |
528 return FS_DIRECTION_BOTH; | |
529 else if ((type & PURPLE_MEDIA_SEND_AUDIO) || | |
530 (type & PURPLE_MEDIA_SEND_VIDEO)) | |
531 return FS_DIRECTION_SEND; | |
532 else if ((type & PURPLE_MEDIA_RECV_AUDIO) || | |
533 (type & PURPLE_MEDIA_RECV_VIDEO)) | |
534 return FS_DIRECTION_RECV; | |
535 else | |
536 return FS_DIRECTION_NONE; | |
537 } | |
538 | |
539 static PurpleMediaSessionType | |
540 purple_media_from_fs(FsMediaType type, FsStreamDirection direction) | |
541 { | |
542 PurpleMediaSessionType result = PURPLE_MEDIA_NONE; | |
543 if (type == FS_MEDIA_TYPE_AUDIO) { | |
544 if (direction & FS_DIRECTION_SEND) | |
545 result |= PURPLE_MEDIA_SEND_AUDIO; | |
546 if (direction & FS_DIRECTION_RECV) | |
547 result |= PURPLE_MEDIA_RECV_AUDIO; | |
548 } else if (type == FS_MEDIA_TYPE_VIDEO) { | |
549 if (direction & FS_DIRECTION_SEND) | |
550 result |= PURPLE_MEDIA_SEND_VIDEO; | |
551 if (direction & FS_DIRECTION_RECV) | |
552 result |= PURPLE_MEDIA_RECV_VIDEO; | |
553 } | |
554 return result; | |
555 } | |
556 | |
557 static PurpleMediaSession* | |
558 purple_media_get_session(PurpleMedia *media, const gchar *sess_id) | |
559 { | |
560 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
561 return (PurpleMediaSession*) (media->priv->sessions) ? | |
562 g_hash_table_lookup(media->priv->sessions, sess_id) : NULL; | |
563 } | |
564 | |
565 static PurpleMediaStream* | |
566 purple_media_get_stream(PurpleMedia *media, const gchar *session, const gchar *participant) | |
567 { | |
568 GList *streams; | |
569 | |
570 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
571 | |
572 streams = media->priv->streams; | |
573 | |
574 for (; streams; streams = g_list_next(streams)) { | |
575 PurpleMediaStream *stream = streams->data; | |
576 if (!strcmp(stream->session->id, session) && | |
577 !strcmp(stream->participant, participant)) | |
578 return stream; | |
579 } | |
580 | |
581 return NULL; | |
582 } | |
583 | |
584 static GList * | |
585 purple_media_get_streams(PurpleMedia *media, const gchar *session, | |
586 const gchar *participant) | |
587 { | |
588 GList *streams; | |
589 GList *ret = NULL; | |
590 | |
591 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
592 | |
593 streams = media->priv->streams; | |
594 | |
595 for (; streams; streams = g_list_next(streams)) { | |
596 PurpleMediaStream *stream = streams->data; | |
597 if ((session == NULL || | |
598 !strcmp(stream->session->id, session)) && | |
599 (participant == NULL || | |
600 !strcmp(stream->participant, participant))) | |
601 ret = g_list_append(ret, stream); | |
602 } | |
603 | |
604 return ret; | |
605 } | |
606 | |
607 static void | |
608 purple_media_add_session(PurpleMedia *media, PurpleMediaSession *session) | |
609 { | |
610 g_return_if_fail(PURPLE_IS_MEDIA(media)); | |
611 g_return_if_fail(session != NULL); | |
612 | |
613 if (!media->priv->sessions) { | |
614 purple_debug_info("media", "Creating hash table for sessions\n"); | |
615 media->priv->sessions = g_hash_table_new(g_str_hash, g_str_equal); | |
616 } | |
617 g_hash_table_insert(media->priv->sessions, g_strdup(session->id), session); | |
618 } | |
619 | |
29568 | 620 #if 0 |
29534 | 621 static gboolean |
622 purple_media_remove_session(PurpleMedia *media, PurpleMediaSession *session) | |
623 { | |
624 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE); | |
625 return g_hash_table_remove(media->priv->sessions, session->id); | |
626 } | |
29568 | 627 #endif |
29534 | 628 |
629 static PurpleMediaStream * | |
630 purple_media_insert_stream(PurpleMediaSession *session, const gchar *name, FsStream *stream) | |
631 { | |
632 PurpleMediaStream *media_stream; | |
633 | |
634 g_return_val_if_fail(session != NULL, NULL); | |
635 | |
636 media_stream = g_new0(PurpleMediaStream, 1); | |
637 media_stream->stream = stream; | |
638 media_stream->participant = g_strdup(name); | |
639 media_stream->session = session; | |
640 | |
641 session->media->priv->streams = | |
642 g_list_append(session->media->priv->streams, media_stream); | |
643 | |
644 return media_stream; | |
645 } | |
646 | |
647 static void | |
648 purple_media_insert_local_candidate(PurpleMediaSession *session, const gchar *name, | |
29559
cb843608e183
Store local_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29557
diff
changeset
|
649 PurpleMediaCandidate *candidate) |
29534 | 650 { |
651 PurpleMediaStream *stream; | |
652 | |
653 g_return_if_fail(session != NULL); | |
654 | |
655 stream = purple_media_get_stream(session->media, session->id, name); | |
656 stream->local_candidates = g_list_append(stream->local_candidates, candidate); | |
657 } | |
658 #endif | |
659 | |
660 GList * | |
661 purple_media_get_session_ids(PurpleMedia *media) | |
662 { | |
663 #ifdef USE_VV | |
664 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
665 return media->priv->sessions != NULL ? | |
666 g_hash_table_get_keys(media->priv->sessions) : NULL; | |
667 #else | |
668 return NULL; | |
669 #endif | |
670 } | |
671 | |
672 #ifdef USE_VV | |
673 static void | |
674 purple_media_set_src(PurpleMedia *media, const gchar *sess_id, GstElement *src) | |
675 { | |
676 PurpleMediaSession *session; | |
677 GstPad *sinkpad; | |
678 GstPad *srcpad; | |
679 | |
680 g_return_if_fail(PURPLE_IS_MEDIA(media)); | |
681 g_return_if_fail(GST_IS_ELEMENT(src)); | |
682 | |
683 session = purple_media_get_session(media, sess_id); | |
684 | |
685 if (session == NULL) { | |
686 purple_debug_warning("media", "purple_media_set_src: trying" | |
687 " to set src on non-existent session\n"); | |
688 return; | |
689 } | |
690 | |
691 if (session->src) | |
692 gst_object_unref(session->src); | |
693 session->src = src; | |
694 gst_element_set_locked_state(session->src, TRUE); | |
695 | |
696 session->tee = gst_element_factory_make("tee", NULL); | |
697 gst_bin_add(GST_BIN(session->media->priv->confbin), session->tee); | |
698 | |
699 /* This supposedly isn't necessary, but it silences some warnings */ | |
700 if (GST_ELEMENT_PARENT(session->media->priv->confbin) | |
701 == GST_ELEMENT_PARENT(session->src)) { | |
702 GstPad *pad = gst_element_get_static_pad(session->tee, "sink"); | |
703 GstPad *ghost = gst_ghost_pad_new(NULL, pad); | |
704 gst_object_unref(pad); | |
705 gst_pad_set_active(ghost, TRUE); | |
706 gst_element_add_pad(session->media->priv->confbin, ghost); | |
707 } | |
708 | |
709 gst_element_set_state(session->tee, GST_STATE_PLAYING); | |
710 gst_element_link(session->src, session->media->priv->confbin); | |
711 | |
712 g_object_get(session->session, "sink-pad", &sinkpad, NULL); | |
713 if (session->type & PURPLE_MEDIA_SEND_AUDIO) { | |
714 gchar *name = g_strdup_printf("volume_%s", session->id); | |
715 GstElement *level; | |
716 GstElement *volume = gst_element_factory_make("volume", name); | |
717 double input_volume = purple_prefs_get_int( | |
718 "/purple/media/audio/volume/input")/10.0; | |
719 g_free(name); | |
720 name = g_strdup_printf("sendlevel_%s", session->id); | |
721 level = gst_element_factory_make("level", name); | |
722 g_free(name); | |
723 gst_bin_add(GST_BIN(session->media->priv->confbin), volume); | |
724 gst_bin_add(GST_BIN(session->media->priv->confbin), level); | |
725 gst_element_set_state(level, GST_STATE_PLAYING); | |
726 gst_element_set_state(volume, GST_STATE_PLAYING); | |
727 gst_element_link(volume, level); | |
728 gst_element_link(session->tee, volume); | |
729 srcpad = gst_element_get_static_pad(level, "src"); | |
730 g_object_set(volume, "volume", input_volume, NULL); | |
731 } else { | |
732 srcpad = gst_element_get_request_pad(session->tee, "src%d"); | |
733 } | |
734 purple_debug_info("media", "connecting pad: %s\n", | |
735 gst_pad_link(srcpad, sinkpad) == GST_PAD_LINK_OK | |
736 ? "success" : "failure"); | |
737 gst_element_set_locked_state(session->src, FALSE); | |
738 gst_object_unref(session->src); | |
739 } | |
740 #endif | |
741 | |
742 #ifdef USE_GSTREAMER | |
743 GstElement * | |
744 purple_media_get_src(PurpleMedia *media, const gchar *sess_id) | |
745 { | |
746 #ifdef USE_VV | |
747 PurpleMediaSession *session; | |
748 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
749 session = purple_media_get_session(media, sess_id); | |
750 return (session != NULL) ? session->src : NULL; | |
751 #else | |
752 return NULL; | |
753 #endif | |
754 } | |
755 #endif /* USE_GSTREAMER */ | |
756 | |
757 #ifdef USE_VV | |
758 static gboolean | |
759 media_bus_call(GstBus *bus, GstMessage *msg, PurpleMedia *media) | |
760 { | |
761 switch(GST_MESSAGE_TYPE(msg)) { | |
762 case GST_MESSAGE_ELEMENT: { | |
763 if (g_signal_has_handler_pending(media, | |
764 purple_media_signals[LEVEL], 0, FALSE) | |
765 && gst_structure_has_name( | |
766 gst_message_get_structure(msg), "level")) { | |
767 GstElement *src = GST_ELEMENT(GST_MESSAGE_SRC(msg)); | |
768 gchar *name; | |
769 gchar *participant = NULL; | |
770 PurpleMediaSession *session = NULL; | |
771 gdouble rms_db; | |
772 gdouble percent; | |
773 const GValue *list; | |
774 const GValue *value; | |
775 | |
776 if (!PURPLE_IS_MEDIA(media) || | |
777 GST_ELEMENT_PARENT(src) != | |
778 media->priv->confbin) | |
779 break; | |
780 | |
781 name = gst_element_get_name(src); | |
782 if (!strncmp(name, "sendlevel_", 10)) { | |
783 session = purple_media_get_session( | |
784 media, name+10); | |
785 } else { | |
786 GList *iter = media->priv->streams; | |
787 for (; iter; iter = g_list_next(iter)) { | |
788 PurpleMediaStream *stream = iter->data; | |
789 if (stream->level == src) { | |
790 session = stream->session; | |
791 participant = stream->participant; | |
792 break; | |
793 } | |
794 } | |
795 } | |
796 g_free(name); | |
797 if (!session) | |
798 break; | |
799 | |
800 list = gst_structure_get_value( | |
801 gst_message_get_structure(msg), "rms"); | |
802 value = gst_value_list_get_value(list, 0); | |
803 rms_db = g_value_get_double(value); | |
804 percent = pow(10, rms_db / 20) * 5; | |
805 if(percent > 1.0) | |
806 percent = 1.0; | |
807 | |
808 g_signal_emit(media, purple_media_signals[LEVEL], | |
809 0, session->id, participant, percent); | |
810 break; | |
811 } | |
812 break; | |
813 } | |
814 default: | |
815 break; | |
816 } | |
817 | |
818 return TRUE; | |
819 } | |
820 #endif | |
821 | |
822 PurpleAccount * | |
823 purple_media_get_account(PurpleMedia *media) | |
824 { | |
825 #ifdef USE_VV | |
826 PurpleAccount *account; | |
827 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
828 g_object_get(G_OBJECT(media), "account", &account, NULL); | |
829 return account; | |
830 #else | |
831 return NULL; | |
832 #endif | |
833 } | |
834 | |
835 gpointer | |
836 purple_media_get_prpl_data(PurpleMedia *media) | |
837 { | |
838 #ifdef USE_VV | |
839 gpointer prpl_data; | |
840 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
841 g_object_get(G_OBJECT(media), "prpl-data", &prpl_data, NULL); | |
842 return prpl_data; | |
843 #else | |
844 return NULL; | |
845 #endif | |
846 } | |
847 | |
848 void | |
849 purple_media_set_prpl_data(PurpleMedia *media, gpointer prpl_data) | |
850 { | |
851 #ifdef USE_VV | |
852 g_return_if_fail(PURPLE_IS_MEDIA(media)); | |
853 g_object_set(G_OBJECT(media), "prpl-data", prpl_data, NULL); | |
854 #endif | |
855 } | |
856 | |
857 void | |
858 purple_media_error(PurpleMedia *media, const gchar *error, ...) | |
859 { | |
860 #ifdef USE_VV | |
861 va_list args; | |
862 gchar *message; | |
863 | |
864 g_return_if_fail(PURPLE_IS_MEDIA(media)); | |
865 | |
866 va_start(args, error); | |
867 message = g_strdup_vprintf(error, args); | |
868 va_end(args); | |
869 | |
870 purple_debug_error("media", "%s\n", message); | |
871 g_signal_emit(media, purple_media_signals[S_ERROR], 0, message); | |
872 | |
873 g_free(message); | |
874 #endif | |
875 } | |
876 | |
877 void | |
878 purple_media_end(PurpleMedia *media, | |
879 const gchar *session_id, const gchar *participant) | |
880 { | |
881 #ifdef USE_VV | |
882 g_return_if_fail(PURPLE_IS_MEDIA(media)); | |
883 if (session_id == NULL && participant == NULL) { | |
884 g_signal_emit(media, purple_media_signals[STATE_CHANGED], | |
885 0, PURPLE_MEDIA_STATE_END, | |
886 NULL, NULL); | |
887 g_object_unref(media); | |
888 } | |
889 #endif | |
890 } | |
891 | |
892 void | |
893 purple_media_stream_info(PurpleMedia *media, PurpleMediaInfoType type, | |
894 const gchar *session_id, const gchar *participant, | |
895 gboolean local) | |
896 { | |
897 #ifdef USE_VV | |
898 g_return_if_fail(PURPLE_IS_MEDIA(media)); | |
899 | |
900 if (type == PURPLE_MEDIA_INFO_ACCEPT) { | |
901 GList *streams; | |
902 | |
903 g_return_if_fail(PURPLE_IS_MEDIA(media)); | |
904 | |
905 streams = purple_media_get_streams(media, | |
906 session_id, participant); | |
907 | |
908 for (; streams; streams = | |
909 g_list_delete_link(streams, streams)) { | |
910 PurpleMediaStream *stream = streams->data; | |
29576
a27e41f373db
Handle part of accepting a stream in the Fs2 media backend.
maiku@pidgin.im
parents:
29575
diff
changeset
|
911 |
29534 | 912 stream->accepted = TRUE; |
913 } | |
914 } else if (local == TRUE && (type == PURPLE_MEDIA_INFO_MUTE || | |
915 type == PURPLE_MEDIA_INFO_UNMUTE)) { | |
916 GList *sessions; | |
917 gboolean active = (type == PURPLE_MEDIA_INFO_MUTE); | |
918 | |
919 g_return_if_fail(PURPLE_IS_MEDIA(media)); | |
920 | |
921 if (session_id == NULL) | |
922 sessions = g_hash_table_get_values( | |
923 media->priv->sessions); | |
924 else | |
925 sessions = g_list_prepend(NULL, | |
926 purple_media_get_session( | |
927 media, session_id)); | |
928 | |
929 purple_debug_info("media", "Turning mute %s\n", | |
930 active ? "on" : "off"); | |
931 | |
932 for (; sessions; sessions = g_list_delete_link( | |
933 sessions, sessions)) { | |
934 PurpleMediaSession *session = sessions->data; | |
935 if (session->type & PURPLE_MEDIA_SEND_AUDIO) { | |
936 gchar *name = g_strdup_printf("volume_%s", | |
937 session->id); | |
938 GstElement *volume = gst_bin_get_by_name( | |
939 GST_BIN(session->media-> | |
940 priv->confbin), name); | |
941 g_free(name); | |
942 g_object_set(volume, "mute", active, NULL); | |
943 } | |
944 } | |
945 } else if (local == TRUE && (type == PURPLE_MEDIA_INFO_PAUSE || | |
946 type == PURPLE_MEDIA_INFO_UNPAUSE)) { | |
947 gboolean active = (type == PURPLE_MEDIA_INFO_PAUSE); | |
948 GList *streams = purple_media_get_streams(media, | |
949 session_id, participant); | |
950 for (; streams; streams = g_list_delete_link(streams, streams)) { | |
951 PurpleMediaStream *stream = streams->data; | |
952 if (stream->session->type & PURPLE_MEDIA_SEND_VIDEO) { | |
953 g_object_set(stream->stream, "direction", | |
954 purple_media_to_fs_stream_direction( | |
955 stream->session->type & ((active) ? | |
956 ~PURPLE_MEDIA_SEND_VIDEO : | |
957 PURPLE_MEDIA_VIDEO)), NULL); | |
958 } | |
959 } | |
960 } | |
961 | |
962 g_signal_emit(media, purple_media_signals[STREAM_INFO], | |
963 0, type, session_id, participant, local); | |
964 | |
965 if (type == PURPLE_MEDIA_INFO_HANGUP || | |
966 type == PURPLE_MEDIA_INFO_REJECT) { | |
967 purple_media_end(media, session_id, participant); | |
968 } | |
969 #endif | |
970 } | |
971 | |
972 #ifdef USE_VV | |
973 static void | |
29554
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29553
diff
changeset
|
974 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:
29553
diff
changeset
|
975 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:
29553
diff
changeset
|
976 PurpleMediaCandidate *candidate, PurpleMedia *media) |
29534 | 977 { |
29554
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29553
diff
changeset
|
978 PurpleMediaSession *session = |
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29553
diff
changeset
|
979 purple_media_get_session(media, sess_id); |
29534 | 980 |
29554
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29553
diff
changeset
|
981 purple_media_insert_local_candidate(session, participant, |
29559
cb843608e183
Store local_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29557
diff
changeset
|
982 purple_media_candidate_copy(candidate)); |
29534 | 983 |
984 g_signal_emit(session->media, purple_media_signals[NEW_CANDIDATE], | |
29554
2460e6774e08
Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents:
29553
diff
changeset
|
985 0, session->id, participant, candidate); |
29534 | 986 } |
987 | |
988 static void | |
29557
1fdc75c94c22
Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents:
29556
diff
changeset
|
989 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:
29556
diff
changeset
|
990 const gchar *sess_id, const gchar *name, PurpleMedia *media) |
29534 | 991 { |
992 PurpleMediaStream *stream_data; | |
993 | |
29557
1fdc75c94c22
Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents:
29556
diff
changeset
|
994 g_return_if_fail(PURPLE_IS_MEDIA(media)); |
29534 | 995 |
29557
1fdc75c94c22
Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents:
29556
diff
changeset
|
996 stream_data = purple_media_get_stream(media, sess_id, name); |
29534 | 997 stream_data->candidates_prepared = TRUE; |
998 | |
29557
1fdc75c94c22
Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents:
29556
diff
changeset
|
999 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:
29556
diff
changeset
|
1000 0, sess_id, name); |
29534 | 1001 } |
1002 | |
1003 /* callback called when a pair of transport candidates (local and remote) | |
1004 * has been established */ | |
1005 static void | |
29556
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29555
diff
changeset
|
1006 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:
29555
diff
changeset
|
1007 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:
29555
diff
changeset
|
1008 PurpleMediaCandidate *local_candidate, |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29555
diff
changeset
|
1009 PurpleMediaCandidate *remote_candidate, |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29555
diff
changeset
|
1010 PurpleMedia *media) |
29534 | 1011 { |
1012 PurpleMediaStream *stream; | |
1013 GList *iter; | |
29556
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29555
diff
changeset
|
1014 guint id; |
29534 | 1015 |
29556
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29555
diff
changeset
|
1016 g_return_if_fail(PURPLE_IS_MEDIA(media)); |
29534 | 1017 |
29556
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29555
diff
changeset
|
1018 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:
29555
diff
changeset
|
1019 id = purple_media_candidate_get_component_id(local_candidate); |
29534 | 1020 |
1021 iter = stream->active_local_candidates; | |
1022 for(; iter; iter = g_list_next(iter)) { | |
29561
7713312c4ab0
Store active_local_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29560
diff
changeset
|
1023 PurpleMediaCandidate *c = iter->data; |
7713312c4ab0
Store active_local_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29560
diff
changeset
|
1024 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:
29560
diff
changeset
|
1025 g_object_unref(c); |
29534 | 1026 stream->active_local_candidates = |
1027 g_list_delete_link(iter, iter); | |
1028 stream->active_local_candidates = g_list_prepend( | |
1029 stream->active_local_candidates, | |
29561
7713312c4ab0
Store active_local_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29560
diff
changeset
|
1030 purple_media_candidate_copy( |
29556
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29555
diff
changeset
|
1031 local_candidate)); |
29534 | 1032 break; |
1033 } | |
1034 } | |
1035 if (iter == NULL) | |
1036 stream->active_local_candidates = g_list_prepend( | |
1037 stream->active_local_candidates, | |
29561
7713312c4ab0
Store active_local_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29560
diff
changeset
|
1038 purple_media_candidate_copy( |
29556
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29555
diff
changeset
|
1039 local_candidate)); |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29555
diff
changeset
|
1040 |
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29555
diff
changeset
|
1041 id = purple_media_candidate_get_component_id(local_candidate); |
29534 | 1042 |
1043 iter = stream->active_remote_candidates; | |
1044 for(; iter; iter = g_list_next(iter)) { | |
29562
1156bf88b4d3
Store active_remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29561
diff
changeset
|
1045 PurpleMediaCandidate *c = iter->data; |
1156bf88b4d3
Store active_remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29561
diff
changeset
|
1046 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:
29561
diff
changeset
|
1047 g_object_unref(c); |
29534 | 1048 stream->active_remote_candidates = |
1049 g_list_delete_link(iter, iter); | |
1050 stream->active_remote_candidates = g_list_prepend( | |
1051 stream->active_remote_candidates, | |
29562
1156bf88b4d3
Store active_remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29561
diff
changeset
|
1052 purple_media_candidate_copy( |
29556
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29555
diff
changeset
|
1053 remote_candidate)); |
29534 | 1054 break; |
1055 } | |
1056 } | |
1057 if (iter == NULL) | |
1058 stream->active_remote_candidates = g_list_prepend( | |
1059 stream->active_remote_candidates, | |
29562
1156bf88b4d3
Store active_remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29561
diff
changeset
|
1060 purple_media_candidate_copy( |
29556
74e75fc3481e
Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents:
29555
diff
changeset
|
1061 remote_candidate)); |
29534 | 1062 |
1063 purple_debug_info("media", "candidate pair established\n"); | |
1064 } | |
1065 | |
29555
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29554
diff
changeset
|
1066 static void |
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29554
diff
changeset
|
1067 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:
29554
diff
changeset
|
1068 const gchar *sess_id, PurpleMedia *media) |
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29554
diff
changeset
|
1069 { |
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29554
diff
changeset
|
1070 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:
29554
diff
changeset
|
1071 } |
cc978a1a4bd1
Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents:
29554
diff
changeset
|
1072 |
29534 | 1073 static gboolean |
1074 purple_media_connected_cb(PurpleMediaStream *stream) | |
1075 { | |
1076 g_return_val_if_fail(stream != NULL, FALSE); | |
1077 | |
1078 stream->connected_cb_id = 0; | |
1079 | |
1080 purple_media_manager_create_output_window( | |
1081 stream->session->media->priv->manager, | |
1082 stream->session->media, | |
1083 stream->session->id, stream->participant); | |
1084 | |
1085 g_signal_emit(stream->session->media, | |
1086 purple_media_signals[STATE_CHANGED], | |
1087 0, PURPLE_MEDIA_STATE_CONNECTED, | |
1088 stream->session->id, stream->participant); | |
1089 return FALSE; | |
1090 } | |
1091 | |
1092 static void | |
1093 purple_media_src_pad_added_cb(FsStream *fsstream, GstPad *srcpad, | |
1094 FsCodec *codec, PurpleMediaStream *stream) | |
1095 { | |
1096 PurpleMediaPrivate *priv; | |
1097 GstPad *sinkpad; | |
1098 | |
1099 g_return_if_fail(FS_IS_STREAM(fsstream)); | |
1100 g_return_if_fail(stream != NULL); | |
1101 | |
1102 priv = stream->session->media->priv; | |
1103 | |
1104 if (stream->src == NULL) { | |
1105 GstElement *sink = NULL; | |
1106 | |
1107 if (codec->media_type == FS_MEDIA_TYPE_AUDIO) { | |
1108 GstElement *queue = NULL; | |
1109 double output_volume = purple_prefs_get_int( | |
1110 "/purple/media/audio/volume/output")/10.0; | |
1111 /* | |
1112 * Should this instead be: | |
1113 * audioconvert ! audioresample ! liveadder ! | |
1114 * audioresample ! audioconvert ! realsink | |
1115 */ | |
1116 queue = gst_element_factory_make("queue", NULL); | |
1117 stream->volume = gst_element_factory_make( | |
1118 "volume", NULL); | |
1119 g_object_set(stream->volume, "volume", | |
1120 output_volume, NULL); | |
1121 stream->level = gst_element_factory_make( | |
1122 "level", NULL); | |
1123 stream->src = gst_element_factory_make( | |
1124 "liveadder", NULL); | |
1125 sink = purple_media_manager_get_element(priv->manager, | |
1126 PURPLE_MEDIA_RECV_AUDIO, | |
1127 stream->session->media, | |
1128 stream->session->id, | |
1129 stream->participant); | |
1130 gst_bin_add(GST_BIN(priv->confbin), queue); | |
1131 gst_bin_add(GST_BIN(priv->confbin), stream->volume); | |
1132 gst_bin_add(GST_BIN(priv->confbin), stream->level); | |
1133 gst_bin_add(GST_BIN(priv->confbin), sink); | |
1134 gst_element_set_state(sink, GST_STATE_PLAYING); | |
1135 gst_element_set_state(stream->level, GST_STATE_PLAYING); | |
1136 gst_element_set_state(stream->volume, GST_STATE_PLAYING); | |
1137 gst_element_set_state(queue, GST_STATE_PLAYING); | |
1138 gst_element_link(stream->level, sink); | |
1139 gst_element_link(stream->volume, stream->level); | |
1140 gst_element_link(queue, stream->volume); | |
1141 sink = queue; | |
1142 } else if (codec->media_type == FS_MEDIA_TYPE_VIDEO) { | |
1143 stream->src = gst_element_factory_make( | |
1144 "fsfunnel", NULL); | |
1145 sink = gst_element_factory_make( | |
1146 "fakesink", NULL); | |
1147 g_object_set(G_OBJECT(sink), "async", FALSE, NULL); | |
1148 gst_bin_add(GST_BIN(priv->confbin), sink); | |
1149 gst_element_set_state(sink, GST_STATE_PLAYING); | |
1150 } | |
1151 stream->tee = gst_element_factory_make("tee", NULL); | |
1152 gst_bin_add_many(GST_BIN(priv->confbin), | |
1153 stream->src, stream->tee, NULL); | |
1154 gst_element_set_state(stream->tee, GST_STATE_PLAYING); | |
1155 gst_element_set_state(stream->src, GST_STATE_PLAYING); | |
1156 gst_element_link_many(stream->src, stream->tee, sink, NULL); | |
1157 } | |
1158 | |
1159 sinkpad = gst_element_get_request_pad(stream->src, "sink%d"); | |
1160 gst_pad_link(srcpad, sinkpad); | |
1161 gst_object_unref(sinkpad); | |
1162 | |
1163 stream->connected_cb_id = purple_timeout_add(0, | |
1164 (GSourceFunc)purple_media_connected_cb, stream); | |
1165 } | |
1166 #endif /* USE_VV */ | |
1167 | |
1168 gboolean | |
1169 purple_media_add_stream(PurpleMedia *media, const gchar *sess_id, | |
1170 const gchar *who, PurpleMediaSessionType type, | |
1171 gboolean initiator, const gchar *transmitter, | |
1172 guint num_params, GParameter *params) | |
1173 { | |
1174 #ifdef USE_VV | |
1175 PurpleMediaSession *session; | |
1176 FsParticipant *participant = NULL; | |
1177 PurpleMediaStream *stream = NULL; | |
1178 FsMediaType media_type = purple_media_to_fs_media_type(type); | |
1179 FsStreamDirection type_direction = | |
1180 purple_media_to_fs_stream_direction(type); | |
1181 | |
1182 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE); | |
1183 | |
29551
e85df0170905
Decouple the media_bus_call from the backend. It will still be needed even
maiku@pidgin.im
parents:
29550
diff
changeset
|
1184 if (media->priv->gst_bus_handler_id == 0) { |
e85df0170905
Decouple the media_bus_call from the backend. It will still be needed even
maiku@pidgin.im
parents:
29550
diff
changeset
|
1185 GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE( |
e85df0170905
Decouple the media_bus_call from the backend. It will still be needed even
maiku@pidgin.im
parents:
29550
diff
changeset
|
1186 purple_media_manager_get_pipeline( |
e85df0170905
Decouple the media_bus_call from the backend. It will still be needed even
maiku@pidgin.im
parents:
29550
diff
changeset
|
1187 purple_media_manager_get()))); |
e85df0170905
Decouple the media_bus_call from the backend. It will still be needed even
maiku@pidgin.im
parents:
29550
diff
changeset
|
1188 media->priv->gst_bus_handler_id = |
e85df0170905
Decouple the media_bus_call from the backend. It will still be needed even
maiku@pidgin.im
parents:
29550
diff
changeset
|
1189 g_signal_connect(G_OBJECT(bus), "message", |
e85df0170905
Decouple the media_bus_call from the backend. It will still be needed even
maiku@pidgin.im
parents:
29550
diff
changeset
|
1190 G_CALLBACK(media_bus_call), media); |
e85df0170905
Decouple the media_bus_call from the backend. It will still be needed even
maiku@pidgin.im
parents:
29550
diff
changeset
|
1191 gst_object_unref(bus); |
e85df0170905
Decouple the media_bus_call from the backend. It will still be needed even
maiku@pidgin.im
parents:
29550
diff
changeset
|
1192 } |
e85df0170905
Decouple the media_bus_call from the backend. It will still be needed even
maiku@pidgin.im
parents:
29550
diff
changeset
|
1193 |
29549
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
1194 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:
29545
diff
changeset
|
1195 sess_id, who, type, initiator, transmitter, |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
1196 num_params, params)) { |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
1197 purple_debug_error("media", "Error adding stream.\n"); |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
1198 return FALSE; |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
1199 } |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
1200 |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
1201 /* XXX: Temporary call while integrating with backend */ |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
1202 if (media->priv->conference == NULL) { |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
1203 media->priv->conference = |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
1204 purple_media_backend_fs2_get_conference( |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
1205 PURPLE_MEDIA_BACKEND_FS2( |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
1206 media->priv->backend)); |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
1207 media->priv->confbin = GST_ELEMENT_PARENT( |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
1208 media->priv->conference); |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
1209 } |
41ae97b7e97e
Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents:
29545
diff
changeset
|
1210 |
29534 | 1211 session = purple_media_get_session(media, sess_id); |
1212 | |
1213 if (!session) { | |
1214 PurpleMediaSessionType session_type; | |
1215 GstElement *src = NULL; | |
1216 | |
1217 session = g_new0(PurpleMediaSession, 1); | |
29553
efeb21092ed2
Begin transferring FsSession over to the Farsight 2 media backend.
maiku@pidgin.im
parents:
29552
diff
changeset
|
1218 session->session = purple_media_backend_fs2_get_session( |
efeb21092ed2
Begin transferring FsSession over to the Farsight 2 media backend.
maiku@pidgin.im
parents:
29552
diff
changeset
|
1219 PURPLE_MEDIA_BACKEND_FS2(media->priv->backend), |
efeb21092ed2
Begin transferring FsSession over to the Farsight 2 media backend.
maiku@pidgin.im
parents:
29552
diff
changeset
|
1220 sess_id); |
29534 | 1221 session->id = g_strdup(sess_id); |
1222 session->media = media; | |
1223 session->type = type; | |
1224 session->initiator = initiator; | |
1225 | |
1226 purple_media_add_session(media, session); | |
1227 g_signal_emit(media, purple_media_signals[STATE_CHANGED], | |
1228 0, PURPLE_MEDIA_STATE_NEW, | |
1229 session->id, NULL); | |
1230 | |
1231 if (type_direction & FS_DIRECTION_SEND) { | |
1232 session_type = purple_media_from_fs(media_type, | |
1233 FS_DIRECTION_SEND); | |
1234 src = purple_media_manager_get_element( | |
1235 media->priv->manager, session_type, | |
1236 media, session->id, who); | |
1237 if (!GST_IS_ELEMENT(src)) { | |
1238 purple_debug_error("media", | |
1239 "Error creating src for session %s\n", | |
1240 session->id); | |
1241 purple_media_end(media, session->id, NULL); | |
1242 return FALSE; | |
1243 } | |
1244 | |
1245 purple_media_set_src(media, session->id, src); | |
1246 gst_element_set_state(session->src, GST_STATE_PLAYING); | |
1247 purple_media_manager_create_output_window( | |
1248 media->priv->manager, | |
1249 session->media, | |
1250 session->id, NULL); | |
1251 } | |
1252 } | |
1253 | |
29565
eef5ec04a5bf
Remove the list of participants from PurpleMedia and use the Fs2 backend's.
maiku@pidgin.im
parents:
29562
diff
changeset
|
1254 participant = purple_media_backend_fs2_get_participant( |
eef5ec04a5bf
Remove the list of participants from PurpleMedia and use the Fs2 backend's.
maiku@pidgin.im
parents:
29562
diff
changeset
|
1255 PURPLE_MEDIA_BACKEND_FS2(media->priv->backend), who); |
29534 | 1256 |
1257 stream = purple_media_get_stream(media, sess_id, who); | |
1258 | |
1259 if (!stream) { | |
1260 FsStream *fsstream = NULL; | |
1261 | |
29566
f600903f7811
Transfer creating Farsight 2 streams to the Fs2 media backend.
maiku@pidgin.im
parents:
29565
diff
changeset
|
1262 fsstream = purple_media_backend_fs2_get_stream( |
f600903f7811
Transfer creating Farsight 2 streams to the Fs2 media backend.
maiku@pidgin.im
parents:
29565
diff
changeset
|
1263 PURPLE_MEDIA_BACKEND_FS2( |
f600903f7811
Transfer creating Farsight 2 streams to the Fs2 media backend.
maiku@pidgin.im
parents:
29565
diff
changeset
|
1264 media->priv->backend), sess_id, who); |
29534 | 1265 |
1266 stream = purple_media_insert_stream(session, who, fsstream); | |
1267 stream->initiator = initiator; | |
1268 | |
1269 /* callback for source pad added (new stream source ready) */ | |
1270 g_signal_connect(G_OBJECT(fsstream), | |
1271 "src-pad-added", G_CALLBACK(purple_media_src_pad_added_cb), stream); | |
1272 | |
1273 g_signal_emit(media, purple_media_signals[STATE_CHANGED], | |
1274 0, PURPLE_MEDIA_STATE_NEW, | |
1275 session->id, who); | |
1276 } else { | |
1277 if (purple_media_to_fs_stream_direction(stream->session->type) | |
1278 != type_direction) { | |
1279 /* change direction */ | |
1280 g_object_set(stream->stream, "direction", | |
1281 type_direction, NULL); | |
1282 } | |
1283 } | |
1284 | |
1285 return TRUE; | |
1286 #else | |
1287 return FALSE; | |
1288 #endif /* USE_VV */ | |
1289 } | |
1290 | |
1291 PurpleMediaManager * | |
1292 purple_media_get_manager(PurpleMedia *media) | |
1293 { | |
1294 PurpleMediaManager *ret; | |
1295 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
1296 g_object_get(media, "manager", &ret, NULL); | |
1297 return ret; | |
1298 } | |
1299 | |
1300 PurpleMediaSessionType | |
1301 purple_media_get_session_type(PurpleMedia *media, const gchar *sess_id) | |
1302 { | |
1303 #ifdef USE_VV | |
1304 PurpleMediaSession *session; | |
1305 g_return_val_if_fail(PURPLE_IS_MEDIA(media), PURPLE_MEDIA_NONE); | |
1306 session = purple_media_get_session(media, sess_id); | |
1307 return session->type; | |
1308 #else | |
1309 return PURPLE_MEDIA_NONE; | |
1310 #endif | |
1311 } | |
1312 /* XXX: Should wait until codecs-ready is TRUE before using this function */ | |
1313 GList * | |
1314 purple_media_get_codecs(PurpleMedia *media, const gchar *sess_id) | |
1315 { | |
1316 #ifdef USE_VV | |
1317 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
1318 | |
29569
9c1810122f21
Transfer get_codecs functionality to the Fs2 media backend.
maiku@pidgin.im
parents:
29568
diff
changeset
|
1319 return purple_media_backend_get_codecs(media->priv->backend, sess_id); |
29534 | 1320 #else |
1321 return NULL; | |
1322 #endif | |
1323 } | |
1324 | |
1325 GList * | |
1326 purple_media_get_local_candidates(PurpleMedia *media, const gchar *sess_id, | |
1327 const gchar *participant) | |
1328 { | |
1329 #ifdef USE_VV | |
1330 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
29571
f0966e90ec44
Move get_local_candidates functionality over to the Fs2 media backend.
maiku@pidgin.im
parents:
29569
diff
changeset
|
1331 |
f0966e90ec44
Move get_local_candidates functionality over to the Fs2 media backend.
maiku@pidgin.im
parents:
29569
diff
changeset
|
1332 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:
29569
diff
changeset
|
1333 sess_id, participant); |
29534 | 1334 #else |
1335 return NULL; | |
1336 #endif | |
1337 } | |
1338 | |
1339 void | |
1340 purple_media_add_remote_candidates(PurpleMedia *media, const gchar *sess_id, | |
1341 const gchar *participant, | |
1342 GList *remote_candidates) | |
1343 { | |
1344 #ifdef USE_VV | |
1345 PurpleMediaStream *stream; | |
1346 | |
1347 g_return_if_fail(PURPLE_IS_MEDIA(media)); | |
1348 stream = purple_media_get_stream(media, sess_id, participant); | |
1349 | |
1350 if (stream == NULL) { | |
1351 purple_debug_error("media", | |
1352 "purple_media_add_remote_candidates: " | |
1353 "couldn't find stream %s %s.\n", | |
1354 sess_id ? sess_id : "(null)", | |
1355 participant ? participant : "(null)"); | |
1356 return; | |
1357 } | |
1358 | |
1359 stream->remote_candidates = g_list_concat(stream->remote_candidates, | |
29560
18571ea6e44a
Store remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29559
diff
changeset
|
1360 purple_media_candidate_list_copy(remote_candidates)); |
29534 | 1361 |
29576
a27e41f373db
Handle part of accepting a stream in the Fs2 media backend.
maiku@pidgin.im
parents:
29575
diff
changeset
|
1362 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:
29575
diff
changeset
|
1363 sess_id, participant, remote_candidates); |
29534 | 1364 #endif |
1365 } | |
1366 | |
1367 #if 0 | |
1368 /* | |
1369 * These two functions aren't being used and I'd rather not lock in the API | |
1370 * until they are needed. If they ever are. | |
1371 */ | |
1372 | |
1373 GList * | |
1374 purple_media_get_active_local_candidates(PurpleMedia *media, | |
1375 const gchar *sess_id, const gchar *participant) | |
1376 { | |
1377 #ifdef USE_VV | |
1378 PurpleMediaStream *stream; | |
1379 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
1380 stream = purple_media_get_stream(media, sess_id, participant); | |
29561
7713312c4ab0
Store active_local_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29560
diff
changeset
|
1381 return purple_media_candidate_list_copy( |
29534 | 1382 stream->active_local_candidates); |
1383 #else | |
1384 return NULL; | |
1385 #endif | |
1386 } | |
1387 | |
1388 GList * | |
1389 purple_media_get_active_remote_candidates(PurpleMedia *media, | |
1390 const gchar *sess_id, const gchar *participant) | |
1391 { | |
1392 #ifdef USE_VV | |
1393 PurpleMediaStream *stream; | |
1394 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
1395 stream = purple_media_get_stream(media, sess_id, participant); | |
29562
1156bf88b4d3
Store active_remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents:
29561
diff
changeset
|
1396 return purple_media_candidate_list_copy( |
29534 | 1397 stream->active_remote_candidates); |
1398 #else | |
1399 return NULL; | |
1400 #endif | |
1401 } | |
1402 #endif | |
1403 | |
1404 gboolean | |
1405 purple_media_set_remote_codecs(PurpleMedia *media, const gchar *sess_id, | |
1406 const gchar *participant, GList *codecs) | |
1407 { | |
1408 #ifdef USE_VV | |
1409 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE); | |
1410 | |
29573
a39696686dd6
Move set_remote_codecs functionality to the Fs2 media backend.
maiku@pidgin.im
parents:
29571
diff
changeset
|
1411 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:
29571
diff
changeset
|
1412 sess_id, participant, codecs); |
29534 | 1413 #else |
1414 return FALSE; | |
1415 #endif | |
1416 } | |
1417 | |
1418 gboolean | |
1419 purple_media_candidates_prepared(PurpleMedia *media, | |
1420 const gchar *session_id, const gchar *participant) | |
1421 { | |
1422 #ifdef USE_VV | |
1423 GList *streams; | |
1424 gboolean prepared = TRUE; | |
1425 | |
1426 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE); | |
1427 | |
1428 streams = purple_media_get_streams(media, session_id, participant); | |
1429 | |
1430 for (; streams; streams = g_list_delete_link(streams, streams)) { | |
1431 PurpleMediaStream *stream = streams->data; | |
1432 if (stream->candidates_prepared == FALSE) { | |
1433 g_list_free(streams); | |
1434 prepared = FALSE; | |
1435 break; | |
1436 } | |
1437 } | |
1438 | |
1439 return prepared; | |
1440 #else | |
1441 return FALSE; | |
1442 #endif | |
1443 } | |
1444 | |
1445 gboolean | |
1446 purple_media_set_send_codec(PurpleMedia *media, const gchar *sess_id, PurpleMediaCodec *codec) | |
1447 { | |
1448 #ifdef USE_VV | |
1449 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE); | |
1450 | |
29575
ec5ed142f551
Move set_remote_codec functionality to the Fs2 media backend.
maiku@pidgin.im
parents:
29573
diff
changeset
|
1451 return purple_media_backend_set_send_codec( |
ec5ed142f551
Move set_remote_codec functionality to the Fs2 media backend.
maiku@pidgin.im
parents:
29573
diff
changeset
|
1452 media->priv->backend, sess_id, codec); |
29534 | 1453 #else |
1454 return FALSE; | |
1455 #endif | |
1456 } | |
1457 | |
1458 gboolean | |
1459 purple_media_codecs_ready(PurpleMedia *media, const gchar *sess_id) | |
1460 { | |
1461 #ifdef USE_VV | |
1462 gboolean ret; | |
1463 | |
1464 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE); | |
1465 | |
1466 if (sess_id != NULL) { | |
1467 PurpleMediaSession *session; | |
1468 session = purple_media_get_session(media, sess_id); | |
1469 | |
1470 if (session == NULL) | |
1471 return FALSE; | |
1472 if (session->type & (PURPLE_MEDIA_SEND_AUDIO | | |
1473 PURPLE_MEDIA_SEND_VIDEO)) | |
1474 g_object_get(session->session, | |
1475 "codecs-ready", &ret, NULL); | |
1476 else | |
1477 ret = TRUE; | |
1478 } else { | |
1479 GList *values = g_hash_table_get_values(media->priv->sessions); | |
1480 for (; values; values = g_list_delete_link(values, values)) { | |
1481 PurpleMediaSession *session = values->data; | |
1482 if (session->type & (PURPLE_MEDIA_SEND_AUDIO | | |
1483 PURPLE_MEDIA_SEND_VIDEO)) | |
1484 g_object_get(session->session, | |
1485 "codecs-ready", &ret, NULL); | |
1486 else | |
1487 ret = TRUE; | |
1488 | |
1489 if (ret == FALSE) | |
1490 break; | |
1491 } | |
1492 if (values != NULL) | |
1493 g_list_free(values); | |
1494 } | |
1495 return ret; | |
1496 #else | |
1497 return FALSE; | |
1498 #endif | |
1499 } | |
1500 | |
1501 gboolean | |
1502 purple_media_is_initiator(PurpleMedia *media, | |
1503 const gchar *sess_id, const gchar *participant) | |
1504 { | |
1505 #ifdef USE_VV | |
1506 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE); | |
1507 | |
1508 if (sess_id == NULL && participant == NULL) | |
1509 return media->priv->initiator; | |
1510 else if (sess_id != NULL && participant == NULL) { | |
1511 PurpleMediaSession *session = | |
1512 purple_media_get_session(media, sess_id); | |
1513 return session != NULL ? session->initiator : FALSE; | |
1514 } else if (sess_id != NULL && participant != NULL) { | |
1515 PurpleMediaStream *stream = purple_media_get_stream( | |
1516 media, sess_id, participant); | |
1517 return stream != NULL ? stream->initiator : FALSE; | |
1518 } | |
1519 #endif | |
1520 return FALSE; | |
1521 } | |
1522 | |
1523 gboolean | |
1524 purple_media_accepted(PurpleMedia *media, const gchar *sess_id, | |
1525 const gchar *participant) | |
1526 { | |
1527 #ifdef USE_VV | |
1528 gboolean accepted = TRUE; | |
1529 | |
1530 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE); | |
1531 | |
1532 if (sess_id == NULL && participant == NULL) { | |
1533 GList *streams = media->priv->streams; | |
1534 | |
1535 for (; streams; streams = g_list_next(streams)) { | |
1536 PurpleMediaStream *stream = streams->data; | |
1537 if (stream->accepted == FALSE) { | |
1538 accepted = FALSE; | |
1539 break; | |
1540 } | |
1541 } | |
1542 } else if (sess_id != NULL && participant == NULL) { | |
1543 GList *streams = purple_media_get_streams( | |
1544 media, sess_id, NULL); | |
1545 for (; streams; streams = | |
1546 g_list_delete_link(streams, streams)) { | |
1547 PurpleMediaStream *stream = streams->data; | |
1548 if (stream->accepted == FALSE) { | |
1549 g_list_free(streams); | |
1550 accepted = FALSE; | |
1551 break; | |
1552 } | |
1553 } | |
1554 } else if (sess_id != NULL && participant != NULL) { | |
1555 PurpleMediaStream *stream = purple_media_get_stream( | |
1556 media, sess_id, participant); | |
1557 if (stream == NULL || stream->accepted == FALSE) | |
1558 accepted = FALSE; | |
1559 } | |
1560 | |
1561 return accepted; | |
1562 #else | |
1563 return FALSE; | |
1564 #endif | |
1565 } | |
1566 | |
1567 void purple_media_set_input_volume(PurpleMedia *media, | |
1568 const gchar *session_id, double level) | |
1569 { | |
1570 #ifdef USE_VV | |
1571 GList *sessions; | |
1572 | |
1573 g_return_if_fail(PURPLE_IS_MEDIA(media)); | |
1574 | |
1575 purple_prefs_set_int("/purple/media/audio/volume/input", level); | |
1576 | |
1577 if (session_id == NULL) | |
1578 sessions = g_hash_table_get_values(media->priv->sessions); | |
1579 else | |
1580 sessions = g_list_append(NULL, | |
1581 purple_media_get_session(media, session_id)); | |
1582 | |
1583 for (; sessions; sessions = g_list_delete_link(sessions, sessions)) { | |
1584 PurpleMediaSession *session = sessions->data; | |
1585 | |
1586 if (session->type & PURPLE_MEDIA_SEND_AUDIO) { | |
1587 gchar *name = g_strdup_printf("volume_%s", | |
1588 session->id); | |
1589 GstElement *volume = gst_bin_get_by_name( | |
1590 GST_BIN(session->media->priv->confbin), | |
1591 name); | |
1592 g_free(name); | |
1593 g_object_set(volume, "volume", level/10.0, NULL); | |
1594 } | |
1595 } | |
1596 #endif | |
1597 } | |
1598 | |
1599 void purple_media_set_output_volume(PurpleMedia *media, | |
1600 const gchar *session_id, const gchar *participant, | |
1601 double level) | |
1602 { | |
1603 #ifdef USE_VV | |
1604 GList *streams; | |
1605 | |
1606 g_return_if_fail(PURPLE_IS_MEDIA(media)); | |
1607 | |
1608 purple_prefs_set_int("/purple/media/audio/volume/output", level); | |
1609 | |
1610 streams = purple_media_get_streams(media, | |
1611 session_id, participant); | |
1612 | |
1613 for (; streams; streams = g_list_delete_link(streams, streams)) { | |
1614 PurpleMediaStream *stream = streams->data; | |
1615 | |
1616 if (stream->session->type & PURPLE_MEDIA_RECV_AUDIO | |
1617 && GST_IS_ELEMENT(stream->volume)) { | |
1618 g_object_set(stream->volume, "volume", level/10.0, NULL); | |
1619 } | |
1620 } | |
1621 #endif | |
1622 } | |
1623 | |
1624 gulong | |
1625 purple_media_set_output_window(PurpleMedia *media, const gchar *session_id, | |
1626 const gchar *participant, gulong window_id) | |
1627 { | |
1628 #ifdef USE_VV | |
1629 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE); | |
1630 | |
1631 return purple_media_manager_set_output_window(media->priv->manager, | |
1632 media, session_id, participant, window_id); | |
1633 #else | |
1634 return 0; | |
1635 #endif | |
1636 } | |
1637 | |
1638 void | |
1639 purple_media_remove_output_windows(PurpleMedia *media) | |
1640 { | |
1641 #ifdef USE_VV | |
1642 GList *iter = media->priv->streams; | |
1643 for (; iter; iter = g_list_next(iter)) { | |
1644 PurpleMediaStream *stream = iter->data; | |
1645 purple_media_manager_remove_output_windows( | |
1646 media->priv->manager, media, | |
1647 stream->session->id, stream->participant); | |
1648 } | |
1649 | |
1650 iter = purple_media_get_session_ids(media); | |
1651 for (; iter; iter = g_list_delete_link(iter, iter)) { | |
1652 gchar *session_name = iter->data; | |
1653 purple_media_manager_remove_output_windows( | |
1654 media->priv->manager, media, | |
1655 session_name, NULL); | |
1656 } | |
1657 #endif | |
1658 } | |
1659 | |
1660 #ifdef USE_GSTREAMER | |
1661 GstElement * | |
1662 purple_media_get_tee(PurpleMedia *media, | |
1663 const gchar *session_id, const gchar *participant) | |
1664 { | |
1665 #ifdef USE_VV | |
1666 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); | |
1667 | |
1668 if (session_id != NULL && participant == NULL) { | |
1669 PurpleMediaSession *session = | |
1670 purple_media_get_session(media, session_id); | |
1671 return (session != NULL) ? session->tee : NULL; | |
1672 } else if (session_id != NULL && participant != NULL) { | |
1673 PurpleMediaStream *stream = | |
1674 purple_media_get_stream(media, | |
1675 session_id, participant); | |
1676 return (stream != NULL) ? stream->tee : NULL; | |
1677 } | |
1678 g_return_val_if_reached(NULL); | |
1679 #else | |
1680 return NULL; | |
1681 #endif | |
1682 } | |
1683 #endif /* USE_GSTREAMER */ | |
1684 |