Mercurial > pidgin.yaz
annotate pidgin/gtkmedia.c @ 25643:befeece4dd48
Change a few things:
* call purple_media_wait to notify that we are waiting on a response from the
remote end
* fix the /call command in finch
* keep track of the PidginMedia for a PidginConversation
* fix the two-widget bug in pidgin.
We probably should have a way to get the PidginMedia from a PurpleMedia. Should
we use _set/_get_ui_data for this?
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 22 Mar 2008 09:17:34 +0000 |
parents | 92e71f6e10d4 |
children | e1c8ec1259de |
rev | line source |
---|---|
25550 | 1 /** |
2 * @file media.c Account API | |
3 * @ingroup core | |
4 * | |
5 * Pidgin | |
6 * | |
7 * Pidgin is the legal property of its developers, whose names are too numerous | |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
10 * | |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
25 | |
26 #include <string.h> | |
27 #include "internal.h" | |
28 #include "connection.h" | |
29 #include "media.h" | |
30 | |
31 #include "gtkmedia.h" | |
32 | |
33 #ifdef USE_FARSIGHT | |
34 | |
35 #include <farsight/farsight.h> | |
36 | |
25643
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
37 typedef enum |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
38 { |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
39 /* Waiting for response */ |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
40 PIDGIN_MEDIA_WAITING = 1, |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
41 /* Got request */ |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
42 PIDGIN_MEDIA_REQUESTED, |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
43 /* Accepted call */ |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
44 PIDGIN_MEDIA_ACCEPTED, |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
45 /* Rejected call */ |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
46 PIDGIN_MEDIA_REJECTED, |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
47 } PidginMediaState; |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
48 |
25550 | 49 struct _PidginMediaPrivate |
50 { | |
51 PurpleMedia *media; | |
52 GstElement *send_level; | |
53 GstElement *recv_level; | |
54 | |
25637
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
55 GtkWidget *calling; |
25550 | 56 GtkWidget *accept; |
57 GtkWidget *reject; | |
58 GtkWidget *hangup; | |
25637
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
59 |
25550 | 60 GtkWidget *send_progress; |
61 GtkWidget *recv_progress; | |
25637
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
62 |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
63 PidginMediaState state; |
25550 | 64 }; |
65 | |
66 #define PIDGIN_MEDIA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), PIDGIN_TYPE_MEDIA, PidginMediaPrivate)) | |
67 | |
68 static void pidgin_media_class_init (PidginMediaClass *klass); | |
69 static void pidgin_media_init (PidginMedia *media); | |
70 static void pidgin_media_finalize (GObject *object); | |
71 static void pidgin_media_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); | |
72 static void pidgin_media_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); | |
25643
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
73 static void pidgin_media_set_state(PidginMedia *gtkmedia, PidginMediaState state); |
25550 | 74 |
75 static GtkHBoxClass *parent_class = NULL; | |
76 | |
77 | |
78 | |
79 enum { | |
80 MESSAGE, | |
81 LAST_SIGNAL | |
82 }; | |
83 static guint pidgin_media_signals[LAST_SIGNAL] = {0}; | |
84 | |
85 enum { | |
86 PROP_0, | |
87 PROP_MEDIA, | |
88 PROP_SEND_LEVEL, | |
89 PROP_RECV_LEVEL | |
90 }; | |
91 | |
92 GType | |
25634
741a702033e0
Show a message when the remote end terminates a session.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25561
diff
changeset
|
93 pidgin_media_get_type(void) |
25550 | 94 { |
95 static GType type = 0; | |
96 | |
97 if (type == 0) { | |
98 static const GTypeInfo info = { | |
99 sizeof(PidginMediaClass), | |
100 NULL, | |
101 NULL, | |
102 (GClassInitFunc) pidgin_media_class_init, | |
103 NULL, | |
104 NULL, | |
105 sizeof(PidginMedia), | |
106 0, | |
25561
1ec6a26cfefc
Remove a compile error, and a few warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25550
diff
changeset
|
107 (GInstanceInitFunc) pidgin_media_init, |
1ec6a26cfefc
Remove a compile error, and a few warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25550
diff
changeset
|
108 NULL |
25550 | 109 }; |
110 type = g_type_register_static(GTK_TYPE_HBOX, "PidginMedia", &info, 0); | |
111 } | |
112 return type; | |
113 } | |
114 | |
115 | |
116 static void | |
117 pidgin_media_class_init (PidginMediaClass *klass) | |
118 { | |
119 GObjectClass *gobject_class = (GObjectClass*)klass; | |
120 GtkContainerClass *container_class = (GtkContainerClass*)klass; | |
121 parent_class = g_type_class_peek_parent(klass); | |
25637
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
122 |
25550 | 123 gobject_class->finalize = pidgin_media_finalize; |
124 gobject_class->set_property = pidgin_media_set_property; | |
125 gobject_class->get_property = pidgin_media_get_property; | |
126 | |
127 g_object_class_install_property(gobject_class, PROP_MEDIA, | |
128 g_param_spec_object("media", | |
129 "PurpleMedia", | |
130 "The PurpleMedia associated with this media.", | |
131 PURPLE_TYPE_MEDIA, | |
132 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); | |
133 g_object_class_install_property(gobject_class, PROP_SEND_LEVEL, | |
134 g_param_spec_object("send-level", | |
135 "Send level", | |
136 "The GstElement of this media's send 'level'", | |
137 GST_TYPE_ELEMENT, | |
25637
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
138 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); |
25550 | 139 g_object_class_install_property(gobject_class, PROP_RECV_LEVEL, |
140 g_param_spec_object("recv-level", | |
141 "Receive level", | |
142 "The GstElement of this media's recv 'level'", | |
143 GST_TYPE_ELEMENT, | |
144 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); | |
145 | |
146 pidgin_media_signals[MESSAGE] = g_signal_new("message", G_TYPE_FROM_CLASS(klass), | |
147 G_SIGNAL_RUN_LAST, 0, NULL, NULL, | |
148 g_cclosure_marshal_VOID__STRING, | |
149 G_TYPE_NONE, 1, G_TYPE_STRING); | |
150 | |
151 g_type_class_add_private(klass, sizeof(PidginMediaPrivate)); | |
152 } | |
153 | |
154 | |
155 static void | |
156 pidgin_media_init (PidginMedia *media) | |
157 { | |
158 media->priv = PIDGIN_MEDIA_GET_PRIVATE(media); | |
25637
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
159 media->priv->calling = gtk_label_new_with_mnemonic("Calling..."); |
25550 | 160 media->priv->hangup = gtk_button_new_with_label("Hangup"); |
161 media->priv->accept = gtk_button_new_with_label("Accept"); | |
162 media->priv->reject = gtk_button_new_with_label("Reject"); | |
25637
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
163 media->priv->send_progress = gtk_progress_bar_new(); |
25550 | 164 media->priv->recv_progress = gtk_progress_bar_new(); |
165 | |
166 gtk_widget_set_size_request(media->priv->send_progress, 70, 5); | |
167 gtk_widget_set_size_request(media->priv->recv_progress, 70, 5); | |
25637
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
168 |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
169 gtk_box_pack_start(GTK_BOX(media), media->priv->calling, FALSE, FALSE, 0); |
25550 | 170 gtk_box_pack_start(GTK_BOX(media), media->priv->hangup, FALSE, FALSE, 0); |
171 gtk_box_pack_start(GTK_BOX(media), media->priv->accept, FALSE, FALSE, 0); | |
172 gtk_box_pack_start(GTK_BOX(media), media->priv->reject, FALSE, FALSE, 0); | |
173 | |
174 gtk_box_pack_start(GTK_BOX(media), media->priv->send_progress, FALSE, FALSE, 6); | |
175 gtk_box_pack_start(GTK_BOX(media), media->priv->recv_progress, FALSE, FALSE, 6); | |
176 | |
177 gtk_widget_show(media->priv->send_progress); | |
178 gtk_widget_show(media->priv->recv_progress); | |
25637
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
179 |
25643
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
180 gtk_widget_show_all(media->priv->accept); |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
181 gtk_widget_show_all(media->priv->reject); |
25550 | 182 } |
183 | |
184 static void | |
185 pidgin_media_finalize (GObject *media) | |
186 { | |
25643
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
187 PidginMedia *gtkmedia = PIDGIN_MEDIA(media); |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
188 if (gtkmedia->priv->media) |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
189 g_object_unref(gtkmedia->priv->media); |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
190 if (gtkmedia->priv->send_level) |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
191 gst_object_unref(gtkmedia->priv->send_level); |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
192 if (gtkmedia->priv->recv_level) |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
193 gst_object_unref(gtkmedia->priv->recv_level); |
25550 | 194 } |
195 | |
196 static void | |
197 pidgin_media_emit_message(PidginMedia *gtkmedia, const char *msg) | |
198 { | |
199 g_signal_emit(gtkmedia, pidgin_media_signals[MESSAGE], 0, msg); | |
200 } | |
25634
741a702033e0
Show a message when the remote end terminates a session.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25561
diff
changeset
|
201 |
25550 | 202 static gboolean |
203 level_message_cb(GstBus *bus, GstMessage *message, PidginMedia *gtkmedia) | |
204 { | |
205 const GstStructure *s; | |
206 const gchar *name; | |
207 | |
208 int channels; | |
209 gdouble rms_db, peak_db, decay_db; | |
210 gdouble rms; | |
211 const GValue *list; | |
212 const GValue *value; | |
25634
741a702033e0
Show a message when the remote end terminates a session.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25561
diff
changeset
|
213 |
741a702033e0
Show a message when the remote end terminates a session.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25561
diff
changeset
|
214 GstElement *src = GST_ELEMENT(message); |
25550 | 215 |
216 if (message->type != GST_MESSAGE_ELEMENT) | |
217 return TRUE; | |
218 | |
219 s = gst_message_get_structure(message); | |
220 name = gst_structure_get_name(s); | |
221 | |
222 if (strcmp(name, "level")) | |
223 return TRUE; | |
224 | |
225 list = gst_structure_get_value(s, "rms"); | |
226 | |
227 /* Only bother with the first channel. */ | |
228 value = gst_value_list_get_value(list, 0); | |
229 rms_db = g_value_get_double(value); | |
230 | |
231 if (!strcmp(gst_element_get_name(src), "sendlevel")) | |
25561
1ec6a26cfefc
Remove a compile error, and a few warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25550
diff
changeset
|
232 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(gtkmedia->priv->send_progress), pow(10, rms_db / 20) * 5); |
25550 | 233 else |
25561
1ec6a26cfefc
Remove a compile error, and a few warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25550
diff
changeset
|
234 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(gtkmedia->priv->recv_progress), pow(10, rms_db / 20) * 5); |
25550 | 235 |
236 return TRUE; | |
237 } | |
238 | |
239 static void | |
240 pidgin_media_ready_cb(PurpleMedia *media, PidginMedia *gtkmedia) | |
241 { | |
242 GstElement *element = purple_media_get_audio_pipeline(media); | |
25561
1ec6a26cfefc
Remove a compile error, and a few warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25550
diff
changeset
|
243 gst_bus_add_signal_watch(GST_BUS(gst_pipeline_get_bus(GST_PIPELINE(element)))); |
1ec6a26cfefc
Remove a compile error, and a few warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25550
diff
changeset
|
244 g_signal_connect(G_OBJECT(gst_pipeline_get_bus(GST_PIPELINE(element))), "message", G_CALLBACK(level_message_cb), gtkmedia); |
1ec6a26cfefc
Remove a compile error, and a few warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25550
diff
changeset
|
245 printf("\n\nbus: %p\n", gst_pipeline_get_bus(GST_PIPELINE(element))); |
25550 | 246 } |
247 | |
25643
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
248 static void |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
249 pidgin_media_wait_cb(PurpleMedia *media, PidginMedia *gtkmedia) |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
250 { |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
251 pidgin_media_set_state(gtkmedia, PIDGIN_MEDIA_WAITING); |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
252 } |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
253 |
25637
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
254 /* maybe we should have different callbacks for when we received the accept |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
255 and we accepted ourselves */ |
25550 | 256 static void |
257 pidgin_media_accept_cb(PurpleMedia *media, PidginMedia *gtkmedia) | |
258 { | |
259 pidgin_media_emit_message(gtkmedia, _("Call in progress.")); | |
25637
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
260 pidgin_media_set_state(gtkmedia, PIDGIN_MEDIA_ACCEPTED); |
25550 | 261 } |
262 | |
263 static void | |
264 pidgin_media_hangup_cb(PurpleMedia *media, PidginMedia *gtkmedia) | |
265 { | |
266 pidgin_media_emit_message(gtkmedia, _("You have ended the call.")); | |
25561
1ec6a26cfefc
Remove a compile error, and a few warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25550
diff
changeset
|
267 gtk_widget_destroy(GTK_WIDGET(gtkmedia)); |
25550 | 268 } |
269 | |
270 static void | |
25634
741a702033e0
Show a message when the remote end terminates a session.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25561
diff
changeset
|
271 pidgin_media_got_hangup_cb(PurpleMedia *media, PidginMedia *gtkmedia) |
741a702033e0
Show a message when the remote end terminates a session.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25561
diff
changeset
|
272 { |
741a702033e0
Show a message when the remote end terminates a session.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25561
diff
changeset
|
273 pidgin_media_emit_message(gtkmedia, _("The call has been terminated.")); |
741a702033e0
Show a message when the remote end terminates a session.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25561
diff
changeset
|
274 gtk_widget_destroy(GTK_WIDGET(gtkmedia)); |
741a702033e0
Show a message when the remote end terminates a session.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25561
diff
changeset
|
275 } |
741a702033e0
Show a message when the remote end terminates a session.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25561
diff
changeset
|
276 |
741a702033e0
Show a message when the remote end terminates a session.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25561
diff
changeset
|
277 static void |
25550 | 278 pidgin_media_reject_cb(PurpleMedia *media, PidginMedia *gtkmedia) |
279 { | |
280 pidgin_media_emit_message(gtkmedia, _("You have rejected the call.")); | |
25561
1ec6a26cfefc
Remove a compile error, and a few warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25550
diff
changeset
|
281 gtk_widget_destroy(GTK_WIDGET(gtkmedia)); |
25550 | 282 } |
283 | |
284 static void | |
285 pidgin_media_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) | |
286 { | |
287 PidginMedia *media; | |
288 g_return_if_fail(PIDGIN_IS_MEDIA(object)); | |
25634
741a702033e0
Show a message when the remote end terminates a session.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25561
diff
changeset
|
289 |
25550 | 290 media = PIDGIN_MEDIA(object); |
291 switch (prop_id) { | |
292 case PROP_MEDIA: | |
293 if (media->priv->media) | |
294 g_object_unref(media->priv->media); | |
295 media->priv->media = g_value_get_object(value); | |
296 g_object_ref(media->priv->media); | |
297 g_signal_connect_swapped(G_OBJECT(media->priv->accept), "clicked", | |
298 G_CALLBACK(purple_media_accept), media->priv->media); | |
299 g_signal_connect_swapped(G_OBJECT(media->priv->reject), "clicked", | |
300 G_CALLBACK(purple_media_reject), media->priv->media); | |
301 g_signal_connect_swapped(G_OBJECT(media->priv->hangup), "clicked", | |
302 G_CALLBACK(purple_media_hangup), media->priv->media); | |
303 | |
304 g_signal_connect(G_OBJECT(media->priv->media), "accepted", | |
305 G_CALLBACK(pidgin_media_accept_cb), media); | |
306 g_signal_connect(G_OBJECT(media->priv->media) ,"ready", | |
307 G_CALLBACK(pidgin_media_ready_cb), media); | |
25643
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
308 g_signal_connect(G_OBJECT(media->priv->media) ,"wait", |
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
309 G_CALLBACK(pidgin_media_wait_cb), media); |
25550 | 310 g_signal_connect(G_OBJECT(media->priv->media), "hangup", |
311 G_CALLBACK(pidgin_media_hangup_cb), media); | |
312 g_signal_connect(G_OBJECT(media->priv->media), "reject", | |
313 G_CALLBACK(pidgin_media_reject_cb), media); | |
25634
741a702033e0
Show a message when the remote end terminates a session.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25561
diff
changeset
|
314 g_signal_connect(G_OBJECT(media->priv->media), "got-hangup", |
741a702033e0
Show a message when the remote end terminates a session.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25561
diff
changeset
|
315 G_CALLBACK(pidgin_media_got_hangup_cb), media); |
25637
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
316 g_signal_connect(G_OBJECT(media->priv->media), "got-accept", |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
317 G_CALLBACK(pidgin_media_accept_cb), media); |
25550 | 318 break; |
319 case PROP_SEND_LEVEL: | |
320 if (media->priv->send_level) | |
321 gst_object_unref(media->priv->send_level); | |
322 media->priv->send_level = g_value_get_object(value); | |
323 g_object_ref(media->priv->send_level); | |
324 break; | |
325 case PROP_RECV_LEVEL: | |
326 if (media->priv->recv_level) | |
327 gst_object_unref(media->priv->recv_level); | |
328 media->priv->recv_level = g_value_get_object(value); | |
329 g_object_ref(media->priv->recv_level); | |
330 break; | |
25637
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
331 default: |
25550 | 332 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
333 break; | |
334 } | |
335 } | |
336 | |
337 static void | |
338 pidgin_media_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) | |
339 { | |
340 PidginMedia *media; | |
341 g_return_if_fail(PIDGIN_IS_MEDIA(object)); | |
25637
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
342 |
25550 | 343 media = PIDGIN_MEDIA(object); |
25637
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
344 |
25550 | 345 switch (prop_id) { |
346 case PROP_MEDIA: | |
347 g_value_set_object(value, media->priv->media); | |
348 break; | |
349 case PROP_SEND_LEVEL: | |
350 g_value_set_object(value, media->priv->send_level); | |
351 break; | |
352 case PROP_RECV_LEVEL: | |
353 g_value_set_object(value, media->priv->recv_level); | |
354 break; | |
25637
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
355 default: |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
356 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
25550 | 357 break; |
358 } | |
359 } | |
360 | |
361 GtkWidget * | |
25643
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
362 pidgin_media_new(PurpleMedia *media, GstElement *sendlevel, GstElement *recvlevel) |
25637
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
363 { |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
364 PidginMedia *gtkmedia = g_object_new(pidgin_media_get_type(), "media", media, |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
365 "send-level", sendlevel, |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
366 "recv-level", recvlevel, NULL); |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
367 return GTK_WIDGET(gtkmedia); |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
368 } |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
369 |
25643
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
370 static void |
25637
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
371 pidgin_media_set_state(PidginMedia *gtkmedia, PidginMediaState state) |
25550 | 372 { |
25637
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
373 gtkmedia->priv->state = state; |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
374 switch (state) { |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
375 case PIDGIN_MEDIA_WAITING: |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
376 gtk_widget_show(gtkmedia->priv->calling); |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
377 gtk_widget_hide(gtkmedia->priv->accept); |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
378 gtk_widget_hide(gtkmedia->priv->reject); |
25643
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
379 gtk_widget_show(gtkmedia->priv->hangup); |
25637
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
380 break; |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
381 case PIDGIN_MEDIA_REQUESTED: |
25643
befeece4dd48
Change a few things:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25637
diff
changeset
|
382 gtk_widget_hide(gtkmedia->priv->calling); |
25637
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
383 gtk_widget_show(gtkmedia->priv->accept); |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
384 gtk_widget_show(gtkmedia->priv->reject); |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
385 gtk_widget_hide(gtkmedia->priv->hangup); |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
386 break; |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
387 case PIDGIN_MEDIA_ACCEPTED: |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
388 gtk_widget_show(gtkmedia->priv->hangup); |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
389 gtk_widget_hide(gtkmedia->priv->calling); |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
390 gtk_widget_hide(gtkmedia->priv->accept); |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
391 gtk_widget_hide(gtkmedia->priv->reject); |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
392 break; |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
393 default: |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
394 break; |
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25634
diff
changeset
|
395 } |
25550 | 396 } |
397 | |
398 #endif /* USE_FARSIGHT */ |