annotate libpurple/media.c @ 26190:d6e23439b77c

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