annotate libpurple/media/media.c @ 29554:2460e6774e08

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