annotate libpurple/media/media.c @ 29566:f600903f7811

Transfer creating Farsight 2 streams to the Fs2 media backend.
author maiku@pidgin.im
date Mon, 26 Oct 2009 21:35:11 +0000
parents eef5ec04a5bf
children 983af0970bb2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1 /**
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2 * @file media.c Media API
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
3 * @ingroup core
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
4 */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
5
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
6 /* purple
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
7 *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
8 * Purple is the legal property of its developers, whose names are too numerous
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
9 * to list here. Please refer to the COPYRIGHT file distributed with this
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
10 * source distribution.
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
11 *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
12 * This program is free software; you can redistribute it and/or modify
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
15 * (at your option) any later version.
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
16 *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
20 * GNU General Public License for more details.
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
21 *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
23 * along with this program; if not, write to the Free Software
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
25 */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
26
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
27 #include <string.h>
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
28
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
29 #include "internal.h"
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
30
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
31 #include "account.h"
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
35 #include "mediamanager.h"
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
36 #include "network.h"
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
37
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
38 #include "debug.h"
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
39
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
40 #ifdef USE_GSTREAMER
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
41 #include "marshallers.h"
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
42 #include "media-gst.h"
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
43 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
44
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
45 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
46
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
47 #include <gst/farsight/fs-conference-iface.h>
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
48 #include <gst/farsight/fs-element-added-notifier.h>
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
49
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
50 /** @copydoc _PurpleMediaSession */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
51 typedef struct _PurpleMediaSession PurpleMediaSession;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
52 /** @copydoc _PurpleMediaStream */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
53 typedef struct _PurpleMediaStream PurpleMediaStream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
54 /** @copydoc _PurpleMediaClass */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
55 typedef struct _PurpleMediaClass PurpleMediaClass;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
56 /** @copydoc _PurpleMediaPrivate */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
57 typedef struct _PurpleMediaPrivate PurpleMediaPrivate;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
58
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
59 /** The media class */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
60 struct _PurpleMediaClass
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
61 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
62 GObjectClass parent_class; /**< The parent class. */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
63 };
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
64
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
65 /** The media class's private data */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
66 struct _PurpleMedia
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
67 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
68 GObject parent; /**< The parent of this object. */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
69 PurpleMediaPrivate *priv; /**< The private data of this object. */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
70 };
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
71
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
72 struct _PurpleMediaSession
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
73 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
74 gchar *id;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
75 PurpleMedia *media;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
76 GstElement *src;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
77 GstElement *tee;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
78 FsSession *session;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
79
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
80 PurpleMediaSessionType type;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
81 gboolean initiator;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
82 };
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
83
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
84 struct _PurpleMediaStream
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
85 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
86 PurpleMediaSession *session;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
87 gchar *participant;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
88 FsStream *stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
89 GstElement *src;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
90 GstElement *tee;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
91 GstElement *volume;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
92 GstElement *level;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
93
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
94 GList *local_candidates;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
95 GList *remote_candidates;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
96
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
97 gboolean initiator;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
98 gboolean accepted;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
99 gboolean candidates_prepared;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
100
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
101 GList *active_local_candidates;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
102 GList *active_remote_candidates;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
103
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
104 guint connected_cb_id;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
105 };
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
106 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
107
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
108 struct _PurpleMediaPrivate
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
109 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
110 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
111 PurpleMediaManager *manager;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
117 gboolean initiator;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
118 gpointer prpl_data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
119
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
120 GHashTable *sessions; /* PurpleMediaSession table */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
121
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
122 GList *streams; /* PurpleMediaStream table */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
123
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
124 GstElement *confbin;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
125 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
126 gpointer dummy;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
127 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
128 };
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
129
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
130 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
131 #define PURPLE_MEDIA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_MEDIA, PurpleMediaPrivate))
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
132
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
133 static void purple_media_class_init (PurpleMediaClass *klass);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
134 static void purple_media_init (PurpleMedia *media);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
135 static void purple_media_dispose (GObject *object);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
136 static void purple_media_finalize (GObject *object);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
137 static void purple_media_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
138 static void purple_media_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
153 static gboolean media_bus_call(GstBus *bus,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
154 GstMessage *msg, PurpleMedia *media);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
155
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
156 static GObjectClass *parent_class = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
157
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
158
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
159
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
160 enum {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
161 S_ERROR,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
162 CANDIDATES_PREPARED,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
163 CODECS_CHANGED,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
164 LEVEL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
165 NEW_CANDIDATE,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
166 STATE_CHANGED,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
167 STREAM_INFO,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
168 LAST_SIGNAL
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
169 };
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
170 static guint purple_media_signals[LAST_SIGNAL] = {0};
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
171
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
172 enum {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
173 PROP_0,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
174 PROP_MANAGER,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
175 PROP_ACCOUNT,
29550
846a475a1573 Deprecate the conference property of PurpleMedia.
maiku@pidgin.im
parents: 29549
diff changeset
176 #ifndef PURPLE_DISABLE_DEPRECATED
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
180 PROP_INITIATOR,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
181 PROP_PRPL_DATA,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
182 };
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
183 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
184
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
185
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
186 GType
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
187 purple_media_get_type()
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
188 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
189 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
190 static GType type = 0;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
191
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
192 if (type == 0) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
193 static const GTypeInfo info = {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
194 sizeof(PurpleMediaClass),
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
195 NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
196 NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
197 (GClassInitFunc) purple_media_class_init,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
198 NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
199 NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
200 sizeof(PurpleMedia),
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
201 0,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
202 (GInstanceInitFunc) purple_media_init,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
203 NULL
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
204 };
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
205 type = g_type_register_static(G_TYPE_OBJECT, "PurpleMedia", &info, 0);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
206 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
207 return type;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
208 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
209 return G_TYPE_NONE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
210 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
211 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
212
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
213 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
214 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
215 purple_media_class_init (PurpleMediaClass *klass)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
216 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
217 GObjectClass *gobject_class = (GObjectClass*)klass;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
218 parent_class = g_type_class_peek_parent(klass);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
219
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
220 gobject_class->dispose = purple_media_dispose;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
221 gobject_class->finalize = purple_media_finalize;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
222 gobject_class->set_property = purple_media_set_property;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
223 gobject_class->get_property = purple_media_get_property;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
224
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
225 g_object_class_install_property(gobject_class, PROP_MANAGER,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
226 g_param_spec_object("manager",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
227 "Purple Media Manager",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
228 "The media manager that contains this media session.",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
229 PURPLE_TYPE_MEDIA_MANAGER,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
230 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
231
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
232 g_object_class_install_property(gobject_class, PROP_ACCOUNT,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
233 g_param_spec_pointer("account",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
234 "PurpleAccount",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
235 "The account this media session is on.",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
236 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
237
29550
846a475a1573 Deprecate the conference property of PurpleMedia.
maiku@pidgin.im
parents: 29549
diff changeset
238 #ifndef PURPLE_DISABLE_DEPRECATED
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
239 g_object_class_install_property(gobject_class, PROP_CONFERENCE,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
240 g_param_spec_object("conference",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
241 "Farsight conference",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
242 "The FsConference associated with this media.",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
243 FS_TYPE_CONFERENCE,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
255 g_object_class_install_property(gobject_class, PROP_INITIATOR,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
256 g_param_spec_boolean("initiator",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
257 "initiator",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
258 "If the local user initiated the conference.",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
259 FALSE,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
260 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
261
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
262 g_object_class_install_property(gobject_class, PROP_PRPL_DATA,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
263 g_param_spec_pointer("prpl-data",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
264 "gpointer",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
265 "Data the prpl plugin set on the media session.",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
266 G_PARAM_READWRITE));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
267
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
268 purple_media_signals[S_ERROR] = g_signal_new("error", G_TYPE_FROM_CLASS(klass),
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
269 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
270 g_cclosure_marshal_VOID__STRING,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
271 G_TYPE_NONE, 1, G_TYPE_STRING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
272 purple_media_signals[CANDIDATES_PREPARED] = g_signal_new("candidates-prepared", G_TYPE_FROM_CLASS(klass),
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
273 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
274 purple_smarshal_VOID__STRING_STRING,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
275 G_TYPE_NONE, 2, G_TYPE_STRING,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
276 G_TYPE_STRING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
277 purple_media_signals[CODECS_CHANGED] = g_signal_new("codecs-changed", G_TYPE_FROM_CLASS(klass),
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
278 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
279 g_cclosure_marshal_VOID__STRING,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
280 G_TYPE_NONE, 1, G_TYPE_STRING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
281 purple_media_signals[LEVEL] = g_signal_new("level", G_TYPE_FROM_CLASS(klass),
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
282 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
283 purple_smarshal_VOID__STRING_STRING_DOUBLE,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
284 G_TYPE_NONE, 3, G_TYPE_STRING,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
285 G_TYPE_STRING, G_TYPE_DOUBLE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
286 purple_media_signals[NEW_CANDIDATE] = g_signal_new("new-candidate", G_TYPE_FROM_CLASS(klass),
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
287 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
288 purple_smarshal_VOID__POINTER_POINTER_OBJECT,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
289 G_TYPE_NONE, 3, G_TYPE_POINTER,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
290 G_TYPE_POINTER, PURPLE_TYPE_MEDIA_CANDIDATE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
291 purple_media_signals[STATE_CHANGED] = g_signal_new("state-changed", G_TYPE_FROM_CLASS(klass),
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
292 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
293 purple_smarshal_VOID__ENUM_STRING_STRING,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
294 G_TYPE_NONE, 3, PURPLE_MEDIA_TYPE_STATE,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
295 G_TYPE_STRING, G_TYPE_STRING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
296 purple_media_signals[STREAM_INFO] = g_signal_new("stream-info", G_TYPE_FROM_CLASS(klass),
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
297 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
298 purple_smarshal_VOID__ENUM_STRING_STRING_BOOLEAN,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
299 G_TYPE_NONE, 4, PURPLE_MEDIA_TYPE_INFO_TYPE,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
300 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
301 g_type_class_add_private(klass, sizeof(PurpleMediaPrivate));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
302 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
303
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
304
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
305 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
306 purple_media_init (PurpleMedia *media)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
307 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
308 media->priv = PURPLE_MEDIA_GET_PRIVATE(media);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
309 memset(media->priv, 0, sizeof(*media->priv));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
310 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
311
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
312 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
313 purple_media_stream_free(PurpleMediaStream *stream)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
314 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
315 if (stream == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
316 return;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
317
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
318 /* Remove the connected_cb timeout */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
319 if (stream->connected_cb_id != 0)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
320 purple_timeout_remove(stream->connected_cb_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
321
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
322 g_free(stream->participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
323
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
328
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
335
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
336 g_free(stream);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
337 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
338
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
339 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
340 purple_media_session_free(PurpleMediaSession *session)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
341 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
342 if (session == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
343 return;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
344
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
345 g_free(session->id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
346 g_free(session);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
347 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
348
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
349 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
350 purple_media_dispose(GObject *media)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
351 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
352 PurpleMediaPrivate *priv = PURPLE_MEDIA_GET_PRIVATE(media);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
353 GList *iter = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
354
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
355 purple_debug_info("media","purple_media_dispose\n");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
356
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
357 purple_media_manager_remove_media(priv->manager, PURPLE_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
362 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
363
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
364 for (iter = priv->streams; iter; iter = g_list_next(iter)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
365 PurpleMediaStream *stream = iter->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
366 if (stream->stream) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
367 g_object_unref(stream->stream);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
368 stream->stream = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
369 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
370 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
373 GstElement *pipeline = purple_media_manager_get_pipeline(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
374 priv->manager);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
382 g_object_unref(priv->manager);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
383 priv->manager = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
384 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
385
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
386 G_OBJECT_CLASS(parent_class)->dispose(media);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
387 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
388
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
389 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
390 purple_media_finalize(GObject *media)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
391 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
392 PurpleMediaPrivate *priv = PURPLE_MEDIA_GET_PRIVATE(media);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
393 purple_debug_info("media","purple_media_finalize\n");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
394
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
395 for (; priv->streams; priv->streams = g_list_delete_link(priv->streams, priv->streams))
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
396 purple_media_stream_free(priv->streams->data);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
397
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
398 if (priv->sessions) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
399 GList *sessions = g_hash_table_get_values(priv->sessions);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
400 for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
401 purple_media_session_free(sessions->data);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
402 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
403 g_hash_table_destroy(priv->sessions);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
404 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
405
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
406 G_OBJECT_CLASS(parent_class)->finalize(media);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
407 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
408
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
409 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
410 purple_media_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
411 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
412 PurpleMedia *media;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
413 g_return_if_fail(PURPLE_IS_MEDIA(object));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
414
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
415 media = PURPLE_MEDIA(object);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
416
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
417 switch (prop_id) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
420 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
421 case PROP_ACCOUNT:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
422 media->priv->account = g_value_get_pointer(value);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
423 break;
29550
846a475a1573 Deprecate the conference property of PurpleMedia.
maiku@pidgin.im
parents: 29549
diff changeset
424 #ifndef PURPLE_DISABLE_DEPRECATED
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
425 case PROP_CONFERENCE: {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
426 if (media->priv->conference)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
429 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
463 case PROP_INITIATOR:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
464 media->priv->initiator = g_value_get_boolean(value);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
465 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
466 case PROP_PRPL_DATA:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
467 media->priv->prpl_data = g_value_get_pointer(value);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
468 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
469 default:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
470 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
471 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
472 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
473 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
474
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
475 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
476 purple_media_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
477 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
478 PurpleMedia *media;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
479 g_return_if_fail(PURPLE_IS_MEDIA(object));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
480
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
481 media = PURPLE_MEDIA(object);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
482
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
483 switch (prop_id) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
484 case PROP_MANAGER:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
485 g_value_set_object(value, media->priv->manager);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
486 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
487 case PROP_ACCOUNT:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
488 g_value_set_pointer(value, media->priv->account);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
489 break;
29550
846a475a1573 Deprecate the conference property of PurpleMedia.
maiku@pidgin.im
parents: 29549
diff changeset
490 #ifndef PURPLE_DISABLE_DEPRECATED
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
491 case PROP_CONFERENCE:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
492 g_value_set_object(value, media->priv->conference);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
499 case PROP_INITIATOR:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
500 g_value_set_boolean(value, media->priv->initiator);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
501 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
502 case PROP_PRPL_DATA:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
503 g_value_set_pointer(value, media->priv->prpl_data);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
504 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
505 default:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
506 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
507 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
508 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
509
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
510 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
511
29536
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
512 static FsCandidate *
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
513 purple_media_candidate_to_fs(PurpleMediaCandidate *candidate)
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
514 {
29536
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
515 FsCandidate *fscandidate;
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
516 gchar *foundation;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
517 guint component_id;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
518 gchar *ip;
29536
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
519 guint port;
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
520 gchar *base_ip;
29536
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
521 guint base_port;
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
522 PurpleMediaNetworkProtocol proto;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
523 guint32 priority;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
524 PurpleMediaCandidateType type;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
525 gchar *username;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
526 gchar *password;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
527 guint ttl;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
528
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
529 if (candidate == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
530 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
531
29536
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
532 g_object_get(G_OBJECT(candidate),
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
533 "foundation", &foundation,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
534 "component-id", &component_id,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
535 "ip", &ip,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
536 "port", &port,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
537 "base-ip", &base_ip,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
538 "base-port", &base_port,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
539 "protocol", &proto,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
540 "priority", &priority,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
541 "type", &type,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
542 "username", &username,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
543 "password", &password,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
544 "ttl", &ttl,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
545 NULL);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
546
29536
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
547 fscandidate = fs_candidate_new(foundation,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
548 component_id, type,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
549 proto, ip, port);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
550
29536
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
551 fscandidate->base_ip = base_ip;
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
552 fscandidate->base_port = base_port;
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
553 fscandidate->priority = priority;
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
554 fscandidate->username = username;
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
555 fscandidate->password = password;
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
556 fscandidate->ttl = ttl;
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
557
29536
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
558 g_free(foundation);
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
559 g_free(ip);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
560 return fscandidate;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
561 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
562
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
563 static GList *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
564 purple_media_candidate_list_to_fs(GList *candidates)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
565 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
566 GList *new_list = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
567
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
568 for (; candidates; candidates = g_list_next(candidates)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
569 new_list = g_list_prepend(new_list,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
570 purple_media_candidate_to_fs(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
571 candidates->data));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
572 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
573
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
574 new_list = g_list_reverse(new_list);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
575 return new_list;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
576 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
577
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
578 static FsMediaType
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
579 purple_media_to_fs_media_type(PurpleMediaSessionType type)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
580 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
581 if (type & PURPLE_MEDIA_AUDIO)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
582 return FS_MEDIA_TYPE_AUDIO;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
583 else if (type & PURPLE_MEDIA_VIDEO)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
584 return FS_MEDIA_TYPE_VIDEO;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
585 else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
586 return 0;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
587 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
588
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
589 static FsStreamDirection
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
590 purple_media_to_fs_stream_direction(PurpleMediaSessionType type)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
591 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
592 if ((type & PURPLE_MEDIA_AUDIO) == PURPLE_MEDIA_AUDIO ||
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
593 (type & PURPLE_MEDIA_VIDEO) == PURPLE_MEDIA_VIDEO)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
594 return FS_DIRECTION_BOTH;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
595 else if ((type & PURPLE_MEDIA_SEND_AUDIO) ||
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
596 (type & PURPLE_MEDIA_SEND_VIDEO))
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
597 return FS_DIRECTION_SEND;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
598 else if ((type & PURPLE_MEDIA_RECV_AUDIO) ||
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
599 (type & PURPLE_MEDIA_RECV_VIDEO))
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
600 return FS_DIRECTION_RECV;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
601 else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
602 return FS_DIRECTION_NONE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
603 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
604
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
605 static PurpleMediaSessionType
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
606 purple_media_from_fs(FsMediaType type, FsStreamDirection direction)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
607 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
608 PurpleMediaSessionType result = PURPLE_MEDIA_NONE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
609 if (type == FS_MEDIA_TYPE_AUDIO) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
610 if (direction & FS_DIRECTION_SEND)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
611 result |= PURPLE_MEDIA_SEND_AUDIO;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
612 if (direction & FS_DIRECTION_RECV)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
613 result |= PURPLE_MEDIA_RECV_AUDIO;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
614 } else if (type == FS_MEDIA_TYPE_VIDEO) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
615 if (direction & FS_DIRECTION_SEND)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
616 result |= PURPLE_MEDIA_SEND_VIDEO;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
617 if (direction & FS_DIRECTION_RECV)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
618 result |= PURPLE_MEDIA_RECV_VIDEO;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
619 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
620 return result;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
621 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
622
29538
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
623 static FsCodec *
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
624 purple_media_codec_to_fs(const PurpleMediaCodec *codec)
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
625 {
29538
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
626 FsCodec *new_codec;
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
627 gint id;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
628 char *encoding_name;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
629 PurpleMediaSessionType media_type;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
630 guint clock_rate;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
631 guint channels;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
632 GList *iter;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
633
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
634 if (codec == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
635 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
636
29538
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
637 g_object_get(G_OBJECT(codec),
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
638 "id", &id,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
639 "encoding-name", &encoding_name,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
640 "media-type", &media_type,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
641 "clock-rate", &clock_rate,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
642 "channels", &channels,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
643 "optional-params", &iter,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
644 NULL);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
645
29538
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
646 new_codec = fs_codec_new(id, encoding_name,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
647 purple_media_to_fs_media_type(media_type),
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
648 clock_rate);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
649 new_codec->channels = channels;
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
650
29538
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
651 for (; iter; iter = g_list_next(iter)) {
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
652 PurpleKeyValuePair *param = (PurpleKeyValuePair*)iter->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
653 fs_codec_add_optional_parameter(new_codec,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
654 param->key, param->value);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
655 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
656
29538
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
657 g_free(encoding_name);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
658 return new_codec;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
659 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
660
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
661 static PurpleMediaCodec *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
662 purple_media_codec_from_fs(const FsCodec *codec)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
663 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
664 PurpleMediaCodec *new_codec;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
665 GList *iter;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
666
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
667 if (codec == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
668 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
669
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
670 new_codec = purple_media_codec_new(codec->id, codec->encoding_name,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
671 purple_media_from_fs(codec->media_type,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
672 FS_DIRECTION_BOTH), codec->clock_rate);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
673 g_object_set(new_codec, "channels", codec->channels, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
674
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
675 for (iter = codec->optional_params; iter; iter = g_list_next(iter)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
676 FsCodecParameter *param = (FsCodecParameter*)iter->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
677 purple_media_codec_add_optional_parameter(new_codec,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
678 param->name, param->value);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
679 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
680
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
681 return new_codec;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
682 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
683
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
684 static GList *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
685 purple_media_codec_list_from_fs(GList *codecs)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
686 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
687 GList *new_list = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
688
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
689 for (; codecs; codecs = g_list_next(codecs)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
690 new_list = g_list_prepend(new_list,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
691 purple_media_codec_from_fs(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
692 codecs->data));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
693 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
694
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
695 new_list = g_list_reverse(new_list);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
696 return new_list;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
697 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
698
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
699 static GList *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
700 purple_media_codec_list_to_fs(GList *codecs)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
701 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
702 GList *new_list = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
703
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
704 for (; codecs; codecs = g_list_next(codecs)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
705 new_list = g_list_prepend(new_list,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
706 purple_media_codec_to_fs(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
707 codecs->data));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
708 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
709
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
710 new_list = g_list_reverse(new_list);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
711 return new_list;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
712 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
713
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
714 static PurpleMediaSession*
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
715 purple_media_get_session(PurpleMedia *media, const gchar *sess_id)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
716 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
717 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
718 return (PurpleMediaSession*) (media->priv->sessions) ?
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
719 g_hash_table_lookup(media->priv->sessions, sess_id) : NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
720 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
721
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
722 static PurpleMediaStream*
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
723 purple_media_get_stream(PurpleMedia *media, const gchar *session, const gchar *participant)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
724 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
725 GList *streams;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
726
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
727 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
728
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
729 streams = media->priv->streams;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
730
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
731 for (; streams; streams = g_list_next(streams)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
732 PurpleMediaStream *stream = streams->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
733 if (!strcmp(stream->session->id, session) &&
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
734 !strcmp(stream->participant, participant))
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
735 return stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
736 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
737
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
738 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
739 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
740
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
741 static GList *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
742 purple_media_get_streams(PurpleMedia *media, const gchar *session,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
743 const gchar *participant)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
744 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
745 GList *streams;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
746 GList *ret = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
747
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
748 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
749
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
750 streams = media->priv->streams;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
751
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
752 for (; streams; streams = g_list_next(streams)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
753 PurpleMediaStream *stream = streams->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
754 if ((session == NULL ||
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
755 !strcmp(stream->session->id, session)) &&
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
756 (participant == NULL ||
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
757 !strcmp(stream->participant, participant)))
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
758 ret = g_list_append(ret, stream);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
759 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
760
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
761 return ret;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
762 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
763
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
764 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
765 purple_media_add_session(PurpleMedia *media, PurpleMediaSession *session)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
766 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
767 g_return_if_fail(PURPLE_IS_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
768 g_return_if_fail(session != NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
769
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
770 if (!media->priv->sessions) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
771 purple_debug_info("media", "Creating hash table for sessions\n");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
772 media->priv->sessions = g_hash_table_new(g_str_hash, g_str_equal);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
773 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
774 g_hash_table_insert(media->priv->sessions, g_strdup(session->id), session);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
775 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
776
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
777 static gboolean
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
778 purple_media_remove_session(PurpleMedia *media, PurpleMediaSession *session)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
779 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
780 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
781 return g_hash_table_remove(media->priv->sessions, session->id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
782 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
783
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
784 static PurpleMediaStream *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
785 purple_media_insert_stream(PurpleMediaSession *session, const gchar *name, FsStream *stream)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
786 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
787 PurpleMediaStream *media_stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
788
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
789 g_return_val_if_fail(session != NULL, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
790
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
791 media_stream = g_new0(PurpleMediaStream, 1);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
792 media_stream->stream = stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
793 media_stream->participant = g_strdup(name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
794 media_stream->session = session;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
795
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
796 session->media->priv->streams =
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
797 g_list_append(session->media->priv->streams, media_stream);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
798
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
799 return media_stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
800 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
801
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
802 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
803 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
804 PurpleMediaCandidate *candidate)
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
805 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
806 PurpleMediaStream *stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
807
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
808 g_return_if_fail(session != NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
809
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
810 stream = purple_media_get_stream(session->media, session->id, name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
811 stream->local_candidates = g_list_append(stream->local_candidates, candidate);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
812 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
813 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
814
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
815 GList *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
816 purple_media_get_session_ids(PurpleMedia *media)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
817 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
818 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
819 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
820 return media->priv->sessions != NULL ?
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
821 g_hash_table_get_keys(media->priv->sessions) : NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
822 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
823 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
824 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
825 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
826
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
827 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
828 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
829 purple_media_set_src(PurpleMedia *media, const gchar *sess_id, GstElement *src)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
830 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
831 PurpleMediaSession *session;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
832 GstPad *sinkpad;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
833 GstPad *srcpad;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
834
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
835 g_return_if_fail(PURPLE_IS_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
836 g_return_if_fail(GST_IS_ELEMENT(src));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
837
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
838 session = purple_media_get_session(media, sess_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
839
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
840 if (session == NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
841 purple_debug_warning("media", "purple_media_set_src: trying"
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
842 " to set src on non-existent session\n");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
843 return;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
844 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
845
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
846 if (session->src)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
847 gst_object_unref(session->src);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
848 session->src = src;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
849 gst_element_set_locked_state(session->src, TRUE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
850
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
851 session->tee = gst_element_factory_make("tee", NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
852 gst_bin_add(GST_BIN(session->media->priv->confbin), session->tee);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
853
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
854 /* This supposedly isn't necessary, but it silences some warnings */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
855 if (GST_ELEMENT_PARENT(session->media->priv->confbin)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
856 == GST_ELEMENT_PARENT(session->src)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
857 GstPad *pad = gst_element_get_static_pad(session->tee, "sink");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
858 GstPad *ghost = gst_ghost_pad_new(NULL, pad);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
859 gst_object_unref(pad);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
860 gst_pad_set_active(ghost, TRUE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
861 gst_element_add_pad(session->media->priv->confbin, ghost);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
862 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
863
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
864 gst_element_set_state(session->tee, GST_STATE_PLAYING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
865 gst_element_link(session->src, session->media->priv->confbin);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
866
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
867 g_object_get(session->session, "sink-pad", &sinkpad, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
868 if (session->type & PURPLE_MEDIA_SEND_AUDIO) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
869 gchar *name = g_strdup_printf("volume_%s", session->id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
870 GstElement *level;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
871 GstElement *volume = gst_element_factory_make("volume", name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
872 double input_volume = purple_prefs_get_int(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
873 "/purple/media/audio/volume/input")/10.0;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
874 g_free(name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
875 name = g_strdup_printf("sendlevel_%s", session->id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
876 level = gst_element_factory_make("level", name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
877 g_free(name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
878 gst_bin_add(GST_BIN(session->media->priv->confbin), volume);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
879 gst_bin_add(GST_BIN(session->media->priv->confbin), level);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
880 gst_element_set_state(level, GST_STATE_PLAYING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
881 gst_element_set_state(volume, GST_STATE_PLAYING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
882 gst_element_link(volume, level);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
883 gst_element_link(session->tee, volume);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
884 srcpad = gst_element_get_static_pad(level, "src");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
885 g_object_set(volume, "volume", input_volume, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
886 } else {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
887 srcpad = gst_element_get_request_pad(session->tee, "src%d");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
888 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
889 purple_debug_info("media", "connecting pad: %s\n",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
890 gst_pad_link(srcpad, sinkpad) == GST_PAD_LINK_OK
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
891 ? "success" : "failure");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
892 gst_element_set_locked_state(session->src, FALSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
893 gst_object_unref(session->src);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
894 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
895 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
896
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
897 #ifdef USE_GSTREAMER
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
898 GstElement *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
899 purple_media_get_src(PurpleMedia *media, const gchar *sess_id)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
900 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
901 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
902 PurpleMediaSession *session;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
903 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
904 session = purple_media_get_session(media, sess_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
905 return (session != NULL) ? session->src : NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
906 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
907 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
908 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
909 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
910 #endif /* USE_GSTREAMER */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
911
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
912 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
913 static gboolean
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
914 media_bus_call(GstBus *bus, GstMessage *msg, PurpleMedia *media)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
915 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
916 switch(GST_MESSAGE_TYPE(msg)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
917 case GST_MESSAGE_ELEMENT: {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
918 if (g_signal_has_handler_pending(media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
919 purple_media_signals[LEVEL], 0, FALSE)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
920 && gst_structure_has_name(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
921 gst_message_get_structure(msg), "level")) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
922 GstElement *src = GST_ELEMENT(GST_MESSAGE_SRC(msg));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
923 gchar *name;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
924 gchar *participant = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
925 PurpleMediaSession *session = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
926 gdouble rms_db;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
927 gdouble percent;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
928 const GValue *list;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
929 const GValue *value;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
930
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
931 if (!PURPLE_IS_MEDIA(media) ||
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
932 GST_ELEMENT_PARENT(src) !=
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
933 media->priv->confbin)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
934 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
935
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
936 name = gst_element_get_name(src);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
937 if (!strncmp(name, "sendlevel_", 10)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
938 session = purple_media_get_session(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
939 media, name+10);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
940 } else {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
941 GList *iter = media->priv->streams;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
942 for (; iter; iter = g_list_next(iter)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
943 PurpleMediaStream *stream = iter->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
944 if (stream->level == src) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
945 session = stream->session;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
946 participant = stream->participant;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
947 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
948 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
949 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
950 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
951 g_free(name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
952 if (!session)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
953 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
954
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
955 list = gst_structure_get_value(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
956 gst_message_get_structure(msg), "rms");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
957 value = gst_value_list_get_value(list, 0);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
958 rms_db = g_value_get_double(value);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
959 percent = pow(10, rms_db / 20) * 5;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
960 if(percent > 1.0)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
961 percent = 1.0;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
962
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
963 g_signal_emit(media, purple_media_signals[LEVEL],
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
964 0, session->id, participant, percent);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
965 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
966 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
967 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
968 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
969 default:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
970 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
971 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
972
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
973 return TRUE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
974 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
975 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
976
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
977 PurpleAccount *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
978 purple_media_get_account(PurpleMedia *media)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
979 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
980 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
981 PurpleAccount *account;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
982 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
983 g_object_get(G_OBJECT(media), "account", &account, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
984 return account;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
985 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
986 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
987 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
988 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
989
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
990 gpointer
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
991 purple_media_get_prpl_data(PurpleMedia *media)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
992 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
993 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
994 gpointer prpl_data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
995 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
996 g_object_get(G_OBJECT(media), "prpl-data", &prpl_data, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
997 return prpl_data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
998 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
999 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1000 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1001 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1002
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1003 void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1004 purple_media_set_prpl_data(PurpleMedia *media, gpointer prpl_data)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1005 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1006 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1007 g_return_if_fail(PURPLE_IS_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1008 g_object_set(G_OBJECT(media), "prpl-data", prpl_data, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1009 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1010 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1011
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1012 void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1013 purple_media_error(PurpleMedia *media, const gchar *error, ...)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1014 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1015 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1016 va_list args;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1017 gchar *message;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1018
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1019 g_return_if_fail(PURPLE_IS_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1020
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1021 va_start(args, error);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1022 message = g_strdup_vprintf(error, args);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1023 va_end(args);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1024
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1025 purple_debug_error("media", "%s\n", message);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1026 g_signal_emit(media, purple_media_signals[S_ERROR], 0, message);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1027
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1028 g_free(message);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1029 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1030 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1031
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1032 void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1033 purple_media_end(PurpleMedia *media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1034 const gchar *session_id, const gchar *participant)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1035 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1036 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1037 g_return_if_fail(PURPLE_IS_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1038 if (session_id == NULL && participant == NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1039 g_signal_emit(media, purple_media_signals[STATE_CHANGED],
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1040 0, PURPLE_MEDIA_STATE_END,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1041 NULL, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1042 g_object_unref(media);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1043 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1044 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1045 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1046
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1047 void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1048 purple_media_stream_info(PurpleMedia *media, PurpleMediaInfoType type,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1049 const gchar *session_id, const gchar *participant,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1050 gboolean local)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1051 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1052 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1053 g_return_if_fail(PURPLE_IS_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1054
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1055 if (type == PURPLE_MEDIA_INFO_ACCEPT) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1056 GList *streams;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1057
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1058 g_return_if_fail(PURPLE_IS_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1059
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1060 streams = purple_media_get_streams(media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1061 session_id, participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1062
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1063 for (; streams; streams =
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1064 g_list_delete_link(streams, streams)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1065 PurpleMediaStream *stream = streams->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1066 g_object_set(G_OBJECT(stream->stream), "direction",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1067 purple_media_to_fs_stream_direction(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1068 stream->session->type), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1069 stream->accepted = TRUE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1070
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1071 if (stream->remote_candidates != NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1072 GError *err = NULL;
29560
18571ea6e44a Store remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents: 29559
diff changeset
1073 GList *candidates;
18571ea6e44a Store remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents: 29559
diff changeset
1074
18571ea6e44a Store remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents: 29559
diff changeset
1075 candidates = purple_media_candidate_list_to_fs(
18571ea6e44a Store remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents: 29559
diff changeset
1076 stream->remote_candidates);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1077 fs_stream_set_remote_candidates(stream->stream,
29560
18571ea6e44a Store remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents: 29559
diff changeset
1078 candidates, &err);
18571ea6e44a Store remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents: 29559
diff changeset
1079 fs_candidate_list_destroy(candidates);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1080
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1081 if (err) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1082 purple_debug_error("media", "Error adding remote"
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1083 " candidates: %s\n", err->message);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1084 g_error_free(err);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1085 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1086 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1087 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1088 } else if (local == TRUE && (type == PURPLE_MEDIA_INFO_MUTE ||
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1089 type == PURPLE_MEDIA_INFO_UNMUTE)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1090 GList *sessions;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1091 gboolean active = (type == PURPLE_MEDIA_INFO_MUTE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1092
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1093 g_return_if_fail(PURPLE_IS_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1094
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1095 if (session_id == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1096 sessions = g_hash_table_get_values(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1097 media->priv->sessions);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1098 else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1099 sessions = g_list_prepend(NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1100 purple_media_get_session(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1101 media, session_id));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1102
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1103 purple_debug_info("media", "Turning mute %s\n",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1104 active ? "on" : "off");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1105
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1106 for (; sessions; sessions = g_list_delete_link(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1107 sessions, sessions)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1108 PurpleMediaSession *session = sessions->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1109 if (session->type & PURPLE_MEDIA_SEND_AUDIO) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1110 gchar *name = g_strdup_printf("volume_%s",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1111 session->id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1112 GstElement *volume = gst_bin_get_by_name(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1113 GST_BIN(session->media->
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1114 priv->confbin), name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1115 g_free(name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1116 g_object_set(volume, "mute", active, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1117 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1118 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1119 } else if (local == TRUE && (type == PURPLE_MEDIA_INFO_PAUSE ||
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1120 type == PURPLE_MEDIA_INFO_UNPAUSE)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1121 gboolean active = (type == PURPLE_MEDIA_INFO_PAUSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1122 GList *streams = purple_media_get_streams(media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1123 session_id, participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1124 for (; streams; streams = g_list_delete_link(streams, streams)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1125 PurpleMediaStream *stream = streams->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1126 if (stream->session->type & PURPLE_MEDIA_SEND_VIDEO) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1127 g_object_set(stream->stream, "direction",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1128 purple_media_to_fs_stream_direction(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1129 stream->session->type & ((active) ?
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1130 ~PURPLE_MEDIA_SEND_VIDEO :
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1131 PURPLE_MEDIA_VIDEO)), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1132 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1133 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1134 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1135
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1136 g_signal_emit(media, purple_media_signals[STREAM_INFO],
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1137 0, type, session_id, participant, local);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1138
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1139 if (type == PURPLE_MEDIA_INFO_HANGUP ||
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1140 type == PURPLE_MEDIA_INFO_REJECT) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1141 purple_media_end(media, session_id, participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1142 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1143 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1144 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1145
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1146 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1147 static void
29554
2460e6774e08 Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents: 29553
diff changeset
1148 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
1149 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
1150 PurpleMediaCandidate *candidate, PurpleMedia *media)
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1151 {
29554
2460e6774e08 Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents: 29553
diff changeset
1152 PurpleMediaSession *session =
2460e6774e08 Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents: 29553
diff changeset
1153 purple_media_get_session(media, sess_id);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1154
29554
2460e6774e08 Move handling Farsight 2's new-local-candidate signal in Fs2 media backend.
maiku@pidgin.im
parents: 29553
diff changeset
1155 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
1156 purple_media_candidate_copy(candidate));
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1157
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1158 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
1159 0, session->id, participant, candidate);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1160 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1161
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1162 static void
29557
1fdc75c94c22 Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents: 29556
diff changeset
1163 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
1164 const gchar *sess_id, const gchar *name, PurpleMedia *media)
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1165 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1166 PurpleMediaStream *stream_data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1167
29557
1fdc75c94c22 Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents: 29556
diff changeset
1168 g_return_if_fail(PURPLE_IS_MEDIA(media));
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1169
29557
1fdc75c94c22 Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents: 29556
diff changeset
1170 stream_data = purple_media_get_stream(media, sess_id, name);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1171 stream_data->candidates_prepared = TRUE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1172
29557
1fdc75c94c22 Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.
maiku@pidgin.im
parents: 29556
diff changeset
1173 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
1174 0, sess_id, name);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1175 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1176
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1177 /* callback called when a pair of transport candidates (local and remote)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1178 * has been established */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1179 static void
29556
74e75fc3481e Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents: 29555
diff changeset
1180 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
1181 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
1182 PurpleMediaCandidate *local_candidate,
74e75fc3481e Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents: 29555
diff changeset
1183 PurpleMediaCandidate *remote_candidate,
74e75fc3481e Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents: 29555
diff changeset
1184 PurpleMedia *media)
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1185 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1186 PurpleMediaStream *stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1187 GList *iter;
29556
74e75fc3481e Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents: 29555
diff changeset
1188 guint id;
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1189
29556
74e75fc3481e Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents: 29555
diff changeset
1190 g_return_if_fail(PURPLE_IS_MEDIA(media));
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1191
29556
74e75fc3481e Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents: 29555
diff changeset
1192 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
1193 id = purple_media_candidate_get_component_id(local_candidate);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1194
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1195 iter = stream->active_local_candidates;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1196 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
1197 PurpleMediaCandidate *c = iter->data;
7713312c4ab0 Store active_local_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents: 29560
diff changeset
1198 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
1199 g_object_unref(c);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1200 stream->active_local_candidates =
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1201 g_list_delete_link(iter, iter);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1202 stream->active_local_candidates = g_list_prepend(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1203 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
1204 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
1205 local_candidate));
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1206 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1207 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1208 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1209 if (iter == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1210 stream->active_local_candidates = g_list_prepend(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1211 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
1212 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
1213 local_candidate));
74e75fc3481e Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents: 29555
diff changeset
1214
74e75fc3481e Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
maiku@pidgin.im
parents: 29555
diff changeset
1215 id = purple_media_candidate_get_component_id(local_candidate);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1216
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1217 iter = stream->active_remote_candidates;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1218 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
1219 PurpleMediaCandidate *c = iter->data;
1156bf88b4d3 Store active_remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents: 29561
diff changeset
1220 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
1221 g_object_unref(c);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1222 stream->active_remote_candidates =
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1223 g_list_delete_link(iter, iter);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1224 stream->active_remote_candidates = g_list_prepend(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1225 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
1226 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
1227 remote_candidate));
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1228 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1229 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1230 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1231 if (iter == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1232 stream->active_remote_candidates = g_list_prepend(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1233 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
1234 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
1235 remote_candidate));
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1236
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1237 purple_debug_info("media", "candidate pair established\n");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1238 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1239
29555
cc978a1a4bd1 Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents: 29554
diff changeset
1240 static void
cc978a1a4bd1 Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents: 29554
diff changeset
1241 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
1242 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
1243 {
cc978a1a4bd1 Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents: 29554
diff changeset
1244 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
1245 }
cc978a1a4bd1 Move handling Farsight 2's codecs-changed signal into the Fs2 media backend.
maiku@pidgin.im
parents: 29554
diff changeset
1246
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1247 static gboolean
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1248 purple_media_connected_cb(PurpleMediaStream *stream)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1249 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1250 g_return_val_if_fail(stream != NULL, FALSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1251
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1252 stream->connected_cb_id = 0;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1253
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1254 purple_media_manager_create_output_window(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1255 stream->session->media->priv->manager,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1256 stream->session->media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1257 stream->session->id, stream->participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1258
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1259 g_signal_emit(stream->session->media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1260 purple_media_signals[STATE_CHANGED],
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1261 0, PURPLE_MEDIA_STATE_CONNECTED,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1262 stream->session->id, stream->participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1263 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1264 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1265
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1266 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1267 purple_media_src_pad_added_cb(FsStream *fsstream, GstPad *srcpad,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1268 FsCodec *codec, PurpleMediaStream *stream)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1269 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1270 PurpleMediaPrivate *priv;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1271 GstPad *sinkpad;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1272
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1273 g_return_if_fail(FS_IS_STREAM(fsstream));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1274 g_return_if_fail(stream != NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1275
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1276 priv = stream->session->media->priv;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1277
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1278 if (stream->src == NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1279 GstElement *sink = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1280
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1281 if (codec->media_type == FS_MEDIA_TYPE_AUDIO) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1282 GstElement *queue = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1283 double output_volume = purple_prefs_get_int(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1284 "/purple/media/audio/volume/output")/10.0;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1285 /*
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1286 * Should this instead be:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1287 * audioconvert ! audioresample ! liveadder !
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1288 * audioresample ! audioconvert ! realsink
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1289 */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1290 queue = gst_element_factory_make("queue", NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1291 stream->volume = gst_element_factory_make(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1292 "volume", NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1293 g_object_set(stream->volume, "volume",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1294 output_volume, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1295 stream->level = gst_element_factory_make(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1296 "level", NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1297 stream->src = gst_element_factory_make(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1298 "liveadder", NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1299 sink = purple_media_manager_get_element(priv->manager,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1300 PURPLE_MEDIA_RECV_AUDIO,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1301 stream->session->media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1302 stream->session->id,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1303 stream->participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1304 gst_bin_add(GST_BIN(priv->confbin), queue);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1305 gst_bin_add(GST_BIN(priv->confbin), stream->volume);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1306 gst_bin_add(GST_BIN(priv->confbin), stream->level);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1307 gst_bin_add(GST_BIN(priv->confbin), sink);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1308 gst_element_set_state(sink, GST_STATE_PLAYING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1309 gst_element_set_state(stream->level, GST_STATE_PLAYING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1310 gst_element_set_state(stream->volume, GST_STATE_PLAYING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1311 gst_element_set_state(queue, GST_STATE_PLAYING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1312 gst_element_link(stream->level, sink);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1313 gst_element_link(stream->volume, stream->level);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1314 gst_element_link(queue, stream->volume);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1315 sink = queue;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1316 } else if (codec->media_type == FS_MEDIA_TYPE_VIDEO) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1317 stream->src = gst_element_factory_make(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1318 "fsfunnel", NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1319 sink = gst_element_factory_make(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1320 "fakesink", NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1321 g_object_set(G_OBJECT(sink), "async", FALSE, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1322 gst_bin_add(GST_BIN(priv->confbin), sink);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1323 gst_element_set_state(sink, GST_STATE_PLAYING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1324 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1325 stream->tee = gst_element_factory_make("tee", NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1326 gst_bin_add_many(GST_BIN(priv->confbin),
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1327 stream->src, stream->tee, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1328 gst_element_set_state(stream->tee, GST_STATE_PLAYING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1329 gst_element_set_state(stream->src, GST_STATE_PLAYING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1330 gst_element_link_many(stream->src, stream->tee, sink, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1331 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1332
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1333 sinkpad = gst_element_get_request_pad(stream->src, "sink%d");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1334 gst_pad_link(srcpad, sinkpad);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1335 gst_object_unref(sinkpad);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1336
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1337 stream->connected_cb_id = purple_timeout_add(0,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1338 (GSourceFunc)purple_media_connected_cb, stream);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1339 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1340 #endif /* USE_VV */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1341
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1342 gboolean
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1343 purple_media_add_stream(PurpleMedia *media, const gchar *sess_id,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1344 const gchar *who, PurpleMediaSessionType type,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1345 gboolean initiator, const gchar *transmitter,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1346 guint num_params, GParameter *params)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1347 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1348 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1349 PurpleMediaSession *session;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1350 FsParticipant *participant = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1351 PurpleMediaStream *stream = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1352 FsMediaType media_type = purple_media_to_fs_media_type(type);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1353 FsStreamDirection type_direction =
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1354 purple_media_to_fs_stream_direction(type);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1355
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1356 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1357
29551
e85df0170905 Decouple the media_bus_call from the backend. It will still be needed even
maiku@pidgin.im
parents: 29550
diff changeset
1358 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
1359 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
1360 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
1361 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
1362 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
1363 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
1364 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
1365 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
1366 }
e85df0170905 Decouple the media_bus_call from the backend. It will still be needed even
maiku@pidgin.im
parents: 29550
diff changeset
1367
29549
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1368 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
1369 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
1370 num_params, params)) {
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1371 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
1372 return FALSE;
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1373 }
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1374
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1375 /* 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
1376 if (media->priv->conference == NULL) {
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1377 media->priv->conference =
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1378 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
1379 PURPLE_MEDIA_BACKEND_FS2(
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1380 media->priv->backend));
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1381 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
1382 media->priv->conference);
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1383 }
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1384
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1385 session = purple_media_get_session(media, sess_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1386
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1387 if (!session) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1388 PurpleMediaSessionType session_type;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1389 GstElement *src = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1390
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1391 session = g_new0(PurpleMediaSession, 1);
29553
efeb21092ed2 Begin transferring FsSession over to the Farsight 2 media backend.
maiku@pidgin.im
parents: 29552
diff changeset
1392 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
1393 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
1394 sess_id);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1395 session->id = g_strdup(sess_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1396 session->media = media;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1397 session->type = type;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1398 session->initiator = initiator;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1399
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1400 purple_media_add_session(media, session);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1401 g_signal_emit(media, purple_media_signals[STATE_CHANGED],
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1402 0, PURPLE_MEDIA_STATE_NEW,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1403 session->id, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1404
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1405 if (type_direction & FS_DIRECTION_SEND) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1406 session_type = purple_media_from_fs(media_type,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1407 FS_DIRECTION_SEND);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1408 src = purple_media_manager_get_element(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1409 media->priv->manager, session_type,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1410 media, session->id, who);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1411 if (!GST_IS_ELEMENT(src)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1412 purple_debug_error("media",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1413 "Error creating src for session %s\n",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1414 session->id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1415 purple_media_end(media, session->id, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1416 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1417 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1418
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1419 purple_media_set_src(media, session->id, src);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1420 gst_element_set_state(session->src, GST_STATE_PLAYING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1421 purple_media_manager_create_output_window(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1422 media->priv->manager,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1423 session->media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1424 session->id, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1425 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1426 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1427
29565
eef5ec04a5bf Remove the list of participants from PurpleMedia and use the Fs2 backend's.
maiku@pidgin.im
parents: 29562
diff changeset
1428 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
1429 PURPLE_MEDIA_BACKEND_FS2(media->priv->backend), who);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1430
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1431 stream = purple_media_get_stream(media, sess_id, who);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1432
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1433 if (!stream) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1434 FsStream *fsstream = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1435
29566
f600903f7811 Transfer creating Farsight 2 streams to the Fs2 media backend.
maiku@pidgin.im
parents: 29565
diff changeset
1436 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
1437 PURPLE_MEDIA_BACKEND_FS2(
f600903f7811 Transfer creating Farsight 2 streams to the Fs2 media backend.
maiku@pidgin.im
parents: 29565
diff changeset
1438 media->priv->backend), sess_id, who);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1439
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1440 stream = purple_media_insert_stream(session, who, fsstream);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1441 stream->initiator = initiator;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1442
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1443 /* callback for source pad added (new stream source ready) */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1444 g_signal_connect(G_OBJECT(fsstream),
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1445 "src-pad-added", G_CALLBACK(purple_media_src_pad_added_cb), stream);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1446
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1447 g_signal_emit(media, purple_media_signals[STATE_CHANGED],
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1448 0, PURPLE_MEDIA_STATE_NEW,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1449 session->id, who);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1450 } else {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1451 if (purple_media_to_fs_stream_direction(stream->session->type)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1452 != type_direction) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1453 /* change direction */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1454 g_object_set(stream->stream, "direction",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1455 type_direction, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1456 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1457 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1458
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1459 return TRUE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1460 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1461 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1462 #endif /* USE_VV */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1463 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1464
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1465 PurpleMediaManager *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1466 purple_media_get_manager(PurpleMedia *media)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1467 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1468 PurpleMediaManager *ret;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1469 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1470 g_object_get(media, "manager", &ret, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1471 return ret;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1472 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1473
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1474 PurpleMediaSessionType
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1475 purple_media_get_session_type(PurpleMedia *media, const gchar *sess_id)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1476 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1477 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1478 PurpleMediaSession *session;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1479 g_return_val_if_fail(PURPLE_IS_MEDIA(media), PURPLE_MEDIA_NONE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1480 session = purple_media_get_session(media, sess_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1481 return session->type;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1482 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1483 return PURPLE_MEDIA_NONE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1484 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1485 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1486 /* XXX: Should wait until codecs-ready is TRUE before using this function */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1487 GList *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1488 purple_media_get_codecs(PurpleMedia *media, const gchar *sess_id)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1489 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1490 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1491 GList *fscodecs;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1492 GList *codecs;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1493 PurpleMediaSession *session;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1494
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1495 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1496
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1497 session = purple_media_get_session(media, sess_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1498
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1499 if (session == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1500 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1501
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1502 g_object_get(G_OBJECT(session->session),
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1503 "codecs", &fscodecs, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1504 codecs = purple_media_codec_list_from_fs(fscodecs);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1505 fs_codec_list_destroy(fscodecs);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1506 return codecs;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1507 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1508 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1509 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1510 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1511
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1512 GList *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1513 purple_media_get_local_candidates(PurpleMedia *media, const gchar *sess_id,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1514 const gchar *participant)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1515 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1516 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1517 PurpleMediaStream *stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1518 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1519 stream = purple_media_get_stream(media, sess_id, participant);
29559
cb843608e183 Store local_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents: 29557
diff changeset
1520 return stream ? purple_media_candidate_list_copy(
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1521 stream->local_candidates) : NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1522 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1523 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1524 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1525 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1526
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1527 void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1528 purple_media_add_remote_candidates(PurpleMedia *media, const gchar *sess_id,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1529 const gchar *participant,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1530 GList *remote_candidates)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1531 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1532 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1533 PurpleMediaStream *stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1534 GError *err = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1535
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1536 g_return_if_fail(PURPLE_IS_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1537 stream = purple_media_get_stream(media, sess_id, participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1538
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1539 if (stream == NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1540 purple_debug_error("media",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1541 "purple_media_add_remote_candidates: "
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1542 "couldn't find stream %s %s.\n",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1543 sess_id ? sess_id : "(null)",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1544 participant ? participant : "(null)");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1545 return;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1546 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1547
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1548 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
1549 purple_media_candidate_list_copy(remote_candidates));
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1550
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1551 if (stream->accepted == TRUE) {
29560
18571ea6e44a Store remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents: 29559
diff changeset
1552 GList *candidates = purple_media_candidate_list_to_fs(
18571ea6e44a Store remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents: 29559
diff changeset
1553 stream->remote_candidates);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1554 fs_stream_set_remote_candidates(stream->stream,
29560
18571ea6e44a Store remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents: 29559
diff changeset
1555 candidates, &err);
18571ea6e44a Store remote_candidates in PurpleMedia as a GList of PurpleMediaCandidate's.
maiku@pidgin.im
parents: 29559
diff changeset
1556 fs_candidate_list_destroy(candidates);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1557
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1558 if (err) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1559 purple_debug_error("media", "Error adding remote"
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1560 " candidates: %s\n", err->message);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1561 g_error_free(err);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1562 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1563 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1564 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1565 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1566
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1567 #if 0
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1568 /*
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1569 * These two functions aren't being used and I'd rather not lock in the API
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1570 * until they are needed. If they ever are.
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1571 */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1572
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1573 GList *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1574 purple_media_get_active_local_candidates(PurpleMedia *media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1575 const gchar *sess_id, const gchar *participant)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1576 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1577 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1578 PurpleMediaStream *stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1579 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1580 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
1581 return purple_media_candidate_list_copy(
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1582 stream->active_local_candidates);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1583 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1584 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1585 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1586 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1587
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1588 GList *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1589 purple_media_get_active_remote_candidates(PurpleMedia *media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1590 const gchar *sess_id, const gchar *participant)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1591 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1592 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1593 PurpleMediaStream *stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1594 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1595 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
1596 return purple_media_candidate_list_copy(
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1597 stream->active_remote_candidates);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1598 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1599 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1600 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1601 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1602 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1603
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1604 gboolean
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1605 purple_media_set_remote_codecs(PurpleMedia *media, const gchar *sess_id,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1606 const gchar *participant, GList *codecs)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1607 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1608 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1609 PurpleMediaStream *stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1610 FsStream *fsstream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1611 GList *fscodecs;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1612 GError *err = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1613
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1614 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1615 stream = purple_media_get_stream(media, sess_id, participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1616
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1617 if (stream == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1618 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1619
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1620 fsstream = stream->stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1621 fscodecs = purple_media_codec_list_to_fs(codecs);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1622 fs_stream_set_remote_codecs(fsstream, fscodecs, &err);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1623 fs_codec_list_destroy(fscodecs);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1624
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1625 if (err) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1626 purple_debug_error("media", "Error setting remote codecs: %s\n",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1627 err->message);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1628 g_error_free(err);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1629 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1630 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1631 return TRUE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1632 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1633 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1634 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1635 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1636
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1637 gboolean
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1638 purple_media_candidates_prepared(PurpleMedia *media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1639 const gchar *session_id, const gchar *participant)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1640 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1641 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1642 GList *streams;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1643 gboolean prepared = TRUE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1644
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1645 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1646
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1647 streams = purple_media_get_streams(media, session_id, participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1648
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1649 for (; streams; streams = g_list_delete_link(streams, streams)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1650 PurpleMediaStream *stream = streams->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1651 if (stream->candidates_prepared == FALSE) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1652 g_list_free(streams);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1653 prepared = FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1654 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1655 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1656 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1657
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1658 return prepared;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1659 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1660 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1661 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1662 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1663
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1664 gboolean
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1665 purple_media_set_send_codec(PurpleMedia *media, const gchar *sess_id, PurpleMediaCodec *codec)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1666 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1667 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1668 PurpleMediaSession *session;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1669 FsCodec *fscodec;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1670 GError *err = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1671
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1672 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1673
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1674 session = purple_media_get_session(media, sess_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1675
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1676 if (session != NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1677 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1678
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1679 fscodec = purple_media_codec_to_fs(codec);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1680 fs_session_set_send_codec(session->session, fscodec, &err);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1681 fs_codec_destroy(fscodec);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1682
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1683 if (err) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1684 purple_debug_error("media", "Error setting send codec\n");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1685 g_error_free(err);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1686 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1687 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1688 return TRUE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1689 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1690 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1691 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1692 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1693
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1694 gboolean
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1695 purple_media_codecs_ready(PurpleMedia *media, const gchar *sess_id)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1696 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1697 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1698 gboolean ret;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1699
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1700 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1701
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1702 if (sess_id != NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1703 PurpleMediaSession *session;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1704 session = purple_media_get_session(media, sess_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1705
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1706 if (session == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1707 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1708 if (session->type & (PURPLE_MEDIA_SEND_AUDIO |
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1709 PURPLE_MEDIA_SEND_VIDEO))
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1710 g_object_get(session->session,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1711 "codecs-ready", &ret, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1712 else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1713 ret = TRUE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1714 } else {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1715 GList *values = g_hash_table_get_values(media->priv->sessions);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1716 for (; values; values = g_list_delete_link(values, values)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1717 PurpleMediaSession *session = values->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1718 if (session->type & (PURPLE_MEDIA_SEND_AUDIO |
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1719 PURPLE_MEDIA_SEND_VIDEO))
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1720 g_object_get(session->session,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1721 "codecs-ready", &ret, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1722 else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1723 ret = TRUE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1724
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1725 if (ret == FALSE)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1726 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1727 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1728 if (values != NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1729 g_list_free(values);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1730 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1731 return ret;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1732 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1733 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1734 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1735 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1736
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1737 gboolean
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1738 purple_media_is_initiator(PurpleMedia *media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1739 const gchar *sess_id, const gchar *participant)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1740 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1741 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1742 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1743
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1744 if (sess_id == NULL && participant == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1745 return media->priv->initiator;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1746 else if (sess_id != NULL && participant == NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1747 PurpleMediaSession *session =
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1748 purple_media_get_session(media, sess_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1749 return session != NULL ? session->initiator : FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1750 } else if (sess_id != NULL && participant != NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1751 PurpleMediaStream *stream = purple_media_get_stream(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1752 media, sess_id, participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1753 return stream != NULL ? stream->initiator : FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1754 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1755 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1756 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1757 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1758
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1759 gboolean
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1760 purple_media_accepted(PurpleMedia *media, const gchar *sess_id,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1761 const gchar *participant)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1762 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1763 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1764 gboolean accepted = TRUE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1765
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1766 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1767
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1768 if (sess_id == NULL && participant == NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1769 GList *streams = media->priv->streams;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1770
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1771 for (; streams; streams = g_list_next(streams)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1772 PurpleMediaStream *stream = streams->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1773 if (stream->accepted == FALSE) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1774 accepted = FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1775 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1776 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1777 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1778 } else if (sess_id != NULL && participant == NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1779 GList *streams = purple_media_get_streams(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1780 media, sess_id, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1781 for (; streams; streams =
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1782 g_list_delete_link(streams, streams)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1783 PurpleMediaStream *stream = streams->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1784 if (stream->accepted == FALSE) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1785 g_list_free(streams);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1786 accepted = FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1787 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1788 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1789 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1790 } else if (sess_id != NULL && participant != NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1791 PurpleMediaStream *stream = purple_media_get_stream(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1792 media, sess_id, participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1793 if (stream == NULL || stream->accepted == FALSE)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1794 accepted = FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1795 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1796
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1797 return accepted;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1798 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1799 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1800 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1801 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1802
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1803 void purple_media_set_input_volume(PurpleMedia *media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1804 const gchar *session_id, double level)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1805 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1806 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1807 GList *sessions;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1808
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1809 g_return_if_fail(PURPLE_IS_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1810
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1811 purple_prefs_set_int("/purple/media/audio/volume/input", level);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1812
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1813 if (session_id == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1814 sessions = g_hash_table_get_values(media->priv->sessions);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1815 else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1816 sessions = g_list_append(NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1817 purple_media_get_session(media, session_id));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1818
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1819 for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1820 PurpleMediaSession *session = sessions->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1821
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1822 if (session->type & PURPLE_MEDIA_SEND_AUDIO) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1823 gchar *name = g_strdup_printf("volume_%s",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1824 session->id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1825 GstElement *volume = gst_bin_get_by_name(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1826 GST_BIN(session->media->priv->confbin),
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1827 name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1828 g_free(name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1829 g_object_set(volume, "volume", level/10.0, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1830 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1831 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1832 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1833 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1834
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1835 void purple_media_set_output_volume(PurpleMedia *media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1836 const gchar *session_id, const gchar *participant,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1837 double level)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1838 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1839 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1840 GList *streams;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1841
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1842 g_return_if_fail(PURPLE_IS_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1843
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1844 purple_prefs_set_int("/purple/media/audio/volume/output", level);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1845
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1846 streams = purple_media_get_streams(media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1847 session_id, participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1848
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1849 for (; streams; streams = g_list_delete_link(streams, streams)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1850 PurpleMediaStream *stream = streams->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1851
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1852 if (stream->session->type & PURPLE_MEDIA_RECV_AUDIO
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1853 && GST_IS_ELEMENT(stream->volume)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1854 g_object_set(stream->volume, "volume", level/10.0, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1855 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1856 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1857 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1858 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1859
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1860 gulong
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1861 purple_media_set_output_window(PurpleMedia *media, const gchar *session_id,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1862 const gchar *participant, gulong window_id)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1863 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1864 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1865 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1866
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1867 return purple_media_manager_set_output_window(media->priv->manager,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1868 media, session_id, participant, window_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1869 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1870 return 0;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1871 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1872 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1873
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1874 void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1875 purple_media_remove_output_windows(PurpleMedia *media)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1876 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1877 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1878 GList *iter = media->priv->streams;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1879 for (; iter; iter = g_list_next(iter)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1880 PurpleMediaStream *stream = iter->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1881 purple_media_manager_remove_output_windows(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1882 media->priv->manager, media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1883 stream->session->id, stream->participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1884 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1885
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1886 iter = purple_media_get_session_ids(media);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1887 for (; iter; iter = g_list_delete_link(iter, iter)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1888 gchar *session_name = iter->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1889 purple_media_manager_remove_output_windows(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1890 media->priv->manager, media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1891 session_name, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1892 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1893 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1894 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1895
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1896 #ifdef USE_GSTREAMER
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1897 GstElement *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1898 purple_media_get_tee(PurpleMedia *media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1899 const gchar *session_id, const gchar *participant)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1900 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1901 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1902 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1903
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1904 if (session_id != NULL && participant == NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1905 PurpleMediaSession *session =
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1906 purple_media_get_session(media, session_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1907 return (session != NULL) ? session->tee : NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1908 } else if (session_id != NULL && participant != NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1909 PurpleMediaStream *stream =
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1910 purple_media_get_stream(media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1911 session_id, participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1912 return (stream != NULL) ? stream->tee : NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1913 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1914 g_return_val_if_reached(NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1915 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1916 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1917 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1918 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1919 #endif /* USE_GSTREAMER */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1920