libpurple/media.c

Thu, 19 Mar 2009 09:30:16 +0000

author
Michael Ruprecht <maiku@pidgin.im>
date
Thu, 19 Mar 2009 09:30:16 +0000
branch
vv
changeset 26417
b73b6e73abe6
parent 26412
f16755a1a0b5
child 26425
e052e2118184
permissions
-rw-r--r--

Add candidates-prepared signal to PurpleMedia.

19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1 /**
19889
defa6a4f45cc Cosmetics.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19885
diff changeset
2 * @file media.c Media API
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
3 * @ingroup core
26105
7647c0dcf202 * Added documentation to media.h and mediamanager.h
Michael Ruprecht <maiku@pidgin.im>
parents: 26103
diff changeset
4 */
7647c0dcf202 * Added documentation to media.h and mediamanager.h
Michael Ruprecht <maiku@pidgin.im>
parents: 26103
diff changeset
5
7647c0dcf202 * Added documentation to media.h and mediamanager.h
Michael Ruprecht <maiku@pidgin.im>
parents: 26103
diff changeset
6 /* purple
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
7 *
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
8 * Purple is the legal property of its developers, whose names are too numerous
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
9 * to list here. Please refer to the COPYRIGHT file distributed with this
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
10 * source distribution.
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
11 *
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
12 * This program is free software; you can redistribute it and/or modify
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
15 * (at your option) any later version.
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
16 *
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
20 * GNU General Public License for more details.
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
21 *
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
23 * along with this program; if not, write to the Free Software
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
25 */
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
26
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
27 #include <string.h>
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
28
19889
defa6a4f45cc Cosmetics.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19885
diff changeset
29 #include "internal.h"
defa6a4f45cc Cosmetics.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19885
diff changeset
30
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
31 #include "connection.h"
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
32 #include "media.h"
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
33 #include "marshallers.h"
26115
5f0500efc781 * Added input/output volume preferences for voice conversations.
Michael Ruprecht <maiku@pidgin.im>
parents: 26112
diff changeset
34 #include "mediamanager.h"
26256
d2673c935184 Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents: 26253
diff changeset
35 #include "network.h"
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
36
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
37 #include "debug.h"
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
38
23704
9b88c9b23aed Use USE_VV instead of USE_FARSIGHT.
Michael Ruprecht <maiku@pidgin.im>
parents: 23701
diff changeset
39 #ifdef USE_VV
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
40
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
41 #include <gst/interfaces/propertyprobe.h>
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
42 #include <gst/farsight/fs-conference-iface.h>
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
43
26162
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
44 /** @copydoc _PurpleMediaSession */
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
45 typedef struct _PurpleMediaSession PurpleMediaSession;
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
46 /** @copydoc _PurpleMediaStream */
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
47 typedef struct _PurpleMediaStream PurpleMediaStream;
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
48
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
49 struct _PurpleMediaSession
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
50 {
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
51 gchar *id;
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
52 PurpleMedia *media;
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
53 GstElement *src;
26321
a1d92d85cb34 Handle the session tee in the session rather than the src bin.
Michael Ruprecht <maiku@pidgin.im>
parents: 26320
diff changeset
54 GstElement *tee;
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
55 FsSession *session;
26162
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
56
26108
8d0fd2f195aa Changed PurpleMediaStreamType to PurpleMediaSessionType.
Michael Ruprecht <maiku@pidgin.im>
parents: 26105
diff changeset
57 PurpleMediaSessionType type;
26189
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
58
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
59 gboolean codecs_ready;
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
60 gboolean accepted;
26259
0983517fc75f Wait to create the sinks until the frames are ready.
Michael Ruprecht <maiku@pidgin.im>
parents: 26258
diff changeset
61
0983517fc75f Wait to create the sinks until the frames are ready.
Michael Ruprecht <maiku@pidgin.im>
parents: 26258
diff changeset
62 GstElement *sink;
0983517fc75f Wait to create the sinks until the frames are ready.
Michael Ruprecht <maiku@pidgin.im>
parents: 26258
diff changeset
63 gulong window_id;
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
64 };
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
65
26162
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
66 struct _PurpleMediaStream
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
67 {
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
68 PurpleMediaSession *session;
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
69 gchar *participant;
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
70 FsStream *stream;
26176
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
71 GstElement *sink;
26317
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
72 GstElement *src;
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
73 GstElement *tee;
26162
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
74
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
75 GList *local_candidates;
26200
6636bcf92be3 Add candidates instead of replacing them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26195
diff changeset
76 GList *remote_candidates;
26162
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
77
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
78 gboolean candidates_prepared;
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
79
26304
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
80 GList *active_local_candidates;
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
81 GList *active_remote_candidates;
26259
0983517fc75f Wait to create the sinks until the frames are ready.
Michael Ruprecht <maiku@pidgin.im>
parents: 26258
diff changeset
82
0983517fc75f Wait to create the sinks until the frames are ready.
Michael Ruprecht <maiku@pidgin.im>
parents: 26258
diff changeset
83 gulong window_id;
26324
4100af381e4e Use purple_timeout_* instead of g_timeout_*.
Michael Ruprecht <maiku@pidgin.im>
parents: 26323
diff changeset
84 guint connected_cb_id;
26162
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
85 };
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
86
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
87 struct _PurpleMediaPrivate
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
88 {
26315
c72d67da93eb Use the media manager that created the media session in media.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 26309
diff changeset
89 PurpleMediaManager *manager;
26327
6a436310d508 Added the connection property back to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26324
diff changeset
90 PurpleConnection *pc;
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
91 FsConference *conference;
26187
3b3059a7c091 Add initiator property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26185
diff changeset
92 gboolean initiator;
26328
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
93 gpointer prpl_data;
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
94
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
95 GHashTable *sessions; /* PurpleMediaSession table */
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
96 GHashTable *participants; /* FsParticipant table */
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
97
26162
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
98 GList *streams; /* PurpleMediaStream table */
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
99
26276
b9d3887b8318 Have all media sessions use a single pipeline.
Michael Ruprecht <maiku@pidgin.im>
parents: 26270
diff changeset
100 GstElement *confbin;
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
101 };
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
102
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
103 #define PURPLE_MEDIA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_MEDIA, PurpleMediaPrivate))
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
104
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
105 static void purple_media_class_init (PurpleMediaClass *klass);
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
106 static void purple_media_init (PurpleMedia *media);
26210
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
107 static void purple_media_dispose (GObject *object);
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
108 static void purple_media_finalize (GObject *object);
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
109 static void purple_media_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
110 static void purple_media_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
111
26121
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
112 static void purple_media_new_local_candidate_cb(FsStream *stream,
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
113 FsCandidate *local_candidate, PurpleMediaSession *session);
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
114 static void purple_media_candidates_prepared_cb(FsStream *stream,
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
115 PurpleMediaSession *session);
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
116 static void purple_media_candidate_pair_established_cb(FsStream *stream,
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
117 FsCandidate *native_candidate, FsCandidate *remote_candidate,
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
118 PurpleMediaSession *session);
26320
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
119 static gboolean media_bus_call(GstBus *bus,
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
120 GstMessage *msg, PurpleMedia *media);
26121
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
121
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
122 static GObjectClass *parent_class = NULL;
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
123
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
124
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
125
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
126 enum {
26182
728ad1da9cbc Add purple_media_error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26181
diff changeset
127 ERROR,
26266
069e72982f87 Added the accepted signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26265
diff changeset
128 ACCEPTED,
26417
b73b6e73abe6 Add candidates-prepared signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26412
diff changeset
129 CANDIDATES_PREPARED,
26265
66aee93241e2 Added codecs-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26264
diff changeset
130 CODECS_CHANGED,
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
131 NEW_CANDIDATE,
26189
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
132 READY_NEW,
26193
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
133 STATE_CHANGED,
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
134 LAST_SIGNAL
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
135 };
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
136 static guint purple_media_signals[LAST_SIGNAL] = {0};
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
137
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
138 enum {
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
139 PROP_0,
26315
c72d67da93eb Use the media manager that created the media session in media.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 26309
diff changeset
140 PROP_MANAGER,
26327
6a436310d508 Added the connection property back to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26324
diff changeset
141 PROP_CONNECTION,
26185
6061487f59a7 Rename "fs-conference" to "conference".
Michael Ruprecht <maiku@pidgin.im>
parents: 26184
diff changeset
142 PROP_CONFERENCE,
26187
3b3059a7c091 Add initiator property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26185
diff changeset
143 PROP_INITIATOR,
26328
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
144 PROP_PRPL_DATA,
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
145 };
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
146
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
147 GType
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
148 purple_media_get_type()
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
149 {
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
150 static GType type = 0;
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
151
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
152 if (type == 0) {
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
153 static const GTypeInfo info = {
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
154 sizeof(PurpleMediaClass),
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
155 NULL,
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
156 NULL,
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
157 (GClassInitFunc) purple_media_class_init,
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
158 NULL,
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
159 NULL,
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
160 sizeof(PurpleMedia),
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
161 0,
22071
4c47e360e467 Fix the prplinfo structs and get rid of some compile warnings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19889
diff changeset
162 (GInstanceInitFunc) purple_media_init,
4c47e360e467 Fix the prplinfo structs and get rid of some compile warnings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19889
diff changeset
163 NULL
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
164 };
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
165 type = g_type_register_static(G_TYPE_OBJECT, "PurpleMedia", &info, 0);
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
166 }
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
167 return type;
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
168 }
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
169
26193
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
170 GType
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
171 purple_media_state_changed_get_type()
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
172 {
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
173 static GType type = 0;
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
174 if (type == 0) {
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
175 static const GEnumValue values[] = {
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
176 { PURPLE_MEDIA_STATE_CHANGED_NEW, "PURPLE_MEDIA_STATE_CHANGED_NEW", "new" },
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
177 { PURPLE_MEDIA_STATE_CHANGED_CONNECTED, "PURPLE_MEDIA_STATE_CHANGED_CONNECTED", "connected" },
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
178 { PURPLE_MEDIA_STATE_CHANGED_END, "PURPLE_MEDIA_STATE_CHANGED_END", "end" },
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
179 { 0, NULL, NULL }
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
180 };
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
181 type = g_enum_register_static("PurpleMediaStateChangedType", values);
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
182 }
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
183 return type;
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
184 }
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
185
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
186 static void
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
187 purple_media_class_init (PurpleMediaClass *klass)
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
188 {
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
189 GObjectClass *gobject_class = (GObjectClass*)klass;
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
190 parent_class = g_type_class_peek_parent(klass);
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
191
26210
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
192 gobject_class->dispose = purple_media_dispose;
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
193 gobject_class->finalize = purple_media_finalize;
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
194 gobject_class->set_property = purple_media_set_property;
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
195 gobject_class->get_property = purple_media_get_property;
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
196
26315
c72d67da93eb Use the media manager that created the media session in media.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 26309
diff changeset
197 g_object_class_install_property(gobject_class, PROP_MANAGER,
c72d67da93eb Use the media manager that created the media session in media.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 26309
diff changeset
198 g_param_spec_object("manager",
c72d67da93eb Use the media manager that created the media session in media.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 26309
diff changeset
199 "Purple Media Manager",
c72d67da93eb Use the media manager that created the media session in media.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 26309
diff changeset
200 "The media manager that contains this media session.",
c72d67da93eb Use the media manager that created the media session in media.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 26309
diff changeset
201 PURPLE_TYPE_MEDIA_MANAGER,
c72d67da93eb Use the media manager that created the media session in media.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 26309
diff changeset
202 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
c72d67da93eb Use the media manager that created the media session in media.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 26309
diff changeset
203
26327
6a436310d508 Added the connection property back to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26324
diff changeset
204 g_object_class_install_property(gobject_class, PROP_CONNECTION,
6a436310d508 Added the connection property back to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26324
diff changeset
205 g_param_spec_pointer("connection",
6a436310d508 Added the connection property back to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26324
diff changeset
206 "PurpleConnection",
6a436310d508 Added the connection property back to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26324
diff changeset
207 "The connection this media session is on.",
6a436310d508 Added the connection property back to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26324
diff changeset
208 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
6a436310d508 Added the connection property back to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26324
diff changeset
209
26185
6061487f59a7 Rename "fs-conference" to "conference".
Michael Ruprecht <maiku@pidgin.im>
parents: 26184
diff changeset
210 g_object_class_install_property(gobject_class, PROP_CONFERENCE,
6061487f59a7 Rename "fs-conference" to "conference".
Michael Ruprecht <maiku@pidgin.im>
parents: 26184
diff changeset
211 g_param_spec_object("conference",
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
212 "Farsight conference",
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
213 "The FsConference associated with this media.",
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
214 FS_TYPE_CONFERENCE,
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
215 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
216
26187
3b3059a7c091 Add initiator property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26185
diff changeset
217 g_object_class_install_property(gobject_class, PROP_INITIATOR,
3b3059a7c091 Add initiator property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26185
diff changeset
218 g_param_spec_boolean("initiator",
3b3059a7c091 Add initiator property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26185
diff changeset
219 "initiator",
3b3059a7c091 Add initiator property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26185
diff changeset
220 "If the local user initiated the conference.",
3b3059a7c091 Add initiator property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26185
diff changeset
221 FALSE,
3b3059a7c091 Add initiator property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26185
diff changeset
222 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
3b3059a7c091 Add initiator property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26185
diff changeset
223
26328
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
224 g_object_class_install_property(gobject_class, PROP_PRPL_DATA,
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
225 g_param_spec_pointer("prpl-data",
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
226 "gpointer",
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
227 "Data the prpl plugin set on the media session.",
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
228 G_PARAM_READWRITE));
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
229
26182
728ad1da9cbc Add purple_media_error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26181
diff changeset
230 purple_media_signals[ERROR] = g_signal_new("error", G_TYPE_FROM_CLASS(klass),
728ad1da9cbc Add purple_media_error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26181
diff changeset
231 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
728ad1da9cbc Add purple_media_error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26181
diff changeset
232 g_cclosure_marshal_VOID__STRING,
728ad1da9cbc Add purple_media_error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26181
diff changeset
233 G_TYPE_NONE, 1, G_TYPE_STRING);
26266
069e72982f87 Added the accepted signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26265
diff changeset
234 purple_media_signals[ACCEPTED] = g_signal_new("accepted", G_TYPE_FROM_CLASS(klass),
069e72982f87 Added the accepted signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26265
diff changeset
235 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
069e72982f87 Added the accepted signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26265
diff changeset
236 purple_smarshal_VOID__STRING_STRING,
069e72982f87 Added the accepted signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26265
diff changeset
237 G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
26417
b73b6e73abe6 Add candidates-prepared signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26412
diff changeset
238 purple_media_signals[CANDIDATES_PREPARED] = g_signal_new("candidates-prepared", G_TYPE_FROM_CLASS(klass),
b73b6e73abe6 Add candidates-prepared signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26412
diff changeset
239 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
b73b6e73abe6 Add candidates-prepared signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26412
diff changeset
240 purple_smarshal_VOID__STRING_STRING,
b73b6e73abe6 Add candidates-prepared signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26412
diff changeset
241 G_TYPE_NONE, 2, G_TYPE_STRING,
b73b6e73abe6 Add candidates-prepared signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26412
diff changeset
242 G_TYPE_STRING);
26265
66aee93241e2 Added codecs-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26264
diff changeset
243 purple_media_signals[CODECS_CHANGED] = g_signal_new("codecs-changed", G_TYPE_FROM_CLASS(klass),
66aee93241e2 Added codecs-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26264
diff changeset
244 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
66aee93241e2 Added codecs-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26264
diff changeset
245 g_cclosure_marshal_VOID__STRING,
66aee93241e2 Added codecs-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26264
diff changeset
246 G_TYPE_NONE, 1, G_TYPE_STRING);
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
247 purple_media_signals[NEW_CANDIDATE] = g_signal_new("new-candidate", G_TYPE_FROM_CLASS(klass),
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
248 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
249 purple_smarshal_VOID__POINTER_POINTER_OBJECT,
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
250 G_TYPE_NONE, 3, G_TYPE_POINTER,
26229
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
251 G_TYPE_POINTER, PURPLE_TYPE_MEDIA_CANDIDATE);
26189
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
252 purple_media_signals[READY_NEW] = g_signal_new("ready-new", G_TYPE_FROM_CLASS(klass),
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
253 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
254 purple_smarshal_VOID__STRING_STRING,
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
255 G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
26193
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
256 purple_media_signals[STATE_CHANGED] = g_signal_new("state-changed", G_TYPE_FROM_CLASS(klass),
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
257 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
258 purple_smarshal_VOID__ENUM_STRING_STRING,
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
259 G_TYPE_NONE, 3, PURPLE_MEDIA_TYPE_STATE_CHANGED,
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
260 G_TYPE_STRING, G_TYPE_STRING);
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
261 g_type_class_add_private(klass, sizeof(PurpleMediaPrivate));
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
262 }
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
263
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
264
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
265 static void
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
266 purple_media_init (PurpleMedia *media)
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
267 {
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
268 media->priv = PURPLE_MEDIA_GET_PRIVATE(media);
26406
9cd3c72d787d Zero out the proper size for the PurpleMediaPrivate structure.
Michael Ruprecht <maiku@pidgin.im>
parents: 26340
diff changeset
269 memset(media->priv, 0, sizeof(*media->priv));
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
270 }
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
271
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
272 static void
26162
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
273 purple_media_stream_free(PurpleMediaStream *stream)
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
274 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
275 if (stream == NULL)
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
276 return;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
277
26280
9c7d0dc8268e Set the purple_media_connected_cb timeout to a high priority and remove
Michael Ruprecht <maiku@pidgin.im>
parents: 26279
diff changeset
278 /* Remove the connected_cb timeout */
26324
4100af381e4e Use purple_timeout_* instead of g_timeout_*.
Michael Ruprecht <maiku@pidgin.im>
parents: 26323
diff changeset
279 if (stream->connected_cb_id != 0)
4100af381e4e Use purple_timeout_* instead of g_timeout_*.
Michael Ruprecht <maiku@pidgin.im>
parents: 26323
diff changeset
280 purple_timeout_remove(stream->connected_cb_id);
26280
9c7d0dc8268e Set the purple_media_connected_cb timeout to a high priority and remove
Michael Ruprecht <maiku@pidgin.im>
parents: 26279
diff changeset
281
26162
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
282 g_free(stream->participant);
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
283
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
284 if (stream->local_candidates)
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
285 fs_candidate_list_destroy(stream->local_candidates);
26200
6636bcf92be3 Add candidates instead of replacing them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26195
diff changeset
286 if (stream->remote_candidates)
6636bcf92be3 Add candidates instead of replacing them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26195
diff changeset
287 fs_candidate_list_destroy(stream->remote_candidates);
26162
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
288
26304
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
289 if (stream->active_local_candidates)
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
290 fs_candidate_list_destroy(stream->active_local_candidates);
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
291 if (stream->active_remote_candidates)
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
292 fs_candidate_list_destroy(stream->active_remote_candidates);
26162
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
293
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
294 g_free(stream);
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
295 }
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
296
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
297 static void
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
298 purple_media_session_free(PurpleMediaSession *session)
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
299 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
300 if (session == NULL)
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
301 return;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
302
26162
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
303 g_free(session->id);
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
304 g_free(session);
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
305 }
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
306
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
307 static void
26210
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
308 purple_media_dispose(GObject *media)
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
309 {
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
310 PurpleMediaPrivate *priv = PURPLE_MEDIA_GET_PRIVATE(media);
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
311 GList *iter = NULL;
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
312
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
313 purple_debug_info("media","purple_media_dispose\n");
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
314
26315
c72d67da93eb Use the media manager that created the media session in media.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 26309
diff changeset
315 purple_media_manager_remove_media(priv->manager, PURPLE_MEDIA(media));
26210
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
316
26276
b9d3887b8318 Have all media sessions use a single pipeline.
Michael Ruprecht <maiku@pidgin.im>
parents: 26270
diff changeset
317 if (priv->confbin) {
b9d3887b8318 Have all media sessions use a single pipeline.
Michael Ruprecht <maiku@pidgin.im>
parents: 26270
diff changeset
318 gst_element_set_state(GST_ELEMENT(priv->confbin),
b9d3887b8318 Have all media sessions use a single pipeline.
Michael Ruprecht <maiku@pidgin.im>
parents: 26270
diff changeset
319 GST_STATE_NULL);
26320
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
320 gst_bin_remove(GST_BIN(purple_media_manager_get_pipeline(
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
321 priv->manager)), priv->confbin);
26276
b9d3887b8318 Have all media sessions use a single pipeline.
Michael Ruprecht <maiku@pidgin.im>
parents: 26270
diff changeset
322 priv->confbin = NULL;
b9d3887b8318 Have all media sessions use a single pipeline.
Michael Ruprecht <maiku@pidgin.im>
parents: 26270
diff changeset
323 priv->conference = NULL;
26210
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
324 }
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
325
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
326 for (iter = priv->streams; iter; iter = g_list_next(iter)) {
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
327 PurpleMediaStream *stream = iter->data;
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
328 if (stream->stream) {
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
329 g_object_unref(stream->stream);
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
330 stream->stream = NULL;
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
331 }
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
332 }
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
333
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
334 if (priv->sessions) {
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
335 GList *sessions = g_hash_table_get_values(priv->sessions);
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
336 for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
337 PurpleMediaSession *session = sessions->data;
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
338 if (session->session) {
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
339 g_object_unref(session->session);
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
340 session->session = NULL;
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
341 }
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
342 }
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
343 }
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
344
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
345 if (priv->participants) {
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
346 GList *participants = g_hash_table_get_values(priv->participants);
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
347 for (; participants; participants = g_list_delete_link(participants, participants))
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
348 g_object_unref(participants->data);
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
349 }
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
350
26315
c72d67da93eb Use the media manager that created the media session in media.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 26309
diff changeset
351 if (priv->manager) {
26320
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
352 GstElement *pipeline = purple_media_manager_get_pipeline(
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
353 priv->manager);
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
354 GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
355 g_signal_handlers_disconnect_matched(G_OBJECT(bus),
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
356 G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
357 0, 0, 0, media_bus_call, media);
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
358 gst_object_unref(bus);
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
359
26315
c72d67da93eb Use the media manager that created the media session in media.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 26309
diff changeset
360 g_object_unref(priv->manager);
c72d67da93eb Use the media manager that created the media session in media.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 26309
diff changeset
361 priv->manager = NULL;
c72d67da93eb Use the media manager that created the media session in media.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 26309
diff changeset
362 }
c72d67da93eb Use the media manager that created the media session in media.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 26309
diff changeset
363
26412
f16755a1a0b5 Fix copy/paste-o.
Michael Ruprecht <maiku@pidgin.im>
parents: 26406
diff changeset
364 G_OBJECT_CLASS(parent_class)->dispose(media);
26210
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
365 }
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
366
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
367 static void
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
368 purple_media_finalize(GObject *media)
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
369 {
23711
c5058fc31d26 Free the PurpleMedia object when the media session ends and fix ending
Michael Ruprecht <maiku@pidgin.im>
parents: 23704
diff changeset
370 PurpleMediaPrivate *priv = PURPLE_MEDIA_GET_PRIVATE(media);
c5058fc31d26 Free the PurpleMedia object when the media session ends and fix ending
Michael Ruprecht <maiku@pidgin.im>
parents: 23704
diff changeset
371 purple_debug_info("media","purple_media_finalize\n");
c5058fc31d26 Free the PurpleMedia object when the media session ends and fix ending
Michael Ruprecht <maiku@pidgin.im>
parents: 23704
diff changeset
372
26181
8dd52c56abc0 Free Farsight objects better.
Michael Ruprecht <maiku@pidgin.im>
parents: 26180
diff changeset
373 for (; priv->streams; priv->streams = g_list_delete_link(priv->streams, priv->streams))
8dd52c56abc0 Free Farsight objects better.
Michael Ruprecht <maiku@pidgin.im>
parents: 26180
diff changeset
374 purple_media_stream_free(priv->streams->data);
8dd52c56abc0 Free Farsight objects better.
Michael Ruprecht <maiku@pidgin.im>
parents: 26180
diff changeset
375
26116
41f7d4545566 Fixed a ton of memory leaks.
Michael Ruprecht <maiku@pidgin.im>
parents: 26115
diff changeset
376 if (priv->sessions) {
41f7d4545566 Fixed a ton of memory leaks.
Michael Ruprecht <maiku@pidgin.im>
parents: 26115
diff changeset
377 GList *sessions = g_hash_table_get_values(priv->sessions);
41f7d4545566 Fixed a ton of memory leaks.
Michael Ruprecht <maiku@pidgin.im>
parents: 26115
diff changeset
378 for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
26162
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
379 purple_media_session_free(sessions->data);
26096
7249fdfc2eab Set the media pipeline to PLAYING immediately after initialization
Michael Ruprecht <maiku@pidgin.im>
parents: 23752
diff changeset
380 }
26116
41f7d4545566 Fixed a ton of memory leaks.
Michael Ruprecht <maiku@pidgin.im>
parents: 26115
diff changeset
381 g_hash_table_destroy(priv->sessions);
41f7d4545566 Fixed a ton of memory leaks.
Michael Ruprecht <maiku@pidgin.im>
parents: 26115
diff changeset
382 }
26096
7249fdfc2eab Set the media pipeline to PLAYING immediately after initialization
Michael Ruprecht <maiku@pidgin.im>
parents: 23752
diff changeset
383
26210
dffd522ea21e Use the dispose method too.
Michael Ruprecht <maiku@pidgin.im>
parents: 26209
diff changeset
384 G_OBJECT_CLASS(parent_class)->finalize(media);
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
385 }
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
386
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
387 static void
26320
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
388 purple_media_setup_pipeline(PurpleMedia *media)
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
389 {
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
390 GstBus *bus;
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
391 gchar *name;
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
392 GstElement *pipeline;
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
393
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
394 if (media->priv->conference == NULL || media->priv->manager == NULL)
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
395 return;
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
396
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
397 pipeline = purple_media_manager_get_pipeline(media->priv->manager);
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
398
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
399 name = g_strdup_printf("conf_%p",
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
400 media->priv->conference);
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
401 media->priv->confbin = gst_bin_new(name);
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
402 g_free(name);
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
403
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
404 bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
405 g_signal_connect(G_OBJECT(bus), "message",
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
406 G_CALLBACK(media_bus_call), media);
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
407 gst_object_unref(bus);
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
408
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
409 gst_bin_add(GST_BIN(pipeline),
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
410 media->priv->confbin);
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
411 gst_bin_add(GST_BIN(media->priv->confbin),
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
412 GST_ELEMENT(media->priv->conference));
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
413 gst_element_set_state(GST_ELEMENT(media->priv->confbin),
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
414 GST_STATE_PLAYING);
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
415 }
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
416
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
417 static void
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
418 purple_media_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
419 {
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
420 PurpleMedia *media;
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
421 g_return_if_fail(PURPLE_IS_MEDIA(object));
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
422
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
423 media = PURPLE_MEDIA(object);
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
424
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
425 switch (prop_id) {
26315
c72d67da93eb Use the media manager that created the media session in media.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 26309
diff changeset
426 case PROP_MANAGER:
c72d67da93eb Use the media manager that created the media session in media.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 26309
diff changeset
427 media->priv->manager = g_value_get_object(value);
c72d67da93eb Use the media manager that created the media session in media.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 26309
diff changeset
428 g_object_ref(media->priv->manager);
26320
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
429
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
430 purple_media_setup_pipeline(media);
26315
c72d67da93eb Use the media manager that created the media session in media.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 26309
diff changeset
431 break;
26327
6a436310d508 Added the connection property back to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26324
diff changeset
432 case PROP_CONNECTION:
6a436310d508 Added the connection property back to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26324
diff changeset
433 media->priv->pc = g_value_get_pointer(value);
6a436310d508 Added the connection property back to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26324
diff changeset
434 break;
26276
b9d3887b8318 Have all media sessions use a single pipeline.
Michael Ruprecht <maiku@pidgin.im>
parents: 26270
diff changeset
435 case PROP_CONFERENCE: {
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
436 if (media->priv->conference)
26276
b9d3887b8318 Have all media sessions use a single pipeline.
Michael Ruprecht <maiku@pidgin.im>
parents: 26270
diff changeset
437 gst_object_unref(media->priv->conference);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
438 media->priv->conference = g_value_get_object(value);
26276
b9d3887b8318 Have all media sessions use a single pipeline.
Michael Ruprecht <maiku@pidgin.im>
parents: 26270
diff changeset
439 gst_object_ref(media->priv->conference);
b9d3887b8318 Have all media sessions use a single pipeline.
Michael Ruprecht <maiku@pidgin.im>
parents: 26270
diff changeset
440
26320
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
441 purple_media_setup_pipeline(media);
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
442 break;
26276
b9d3887b8318 Have all media sessions use a single pipeline.
Michael Ruprecht <maiku@pidgin.im>
parents: 26270
diff changeset
443 }
26187
3b3059a7c091 Add initiator property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26185
diff changeset
444 case PROP_INITIATOR:
3b3059a7c091 Add initiator property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26185
diff changeset
445 media->priv->initiator = g_value_get_boolean(value);
3b3059a7c091 Add initiator property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26185
diff changeset
446 break;
26328
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
447 case PROP_PRPL_DATA:
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
448 media->priv->prpl_data = g_value_get_pointer(value);
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
449 break;
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
450 default:
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
451 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
452 break;
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
453 }
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
454 }
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
455
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
456 static void
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
457 purple_media_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
458 {
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
459 PurpleMedia *media;
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
460 g_return_if_fail(PURPLE_IS_MEDIA(object));
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
461
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
462 media = PURPLE_MEDIA(object);
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
463
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
464 switch (prop_id) {
26315
c72d67da93eb Use the media manager that created the media session in media.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 26309
diff changeset
465 case PROP_MANAGER:
c72d67da93eb Use the media manager that created the media session in media.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 26309
diff changeset
466 g_value_set_object(value, media->priv->manager);
c72d67da93eb Use the media manager that created the media session in media.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 26309
diff changeset
467 break;
26327
6a436310d508 Added the connection property back to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26324
diff changeset
468 case PROP_CONNECTION:
6a436310d508 Added the connection property back to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26324
diff changeset
469 g_value_set_pointer(value, media->priv->pc);
6a436310d508 Added the connection property back to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26324
diff changeset
470 break;
26185
6061487f59a7 Rename "fs-conference" to "conference".
Michael Ruprecht <maiku@pidgin.im>
parents: 26184
diff changeset
471 case PROP_CONFERENCE:
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
472 g_value_set_object(value, media->priv->conference);
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
473 break;
26187
3b3059a7c091 Add initiator property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26185
diff changeset
474 case PROP_INITIATOR:
3b3059a7c091 Add initiator property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26185
diff changeset
475 g_value_set_boolean(value, media->priv->initiator);
3b3059a7c091 Add initiator property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26185
diff changeset
476 break;
26328
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
477 case PROP_PRPL_DATA:
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
478 g_value_set_pointer(value, media->priv->prpl_data);
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
479 break;
19883
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
480 default:
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
481 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
482 break;
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
483 }
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
484
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
485 }
2b59550f211d Missed files
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
486
26229
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
487 PurpleMediaCandidate *
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
488 purple_media_candidate_new(const gchar *foundation, guint component_id,
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
489 PurpleMediaCandidateType type,
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
490 PurpleMediaNetworkProtocol proto,
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
491 const gchar *ip, guint port)
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
492 {
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
493 PurpleMediaCandidate *candidate = g_new0(PurpleMediaCandidate, 1);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
494 candidate->foundation = g_strdup(foundation);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
495 candidate->component_id = component_id;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
496 candidate->type = type;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
497 candidate->proto = proto;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
498 candidate->ip = g_strdup(ip);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
499 candidate->port = port;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
500 return candidate;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
501 }
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
502
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
503 static PurpleMediaCandidate *
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
504 purple_media_candidate_copy(PurpleMediaCandidate *candidate)
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
505 {
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
506 PurpleMediaCandidate *new_candidate;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
507
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
508 if (candidate == NULL)
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
509 return NULL;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
510
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
511 new_candidate = g_new0(PurpleMediaCandidate, 1);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
512 new_candidate->foundation = g_strdup(candidate->foundation);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
513 new_candidate->component_id = candidate->component_id;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
514 new_candidate->ip = g_strdup(candidate->ip);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
515 new_candidate->port = candidate->port;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
516 new_candidate->base_ip = g_strdup(candidate->base_ip);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
517 new_candidate->base_port = candidate->base_port;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
518 new_candidate->proto = candidate->proto;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
519 new_candidate->priority = candidate->priority;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
520 new_candidate->type = candidate->type;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
521 new_candidate->username = g_strdup(candidate->username);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
522 new_candidate->password = g_strdup(candidate->password);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
523 new_candidate->ttl = candidate->ttl;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
524 return new_candidate;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
525 }
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
526
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
527 static void
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
528 purple_media_candidate_free(PurpleMediaCandidate *candidate)
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
529 {
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
530 if (candidate == NULL)
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
531 return;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
532
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
533 g_free((gchar*)candidate->foundation);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
534 g_free((gchar*)candidate->ip);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
535 g_free((gchar*)candidate->base_ip);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
536 g_free((gchar*)candidate->username);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
537 g_free((gchar*)candidate->password);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
538 g_free(candidate);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
539 }
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
540
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
541 static FsCandidate *
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
542 purple_media_candidate_to_fs(PurpleMediaCandidate *candidate)
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
543 {
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
544 FsCandidate *fscandidate;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
545
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
546 if (candidate == NULL)
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
547 return NULL;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
548
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
549 fscandidate = fs_candidate_new(candidate->foundation,
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
550 candidate->component_id, candidate->type,
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
551 candidate->proto, candidate->ip, candidate->port);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
552
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
553 fscandidate->base_ip = g_strdup(candidate->base_ip);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
554 fscandidate->base_port = candidate->base_port;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
555 fscandidate->priority = candidate->priority;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
556 fscandidate->username = g_strdup(candidate->username);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
557 fscandidate->password = g_strdup(candidate->password);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
558 fscandidate->ttl = candidate->ttl;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
559 return fscandidate;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
560 }
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
561
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
562 static PurpleMediaCandidate *
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
563 purple_media_candidate_from_fs(FsCandidate *fscandidate)
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
564 {
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
565 PurpleMediaCandidate *candidate;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
566
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
567 if (fscandidate == NULL)
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
568 return NULL;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
569
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
570 candidate = purple_media_candidate_new(fscandidate->foundation,
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
571 fscandidate->component_id, fscandidate->type,
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
572 fscandidate->proto, fscandidate->ip, fscandidate->port);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
573 candidate->base_ip = g_strdup(fscandidate->base_ip);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
574 candidate->base_port = fscandidate->base_port;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
575 candidate->priority = fscandidate->priority;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
576 candidate->username = g_strdup(fscandidate->username);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
577 candidate->password = g_strdup(fscandidate->password);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
578 candidate->ttl = fscandidate->ttl;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
579 return candidate;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
580 }
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
581
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
582 static GList *
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
583 purple_media_candidate_list_from_fs(GList *candidates)
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
584 {
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
585 GList *new_list = NULL;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
586
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
587 for (; candidates; candidates = g_list_next(candidates)) {
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
588 new_list = g_list_prepend(new_list,
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
589 purple_media_candidate_from_fs(
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
590 candidates->data));
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
591 }
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
592
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
593 new_list = g_list_reverse(new_list);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
594 return new_list;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
595 }
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
596
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
597 static GList *
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
598 purple_media_candidate_list_to_fs(GList *candidates)
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
599 {
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
600 GList *new_list = NULL;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
601
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
602 for (; candidates; candidates = g_list_next(candidates)) {
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
603 new_list = g_list_prepend(new_list,
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
604 purple_media_candidate_to_fs(
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
605 candidates->data));
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
606 }
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
607
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
608 new_list = g_list_reverse(new_list);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
609 return new_list;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
610 }
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
611
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
612 GList *
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
613 purple_media_candidate_list_copy(GList *candidates)
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
614 {
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
615 GList *new_list = NULL;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
616
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
617 for (; candidates; candidates = g_list_next(candidates)) {
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
618 new_list = g_list_prepend(new_list, g_boxed_copy(
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
619 PURPLE_TYPE_MEDIA_CANDIDATE,
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
620 candidates->data));
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
621 }
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
622
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
623 new_list = g_list_reverse(new_list);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
624 return new_list;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
625 }
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
626
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
627 void
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
628 purple_media_candidate_list_free(GList *candidates)
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
629 {
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
630 for (; candidates; candidates =
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
631 g_list_delete_link(candidates, candidates)) {
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
632 g_boxed_free(PURPLE_TYPE_MEDIA_CANDIDATE,
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
633 candidates->data);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
634 }
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
635 }
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
636
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
637 GType
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
638 purple_media_candidate_get_type()
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
639 {
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
640 static GType type = 0;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
641
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
642 if (type == 0) {
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
643 type = g_boxed_type_register_static("PurpleMediaCandidate",
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
644 (GBoxedCopyFunc)purple_media_candidate_copy,
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
645 (GBoxedFreeFunc)purple_media_candidate_free);
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
646 }
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
647 return type;
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
648 }
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
649
26226
dcb05990f479 Make FsStreamDirection and FsMediaType conversion functions static.
Michael Ruprecht <maiku@pidgin.im>
parents: 26217
diff changeset
650 static FsMediaType
26108
8d0fd2f195aa Changed PurpleMediaStreamType to PurpleMediaSessionType.
Michael Ruprecht <maiku@pidgin.im>
parents: 26105
diff changeset
651 purple_media_to_fs_media_type(PurpleMediaSessionType type)
23724
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
652 {
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
653 if (type & PURPLE_MEDIA_AUDIO)
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
654 return FS_MEDIA_TYPE_AUDIO;
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
655 else if (type & PURPLE_MEDIA_VIDEO)
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
656 return FS_MEDIA_TYPE_VIDEO;
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
657 else
26121
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
658 return 0;
23724
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
659 }
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
660
26226
dcb05990f479 Make FsStreamDirection and FsMediaType conversion functions static.
Michael Ruprecht <maiku@pidgin.im>
parents: 26217
diff changeset
661 static FsStreamDirection
26108
8d0fd2f195aa Changed PurpleMediaStreamType to PurpleMediaSessionType.
Michael Ruprecht <maiku@pidgin.im>
parents: 26105
diff changeset
662 purple_media_to_fs_stream_direction(PurpleMediaSessionType type)
23724
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
663 {
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
664 if ((type & PURPLE_MEDIA_AUDIO) == PURPLE_MEDIA_AUDIO ||
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
665 (type & PURPLE_MEDIA_VIDEO) == PURPLE_MEDIA_VIDEO)
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
666 return FS_DIRECTION_BOTH;
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
667 else if ((type & PURPLE_MEDIA_SEND_AUDIO) ||
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
668 (type & PURPLE_MEDIA_SEND_VIDEO))
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
669 return FS_DIRECTION_SEND;
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
670 else if ((type & PURPLE_MEDIA_RECV_AUDIO) ||
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
671 (type & PURPLE_MEDIA_RECV_VIDEO))
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
672 return FS_DIRECTION_RECV;
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
673 else
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
674 return FS_DIRECTION_NONE;
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
675 }
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
676
26226
dcb05990f479 Make FsStreamDirection and FsMediaType conversion functions static.
Michael Ruprecht <maiku@pidgin.im>
parents: 26217
diff changeset
677 static PurpleMediaSessionType
23724
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
678 purple_media_from_fs(FsMediaType type, FsStreamDirection direction)
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
679 {
26108
8d0fd2f195aa Changed PurpleMediaStreamType to PurpleMediaSessionType.
Michael Ruprecht <maiku@pidgin.im>
parents: 26105
diff changeset
680 PurpleMediaSessionType result = PURPLE_MEDIA_NONE;
23724
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
681 if (type == FS_MEDIA_TYPE_AUDIO) {
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
682 if (direction & FS_DIRECTION_SEND)
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
683 result |= PURPLE_MEDIA_SEND_AUDIO;
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
684 if (direction & FS_DIRECTION_RECV)
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
685 result |= PURPLE_MEDIA_RECV_AUDIO;
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
686 } else if (type == FS_MEDIA_TYPE_VIDEO) {
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
687 if (direction & FS_DIRECTION_SEND)
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
688 result |= PURPLE_MEDIA_SEND_VIDEO;
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
689 if (direction & FS_DIRECTION_RECV)
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
690 result |= PURPLE_MEDIA_RECV_VIDEO;
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
691 }
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
692 return result;
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
693 }
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
694
26232
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
695 void
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
696 purple_media_codec_add_optional_parameter(PurpleMediaCodec *codec,
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
697 const gchar *name, const gchar *value)
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
698 {
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
699 PurpleMediaCodecParameter *new_param;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
700
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
701 g_return_if_fail(codec != NULL);
26232
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
702 g_return_if_fail(name != NULL && value != NULL);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
703
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
704 new_param = g_new0(PurpleMediaCodecParameter, 1);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
705 new_param->name = g_strdup(name);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
706 new_param->value = g_strdup(value);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
707 codec->optional_params = g_list_append(
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
708 codec->optional_params, new_param);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
709 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
710
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
711 void
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
712 purple_media_codec_remove_optional_parameter(PurpleMediaCodec *codec,
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
713 PurpleMediaCodecParameter *param)
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
714 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
715 g_return_if_fail(codec != NULL && param != NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
716
26232
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
717 g_free(param->name);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
718 g_free(param->value);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
719 g_free(param);
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
720
26232
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
721 codec->optional_params =
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
722 g_list_remove(codec->optional_params, param);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
723 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
724
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
725 PurpleMediaCodecParameter *
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
726 purple_media_codec_get_optional_parameter(PurpleMediaCodec *codec,
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
727 const gchar *name, const gchar *value)
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
728 {
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
729 GList *iter;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
730
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
731 g_return_val_if_fail(codec != NULL, NULL);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
732 g_return_val_if_fail(name != NULL, NULL);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
733
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
734 for (iter = codec->optional_params; iter; iter = g_list_next(iter)) {
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
735 PurpleMediaCodecParameter *param = iter->data;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
736 if (!g_ascii_strcasecmp(param->name, name) &&
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
737 (value == NULL ||
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
738 !g_ascii_strcasecmp(param->value, value)))
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
739 return param;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
740 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
741
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
742 return NULL;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
743 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
744
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
745 PurpleMediaCodec *
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
746 purple_media_codec_new(int id, const char *encoding_name,
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
747 PurpleMediaSessionType media_type, guint clock_rate)
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
748 {
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
749 PurpleMediaCodec *codec = g_new0(PurpleMediaCodec, 1);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
750
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
751 codec->id = id;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
752 codec->encoding_name = g_strdup(encoding_name);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
753 codec->media_type = media_type;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
754 codec->clock_rate = clock_rate;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
755 return codec;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
756 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
757
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
758 static PurpleMediaCodec *
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
759 purple_media_codec_copy(PurpleMediaCodec *codec)
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
760 {
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
761 PurpleMediaCodec *new_codec;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
762 GList *iter;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
763
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
764 if (codec == NULL)
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
765 return NULL;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
766
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
767 new_codec = purple_media_codec_new(codec->id, codec->encoding_name,
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
768 codec->media_type, codec->clock_rate);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
769 new_codec->channels = codec->channels;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
770
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
771 for (iter = codec->optional_params; iter; iter = g_list_next(iter)) {
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
772 PurpleMediaCodecParameter *param =
26235
10cecb64ea88 Manipulate optional parameters properly.
Michael Ruprecht <maiku@pidgin.im>
parents: 26234
diff changeset
773 (PurpleMediaCodecParameter*)iter->data;
26232
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
774 purple_media_codec_add_optional_parameter(new_codec,
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
775 param->name, param->value);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
776 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
777
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
778 return new_codec;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
779 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
780
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
781 static void
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
782 purple_media_codec_free(PurpleMediaCodec *codec)
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
783 {
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
784 if (codec == NULL)
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
785 return;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
786
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
787 g_free(codec->encoding_name);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
788
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
789 for (; codec->optional_params; codec->optional_params =
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
790 g_list_delete_link(codec->optional_params,
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
791 codec->optional_params)) {
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
792 purple_media_codec_remove_optional_parameter(codec,
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
793 codec->optional_params->data);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
794 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
795
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
796 g_free(codec);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
797 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
798
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
799 static FsCodec *
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
800 purple_media_codec_to_fs(const PurpleMediaCodec *codec)
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
801 {
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
802 FsCodec *new_codec;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
803 GList *iter;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
804
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
805 if (codec == NULL)
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
806 return NULL;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
807
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
808 new_codec = fs_codec_new(codec->id, codec->encoding_name,
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
809 purple_media_to_fs_media_type(codec->media_type),
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
810 codec->clock_rate);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
811 new_codec->channels = codec->channels;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
812
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
813 for (iter = codec->optional_params; iter; iter = g_list_next(iter)) {
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
814 PurpleMediaCodecParameter *param =
26235
10cecb64ea88 Manipulate optional parameters properly.
Michael Ruprecht <maiku@pidgin.im>
parents: 26234
diff changeset
815 (PurpleMediaCodecParameter*)iter->data;
26232
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
816 fs_codec_add_optional_parameter(new_codec,
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
817 param->name, param->value);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
818 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
819
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
820 return new_codec;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
821 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
822
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
823 static PurpleMediaCodec *
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
824 purple_media_codec_from_fs(const FsCodec *codec)
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
825 {
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
826 PurpleMediaCodec *new_codec;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
827 GList *iter;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
828
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
829 if (codec == NULL)
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
830 return NULL;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
831
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
832 new_codec = purple_media_codec_new(codec->id, codec->encoding_name,
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
833 purple_media_from_fs(codec->media_type,
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
834 FS_DIRECTION_BOTH), codec->clock_rate);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
835 new_codec->channels = codec->channels;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
836
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
837 for (iter = codec->optional_params; iter; iter = g_list_next(iter)) {
26235
10cecb64ea88 Manipulate optional parameters properly.
Michael Ruprecht <maiku@pidgin.im>
parents: 26234
diff changeset
838 FsCodecParameter *param = (FsCodecParameter*)iter->data;
26232
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
839 purple_media_codec_add_optional_parameter(new_codec,
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
840 param->name, param->value);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
841 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
842
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
843 return new_codec;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
844 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
845
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
846 gchar *
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
847 purple_media_codec_to_string(const PurpleMediaCodec *codec)
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
848 {
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
849 FsCodec *fscodec = purple_media_codec_to_fs(codec);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
850 gchar *str = fs_codec_to_string(fscodec);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
851 fs_codec_destroy(fscodec);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
852 return str;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
853 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
854
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
855 static GList *
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
856 purple_media_codec_list_from_fs(GList *codecs)
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
857 {
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
858 GList *new_list = NULL;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
859
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
860 for (; codecs; codecs = g_list_next(codecs)) {
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
861 new_list = g_list_prepend(new_list,
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
862 purple_media_codec_from_fs(
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
863 codecs->data));
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
864 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
865
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
866 new_list = g_list_reverse(new_list);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
867 return new_list;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
868 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
869
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
870 static GList *
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
871 purple_media_codec_list_to_fs(GList *codecs)
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
872 {
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
873 GList *new_list = NULL;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
874
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
875 for (; codecs; codecs = g_list_next(codecs)) {
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
876 new_list = g_list_prepend(new_list,
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
877 purple_media_codec_to_fs(
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
878 codecs->data));
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
879 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
880
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
881 new_list = g_list_reverse(new_list);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
882 return new_list;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
883 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
884
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
885 GList *
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
886 purple_media_codec_list_copy(GList *codecs)
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
887 {
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
888 GList *new_list = NULL;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
889
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
890 for (; codecs; codecs = g_list_next(codecs)) {
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
891 new_list = g_list_prepend(new_list, g_boxed_copy(
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
892 PURPLE_TYPE_MEDIA_CODEC,
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
893 codecs->data));
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
894 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
895
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
896 new_list = g_list_reverse(new_list);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
897 return new_list;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
898 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
899
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
900 void
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
901 purple_media_codec_list_free(GList *codecs)
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
902 {
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
903 for (; codecs; codecs =
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
904 g_list_delete_link(codecs, codecs)) {
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
905 g_boxed_free(PURPLE_TYPE_MEDIA_CODEC,
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
906 codecs->data);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
907 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
908 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
909
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
910 GType
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
911 purple_media_codec_get_type()
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
912 {
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
913 static GType type = 0;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
914
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
915 if (type == 0) {
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
916 type = g_boxed_type_register_static("PurpleMediaCodec",
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
917 (GBoxedCopyFunc)purple_media_codec_copy,
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
918 (GBoxedFreeFunc)purple_media_codec_free);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
919 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
920 return type;
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
921 }
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
922
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
923
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
924
26108
8d0fd2f195aa Changed PurpleMediaStreamType to PurpleMediaSessionType.
Michael Ruprecht <maiku@pidgin.im>
parents: 26105
diff changeset
925 PurpleMediaSessionType
23737
91165a8fcbd9 Notify the user which type of media session the remote user wants to initiate.
Michael Ruprecht <maiku@pidgin.im>
parents: 23736
diff changeset
926 purple_media_get_overall_type(PurpleMedia *media)
91165a8fcbd9 Notify the user which type of media session the remote user wants to initiate.
Michael Ruprecht <maiku@pidgin.im>
parents: 23736
diff changeset
927 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
928 GList *values;
26108
8d0fd2f195aa Changed PurpleMediaStreamType to PurpleMediaSessionType.
Michael Ruprecht <maiku@pidgin.im>
parents: 26105
diff changeset
929 PurpleMediaSessionType type = PURPLE_MEDIA_NONE;
23737
91165a8fcbd9 Notify the user which type of media session the remote user wants to initiate.
Michael Ruprecht <maiku@pidgin.im>
parents: 23736
diff changeset
930
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
931 g_return_val_if_fail(PURPLE_IS_MEDIA(media), type);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
932
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
933 values = g_hash_table_get_values(media->priv->sessions);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
934
23752
d573c980437e Fixed some memory leak issues involving GLists.
Michael Ruprecht <maiku@pidgin.im>
parents: 23746
diff changeset
935 for (; values; values = g_list_delete_link(values, values)) {
23737
91165a8fcbd9 Notify the user which type of media session the remote user wants to initiate.
Michael Ruprecht <maiku@pidgin.im>
parents: 23736
diff changeset
936 PurpleMediaSession *session = values->data;
91165a8fcbd9 Notify the user which type of media session the remote user wants to initiate.
Michael Ruprecht <maiku@pidgin.im>
parents: 23736
diff changeset
937 type |= session->type;
91165a8fcbd9 Notify the user which type of media session the remote user wants to initiate.
Michael Ruprecht <maiku@pidgin.im>
parents: 23736
diff changeset
938 }
91165a8fcbd9 Notify the user which type of media session the remote user wants to initiate.
Michael Ruprecht <maiku@pidgin.im>
parents: 23736
diff changeset
939
91165a8fcbd9 Notify the user which type of media session the remote user wants to initiate.
Michael Ruprecht <maiku@pidgin.im>
parents: 23736
diff changeset
940 return type;
91165a8fcbd9 Notify the user which type of media session the remote user wants to initiate.
Michael Ruprecht <maiku@pidgin.im>
parents: 23736
diff changeset
941 }
91165a8fcbd9 Notify the user which type of media session the remote user wants to initiate.
Michael Ruprecht <maiku@pidgin.im>
parents: 23736
diff changeset
942
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
943 static PurpleMediaSession*
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
944 purple_media_get_session(PurpleMedia *media, const gchar *sess_id)
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
945 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
946 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
947 return (PurpleMediaSession*) (media->priv->sessions) ?
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
948 g_hash_table_lookup(media->priv->sessions, sess_id) : NULL;
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
949 }
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
950
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
951 static FsParticipant*
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
952 purple_media_get_participant(PurpleMedia *media, const gchar *name)
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
953 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
954 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
955 return (FsParticipant*) (media->priv->participants) ?
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
956 g_hash_table_lookup(media->priv->participants, name) : NULL;
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
957 }
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
958
26163
df72970bffc6 Move variables to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26162
diff changeset
959 static PurpleMediaStream*
df72970bffc6 Move variables to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26162
diff changeset
960 purple_media_get_stream(PurpleMedia *media, const gchar *session, const gchar *participant)
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
961 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
962 GList *streams;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
963
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
964 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
965
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
966 streams = media->priv->streams;
26162
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
967
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
968 for (; streams; streams = g_list_next(streams)) {
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
969 PurpleMediaStream *stream = streams->data;
26163
df72970bffc6 Move variables to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26162
diff changeset
970 if (!strcmp(stream->session->id, session) &&
df72970bffc6 Move variables to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26162
diff changeset
971 !strcmp(stream->participant, participant))
df72970bffc6 Move variables to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26162
diff changeset
972 return stream;
26162
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
973 }
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
974
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
975 return NULL;
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
976 }
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
977
26172
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
978 static GList *
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
979 purple_media_get_streams(PurpleMedia *media, const gchar *session,
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
980 const gchar *participant)
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
981 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
982 GList *streams;
26172
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
983 GList *ret = NULL;
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
984
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
985 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
986
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
987 streams = media->priv->streams;
26172
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
988
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
989 for (; streams; streams = g_list_next(streams)) {
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
990 PurpleMediaStream *stream = streams->data;
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
991 if ((session == NULL ||
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
992 !strcmp(stream->session->id, session)) &&
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
993 (participant == NULL ||
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
994 !strcmp(stream->participant, participant)))
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
995 ret = g_list_append(ret, stream);
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
996 }
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
997
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
998 return ret;
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
999 }
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
1000
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1001 static void
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1002 purple_media_add_session(PurpleMedia *media, PurpleMediaSession *session)
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1003 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1004 g_return_if_fail(PURPLE_IS_MEDIA(media));
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1005 g_return_if_fail(session != NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1006
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1007 if (!media->priv->sessions) {
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1008 purple_debug_info("media", "Creating hash table for sessions\n");
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1009 media->priv->sessions = g_hash_table_new(g_str_hash, g_str_equal);
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1010 }
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1011 g_hash_table_insert(media->priv->sessions, g_strdup(session->id), session);
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1012 }
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1013
23745
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
1014 static gboolean
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
1015 purple_media_remove_session(PurpleMedia *media, PurpleMediaSession *session)
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
1016 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1017 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
23745
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
1018 return g_hash_table_remove(media->priv->sessions, session->id);
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
1019 }
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
1020
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1021 static FsParticipant *
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1022 purple_media_add_participant(PurpleMedia *media, const gchar *name)
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1023 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1024 FsParticipant *participant;
23745
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
1025 GError *err = NULL;
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1026
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1027 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1028
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1029 participant = purple_media_get_participant(media, name);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1030
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1031 if (participant)
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1032 return participant;
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1033
23745
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
1034 participant = fs_conference_new_participant(media->priv->conference,
26116
41f7d4545566 Fixed a ton of memory leaks.
Michael Ruprecht <maiku@pidgin.im>
parents: 26115
diff changeset
1035 (gchar*)name, &err);
23745
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
1036
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
1037 if (err) {
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
1038 purple_debug_error("media", "Error creating participant: %s\n",
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
1039 err->message);
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
1040 g_error_free(err);
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
1041 return NULL;
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
1042 }
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1043
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1044 if (!media->priv->participants) {
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1045 purple_debug_info("media", "Creating hash table for participants\n");
26116
41f7d4545566 Fixed a ton of memory leaks.
Michael Ruprecht <maiku@pidgin.im>
parents: 26115
diff changeset
1046 media->priv->participants = g_hash_table_new_full(g_str_hash,
41f7d4545566 Fixed a ton of memory leaks.
Michael Ruprecht <maiku@pidgin.im>
parents: 26115
diff changeset
1047 g_str_equal, g_free, NULL);
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1048 }
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1049
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1050 g_hash_table_insert(media->priv->participants, g_strdup(name), participant);
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1051
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1052 return participant;
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1053 }
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1054
26176
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1055 static PurpleMediaStream *
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1056 purple_media_insert_stream(PurpleMediaSession *session, const gchar *name, FsStream *stream)
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1057 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1058 PurpleMediaStream *media_stream;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1059
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1060 g_return_val_if_fail(session != NULL, NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1061
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1062 media_stream = g_new0(PurpleMediaStream, 1);
26162
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
1063 media_stream->stream = stream;
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
1064 media_stream->participant = g_strdup(name);
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
1065 media_stream->session = session;
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1066
26162
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
1067 session->media->priv->streams =
5089efd94a64 Added PurpleMediaStream to wrap FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26160
diff changeset
1068 g_list_append(session->media->priv->streams, media_stream);
26176
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1069
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1070 return media_stream;
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1071 }
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1072
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1073 static void
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1074 purple_media_insert_local_candidate(PurpleMediaSession *session, const gchar *name,
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1075 FsCandidate *candidate)
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1076 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1077 PurpleMediaStream *stream;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1078
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1079 g_return_if_fail(session != NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1080
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1081 stream = purple_media_get_stream(session->media, session->id, name);
26163
df72970bffc6 Move variables to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26162
diff changeset
1082 stream->local_candidates = g_list_append(stream->local_candidates, candidate);
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1083 }
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1084
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1085 GList *
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1086 purple_media_get_session_names(PurpleMedia *media)
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1087 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1088 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
26332
5e5941302f8f Silence assertion.
Michael Ruprecht <maiku@pidgin.im>
parents: 26328
diff changeset
1089 return media->priv->sessions != NULL ?
5e5941302f8f Silence assertion.
Michael Ruprecht <maiku@pidgin.im>
parents: 26328
diff changeset
1090 g_hash_table_get_keys(media->priv->sessions) : NULL;
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1091 }
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1092
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1093 void
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1094 purple_media_get_elements(PurpleMedia *media, GstElement **audio_src, GstElement **audio_sink,
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1095 GstElement **video_src, GstElement **video_sink)
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1096 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1097 GList *values;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1098
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1099 g_return_if_fail(PURPLE_IS_MEDIA(media));
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1100
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1101 values = g_hash_table_get_values(media->priv->sessions);
23744
7b6b91b7e862 Wait to set up the voice and video GUI until the responder has accepted the session.
Michael Ruprecht <maiku@pidgin.im>
parents: 23742
diff changeset
1102
23752
d573c980437e Fixed some memory leak issues involving GLists.
Michael Ruprecht <maiku@pidgin.im>
parents: 23746
diff changeset
1103 for (; values; values = g_list_delete_link(values, values)) {
23744
7b6b91b7e862 Wait to set up the voice and video GUI until the responder has accepted the session.
Michael Ruprecht <maiku@pidgin.im>
parents: 23742
diff changeset
1104 PurpleMediaSession *session = (PurpleMediaSession*)values->data;
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1105
23744
7b6b91b7e862 Wait to set up the voice and video GUI until the responder has accepted the session.
Michael Ruprecht <maiku@pidgin.im>
parents: 23742
diff changeset
1106 if (session->type & PURPLE_MEDIA_SEND_AUDIO && audio_src)
7b6b91b7e862 Wait to set up the voice and video GUI until the responder has accepted the session.
Michael Ruprecht <maiku@pidgin.im>
parents: 23742
diff changeset
1107 *audio_src = session->src;
7b6b91b7e862 Wait to set up the voice and video GUI until the responder has accepted the session.
Michael Ruprecht <maiku@pidgin.im>
parents: 23742
diff changeset
1108 if (session->type & PURPLE_MEDIA_SEND_VIDEO && video_src)
7b6b91b7e862 Wait to set up the voice and video GUI until the responder has accepted the session.
Michael Ruprecht <maiku@pidgin.im>
parents: 23742
diff changeset
1109 *video_src = session->src;
26176
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1110 }
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1111
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1112 values = media->priv->streams;
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1113 for (; values; values = g_list_next(values)) {
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1114 PurpleMediaStream *stream = (PurpleMediaStream*)values->data;
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1115
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1116 if (stream->session->type & PURPLE_MEDIA_RECV_AUDIO && audio_sink)
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1117 *audio_sink = stream->sink;
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1118 if (stream->session->type & PURPLE_MEDIA_RECV_VIDEO && video_sink)
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1119 *video_sink = stream->sink;
23744
7b6b91b7e862 Wait to set up the voice and video GUI until the responder has accepted the session.
Michael Ruprecht <maiku@pidgin.im>
parents: 23742
diff changeset
1120 }
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1121 }
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1122
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1123 void
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1124 purple_media_set_src(PurpleMedia *media, const gchar *sess_id, GstElement *src)
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1125 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1126 PurpleMediaSession *session;
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1127 GstPad *sinkpad;
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1128 GstPad *srcpad;
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1129
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1130 g_return_if_fail(PURPLE_IS_MEDIA(media));
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1131
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1132 session = purple_media_get_session(media, sess_id);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1133
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1134 if (session == NULL) {
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1135 purple_debug_warning("media", "purple_media_set_src: trying"
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1136 " to set src on non-existent session\n");
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1137 return;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1138 }
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1139
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1140 if (session->src)
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1141 gst_object_unref(session->src);
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1142 session->src = src;
26276
b9d3887b8318 Have all media sessions use a single pipeline.
Michael Ruprecht <maiku@pidgin.im>
parents: 26270
diff changeset
1143 gst_bin_add(GST_BIN(session->media->priv->confbin),
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1144 session->src);
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1145
26321
a1d92d85cb34 Handle the session tee in the session rather than the src bin.
Michael Ruprecht <maiku@pidgin.im>
parents: 26320
diff changeset
1146 session->tee = gst_element_factory_make("tee", NULL);
a1d92d85cb34 Handle the session tee in the session rather than the src bin.
Michael Ruprecht <maiku@pidgin.im>
parents: 26320
diff changeset
1147 gst_bin_add(GST_BIN(session->media->priv->confbin), session->tee);
a1d92d85cb34 Handle the session tee in the session rather than the src bin.
Michael Ruprecht <maiku@pidgin.im>
parents: 26320
diff changeset
1148 gst_element_link(session->src, session->tee);
a1d92d85cb34 Handle the session tee in the session rather than the src bin.
Michael Ruprecht <maiku@pidgin.im>
parents: 26320
diff changeset
1149 gst_element_set_state(session->tee, GST_STATE_PLAYING);
a1d92d85cb34 Handle the session tee in the session rather than the src bin.
Michael Ruprecht <maiku@pidgin.im>
parents: 26320
diff changeset
1150
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1151 g_object_get(session->session, "sink-pad", &sinkpad, NULL);
26321
a1d92d85cb34 Handle the session tee in the session rather than the src bin.
Michael Ruprecht <maiku@pidgin.im>
parents: 26320
diff changeset
1152 srcpad = gst_element_get_request_pad(session->tee, "src%d");
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1153 purple_debug_info("media", "connecting pad: %s\n",
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1154 gst_pad_link(srcpad, sinkpad) == GST_PAD_LINK_OK
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1155 ? "success" : "failure");
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1156 }
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1157
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1158 void
26176
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1159 purple_media_set_sink(PurpleMedia *media, const gchar *sess_id,
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1160 const gchar *participant, GstElement *sink)
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1161 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1162 PurpleMediaStream *stream;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1163
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1164 g_return_if_fail(PURPLE_IS_MEDIA(media));
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1165
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1166 stream = purple_media_get_stream(media, sess_id, participant);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1167
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1168 if (stream == NULL) {
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1169 purple_debug_warning("media", "purple_media_set_sink: trying"
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1170 " to set sink on non-existent stream\n");
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1171 return;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1172 }
26176
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1173
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1174 if (stream->sink)
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1175 gst_object_unref(stream->sink);
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1176 stream->sink = sink;
26276
b9d3887b8318 Have all media sessions use a single pipeline.
Michael Ruprecht <maiku@pidgin.im>
parents: 26270
diff changeset
1177 gst_bin_add(GST_BIN(stream->session->media->priv->confbin),
26176
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1178 stream->sink);
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1179 }
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1180
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1181 GstElement *
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1182 purple_media_get_src(PurpleMedia *media, const gchar *sess_id)
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1183 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1184 PurpleMediaSession *session;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1185 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1186 session = purple_media_get_session(media, sess_id);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1187 return (session != NULL) ? session->src : NULL;
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1188 }
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1189
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1190 GstElement *
26176
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1191 purple_media_get_sink(PurpleMedia *media, const gchar *sess_id, const gchar *participant)
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1192 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1193 PurpleMediaStream *stream;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1194 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1195 stream = purple_media_get_stream(media, sess_id, participant);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1196 return (stream != NULL) ? stream->sink : NULL;
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1197 }
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1198
26121
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1199 static PurpleMediaSession *
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1200 purple_media_session_from_fs_stream(PurpleMedia *media, FsStream *stream)
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1201 {
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1202 FsSession *fssession;
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1203 GList *values;
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1204
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1205 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1206 g_return_val_if_fail(FS_IS_STREAM(stream), NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1207
26121
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1208 g_object_get(stream, "session", &fssession, NULL);
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1209
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1210 values = g_hash_table_get_values(media->priv->sessions);
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1211
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1212 for (; values; values = g_list_delete_link(values, values)) {
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1213 PurpleMediaSession *session = values->data;
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1214
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1215 if (session->session == fssession) {
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1216 g_list_free(values);
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1217 g_object_unref(fssession);
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1218 return session;
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1219 }
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1220 }
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1221
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1222 g_object_unref(fssession);
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1223 return NULL;
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1224 }
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1225
26189
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1226 /* This could also emit when participants are ready */
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1227 static void
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1228 purple_media_emit_ready(PurpleMedia *media, PurpleMediaSession *session, const gchar *participant)
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1229 {
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1230 GList *sessions;
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1231 gboolean conf_ready = TRUE;
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1232
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1233 g_return_if_fail(PURPLE_IS_MEDIA(media));
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1234
26190
8d7ea9d4f8d4 Have XMPP use the new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26189
diff changeset
1235 if ((session != NULL) && ((media->priv->initiator == FALSE &&
8d7ea9d4f8d4 Have XMPP use the new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26189
diff changeset
1236 session->accepted == FALSE) ||
26189
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1237 (purple_media_codecs_ready(media, session->id) == FALSE)))
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1238 return;
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1239
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1240 sessions = g_hash_table_get_values(media->priv->sessions);
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1241
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1242 for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1243 PurpleMediaSession *session_data = sessions->data;
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1244 GList *streams = purple_media_get_streams(media,
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1245 session_data->id, NULL);
26190
8d7ea9d4f8d4 Have XMPP use the new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26189
diff changeset
1246 gboolean session_ready = TRUE;
26189
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1247
26190
8d7ea9d4f8d4 Have XMPP use the new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26189
diff changeset
1248 if ((media->priv->initiator == FALSE &&
8d7ea9d4f8d4 Have XMPP use the new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26189
diff changeset
1249 session_data->accepted == FALSE) ||
26189
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1250 (purple_media_codecs_ready(
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1251 media, session_data->id) == FALSE))
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1252 conf_ready = FALSE;
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1253
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1254 for (; streams; streams = g_list_delete_link(streams, streams)) {
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1255 PurpleMediaStream *stream = streams->data;
26190
8d7ea9d4f8d4 Have XMPP use the new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26189
diff changeset
1256 if (stream->candidates_prepared == FALSE) {
8d7ea9d4f8d4 Have XMPP use the new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26189
diff changeset
1257 session_ready = FALSE;
8d7ea9d4f8d4 Have XMPP use the new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26189
diff changeset
1258 conf_ready = FALSE;
8d7ea9d4f8d4 Have XMPP use the new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26189
diff changeset
1259 } else if (session_data == session)
26189
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1260 g_signal_emit(media, purple_media_signals[READY_NEW],
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1261 0, session_data->id, stream->participant);
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1262 }
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1263
26190
8d7ea9d4f8d4 Have XMPP use the new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26189
diff changeset
1264 if (session_ready == TRUE &&
8d7ea9d4f8d4 Have XMPP use the new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26189
diff changeset
1265 (session == session_data || session == NULL))
26189
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1266 g_signal_emit(media, purple_media_signals[READY_NEW],
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1267 0, session_data->id, NULL);
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1268 }
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1269
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1270 if (conf_ready == TRUE) {
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1271 g_signal_emit(media, purple_media_signals[READY_NEW],
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1272 0, NULL, NULL);
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1273 }
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1274 }
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1275
23742
a3eda57d01b5 Move the main voice and video pipeline into media.c and display more debug info.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
1276 static gboolean
26320
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
1277 media_bus_call(GstBus *bus, GstMessage *msg, PurpleMedia *media)
23742
a3eda57d01b5 Move the main voice and video pipeline into media.c and display more debug info.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
1278 {
a3eda57d01b5 Move the main voice and video pipeline into media.c and display more debug info.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
1279 switch(GST_MESSAGE_TYPE(msg)) {
a3eda57d01b5 Move the main voice and video pipeline into media.c and display more debug info.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
1280 case GST_MESSAGE_ELEMENT: {
26320
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
1281 if (!FS_IS_CONFERENCE(GST_MESSAGE_SRC(msg)) ||
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
1282 !PURPLE_IS_MEDIA(media) ||
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
1283 media->priv->conference !=
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
1284 FS_CONFERENCE(GST_MESSAGE_SRC(msg)))
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
1285 break;
26276
b9d3887b8318 Have all media sessions use a single pipeline.
Michael Ruprecht <maiku@pidgin.im>
parents: 26270
diff changeset
1286
23742
a3eda57d01b5 Move the main voice and video pipeline into media.c and display more debug info.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
1287 if (gst_structure_has_name(msg->structure, "farsight-error")) {
26121
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1288 FsError error_no;
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1289 gst_structure_get_enum(msg->structure, "error-no",
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1290 FS_TYPE_ERROR, (gint*)&error_no);
26132
1dce93db50e3 Silence FS_ERROR_UNKNOWN_CNAME error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26131
diff changeset
1291 /*
1dce93db50e3 Silence FS_ERROR_UNKNOWN_CNAME error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26131
diff changeset
1292 * Unknown CName is only a problem for the
1dce93db50e3 Silence FS_ERROR_UNKNOWN_CNAME error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26131
diff changeset
1293 * multicast transmitter which isn't used.
1dce93db50e3 Silence FS_ERROR_UNKNOWN_CNAME error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26131
diff changeset
1294 */
1dce93db50e3 Silence FS_ERROR_UNKNOWN_CNAME error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26131
diff changeset
1295 if (error_no != FS_ERROR_UNKNOWN_CNAME)
1dce93db50e3 Silence FS_ERROR_UNKNOWN_CNAME error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26131
diff changeset
1296 purple_debug_error("media", "farsight-error: %i: %s\n", error_no,
1dce93db50e3 Silence FS_ERROR_UNKNOWN_CNAME error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26131
diff changeset
1297 gst_structure_get_string(msg->structure, "error-msg"));
26121
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1298 } else if (gst_structure_has_name(msg->structure,
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1299 "farsight-new-local-candidate")) {
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1300 FsStream *stream = g_value_get_object(gst_structure_get_value(msg->structure, "stream"));
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1301 FsCandidate *local_candidate = g_value_get_boxed(gst_structure_get_value(msg->structure, "candidate"));
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1302 PurpleMediaSession *session = purple_media_session_from_fs_stream(media, stream);
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1303 purple_media_new_local_candidate_cb(stream, local_candidate, session);
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1304 } else if (gst_structure_has_name(msg->structure,
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1305 "farsight-local-candidates-prepared")) {
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1306 FsStream *stream = g_value_get_object(gst_structure_get_value(msg->structure, "stream"));
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1307 PurpleMediaSession *session = purple_media_session_from_fs_stream(media, stream);
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1308 purple_media_candidates_prepared_cb(stream, session);
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1309 } else if (gst_structure_has_name(msg->structure,
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1310 "farsight-new-active-candidate-pair")) {
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1311 FsStream *stream = g_value_get_object(gst_structure_get_value(msg->structure, "stream"));
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1312 FsCandidate *local_candidate = g_value_get_boxed(gst_structure_get_value(msg->structure, "local-candidate"));
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1313 FsCandidate *remote_candidate = g_value_get_boxed(gst_structure_get_value(msg->structure, "remote-candidate"));
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1314 PurpleMediaSession *session = purple_media_session_from_fs_stream(media, stream);
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1315 purple_media_candidate_pair_established_cb(stream, local_candidate, remote_candidate, session);
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1316 } else if (gst_structure_has_name(msg->structure,
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1317 "farsight-recv-codecs-changed")) {
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1318 GList *codecs = g_value_get_boxed(gst_structure_get_value(msg->structure, "codecs"));
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1319 FsCodec *codec = codecs->data;
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1320 purple_debug_info("media", "farsight-recv-codecs-changed: %s\n", codec->encoding_name);
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1321
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1322 } else if (gst_structure_has_name(msg->structure,
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1323 "farsight-component-state-changed")) {
26297
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1324 FsStreamState fsstate = g_value_get_enum(gst_structure_get_value(msg->structure, "state"));
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1325 guint component = g_value_get_uint(gst_structure_get_value(msg->structure, "component"));
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1326 const gchar *state;
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1327 switch (fsstate) {
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1328 case FS_STREAM_STATE_FAILED:
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1329 state = "FAILED";
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1330 break;
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1331 case FS_STREAM_STATE_DISCONNECTED:
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1332 state = "DISCONNECTED";
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1333 break;
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1334 case FS_STREAM_STATE_GATHERING:
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1335 state = "GATHERING";
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1336 break;
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1337 case FS_STREAM_STATE_CONNECTING:
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1338 state = "CONNECTING";
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1339 break;
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1340 case FS_STREAM_STATE_CONNECTED:
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1341 state = "CONNECTED";
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1342 break;
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1343 case FS_STREAM_STATE_READY:
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1344 state = "READY";
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1345 break;
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1346 default:
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1347 state = "UNKNOWN";
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1348 break;
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1349 }
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1350 purple_debug_info("media", "farsight-component-state-changed: component: %u state: %s\n", component, state);
26121
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1351 } else if (gst_structure_has_name(msg->structure,
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1352 "farsight-send-codec-changed")) {
26297
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1353 FsCodec *codec = g_value_get_boxed(gst_structure_get_value(msg->structure, "codec"));
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1354 gchar *codec_str = fs_codec_to_string(codec);
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1355 purple_debug_info("media", "farsight-send-codec-changed: codec: %s\n", codec_str);
7150ea9de94b Add some debug messages for the remaining Farsight signals.
Michael Ruprecht <maiku@pidgin.im>
parents: 26296
diff changeset
1356 g_free(codec_str);
26121
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1357 } else if (gst_structure_has_name(msg->structure,
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1358 "farsight-codecs-changed")) {
26137
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26135
diff changeset
1359 GList *sessions = g_hash_table_get_values(PURPLE_MEDIA(media)->priv->sessions);
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26135
diff changeset
1360 FsSession *fssession = g_value_get_object(gst_structure_get_value(msg->structure, "session"));
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26135
diff changeset
1361 for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26135
diff changeset
1362 PurpleMediaSession *session = sessions->data;
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26135
diff changeset
1363 if (session->session == fssession) {
26189
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1364 gboolean ready;
26265
66aee93241e2 Added codecs-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26264
diff changeset
1365 gchar *session_id;
66aee93241e2 Added codecs-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26264
diff changeset
1366
26189
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1367 g_object_get(session->session, "codecs-ready", &ready, NULL);
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1368 if (session->codecs_ready == FALSE && ready == TRUE) {
26191
12ec5694e4a4 Use the new ready signal instead of accept to send a session-accept.
Michael Ruprecht <maiku@pidgin.im>
parents: 26190
diff changeset
1369 session->codecs_ready = ready;
26189
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1370 purple_media_emit_ready(media, session, NULL);
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1371 }
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1372
26265
66aee93241e2 Added codecs-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26264
diff changeset
1373 session_id = g_strdup(session->id);
66aee93241e2 Added codecs-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26264
diff changeset
1374 g_signal_emit(media, purple_media_signals[CODECS_CHANGED], 0, session_id);
66aee93241e2 Added codecs-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26264
diff changeset
1375 g_free(session_id);
26137
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26135
diff changeset
1376 g_list_free(sessions);
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26135
diff changeset
1377 break;
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26135
diff changeset
1378 }
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26135
diff changeset
1379 }
23742
a3eda57d01b5 Move the main voice and video pipeline into media.c and display more debug info.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
1380 }
a3eda57d01b5 Move the main voice and video pipeline into media.c and display more debug info.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
1381 break;
a3eda57d01b5 Move the main voice and video pipeline into media.c and display more debug info.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
1382 }
a3eda57d01b5 Move the main voice and video pipeline into media.c and display more debug info.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
1383 default:
26120
b4ab036ab9fe Remove a bunch of extraneous GstBus messages from the debug output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26119
diff changeset
1384 break;
23742
a3eda57d01b5 Move the main voice and video pipeline into media.c and display more debug info.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
1385 }
a3eda57d01b5 Move the main voice and video pipeline into media.c and display more debug info.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
1386
a3eda57d01b5 Move the main voice and video pipeline into media.c and display more debug info.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
1387 return TRUE;
a3eda57d01b5 Move the main voice and video pipeline into media.c and display more debug info.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
1388 }
a3eda57d01b5 Move the main voice and video pipeline into media.c and display more debug info.
Michael Ruprecht <maiku@pidgin.im>
parents: 23737
diff changeset
1389
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1390 GstElement *
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1391 purple_media_get_pipeline(PurpleMedia *media)
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1392 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1393 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1394
26320
2e9c1e8391f4 Move pipeline creation into the media manager.
Michael Ruprecht <maiku@pidgin.im>
parents: 26317
diff changeset
1395 return purple_media_manager_get_pipeline(media->priv->manager);
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1396 }
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1397
26327
6a436310d508 Added the connection property back to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26324
diff changeset
1398 PurpleConnection *
6a436310d508 Added the connection property back to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26324
diff changeset
1399 purple_media_get_connection(PurpleMedia *media)
6a436310d508 Added the connection property back to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26324
diff changeset
1400 {
6a436310d508 Added the connection property back to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26324
diff changeset
1401 PurpleConnection *pc;
6a436310d508 Added the connection property back to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26324
diff changeset
1402 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
6a436310d508 Added the connection property back to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26324
diff changeset
1403 g_object_get(G_OBJECT(media), "connection", &pc, NULL);
6a436310d508 Added the connection property back to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26324
diff changeset
1404 return pc;
6a436310d508 Added the connection property back to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26324
diff changeset
1405 }
6a436310d508 Added the connection property back to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26324
diff changeset
1406
26328
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
1407 gpointer
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
1408 purple_media_get_prpl_data(PurpleMedia *media)
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
1409 {
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
1410 gpointer prpl_data;
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
1411 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
1412 g_object_get(G_OBJECT(media), "prpl-data", &prpl_data, NULL);
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
1413 return prpl_data;
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
1414 }
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
1415
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
1416 void
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
1417 purple_media_set_prpl_data(PurpleMedia *media, gpointer prpl_data)
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
1418 {
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
1419 g_return_if_fail(PURPLE_IS_MEDIA(media));
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
1420 g_object_set(G_OBJECT(media), "prpl-data", prpl_data, NULL);
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
1421 }
9c15d3c83e24 Add a prpl-data property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26327
diff changeset
1422
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1423 void
26182
728ad1da9cbc Add purple_media_error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26181
diff changeset
1424 purple_media_error(PurpleMedia *media, const gchar *error, ...)
728ad1da9cbc Add purple_media_error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26181
diff changeset
1425 {
728ad1da9cbc Add purple_media_error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26181
diff changeset
1426 va_list args;
728ad1da9cbc Add purple_media_error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26181
diff changeset
1427 gchar *message;
728ad1da9cbc Add purple_media_error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26181
diff changeset
1428
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1429 g_return_if_fail(PURPLE_IS_MEDIA(media));
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1430
26182
728ad1da9cbc Add purple_media_error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26181
diff changeset
1431 va_start(args, error);
728ad1da9cbc Add purple_media_error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26181
diff changeset
1432 message = g_strdup_vprintf(error, args);
728ad1da9cbc Add purple_media_error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26181
diff changeset
1433 va_end(args);
728ad1da9cbc Add purple_media_error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26181
diff changeset
1434
728ad1da9cbc Add purple_media_error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26181
diff changeset
1435 purple_debug_error("media", "%s\n", message);
728ad1da9cbc Add purple_media_error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26181
diff changeset
1436 g_signal_emit(media, purple_media_signals[ERROR], 0, message);
728ad1da9cbc Add purple_media_error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26181
diff changeset
1437
728ad1da9cbc Add purple_media_error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26181
diff changeset
1438 g_free(message);
728ad1da9cbc Add purple_media_error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26181
diff changeset
1439 }
728ad1da9cbc Add purple_media_error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26181
diff changeset
1440
728ad1da9cbc Add purple_media_error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26181
diff changeset
1441 void
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1442 purple_media_accept(PurpleMedia *media)
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1443 {
26189
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1444 GList *sessions;
26209
618cc6a7cff2 Wait to send media until both sides have accepted.
Michael Ruprecht <maiku@pidgin.im>
parents: 26200
diff changeset
1445 GList *streams;
26189
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1446
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1447 g_return_if_fail(PURPLE_IS_MEDIA(media));
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1448
26189
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1449 sessions = g_hash_table_get_values(media->priv->sessions);
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1450
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1451 for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1452 PurpleMediaSession *session = sessions->data;
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1453 session->accepted = TRUE;
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1454
26248
03954067f80e Remove some of the deprecated API.
Michael Ruprecht <maiku@pidgin.im>
parents: 26247
diff changeset
1455 if (media->priv->initiator == FALSE)
03954067f80e Remove some of the deprecated API.
Michael Ruprecht <maiku@pidgin.im>
parents: 26247
diff changeset
1456 purple_media_emit_ready(media, session, NULL);
26189
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1457 }
26209
618cc6a7cff2 Wait to send media until both sides have accepted.
Michael Ruprecht <maiku@pidgin.im>
parents: 26200
diff changeset
1458
26266
069e72982f87 Added the accepted signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26265
diff changeset
1459 g_signal_emit(media, purple_media_signals[ACCEPTED],
069e72982f87 Added the accepted signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26265
diff changeset
1460 0, NULL, NULL);
26209
618cc6a7cff2 Wait to send media until both sides have accepted.
Michael Ruprecht <maiku@pidgin.im>
parents: 26200
diff changeset
1461 streams = media->priv->streams;
618cc6a7cff2 Wait to send media until both sides have accepted.
Michael Ruprecht <maiku@pidgin.im>
parents: 26200
diff changeset
1462
618cc6a7cff2 Wait to send media until both sides have accepted.
Michael Ruprecht <maiku@pidgin.im>
parents: 26200
diff changeset
1463 for (; streams; streams = g_list_next(streams)) {
26257
e4a840dab1d4 Use the stream's direction to wait to send media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26256
diff changeset
1464 PurpleMediaStream *stream = streams->data;
e4a840dab1d4 Use the stream's direction to wait to send media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26256
diff changeset
1465 g_object_set(G_OBJECT(stream->stream), "direction",
e4a840dab1d4 Use the stream's direction to wait to send media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26256
diff changeset
1466 purple_media_to_fs_stream_direction(
e4a840dab1d4 Use the stream's direction to wait to send media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26256
diff changeset
1467 stream->session->type), NULL);
26209
618cc6a7cff2 Wait to send media until both sides have accepted.
Michael Ruprecht <maiku@pidgin.im>
parents: 26200
diff changeset
1468 }
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1469 }
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1470
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1471 void
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1472 purple_media_hangup(PurpleMedia *media)
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1473 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1474 g_return_if_fail(PURPLE_IS_MEDIA(media));
26193
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
1475 g_signal_emit(media, purple_media_signals[STATE_CHANGED],
26237
9f5f3c147950 Added reject and hangup states to the state-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26235
diff changeset
1476 0, PURPLE_MEDIA_STATE_CHANGED_HANGUP,
9f5f3c147950 Added reject and hangup states to the state-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26235
diff changeset
1477 NULL, NULL);
26264
c062fc1f212f Added purple_media_end and removed the purple_media_got_hangup.
Michael Ruprecht <maiku@pidgin.im>
parents: 26263
diff changeset
1478 purple_media_end(media, NULL, NULL);
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1479 }
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1480
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1481 void
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1482 purple_media_reject(PurpleMedia *media)
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1483 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1484 g_return_if_fail(PURPLE_IS_MEDIA(media));
26193
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
1485 g_signal_emit(media, purple_media_signals[STATE_CHANGED],
26237
9f5f3c147950 Added reject and hangup states to the state-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26235
diff changeset
1486 0, PURPLE_MEDIA_STATE_CHANGED_REJECTED,
9f5f3c147950 Added reject and hangup states to the state-changed signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26235
diff changeset
1487 NULL, NULL);
26264
c062fc1f212f Added purple_media_end and removed the purple_media_got_hangup.
Michael Ruprecht <maiku@pidgin.im>
parents: 26263
diff changeset
1488 purple_media_end(media, NULL, NULL);
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1489 }
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1490
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1491 void
26264
c062fc1f212f Added purple_media_end and removed the purple_media_got_hangup.
Michael Ruprecht <maiku@pidgin.im>
parents: 26263
diff changeset
1492 purple_media_end(PurpleMedia *media,
c062fc1f212f Added purple_media_end and removed the purple_media_got_hangup.
Michael Ruprecht <maiku@pidgin.im>
parents: 26263
diff changeset
1493 const gchar *session_id, const gchar *participant)
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1494 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1495 g_return_if_fail(PURPLE_IS_MEDIA(media));
26269
cacc598079e4 Separate PidginMedia from PidginConversation.
Michael Ruprecht <maiku@pidgin.im>
parents: 26267
diff changeset
1496 if (session_id == NULL && participant == NULL) {
26264
c062fc1f212f Added purple_media_end and removed the purple_media_got_hangup.
Michael Ruprecht <maiku@pidgin.im>
parents: 26263
diff changeset
1497 g_signal_emit(media, purple_media_signals[STATE_CHANGED],
c062fc1f212f Added purple_media_end and removed the purple_media_got_hangup.
Michael Ruprecht <maiku@pidgin.im>
parents: 26263
diff changeset
1498 0, PURPLE_MEDIA_STATE_CHANGED_END,
c062fc1f212f Added purple_media_end and removed the purple_media_got_hangup.
Michael Ruprecht <maiku@pidgin.im>
parents: 26263
diff changeset
1499 NULL, NULL);
26269
cacc598079e4 Separate PidginMedia from PidginConversation.
Michael Ruprecht <maiku@pidgin.im>
parents: 26267
diff changeset
1500 g_object_unref(media);
cacc598079e4 Separate PidginMedia from PidginConversation.
Michael Ruprecht <maiku@pidgin.im>
parents: 26267
diff changeset
1501 }
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1502 }
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19883
diff changeset
1503
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1504 GList*
26135
b7e6a25f1771 Simplified purple_media_get_devices.
Michael Ruprecht <maiku@pidgin.im>
parents: 26134
diff changeset
1505 purple_media_get_devices(const gchar *plugin)
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1506 {
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1507 GObjectClass *klass;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1508 GstPropertyProbe *probe;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1509 const GParamSpec *pspec;
26135
b7e6a25f1771 Simplified purple_media_get_devices.
Michael Ruprecht <maiku@pidgin.im>
parents: 26134
diff changeset
1510 GstElement *element = gst_element_factory_make(plugin, NULL);
b7e6a25f1771 Simplified purple_media_get_devices.
Michael Ruprecht <maiku@pidgin.im>
parents: 26134
diff changeset
1511 GstElementFactory *factory;
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1512 const gchar *longname = NULL;
26135
b7e6a25f1771 Simplified purple_media_get_devices.
Michael Ruprecht <maiku@pidgin.im>
parents: 26134
diff changeset
1513 GList *ret = NULL;
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1514
26135
b7e6a25f1771 Simplified purple_media_get_devices.
Michael Ruprecht <maiku@pidgin.im>
parents: 26134
diff changeset
1515 if (element == NULL)
b7e6a25f1771 Simplified purple_media_get_devices.
Michael Ruprecht <maiku@pidgin.im>
parents: 26134
diff changeset
1516 return NULL;
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1517
26135
b7e6a25f1771 Simplified purple_media_get_devices.
Michael Ruprecht <maiku@pidgin.im>
parents: 26134
diff changeset
1518 factory = gst_element_get_factory(element);
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1519
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1520 longname = gst_element_factory_get_longname(factory);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1521 klass = G_OBJECT_GET_CLASS(element);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1522
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1523 if (!g_object_class_find_property (klass, "device") ||
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1524 !GST_IS_PROPERTY_PROBE (element) ||
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1525 !(probe = GST_PROPERTY_PROBE (element)) ||
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1526 !(pspec = gst_property_probe_get_property (probe, "device"))) {
23699
f21b7382aecb Fix video plugin/device preference and preview.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
1527 purple_debug_info("media", "Found source '%s' (%s) - no device\n",
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1528 longname, GST_PLUGIN_FEATURE (factory)->name);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1529 } else {
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1530 gint n;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1531 gchar *name;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1532 GValueArray *array;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1533
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1534 purple_debug_info("media", "Found devices\n");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1535
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1536 /* Set autoprobe[-fps] to FALSE to avoid delays when probing. */
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1537 if (g_object_class_find_property (klass, "autoprobe")) {
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1538 g_object_set (G_OBJECT (element), "autoprobe", FALSE, NULL);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1539 if (g_object_class_find_property (klass, "autoprobe-fps")) {
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1540 g_object_set (G_OBJECT (element), "autoprobe-fps", FALSE, NULL);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1541 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1542 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1543
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1544 array = gst_property_probe_probe_and_get_values (probe, pspec);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1545 if (array != NULL) {
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1546 for (n = 0 ; n < array->n_values ; n++) {
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1547 GValue *device = g_value_array_get_nth (array, n);
26125
17cbd1af89d3 Simplify device API. Use gchar* instead of GValue.
Michael Ruprecht <maiku@pidgin.im>
parents: 26124
diff changeset
1548
17cbd1af89d3 Simplify device API. Use gchar* instead of GValue.
Michael Ruprecht <maiku@pidgin.im>
parents: 26124
diff changeset
1549 ret = g_list_append(ret, g_value_dup_string(device));
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1550
26135
b7e6a25f1771 Simplified purple_media_get_devices.
Michael Ruprecht <maiku@pidgin.im>
parents: 26134
diff changeset
1551 g_object_set(G_OBJECT(element), "device",
b7e6a25f1771 Simplified purple_media_get_devices.
Michael Ruprecht <maiku@pidgin.im>
parents: 26134
diff changeset
1552 g_value_get_string(device), NULL);
26131
5b1937e15c58 Removed several PurpleMedia functions that now seem unnecessary:
Michael Ruprecht <maiku@pidgin.im>
parents: 26129
diff changeset
1553 g_object_get(G_OBJECT(element), "device-name", &name, NULL);
23699
f21b7382aecb Fix video plugin/device preference and preview.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
1554 purple_debug_info("media", "Found source '%s' (%s) - device '%s' (%s)\n",
f21b7382aecb Fix video plugin/device preference and preview.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
1555 longname, GST_PLUGIN_FEATURE (factory)->name,
f21b7382aecb Fix video plugin/device preference and preview.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
1556 name, g_value_get_string(device));
f21b7382aecb Fix video plugin/device preference and preview.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
1557 g_free(name);
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1558 }
26116
41f7d4545566 Fixed a ton of memory leaks.
Michael Ruprecht <maiku@pidgin.im>
parents: 26115
diff changeset
1559 g_value_array_free(array);
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1560 }
26122
51a3f29ecf01 Restore autoprobe property when finished probing for devices.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1561
51a3f29ecf01 Restore autoprobe property when finished probing for devices.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1562 /* Restore autoprobe[-fps] to TRUE. */
51a3f29ecf01 Restore autoprobe property when finished probing for devices.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1563 if (g_object_class_find_property (klass, "autoprobe")) {
51a3f29ecf01 Restore autoprobe property when finished probing for devices.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1564 g_object_set (G_OBJECT (element), "autoprobe", TRUE, NULL);
51a3f29ecf01 Restore autoprobe property when finished probing for devices.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1565 if (g_object_class_find_property (klass, "autoprobe-fps")) {
51a3f29ecf01 Restore autoprobe property when finished probing for devices.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1566 g_object_set (G_OBJECT (element), "autoprobe-fps", TRUE, NULL);
51a3f29ecf01 Restore autoprobe property when finished probing for devices.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1567 }
51a3f29ecf01 Restore autoprobe property when finished probing for devices.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1568 }
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1569 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1570
26135
b7e6a25f1771 Simplified purple_media_get_devices.
Michael Ruprecht <maiku@pidgin.im>
parents: 26134
diff changeset
1571 gst_object_unref(element);
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1572 return ret;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1573 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1574
26125
17cbd1af89d3 Simplify device API. Use gchar* instead of GValue.
Michael Ruprecht <maiku@pidgin.im>
parents: 26124
diff changeset
1575 gchar *
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1576 purple_media_element_get_device(GstElement *element)
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1577 {
26125
17cbd1af89d3 Simplify device API. Use gchar* instead of GValue.
Michael Ruprecht <maiku@pidgin.im>
parents: 26124
diff changeset
1578 gchar *device;
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1579 g_object_get(G_OBJECT(element), "device", &device, NULL);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1580 return device;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1581 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1582
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1583 void
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1584 purple_media_audio_init_src(GstElement **sendbin, GstElement **sendlevel)
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1585 {
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1586 GstElement *src;
26103
1cdefa229226 Added a mute button for the local microphone.
Michael Ruprecht <maiku@pidgin.im>
parents: 26102
diff changeset
1587 GstElement *volume;
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1588 GstPad *pad;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1589 GstPad *ghost;
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1590 const gchar *audio_device = purple_prefs_get_string("/purple/media/audio/device");
26115
5f0500efc781 * Added input/output volume preferences for voice conversations.
Michael Ruprecht <maiku@pidgin.im>
parents: 26112
diff changeset
1591 double input_volume = purple_prefs_get_int("/purple/media/audio/volume/input")/10.0;
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1592
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1593 g_return_if_fail(sendbin != NULL && sendlevel != NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1594
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1595 *sendbin = gst_bin_new("purplesendaudiobin");
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1596 src = gst_element_factory_make("alsasrc", "asrc");
26115
5f0500efc781 * Added input/output volume preferences for voice conversations.
Michael Ruprecht <maiku@pidgin.im>
parents: 26112
diff changeset
1597 volume = gst_element_factory_make("volume", "purpleaudioinputvolume");
5f0500efc781 * Added input/output volume preferences for voice conversations.
Michael Ruprecht <maiku@pidgin.im>
parents: 26112
diff changeset
1598 g_object_set(volume, "volume", input_volume, NULL);
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1599 *sendlevel = gst_element_factory_make("level", "sendlevel");
26103
1cdefa229226 Added a mute button for the local microphone.
Michael Ruprecht <maiku@pidgin.im>
parents: 26102
diff changeset
1600 gst_bin_add_many(GST_BIN(*sendbin), src, volume, *sendlevel, NULL);
1cdefa229226 Added a mute button for the local microphone.
Michael Ruprecht <maiku@pidgin.im>
parents: 26102
diff changeset
1601 gst_element_link(src, volume);
1cdefa229226 Added a mute button for the local microphone.
Michael Ruprecht <maiku@pidgin.im>
parents: 26102
diff changeset
1602 gst_element_link(volume, *sendlevel);
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1603 pad = gst_element_get_pad(*sendlevel, "src");
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1604 ghost = gst_ghost_pad_new("ghostsrc", pad);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1605 gst_element_add_pad(*sendbin, ghost);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1606 g_object_set(G_OBJECT(*sendlevel), "message", TRUE, NULL);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1607
26131
5b1937e15c58 Removed several PurpleMedia functions that now seem unnecessary:
Michael Ruprecht <maiku@pidgin.im>
parents: 26129
diff changeset
1608 if (audio_device != NULL && strcmp(audio_device, ""))
5b1937e15c58 Removed several PurpleMedia functions that now seem unnecessary:
Michael Ruprecht <maiku@pidgin.im>
parents: 26129
diff changeset
1609 g_object_set(G_OBJECT(src), "device", audio_device, NULL);
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1610 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1611
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1612 void
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1613 purple_media_video_init_src(GstElement **sendbin)
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1614 {
26335
ee12e5ab3735 Limit the size and framerate of the video source.
Michael Ruprecht <maiku@pidgin.im>
parents: 26333
diff changeset
1615 GstElement *src, *videoscale, *capsfilter;
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1616 GstPad *pad;
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1617 GstPad *ghost;
26335
ee12e5ab3735 Limit the size and framerate of the video source.
Michael Ruprecht <maiku@pidgin.im>
parents: 26333
diff changeset
1618 GstCaps *caps;
26115
5f0500efc781 * Added input/output volume preferences for voice conversations.
Michael Ruprecht <maiku@pidgin.im>
parents: 26112
diff changeset
1619 const gchar *video_plugin = purple_prefs_get_string(
5f0500efc781 * Added input/output volume preferences for voice conversations.
Michael Ruprecht <maiku@pidgin.im>
parents: 26112
diff changeset
1620 "/purple/media/video/plugin");
5f0500efc781 * Added input/output volume preferences for voice conversations.
Michael Ruprecht <maiku@pidgin.im>
parents: 26112
diff changeset
1621 const gchar *video_device = purple_prefs_get_string(
5f0500efc781 * Added input/output volume preferences for voice conversations.
Michael Ruprecht <maiku@pidgin.im>
parents: 26112
diff changeset
1622 "/purple/media/video/device");
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1623
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1624 g_return_if_fail(sendbin != NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1625
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1626 *sendbin = gst_bin_new("purplesendvideobin");
23736
e77595cce169 Preliminary video embedded in the conversation window. It's still kind of buggy.
Michael Ruprecht <maiku@pidgin.im>
parents: 23730
diff changeset
1627 src = gst_element_factory_make(video_plugin, "purplevideosource");
26335
ee12e5ab3735 Limit the size and framerate of the video source.
Michael Ruprecht <maiku@pidgin.im>
parents: 26333
diff changeset
1628 videoscale = gst_element_factory_make("videoscale", NULL);
ee12e5ab3735 Limit the size and framerate of the video source.
Michael Ruprecht <maiku@pidgin.im>
parents: 26333
diff changeset
1629 capsfilter = gst_element_factory_make("capsfilter", NULL);
ee12e5ab3735 Limit the size and framerate of the video source.
Michael Ruprecht <maiku@pidgin.im>
parents: 26333
diff changeset
1630
ee12e5ab3735 Limit the size and framerate of the video source.
Michael Ruprecht <maiku@pidgin.im>
parents: 26333
diff changeset
1631 /* It was recommended to set the size < 352x288 and framerate < 20 */
ee12e5ab3735 Limit the size and framerate of the video source.
Michael Ruprecht <maiku@pidgin.im>
parents: 26333
diff changeset
1632 caps = gst_caps_from_string("video/x-raw-yuv , width=[250,350] , "
ee12e5ab3735 Limit the size and framerate of the video source.
Michael Ruprecht <maiku@pidgin.im>
parents: 26333
diff changeset
1633 "height=[200,275] , framerate=[10/1,20/1]");
ee12e5ab3735 Limit the size and framerate of the video source.
Michael Ruprecht <maiku@pidgin.im>
parents: 26333
diff changeset
1634 g_object_set(G_OBJECT(capsfilter), "caps", caps, NULL);
ee12e5ab3735 Limit the size and framerate of the video source.
Michael Ruprecht <maiku@pidgin.im>
parents: 26333
diff changeset
1635
ee12e5ab3735 Limit the size and framerate of the video source.
Michael Ruprecht <maiku@pidgin.im>
parents: 26333
diff changeset
1636 gst_bin_add_many(GST_BIN(*sendbin), src, videoscale, capsfilter, NULL);
ee12e5ab3735 Limit the size and framerate of the video source.
Michael Ruprecht <maiku@pidgin.im>
parents: 26333
diff changeset
1637 gst_element_link_many(src, videoscale, capsfilter, NULL);
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1638
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1639 if (!strcmp(video_plugin, "videotestsrc")) {
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1640 /* unless is-live is set to true it doesn't throttle videotestsrc */
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1641 g_object_set (G_OBJECT(src), "is-live", TRUE, NULL);
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1642 }
23736
e77595cce169 Preliminary video embedded in the conversation window. It's still kind of buggy.
Michael Ruprecht <maiku@pidgin.im>
parents: 23730
diff changeset
1643
26335
ee12e5ab3735 Limit the size and framerate of the video source.
Michael Ruprecht <maiku@pidgin.im>
parents: 26333
diff changeset
1644 pad = gst_element_get_static_pad(capsfilter, "src");
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1645 ghost = gst_ghost_pad_new("ghostsrc", pad);
26137
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26135
diff changeset
1646 gst_object_unref(pad);
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1647 gst_element_add_pad(*sendbin, ghost);
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1648
26131
5b1937e15c58 Removed several PurpleMedia functions that now seem unnecessary:
Michael Ruprecht <maiku@pidgin.im>
parents: 26129
diff changeset
1649 if (video_device != NULL && strcmp(video_device, ""))
5b1937e15c58 Removed several PurpleMedia functions that now seem unnecessary:
Michael Ruprecht <maiku@pidgin.im>
parents: 26129
diff changeset
1650 g_object_set(G_OBJECT(src), "device", video_device, NULL);
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1651 }
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1652
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1653 void
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1654 purple_media_audio_init_recv(GstElement **recvbin, GstElement **recvlevel)
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1655 {
26317
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1656 GstElement *sink, *volume, *queue;
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1657 GstPad *pad, *ghost;
26115
5f0500efc781 * Added input/output volume preferences for voice conversations.
Michael Ruprecht <maiku@pidgin.im>
parents: 26112
diff changeset
1658 double output_volume = purple_prefs_get_int(
5f0500efc781 * Added input/output volume preferences for voice conversations.
Michael Ruprecht <maiku@pidgin.im>
parents: 26112
diff changeset
1659 "/purple/media/audio/volume/output")/10.0;
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1660
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1661 g_return_if_fail(recvbin != NULL && recvlevel != NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1662
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1663 *recvbin = gst_bin_new("pidginrecvaudiobin");
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1664 sink = gst_element_factory_make("alsasink", "asink");
26323
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
1665 g_object_set(G_OBJECT(sink), "async", FALSE, "sync", FALSE, NULL);
26115
5f0500efc781 * Added input/output volume preferences for voice conversations.
Michael Ruprecht <maiku@pidgin.im>
parents: 26112
diff changeset
1666 volume = gst_element_factory_make("volume", "purpleaudiooutputvolume");
5f0500efc781 * Added input/output volume preferences for voice conversations.
Michael Ruprecht <maiku@pidgin.im>
parents: 26112
diff changeset
1667 g_object_set(volume, "volume", output_volume, NULL);
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1668 *recvlevel = gst_element_factory_make("level", "recvlevel");
26317
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1669 queue = gst_element_factory_make("queue", NULL);
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1670 gst_bin_add_many(GST_BIN(*recvbin), sink, volume,
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1671 *recvlevel, queue, NULL);
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1672 gst_element_link(*recvlevel, sink);
26115
5f0500efc781 * Added input/output volume preferences for voice conversations.
Michael Ruprecht <maiku@pidgin.im>
parents: 26112
diff changeset
1673 gst_element_link(volume, *recvlevel);
26317
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1674 gst_element_link(queue, volume);
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1675 pad = gst_element_get_pad(queue, "sink");
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1676 ghost = gst_ghost_pad_new("ghostsink", pad);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1677 gst_element_add_pad(*recvbin, ghost);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1678 g_object_set(G_OBJECT(*recvlevel), "message", TRUE, NULL);
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1679 }
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22071
diff changeset
1680
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1681 void
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1682 purple_media_video_init_recv(GstElement **recvbin)
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1683 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1684 g_return_if_fail(recvbin != NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1685
26323
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
1686 *recvbin = gst_element_factory_make("autovideosink", NULL);
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1687 }
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1688
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1689 static void
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23726
diff changeset
1690 purple_media_new_local_candidate_cb(FsStream *stream,
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23726
diff changeset
1691 FsCandidate *local_candidate,
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23726
diff changeset
1692 PurpleMediaSession *session)
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1693 {
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1694 gchar *name;
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1695 FsParticipant *participant;
26229
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
1696 PurpleMediaCandidate *candidate;
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1697
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1698 g_return_if_fail(FS_IS_STREAM(stream));
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1699 g_return_if_fail(session != NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1700
26121
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1701 purple_debug_info("media", "got new local candidate: %s\n", local_candidate->foundation);
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1702 g_object_get(stream, "participant", &participant, NULL);
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1703 g_object_get(participant, "cname", &name, NULL);
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1704 g_object_unref(participant);
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1705
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1706 purple_media_insert_local_candidate(session, name, fs_candidate_copy(local_candidate));
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1707
26229
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
1708 candidate = purple_media_candidate_from_fs(local_candidate);
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1709 g_signal_emit(session->media, purple_media_signals[NEW_CANDIDATE],
26116
41f7d4545566 Fixed a ton of memory leaks.
Michael Ruprecht <maiku@pidgin.im>
parents: 26115
diff changeset
1710 0, session->id, name, candidate);
26229
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
1711 purple_media_candidate_free(candidate);
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1712
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1713 g_free(name);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1714 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1715
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1716 static void
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23726
diff changeset
1717 purple_media_candidates_prepared_cb(FsStream *stream, PurpleMediaSession *session)
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1718 {
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1719 gchar *name;
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1720 FsParticipant *participant;
26189
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1721 PurpleMediaStream *stream_data;
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1722
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1723 g_return_if_fail(FS_IS_STREAM(stream));
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1724 g_return_if_fail(session != NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1725
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1726 g_object_get(stream, "participant", &participant, NULL);
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1727 g_object_get(participant, "cname", &name, NULL);
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1728 g_object_unref(participant);
26189
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1729
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1730 stream_data = purple_media_get_stream(session->media, session->id, name);
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1731 stream_data->candidates_prepared = TRUE;
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1732
26417
b73b6e73abe6 Add candidates-prepared signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26412
diff changeset
1733 g_signal_emit(session->media,
b73b6e73abe6 Add candidates-prepared signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26412
diff changeset
1734 purple_media_signals[CANDIDATES_PREPARED],
b73b6e73abe6 Add candidates-prepared signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26412
diff changeset
1735 0, session->id, name);
b73b6e73abe6 Add candidates-prepared signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26412
diff changeset
1736
26189
32cf2cf21fd6 Implement a new ready signal.
Michael Ruprecht <maiku@pidgin.im>
parents: 26187
diff changeset
1737 purple_media_emit_ready(session->media, session, name);
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1738 g_free(name);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1739 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1740
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1741 /* callback called when a pair of transport candidates (local and remote)
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1742 * has been established */
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1743 static void
26163
df72970bffc6 Move variables to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26162
diff changeset
1744 purple_media_candidate_pair_established_cb(FsStream *fsstream,
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23726
diff changeset
1745 FsCandidate *native_candidate,
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23726
diff changeset
1746 FsCandidate *remote_candidate,
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23726
diff changeset
1747 PurpleMediaSession *session)
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1748 {
26163
df72970bffc6 Move variables to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26162
diff changeset
1749 gchar *name;
df72970bffc6 Move variables to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26162
diff changeset
1750 FsParticipant *participant;
df72970bffc6 Move variables to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26162
diff changeset
1751 PurpleMediaStream *stream;
26304
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1752 GList *iter;
26116
41f7d4545566 Fixed a ton of memory leaks.
Michael Ruprecht <maiku@pidgin.im>
parents: 26115
diff changeset
1753
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1754 g_return_if_fail(FS_IS_STREAM(fsstream));
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1755 g_return_if_fail(session != NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1756
26163
df72970bffc6 Move variables to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26162
diff changeset
1757 g_object_get(fsstream, "participant", &participant, NULL);
df72970bffc6 Move variables to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26162
diff changeset
1758 g_object_get(participant, "cname", &name, NULL);
df72970bffc6 Move variables to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26162
diff changeset
1759 g_object_unref(participant);
df72970bffc6 Move variables to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26162
diff changeset
1760
df72970bffc6 Move variables to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26162
diff changeset
1761 stream = purple_media_get_stream(session->media, session->id, name);
df72970bffc6 Move variables to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26162
diff changeset
1762
26304
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1763 iter = stream->active_local_candidates;
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1764 for(; iter; iter = g_list_next(iter)) {
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1765 FsCandidate *c = iter->data;
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1766 if (native_candidate->component_id == c->component_id) {
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1767 fs_candidate_destroy(c);
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1768 stream->active_local_candidates =
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1769 g_list_delete_link(iter, iter);
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1770 stream->active_local_candidates = g_list_prepend(
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1771 stream->active_local_candidates,
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1772 fs_candidate_copy(native_candidate));
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1773 break;
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1774 }
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1775 }
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1776 if (iter == NULL)
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1777 stream->active_local_candidates = g_list_prepend(
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1778 stream->active_local_candidates,
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1779 fs_candidate_copy(native_candidate));
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1780
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1781 iter = stream->active_remote_candidates;
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1782 for(; iter; iter = g_list_next(iter)) {
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1783 FsCandidate *c = iter->data;
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1784 if (native_candidate->component_id == c->component_id) {
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1785 fs_candidate_destroy(c);
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1786 stream->active_remote_candidates =
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1787 g_list_delete_link(iter, iter);
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1788 stream->active_remote_candidates = g_list_prepend(
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1789 stream->active_remote_candidates,
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1790 fs_candidate_copy(remote_candidate));
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1791 break;
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1792 }
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1793 }
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1794 if (iter == NULL)
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1795 stream->active_remote_candidates = g_list_prepend(
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1796 stream->active_remote_candidates,
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
1797 fs_candidate_copy(remote_candidate));
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1798
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1799 purple_debug_info("media", "candidate pair established\n");
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1800 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1801
26234
b94d1e8250a1 Fix some crashes from printing debug messages on a separate thread.
Michael Ruprecht <maiku@pidgin.im>
parents: 26232
diff changeset
1802 static gboolean
b94d1e8250a1 Fix some crashes from printing debug messages on a separate thread.
Michael Ruprecht <maiku@pidgin.im>
parents: 26232
diff changeset
1803 purple_media_connected_cb(PurpleMediaStream *stream)
b94d1e8250a1 Fix some crashes from printing debug messages on a separate thread.
Michael Ruprecht <maiku@pidgin.im>
parents: 26232
diff changeset
1804 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1805 g_return_val_if_fail(stream != NULL, FALSE);
26323
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
1806
26324
4100af381e4e Use purple_timeout_* instead of g_timeout_*.
Michael Ruprecht <maiku@pidgin.im>
parents: 26323
diff changeset
1807 stream->connected_cb_id = 0;
4100af381e4e Use purple_timeout_* instead of g_timeout_*.
Michael Ruprecht <maiku@pidgin.im>
parents: 26323
diff changeset
1808
26323
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
1809 purple_media_manager_create_output_window(
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
1810 stream->session->media->priv->manager,
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
1811 stream->session->media,
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
1812 stream->session->id, stream->participant);
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
1813
26234
b94d1e8250a1 Fix some crashes from printing debug messages on a separate thread.
Michael Ruprecht <maiku@pidgin.im>
parents: 26232
diff changeset
1814 g_signal_emit(stream->session->media,
b94d1e8250a1 Fix some crashes from printing debug messages on a separate thread.
Michael Ruprecht <maiku@pidgin.im>
parents: 26232
diff changeset
1815 purple_media_signals[STATE_CHANGED],
b94d1e8250a1 Fix some crashes from printing debug messages on a separate thread.
Michael Ruprecht <maiku@pidgin.im>
parents: 26232
diff changeset
1816 0, PURPLE_MEDIA_STATE_CHANGED_CONNECTED,
b94d1e8250a1 Fix some crashes from printing debug messages on a separate thread.
Michael Ruprecht <maiku@pidgin.im>
parents: 26232
diff changeset
1817 stream->session->id, stream->participant);
b94d1e8250a1 Fix some crashes from printing debug messages on a separate thread.
Michael Ruprecht <maiku@pidgin.im>
parents: 26232
diff changeset
1818 return FALSE;
b94d1e8250a1 Fix some crashes from printing debug messages on a separate thread.
Michael Ruprecht <maiku@pidgin.im>
parents: 26232
diff changeset
1819 }
b94d1e8250a1 Fix some crashes from printing debug messages on a separate thread.
Michael Ruprecht <maiku@pidgin.im>
parents: 26232
diff changeset
1820
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1821 static void
26176
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1822 purple_media_src_pad_added_cb(FsStream *fsstream, GstPad *srcpad,
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1823 FsCodec *codec, PurpleMediaStream *stream)
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1824 {
26317
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1825 PurpleMediaPrivate *priv;
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1826 GstPad *sinkpad;
26176
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
1827
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1828 g_return_if_fail(FS_IS_STREAM(fsstream));
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1829 g_return_if_fail(stream != NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1830
26317
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1831 priv = stream->session->media->priv;
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1832
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1833 if (stream->src == NULL) {
26340
5c27b1a11dbb Silence warning.
Michael Ruprecht <maiku@pidgin.im>
parents: 26335
diff changeset
1834 GstElement *sink = NULL;
26317
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1835
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1836 if (codec->media_type == FS_MEDIA_TYPE_AUDIO) {
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1837 /*
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1838 * Should this instead be:
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1839 * audioconvert ! audioresample ! liveadder !
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1840 * audioresample ! audioconvert ! realsink
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1841 */
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1842 stream->src = gst_element_factory_make(
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1843 "liveadder", NULL);
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1844 sink = purple_media_manager_get_element(priv->manager,
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1845 PURPLE_MEDIA_RECV_AUDIO);
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1846 } else if (codec->media_type == FS_MEDIA_TYPE_VIDEO) {
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1847 stream->src = gst_element_factory_make(
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1848 "fsfunnel", NULL);
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1849 sink = gst_element_factory_make(
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1850 "fakesink", NULL);
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1851 g_object_set(G_OBJECT(sink), "async", FALSE, NULL);
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1852 }
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1853 stream->tee = gst_element_factory_make("tee", NULL);
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1854 gst_bin_add_many(GST_BIN(priv->confbin),
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1855 stream->src, stream->tee, sink, NULL);
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1856 gst_element_sync_state_with_parent(sink);
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1857 gst_element_sync_state_with_parent(stream->tee);
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1858 gst_element_sync_state_with_parent(stream->src);
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1859 gst_element_link_many(stream->src, stream->tee, sink, NULL);
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1860 }
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1861
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1862 sinkpad = gst_element_get_request_pad(stream->src, "sink%d");
26234
b94d1e8250a1 Fix some crashes from printing debug messages on a separate thread.
Michael Ruprecht <maiku@pidgin.im>
parents: 26232
diff changeset
1863 gst_pad_link(srcpad, sinkpad);
26317
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1864 gst_object_unref(sinkpad);
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1865
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1866 if (codec->media_type == FS_MEDIA_TYPE_VIDEO &&
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1867 stream->sink != NULL) {
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1868 gst_bin_add(GST_BIN(priv->confbin), stream->sink);
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1869 gst_element_set_state(stream->sink, GST_STATE_PLAYING);
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1870 gst_element_link(stream->tee, stream->sink);
ba0a648f53f9 Have all src_pads for a stream be funneled into the same stream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26315
diff changeset
1871 }
26193
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
1872
26324
4100af381e4e Use purple_timeout_* instead of g_timeout_*.
Michael Ruprecht <maiku@pidgin.im>
parents: 26323
diff changeset
1873 stream->connected_cb_id = purple_timeout_add(0,
4100af381e4e Use purple_timeout_* instead of g_timeout_*.
Michael Ruprecht <maiku@pidgin.im>
parents: 26323
diff changeset
1874 (GSourceFunc)purple_media_connected_cb, stream);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1875 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1876
23701
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23699
diff changeset
1877 static gboolean
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1878 purple_media_add_stream_internal(PurpleMedia *media, const gchar *sess_id,
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1879 const gchar *who, FsMediaType type,
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1880 FsStreamDirection type_direction,
26133
a12ffee5bd73 Add params to purple_media_add_stream to allow for different libNice
Michael Ruprecht <maiku@pidgin.im>
parents: 26132
diff changeset
1881 const gchar *transmitter,
a12ffee5bd73 Add params to purple_media_add_stream to allow for different libNice
Michael Ruprecht <maiku@pidgin.im>
parents: 26132
diff changeset
1882 guint num_params, GParameter *params)
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1883 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1884 PurpleMediaSession *session;
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1885 FsParticipant *participant = NULL;
26163
df72970bffc6 Move variables to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26162
diff changeset
1886 PurpleMediaStream *stream = NULL;
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1887 FsStreamDirection *direction = NULL;
26270
c92c7e4eb004 Create the media srcs inside PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26269
diff changeset
1888 PurpleMediaSessionType session_type;
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1889
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1890 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1891
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1892 session = purple_media_get_session(media, sess_id);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
1893
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1894 if (!session) {
23701
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23699
diff changeset
1895 GError *err = NULL;
26121
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1896 GList *codec_conf = NULL;
26148
fd54f5fd9bcb Use a key file for Farsight 2 codec configuration.
Michael Ruprecht <maiku@pidgin.im>
parents: 26143
diff changeset
1897 gchar *filename = NULL;
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1898
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1899 session = g_new0(PurpleMediaSession, 1);
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1900
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1901 session->session = fs_conference_new_session(media->priv->conference, type, &err);
23701
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23699
diff changeset
1902
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23699
diff changeset
1903 if (err != NULL) {
26182
728ad1da9cbc Add purple_media_error.
Michael Ruprecht <maiku@pidgin.im>
parents: 26181
diff changeset
1904 purple_media_error(media, "Error creating session: %s\n", err->message);
23701
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23699
diff changeset
1905 g_error_free(err);
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1906 g_free(session);
23701
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23699
diff changeset
1907 return FALSE;
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23699
diff changeset
1908 }
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23699
diff changeset
1909
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1910 /* XXX: SPEEX has a latency of 5 or 6 seconds for me */
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1911 #if 0
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1912 /* SPEEX is added through the configuration */
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1913 codec_conf = g_list_prepend(codec_conf, fs_codec_new(FS_CODEC_ID_ANY,
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1914 "SPEEX", FS_MEDIA_TYPE_AUDIO, 8000));
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1915 codec_conf = g_list_prepend(codec_conf, fs_codec_new(FS_CODEC_ID_ANY,
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1916 "SPEEX", FS_MEDIA_TYPE_AUDIO, 16000));
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1917 #endif
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1918
26148
fd54f5fd9bcb Use a key file for Farsight 2 codec configuration.
Michael Ruprecht <maiku@pidgin.im>
parents: 26143
diff changeset
1919 filename = g_build_filename(purple_user_dir(), "fs-codec.conf", NULL);
fd54f5fd9bcb Use a key file for Farsight 2 codec configuration.
Michael Ruprecht <maiku@pidgin.im>
parents: 26143
diff changeset
1920 codec_conf = fs_codec_list_from_keyfile(filename, &err);
fd54f5fd9bcb Use a key file for Farsight 2 codec configuration.
Michael Ruprecht <maiku@pidgin.im>
parents: 26143
diff changeset
1921 g_free(filename);
fd54f5fd9bcb Use a key file for Farsight 2 codec configuration.
Michael Ruprecht <maiku@pidgin.im>
parents: 26143
diff changeset
1922
fd54f5fd9bcb Use a key file for Farsight 2 codec configuration.
Michael Ruprecht <maiku@pidgin.im>
parents: 26143
diff changeset
1923 if (err != NULL) {
26296
059a3c380f94 Don't output an error if fs-codec.conf doesn't exist.
Michael Ruprecht <maiku@pidgin.im>
parents: 26290
diff changeset
1924 if (err->code == 4)
059a3c380f94 Don't output an error if fs-codec.conf doesn't exist.
Michael Ruprecht <maiku@pidgin.im>
parents: 26290
diff changeset
1925 purple_debug_info("media", "Couldn't read "
059a3c380f94 Don't output an error if fs-codec.conf doesn't exist.
Michael Ruprecht <maiku@pidgin.im>
parents: 26290
diff changeset
1926 "fs-codec.conf: %s\n",
059a3c380f94 Don't output an error if fs-codec.conf doesn't exist.
Michael Ruprecht <maiku@pidgin.im>
parents: 26290
diff changeset
1927 err->message);
059a3c380f94 Don't output an error if fs-codec.conf doesn't exist.
Michael Ruprecht <maiku@pidgin.im>
parents: 26290
diff changeset
1928 else
059a3c380f94 Don't output an error if fs-codec.conf doesn't exist.
Michael Ruprecht <maiku@pidgin.im>
parents: 26290
diff changeset
1929 purple_debug_error("media", "Error reading "
059a3c380f94 Don't output an error if fs-codec.conf doesn't exist.
Michael Ruprecht <maiku@pidgin.im>
parents: 26290
diff changeset
1930 "fs-codec.conf: %s\n",
059a3c380f94 Don't output an error if fs-codec.conf doesn't exist.
Michael Ruprecht <maiku@pidgin.im>
parents: 26290
diff changeset
1931 err->message);
26148
fd54f5fd9bcb Use a key file for Farsight 2 codec configuration.
Michael Ruprecht <maiku@pidgin.im>
parents: 26143
diff changeset
1932 g_error_free(err);
fd54f5fd9bcb Use a key file for Farsight 2 codec configuration.
Michael Ruprecht <maiku@pidgin.im>
parents: 26143
diff changeset
1933 }
fd54f5fd9bcb Use a key file for Farsight 2 codec configuration.
Michael Ruprecht <maiku@pidgin.im>
parents: 26143
diff changeset
1934
26121
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
1935 fs_session_set_codec_preferences(session->session, codec_conf, NULL);
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1936
26180
7ee4ef9150fd Set no-rtcp-timeout to 0 only for nice and rawudp transmitters.
Michael Ruprecht <maiku@pidgin.im>
parents: 26179
diff changeset
1937 /*
7ee4ef9150fd Set no-rtcp-timeout to 0 only for nice and rawudp transmitters.
Michael Ruprecht <maiku@pidgin.im>
parents: 26179
diff changeset
1938 * Removes a 5-7 second delay before
7ee4ef9150fd Set no-rtcp-timeout to 0 only for nice and rawudp transmitters.
Michael Ruprecht <maiku@pidgin.im>
parents: 26179
diff changeset
1939 * receiving the src-pad-added signal.
7ee4ef9150fd Set no-rtcp-timeout to 0 only for nice and rawudp transmitters.
Michael Ruprecht <maiku@pidgin.im>
parents: 26179
diff changeset
1940 * Only works for non-multicast FsRtpSessions.
7ee4ef9150fd Set no-rtcp-timeout to 0 only for nice and rawudp transmitters.
Michael Ruprecht <maiku@pidgin.im>
parents: 26179
diff changeset
1941 */
7ee4ef9150fd Set no-rtcp-timeout to 0 only for nice and rawudp transmitters.
Michael Ruprecht <maiku@pidgin.im>
parents: 26179
diff changeset
1942 if (!strcmp(transmitter, "nice") || !strcmp(transmitter, "rawudp"))
7ee4ef9150fd Set no-rtcp-timeout to 0 only for nice and rawudp transmitters.
Michael Ruprecht <maiku@pidgin.im>
parents: 26179
diff changeset
1943 g_object_set(G_OBJECT(session->session),
7ee4ef9150fd Set no-rtcp-timeout to 0 only for nice and rawudp transmitters.
Michael Ruprecht <maiku@pidgin.im>
parents: 26179
diff changeset
1944 "no-rtcp-timeout", 0, NULL);
23726
43a5e1a3131d Temporary fix to remove a 5-7 second delay when initiating a media session.
Michael Ruprecht <maiku@pidgin.im>
parents: 23724
diff changeset
1945
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1946 fs_codec_list_destroy(codec_conf);
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1947
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1948 session->id = g_strdup(sess_id);
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1949 session->media = media;
23724
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
1950 session->type = purple_media_from_fs(type, type_direction);
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1951
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
1952 purple_media_add_session(media, session);
26193
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
1953 g_signal_emit(media, purple_media_signals[STATE_CHANGED],
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
1954 0, PURPLE_MEDIA_STATE_CHANGED_NEW,
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
1955 session->id, NULL);
26270
c92c7e4eb004 Create the media srcs inside PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26269
diff changeset
1956
c92c7e4eb004 Create the media srcs inside PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26269
diff changeset
1957 session_type = purple_media_from_fs(type, FS_DIRECTION_SEND);
c92c7e4eb004 Create the media srcs inside PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26269
diff changeset
1958 purple_media_set_src(media, session->id,
c92c7e4eb004 Create the media srcs inside PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26269
diff changeset
1959 purple_media_manager_get_element(
26315
c72d67da93eb Use the media manager that created the media session in media.c.
Michael Ruprecht <maiku@pidgin.im>
parents: 26309
diff changeset
1960 media->priv->manager, session_type));
26270
c92c7e4eb004 Create the media srcs inside PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26269
diff changeset
1961 gst_element_set_state(session->src, GST_STATE_PLAYING);
26323
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
1962
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
1963 purple_media_manager_create_output_window(
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
1964 media->priv->manager,
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
1965 session->media,
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
1966 session->id, NULL);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1967 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1968
23745
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
1969 if (!(participant = purple_media_add_participant(media, who))) {
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
1970 purple_media_remove_session(media, session);
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
1971 g_free(session);
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
1972 return FALSE;
26193
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
1973 } else {
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
1974 g_signal_emit(media, purple_media_signals[STATE_CHANGED],
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
1975 0, PURPLE_MEDIA_STATE_CHANGED_NEW,
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
1976 NULL, who);
23745
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
1977 }
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1978
26163
df72970bffc6 Move variables to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26162
diff changeset
1979 stream = purple_media_get_stream(media, sess_id, who);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1980
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
1981 if (!stream) {
23745
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
1982 GError *err = NULL;
26163
df72970bffc6 Move variables to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26162
diff changeset
1983 FsStream *fsstream = NULL;
26256
d2673c935184 Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents: 26253
diff changeset
1984 const gchar *stun_ip = purple_network_get_stun_ip();
26261
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
1985 const gchar *turn_ip = purple_network_get_turn_ip();
26262
1ad96aa2e92a Removed some extra tabs on blank lines
Marcus Lundblad <malu@pidgin.im>
parents: 26261
diff changeset
1986
26261
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
1987 if (stun_ip || turn_ip) {
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
1988 guint new_num_params =
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
1989 stun_ip && turn_ip ? num_params + 2 : num_params + 1;
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
1990 guint next_param_index = num_params;
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
1991 GParameter *param = g_new0(GParameter, new_num_params);
26133
a12ffee5bd73 Add params to purple_media_add_stream to allow for different libNice
Michael Ruprecht <maiku@pidgin.im>
parents: 26132
diff changeset
1992 memcpy(param, params, sizeof(GParameter) * num_params);
26097
0d34ffa7c5a9 Use the purple STUN server preference with the rawudp Farsight transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents: 26096
diff changeset
1993
26261
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
1994 if (stun_ip) {
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
1995 purple_debug_info("media",
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
1996 "setting property stun-ip on new stream: %s\n", stun_ip);
26262
1ad96aa2e92a Removed some extra tabs on blank lines
Marcus Lundblad <malu@pidgin.im>
parents: 26261
diff changeset
1997
26261
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
1998 param[next_param_index].name = "stun-ip";
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
1999 g_value_init(&param[next_param_index].value, G_TYPE_STRING);
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2000 g_value_set_string(&param[next_param_index].value, stun_ip);
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2001 next_param_index++;
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2002 }
26262
1ad96aa2e92a Removed some extra tabs on blank lines
Marcus Lundblad <malu@pidgin.im>
parents: 26261
diff changeset
2003
26261
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2004 if (turn_ip) {
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2005 GValueArray *relay_info = g_value_array_new(0);
26263
725845e88ebf Removed a couple of warnings
Marcus Lundblad <malu@pidgin.im>
parents: 26262
diff changeset
2006 GValue value;
26261
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2007 gint turn_port =
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2008 purple_prefs_get_int("/purple/network/turn_port");
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2009 const gchar *username =
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2010 purple_prefs_get_string("/purple/network/turn_username");
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2011 const gchar *password =
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2012 purple_prefs_get_string("/purple/network/turn_password");
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2013 GstStructure *turn_setup = gst_structure_new("relay-info",
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2014 "ip", G_TYPE_STRING, turn_ip,
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2015 "port", G_TYPE_UINT, turn_port,
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2016 "username", G_TYPE_STRING, username,
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2017 "password", G_TYPE_STRING, password,
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2018 NULL);
26097
0d34ffa7c5a9 Use the purple STUN server preference with the rawudp Farsight transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents: 26096
diff changeset
2019
26261
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2020 if (turn_setup) {
26263
725845e88ebf Removed a couple of warnings
Marcus Lundblad <malu@pidgin.im>
parents: 26262
diff changeset
2021 memset(&value, 0, sizeof(GValue));
26261
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2022 g_value_init(&value, GST_TYPE_STRUCTURE);
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2023 gst_value_set_structure(&value, turn_setup);
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2024 relay_info = g_value_array_append(relay_info, &value);
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2025 gst_structure_free(turn_setup);
26262
1ad96aa2e92a Removed some extra tabs on blank lines
Marcus Lundblad <malu@pidgin.im>
parents: 26261
diff changeset
2026
26261
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2027 purple_debug_info("media",
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2028 "setting property relay-info on new stream\n");
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2029 param[next_param_index].name = "relay-info";
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2030 g_value_init(&param[next_param_index].value,
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2031 G_TYPE_VALUE_ARRAY);
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2032 g_value_set_boxed(&param[next_param_index].value,
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2033 relay_info);
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2034 g_value_array_free(relay_info);
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2035 } else {
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2036 purple_debug_error("media", "Error relay info");
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2037 g_object_unref(participant);
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2038 g_hash_table_remove(media->priv->participants, who);
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2039 purple_media_remove_session(media, session);
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2040 g_free(session);
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2041 return FALSE;
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2042 }
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2043 }
26262
1ad96aa2e92a Removed some extra tabs on blank lines
Marcus Lundblad <malu@pidgin.im>
parents: 26261
diff changeset
2044
26163
df72970bffc6 Move variables to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26162
diff changeset
2045 fsstream = fs_session_new_stream(session->session,
26257
e4a840dab1d4 Use the stream's direction to wait to send media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26256
diff changeset
2046 participant, type_direction &
e4a840dab1d4 Use the stream's direction to wait to send media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26256
diff changeset
2047 FS_DIRECTION_RECV, transmitter,
26261
ffabb135a4b6 Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents: 26259
diff changeset
2048 new_num_params, param, &err);
26133
a12ffee5bd73 Add params to purple_media_add_stream to allow for different libNice
Michael Ruprecht <maiku@pidgin.im>
parents: 26132
diff changeset
2049 g_free(param);
26097
0d34ffa7c5a9 Use the purple STUN server preference with the rawudp Farsight transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents: 26096
diff changeset
2050 } else {
26163
df72970bffc6 Move variables to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26162
diff changeset
2051 fsstream = fs_session_new_stream(session->session,
26257
e4a840dab1d4 Use the stream's direction to wait to send media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26256
diff changeset
2052 participant, type_direction &
e4a840dab1d4 Use the stream's direction to wait to send media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26256
diff changeset
2053 FS_DIRECTION_RECV, transmitter,
e4a840dab1d4 Use the stream's direction to wait to send media.
Michael Ruprecht <maiku@pidgin.im>
parents: 26256
diff changeset
2054 num_params, params, &err);
26097
0d34ffa7c5a9 Use the purple STUN server preference with the rawudp Farsight transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents: 26096
diff changeset
2055 }
23745
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
2056
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
2057 if (err) {
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
2058 purple_debug_error("media", "Error creating stream: %s\n",
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
2059 err->message);
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
2060 g_error_free(err);
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
2061 g_object_unref(participant);
26129
18c8f2cfb52b Properly free PurpleMedia when there's an error creating an FsStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26125
diff changeset
2062 g_hash_table_remove(media->priv->participants, who);
23745
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
2063 purple_media_remove_session(media, session);
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
2064 g_free(session);
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
2065 return FALSE;
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
2066 }
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
2067
26176
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
2068 stream = purple_media_insert_stream(session, who, fsstream);
26121
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
2069
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2070 /* callback for source pad added (new stream source ready) */
26163
df72970bffc6 Move variables to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26162
diff changeset
2071 g_signal_connect(G_OBJECT(fsstream),
26176
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
2072 "src-pad-added", G_CALLBACK(purple_media_src_pad_added_cb), stream);
26121
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
2073
26193
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
2074 g_signal_emit(media, purple_media_signals[STATE_CHANGED],
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
2075 0, PURPLE_MEDIA_STATE_CHANGED_NEW,
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
2076 session->id, who);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2077 } else if (*direction != type_direction) {
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2078 /* change direction */
26163
df72970bffc6 Move variables to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26162
diff changeset
2079 g_object_set(stream->stream, "direction", type_direction, NULL);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2080 }
23701
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23699
diff changeset
2081
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23699
diff changeset
2082 return TRUE;
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2083 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2084
23701
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23699
diff changeset
2085 gboolean
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
2086 purple_media_add_stream(PurpleMedia *media, const gchar *sess_id, const gchar *who,
26108
8d0fd2f195aa Changed PurpleMediaStreamType to PurpleMediaSessionType.
Michael Ruprecht <maiku@pidgin.im>
parents: 26105
diff changeset
2087 PurpleMediaSessionType type,
26133
a12ffee5bd73 Add params to purple_media_add_stream to allow for different libNice
Michael Ruprecht <maiku@pidgin.im>
parents: 26132
diff changeset
2088 const gchar *transmitter,
a12ffee5bd73 Add params to purple_media_add_stream to allow for different libNice
Michael Ruprecht <maiku@pidgin.im>
parents: 26132
diff changeset
2089 guint num_params, GParameter *params)
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2090 {
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2091 FsStreamDirection type_direction;
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2092
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2093 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2094
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2095 if (type & PURPLE_MEDIA_AUDIO) {
23724
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
2096 type_direction = purple_media_to_fs_stream_direction(type & PURPLE_MEDIA_AUDIO);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2097
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
2098 if (!purple_media_add_stream_internal(media, sess_id, who,
23701
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23699
diff changeset
2099 FS_MEDIA_TYPE_AUDIO, type_direction,
26133
a12ffee5bd73 Add params to purple_media_add_stream to allow for different libNice
Michael Ruprecht <maiku@pidgin.im>
parents: 26132
diff changeset
2100 transmitter, num_params, params)) {
23701
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23699
diff changeset
2101 return FALSE;
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23699
diff changeset
2102 }
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2103 }
26134
2def4b29fcfe purple_media_add_stream should only add a stream to one session.
Michael Ruprecht <maiku@pidgin.im>
parents: 26133
diff changeset
2104 else if (type & PURPLE_MEDIA_VIDEO) {
23724
5d3300ffacad Added some utility functions to convert PurpleMediaStreamType
Michael Ruprecht <maiku@pidgin.im>
parents: 23721
diff changeset
2105 type_direction = purple_media_to_fs_stream_direction(type & PURPLE_MEDIA_VIDEO);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2106
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
2107 if (!purple_media_add_stream_internal(media, sess_id, who,
23701
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23699
diff changeset
2108 FS_MEDIA_TYPE_VIDEO, type_direction,
26133
a12ffee5bd73 Add params to purple_media_add_stream to allow for different libNice
Michael Ruprecht <maiku@pidgin.im>
parents: 26132
diff changeset
2109 transmitter, num_params, params)) {
23701
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23699
diff changeset
2110 return FALSE;
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23699
diff changeset
2111 }
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2112 }
23701
ecbd92b724df Added better Farsight error handling. Fixes several crash bugs related
Michael Ruprecht <maiku@pidgin.im>
parents: 23699
diff changeset
2113 return TRUE;
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2114 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2115
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2116 void
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
2117 purple_media_remove_stream(PurpleMedia *media, const gchar *sess_id, const gchar *who)
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2118 {
26193
101122f0f3dd Add state-changed signal to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents: 26191
diff changeset
2119 /* Add state-changed end emits in here when this is implemented */
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2120 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2121
26108
8d0fd2f195aa Changed PurpleMediaStreamType to PurpleMediaSessionType.
Michael Ruprecht <maiku@pidgin.im>
parents: 26105
diff changeset
2122 PurpleMediaSessionType
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
2123 purple_media_get_session_type(PurpleMedia *media, const gchar *sess_id)
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2124 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2125 PurpleMediaSession *session;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2126 g_return_val_if_fail(PURPLE_IS_MEDIA(media), PURPLE_MEDIA_NONE);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2127 session = purple_media_get_session(media, sess_id);
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
2128 return session->type;
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2129 }
26121
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
2130 /* XXX: Should wait until codecs-ready is TRUE before using this function */
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2131 GList *
26160
46bc5e18d59c Combine get_*_codecs functions to mirror Farsight 2.
Michael Ruprecht <maiku@pidgin.im>
parents: 26151
diff changeset
2132 purple_media_get_codecs(PurpleMedia *media, const gchar *sess_id)
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2133 {
26232
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
2134 GList *fscodecs;
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2135 GList *codecs;
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2136 PurpleMediaSession *session;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2137
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2138 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2139
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2140 session = purple_media_get_session(media, sess_id);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2141
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2142 if (session == NULL)
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2143 return NULL;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2144
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2145 g_object_get(G_OBJECT(session->session),
26232
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
2146 "codecs", &fscodecs, NULL);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
2147 codecs = purple_media_codec_list_from_fs(fscodecs);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
2148 fs_codec_list_destroy(fscodecs);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2149 return codecs;
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2150 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2151
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2152 GList *
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
2153 purple_media_get_local_candidates(PurpleMedia *media, const gchar *sess_id, const gchar *name)
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2154 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2155 PurpleMediaStream *stream;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2156 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2157 stream = purple_media_get_stream(media, sess_id, name);
26229
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
2158 return purple_media_candidate_list_from_fs(stream->local_candidates);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2159 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2160
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2161 void
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
2162 purple_media_add_remote_candidates(PurpleMedia *media, const gchar *sess_id,
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
2163 const gchar *name, GList *remote_candidates)
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2164 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2165 PurpleMediaStream *stream;
26258
9cfc01913beb Set remote candidates as soon as they are received.
Michael Ruprecht <maiku@pidgin.im>
parents: 26257
diff changeset
2166 GError *err = NULL;
9cfc01913beb Set remote candidates as soon as they are received.
Michael Ruprecht <maiku@pidgin.im>
parents: 26257
diff changeset
2167
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2168 g_return_if_fail(PURPLE_IS_MEDIA(media));
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2169 stream = purple_media_get_stream(media, sess_id, name);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2170
26200
6636bcf92be3 Add candidates instead of replacing them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26195
diff changeset
2171 stream->remote_candidates = g_list_concat(stream->remote_candidates,
26229
3e786c9ebb62 Duplicate FsCandidate to remove it from the public interface.
Michael Ruprecht <maiku@pidgin.im>
parents: 26228
diff changeset
2172 purple_media_candidate_list_to_fs(remote_candidates));
26121
8b548a0ea68e Update to Farsight2 0.0.3.
Michael Ruprecht <maiku@pidgin.im>
parents: 26120
diff changeset
2173
26258
9cfc01913beb Set remote candidates as soon as they are received.
Michael Ruprecht <maiku@pidgin.im>
parents: 26257
diff changeset
2174 fs_stream_set_remote_candidates(stream->stream,
9cfc01913beb Set remote candidates as soon as they are received.
Michael Ruprecht <maiku@pidgin.im>
parents: 26257
diff changeset
2175 stream->remote_candidates, &err);
9cfc01913beb Set remote candidates as soon as they are received.
Michael Ruprecht <maiku@pidgin.im>
parents: 26257
diff changeset
2176
9cfc01913beb Set remote candidates as soon as they are received.
Michael Ruprecht <maiku@pidgin.im>
parents: 26257
diff changeset
2177 if (err) {
9cfc01913beb Set remote candidates as soon as they are received.
Michael Ruprecht <maiku@pidgin.im>
parents: 26257
diff changeset
2178 purple_debug_error("media", "Error adding remote"
9cfc01913beb Set remote candidates as soon as they are received.
Michael Ruprecht <maiku@pidgin.im>
parents: 26257
diff changeset
2179 " candidates: %s\n", err->message);
9cfc01913beb Set remote candidates as soon as they are received.
Michael Ruprecht <maiku@pidgin.im>
parents: 26257
diff changeset
2180 g_error_free(err);
23745
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
2181 }
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2182 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2183
26304
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
2184 GList *
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
2185 purple_media_get_active_local_candidates(PurpleMedia *media,
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
2186 const gchar *sess_id, const gchar *name)
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2187 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2188 PurpleMediaStream *stream;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2189 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2190 stream = purple_media_get_stream(media, sess_id, name);
26304
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
2191 return purple_media_candidate_list_from_fs(
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
2192 stream->active_local_candidates);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2193 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2194
26304
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
2195 GList *
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
2196 purple_media_get_active_remote_candidates(PurpleMedia *media,
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
2197 const gchar *sess_id, const gchar *name)
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2198 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2199 PurpleMediaStream *stream;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2200 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2201 stream = purple_media_get_stream(media, sess_id, name);
26304
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
2202 return purple_media_candidate_list_from_fs(
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
2203 stream->active_remote_candidates);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2204 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2205
23745
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
2206 gboolean
23721
15285d082f6c Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Michael Ruprecht <maiku@pidgin.im>
parents: 23711
diff changeset
2207 purple_media_set_remote_codecs(PurpleMedia *media, const gchar *sess_id, const gchar *name, GList *codecs)
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2208 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2209 PurpleMediaStream *stream;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2210 FsStream *fsstream;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2211 GList *fscodecs;
23745
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
2212 GError *err = NULL;
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
2213
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2214 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2215 stream = purple_media_get_stream(media, sess_id, name);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2216
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2217 if (stream == NULL)
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2218 return FALSE;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2219
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2220 fsstream = stream->stream;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2221 fscodecs = purple_media_codec_list_to_fs(codecs);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2222 fs_stream_set_remote_codecs(fsstream, fscodecs, &err);
26232
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
2223 fs_codec_list_destroy(fscodecs);
23745
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
2224
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
2225 if (err) {
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
2226 purple_debug_error("media", "Error setting remote codecs: %s\n",
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
2227 err->message);
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
2228 g_error_free(err);
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
2229 return FALSE;
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
2230 }
091a506a7018 Added better Farsight error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 23744
diff changeset
2231 return TRUE;
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2232 }
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22682
diff changeset
2233
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23726
diff changeset
2234 gboolean
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23726
diff changeset
2235 purple_media_candidates_prepared(PurpleMedia *media, const gchar *name)
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23726
diff changeset
2236 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2237 GList *sessions;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2238
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2239 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2240
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2241 sessions = purple_media_get_session_names(media);
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23726
diff changeset
2242
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23726
diff changeset
2243 for (; sessions; sessions = sessions->next) {
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23726
diff changeset
2244 const gchar *session = sessions->data;
26304
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
2245 GList *local = purple_media_get_active_local_candidates(
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
2246 media, session, name);
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
2247 GList *remote = purple_media_get_active_remote_candidates(
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
2248 media, session, name);
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
2249 gboolean result = (local == NULL || remote == NULL);
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
2250 purple_media_candidate_list_free(local);
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
2251 purple_media_candidate_list_free(remote);
6e19bf6af065 Handle having multiple active candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26297
diff changeset
2252 if (!result)
23730
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23726
diff changeset
2253 return FALSE;
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23726
diff changeset
2254 }
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23726
diff changeset
2255
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23726
diff changeset
2256 return TRUE;
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23726
diff changeset
2257 }
ed15b42da75c Jingle sessions now keep track of their transaction state to a degree.
Michael Ruprecht <maiku@pidgin.im>
parents: 23726
diff changeset
2258
26102
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26097
diff changeset
2259 gboolean
26232
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
2260 purple_media_set_send_codec(PurpleMedia *media, const gchar *sess_id, PurpleMediaCodec *codec)
26102
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26097
diff changeset
2261 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2262 PurpleMediaSession *session;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2263 FsCodec *fscodec;
26102
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26097
diff changeset
2264 GError *err = NULL;
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26097
diff changeset
2265
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2266 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2267
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2268 session = purple_media_get_session(media, sess_id);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2269
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2270 if (session != NULL)
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2271 return FALSE;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2272
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2273 fscodec = purple_media_codec_to_fs(codec);
26232
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
2274 fs_session_set_send_codec(session->session, fscodec, &err);
f91c96072586 Wrap FsCodec and remove the Farsight2 include from media.h.
Michael Ruprecht <maiku@pidgin.im>
parents: 26231
diff changeset
2275 fs_codec_destroy(fscodec);
26102
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26097
diff changeset
2276
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26097
diff changeset
2277 if (err) {
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26097
diff changeset
2278 purple_debug_error("media", "Error setting send codec\n");
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26097
diff changeset
2279 g_error_free(err);
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26097
diff changeset
2280 return FALSE;
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26097
diff changeset
2281 }
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26097
diff changeset
2282 return TRUE;
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26097
diff changeset
2283 }
881a436d77eb Set the proper send codec in Farsight.
Michael Ruprecht <maiku@pidgin.im>
parents: 26097
diff changeset
2284
26137
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26135
diff changeset
2285 gboolean
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26135
diff changeset
2286 purple_media_codecs_ready(PurpleMedia *media, const gchar *sess_id)
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26135
diff changeset
2287 {
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26135
diff changeset
2288 gboolean ret;
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2289
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2290 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2291
26333
2b88f86521fb Have purple_media_codecs_ready handle a session wildcard.
Michael Ruprecht <maiku@pidgin.im>
parents: 26332
diff changeset
2292 if (sess_id != NULL) {
2b88f86521fb Have purple_media_codecs_ready handle a session wildcard.
Michael Ruprecht <maiku@pidgin.im>
parents: 26332
diff changeset
2293 PurpleMediaSession *session;
2b88f86521fb Have purple_media_codecs_ready handle a session wildcard.
Michael Ruprecht <maiku@pidgin.im>
parents: 26332
diff changeset
2294 session = purple_media_get_session(media, sess_id);
2b88f86521fb Have purple_media_codecs_ready handle a session wildcard.
Michael Ruprecht <maiku@pidgin.im>
parents: 26332
diff changeset
2295
2b88f86521fb Have purple_media_codecs_ready handle a session wildcard.
Michael Ruprecht <maiku@pidgin.im>
parents: 26332
diff changeset
2296 if (session == NULL)
2b88f86521fb Have purple_media_codecs_ready handle a session wildcard.
Michael Ruprecht <maiku@pidgin.im>
parents: 26332
diff changeset
2297 return FALSE;
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2298
26333
2b88f86521fb Have purple_media_codecs_ready handle a session wildcard.
Michael Ruprecht <maiku@pidgin.im>
parents: 26332
diff changeset
2299 g_object_get(session->session, "codecs-ready", &ret, NULL);
2b88f86521fb Have purple_media_codecs_ready handle a session wildcard.
Michael Ruprecht <maiku@pidgin.im>
parents: 26332
diff changeset
2300 } else {
2b88f86521fb Have purple_media_codecs_ready handle a session wildcard.
Michael Ruprecht <maiku@pidgin.im>
parents: 26332
diff changeset
2301 GList *values = g_hash_table_get_values(media->priv->sessions);
2b88f86521fb Have purple_media_codecs_ready handle a session wildcard.
Michael Ruprecht <maiku@pidgin.im>
parents: 26332
diff changeset
2302 for (; values; values = g_list_delete_link(values, values)) {
2b88f86521fb Have purple_media_codecs_ready handle a session wildcard.
Michael Ruprecht <maiku@pidgin.im>
parents: 26332
diff changeset
2303 PurpleMediaSession *session = values->data;
2b88f86521fb Have purple_media_codecs_ready handle a session wildcard.
Michael Ruprecht <maiku@pidgin.im>
parents: 26332
diff changeset
2304 g_object_get(session->session,
2b88f86521fb Have purple_media_codecs_ready handle a session wildcard.
Michael Ruprecht <maiku@pidgin.im>
parents: 26332
diff changeset
2305 "codecs-ready", &ret, NULL);
2b88f86521fb Have purple_media_codecs_ready handle a session wildcard.
Michael Ruprecht <maiku@pidgin.im>
parents: 26332
diff changeset
2306 if (ret == FALSE)
2b88f86521fb Have purple_media_codecs_ready handle a session wildcard.
Michael Ruprecht <maiku@pidgin.im>
parents: 26332
diff changeset
2307 break;
2b88f86521fb Have purple_media_codecs_ready handle a session wildcard.
Michael Ruprecht <maiku@pidgin.im>
parents: 26332
diff changeset
2308 }
2b88f86521fb Have purple_media_codecs_ready handle a session wildcard.
Michael Ruprecht <maiku@pidgin.im>
parents: 26332
diff changeset
2309 if (values != NULL)
2b88f86521fb Have purple_media_codecs_ready handle a session wildcard.
Michael Ruprecht <maiku@pidgin.im>
parents: 26332
diff changeset
2310 g_list_free(values);
2b88f86521fb Have purple_media_codecs_ready handle a session wildcard.
Michael Ruprecht <maiku@pidgin.im>
parents: 26332
diff changeset
2311 }
26137
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26135
diff changeset
2312 return ret;
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26135
diff changeset
2313 }
0688cf5221c9 Wait for Farsight 2's codecs-ready property to be TRUE before using codecs.
Michael Ruprecht <maiku@pidgin.im>
parents: 26135
diff changeset
2314
26267
3bd0240f0632 Add the accepted signal and make the accept button go away immediately.
Michael Ruprecht <maiku@pidgin.im>
parents: 26266
diff changeset
2315 gboolean
3bd0240f0632 Add the accepted signal and make the accept button go away immediately.
Michael Ruprecht <maiku@pidgin.im>
parents: 26266
diff changeset
2316 purple_media_accepted(PurpleMedia *media, const gchar *sess_id,
3bd0240f0632 Add the accepted signal and make the accept button go away immediately.
Michael Ruprecht <maiku@pidgin.im>
parents: 26266
diff changeset
2317 const gchar *participant)
3bd0240f0632 Add the accepted signal and make the accept button go away immediately.
Michael Ruprecht <maiku@pidgin.im>
parents: 26266
diff changeset
2318 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2319 PurpleMediaSession *session;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2320
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2321 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2322
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2323 session = purple_media_get_session(media, sess_id);
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2324
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2325 if (session == NULL)
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2326 return FALSE;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2327
26267
3bd0240f0632 Add the accepted signal and make the accept button go away immediately.
Michael Ruprecht <maiku@pidgin.im>
parents: 26266
diff changeset
2328 return session->accepted;
3bd0240f0632 Add the accepted signal and make the accept button go away immediately.
Michael Ruprecht <maiku@pidgin.im>
parents: 26266
diff changeset
2329 }
3bd0240f0632 Add the accepted signal and make the accept button go away immediately.
Michael Ruprecht <maiku@pidgin.im>
parents: 26266
diff changeset
2330
26103
1cdefa229226 Added a mute button for the local microphone.
Michael Ruprecht <maiku@pidgin.im>
parents: 26102
diff changeset
2331 void purple_media_mute(PurpleMedia *media, gboolean active)
1cdefa229226 Added a mute button for the local microphone.
Michael Ruprecht <maiku@pidgin.im>
parents: 26102
diff changeset
2332 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2333 GList *sessions;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2334
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2335 g_return_if_fail(PURPLE_IS_MEDIA(media));
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2336
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2337 sessions = g_hash_table_get_values(media->priv->sessions);
26103
1cdefa229226 Added a mute button for the local microphone.
Michael Ruprecht <maiku@pidgin.im>
parents: 26102
diff changeset
2338 purple_debug_info("media", "Turning mute %s\n", active ? "on" : "off");
1cdefa229226 Added a mute button for the local microphone.
Michael Ruprecht <maiku@pidgin.im>
parents: 26102
diff changeset
2339
1cdefa229226 Added a mute button for the local microphone.
Michael Ruprecht <maiku@pidgin.im>
parents: 26102
diff changeset
2340 for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
1cdefa229226 Added a mute button for the local microphone.
Michael Ruprecht <maiku@pidgin.im>
parents: 26102
diff changeset
2341 PurpleMediaSession *session = sessions->data;
1cdefa229226 Added a mute button for the local microphone.
Michael Ruprecht <maiku@pidgin.im>
parents: 26102
diff changeset
2342 if (session->type & PURPLE_MEDIA_SEND_AUDIO) {
1cdefa229226 Added a mute button for the local microphone.
Michael Ruprecht <maiku@pidgin.im>
parents: 26102
diff changeset
2343 GstElement *volume = gst_bin_get_by_name(
1cdefa229226 Added a mute button for the local microphone.
Michael Ruprecht <maiku@pidgin.im>
parents: 26102
diff changeset
2344 GST_BIN(session->src),
26115
5f0500efc781 * Added input/output volume preferences for voice conversations.
Michael Ruprecht <maiku@pidgin.im>
parents: 26112
diff changeset
2345 "purpleaudioinputvolume");
26103
1cdefa229226 Added a mute button for the local microphone.
Michael Ruprecht <maiku@pidgin.im>
parents: 26102
diff changeset
2346 g_object_set(volume, "mute", active, NULL);
1cdefa229226 Added a mute button for the local microphone.
Michael Ruprecht <maiku@pidgin.im>
parents: 26102
diff changeset
2347 }
1cdefa229226 Added a mute button for the local microphone.
Michael Ruprecht <maiku@pidgin.im>
parents: 26102
diff changeset
2348 }
1cdefa229226 Added a mute button for the local microphone.
Michael Ruprecht <maiku@pidgin.im>
parents: 26102
diff changeset
2349 }
1cdefa229226 Added a mute button for the local microphone.
Michael Ruprecht <maiku@pidgin.im>
parents: 26102
diff changeset
2350
26172
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2351 void purple_media_set_input_volume(PurpleMedia *media,
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2352 const gchar *session_id, double level)
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2353 {
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2354 GList *sessions;
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2355
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2356 g_return_if_fail(PURPLE_IS_MEDIA(media));
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2357
26172
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2358 if (session_id == NULL)
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2359 sessions = g_hash_table_get_values(media->priv->sessions);
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2360 else
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2361 sessions = g_list_append(NULL,
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2362 purple_media_get_session(media, session_id));
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2363
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2364 for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2365 PurpleMediaSession *session = sessions->data;
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2366
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2367 if (session->type & PURPLE_MEDIA_SEND_AUDIO) {
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2368 GstElement *volume = gst_bin_get_by_name(
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2369 GST_BIN(session->src),
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2370 "purpleaudioinputvolume");
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2371 g_object_set(volume, "volume", level, NULL);
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2372 }
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2373 }
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2374 }
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2375
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2376 void purple_media_set_output_volume(PurpleMedia *media,
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2377 const gchar *session_id, const gchar *participant,
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2378 double level)
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2379 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2380 GList *streams;
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2381
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2382 g_return_if_fail(PURPLE_IS_MEDIA(media));
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2383
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2384 streams = purple_media_get_streams(media,
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2385 session_id, participant);
26172
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2386
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2387 for (; streams; streams = g_list_delete_link(streams, streams)) {
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2388 PurpleMediaStream *stream = streams->data;
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2389
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2390 if (stream->session->type & PURPLE_MEDIA_RECV_AUDIO) {
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2391 GstElement *volume = gst_bin_get_by_name(
26176
05f45eb5a8ed Move sink from PurpleMediaSession to PurpleMediaStream.
Michael Ruprecht <maiku@pidgin.im>
parents: 26174
diff changeset
2392 GST_BIN(stream->sink),
26172
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2393 "purpleaudiooutputvolume");
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2394 g_object_set(volume, "volume", level, NULL);
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2395 }
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2396 }
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2397 }
b14249e42983 Added media functions to set input and output volume.
Michael Ruprecht <maiku@pidgin.im>
parents: 26168
diff changeset
2398
26323
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2399 gulong
26259
0983517fc75f Wait to create the sinks until the frames are ready.
Michael Ruprecht <maiku@pidgin.im>
parents: 26258
diff changeset
2400 purple_media_set_output_window(PurpleMedia *media, const gchar *session_id,
0983517fc75f Wait to create the sinks until the frames are ready.
Michael Ruprecht <maiku@pidgin.im>
parents: 26258
diff changeset
2401 const gchar *participant, gulong window_id)
0983517fc75f Wait to create the sinks until the frames are ready.
Michael Ruprecht <maiku@pidgin.im>
parents: 26258
diff changeset
2402 {
26278
385a3da0c2fe Added a lot of assertions and error handling.
Michael Ruprecht <maiku@pidgin.im>
parents: 26276
diff changeset
2403 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
26259
0983517fc75f Wait to create the sinks until the frames are ready.
Michael Ruprecht <maiku@pidgin.im>
parents: 26258
diff changeset
2404
26323
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2405 return purple_media_manager_set_output_window(media->priv->manager,
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2406 media, session_id, participant, window_id);
26281
111754ffd39b Implement *_remove_output_window and *_remove_output_windows.
Michael Ruprecht <maiku@pidgin.im>
parents: 26280
diff changeset
2407 }
111754ffd39b Implement *_remove_output_window and *_remove_output_windows.
Michael Ruprecht <maiku@pidgin.im>
parents: 26280
diff changeset
2408
111754ffd39b Implement *_remove_output_window and *_remove_output_windows.
Michael Ruprecht <maiku@pidgin.im>
parents: 26280
diff changeset
2409 void
111754ffd39b Implement *_remove_output_window and *_remove_output_windows.
Michael Ruprecht <maiku@pidgin.im>
parents: 26280
diff changeset
2410 purple_media_remove_output_windows(PurpleMedia *media)
111754ffd39b Implement *_remove_output_window and *_remove_output_windows.
Michael Ruprecht <maiku@pidgin.im>
parents: 26280
diff changeset
2411 {
111754ffd39b Implement *_remove_output_window and *_remove_output_windows.
Michael Ruprecht <maiku@pidgin.im>
parents: 26280
diff changeset
2412 GList *iter = media->priv->streams;
111754ffd39b Implement *_remove_output_window and *_remove_output_windows.
Michael Ruprecht <maiku@pidgin.im>
parents: 26280
diff changeset
2413 for (; iter; iter = g_list_next(iter)) {
111754ffd39b Implement *_remove_output_window and *_remove_output_windows.
Michael Ruprecht <maiku@pidgin.im>
parents: 26280
diff changeset
2414 PurpleMediaStream *stream = iter->data;
26323
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2415 purple_media_manager_remove_output_windows(
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2416 media->priv->manager, media,
26281
111754ffd39b Implement *_remove_output_window and *_remove_output_windows.
Michael Ruprecht <maiku@pidgin.im>
parents: 26280
diff changeset
2417 stream->session->id, stream->participant);
111754ffd39b Implement *_remove_output_window and *_remove_output_windows.
Michael Ruprecht <maiku@pidgin.im>
parents: 26280
diff changeset
2418 }
111754ffd39b Implement *_remove_output_window and *_remove_output_windows.
Michael Ruprecht <maiku@pidgin.im>
parents: 26280
diff changeset
2419
111754ffd39b Implement *_remove_output_window and *_remove_output_windows.
Michael Ruprecht <maiku@pidgin.im>
parents: 26280
diff changeset
2420 iter = purple_media_get_session_names(media);
111754ffd39b Implement *_remove_output_window and *_remove_output_windows.
Michael Ruprecht <maiku@pidgin.im>
parents: 26280
diff changeset
2421 for (; iter; iter = g_list_delete_link(iter, iter)) {
111754ffd39b Implement *_remove_output_window and *_remove_output_windows.
Michael Ruprecht <maiku@pidgin.im>
parents: 26280
diff changeset
2422 gchar *session_name = iter->data;
26323
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2423 purple_media_manager_remove_output_windows(
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2424 media->priv->manager, media,
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2425 session_name, NULL);
26281
111754ffd39b Implement *_remove_output_window and *_remove_output_windows.
Michael Ruprecht <maiku@pidgin.im>
parents: 26280
diff changeset
2426 }
111754ffd39b Implement *_remove_output_window and *_remove_output_windows.
Michael Ruprecht <maiku@pidgin.im>
parents: 26280
diff changeset
2427 }
111754ffd39b Implement *_remove_output_window and *_remove_output_windows.
Michael Ruprecht <maiku@pidgin.im>
parents: 26280
diff changeset
2428
26323
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2429 GstElement *
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2430 purple_media_get_tee(PurpleMedia *media,
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2431 const gchar *session_id, const gchar *participant)
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2432 {
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2433 g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2434
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2435 if (session_id != NULL && participant == NULL) {
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2436 PurpleMediaSession *session =
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2437 purple_media_get_session(media, session_id);
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2438 return (session != NULL) ? session->tee : NULL;
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2439 } else if (session_id != NULL && participant != NULL) {
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2440 PurpleMediaStream *stream =
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2441 purple_media_get_stream(media,
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2442 session_id, participant);
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2443 return (stream != NULL) ? stream->tee : NULL;
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2444 }
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2445 g_return_val_if_reached(NULL);
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2446 }
cf93de98325c Only create output windows once there's data to be output.
Michael Ruprecht <maiku@pidgin.im>
parents: 26321
diff changeset
2447
23704
9b88c9b23aed Use USE_VV instead of USE_FARSIGHT.
Michael Ruprecht <maiku@pidgin.im>
parents: 23701
diff changeset
2448 #endif /* USE_VV */

mercurial