annotate libpurple/media/media.c @ 29549:41ae97b7e97e

Start to use the media backend code in PurpleMedia and PurpleMediaManager.
author maiku@pidgin.im
date Fri, 23 Oct 2009 02:11:33 +0000
parents 30e8ab2a4bc2
children 846a475a1573
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;
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
116 gboolean initiator;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
117 gpointer prpl_data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
118
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
119 GHashTable *sessions; /* PurpleMediaSession table */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
120 GHashTable *participants; /* FsParticipant 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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
140 static void purple_media_new_local_candidate_cb(FsStream *stream,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
141 FsCandidate *local_candidate, PurpleMediaSession *session);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
142 static void purple_media_candidates_prepared_cb(FsStream *stream,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
143 PurpleMediaSession *session);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
144 static void purple_media_candidate_pair_established_cb(FsStream *stream,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
145 FsCandidate *native_candidate, FsCandidate *remote_candidate,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
146 PurpleMediaSession *session);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
147 static gboolean media_bus_call(GstBus *bus,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
148 GstMessage *msg, PurpleMedia *media);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
149
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
150 static GObjectClass *parent_class = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
151
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
152
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
153
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
154 enum {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
155 S_ERROR,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
156 CANDIDATES_PREPARED,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
157 CODECS_CHANGED,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
158 LEVEL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
159 NEW_CANDIDATE,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
160 STATE_CHANGED,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
161 STREAM_INFO,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
162 LAST_SIGNAL
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
163 };
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
164 static guint purple_media_signals[LAST_SIGNAL] = {0};
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
165
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
166 enum {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
167 PROP_0,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
168 PROP_MANAGER,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
169 PROP_ACCOUNT,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
170 PROP_CONFERENCE,
29545
30e8ab2a4bc2 Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents: 29538
diff changeset
171 PROP_CONFERENCE_TYPE,
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
172 PROP_INITIATOR,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
173 PROP_PRPL_DATA,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
174 };
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
175 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
176
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
177
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
178 GType
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
179 purple_media_get_type()
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
180 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
181 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
182 static GType type = 0;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
183
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
184 if (type == 0) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
185 static const GTypeInfo info = {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
186 sizeof(PurpleMediaClass),
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
187 NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
188 NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
189 (GClassInitFunc) purple_media_class_init,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
190 NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
191 NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
192 sizeof(PurpleMedia),
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
193 0,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
194 (GInstanceInitFunc) purple_media_init,
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 };
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
197 type = g_type_register_static(G_TYPE_OBJECT, "PurpleMedia", &info, 0);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
198 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
199 return type;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
200 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
201 return G_TYPE_NONE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
202 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
203 }
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 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
206 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
207 purple_media_class_init (PurpleMediaClass *klass)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
208 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
209 GObjectClass *gobject_class = (GObjectClass*)klass;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
210 parent_class = g_type_class_peek_parent(klass);
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 gobject_class->dispose = purple_media_dispose;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
213 gobject_class->finalize = purple_media_finalize;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
214 gobject_class->set_property = purple_media_set_property;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
215 gobject_class->get_property = purple_media_get_property;
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 g_object_class_install_property(gobject_class, PROP_MANAGER,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
218 g_param_spec_object("manager",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
219 "Purple Media Manager",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
220 "The media manager that contains this media session.",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
221 PURPLE_TYPE_MEDIA_MANAGER,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
222 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
223
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
224 g_object_class_install_property(gobject_class, PROP_ACCOUNT,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
225 g_param_spec_pointer("account",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
226 "PurpleAccount",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
227 "The account this media session is on.",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
228 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
229
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
230 g_object_class_install_property(gobject_class, PROP_CONFERENCE,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
231 g_param_spec_object("conference",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
232 "Farsight conference",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
233 "The FsConference associated with this media.",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
234 FS_TYPE_CONFERENCE,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
235 G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
236
29545
30e8ab2a4bc2 Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents: 29538
diff changeset
237 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
238 g_param_spec_string("conference-type",
30e8ab2a4bc2 Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents: 29538
diff changeset
239 "Conference Type",
30e8ab2a4bc2 Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents: 29538
diff changeset
240 "The type of conference that this media object "
30e8ab2a4bc2 Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents: 29538
diff changeset
241 "has been created to provide.",
30e8ab2a4bc2 Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents: 29538
diff changeset
242 NULL,
30e8ab2a4bc2 Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents: 29538
diff changeset
243 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
30e8ab2a4bc2 Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents: 29538
diff changeset
244
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
245 g_object_class_install_property(gobject_class, PROP_INITIATOR,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
246 g_param_spec_boolean("initiator",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
247 "initiator",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
248 "If the local user initiated the conference.",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
249 FALSE,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
250 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
251
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
252 g_object_class_install_property(gobject_class, PROP_PRPL_DATA,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
253 g_param_spec_pointer("prpl-data",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
254 "gpointer",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
255 "Data the prpl plugin set on the media session.",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
256 G_PARAM_READWRITE));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
257
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
258 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
259 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
260 g_cclosure_marshal_VOID__STRING,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
261 G_TYPE_NONE, 1, G_TYPE_STRING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
262 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
263 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
264 purple_smarshal_VOID__STRING_STRING,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
265 G_TYPE_NONE, 2, G_TYPE_STRING,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
266 G_TYPE_STRING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
267 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
268 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
269 g_cclosure_marshal_VOID__STRING,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
270 G_TYPE_NONE, 1, G_TYPE_STRING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
271 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
272 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
273 purple_smarshal_VOID__STRING_STRING_DOUBLE,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
274 G_TYPE_NONE, 3, G_TYPE_STRING,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
275 G_TYPE_STRING, G_TYPE_DOUBLE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
276 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
277 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
278 purple_smarshal_VOID__POINTER_POINTER_OBJECT,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
279 G_TYPE_NONE, 3, G_TYPE_POINTER,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
280 G_TYPE_POINTER, PURPLE_TYPE_MEDIA_CANDIDATE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
281 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
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__ENUM_STRING_STRING,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
284 G_TYPE_NONE, 3, PURPLE_MEDIA_TYPE_STATE,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
285 G_TYPE_STRING, G_TYPE_STRING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
286 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
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__ENUM_STRING_STRING_BOOLEAN,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
289 G_TYPE_NONE, 4, PURPLE_MEDIA_TYPE_INFO_TYPE,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
290 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
291 g_type_class_add_private(klass, sizeof(PurpleMediaPrivate));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
292 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
293
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
294
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
295 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
296 purple_media_init (PurpleMedia *media)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
297 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
298 media->priv = PURPLE_MEDIA_GET_PRIVATE(media);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
299 memset(media->priv, 0, sizeof(*media->priv));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
300 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
301
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
302 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
303 purple_media_stream_free(PurpleMediaStream *stream)
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 if (stream == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
306 return;
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 /* Remove the connected_cb timeout */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
309 if (stream->connected_cb_id != 0)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
310 purple_timeout_remove(stream->connected_cb_id);
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 g_free(stream->participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
313
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
314 if (stream->local_candidates)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
315 fs_candidate_list_destroy(stream->local_candidates);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
316 if (stream->remote_candidates)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
317 fs_candidate_list_destroy(stream->remote_candidates);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
318
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
319 if (stream->active_local_candidates)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
320 fs_candidate_list_destroy(stream->active_local_candidates);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
321 if (stream->active_remote_candidates)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
322 fs_candidate_list_destroy(stream->active_remote_candidates);
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 g_free(stream);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
325 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
326
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
327 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
328 purple_media_session_free(PurpleMediaSession *session)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
329 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
330 if (session == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
331 return;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
332
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
333 g_free(session->id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
334 g_free(session);
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
337 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
338 purple_media_dispose(GObject *media)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
339 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
340 PurpleMediaPrivate *priv = PURPLE_MEDIA_GET_PRIVATE(media);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
341 GList *iter = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
342
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
343 purple_debug_info("media","purple_media_dispose\n");
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 purple_media_manager_remove_media(priv->manager, PURPLE_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
346
29549
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
347 if (priv->backend) {
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
348 g_object_unref(priv->backend);
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
349 priv->backend = NULL;
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
350 }
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 for (iter = priv->streams; iter; iter = g_list_next(iter)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
353 PurpleMediaStream *stream = iter->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
354 if (stream->stream) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
355 g_object_unref(stream->stream);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
356 stream->stream = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
357 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
358 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
359
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
360 if (priv->sessions) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
361 GList *sessions = g_hash_table_get_values(priv->sessions);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
362 for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
363 PurpleMediaSession *session = sessions->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
364 if (session->session) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
365 g_object_unref(session->session);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
366 session->session = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
367 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
368 }
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 if (priv->participants) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
372 GList *participants = g_hash_table_get_values(priv->participants);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
373 for (; participants; participants = g_list_delete_link(participants, participants))
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
374 g_object_unref(participants->data);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
375 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
376
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
377 if (priv->manager) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
378 GstElement *pipeline = purple_media_manager_get_pipeline(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
379 priv->manager);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
380 GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
381 g_signal_handlers_disconnect_matched(G_OBJECT(bus),
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
382 G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
383 0, 0, 0, media_bus_call, media);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
384 gst_object_unref(bus);
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_unref(priv->manager);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
387 priv->manager = NULL;
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
390 G_OBJECT_CLASS(parent_class)->dispose(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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
393 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
394 purple_media_finalize(GObject *media)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
395 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
396 PurpleMediaPrivate *priv = PURPLE_MEDIA_GET_PRIVATE(media);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
397 purple_debug_info("media","purple_media_finalize\n");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
398
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
399 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
400 purple_media_stream_free(priv->streams->data);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
401
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
402 if (priv->sessions) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
403 GList *sessions = g_hash_table_get_values(priv->sessions);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
404 for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
405 purple_media_session_free(sessions->data);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
406 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
407 g_hash_table_destroy(priv->sessions);
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
410 G_OBJECT_CLASS(parent_class)->finalize(media);
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
413 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
414 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
415 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
416 PurpleMedia *media;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
417 g_return_if_fail(PURPLE_IS_MEDIA(object));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
418
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
419 media = PURPLE_MEDIA(object);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
420
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
421 switch (prop_id) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
422 case PROP_MANAGER:
29549
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
423 media->priv->manager = g_value_dup_object(value);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
424 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
425 case PROP_ACCOUNT:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
426 media->priv->account = g_value_get_pointer(value);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
427 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
428 case PROP_CONFERENCE: {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
429 if (media->priv->conference)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
430 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
431 media->priv->conference = g_value_dup_object(value);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
432 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
433 }
29545
30e8ab2a4bc2 Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents: 29538
diff changeset
434 case PROP_CONFERENCE_TYPE:
30e8ab2a4bc2 Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents: 29538
diff changeset
435 media->priv->conference_type =
30e8ab2a4bc2 Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents: 29538
diff changeset
436 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
437 /* 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
438 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
439 PURPLE_TYPE_MEDIA_BACKEND_FS2,
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
440 "conference-type",
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
441 media->priv->conference_type,
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
442 "media", media,
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
443 NULL);
29545
30e8ab2a4bc2 Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents: 29538
diff changeset
444 break;
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
445 case PROP_INITIATOR:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
446 media->priv->initiator = g_value_get_boolean(value);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
447 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
448 case PROP_PRPL_DATA:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
449 media->priv->prpl_data = g_value_get_pointer(value);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
450 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
451 default:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
452 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
453 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
454 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
455 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
456
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
457 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
458 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
459 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
460 PurpleMedia *media;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
461 g_return_if_fail(PURPLE_IS_MEDIA(object));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
462
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
463 media = PURPLE_MEDIA(object);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
464
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
465 switch (prop_id) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
466 case PROP_MANAGER:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
467 g_value_set_object(value, media->priv->manager);
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 case PROP_ACCOUNT:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
470 g_value_set_pointer(value, media->priv->account);
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 case PROP_CONFERENCE:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
473 g_value_set_object(value, media->priv->conference);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
474 break;
29545
30e8ab2a4bc2 Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents: 29538
diff changeset
475 case PROP_CONFERENCE_TYPE:
30e8ab2a4bc2 Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents: 29538
diff changeset
476 g_value_set_string(value,
30e8ab2a4bc2 Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents: 29538
diff changeset
477 media->priv->conference_type);
30e8ab2a4bc2 Add a conference-type parameter to PurpleMedia.
maiku@pidgin.im
parents: 29538
diff changeset
478 break;
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
479 case PROP_INITIATOR:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
480 g_value_set_boolean(value, media->priv->initiator);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
481 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
482 case PROP_PRPL_DATA:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
483 g_value_set_pointer(value, media->priv->prpl_data);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
484 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
485 default:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
486 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
487 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
488 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
489
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
490 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
491
29536
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
492 static FsCandidate *
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
493 purple_media_candidate_to_fs(PurpleMediaCandidate *candidate)
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
494 {
29536
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
495 FsCandidate *fscandidate;
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
496 gchar *foundation;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
497 guint component_id;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
498 gchar *ip;
29536
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
499 guint port;
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
500 gchar *base_ip;
29536
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
501 guint base_port;
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
502 PurpleMediaNetworkProtocol proto;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
503 guint32 priority;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
504 PurpleMediaCandidateType type;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
505 gchar *username;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
506 gchar *password;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
507 guint ttl;
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 if (candidate == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
510 return NULL;
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 g_object_get(G_OBJECT(candidate),
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
513 "foundation", &foundation,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
514 "component-id", &component_id,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
515 "ip", &ip,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
516 "port", &port,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
517 "base-ip", &base_ip,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
518 "base-port", &base_port,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
519 "protocol", &proto,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
520 "priority", &priority,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
521 "type", &type,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
522 "username", &username,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
523 "password", &password,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
524 "ttl", &ttl,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
525 NULL);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
526
29536
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
527 fscandidate = fs_candidate_new(foundation,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
528 component_id, type,
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
529 proto, ip, port);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
530
29536
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
531 fscandidate->base_ip = base_ip;
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
532 fscandidate->base_port = base_port;
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
533 fscandidate->priority = priority;
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
534 fscandidate->username = username;
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
535 fscandidate->password = password;
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
536 fscandidate->ttl = ttl;
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
537
29536
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
538 g_free(foundation);
f585e10f156b Split out PurpleMediaCandidate into its own file.
maiku@pidgin.im
parents: 29535
diff changeset
539 g_free(ip);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
540 return fscandidate;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
541 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
542
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
543 static PurpleMediaCandidate *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
544 purple_media_candidate_from_fs(FsCandidate *fscandidate)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
545 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
546 PurpleMediaCandidate *candidate;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
547
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
548 if (fscandidate == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
549 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
550
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
551 candidate = purple_media_candidate_new(fscandidate->foundation,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
552 fscandidate->component_id, fscandidate->type,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
553 fscandidate->proto, fscandidate->ip, fscandidate->port);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
554 g_object_set(candidate,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
555 "base-ip", fscandidate->base_ip,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
556 "base-port", fscandidate->base_port,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
557 "priority", fscandidate->priority,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
558 "username", fscandidate->username,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
559 "password", fscandidate->password,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
560 "ttl", fscandidate->ttl, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
561 return candidate;
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
564 static GList *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
565 purple_media_candidate_list_from_fs(GList *candidates)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
566 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
567 GList *new_list = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
568
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
569 for (; candidates; candidates = g_list_next(candidates)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
570 new_list = g_list_prepend(new_list,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
571 purple_media_candidate_from_fs(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
572 candidates->data));
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
575 new_list = g_list_reverse(new_list);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
576 return new_list;
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
579 static GList *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
580 purple_media_candidate_list_to_fs(GList *candidates)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
581 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
582 GList *new_list = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
583
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
584 for (; candidates; candidates = g_list_next(candidates)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
585 new_list = g_list_prepend(new_list,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
586 purple_media_candidate_to_fs(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
587 candidates->data));
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
590 new_list = g_list_reverse(new_list);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
591 return new_list;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
592 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
593
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
594 static FsMediaType
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
595 purple_media_to_fs_media_type(PurpleMediaSessionType type)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
596 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
597 if (type & PURPLE_MEDIA_AUDIO)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
598 return FS_MEDIA_TYPE_AUDIO;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
599 else if (type & PURPLE_MEDIA_VIDEO)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
600 return FS_MEDIA_TYPE_VIDEO;
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 0;
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 FsStreamDirection
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
606 purple_media_to_fs_stream_direction(PurpleMediaSessionType type)
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 if ((type & PURPLE_MEDIA_AUDIO) == PURPLE_MEDIA_AUDIO ||
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
609 (type & PURPLE_MEDIA_VIDEO) == PURPLE_MEDIA_VIDEO)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
610 return FS_DIRECTION_BOTH;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
611 else if ((type & PURPLE_MEDIA_SEND_AUDIO) ||
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
612 (type & PURPLE_MEDIA_SEND_VIDEO))
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
613 return FS_DIRECTION_SEND;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
614 else if ((type & PURPLE_MEDIA_RECV_AUDIO) ||
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
615 (type & PURPLE_MEDIA_RECV_VIDEO))
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
616 return FS_DIRECTION_RECV;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
617 else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
618 return FS_DIRECTION_NONE;
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
621 static PurpleMediaSessionType
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
622 purple_media_from_fs(FsMediaType type, FsStreamDirection direction)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
623 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
624 PurpleMediaSessionType result = PURPLE_MEDIA_NONE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
625 if (type == FS_MEDIA_TYPE_AUDIO) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
626 if (direction & FS_DIRECTION_SEND)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
627 result |= PURPLE_MEDIA_SEND_AUDIO;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
628 if (direction & FS_DIRECTION_RECV)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
629 result |= PURPLE_MEDIA_RECV_AUDIO;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
630 } else if (type == FS_MEDIA_TYPE_VIDEO) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
631 if (direction & FS_DIRECTION_SEND)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
632 result |= PURPLE_MEDIA_SEND_VIDEO;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
633 if (direction & FS_DIRECTION_RECV)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
634 result |= PURPLE_MEDIA_RECV_VIDEO;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
635 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
636 return result;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
637 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
638
29538
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
639 static FsCodec *
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
640 purple_media_codec_to_fs(const PurpleMediaCodec *codec)
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
641 {
29538
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
642 FsCodec *new_codec;
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
643 gint id;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
644 char *encoding_name;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
645 PurpleMediaSessionType media_type;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
646 guint clock_rate;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
647 guint channels;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
648 GList *iter;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
649
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
650 if (codec == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
651 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
652
29538
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
653 g_object_get(G_OBJECT(codec),
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
654 "id", &id,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
655 "encoding-name", &encoding_name,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
656 "media-type", &media_type,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
657 "clock-rate", &clock_rate,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
658 "channels", &channels,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
659 "optional-params", &iter,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
660 NULL);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
661
29538
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
662 new_codec = fs_codec_new(id, encoding_name,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
663 purple_media_to_fs_media_type(media_type),
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
664 clock_rate);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
665 new_codec->channels = channels;
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
666
29538
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
667 for (; iter; iter = g_list_next(iter)) {
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
668 PurpleKeyValuePair *param = (PurpleKeyValuePair*)iter->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
669 fs_codec_add_optional_parameter(new_codec,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
670 param->key, param->value);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
671 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
672
29538
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents: 29536
diff changeset
673 g_free(encoding_name);
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
674 return new_codec;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
675 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
676
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
677 static PurpleMediaCodec *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
678 purple_media_codec_from_fs(const FsCodec *codec)
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 PurpleMediaCodec *new_codec;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
681 GList *iter;
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 if (codec == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
684 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
685
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
686 new_codec = purple_media_codec_new(codec->id, codec->encoding_name,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
687 purple_media_from_fs(codec->media_type,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
688 FS_DIRECTION_BOTH), codec->clock_rate);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
689 g_object_set(new_codec, "channels", codec->channels, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
690
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
691 for (iter = codec->optional_params; iter; iter = g_list_next(iter)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
692 FsCodecParameter *param = (FsCodecParameter*)iter->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
693 purple_media_codec_add_optional_parameter(new_codec,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
694 param->name, param->value);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
695 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
696
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
697 return new_codec;
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
700 static GList *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
701 purple_media_codec_list_from_fs(GList *codecs)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
702 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
703 GList *new_list = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
704
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
705 for (; codecs; codecs = g_list_next(codecs)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
706 new_list = g_list_prepend(new_list,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
707 purple_media_codec_from_fs(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
708 codecs->data));
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
711 new_list = g_list_reverse(new_list);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
712 return new_list;
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
715 static GList *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
716 purple_media_codec_list_to_fs(GList *codecs)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
717 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
718 GList *new_list = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
719
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
720 for (; codecs; codecs = g_list_next(codecs)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
721 new_list = g_list_prepend(new_list,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
722 purple_media_codec_to_fs(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
723 codecs->data));
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
726 new_list = g_list_reverse(new_list);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
727 return new_list;
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
730 static PurpleMediaSession*
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
731 purple_media_get_session(PurpleMedia *media, const gchar *sess_id)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
732 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
733 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
734 return (PurpleMediaSession*) (media->priv->sessions) ?
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
735 g_hash_table_lookup(media->priv->sessions, sess_id) : NULL;
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 static FsParticipant*
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
739 purple_media_get_participant(PurpleMedia *media, const gchar *name)
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 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
742 return (FsParticipant*) (media->priv->participants) ?
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
743 g_hash_table_lookup(media->priv->participants, name) : NULL;
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
746 static PurpleMediaStream*
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
747 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
748 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
749 GList *streams;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
750
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
751 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
752
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
753 streams = media->priv->streams;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
754
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
755 for (; streams; streams = g_list_next(streams)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
756 PurpleMediaStream *stream = streams->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
757 if (!strcmp(stream->session->id, session) &&
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
758 !strcmp(stream->participant, participant))
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
759 return stream;
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
762 return NULL;
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
765 static GList *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
766 purple_media_get_streams(PurpleMedia *media, const gchar *session,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
767 const gchar *participant)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
768 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
769 GList *streams;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
770 GList *ret = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
771
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
772 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
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 streams = media->priv->streams;
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 for (; streams; streams = g_list_next(streams)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
777 PurpleMediaStream *stream = streams->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
778 if ((session == NULL ||
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
779 !strcmp(stream->session->id, session)) &&
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
780 (participant == NULL ||
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
781 !strcmp(stream->participant, participant)))
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
782 ret = g_list_append(ret, stream);
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
785 return ret;
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
788 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
789 purple_media_add_session(PurpleMedia *media, PurpleMediaSession *session)
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 g_return_if_fail(PURPLE_IS_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
792 g_return_if_fail(session != NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
793
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
794 if (!media->priv->sessions) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
795 purple_debug_info("media", "Creating hash table for sessions\n");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
796 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
797 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
798 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
799 }
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 static gboolean
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
802 purple_media_remove_session(PurpleMedia *media, PurpleMediaSession *session)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
803 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
804 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
805 return g_hash_table_remove(media->priv->sessions, session->id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
806 }
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 static FsParticipant *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
809 purple_media_add_participant(PurpleMedia *media, const gchar *name)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
810 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
811 FsParticipant *participant;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
812 GError *err = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
813
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
814 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
815
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
816 participant = purple_media_get_participant(media, name);
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 if (participant)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
819 return participant;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
820
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
821 participant = fs_conference_new_participant(media->priv->conference,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
822 (gchar*)name, &err);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
823
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
824 if (err) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
825 purple_debug_error("media", "Error creating participant: %s\n",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
826 err->message);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
827 g_error_free(err);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
828 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
829 }
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 if (!media->priv->participants) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
832 purple_debug_info("media", "Creating hash table for participants\n");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
833 media->priv->participants = g_hash_table_new_full(g_str_hash,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
834 g_str_equal, g_free, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
835 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
836
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
837 g_hash_table_insert(media->priv->participants, g_strdup(name), participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
838
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
839 return participant;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
840 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
841
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
842 static PurpleMediaStream *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
843 purple_media_insert_stream(PurpleMediaSession *session, const gchar *name, FsStream *stream)
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 PurpleMediaStream *media_stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
846
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
847 g_return_val_if_fail(session != NULL, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
848
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
849 media_stream = g_new0(PurpleMediaStream, 1);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
850 media_stream->stream = stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
851 media_stream->participant = g_strdup(name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
852 media_stream->session = session;
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 session->media->priv->streams =
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
855 g_list_append(session->media->priv->streams, media_stream);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
856
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
857 return media_stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
858 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
859
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
860 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
861 purple_media_insert_local_candidate(PurpleMediaSession *session, const gchar *name,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
862 FsCandidate *candidate)
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 PurpleMediaStream *stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
865
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
866 g_return_if_fail(session != NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
867
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
868 stream = purple_media_get_stream(session->media, session->id, name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
869 stream->local_candidates = g_list_append(stream->local_candidates, candidate);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
870 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
871 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
872
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
873 GList *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
874 purple_media_get_session_ids(PurpleMedia *media)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
875 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
876 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
877 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
878 return media->priv->sessions != NULL ?
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
879 g_hash_table_get_keys(media->priv->sessions) : NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
880 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
881 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
882 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
883 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
884
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
885 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
886 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
887 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
888 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
889 PurpleMediaSession *session;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
890 GstPad *sinkpad;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
891 GstPad *srcpad;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
892
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
893 g_return_if_fail(PURPLE_IS_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
894 g_return_if_fail(GST_IS_ELEMENT(src));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
895
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
896 session = purple_media_get_session(media, sess_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
897
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
898 if (session == NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
899 purple_debug_warning("media", "purple_media_set_src: trying"
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
900 " to set src on non-existent session\n");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
901 return;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
902 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
903
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
904 if (session->src)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
905 gst_object_unref(session->src);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
906 session->src = src;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
907 gst_element_set_locked_state(session->src, TRUE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
908
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
909 session->tee = gst_element_factory_make("tee", NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
910 gst_bin_add(GST_BIN(session->media->priv->confbin), session->tee);
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 /* This supposedly isn't necessary, but it silences some warnings */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
913 if (GST_ELEMENT_PARENT(session->media->priv->confbin)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
914 == GST_ELEMENT_PARENT(session->src)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
915 GstPad *pad = gst_element_get_static_pad(session->tee, "sink");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
916 GstPad *ghost = gst_ghost_pad_new(NULL, pad);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
917 gst_object_unref(pad);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
918 gst_pad_set_active(ghost, TRUE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
919 gst_element_add_pad(session->media->priv->confbin, ghost);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
920 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
921
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
922 gst_element_set_state(session->tee, GST_STATE_PLAYING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
923 gst_element_link(session->src, session->media->priv->confbin);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
924
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
925 g_object_get(session->session, "sink-pad", &sinkpad, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
926 if (session->type & PURPLE_MEDIA_SEND_AUDIO) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
927 gchar *name = g_strdup_printf("volume_%s", session->id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
928 GstElement *level;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
929 GstElement *volume = gst_element_factory_make("volume", name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
930 double input_volume = purple_prefs_get_int(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
931 "/purple/media/audio/volume/input")/10.0;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
932 g_free(name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
933 name = g_strdup_printf("sendlevel_%s", session->id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
934 level = gst_element_factory_make("level", name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
935 g_free(name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
936 gst_bin_add(GST_BIN(session->media->priv->confbin), volume);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
937 gst_bin_add(GST_BIN(session->media->priv->confbin), level);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
938 gst_element_set_state(level, GST_STATE_PLAYING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
939 gst_element_set_state(volume, GST_STATE_PLAYING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
940 gst_element_link(volume, level);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
941 gst_element_link(session->tee, volume);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
942 srcpad = gst_element_get_static_pad(level, "src");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
943 g_object_set(volume, "volume", input_volume, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
944 } else {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
945 srcpad = gst_element_get_request_pad(session->tee, "src%d");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
946 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
947 purple_debug_info("media", "connecting pad: %s\n",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
948 gst_pad_link(srcpad, sinkpad) == GST_PAD_LINK_OK
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
949 ? "success" : "failure");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
950 gst_element_set_locked_state(session->src, FALSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
951 gst_object_unref(session->src);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
952 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
953 #endif
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 #ifdef USE_GSTREAMER
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
956 GstElement *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
957 purple_media_get_src(PurpleMedia *media, const gchar *sess_id)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
958 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
959 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
960 PurpleMediaSession *session;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
961 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
962 session = purple_media_get_session(media, sess_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
963 return (session != NULL) ? session->src : NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
964 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
965 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
966 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
967 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
968 #endif /* USE_GSTREAMER */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
969
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
970 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
971 static PurpleMediaSession *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
972 purple_media_session_from_fs_stream(PurpleMedia *media, FsStream *stream)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
973 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
974 FsSession *fssession;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
975 GList *values;
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 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
978 g_return_val_if_fail(FS_IS_STREAM(stream), NULL);
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 g_object_get(stream, "session", &fssession, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
981
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
982 values = g_hash_table_get_values(media->priv->sessions);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
983
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
984 for (; values; values = g_list_delete_link(values, values)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
985 PurpleMediaSession *session = values->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
986
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
987 if (session->session == fssession) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
988 g_list_free(values);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
989 g_object_unref(fssession);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
990 return session;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
991 }
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
994 g_object_unref(fssession);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
995 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
996 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
997
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
998 static gboolean
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
999 media_bus_call(GstBus *bus, GstMessage *msg, PurpleMedia *media)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1000 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1001 switch(GST_MESSAGE_TYPE(msg)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1002 case GST_MESSAGE_ELEMENT: {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1003 if (g_signal_has_handler_pending(media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1004 purple_media_signals[LEVEL], 0, FALSE)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1005 && gst_structure_has_name(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1006 gst_message_get_structure(msg), "level")) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1007 GstElement *src = GST_ELEMENT(GST_MESSAGE_SRC(msg));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1008 gchar *name;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1009 gchar *participant = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1010 PurpleMediaSession *session = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1011 gdouble rms_db;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1012 gdouble percent;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1013 const GValue *list;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1014 const GValue *value;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1015
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1016 if (!PURPLE_IS_MEDIA(media) ||
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1017 GST_ELEMENT_PARENT(src) !=
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1018 media->priv->confbin)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1019 break;
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 name = gst_element_get_name(src);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1022 if (!strncmp(name, "sendlevel_", 10)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1023 session = purple_media_get_session(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1024 media, name+10);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1025 } else {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1026 GList *iter = media->priv->streams;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1027 for (; iter; iter = g_list_next(iter)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1028 PurpleMediaStream *stream = iter->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1029 if (stream->level == src) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1030 session = stream->session;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1031 participant = stream->participant;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1032 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1033 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1034 }
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 g_free(name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1037 if (!session)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1038 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1039
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1040 list = gst_structure_get_value(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1041 gst_message_get_structure(msg), "rms");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1042 value = gst_value_list_get_value(list, 0);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1043 rms_db = g_value_get_double(value);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1044 percent = pow(10, rms_db / 20) * 5;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1045 if(percent > 1.0)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1046 percent = 1.0;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1047
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1048 g_signal_emit(media, purple_media_signals[LEVEL],
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1049 0, session->id, participant, percent);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1050 break;
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 if (!FS_IS_CONFERENCE(GST_MESSAGE_SRC(msg)) ||
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1053 !PURPLE_IS_MEDIA(media) ||
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1054 media->priv->conference !=
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1055 FS_CONFERENCE(GST_MESSAGE_SRC(msg)))
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1056 break;
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 if (gst_structure_has_name(msg->structure, "farsight-error")) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1059 FsError error_no;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1060 gst_structure_get_enum(msg->structure, "error-no",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1061 FS_TYPE_ERROR, (gint*)&error_no);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1062 switch (error_no) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1063 case FS_ERROR_NO_CODECS:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1064 purple_media_error(media, _("No codecs found. Install some GStreamer codecs found in GStreamer plugins packages."));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1065 purple_media_end(media, NULL, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1066 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1067 case FS_ERROR_NO_CODECS_LEFT:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1068 purple_media_error(media, _("No codecs left. Your codec preferences in fs-codecs.conf are too strict."));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1069 purple_media_end(media, NULL, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1070 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1071 case FS_ERROR_UNKNOWN_CNAME:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1072 /*
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1073 * Unknown CName is only a problem for the
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1074 * multicast transmitter which isn't used.
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1075 * It is also deprecated.
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1076 */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1077 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1078 default:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1079 purple_debug_error("media", "farsight-error: %i: %s\n", error_no,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1080 gst_structure_get_string(msg->structure, "error-msg"));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1081 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1082 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1083
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1084 if (FS_ERROR_IS_FATAL(error_no)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1085 purple_media_error(media, _("A non-recoverable Farsight2 error has occurred."));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1086 purple_media_end(media, NULL, NULL);
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 (gst_structure_has_name(msg->structure,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1089 "farsight-new-local-candidate")) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1090 FsStream *stream = g_value_get_object(gst_structure_get_value(msg->structure, "stream"));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1091 FsCandidate *local_candidate = g_value_get_boxed(gst_structure_get_value(msg->structure, "candidate"));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1092 PurpleMediaSession *session = purple_media_session_from_fs_stream(media, stream);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1093 purple_media_new_local_candidate_cb(stream, local_candidate, session);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1094 } else if (gst_structure_has_name(msg->structure,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1095 "farsight-local-candidates-prepared")) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1096 FsStream *stream = g_value_get_object(gst_structure_get_value(msg->structure, "stream"));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1097 PurpleMediaSession *session = purple_media_session_from_fs_stream(media, stream);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1098 purple_media_candidates_prepared_cb(stream, session);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1099 } else if (gst_structure_has_name(msg->structure,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1100 "farsight-new-active-candidate-pair")) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1101 FsStream *stream = g_value_get_object(gst_structure_get_value(msg->structure, "stream"));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1102 FsCandidate *local_candidate = g_value_get_boxed(gst_structure_get_value(msg->structure, "local-candidate"));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1103 FsCandidate *remote_candidate = g_value_get_boxed(gst_structure_get_value(msg->structure, "remote-candidate"));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1104 PurpleMediaSession *session = purple_media_session_from_fs_stream(media, stream);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1105 purple_media_candidate_pair_established_cb(stream, local_candidate, remote_candidate, session);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1106 } else if (gst_structure_has_name(msg->structure,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1107 "farsight-recv-codecs-changed")) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1108 GList *codecs = g_value_get_boxed(gst_structure_get_value(msg->structure, "codecs"));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1109 FsCodec *codec = codecs->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1110 purple_debug_info("media", "farsight-recv-codecs-changed: %s\n", codec->encoding_name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1111
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1112 } else if (gst_structure_has_name(msg->structure,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1113 "farsight-component-state-changed")) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1114 FsStreamState fsstate = g_value_get_enum(gst_structure_get_value(msg->structure, "state"));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1115 guint component = g_value_get_uint(gst_structure_get_value(msg->structure, "component"));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1116 const gchar *state;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1117 switch (fsstate) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1118 case FS_STREAM_STATE_FAILED:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1119 state = "FAILED";
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1120 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1121 case FS_STREAM_STATE_DISCONNECTED:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1122 state = "DISCONNECTED";
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1123 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1124 case FS_STREAM_STATE_GATHERING:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1125 state = "GATHERING";
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1126 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1127 case FS_STREAM_STATE_CONNECTING:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1128 state = "CONNECTING";
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1129 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1130 case FS_STREAM_STATE_CONNECTED:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1131 state = "CONNECTED";
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1132 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1133 case FS_STREAM_STATE_READY:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1134 state = "READY";
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1135 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1136 default:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1137 state = "UNKNOWN";
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1138 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1139 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1140 purple_debug_info("media", "farsight-component-state-changed: component: %u state: %s\n", component, state);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1141 } else if (gst_structure_has_name(msg->structure,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1142 "farsight-send-codec-changed")) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1143 FsCodec *codec = g_value_get_boxed(gst_structure_get_value(msg->structure, "codec"));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1144 gchar *codec_str = fs_codec_to_string(codec);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1145 purple_debug_info("media", "farsight-send-codec-changed: codec: %s\n", codec_str);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1146 g_free(codec_str);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1147 } else if (gst_structure_has_name(msg->structure,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1148 "farsight-codecs-changed")) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1149 GList *sessions = g_hash_table_get_values(PURPLE_MEDIA(media)->priv->sessions);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1150 FsSession *fssession = g_value_get_object(gst_structure_get_value(msg->structure, "session"));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1151 for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1152 PurpleMediaSession *session = sessions->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1153 if (session->session == fssession) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1154 gchar *session_id = g_strdup(session->id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1155 g_signal_emit(media, purple_media_signals[CODECS_CHANGED], 0, session_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1156 g_free(session_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1157 g_list_free(sessions);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1158 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1159 }
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 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1163 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1164 case GST_MESSAGE_ERROR: {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1165 GstElement *element = GST_ELEMENT(GST_MESSAGE_SRC(msg));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1166 GstElement *lastElement = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1167 while (!GST_IS_PIPELINE(element)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1168 if (element == media->priv->confbin) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1169 purple_media_error(media, _("Conference error"));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1170 purple_media_end(media, NULL, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1171 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1172 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1173 lastElement = element;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1174 element = GST_ELEMENT_PARENT(element);
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 if (GST_IS_PIPELINE(element)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1177 GList *sessions = g_hash_table_get_values(media->priv->sessions);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1178 for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1179 PurpleMediaSession *session = sessions->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1180
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1181 if (session->src == lastElement) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1182 if (session->type & PURPLE_MEDIA_AUDIO)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1183 purple_media_error(media, _("Error with your microphone"));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1184 else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1185 purple_media_error(media, _("Error with your webcam"));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1186 purple_media_end(media, NULL, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1187 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1188 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1189 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1190 g_list_free(sessions);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1191 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1192 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1193 default:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1194 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1195 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1196
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1197 return TRUE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1198 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1199 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1200
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1201 PurpleAccount *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1202 purple_media_get_account(PurpleMedia *media)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1203 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1204 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1205 PurpleAccount *account;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1206 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1207 g_object_get(G_OBJECT(media), "account", &account, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1208 return account;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1209 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1210 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1211 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1212 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1213
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1214 gpointer
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1215 purple_media_get_prpl_data(PurpleMedia *media)
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 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1218 gpointer prpl_data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1219 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1220 g_object_get(G_OBJECT(media), "prpl-data", &prpl_data, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1221 return prpl_data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1222 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1223 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1224 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1225 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1226
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1227 void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1228 purple_media_set_prpl_data(PurpleMedia *media, gpointer prpl_data)
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 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1231 g_return_if_fail(PURPLE_IS_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1232 g_object_set(G_OBJECT(media), "prpl-data", prpl_data, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1233 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1234 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1235
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1236 void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1237 purple_media_error(PurpleMedia *media, const gchar *error, ...)
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 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1240 va_list args;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1241 gchar *message;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1242
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1243 g_return_if_fail(PURPLE_IS_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1244
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1245 va_start(args, error);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1246 message = g_strdup_vprintf(error, args);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1247 va_end(args);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1248
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1249 purple_debug_error("media", "%s\n", message);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1250 g_signal_emit(media, purple_media_signals[S_ERROR], 0, message);
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 g_free(message);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1253 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1254 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1255
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1256 void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1257 purple_media_end(PurpleMedia *media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1258 const gchar *session_id, const gchar *participant)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1259 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1260 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1261 g_return_if_fail(PURPLE_IS_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1262 if (session_id == NULL && participant == NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1263 g_signal_emit(media, purple_media_signals[STATE_CHANGED],
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1264 0, PURPLE_MEDIA_STATE_END,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1265 NULL, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1266 g_object_unref(media);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1267 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1268 #endif
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1271 void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1272 purple_media_stream_info(PurpleMedia *media, PurpleMediaInfoType type,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1273 const gchar *session_id, const gchar *participant,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1274 gboolean local)
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 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1277 g_return_if_fail(PURPLE_IS_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1278
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1279 if (type == PURPLE_MEDIA_INFO_ACCEPT) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1280 GList *streams;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1281
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1282 g_return_if_fail(PURPLE_IS_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1283
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1284 streams = purple_media_get_streams(media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1285 session_id, participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1286
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1287 for (; streams; streams =
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1288 g_list_delete_link(streams, streams)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1289 PurpleMediaStream *stream = streams->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1290 g_object_set(G_OBJECT(stream->stream), "direction",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1291 purple_media_to_fs_stream_direction(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1292 stream->session->type), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1293 stream->accepted = TRUE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1294
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1295 if (stream->remote_candidates != NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1296 GError *err = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1297 fs_stream_set_remote_candidates(stream->stream,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1298 stream->remote_candidates, &err);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1299
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1300 if (err) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1301 purple_debug_error("media", "Error adding remote"
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1302 " candidates: %s\n", err->message);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1303 g_error_free(err);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1304 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1305 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1306 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1307 } else if (local == TRUE && (type == PURPLE_MEDIA_INFO_MUTE ||
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1308 type == PURPLE_MEDIA_INFO_UNMUTE)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1309 GList *sessions;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1310 gboolean active = (type == PURPLE_MEDIA_INFO_MUTE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1311
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1312 g_return_if_fail(PURPLE_IS_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1313
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1314 if (session_id == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1315 sessions = g_hash_table_get_values(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1316 media->priv->sessions);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1317 else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1318 sessions = g_list_prepend(NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1319 purple_media_get_session(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1320 media, session_id));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1321
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1322 purple_debug_info("media", "Turning mute %s\n",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1323 active ? "on" : "off");
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 for (; sessions; sessions = g_list_delete_link(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1326 sessions, sessions)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1327 PurpleMediaSession *session = sessions->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1328 if (session->type & PURPLE_MEDIA_SEND_AUDIO) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1329 gchar *name = g_strdup_printf("volume_%s",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1330 session->id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1331 GstElement *volume = gst_bin_get_by_name(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1332 GST_BIN(session->media->
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1333 priv->confbin), name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1334 g_free(name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1335 g_object_set(volume, "mute", active, NULL);
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 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1338 } else if (local == TRUE && (type == PURPLE_MEDIA_INFO_PAUSE ||
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1339 type == PURPLE_MEDIA_INFO_UNPAUSE)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1340 gboolean active = (type == PURPLE_MEDIA_INFO_PAUSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1341 GList *streams = purple_media_get_streams(media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1342 session_id, participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1343 for (; streams; streams = g_list_delete_link(streams, streams)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1344 PurpleMediaStream *stream = streams->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1345 if (stream->session->type & PURPLE_MEDIA_SEND_VIDEO) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1346 g_object_set(stream->stream, "direction",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1347 purple_media_to_fs_stream_direction(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1348 stream->session->type & ((active) ?
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1349 ~PURPLE_MEDIA_SEND_VIDEO :
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1350 PURPLE_MEDIA_VIDEO)), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1351 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1352 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1353 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1354
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1355 g_signal_emit(media, purple_media_signals[STREAM_INFO],
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1356 0, type, session_id, participant, local);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1357
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1358 if (type == PURPLE_MEDIA_INFO_HANGUP ||
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1359 type == PURPLE_MEDIA_INFO_REJECT) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1360 purple_media_end(media, session_id, participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1361 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1362 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1363 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1364
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1365 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1366 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1367 purple_media_new_local_candidate_cb(FsStream *stream,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1368 FsCandidate *local_candidate,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1369 PurpleMediaSession *session)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1370 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1371 gchar *name;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1372 FsParticipant *participant;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1373 PurpleMediaCandidate *candidate;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1374
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1375 g_return_if_fail(FS_IS_STREAM(stream));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1376 g_return_if_fail(session != NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1377
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1378 purple_debug_info("media", "got new local candidate: %s\n", local_candidate->foundation);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1379 g_object_get(stream, "participant", &participant, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1380 g_object_get(participant, "cname", &name, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1381 g_object_unref(participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1382
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1383 purple_media_insert_local_candidate(session, name, fs_candidate_copy(local_candidate));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1384
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1385 candidate = purple_media_candidate_from_fs(local_candidate);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1386 g_signal_emit(session->media, purple_media_signals[NEW_CANDIDATE],
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1387 0, session->id, name, candidate);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1388 g_object_unref(candidate);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1389
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1390 g_free(name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1391 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1392
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1393 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1394 purple_media_candidates_prepared_cb(FsStream *stream, PurpleMediaSession *session)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1395 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1396 gchar *name;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1397 FsParticipant *participant;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1398 PurpleMediaStream *stream_data;
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 g_return_if_fail(FS_IS_STREAM(stream));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1401 g_return_if_fail(session != NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1402
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1403 g_object_get(stream, "participant", &participant, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1404 g_object_get(participant, "cname", &name, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1405 g_object_unref(participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1406
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1407 stream_data = purple_media_get_stream(session->media, session->id, name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1408 stream_data->candidates_prepared = TRUE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1409
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1410 g_signal_emit(session->media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1411 purple_media_signals[CANDIDATES_PREPARED],
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1412 0, session->id, name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1413
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1414 g_free(name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1415 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1416
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1417 /* callback called when a pair of transport candidates (local and remote)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1418 * has been established */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1419 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1420 purple_media_candidate_pair_established_cb(FsStream *fsstream,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1421 FsCandidate *native_candidate,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1422 FsCandidate *remote_candidate,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1423 PurpleMediaSession *session)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1424 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1425 gchar *name;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1426 FsParticipant *participant;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1427 PurpleMediaStream *stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1428 GList *iter;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1429
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1430 g_return_if_fail(FS_IS_STREAM(fsstream));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1431 g_return_if_fail(session != NULL);
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 g_object_get(fsstream, "participant", &participant, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1434 g_object_get(participant, "cname", &name, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1435 g_object_unref(participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1436
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1437 stream = purple_media_get_stream(session->media, session->id, name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1438
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1439 iter = stream->active_local_candidates;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1440 for(; iter; iter = g_list_next(iter)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1441 FsCandidate *c = iter->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1442 if (native_candidate->component_id == c->component_id) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1443 fs_candidate_destroy(c);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1444 stream->active_local_candidates =
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1445 g_list_delete_link(iter, iter);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1446 stream->active_local_candidates = g_list_prepend(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1447 stream->active_local_candidates,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1448 fs_candidate_copy(native_candidate));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1449 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1450 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1451 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1452 if (iter == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1453 stream->active_local_candidates = g_list_prepend(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1454 stream->active_local_candidates,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1455 fs_candidate_copy(native_candidate));
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 iter = stream->active_remote_candidates;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1458 for(; iter; iter = g_list_next(iter)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1459 FsCandidate *c = iter->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1460 if (native_candidate->component_id == c->component_id) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1461 fs_candidate_destroy(c);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1462 stream->active_remote_candidates =
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1463 g_list_delete_link(iter, iter);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1464 stream->active_remote_candidates = g_list_prepend(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1465 stream->active_remote_candidates,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1466 fs_candidate_copy(remote_candidate));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1467 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1468 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1469 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1470 if (iter == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1471 stream->active_remote_candidates = g_list_prepend(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1472 stream->active_remote_candidates,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1473 fs_candidate_copy(remote_candidate));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1474
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1475 purple_debug_info("media", "candidate pair established\n");
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1478 static gboolean
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1479 purple_media_connected_cb(PurpleMediaStream *stream)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1480 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1481 g_return_val_if_fail(stream != NULL, FALSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1482
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1483 stream->connected_cb_id = 0;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1484
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1485 purple_media_manager_create_output_window(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1486 stream->session->media->priv->manager,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1487 stream->session->media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1488 stream->session->id, stream->participant);
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 g_signal_emit(stream->session->media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1491 purple_media_signals[STATE_CHANGED],
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1492 0, PURPLE_MEDIA_STATE_CONNECTED,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1493 stream->session->id, stream->participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1494 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1495 }
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 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1498 purple_media_src_pad_added_cb(FsStream *fsstream, GstPad *srcpad,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1499 FsCodec *codec, PurpleMediaStream *stream)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1500 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1501 PurpleMediaPrivate *priv;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1502 GstPad *sinkpad;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1503
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1504 g_return_if_fail(FS_IS_STREAM(fsstream));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1505 g_return_if_fail(stream != NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1506
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1507 priv = stream->session->media->priv;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1508
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1509 if (stream->src == NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1510 GstElement *sink = NULL;
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 if (codec->media_type == FS_MEDIA_TYPE_AUDIO) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1513 GstElement *queue = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1514 double output_volume = purple_prefs_get_int(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1515 "/purple/media/audio/volume/output")/10.0;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1516 /*
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1517 * Should this instead be:
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1518 * audioconvert ! audioresample ! liveadder !
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1519 * audioresample ! audioconvert ! realsink
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1520 */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1521 queue = gst_element_factory_make("queue", NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1522 stream->volume = gst_element_factory_make(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1523 "volume", NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1524 g_object_set(stream->volume, "volume",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1525 output_volume, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1526 stream->level = gst_element_factory_make(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1527 "level", NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1528 stream->src = gst_element_factory_make(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1529 "liveadder", NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1530 sink = purple_media_manager_get_element(priv->manager,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1531 PURPLE_MEDIA_RECV_AUDIO,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1532 stream->session->media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1533 stream->session->id,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1534 stream->participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1535 gst_bin_add(GST_BIN(priv->confbin), queue);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1536 gst_bin_add(GST_BIN(priv->confbin), stream->volume);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1537 gst_bin_add(GST_BIN(priv->confbin), stream->level);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1538 gst_bin_add(GST_BIN(priv->confbin), sink);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1539 gst_element_set_state(sink, GST_STATE_PLAYING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1540 gst_element_set_state(stream->level, GST_STATE_PLAYING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1541 gst_element_set_state(stream->volume, GST_STATE_PLAYING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1542 gst_element_set_state(queue, GST_STATE_PLAYING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1543 gst_element_link(stream->level, sink);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1544 gst_element_link(stream->volume, stream->level);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1545 gst_element_link(queue, stream->volume);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1546 sink = queue;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1547 } else if (codec->media_type == FS_MEDIA_TYPE_VIDEO) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1548 stream->src = gst_element_factory_make(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1549 "fsfunnel", NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1550 sink = gst_element_factory_make(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1551 "fakesink", NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1552 g_object_set(G_OBJECT(sink), "async", FALSE, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1553 gst_bin_add(GST_BIN(priv->confbin), sink);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1554 gst_element_set_state(sink, GST_STATE_PLAYING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1555 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1556 stream->tee = gst_element_factory_make("tee", NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1557 gst_bin_add_many(GST_BIN(priv->confbin),
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1558 stream->src, stream->tee, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1559 gst_element_set_state(stream->tee, GST_STATE_PLAYING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1560 gst_element_set_state(stream->src, GST_STATE_PLAYING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1561 gst_element_link_many(stream->src, stream->tee, sink, NULL);
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 sinkpad = gst_element_get_request_pad(stream->src, "sink%d");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1565 gst_pad_link(srcpad, sinkpad);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1566 gst_object_unref(sinkpad);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1567
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1568 stream->connected_cb_id = purple_timeout_add(0,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1569 (GSourceFunc)purple_media_connected_cb, stream);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1570 }
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 static void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1573 purple_media_element_added_cb(FsElementAddedNotifier *self,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1574 GstBin *bin, GstElement *element, gpointer user_data)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1575 {
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 * Hack to make H264 work with Gmail video.
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1578 */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1579 if (!strncmp(GST_ELEMENT_NAME(element), "x264", 4)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1580 g_object_set(GST_OBJECT(element), "cabac", FALSE, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1581 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1582 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1583 #endif /* USE_VV */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1584
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1585 gboolean
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1586 purple_media_add_stream(PurpleMedia *media, const gchar *sess_id,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1587 const gchar *who, PurpleMediaSessionType type,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1588 gboolean initiator, const gchar *transmitter,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1589 guint num_params, GParameter *params)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1590 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1591 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1592 PurpleMediaSession *session;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1593 FsParticipant *participant = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1594 PurpleMediaStream *stream = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1595 FsMediaType media_type = purple_media_to_fs_media_type(type);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1596 FsStreamDirection type_direction =
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1597 purple_media_to_fs_stream_direction(type);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1598 gboolean is_nice = !strcmp(transmitter, "nice");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1599
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1600 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1601
29549
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1602 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
1603 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
1604 num_params, params)) {
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1605 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
1606 return FALSE;
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1607 }
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1608
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1609 /* 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
1610 if (media->priv->conference == NULL) {
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1611 GstBus *bus;
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1612 media->priv->conference =
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1613 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
1614 PURPLE_MEDIA_BACKEND_FS2(
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1615 media->priv->backend));
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1616 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
1617 media->priv->conference);
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1618 bus = gst_pipeline_get_bus(GST_PIPELINE(
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1619 purple_media_manager_get_pipeline(
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1620 purple_media_manager_get())));
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1621 g_signal_connect(G_OBJECT(bus), "message",
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1622 G_CALLBACK(media_bus_call), media);
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1623 gst_object_unref(bus);
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1624 }
41ae97b7e97e Start to use the media backend code in PurpleMedia and PurpleMediaManager.
maiku@pidgin.im
parents: 29545
diff changeset
1625
29534
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1626 session = purple_media_get_session(media, sess_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1627
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1628 if (!session) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1629 GError *err = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1630 GList *codec_conf = NULL, *iter = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1631 gchar *filename = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1632 PurpleMediaSessionType session_type;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1633 GstElement *src = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1634
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1635 session = g_new0(PurpleMediaSession, 1);
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 session->session = fs_conference_new_session(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1638 media->priv->conference, media_type, &err);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1639
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1640 if (err != NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1641 purple_media_error(media, _("Error creating session: %s"), err->message);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1642 g_error_free(err);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1643 g_free(session);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1644 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1645 }
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 filename = g_build_filename(purple_user_dir(), "fs-codec.conf", NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1648 codec_conf = fs_codec_list_from_keyfile(filename, &err);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1649 g_free(filename);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1650
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1651 if (err != NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1652 if (err->code == 4)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1653 purple_debug_info("media", "Couldn't read "
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1654 "fs-codec.conf: %s\n",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1655 err->message);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1656 else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1657 purple_debug_error("media", "Error reading "
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1658 "fs-codec.conf: %s\n",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1659 err->message);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1660 g_error_free(err);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1661 }
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 * Add SPEEX if the configuration file doesn't exist or
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1665 * there isn't a speex entry.
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 for (iter = codec_conf; iter; iter = g_list_next(iter)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1668 FsCodec *codec = iter->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1669 if (!g_ascii_strcasecmp(codec->encoding_name, "speex"))
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1670 break;
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1673 if (iter == NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1674 codec_conf = g_list_prepend(codec_conf,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1675 fs_codec_new(FS_CODEC_ID_ANY,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1676 "SPEEX", FS_MEDIA_TYPE_AUDIO, 8000));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1677 codec_conf = g_list_prepend(codec_conf,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1678 fs_codec_new(FS_CODEC_ID_ANY,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1679 "SPEEX", FS_MEDIA_TYPE_AUDIO, 16000));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1680 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1681
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1682 fs_session_set_codec_preferences(session->session, codec_conf, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1683
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1684 /*
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1685 * Removes a 5-7 second delay before
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1686 * receiving the src-pad-added signal.
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1687 * Only works for non-multicast FsRtpSessions.
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1688 */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1689 if (is_nice || !strcmp(transmitter, "rawudp"))
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1690 g_object_set(G_OBJECT(session->session),
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1691 "no-rtcp-timeout", 0, NULL);
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 * Hack to make x264 work with Gmail video.
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1695 */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1696 if (is_nice && !strcmp(sess_id, "google-video")) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1697 FsElementAddedNotifier *notifier =
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1698 fs_element_added_notifier_new();
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1699 g_signal_connect(G_OBJECT(notifier), "element-added",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1700 G_CALLBACK(purple_media_element_added_cb),
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1701 stream);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1702 fs_element_added_notifier_add(notifier,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1703 GST_BIN(media->priv->conference));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1704 }
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 fs_codec_list_destroy(codec_conf);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1707
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1708 session->id = g_strdup(sess_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1709 session->media = media;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1710 session->type = type;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1711 session->initiator = initiator;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1712
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1713 purple_media_add_session(media, session);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1714 g_signal_emit(media, purple_media_signals[STATE_CHANGED],
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1715 0, PURPLE_MEDIA_STATE_NEW,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1716 session->id, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1717
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1718 if (type_direction & FS_DIRECTION_SEND) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1719 session_type = purple_media_from_fs(media_type,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1720 FS_DIRECTION_SEND);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1721 src = purple_media_manager_get_element(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1722 media->priv->manager, session_type,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1723 media, session->id, who);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1724 if (!GST_IS_ELEMENT(src)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1725 purple_debug_error("media",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1726 "Error creating src for session %s\n",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1727 session->id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1728 purple_media_end(media, session->id, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1729 return FALSE;
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1732 purple_media_set_src(media, session->id, src);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1733 gst_element_set_state(session->src, GST_STATE_PLAYING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1734 purple_media_manager_create_output_window(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1735 media->priv->manager,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1736 session->media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1737 session->id, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1738 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1739 }
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 if (!(participant = purple_media_add_participant(media, who))) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1742 purple_media_remove_session(media, session);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1743 g_free(session);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1744 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1745 } else {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1746 g_signal_emit(media, purple_media_signals[STATE_CHANGED],
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1747 0, PURPLE_MEDIA_STATE_NEW,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1748 NULL, who);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1749 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1750
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1751 stream = purple_media_get_stream(media, sess_id, who);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1752
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1753 if (!stream) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1754 GError *err = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1755 FsStream *fsstream = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1756 const gchar *stun_ip = purple_network_get_stun_ip();
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1757 const gchar *turn_ip = purple_network_get_turn_ip();
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 if (stun_ip || turn_ip) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1760 guint new_num_params =
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1761 (stun_ip && is_nice) && turn_ip ?
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1762 num_params + 2 : num_params + 1;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1763 guint next_param_index = num_params;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1764 GParameter *param = g_new0(GParameter, new_num_params);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1765 memcpy(param, params, sizeof(GParameter) * num_params);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1766
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1767 if (stun_ip) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1768 purple_debug_info("media",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1769 "setting property stun-ip on new stream: %s\n", stun_ip);
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 param[next_param_index].name = "stun-ip";
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1772 g_value_init(&param[next_param_index].value, G_TYPE_STRING);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1773 g_value_set_string(&param[next_param_index].value, stun_ip);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1774 next_param_index++;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1775 }
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 if (turn_ip && is_nice) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1778 GValueArray *relay_info = g_value_array_new(0);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1779 GValue value;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1780 gint turn_port =
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1781 purple_prefs_get_int("/purple/network/turn_port");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1782 const gchar *username =
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1783 purple_prefs_get_string("/purple/network/turn_username");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1784 const gchar *password =
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1785 purple_prefs_get_string("/purple/network/turn_password");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1786 GstStructure *turn_setup = gst_structure_new("relay-info",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1787 "ip", G_TYPE_STRING, turn_ip,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1788 "port", G_TYPE_UINT, turn_port,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1789 "username", G_TYPE_STRING, username,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1790 "password", G_TYPE_STRING, password,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1791 NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1792
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1793 if (turn_setup) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1794 memset(&value, 0, sizeof(GValue));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1795 g_value_init(&value, GST_TYPE_STRUCTURE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1796 gst_value_set_structure(&value, turn_setup);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1797 relay_info = g_value_array_append(relay_info, &value);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1798 gst_structure_free(turn_setup);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1799
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1800 purple_debug_info("media",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1801 "setting property relay-info on new stream\n");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1802 param[next_param_index].name = "relay-info";
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1803 g_value_init(&param[next_param_index].value,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1804 G_TYPE_VALUE_ARRAY);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1805 g_value_set_boxed(&param[next_param_index].value,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1806 relay_info);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1807 g_value_array_free(relay_info);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1808 } else {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1809 purple_debug_error("media", "Error relay info");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1810 g_object_unref(participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1811 g_hash_table_remove(media->priv->participants, who);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1812 purple_media_remove_session(media, session);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1813 g_free(session);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1814 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1815 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1816 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1817
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1818 fsstream = fs_session_new_stream(session->session,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1819 participant, type_direction &
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1820 FS_DIRECTION_RECV, transmitter,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1821 new_num_params, param, &err);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1822 g_free(param);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1823 } else {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1824 fsstream = fs_session_new_stream(session->session,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1825 participant, type_direction &
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1826 FS_DIRECTION_RECV, transmitter,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1827 num_params, params, &err);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1828 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1829
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1830 if (fsstream == NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1831 purple_debug_error("media",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1832 "Error creating stream: %s\n",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1833 err && err->message ?
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1834 err->message : "NULL");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1835 if (err)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1836 g_error_free(err);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1837 g_object_unref(participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1838 g_hash_table_remove(media->priv->participants, who);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1839 purple_media_remove_session(media, session);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1840 g_free(session);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1841 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1842 }
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 stream = purple_media_insert_stream(session, who, fsstream);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1845 stream->initiator = initiator;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1846
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1847 /* callback for source pad added (new stream source ready) */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1848 g_signal_connect(G_OBJECT(fsstream),
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1849 "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
1850
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1851 g_signal_emit(media, purple_media_signals[STATE_CHANGED],
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1852 0, PURPLE_MEDIA_STATE_NEW,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1853 session->id, who);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1854 } else {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1855 if (purple_media_to_fs_stream_direction(stream->session->type)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1856 != type_direction) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1857 /* change direction */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1858 g_object_set(stream->stream, "direction",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1859 type_direction, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1860 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1861 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1862
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1863 return TRUE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1864 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1865 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1866 #endif /* USE_VV */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1867 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1868
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1869 PurpleMediaManager *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1870 purple_media_get_manager(PurpleMedia *media)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1871 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1872 PurpleMediaManager *ret;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1873 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1874 g_object_get(media, "manager", &ret, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1875 return ret;
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
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1878 PurpleMediaSessionType
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1879 purple_media_get_session_type(PurpleMedia *media, const gchar *sess_id)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1880 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1881 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1882 PurpleMediaSession *session;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1883 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
1884 session = purple_media_get_session(media, sess_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1885 return session->type;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1886 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1887 return PURPLE_MEDIA_NONE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1888 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1889 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1890 /* 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
1891 GList *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1892 purple_media_get_codecs(PurpleMedia *media, const gchar *sess_id)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1893 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1894 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1895 GList *fscodecs;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1896 GList *codecs;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1897 PurpleMediaSession *session;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1898
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1899 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
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 session = purple_media_get_session(media, sess_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1902
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1903 if (session == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1904 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1905
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1906 g_object_get(G_OBJECT(session->session),
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1907 "codecs", &fscodecs, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1908 codecs = purple_media_codec_list_from_fs(fscodecs);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1909 fs_codec_list_destroy(fscodecs);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1910 return codecs;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1911 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1912 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1913 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1914 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1915
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1916 GList *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1917 purple_media_get_local_candidates(PurpleMedia *media, const gchar *sess_id,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1918 const gchar *participant)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1919 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1920 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1921 PurpleMediaStream *stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1922 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1923 stream = purple_media_get_stream(media, sess_id, participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1924 return stream ? purple_media_candidate_list_from_fs(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1925 stream->local_candidates) : NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1926 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1927 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1928 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1929 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1930
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1931 void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1932 purple_media_add_remote_candidates(PurpleMedia *media, const gchar *sess_id,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1933 const gchar *participant,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1934 GList *remote_candidates)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1935 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1936 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1937 PurpleMediaStream *stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1938 GError *err = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1939
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1940 g_return_if_fail(PURPLE_IS_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1941 stream = purple_media_get_stream(media, sess_id, participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1942
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1943 if (stream == NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1944 purple_debug_error("media",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1945 "purple_media_add_remote_candidates: "
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1946 "couldn't find stream %s %s.\n",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1947 sess_id ? sess_id : "(null)",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1948 participant ? participant : "(null)");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1949 return;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1950 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1951
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1952 stream->remote_candidates = g_list_concat(stream->remote_candidates,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1953 purple_media_candidate_list_to_fs(remote_candidates));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1954
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1955 if (stream->accepted == TRUE) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1956 fs_stream_set_remote_candidates(stream->stream,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1957 stream->remote_candidates, &err);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1958
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1959 if (err) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1960 purple_debug_error("media", "Error adding remote"
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1961 " candidates: %s\n", err->message);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1962 g_error_free(err);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1963 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1964 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1965 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1966 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1967
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1968 #if 0
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1969 /*
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1970 * 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
1971 * until they are needed. If they ever are.
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1972 */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1973
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1974 GList *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1975 purple_media_get_active_local_candidates(PurpleMedia *media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1976 const gchar *sess_id, const gchar *participant)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1977 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1978 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1979 PurpleMediaStream *stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1980 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1981 stream = purple_media_get_stream(media, sess_id, participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1982 return purple_media_candidate_list_from_fs(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1983 stream->active_local_candidates);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1984 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1985 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1986 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1987 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1988
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1989 GList *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1990 purple_media_get_active_remote_candidates(PurpleMedia *media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1991 const gchar *sess_id, const gchar *participant)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1992 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1993 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1994 PurpleMediaStream *stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1995 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1996 stream = purple_media_get_stream(media, sess_id, participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1997 return purple_media_candidate_list_from_fs(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1998 stream->active_remote_candidates);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
1999 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2000 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2001 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2002 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2003 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2004
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2005 gboolean
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2006 purple_media_set_remote_codecs(PurpleMedia *media, const gchar *sess_id,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2007 const gchar *participant, GList *codecs)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2008 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2009 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2010 PurpleMediaStream *stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2011 FsStream *fsstream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2012 GList *fscodecs;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2013 GError *err = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2014
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2015 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2016 stream = purple_media_get_stream(media, sess_id, participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2017
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2018 if (stream == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2019 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2020
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2021 fsstream = stream->stream;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2022 fscodecs = purple_media_codec_list_to_fs(codecs);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2023 fs_stream_set_remote_codecs(fsstream, fscodecs, &err);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2024 fs_codec_list_destroy(fscodecs);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2025
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2026 if (err) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2027 purple_debug_error("media", "Error setting remote codecs: %s\n",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2028 err->message);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2029 g_error_free(err);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2030 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2031 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2032 return TRUE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2033 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2034 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2035 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2036 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2037
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2038 gboolean
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2039 purple_media_candidates_prepared(PurpleMedia *media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2040 const gchar *session_id, const gchar *participant)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2041 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2042 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2043 GList *streams;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2044 gboolean prepared = TRUE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2045
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2046 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2047
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2048 streams = purple_media_get_streams(media, session_id, participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2049
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2050 for (; streams; streams = g_list_delete_link(streams, streams)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2051 PurpleMediaStream *stream = streams->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2052 if (stream->candidates_prepared == FALSE) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2053 g_list_free(streams);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2054 prepared = FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2055 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2056 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2057 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2058
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2059 return prepared;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2060 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2061 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2062 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2063 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2064
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2065 gboolean
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2066 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
2067 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2068 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2069 PurpleMediaSession *session;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2070 FsCodec *fscodec;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2071 GError *err = NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2072
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2073 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2074
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2075 session = purple_media_get_session(media, sess_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2076
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2077 if (session != NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2078 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2079
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2080 fscodec = purple_media_codec_to_fs(codec);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2081 fs_session_set_send_codec(session->session, fscodec, &err);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2082 fs_codec_destroy(fscodec);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2083
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2084 if (err) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2085 purple_debug_error("media", "Error setting send codec\n");
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2086 g_error_free(err);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2087 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2088 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2089 return TRUE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2090 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2091 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2092 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2093 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2094
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2095 gboolean
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2096 purple_media_codecs_ready(PurpleMedia *media, const gchar *sess_id)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2097 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2098 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2099 gboolean ret;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2100
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2101 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2102
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2103 if (sess_id != NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2104 PurpleMediaSession *session;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2105 session = purple_media_get_session(media, sess_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2106
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2107 if (session == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2108 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2109 if (session->type & (PURPLE_MEDIA_SEND_AUDIO |
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2110 PURPLE_MEDIA_SEND_VIDEO))
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2111 g_object_get(session->session,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2112 "codecs-ready", &ret, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2113 else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2114 ret = TRUE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2115 } else {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2116 GList *values = g_hash_table_get_values(media->priv->sessions);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2117 for (; values; values = g_list_delete_link(values, values)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2118 PurpleMediaSession *session = values->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2119 if (session->type & (PURPLE_MEDIA_SEND_AUDIO |
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2120 PURPLE_MEDIA_SEND_VIDEO))
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2121 g_object_get(session->session,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2122 "codecs-ready", &ret, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2123 else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2124 ret = TRUE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2125
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2126 if (ret == FALSE)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2127 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2128 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2129 if (values != NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2130 g_list_free(values);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2131 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2132 return ret;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2133 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2134 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2135 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2136 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2137
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2138 gboolean
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2139 purple_media_is_initiator(PurpleMedia *media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2140 const gchar *sess_id, const gchar *participant)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2141 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2142 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2143 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2144
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2145 if (sess_id == NULL && participant == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2146 return media->priv->initiator;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2147 else if (sess_id != NULL && participant == NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2148 PurpleMediaSession *session =
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2149 purple_media_get_session(media, sess_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2150 return session != NULL ? session->initiator : FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2151 } else if (sess_id != NULL && participant != NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2152 PurpleMediaStream *stream = purple_media_get_stream(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2153 media, sess_id, participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2154 return stream != NULL ? stream->initiator : FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2155 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2156 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2157 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2158 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2159
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2160 gboolean
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2161 purple_media_accepted(PurpleMedia *media, const gchar *sess_id,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2162 const gchar *participant)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2163 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2164 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2165 gboolean accepted = TRUE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2166
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2167 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2168
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2169 if (sess_id == NULL && participant == NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2170 GList *streams = media->priv->streams;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2171
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2172 for (; streams; streams = g_list_next(streams)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2173 PurpleMediaStream *stream = streams->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2174 if (stream->accepted == FALSE) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2175 accepted = FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2176 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2177 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2178 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2179 } else if (sess_id != NULL && participant == NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2180 GList *streams = purple_media_get_streams(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2181 media, sess_id, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2182 for (; streams; streams =
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2183 g_list_delete_link(streams, streams)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2184 PurpleMediaStream *stream = streams->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2185 if (stream->accepted == FALSE) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2186 g_list_free(streams);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2187 accepted = FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2188 break;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2189 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2190 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2191 } else if (sess_id != NULL && participant != NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2192 PurpleMediaStream *stream = purple_media_get_stream(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2193 media, sess_id, participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2194 if (stream == NULL || stream->accepted == FALSE)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2195 accepted = FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2196 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2197
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2198 return accepted;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2199 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2200 return FALSE;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2201 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2202 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2203
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2204 void purple_media_set_input_volume(PurpleMedia *media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2205 const gchar *session_id, double level)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2206 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2207 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2208 GList *sessions;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2209
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2210 g_return_if_fail(PURPLE_IS_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2211
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2212 purple_prefs_set_int("/purple/media/audio/volume/input", level);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2213
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2214 if (session_id == NULL)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2215 sessions = g_hash_table_get_values(media->priv->sessions);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2216 else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2217 sessions = g_list_append(NULL,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2218 purple_media_get_session(media, session_id));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2219
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2220 for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2221 PurpleMediaSession *session = sessions->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2222
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2223 if (session->type & PURPLE_MEDIA_SEND_AUDIO) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2224 gchar *name = g_strdup_printf("volume_%s",
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2225 session->id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2226 GstElement *volume = gst_bin_get_by_name(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2227 GST_BIN(session->media->priv->confbin),
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2228 name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2229 g_free(name);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2230 g_object_set(volume, "volume", level/10.0, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2231 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2232 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2233 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2234 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2235
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2236 void purple_media_set_output_volume(PurpleMedia *media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2237 const gchar *session_id, const gchar *participant,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2238 double level)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2239 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2240 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2241 GList *streams;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2242
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2243 g_return_if_fail(PURPLE_IS_MEDIA(media));
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2244
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2245 purple_prefs_set_int("/purple/media/audio/volume/output", level);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2246
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2247 streams = purple_media_get_streams(media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2248 session_id, participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2249
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2250 for (; streams; streams = g_list_delete_link(streams, streams)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2251 PurpleMediaStream *stream = streams->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2252
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2253 if (stream->session->type & PURPLE_MEDIA_RECV_AUDIO
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2254 && GST_IS_ELEMENT(stream->volume)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2255 g_object_set(stream->volume, "volume", level/10.0, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2256 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2257 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2258 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2259 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2260
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2261 gulong
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2262 purple_media_set_output_window(PurpleMedia *media, const gchar *session_id,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2263 const gchar *participant, gulong window_id)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2264 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2265 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2266 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2267
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2268 return purple_media_manager_set_output_window(media->priv->manager,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2269 media, session_id, participant, window_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2270 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2271 return 0;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2272 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2273 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2274
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2275 void
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2276 purple_media_remove_output_windows(PurpleMedia *media)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2277 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2278 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2279 GList *iter = media->priv->streams;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2280 for (; iter; iter = g_list_next(iter)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2281 PurpleMediaStream *stream = iter->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2282 purple_media_manager_remove_output_windows(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2283 media->priv->manager, media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2284 stream->session->id, stream->participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2285 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2286
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2287 iter = purple_media_get_session_ids(media);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2288 for (; iter; iter = g_list_delete_link(iter, iter)) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2289 gchar *session_name = iter->data;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2290 purple_media_manager_remove_output_windows(
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2291 media->priv->manager, media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2292 session_name, NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2293 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2294 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2295 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2296
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2297 #ifdef USE_GSTREAMER
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2298 GstElement *
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2299 purple_media_get_tee(PurpleMedia *media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2300 const gchar *session_id, const gchar *participant)
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2301 {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2302 #ifdef USE_VV
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2303 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2304
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2305 if (session_id != NULL && participant == NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2306 PurpleMediaSession *session =
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2307 purple_media_get_session(media, session_id);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2308 return (session != NULL) ? session->tee : NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2309 } else if (session_id != NULL && participant != NULL) {
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2310 PurpleMediaStream *stream =
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2311 purple_media_get_stream(media,
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2312 session_id, participant);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2313 return (stream != NULL) ? stream->tee : NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2314 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2315 g_return_val_if_reached(NULL);
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2316 #else
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2317 return NULL;
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2318 #endif
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2319 }
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2320 #endif /* USE_GSTREAMER */
fb2c0674e828 Move media.c into libpurple/media/.
maiku@pidgin.im
parents:
diff changeset
2321