Mercurial > pidgin.yaz
annotate libpurple/mediamanager.c @ 25728:c48f5c9600c3
Fixed a ton of memory leaks.
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Mon, 18 Aug 2008 06:25:38 +0000 |
parents | f10e0ac24595 |
children | 0baeafee93be |
rev | line source |
---|---|
25546 | 1 /** |
25552 | 2 * @file mediamanager.c Media Manager API |
25546 | 3 * @ingroup core |
25715
b8a73b6dc0a4
* Added documentation to media.h and mediamanager.h
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25706
diff
changeset
|
4 */ |
b8a73b6dc0a4
* Added documentation to media.h and mediamanager.h
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25706
diff
changeset
|
5 |
b8a73b6dc0a4
* Added documentation to media.h and mediamanager.h
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25706
diff
changeset
|
6 /* purple |
25546 | 7 * |
8 * Purple is the legal property of its developers, whose names are too numerous | |
9 * to list here. Please refer to the COPYRIGHT file distributed with this | |
10 * source distribution. | |
11 * | |
12 * This program is free software; you can redistribute it and/or modify | |
13 * it under the terms of the GNU General Public License as published by | |
14 * the Free Software Foundation; either version 2 of the License, or | |
15 * (at your option) any later version. | |
16 * | |
17 * This program is distributed in the hope that it will be useful, | |
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 * GNU General Public License for more details. | |
21 * | |
22 * You should have received a copy of the GNU General Public License | |
23 * along with this program; if not, write to the Free Software | |
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
25 */ | |
26 | |
25552 | 27 #include "internal.h" |
28 | |
25546 | 29 #include "connection.h" |
25723
1d9a2296d5d2
Stop additional media sessions within a single conversation for grouped contacts.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25715
diff
changeset
|
30 #include "marshallers.h" |
25546 | 31 #include "mediamanager.h" |
32 #include "media.h" | |
33 | |
25654
cbe97caec684
Use USE_VV instead of USE_FARSIGHT.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25651
diff
changeset
|
34 #ifdef USE_VV |
25546 | 35 |
25647
e1c8ec1259de
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25560
diff
changeset
|
36 #include <gst/farsight/fs-conference-iface.h> |
25546 | 37 |
38 struct _PurpleMediaManagerPrivate | |
39 { | |
40 GList *medias; | |
41 }; | |
42 | |
43 #define PURPLE_MEDIA_MANAGER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_MEDIA_MANAGER, PurpleMediaManagerPrivate)) | |
44 | |
45 static void purple_media_manager_class_init (PurpleMediaManagerClass *klass); | |
46 static void purple_media_manager_init (PurpleMediaManager *media); | |
47 static void purple_media_manager_finalize (GObject *object); | |
48 | |
49 static GObjectClass *parent_class = NULL; | |
50 | |
51 | |
52 | |
53 enum { | |
25548
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
25547
diff
changeset
|
54 INIT_MEDIA, |
25546 | 55 LAST_SIGNAL |
56 }; | |
57 static guint purple_media_manager_signals[LAST_SIGNAL] = {0}; | |
58 | |
59 enum { | |
60 PROP_0, | |
61 PROP_FARSIGHT_SESSION, | |
62 PROP_NAME, | |
63 PROP_CONNECTION, | |
64 PROP_MIC_ELEMENT, | |
65 PROP_SPEAKER_ELEMENT, | |
66 }; | |
67 | |
68 GType | |
69 purple_media_manager_get_type() | |
70 { | |
71 static GType type = 0; | |
72 | |
73 if (type == 0) { | |
74 static const GTypeInfo info = { | |
75 sizeof(PurpleMediaManagerClass), | |
76 NULL, | |
77 NULL, | |
78 (GClassInitFunc) purple_media_manager_class_init, | |
79 NULL, | |
80 NULL, | |
81 sizeof(PurpleMediaManager), | |
82 0, | |
25560
750d700098c1
Fix the prplinfo structs and get rid of some compile warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25552
diff
changeset
|
83 (GInstanceInitFunc) purple_media_manager_init, |
750d700098c1
Fix the prplinfo structs and get rid of some compile warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25552
diff
changeset
|
84 NULL |
25546 | 85 }; |
86 type = g_type_register_static(G_TYPE_OBJECT, "PurpleMediaManager", &info, 0); | |
87 } | |
88 return type; | |
89 } | |
90 | |
91 | |
92 static void | |
93 purple_media_manager_class_init (PurpleMediaManagerClass *klass) | |
94 { | |
95 GObjectClass *gobject_class = (GObjectClass*)klass; | |
96 parent_class = g_type_class_peek_parent(klass); | |
97 | |
98 gobject_class->finalize = purple_media_manager_finalize; | |
99 | |
25548
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
25547
diff
changeset
|
100 purple_media_manager_signals[INIT_MEDIA] = g_signal_new ("init-media", |
25546 | 101 G_TYPE_FROM_CLASS (klass), |
102 G_SIGNAL_RUN_LAST, | |
103 0, NULL, NULL, | |
25723
1d9a2296d5d2
Stop additional media sessions within a single conversation for grouped contacts.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25715
diff
changeset
|
104 purple_smarshal_BOOLEAN__OBJECT, |
1d9a2296d5d2
Stop additional media sessions within a single conversation for grouped contacts.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25715
diff
changeset
|
105 G_TYPE_BOOLEAN, 1, PURPLE_TYPE_MEDIA); |
25547 | 106 g_type_class_add_private(klass, sizeof(PurpleMediaManagerPrivate)); |
25546 | 107 } |
108 | |
109 static void | |
110 purple_media_manager_init (PurpleMediaManager *media) | |
111 { | |
112 media->priv = PURPLE_MEDIA_MANAGER_GET_PRIVATE(media); | |
25547 | 113 media->priv->medias = NULL; |
25546 | 114 } |
115 | |
116 static void | |
117 purple_media_manager_finalize (GObject *media) | |
118 { | |
25727
f10e0ac24595
* Added input/output volume preferences for voice conversations.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25723
diff
changeset
|
119 PurpleMediaManagerPrivate *priv = PURPLE_MEDIA_MANAGER_GET_PRIVATE(media); |
f10e0ac24595
* Added input/output volume preferences for voice conversations.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25723
diff
changeset
|
120 for (; priv->medias; priv->medias = |
f10e0ac24595
* Added input/output volume preferences for voice conversations.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25723
diff
changeset
|
121 g_list_delete_link(priv->medias, priv->medias)) { |
f10e0ac24595
* Added input/output volume preferences for voice conversations.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25723
diff
changeset
|
122 g_object_unref(priv->medias->data); |
f10e0ac24595
* Added input/output volume preferences for voice conversations.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25723
diff
changeset
|
123 } |
25546 | 124 parent_class->finalize(media); |
125 } | |
126 | |
127 PurpleMediaManager * | |
128 purple_media_manager_get() | |
129 { | |
130 static PurpleMediaManager *manager = NULL; | |
131 | |
132 if (manager == NULL) | |
133 manager = PURPLE_MEDIA_MANAGER(g_object_new(purple_media_manager_get_type(), NULL)); | |
134 return manager; | |
135 } | |
136 | |
25647
e1c8ec1259de
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25560
diff
changeset
|
137 PurpleMedia * |
e1c8ec1259de
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25560
diff
changeset
|
138 purple_media_manager_create_media(PurpleMediaManager *manager, |
25546 | 139 PurpleConnection *gc, |
25647
e1c8ec1259de
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25560
diff
changeset
|
140 const char *conference_type, |
e1c8ec1259de
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25560
diff
changeset
|
141 const char *remote_user) |
25546 | 142 { |
25651
43b3b9ff6028
Added better Farsight error handling. Fixes several crash bugs related
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25647
diff
changeset
|
143 PurpleMedia *media; |
25647
e1c8ec1259de
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25560
diff
changeset
|
144 FsConference *conference = FS_CONFERENCE(gst_element_factory_make(conference_type, NULL)); |
25706
1c68f78414b7
Set the media pipeline to PLAYING immediately after initialization
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25654
diff
changeset
|
145 GstStateChangeReturn ret; |
25723
1d9a2296d5d2
Stop additional media sessions within a single conversation for grouped contacts.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25715
diff
changeset
|
146 gboolean signal_ret; |
25651
43b3b9ff6028
Added better Farsight error handling. Fixes several crash bugs related
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25647
diff
changeset
|
147 |
43b3b9ff6028
Added better Farsight error handling. Fixes several crash bugs related
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25647
diff
changeset
|
148 media = PURPLE_MEDIA(g_object_new(purple_media_get_type(), |
43b3b9ff6028
Added better Farsight error handling. Fixes several crash bugs related
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25647
diff
changeset
|
149 "screenname", remote_user, |
43b3b9ff6028
Added better Farsight error handling. Fixes several crash bugs related
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25647
diff
changeset
|
150 "connection", gc, |
43b3b9ff6028
Added better Farsight error handling. Fixes several crash bugs related
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25647
diff
changeset
|
151 "farsight-conference", conference, |
43b3b9ff6028
Added better Farsight error handling. Fixes several crash bugs related
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25647
diff
changeset
|
152 NULL)); |
25706
1c68f78414b7
Set the media pipeline to PLAYING immediately after initialization
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25654
diff
changeset
|
153 |
1c68f78414b7
Set the media pipeline to PLAYING immediately after initialization
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25654
diff
changeset
|
154 ret = gst_element_set_state(purple_media_get_pipeline(media), GST_STATE_PLAYING); |
1c68f78414b7
Set the media pipeline to PLAYING immediately after initialization
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25654
diff
changeset
|
155 |
1c68f78414b7
Set the media pipeline to PLAYING immediately after initialization
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25654
diff
changeset
|
156 if (ret == GST_STATE_CHANGE_FAILURE) { |
1c68f78414b7
Set the media pipeline to PLAYING immediately after initialization
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25654
diff
changeset
|
157 purple_conv_present_error(remote_user, |
1c68f78414b7
Set the media pipeline to PLAYING immediately after initialization
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25654
diff
changeset
|
158 purple_connection_get_account(gc), |
1c68f78414b7
Set the media pipeline to PLAYING immediately after initialization
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25654
diff
changeset
|
159 _("Error creating conference.")); |
1c68f78414b7
Set the media pipeline to PLAYING immediately after initialization
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25654
diff
changeset
|
160 g_object_unref(media); |
1c68f78414b7
Set the media pipeline to PLAYING immediately after initialization
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25654
diff
changeset
|
161 return NULL; |
1c68f78414b7
Set the media pipeline to PLAYING immediately after initialization
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25654
diff
changeset
|
162 } |
1c68f78414b7
Set the media pipeline to PLAYING immediately after initialization
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25654
diff
changeset
|
163 |
25723
1d9a2296d5d2
Stop additional media sessions within a single conversation for grouped contacts.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25715
diff
changeset
|
164 g_signal_emit(manager, purple_media_manager_signals[INIT_MEDIA], 0, |
1d9a2296d5d2
Stop additional media sessions within a single conversation for grouped contacts.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25715
diff
changeset
|
165 media, &signal_ret); |
1d9a2296d5d2
Stop additional media sessions within a single conversation for grouped contacts.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25715
diff
changeset
|
166 |
1d9a2296d5d2
Stop additional media sessions within a single conversation for grouped contacts.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25715
diff
changeset
|
167 if (signal_ret == FALSE) { |
1d9a2296d5d2
Stop additional media sessions within a single conversation for grouped contacts.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25715
diff
changeset
|
168 g_object_unref(media); |
1d9a2296d5d2
Stop additional media sessions within a single conversation for grouped contacts.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25715
diff
changeset
|
169 return NULL; |
1d9a2296d5d2
Stop additional media sessions within a single conversation for grouped contacts.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25715
diff
changeset
|
170 } |
1d9a2296d5d2
Stop additional media sessions within a single conversation for grouped contacts.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25715
diff
changeset
|
171 |
25546 | 172 manager->priv->medias = g_list_append(manager->priv->medias, media); |
173 return media; | |
174 } | |
175 | |
25727
f10e0ac24595
* Added input/output volume preferences for voice conversations.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25723
diff
changeset
|
176 GList * |
f10e0ac24595
* Added input/output volume preferences for voice conversations.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25723
diff
changeset
|
177 purple_media_manager_get_media(PurpleMediaManager *manager) |
f10e0ac24595
* Added input/output volume preferences for voice conversations.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25723
diff
changeset
|
178 { |
f10e0ac24595
* Added input/output volume preferences for voice conversations.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25723
diff
changeset
|
179 return manager->priv->medias; |
f10e0ac24595
* Added input/output volume preferences for voice conversations.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25723
diff
changeset
|
180 } |
f10e0ac24595
* Added input/output volume preferences for voice conversations.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25723
diff
changeset
|
181 |
f10e0ac24595
* Added input/output volume preferences for voice conversations.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25723
diff
changeset
|
182 void |
f10e0ac24595
* Added input/output volume preferences for voice conversations.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25723
diff
changeset
|
183 purple_media_manager_remove_media(PurpleMediaManager *manager, |
f10e0ac24595
* Added input/output volume preferences for voice conversations.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25723
diff
changeset
|
184 PurpleMedia *media) |
f10e0ac24595
* Added input/output volume preferences for voice conversations.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25723
diff
changeset
|
185 { |
f10e0ac24595
* Added input/output volume preferences for voice conversations.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25723
diff
changeset
|
186 GList *list = g_list_find(manager->priv->medias, media); |
f10e0ac24595
* Added input/output volume preferences for voice conversations.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25723
diff
changeset
|
187 if (list) |
f10e0ac24595
* Added input/output volume preferences for voice conversations.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25723
diff
changeset
|
188 manager->priv->medias = |
f10e0ac24595
* Added input/output volume preferences for voice conversations.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25723
diff
changeset
|
189 g_list_delete_link(manager->priv->medias, list); |
f10e0ac24595
* Added input/output volume preferences for voice conversations.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25723
diff
changeset
|
190 } |
f10e0ac24595
* Added input/output volume preferences for voice conversations.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25723
diff
changeset
|
191 |
25654
cbe97caec684
Use USE_VV instead of USE_FARSIGHT.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25651
diff
changeset
|
192 #endif /* USE_VV */ |