2 * empathy-call-window.c - Source for EmpathyCallWindow
3 * Copyright (C) 2008-2009 Collabora Ltd.
4 * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 #include <gdk/gdkkeysyms.h>
30 #include <glib/gi18n.h>
32 #include <telepathy-glib/util.h>
33 #include <telepathy-farsight/channel.h>
34 #include <telepathy-glib/util.h>
36 #include <gst/farsight/fs-element-added-notifier.h>
38 #include <libempathy/empathy-tp-contact-factory.h>
39 #include <libempathy/empathy-call-factory.h>
40 #include <libempathy/empathy-utils.h>
41 #include <libempathy-gtk/empathy-avatar-image.h>
42 #include <libempathy-gtk/empathy-video-widget.h>
43 #include <libempathy-gtk/empathy-audio-src.h>
44 #include <libempathy-gtk/empathy-audio-sink.h>
45 #include <libempathy-gtk/empathy-video-src.h>
46 #include <libempathy-gtk/empathy-ui-utils.h>
47 #include <libempathy-gtk/empathy-sound.h>
48 #include <libempathy-gtk/empathy-geometry.h>
49 #include <libempathy-gtk/empathy-images.h>
51 #define DEBUG_FLAG EMPATHY_DEBUG_VOIP
52 #include <libempathy/empathy-debug.h>
54 #include "empathy-call-window.h"
55 #include "empathy-call-window-fullscreen.h"
56 #include "empathy-sidebar.h"
58 #define BUTTON_ID "empathy-call-dtmf-button-id"
60 #define CONTENT_HBOX_BORDER_WIDTH 6
61 #define CONTENT_HBOX_SPACING 3
62 #define CONTENT_HBOX_CHILDREN_PACKING_PADDING 3
64 #define SELF_VIDEO_SECTION_WIDTH 160
65 #define SELF_VIDEO_SECTION_HEIGTH 120
67 /* The avatar's default width and height are set to the same value because we
68 want a square icon. */
69 #define REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH EMPATHY_VIDEO_WIDGET_DEFAULT_HEIGHT
70 #define REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT \
71 EMPATHY_VIDEO_WIDGET_DEFAULT_HEIGHT
73 /* If an video input error occurs, the error message will start with "v4l" */
74 #define VIDEO_INPUT_ERROR_PREFIX "v4l"
76 /* The time interval in milliseconds between 2 outgoing rings */
77 #define MS_BETWEEN_RING 500
79 G_DEFINE_TYPE(EmpathyCallWindow, empathy_call_window, GTK_TYPE_WINDOW)
88 static guint signals[LAST_SIGNAL] = {0};
92 PROP_CALL_HANDLER = 1,
103 CAMERA_STATE_OFF = 0,
104 CAMERA_STATE_PREVIEW,
108 /* private structure */
109 typedef struct _EmpathyCallWindowPriv EmpathyCallWindowPriv;
111 struct _EmpathyCallWindowPriv
113 gboolean dispose_has_run;
114 EmpathyCallHandler *handler;
115 EmpathyContact *contact;
120 GtkUIManager *ui_manager;
121 GtkWidget *errors_vbox;
122 /* widget displays the video received from the remote user. This widget is
123 * alive only during call. */
124 GtkWidget *video_output;
125 GtkWidget *video_preview;
126 GtkWidget *remote_user_avatar_widget;
127 GtkWidget *self_user_avatar_widget;
129 GtkWidget *sidebar_button;
130 GtkWidget *statusbar;
131 GtkWidget *volume_button;
132 GtkWidget *redial_button;
133 GtkWidget *mic_button;
137 GtkAction *menu_fullscreen;
138 GtkAction *action_camera;
139 GtkAction *action_camera_preview;
140 GtkWidget *tool_button_camera_off;
141 GtkWidget *tool_button_camera_preview;
142 GtkWidget *tool_button_camera_on;
144 /* The frames and boxes that contain self and remote avatar and video
145 input/output. When we redial, we destroy and re-create the boxes */
146 GtkWidget *remote_user_output_frame;
147 GtkWidget *self_user_output_frame;
148 GtkWidget *remote_user_output_hbox;
149 GtkWidget *self_user_output_hbox;
151 /* We keep a reference on the hbox which contains the main content so we can
152 easilly repack everything when toggling fullscreen */
153 GtkWidget *content_hbox;
155 /* This vbox is contained in the content_hbox and it contains the
156 self_user_output_frame and the sidebar button. When toggling fullscreen,
157 it needs to be repacked. We keep a reference on it for easier access. */
160 gulong video_output_motion_handler_id;
161 guint bus_message_source_id;
164 GtkWidget *volume_scale;
165 GtkWidget *volume_progress_bar;
166 GtkAdjustment *audio_input_adj;
168 GtkWidget *dtmf_panel;
171 GtkWidget *details_vbox;
172 GtkWidget *vcodec_encoding_label;
173 GtkWidget *acodec_encoding_label;
174 GtkWidget *vcodec_decoding_label;
175 GtkWidget *acodec_decoding_label;
177 GstElement *video_input;
178 GstElement *audio_input;
179 GstElement *audio_output;
180 GstElement *pipeline;
181 GstElement *video_tee;
184 GstElement *liveadder;
186 FsElementAddedNotifier *fsnotifier;
193 GtkWidget *video_contrast;
194 GtkWidget *video_brightness;
195 GtkWidget *video_gamma;
198 gboolean call_started;
199 gboolean sending_video;
200 CameraState camera_state;
202 EmpathyCallWindowFullscreen *fullscreen;
203 gboolean is_fullscreen;
205 /* Those fields represent the state of the window before it actually was in
207 gboolean sidebar_was_visible_before_fs;
208 gint original_width_before_fs;
209 gint original_height_before_fs;
211 /* TRUE if the call should be started when the pipeline is playing */
212 gboolean start_call_when_playing;
213 /* TRUE if we requested to set the pipeline in the playing state */
214 gboolean pipeline_playing;
217 #define GET_PRIV(o) \
218 (G_TYPE_INSTANCE_GET_PRIVATE ((o), EMPATHY_TYPE_CALL_WINDOW, \
219 EmpathyCallWindowPriv))
221 static void empathy_call_window_realized_cb (GtkWidget *widget,
222 EmpathyCallWindow *window);
224 static gboolean empathy_call_window_delete_cb (GtkWidget *widget,
225 GdkEvent *event, EmpathyCallWindow *window);
227 static gboolean empathy_call_window_state_event_cb (GtkWidget *widget,
228 GdkEventWindowState *event, EmpathyCallWindow *window);
230 static void empathy_call_window_sidebar_toggled_cb (GtkToggleButton *toggle,
231 EmpathyCallWindow *window);
233 static void empathy_call_window_set_send_video (EmpathyCallWindow *window,
236 static void empathy_call_window_mic_toggled_cb (
237 GtkToggleToolButton *toggle, EmpathyCallWindow *window);
239 static void empathy_call_window_sidebar_hidden_cb (EmpathySidebar *sidebar,
240 EmpathyCallWindow *window);
242 static void empathy_call_window_sidebar_shown_cb (EmpathySidebar *sidebar,
243 EmpathyCallWindow *window);
245 static void empathy_call_window_hangup_cb (gpointer object,
246 EmpathyCallWindow *window);
248 static void empathy_call_window_fullscreen_cb (gpointer object,
249 EmpathyCallWindow *window);
251 static void empathy_call_window_fullscreen_toggle (EmpathyCallWindow *window);
253 static gboolean empathy_call_window_video_button_press_cb (
254 GtkWidget *video_output, GdkEventButton *event, EmpathyCallWindow *window);
256 static gboolean empathy_call_window_key_press_cb (GtkWidget *video_output,
257 GdkEventKey *event, EmpathyCallWindow *window);
259 static gboolean empathy_call_window_video_output_motion_notify (
260 GtkWidget *widget, GdkEventMotion *event, EmpathyCallWindow *window);
262 static void empathy_call_window_video_menu_popup (EmpathyCallWindow *window,
265 static void empathy_call_window_redial_cb (gpointer object,
266 EmpathyCallWindow *window);
268 static void empathy_call_window_restart_call (EmpathyCallWindow *window);
270 static void empathy_call_window_status_message (EmpathyCallWindow *window,
273 static void empathy_call_window_update_avatars_visibility (EmpathyTpCall *call,
274 EmpathyCallWindow *window);
276 static gboolean empathy_call_window_bus_message (GstBus *bus,
277 GstMessage *message, gpointer user_data);
280 empathy_call_window_volume_changed_cb (GtkScaleButton *button,
281 gdouble value, EmpathyCallWindow *window);
283 static void block_camera_control_signals (EmpathyCallWindow *self);
284 static void unblock_camera_control_signals (EmpathyCallWindow *self);
287 empathy_call_window_setup_toolbar (EmpathyCallWindow *self)
289 EmpathyCallWindowPriv *priv = GET_PRIV (self);
290 GtkToolItem *tool_item;
291 GtkWidget *camera_off_icon;
292 GdkPixbuf *pixbuf, *modded_pixbuf;
294 /* set the icon of the 'camera off' button by greying off the webcam icon */
295 pixbuf = empathy_pixbuf_from_icon_name ("camera-web",
296 GTK_ICON_SIZE_SMALL_TOOLBAR);
298 modded_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
299 gdk_pixbuf_get_width (pixbuf),
300 gdk_pixbuf_get_height (pixbuf));
302 gdk_pixbuf_saturate_and_pixelate (pixbuf, modded_pixbuf, 1.0, TRUE);
303 g_object_unref (pixbuf);
305 camera_off_icon = gtk_image_new_from_pixbuf (modded_pixbuf);
306 g_object_unref (modded_pixbuf);
307 gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (
308 priv->tool_button_camera_off), camera_off_icon);
310 /* Add an empty expanded GtkToolItem so the volume button is at the end of
312 tool_item = gtk_tool_item_new ();
313 gtk_tool_item_set_expand (tool_item, TRUE);
314 gtk_widget_show (GTK_WIDGET (tool_item));
315 gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), tool_item, -1);
317 priv->volume_button = gtk_volume_button_new ();
318 /* FIXME listen to the audiosinks signals and update the button according to
319 * that, for now starting out at 1.0 and assuming only the app changes the
321 gtk_scale_button_set_value (GTK_SCALE_BUTTON (priv->volume_button), 1.0);
322 g_signal_connect (G_OBJECT (priv->volume_button), "value-changed",
323 G_CALLBACK (empathy_call_window_volume_changed_cb), self);
325 tool_item = gtk_tool_item_new ();
326 gtk_container_add (GTK_CONTAINER (tool_item), priv->volume_button);
327 gtk_widget_show_all (GTK_WIDGET (tool_item));
328 gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), tool_item, -1);
332 dtmf_button_pressed_cb (GtkButton *button, EmpathyCallWindow *window)
334 EmpathyCallWindowPriv *priv = GET_PRIV (window);
339 g_object_get (priv->handler, "tp-call", &call, NULL);
341 button_quark = g_quark_from_static_string (BUTTON_ID);
342 event = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (button),
345 empathy_tp_call_start_tone (call, event);
347 g_object_unref (call);
351 dtmf_button_released_cb (GtkButton *button, EmpathyCallWindow *window)
353 EmpathyCallWindowPriv *priv = GET_PRIV (window);
356 g_object_get (priv->handler, "tp-call", &call, NULL);
358 empathy_tp_call_stop_tone (call);
360 g_object_unref (call);
364 empathy_call_window_create_dtmf (EmpathyCallWindow *self)
372 } dtmfbuttons[] = { { "1", TP_DTMF_EVENT_DIGIT_1 },
373 { "2", TP_DTMF_EVENT_DIGIT_2 },
374 { "3", TP_DTMF_EVENT_DIGIT_3 },
375 { "4", TP_DTMF_EVENT_DIGIT_4 },
376 { "5", TP_DTMF_EVENT_DIGIT_5 },
377 { "6", TP_DTMF_EVENT_DIGIT_6 },
378 { "7", TP_DTMF_EVENT_DIGIT_7 },
379 { "8", TP_DTMF_EVENT_DIGIT_8 },
380 { "9", TP_DTMF_EVENT_DIGIT_9 },
381 { "#", TP_DTMF_EVENT_HASH },
382 { "0", TP_DTMF_EVENT_DIGIT_0 },
383 { "*", TP_DTMF_EVENT_ASTERISK },
386 button_quark = g_quark_from_static_string (BUTTON_ID);
388 table = gtk_table_new (4, 3, TRUE);
390 for (i = 0; dtmfbuttons[i].label != NULL; i++)
392 GtkWidget *button = gtk_button_new_with_label (dtmfbuttons[i].label);
393 gtk_table_attach (GTK_TABLE (table), button, i % 3, i % 3 + 1,
394 i/3, i/3 + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 1, 1);
396 g_object_set_qdata (G_OBJECT (button), button_quark,
397 GUINT_TO_POINTER (dtmfbuttons[i].event));
399 g_signal_connect (G_OBJECT (button), "pressed",
400 G_CALLBACK (dtmf_button_pressed_cb), self);
401 g_signal_connect (G_OBJECT (button), "released",
402 G_CALLBACK (dtmf_button_released_cb), self);
409 empathy_call_window_create_video_input_add_slider (EmpathyCallWindow *self,
410 gchar *label_text, GtkWidget *bin)
412 GtkWidget *vbox = gtk_vbox_new (FALSE, 2);
413 GtkWidget *scale = gtk_vscale_new_with_range (0, 100, 10);
414 GtkWidget *label = gtk_label_new (label_text);
416 gtk_widget_set_sensitive (scale, FALSE);
418 gtk_container_add (GTK_CONTAINER (bin), vbox);
420 gtk_range_set_inverted (GTK_RANGE (scale), TRUE);
421 gtk_box_pack_start (GTK_BOX (vbox), scale, TRUE, TRUE, 0);
422 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
428 empathy_call_window_video_contrast_changed_cb (GtkAdjustment *adj,
429 EmpathyCallWindow *self)
432 EmpathyCallWindowPriv *priv = GET_PRIV (self);
434 empathy_video_src_set_channel (priv->video_input,
435 EMPATHY_GST_VIDEO_SRC_CHANNEL_CONTRAST, gtk_adjustment_get_value (adj));
439 empathy_call_window_video_brightness_changed_cb (GtkAdjustment *adj,
440 EmpathyCallWindow *self)
443 EmpathyCallWindowPriv *priv = GET_PRIV (self);
445 empathy_video_src_set_channel (priv->video_input,
446 EMPATHY_GST_VIDEO_SRC_CHANNEL_BRIGHTNESS, gtk_adjustment_get_value (adj));
450 empathy_call_window_video_gamma_changed_cb (GtkAdjustment *adj,
451 EmpathyCallWindow *self)
454 EmpathyCallWindowPriv *priv = GET_PRIV (self);
456 empathy_video_src_set_channel (priv->video_input,
457 EMPATHY_GST_VIDEO_SRC_CHANNEL_GAMMA, gtk_adjustment_get_value (adj));
462 empathy_call_window_create_video_input (EmpathyCallWindow *self)
464 EmpathyCallWindowPriv *priv = GET_PRIV (self);
467 hbox = gtk_hbox_new (TRUE, 3);
469 priv->video_contrast = empathy_call_window_create_video_input_add_slider (
470 self, _("Contrast"), hbox);
472 priv->video_brightness = empathy_call_window_create_video_input_add_slider (
473 self, _("Brightness"), hbox);
475 priv->video_gamma = empathy_call_window_create_video_input_add_slider (
476 self, _("Gamma"), hbox);
482 empathy_call_window_setup_video_input (EmpathyCallWindow *self)
484 EmpathyCallWindowPriv *priv = GET_PRIV (self);
488 supported = empathy_video_src_get_supported_channels (priv->video_input);
490 if (supported & EMPATHY_GST_VIDEO_SRC_SUPPORTS_CONTRAST)
492 adj = gtk_range_get_adjustment (GTK_RANGE (priv->video_contrast));
494 gtk_adjustment_set_value (adj,
495 empathy_video_src_get_channel (priv->video_input,
496 EMPATHY_GST_VIDEO_SRC_CHANNEL_CONTRAST));
498 g_signal_connect (G_OBJECT (adj), "value-changed",
499 G_CALLBACK (empathy_call_window_video_contrast_changed_cb), self);
501 gtk_widget_set_sensitive (priv->video_contrast, TRUE);
504 if (supported & EMPATHY_GST_VIDEO_SRC_SUPPORTS_BRIGHTNESS)
506 adj = gtk_range_get_adjustment (GTK_RANGE (priv->video_brightness));
508 gtk_adjustment_set_value (adj,
509 empathy_video_src_get_channel (priv->video_input,
510 EMPATHY_GST_VIDEO_SRC_CHANNEL_BRIGHTNESS));
512 g_signal_connect (G_OBJECT (adj), "value-changed",
513 G_CALLBACK (empathy_call_window_video_brightness_changed_cb), self);
514 gtk_widget_set_sensitive (priv->video_brightness, TRUE);
517 if (supported & EMPATHY_GST_VIDEO_SRC_SUPPORTS_GAMMA)
519 adj = gtk_range_get_adjustment (GTK_RANGE (priv->video_gamma));
521 gtk_adjustment_set_value (adj,
522 empathy_video_src_get_channel (priv->video_input,
523 EMPATHY_GST_VIDEO_SRC_CHANNEL_GAMMA));
525 g_signal_connect (G_OBJECT (adj), "value-changed",
526 G_CALLBACK (empathy_call_window_video_gamma_changed_cb), self);
527 gtk_widget_set_sensitive (priv->video_gamma, TRUE);
532 empathy_call_window_mic_volume_changed_cb (GtkAdjustment *adj,
533 EmpathyCallWindow *self)
535 EmpathyCallWindowPriv *priv = GET_PRIV (self);
538 volume = gtk_adjustment_get_value (adj)/100.0;
540 /* Don't store the volume because of muting */
541 if (volume > 0 || gtk_toggle_tool_button_get_active (
542 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
543 priv->volume = volume;
545 /* Ensure that the toggle button is active if the volume is > 0 and inactive
546 * if it's smaller than 0 */
547 if ((volume > 0) != gtk_toggle_tool_button_get_active (
548 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
549 gtk_toggle_tool_button_set_active (
550 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button), volume > 0);
552 empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
557 empathy_call_window_audio_input_level_changed_cb (EmpathyGstAudioSrc *src,
558 gdouble level, EmpathyCallWindow *window)
561 EmpathyCallWindowPriv *priv = GET_PRIV (window);
563 value = CLAMP (pow (10, level / 20), 0.0, 1.0);
564 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->volume_progress_bar),
569 empathy_call_window_create_audio_input (EmpathyCallWindow *self)
571 EmpathyCallWindowPriv *priv = GET_PRIV (self);
572 GtkWidget *hbox, *vbox, *label;
574 hbox = gtk_hbox_new (TRUE, 3);
576 vbox = gtk_vbox_new (FALSE, 3);
577 gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 3);
579 priv->volume_scale = gtk_vscale_new_with_range (0, 150, 100);
580 gtk_range_set_inverted (GTK_RANGE (priv->volume_scale), TRUE);
581 label = gtk_label_new (_("Volume"));
583 priv->audio_input_adj = gtk_range_get_adjustment (
584 GTK_RANGE (priv->volume_scale));
585 priv->volume = empathy_audio_src_get_volume (EMPATHY_GST_AUDIO_SRC
586 (priv->audio_input));
587 gtk_adjustment_set_value (priv->audio_input_adj, priv->volume * 100);
589 g_signal_connect (G_OBJECT (priv->audio_input_adj), "value-changed",
590 G_CALLBACK (empathy_call_window_mic_volume_changed_cb), self);
592 gtk_box_pack_start (GTK_BOX (vbox), priv->volume_scale, TRUE, TRUE, 3);
593 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 3);
595 priv->volume_progress_bar = gtk_progress_bar_new ();
596 gtk_progress_bar_set_orientation (
597 GTK_PROGRESS_BAR (priv->volume_progress_bar),
598 GTK_PROGRESS_BOTTOM_TO_TOP);
599 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->volume_progress_bar),
602 gtk_box_pack_start (GTK_BOX (hbox), priv->volume_progress_bar, FALSE, FALSE,
609 create_video_output_widget (EmpathyCallWindow *self)
611 EmpathyCallWindowPriv *priv = GET_PRIV (self);
614 g_assert (priv->video_output == NULL);
615 g_assert (priv->pipeline != NULL);
617 bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
618 priv->video_output = empathy_video_widget_new (bus);
620 gtk_box_pack_start (GTK_BOX (priv->remote_user_output_hbox),
621 priv->video_output, TRUE, TRUE, 0);
623 gtk_widget_add_events (priv->video_output,
624 GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK);
625 g_signal_connect (G_OBJECT (priv->video_output), "button-press-event",
626 G_CALLBACK (empathy_call_window_video_button_press_cb), self);
628 g_object_unref (bus);
632 create_audio_output (EmpathyCallWindow *self)
634 EmpathyCallWindowPriv *priv = GET_PRIV (self);
636 g_assert (priv->audio_output == NULL);
637 priv->audio_output = empathy_audio_sink_new ();
638 gst_object_ref (priv->audio_output);
639 gst_object_sink (priv->audio_output);
643 create_video_input (EmpathyCallWindow *self)
645 EmpathyCallWindowPriv *priv = GET_PRIV (self);
647 g_assert (priv->video_input == NULL);
648 priv->video_input = empathy_video_src_new ();
649 gst_object_ref (priv->video_input);
650 gst_object_sink (priv->video_input);
654 create_audio_input (EmpathyCallWindow *self)
656 EmpathyCallWindowPriv *priv = GET_PRIV (self);
658 g_assert (priv->audio_input == NULL);
659 priv->audio_input = empathy_audio_src_new ();
660 gst_object_ref (priv->audio_input);
661 gst_object_sink (priv->audio_input);
663 tp_g_signal_connect_object (priv->audio_input, "peak-level-changed",
664 G_CALLBACK (empathy_call_window_audio_input_level_changed_cb),
669 add_video_preview_to_pipeline (EmpathyCallWindow *self)
671 EmpathyCallWindowPriv *priv = GET_PRIV (self);
674 g_assert (priv->video_preview != NULL);
675 g_assert (priv->pipeline != NULL);
676 g_assert (priv->video_input != NULL);
677 g_assert (priv->video_tee != NULL);
679 preview = empathy_video_widget_get_element (
680 EMPATHY_VIDEO_WIDGET (priv->video_preview));
682 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->video_input))
684 g_warning ("Could not add video input to pipeline");
688 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->video_tee))
690 g_warning ("Could not add video tee to pipeline");
694 if (!gst_bin_add (GST_BIN (priv->pipeline), preview))
696 g_warning ("Could not add video preview to pipeline");
700 if (!gst_element_link (priv->video_input, priv->video_tee))
702 g_warning ("Could not link video input to video tee");
706 if (!gst_element_link (priv->video_tee, preview))
708 g_warning ("Could not link video tee to video preview");
714 create_video_preview (EmpathyCallWindow *self)
716 EmpathyCallWindowPriv *priv = GET_PRIV (self);
719 g_assert (priv->video_preview == NULL);
720 g_assert (priv->video_tee == NULL);
722 bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
724 priv->video_preview = empathy_video_widget_new_with_size (bus,
725 SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGTH);
726 g_object_set (priv->video_preview, "sync", FALSE, "async", TRUE, NULL);
728 gtk_box_pack_start (GTK_BOX (priv->self_user_output_hbox),
729 priv->video_preview, TRUE, TRUE, 0);
731 priv->video_tee = gst_element_factory_make ("tee", NULL);
732 gst_object_ref (priv->video_tee);
733 gst_object_sink (priv->video_tee);
735 g_object_unref (bus);
739 play_camera (EmpathyCallWindow *window,
742 EmpathyCallWindowPriv *priv = GET_PRIV (window);
746 if (priv->video_preview == NULL)
748 create_video_preview (window);
749 add_video_preview_to_pipeline (window);
753 state = GST_STATE_PLAYING;
755 state = GST_STATE_NULL;
757 preview = empathy_video_widget_get_element (
758 EMPATHY_VIDEO_WIDGET (priv->video_preview));
760 gst_element_set_state (preview, state);
761 gst_element_set_state (priv->video_input, state);
762 gst_element_set_state (priv->video_tee, state);
766 display_video_preview (EmpathyCallWindow *self,
769 EmpathyCallWindowPriv *priv = GET_PRIV (self);
773 /* Display the preview and hide the self avatar */
774 DEBUG ("Show video preview");
776 play_camera (self, TRUE);
777 gtk_widget_show (priv->video_preview);
778 gtk_widget_hide (priv->self_user_avatar_widget);
782 /* Display the self avatar and hide the preview */
783 DEBUG ("Show self avatar");
785 if (priv->video_preview != NULL)
787 gtk_widget_hide (priv->video_preview);
788 play_camera (self, FALSE);
790 gtk_widget_show (priv->self_user_avatar_widget);
795 empathy_call_window_set_state_connecting (EmpathyCallWindow *window)
797 EmpathyCallWindowPriv *priv = GET_PRIV (window);
799 empathy_call_window_status_message (window, _("Connecting…"));
800 priv->call_state = CONNECTING;
803 empathy_sound_start_playing (GTK_WIDGET (window),
804 EMPATHY_SOUND_PHONE_OUTGOING, MS_BETWEEN_RING);
808 disable_camera (EmpathyCallWindow *self)
810 EmpathyCallWindowPriv *priv = GET_PRIV (self);
812 if (priv->camera_state == CAMERA_STATE_OFF)
815 DEBUG ("Disable camera");
817 display_video_preview (self, FALSE);
819 if (priv->camera_state == CAMERA_STATE_ON)
820 empathy_call_window_set_send_video (self, CAMERA_STATE_OFF);
822 block_camera_control_signals (self);
823 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (
824 priv->tool_button_camera_on), FALSE);
825 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (
826 priv->tool_button_camera_preview), FALSE);
828 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (
829 priv->tool_button_camera_off), TRUE);
830 gtk_radio_action_set_current_value (GTK_RADIO_ACTION (priv->action_camera),
832 unblock_camera_control_signals (self);
834 priv->camera_state = CAMERA_STATE_OFF;
838 tool_button_camera_off_toggled_cb (GtkToggleToolButton *toggle,
839 EmpathyCallWindow *self)
841 EmpathyCallWindowPriv *priv = GET_PRIV (self);
843 if (!gtk_toggle_tool_button_get_active (toggle))
845 if (priv->camera_state == CAMERA_STATE_OFF)
847 /* We can't change the state by disabling the button */
848 block_camera_control_signals (self);
849 gtk_toggle_tool_button_set_active (toggle, TRUE);
850 unblock_camera_control_signals (self);
856 disable_camera (self);
860 enable_preview (EmpathyCallWindow *self)
862 EmpathyCallWindowPriv *priv = GET_PRIV (self);
864 if (priv->camera_state == CAMERA_STATE_PREVIEW)
867 DEBUG ("Enable preview");
869 if (priv->camera_state == CAMERA_STATE_ON)
871 /* preview is already displayed so we just have to stop sending */
872 empathy_call_window_set_send_video (self, CAMERA_STATE_PREVIEW);
876 display_video_preview (self, TRUE);
879 block_camera_control_signals (self);
880 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (
881 priv->tool_button_camera_off), FALSE);
882 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (
883 priv->tool_button_camera_on), FALSE);
885 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (
886 priv->tool_button_camera_preview), TRUE);
887 gtk_radio_action_set_current_value (GTK_RADIO_ACTION (priv->action_camera),
888 CAMERA_STATE_PREVIEW);
889 unblock_camera_control_signals (self);
891 priv->camera_state = CAMERA_STATE_PREVIEW;
895 tool_button_camera_preview_toggled_cb (GtkToggleToolButton *toggle,
896 EmpathyCallWindow *self)
898 EmpathyCallWindowPriv *priv = GET_PRIV (self);
900 if (!gtk_toggle_tool_button_get_active (toggle))
902 if (priv->camera_state == CAMERA_STATE_PREVIEW)
904 /* We can't change the state by disabling the button */
905 block_camera_control_signals (self);
906 gtk_toggle_tool_button_set_active (toggle, TRUE);
907 unblock_camera_control_signals (self);
913 enable_preview (self);
917 enable_camera (EmpathyCallWindow *self)
919 EmpathyCallWindowPriv *priv = GET_PRIV (self);
921 if (priv->camera_state == CAMERA_STATE_ON)
924 if (priv->video_input == NULL)
926 DEBUG ("Can't enable camera, no input");
931 DEBUG ("Enable camera");
933 empathy_call_window_set_send_video (self, CAMERA_STATE_ON);
935 block_camera_control_signals (self);
936 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (
937 priv->tool_button_camera_off), FALSE);
938 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (
939 priv->tool_button_camera_preview), FALSE);
941 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (
942 priv->tool_button_camera_on), TRUE);
943 gtk_radio_action_set_current_value (GTK_RADIO_ACTION (priv->action_camera),
945 unblock_camera_control_signals (self);
947 priv->camera_state = CAMERA_STATE_ON;
951 tool_button_camera_on_toggled_cb (GtkToggleToolButton *toggle,
952 EmpathyCallWindow *self)
954 EmpathyCallWindowPriv *priv = GET_PRIV (self);
956 if (!gtk_toggle_tool_button_get_active (toggle))
958 if (priv->camera_state == CAMERA_STATE_ON)
960 /* We can't change the state by disabling the button */
961 block_camera_control_signals (self);
962 gtk_toggle_tool_button_set_active (toggle, TRUE);
963 unblock_camera_control_signals (self);
969 enable_camera (self);
973 action_camera_change_cb (GtkRadioAction *action,
974 GtkRadioAction *current,
975 EmpathyCallWindow *self)
979 state = gtk_radio_action_get_current_value (current);
983 case CAMERA_STATE_OFF:
984 disable_camera (self);
987 case CAMERA_STATE_PREVIEW:
988 enable_preview (self);
991 case CAMERA_STATE_ON:
992 enable_camera (self);
996 g_assert_not_reached ();
1001 create_pipeline (EmpathyCallWindow *self)
1003 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1006 g_assert (priv->pipeline == NULL);
1008 priv->pipeline = gst_pipeline_new (NULL);
1009 priv->pipeline_playing = FALSE;
1011 bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
1012 priv->bus_message_source_id = gst_bus_add_watch (bus,
1013 empathy_call_window_bus_message, self);
1015 g_object_unref (bus);
1020 empathy_call_window_init (EmpathyCallWindow *self)
1022 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1024 GtkWidget *top_vbox;
1030 GError *error = NULL;
1032 filename = empathy_file_lookup ("empathy-call-window.ui", "src");
1033 gui = empathy_builder_get_file (filename,
1034 "call_window_vbox", &top_vbox,
1035 "errors_vbox", &priv->errors_vbox,
1036 "pane", &priv->pane,
1037 "statusbar", &priv->statusbar,
1038 "redial", &priv->redial_button,
1039 "microphone", &priv->mic_button,
1040 "toolbar", &priv->toolbar,
1041 "menuredial", &priv->redial,
1042 "ui_manager", &priv->ui_manager,
1043 "menufullscreen", &priv->menu_fullscreen,
1044 "camera_off", &priv->tool_button_camera_off,
1045 "camera_preview", &priv->tool_button_camera_preview,
1046 "camera_on", &priv->tool_button_camera_on,
1047 "action_camera_off", &priv->action_camera,
1048 "action_camera_preview", &priv->action_camera_preview,
1049 "details_vbox", &priv->details_vbox,
1050 "vcodec_encoding_label", &priv->vcodec_encoding_label,
1051 "acodec_encoding_label", &priv->acodec_encoding_label,
1052 "acodec_decoding_label", &priv->acodec_decoding_label,
1053 "vcodec_decoding_label", &priv->vcodec_decoding_label,
1057 empathy_builder_connect (gui, self,
1058 "menuhangup", "activate", empathy_call_window_hangup_cb,
1059 "hangup", "clicked", empathy_call_window_hangup_cb,
1060 "menuredial", "activate", empathy_call_window_redial_cb,
1061 "redial", "clicked", empathy_call_window_redial_cb,
1062 "microphone", "toggled", empathy_call_window_mic_toggled_cb,
1063 "menufullscreen", "activate", empathy_call_window_fullscreen_cb,
1064 "camera_off", "toggled", tool_button_camera_off_toggled_cb,
1065 "camera_preview", "toggled", tool_button_camera_preview_toggled_cb,
1066 "camera_on", "toggled", tool_button_camera_on_toggled_cb,
1067 "action_camera_off", "changed", action_camera_change_cb,
1070 priv->lock = g_mutex_new ();
1072 gtk_container_add (GTK_CONTAINER (self), top_vbox);
1074 priv->content_hbox = gtk_hbox_new (FALSE, CONTENT_HBOX_SPACING);
1075 gtk_container_set_border_width (GTK_CONTAINER (priv->content_hbox),
1076 CONTENT_HBOX_BORDER_WIDTH);
1077 gtk_paned_pack1 (GTK_PANED (priv->pane), priv->content_hbox, TRUE, FALSE);
1079 /* remote user output frame */
1080 priv->remote_user_output_frame = gtk_frame_new (NULL);
1081 gtk_widget_set_size_request (priv->remote_user_output_frame,
1082 EMPATHY_VIDEO_WIDGET_DEFAULT_WIDTH, EMPATHY_VIDEO_WIDGET_DEFAULT_HEIGHT);
1083 gtk_box_pack_start (GTK_BOX (priv->content_hbox),
1084 priv->remote_user_output_frame, TRUE, TRUE,
1085 CONTENT_HBOX_CHILDREN_PACKING_PADDING);
1087 priv->remote_user_output_hbox = gtk_hbox_new (FALSE, 0);
1089 priv->remote_user_avatar_widget = gtk_image_new ();
1091 gtk_box_pack_start (GTK_BOX (priv->remote_user_output_hbox),
1092 priv->remote_user_avatar_widget, TRUE, TRUE, 0);
1094 gtk_container_add (GTK_CONTAINER (priv->remote_user_output_frame),
1095 priv->remote_user_output_hbox);
1097 /* self user output frame */
1098 priv->self_user_output_frame = gtk_frame_new (NULL);
1099 gtk_widget_set_size_request (priv->self_user_output_frame,
1100 SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGTH);
1102 priv->self_user_output_hbox = gtk_hbox_new (FALSE, 0);
1104 priv->self_user_avatar_widget = gtk_image_new ();
1105 gtk_box_pack_start (GTK_BOX (priv->self_user_output_hbox),
1106 priv->self_user_avatar_widget, TRUE, TRUE, 0);
1108 gtk_container_add (GTK_CONTAINER (priv->self_user_output_frame),
1109 priv->self_user_output_hbox);
1111 create_pipeline (self);
1112 create_video_output_widget (self);
1113 create_audio_input (self);
1114 create_audio_output (self);
1115 create_video_input (self);
1117 priv->fsnotifier = fs_element_added_notifier_new ();
1118 fs_element_added_notifier_add (priv->fsnotifier, GST_BIN (priv->pipeline));
1120 /* The call will be started as soon the pipeline is playing */
1121 priv->start_call_when_playing = TRUE;
1123 keyfile = g_key_file_new ();
1124 filename = empathy_file_lookup ("element-properties", "data");
1125 if (g_key_file_load_from_file (keyfile, filename, G_KEY_FILE_NONE, &error))
1127 fs_element_added_notifier_set_properties_from_keyfile (priv->fsnotifier,
1132 g_warning ("Could not load element-properties file: %s", error->message);
1133 g_key_file_free (keyfile);
1134 g_clear_error (&error);
1138 priv->vbox = gtk_vbox_new (FALSE, 3);
1139 gtk_box_pack_start (GTK_BOX (priv->content_hbox), priv->vbox,
1140 FALSE, FALSE, CONTENT_HBOX_CHILDREN_PACKING_PADDING);
1141 gtk_box_pack_start (GTK_BOX (priv->vbox), priv->self_user_output_frame,
1144 empathy_call_window_setup_toolbar (self);
1146 priv->sidebar_button = gtk_toggle_button_new_with_mnemonic (_("_Sidebar"));
1147 arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
1148 g_signal_connect (G_OBJECT (priv->sidebar_button), "toggled",
1149 G_CALLBACK (empathy_call_window_sidebar_toggled_cb), self);
1151 gtk_button_set_image (GTK_BUTTON (priv->sidebar_button), arrow);
1153 h = gtk_hbox_new (FALSE, 3);
1154 gtk_box_pack_end (GTK_BOX (priv->vbox), h, FALSE, FALSE, 3);
1155 gtk_box_pack_end (GTK_BOX (h), priv->sidebar_button, FALSE, FALSE, 3);
1157 priv->sidebar = empathy_sidebar_new ();
1158 g_signal_connect (G_OBJECT (priv->sidebar),
1159 "hide", G_CALLBACK (empathy_call_window_sidebar_hidden_cb), self);
1160 g_signal_connect (G_OBJECT (priv->sidebar),
1161 "show", G_CALLBACK (empathy_call_window_sidebar_shown_cb), self);
1162 gtk_paned_pack2 (GTK_PANED (priv->pane), priv->sidebar, FALSE, FALSE);
1164 page = empathy_call_window_create_audio_input (self);
1165 empathy_sidebar_add_page (EMPATHY_SIDEBAR (priv->sidebar), _("Audio input"),
1168 page = empathy_call_window_create_video_input (self);
1169 empathy_sidebar_add_page (EMPATHY_SIDEBAR (priv->sidebar), _("Video input"),
1172 priv->dtmf_panel = empathy_call_window_create_dtmf (self);
1173 empathy_sidebar_add_page (EMPATHY_SIDEBAR (priv->sidebar), _("Dialpad"),
1176 gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
1178 empathy_sidebar_add_page (EMPATHY_SIDEBAR (priv->sidebar), _("Details"),
1179 priv->details_vbox);
1181 gtk_widget_show_all (top_vbox);
1183 gtk_widget_hide (priv->sidebar);
1185 priv->fullscreen = empathy_call_window_fullscreen_new (self);
1186 empathy_call_window_fullscreen_set_video_widget (priv->fullscreen,
1187 priv->video_output);
1188 g_signal_connect (G_OBJECT (priv->fullscreen->leave_fullscreen_button),
1189 "clicked", G_CALLBACK (empathy_call_window_fullscreen_cb), self);
1191 g_signal_connect (G_OBJECT (self), "realize",
1192 G_CALLBACK (empathy_call_window_realized_cb), self);
1194 g_signal_connect (G_OBJECT (self), "delete-event",
1195 G_CALLBACK (empathy_call_window_delete_cb), self);
1197 g_signal_connect (G_OBJECT (self), "window-state-event",
1198 G_CALLBACK (empathy_call_window_state_event_cb), self);
1200 g_signal_connect (G_OBJECT (self), "key-press-event",
1201 G_CALLBACK (empathy_call_window_key_press_cb), self);
1203 priv->timer = g_timer_new ();
1205 g_object_ref (priv->ui_manager);
1206 g_object_unref (gui);
1208 empathy_geometry_bind (GTK_WINDOW (self), "call-window");
1211 /* Instead of specifying a width and a height, we specify only one size. That's
1212 because we want a square avatar icon. */
1214 init_contact_avatar_with_size (EmpathyContact *contact,
1215 GtkWidget *image_widget,
1218 GdkPixbuf *pixbuf_avatar = NULL;
1220 if (contact != NULL)
1222 pixbuf_avatar = empathy_pixbuf_avatar_from_contact_scaled (contact,
1226 if (pixbuf_avatar == NULL)
1228 pixbuf_avatar = empathy_pixbuf_from_icon_name_sized (
1229 EMPATHY_IMAGE_AVATAR_DEFAULT, size);
1232 gtk_image_set_from_pixbuf (GTK_IMAGE (image_widget), pixbuf_avatar);
1234 if (pixbuf_avatar != NULL)
1235 g_object_unref (pixbuf_avatar);
1239 set_window_title (EmpathyCallWindow *self)
1241 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1244 /* translators: Call is a noun and %s is the contact name. This string
1245 * is used in the window title */
1246 tmp = g_strdup_printf (_("Call with %s"),
1247 empathy_contact_get_name (priv->contact));
1248 gtk_window_set_title (GTK_WINDOW (self), tmp);
1253 contact_name_changed_cb (EmpathyContact *contact,
1254 GParamSpec *pspec, EmpathyCallWindow *self)
1256 set_window_title (self);
1260 contact_avatar_changed_cb (EmpathyContact *contact,
1261 GParamSpec *pspec, GtkWidget *avatar_widget)
1264 GtkAllocation allocation;
1266 gtk_widget_get_allocation (avatar_widget, &allocation);
1267 size = allocation.height;
1271 /* the widget is not allocated yet, set a default size */
1272 size = MIN (REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT,
1273 REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH);
1276 init_contact_avatar_with_size (contact, avatar_widget, size);
1280 empathy_call_window_got_self_contact_cb (TpConnection *connection,
1281 EmpathyContact *contact, const GError *error, gpointer user_data,
1282 GObject *weak_object)
1284 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
1285 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1287 init_contact_avatar_with_size (contact, priv->self_user_avatar_widget,
1288 MIN (SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGTH));
1290 g_signal_connect (contact, "notify::avatar",
1291 G_CALLBACK (contact_avatar_changed_cb), priv->self_user_avatar_widget);
1295 empathy_call_window_setup_avatars (EmpathyCallWindow *self,
1296 EmpathyCallHandler *handler)
1298 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1300 g_object_get (handler, "contact", &(priv->contact), NULL);
1302 if (priv->contact != NULL)
1304 TpConnection *connection;
1306 set_window_title (self);
1308 g_signal_connect (priv->contact, "notify::name",
1309 G_CALLBACK (contact_name_changed_cb), self);
1310 g_signal_connect (priv->contact, "notify::avatar",
1311 G_CALLBACK (contact_avatar_changed_cb),
1312 priv->remote_user_avatar_widget);
1314 /* Retreiving the self avatar */
1315 connection = empathy_contact_get_connection (priv->contact);
1316 empathy_tp_contact_factory_get_from_handle (connection,
1317 tp_connection_get_self_handle (connection),
1318 empathy_call_window_got_self_contact_cb, self, NULL, G_OBJECT (self));
1322 g_warning ("call handler doesn't have a contact");
1323 /* translators: Call is a noun. This string is used in the window
1325 gtk_window_set_title (GTK_WINDOW (self), _("Call"));
1327 /* Since we can't access the remote contact, we can't get a connection
1328 to it and can't get the self contact (and its avatar). This means
1329 that we have to manually set the self avatar. */
1330 init_contact_avatar_with_size (NULL, priv->self_user_avatar_widget,
1331 MIN (SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGTH));
1334 init_contact_avatar_with_size (priv->contact,
1335 priv->remote_user_avatar_widget,
1336 MIN (REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH,
1337 REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT));
1339 /* The remote avatar is shown by default and will be hidden when we receive
1340 video from the remote side. */
1341 gtk_widget_hide (priv->video_output);
1342 gtk_widget_show (priv->remote_user_avatar_widget);
1346 update_send_codec (EmpathyCallWindow *self,
1349 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1356 codec = empathy_call_handler_get_send_audio_codec (priv->handler);
1357 widget = priv->acodec_encoding_label;
1361 codec = empathy_call_handler_get_send_video_codec (priv->handler);
1362 widget = priv->vcodec_encoding_label;
1368 tmp = g_strdup_printf ("%s/%u", codec->encoding_name, codec->clock_rate);
1369 gtk_label_set_text (GTK_LABEL (widget), tmp);
1374 send_audio_codec_notify_cb (GObject *object,
1378 EmpathyCallWindow *self = user_data;
1380 update_send_codec (self, TRUE);
1384 send_video_codec_notify_cb (GObject *object,
1388 EmpathyCallWindow *self = user_data;
1390 update_send_codec (self, FALSE);
1394 update_recv_codec (EmpathyCallWindow *self,
1397 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1400 GString *str = NULL;
1404 codecs = empathy_call_handler_get_recv_audio_codecs (priv->handler);
1405 widget = priv->acodec_decoding_label;
1409 codecs = empathy_call_handler_get_recv_video_codecs (priv->handler);
1410 widget = priv->vcodec_decoding_label;
1416 for (l = codecs; l != NULL; l = g_list_next (l))
1418 FsCodec *codec = l->data;
1421 str = g_string_new (NULL);
1423 g_string_append (str, ", ");
1425 g_string_append_printf (str, "%s/%u", codec->encoding_name,
1429 gtk_label_set_text (GTK_LABEL (widget), str->str);
1430 g_string_free (str, TRUE);
1434 recv_audio_codecs_notify_cb (GObject *object,
1438 EmpathyCallWindow *self = user_data;
1440 update_recv_codec (self, TRUE);
1444 recv_video_codecs_notify_cb (GObject *object,
1448 EmpathyCallWindow *self = user_data;
1450 update_recv_codec (self, FALSE);
1454 empathy_call_window_constructed (GObject *object)
1456 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
1457 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1458 EmpathyTpCall *call;
1460 g_assert (priv->handler != NULL);
1462 g_object_get (priv->handler, "tp-call", &call, NULL);
1463 priv->outgoing = (call == NULL);
1465 g_object_unref (call);
1467 empathy_call_window_setup_avatars (self, priv->handler);
1468 empathy_call_window_set_state_connecting (self);
1470 if (!empathy_call_handler_has_initial_video (priv->handler))
1472 gtk_toggle_tool_button_set_active (
1473 GTK_TOGGLE_TOOL_BUTTON (priv->tool_button_camera_off), TRUE);
1475 /* If call has InitialVideo, the preview will be started once the call has
1476 * been started (start_call()). */
1478 update_send_codec (self, TRUE);
1479 update_send_codec (self, FALSE);
1480 update_recv_codec (self, TRUE);
1481 update_recv_codec (self, FALSE);
1483 tp_g_signal_connect_object (priv->handler, "notify::send-audio-codec",
1484 G_CALLBACK (send_audio_codec_notify_cb), self, 0);
1485 tp_g_signal_connect_object (priv->handler, "notify::send-video-codec",
1486 G_CALLBACK (send_video_codec_notify_cb), self, 0);
1487 tp_g_signal_connect_object (priv->handler, "notify::recv-audio-codecs",
1488 G_CALLBACK (recv_audio_codecs_notify_cb), self, 0);
1489 tp_g_signal_connect_object (priv->handler, "notify::recv-video-codecs",
1490 G_CALLBACK (recv_video_codecs_notify_cb), self, 0);
1493 static void empathy_call_window_dispose (GObject *object);
1494 static void empathy_call_window_finalize (GObject *object);
1497 empathy_call_window_set_property (GObject *object,
1498 guint property_id, const GValue *value, GParamSpec *pspec)
1500 EmpathyCallWindowPriv *priv = GET_PRIV (object);
1502 switch (property_id)
1504 case PROP_CALL_HANDLER:
1505 priv->handler = g_value_dup_object (value);
1508 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1513 empathy_call_window_get_property (GObject *object,
1514 guint property_id, GValue *value, GParamSpec *pspec)
1516 EmpathyCallWindowPriv *priv = GET_PRIV (object);
1518 switch (property_id)
1520 case PROP_CALL_HANDLER:
1521 g_value_set_object (value, priv->handler);
1524 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1529 empathy_call_window_class_init (
1530 EmpathyCallWindowClass *empathy_call_window_class)
1532 GObjectClass *object_class = G_OBJECT_CLASS (empathy_call_window_class);
1533 GParamSpec *param_spec;
1535 g_type_class_add_private (empathy_call_window_class,
1536 sizeof (EmpathyCallWindowPriv));
1538 object_class->constructed = empathy_call_window_constructed;
1539 object_class->set_property = empathy_call_window_set_property;
1540 object_class->get_property = empathy_call_window_get_property;
1542 object_class->dispose = empathy_call_window_dispose;
1543 object_class->finalize = empathy_call_window_finalize;
1545 param_spec = g_param_spec_object ("handler",
1546 "handler", "The call handler",
1547 EMPATHY_TYPE_CALL_HANDLER,
1548 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
1549 g_object_class_install_property (object_class,
1550 PROP_CALL_HANDLER, param_spec);
1554 empathy_call_window_video_stream_changed_cb (EmpathyTpCall *call,
1555 GParamSpec *property, EmpathyCallWindow *self)
1557 DEBUG ("video stream changed");
1558 empathy_call_window_update_avatars_visibility (call, self);
1562 empathy_call_window_dispose (GObject *object)
1564 EmpathyTpCall *call;
1565 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
1566 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1568 if (priv->dispose_has_run)
1571 priv->dispose_has_run = TRUE;
1573 g_object_get (priv->handler, "tp-call", &call, NULL);
1577 g_object_unref (call);
1580 if (priv->handler != NULL)
1582 empathy_call_handler_stop_call (priv->handler);
1583 g_object_unref (priv->handler);
1585 priv->handler = NULL;
1587 if (priv->bus_message_source_id != 0)
1589 g_source_remove (priv->bus_message_source_id);
1590 priv->bus_message_source_id = 0;
1593 if (priv->pipeline != NULL)
1594 g_object_unref (priv->pipeline);
1595 priv->pipeline = NULL;
1597 if (priv->video_input != NULL)
1598 g_object_unref (priv->video_input);
1599 priv->video_input = NULL;
1601 if (priv->audio_input != NULL)
1602 g_object_unref (priv->audio_input);
1603 priv->audio_input = NULL;
1605 if (priv->audio_output != NULL)
1606 g_object_unref (priv->audio_output);
1607 priv->audio_output = NULL;
1609 if (priv->video_tee != NULL)
1610 g_object_unref (priv->video_tee);
1611 priv->video_tee = NULL;
1613 if (priv->liveadder != NULL)
1614 gst_object_unref (priv->liveadder);
1615 priv->liveadder = NULL;
1617 if (priv->fsnotifier != NULL)
1618 g_object_unref (priv->fsnotifier);
1619 priv->fsnotifier = NULL;
1621 if (priv->timer_id != 0)
1622 g_source_remove (priv->timer_id);
1625 if (priv->ui_manager != NULL)
1626 g_object_unref (priv->ui_manager);
1627 priv->ui_manager = NULL;
1629 if (priv->fullscreen != NULL)
1630 g_object_unref (priv->fullscreen);
1631 priv->fullscreen = NULL;
1633 if (priv->contact != NULL)
1635 g_signal_handlers_disconnect_by_func (priv->contact,
1636 contact_name_changed_cb, self);
1637 g_object_unref (priv->contact);
1638 priv->contact = NULL;
1641 /* release any references held by the object here */
1642 if (G_OBJECT_CLASS (empathy_call_window_parent_class)->dispose)
1643 G_OBJECT_CLASS (empathy_call_window_parent_class)->dispose (object);
1647 empathy_call_window_finalize (GObject *object)
1649 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
1650 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1652 if (priv->video_output_motion_handler_id != 0)
1654 g_signal_handler_disconnect (G_OBJECT (priv->video_output),
1655 priv->video_output_motion_handler_id);
1656 priv->video_output_motion_handler_id = 0;
1659 /* free any data held directly by the object here */
1660 g_mutex_free (priv->lock);
1662 g_timer_destroy (priv->timer);
1664 G_OBJECT_CLASS (empathy_call_window_parent_class)->finalize (object);
1669 empathy_call_window_new (EmpathyCallHandler *handler)
1671 return EMPATHY_CALL_WINDOW (
1672 g_object_new (EMPATHY_TYPE_CALL_WINDOW, "handler", handler, NULL));
1676 empathy_call_window_conference_added_cb (EmpathyCallHandler *handler,
1677 GstElement *conference, gpointer user_data)
1679 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
1680 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1682 gst_bin_add (GST_BIN (priv->pipeline), conference);
1684 gst_element_set_state (conference, GST_STATE_PLAYING);
1688 empathy_call_window_request_resource_cb (EmpathyCallHandler *handler,
1689 FsMediaType type, FsStreamDirection direction, gpointer user_data)
1691 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
1692 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1694 if (type != FS_MEDIA_TYPE_VIDEO)
1697 if (direction == FS_DIRECTION_RECV)
1700 /* video and direction is send */
1701 return priv->video_input != NULL;
1705 empathy_call_window_reset_pipeline (EmpathyCallWindow *self)
1707 GstStateChangeReturn state_change_return;
1708 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1710 if (priv->pipeline == NULL)
1713 if (priv->bus_message_source_id != 0)
1715 g_source_remove (priv->bus_message_source_id);
1716 priv->bus_message_source_id = 0;
1719 state_change_return = gst_element_set_state (priv->pipeline, GST_STATE_NULL);
1721 if (state_change_return == GST_STATE_CHANGE_SUCCESS ||
1722 state_change_return == GST_STATE_CHANGE_NO_PREROLL)
1724 if (priv->pipeline != NULL)
1725 g_object_unref (priv->pipeline);
1726 priv->pipeline = NULL;
1728 g_signal_handlers_disconnect_by_func (priv->audio_input_adj,
1729 empathy_call_window_mic_volume_changed_cb, self);
1731 if (priv->video_tee != NULL)
1732 g_object_unref (priv->video_tee);
1733 priv->video_tee = NULL;
1735 if (priv->video_preview != NULL)
1736 gtk_widget_destroy (priv->video_preview);
1737 priv->video_preview = NULL;
1739 priv->liveadder = NULL;
1740 priv->funnel = NULL;
1742 create_pipeline (self);
1743 /* Call will be started when user will hit the 'redial' button */
1744 priv->start_call_when_playing = FALSE;
1745 gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
1751 g_message ("Error: could not destroy pipeline. Closing call window");
1752 gtk_widget_destroy (GTK_WIDGET (self));
1759 reset_details_pane (EmpathyCallWindow *self)
1761 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1763 gtk_label_set_text (GTK_LABEL (priv->vcodec_encoding_label), _("Unknown"));
1764 gtk_label_set_text (GTK_LABEL (priv->acodec_encoding_label), _("Unknown"));
1765 gtk_label_set_text (GTK_LABEL (priv->vcodec_decoding_label), _("Unknown"));
1766 gtk_label_set_text (GTK_LABEL (priv->acodec_decoding_label), _("Unknown"));
1770 empathy_call_window_disconnected (EmpathyCallWindow *self,
1773 gboolean could_disconnect = FALSE;
1774 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1775 gboolean could_reset_pipeline;
1777 could_reset_pipeline = empathy_call_window_reset_pipeline (self);
1779 if (priv->call_state == CONNECTING)
1780 empathy_sound_stop (EMPATHY_SOUND_PHONE_OUTGOING);
1782 if (priv->call_state != REDIALING)
1783 priv->call_state = DISCONNECTED;
1785 if (could_reset_pipeline)
1787 g_mutex_lock (priv->lock);
1789 g_timer_stop (priv->timer);
1791 if (priv->timer_id != 0)
1792 g_source_remove (priv->timer_id);
1795 g_mutex_unlock (priv->lock);
1798 /* We are about to destroy the window, no need to update it or create
1799 * a video preview */
1802 empathy_call_window_status_message (self, _("Disconnected"));
1804 gtk_action_set_sensitive (priv->redial, TRUE);
1805 gtk_widget_set_sensitive (priv->redial_button, TRUE);
1807 /* Unsensitive the camera and mic button */
1808 gtk_widget_set_sensitive (priv->tool_button_camera_on, FALSE);
1809 gtk_widget_set_sensitive (priv->mic_button, FALSE);
1811 /* Be sure that the mic button is enabled */
1812 gtk_toggle_tool_button_set_active (
1813 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button), TRUE);
1815 if (priv->camera_state == CAMERA_STATE_ON)
1817 /* Enable the 'preview' button as we are not sending atm. */
1818 gtk_toggle_tool_button_set_active (
1819 GTK_TOGGLE_TOOL_BUTTON (priv->tool_button_camera_preview), TRUE);
1821 else if (priv->camera_state == CAMERA_STATE_PREVIEW)
1823 /* Restart the preview with the new pipeline. */
1824 display_video_preview (self, TRUE);
1827 gtk_progress_bar_set_fraction (
1828 GTK_PROGRESS_BAR (priv->volume_progress_bar), 0);
1830 /* destroy the video output; it will be recreated when we'll redial */
1831 gtk_widget_destroy (priv->video_output);
1832 priv->video_output = NULL;
1834 gtk_widget_show (priv->remote_user_avatar_widget);
1836 reset_details_pane (self);
1838 priv->sending_video = FALSE;
1839 priv->call_started = FALSE;
1841 could_disconnect = TRUE;
1843 /* TODO: display the self avatar of the preview (depends if the "Always
1844 * Show Video Preview" is enabled or not) */
1847 return could_disconnect;
1852 empathy_call_window_channel_closed_cb (EmpathyCallHandler *handler,
1855 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
1856 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1858 if (empathy_call_window_disconnected (self, TRUE) &&
1859 priv->call_state == REDIALING)
1860 empathy_call_window_restart_call (self);
1865 empathy_call_window_channel_stream_closed_cb (EmpathyCallHandler *handler,
1866 TfStream *stream, gpointer user_data)
1868 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
1869 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1872 g_object_get (stream, "media-type", &media_type, NULL);
1875 * This assumes that there is only one video stream per channel...
1878 if (media_type == TP_MEDIA_STREAM_TYPE_VIDEO)
1880 if (priv->funnel != NULL)
1884 output = empathy_video_widget_get_element (EMPATHY_VIDEO_WIDGET
1885 (priv->video_output));
1887 gst_element_set_state (output, GST_STATE_NULL);
1888 gst_element_set_state (priv->funnel, GST_STATE_NULL);
1890 gst_bin_remove (GST_BIN (priv->pipeline), output);
1891 gst_bin_remove (GST_BIN (priv->pipeline), priv->funnel);
1892 priv->funnel = NULL;
1895 else if (media_type == TP_MEDIA_STREAM_TYPE_AUDIO)
1897 if (priv->liveadder != NULL)
1899 gst_element_set_state (priv->audio_output, GST_STATE_NULL);
1900 gst_element_set_state (priv->liveadder, GST_STATE_NULL);
1902 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
1903 gst_bin_remove (GST_BIN (priv->pipeline), priv->liveadder);
1904 priv->liveadder = NULL;
1909 /* Called with global lock held */
1911 empathy_call_window_get_video_sink_pad (EmpathyCallWindow *self)
1913 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1917 if (priv->funnel == NULL)
1919 output = empathy_video_widget_get_element (EMPATHY_VIDEO_WIDGET
1920 (priv->video_output));
1922 priv->funnel = gst_element_factory_make ("fsfunnel", NULL);
1926 g_warning ("Could not create fsfunnel");
1930 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->funnel))
1932 gst_object_unref (priv->funnel);
1933 priv->funnel = NULL;
1934 g_warning ("Could not add funnel to pipeline");
1938 if (!gst_bin_add (GST_BIN (priv->pipeline), output))
1940 g_warning ("Could not add the video output widget to the pipeline");
1944 if (!gst_element_link (priv->funnel, output))
1946 g_warning ("Could not link output sink to funnel");
1947 goto error_output_added;
1950 if (gst_element_set_state (output, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
1952 g_warning ("Could not start video sink");
1953 goto error_output_added;
1956 if (gst_element_set_state (priv->funnel, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
1958 g_warning ("Could not start funnel");
1959 goto error_output_added;
1963 pad = gst_element_get_request_pad (priv->funnel, "sink%d");
1966 g_warning ("Could not get request pad from funnel");
1973 gst_element_set_locked_state (priv->funnel, TRUE);
1974 gst_element_set_locked_state (output, TRUE);
1976 gst_element_set_state (priv->funnel, GST_STATE_NULL);
1977 gst_element_set_state (output, GST_STATE_NULL);
1979 gst_bin_remove (GST_BIN (priv->pipeline), output);
1980 gst_element_set_locked_state (output, FALSE);
1984 gst_bin_remove (GST_BIN (priv->pipeline), priv->funnel);
1985 priv->funnel = NULL;
1990 /* Called with global lock held */
1992 empathy_call_window_get_audio_sink_pad (EmpathyCallWindow *self)
1994 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1997 GError *gerror = NULL;
1999 if (priv->liveadder == NULL)
2001 priv->liveadder = gst_element_factory_make ("liveadder", NULL);
2003 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->liveadder))
2005 g_warning ("Could not add liveadder to the pipeline");
2006 goto error_add_liveadder;
2008 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_output))
2010 g_warning ("Could not add audio sink to pipeline");
2011 goto error_add_output;
2014 if (gst_element_set_state (priv->liveadder, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2016 g_warning ("Could not start liveadder");
2020 if (gst_element_set_state (priv->audio_output, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2022 g_warning ("Could not start audio sink");
2026 if (GST_PAD_LINK_FAILED (
2027 gst_element_link (priv->liveadder, priv->audio_output)))
2029 g_warning ("Could not link liveadder to audio output");
2034 filter = gst_parse_bin_from_description (
2035 "audioconvert ! audioresample ! audioconvert", TRUE, &gerror);
2038 g_warning ("Could not make audio conversion filter: %s", gerror->message);
2039 g_clear_error (&gerror);
2043 if (!gst_bin_add (GST_BIN (priv->pipeline), filter))
2045 g_warning ("Could not add audio conversion filter to pipeline");
2046 gst_object_unref (filter);
2050 if (gst_element_set_state (filter, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2052 g_warning ("Could not start audio conversion filter");
2056 if (!gst_element_link (filter, priv->liveadder))
2058 g_warning ("Could not link audio conversion filter to liveadder");
2062 pad = gst_element_get_static_pad (filter, "sink");
2066 g_warning ("Could not get sink pad from filter");
2074 gst_element_set_locked_state (filter, TRUE);
2075 gst_element_set_state (filter, GST_STATE_NULL);
2076 gst_bin_remove (GST_BIN (priv->pipeline), filter);
2080 gst_element_set_locked_state (priv->liveadder, TRUE);
2081 gst_element_set_locked_state (priv->audio_output, TRUE);
2083 gst_element_set_state (priv->liveadder, GST_STATE_NULL);
2084 gst_element_set_state (priv->audio_output, GST_STATE_NULL);
2086 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
2090 gst_bin_remove (GST_BIN (priv->pipeline), priv->liveadder);
2092 gst_element_set_locked_state (priv->liveadder, FALSE);
2093 gst_element_set_locked_state (priv->audio_output, FALSE);
2095 error_add_liveadder:
2097 if (priv->liveadder != NULL)
2099 gst_object_unref (priv->liveadder);
2100 priv->liveadder = NULL;
2107 empathy_call_window_update_timer (gpointer user_data)
2109 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2110 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2114 time_ = g_timer_elapsed (priv->timer, NULL);
2116 /* Translators: number of minutes:seconds the caller has been connected */
2117 str = g_strdup_printf (_("Connected — %d:%02dm"), (int) time_ / 60,
2119 empathy_call_window_status_message (self, str);
2126 display_error (EmpathyCallWindow *self,
2127 EmpathyTpCall *call,
2131 const gchar *details)
2133 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2134 GtkWidget *info_bar;
2135 GtkWidget *content_area;
2142 /* Create info bar */
2143 info_bar = gtk_info_bar_new_with_buttons (GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
2146 gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_WARNING);
2148 content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar));
2150 /* hbox containing the image and the messages vbox */
2151 hbox = gtk_hbox_new (FALSE, 3);
2152 gtk_container_add (GTK_CONTAINER (content_area), hbox);
2155 image = gtk_image_new_from_icon_name (img, GTK_ICON_SIZE_DIALOG);
2156 gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
2158 /* vbox containing the main message and the details expander */
2159 vbox = gtk_vbox_new (FALSE, 3);
2160 gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
2163 txt = g_strdup_printf ("<b>%s</b>\n%s", title, desc);
2165 label = gtk_label_new (NULL);
2166 gtk_label_set_markup (GTK_LABEL (label), txt);
2167 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
2168 gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
2171 gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
2174 if (details != NULL)
2176 GtkWidget *expander;
2178 expander = gtk_expander_new (_("Technical Details"));
2180 txt = g_strdup_printf ("<i>%s</i>", details);
2182 label = gtk_label_new (NULL);
2183 gtk_label_set_markup (GTK_LABEL (label), txt);
2184 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
2185 gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
2188 gtk_container_add (GTK_CONTAINER (expander), label);
2189 gtk_box_pack_start (GTK_BOX (vbox), expander, TRUE, TRUE, 0);
2192 g_signal_connect (info_bar, "response",
2193 G_CALLBACK (gtk_widget_destroy), NULL);
2195 gtk_box_pack_start (GTK_BOX (priv->errors_vbox), info_bar,
2196 FALSE, FALSE, CONTENT_HBOX_CHILDREN_PACKING_PADDING);
2197 gtk_widget_show_all (info_bar);
2201 media_stream_error_to_txt (EmpathyCallWindow *self,
2202 EmpathyTpCall *call,
2204 TpMediaStreamError error)
2206 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2213 case TP_MEDIA_STREAM_ERROR_CODEC_NEGOTIATION_FAILED:
2215 return g_strdup_printf (
2216 _("%s's software does not understand any of the audio formats "
2217 "supported by your computer"),
2218 empathy_contact_get_name (priv->contact));
2220 return g_strdup_printf (
2221 _("%s's software does not understand any of the video formats "
2222 "supported by your computer"),
2223 empathy_contact_get_name (priv->contact));
2225 case TP_MEDIA_STREAM_ERROR_CONNECTION_FAILED:
2226 return g_strdup_printf (
2227 _("Can't establish a connection to %s. "
2228 "One of you might be on a network that does not allow "
2229 "direct connections."),
2230 empathy_contact_get_name (priv->contact));
2232 case TP_MEDIA_STREAM_ERROR_NETWORK_ERROR:
2233 return g_strdup (_("There was a failure on the network"));
2235 case TP_MEDIA_STREAM_ERROR_NO_CODECS:
2237 return g_strdup (_("The audio formats necessary for this call "
2238 "are not installed on your computer"));
2240 return g_strdup (_("The video formats necessary for this call "
2241 "are not installed on your computer"));
2243 case TP_MEDIA_STREAM_ERROR_INVALID_CM_BEHAVIOR:
2244 cm = empathy_tp_call_get_connection_manager (call);
2246 url = g_strdup_printf ("http://bugs.freedesktop.org/enter_bug.cgi?"
2247 "product=Telepathy&component=%s", cm);
2249 result = g_strdup_printf (
2250 _("Something unexpected happened in a Telepathy component. "
2251 "Please <a href=\"%s\">report this bug</a> and attach "
2252 "logs gathered from the 'Debug' window in the Help menu."), url);
2257 case TP_MEDIA_STREAM_ERROR_MEDIA_ERROR:
2258 return g_strdup (_("There was a failure in the call engine"));
2266 empathy_call_window_stream_error (EmpathyCallWindow *self,
2267 EmpathyTpCall *call,
2276 desc = media_stream_error_to_txt (self, call, audio, code);
2279 /* No description, use the error message. That's not great as it's not
2280 * localized but it's better than nothing. */
2281 display_error (self, call, icon, title, msg, NULL);
2285 display_error (self, call, icon, title, desc, msg);
2291 empathy_call_window_audio_stream_error (EmpathyTpCall *call,
2294 EmpathyCallWindow *self)
2296 empathy_call_window_stream_error (self, call, TRUE, code, msg,
2297 "gnome-stock-mic", _("Can't establish audio stream"));
2301 empathy_call_window_video_stream_error (EmpathyTpCall *call,
2304 EmpathyCallWindow *self)
2306 empathy_call_window_stream_error (self, call, FALSE, code, msg,
2307 "camera-web", _("Can't establish video stream"));
2311 empathy_call_window_connected (gpointer user_data)
2313 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2314 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2315 EmpathyTpCall *call;
2316 gboolean can_send_video;
2318 empathy_sound_stop (EMPATHY_SOUND_PHONE_OUTGOING);
2320 can_send_video = priv->video_input != NULL && priv->contact != NULL &&
2321 empathy_contact_can_voip_video (priv->contact);
2323 g_object_get (priv->handler, "tp-call", &call, NULL);
2325 tp_g_signal_connect_object (call, "notify::video-stream",
2326 G_CALLBACK (empathy_call_window_video_stream_changed_cb),
2329 if (empathy_tp_call_has_dtmf (call))
2330 gtk_widget_set_sensitive (priv->dtmf_panel, TRUE);
2332 if (priv->video_input == NULL)
2333 empathy_call_window_set_send_video (self, CAMERA_STATE_OFF);
2335 priv->sending_video = can_send_video ?
2336 empathy_tp_call_is_sending_video (call) : FALSE;
2338 gtk_toggle_tool_button_set_active (
2339 GTK_TOGGLE_TOOL_BUTTON (priv->tool_button_camera_on),
2340 priv->sending_video && priv->video_input != NULL);
2341 gtk_widget_set_sensitive (priv->tool_button_camera_on, can_send_video);
2343 gtk_action_set_sensitive (priv->redial, FALSE);
2344 gtk_widget_set_sensitive (priv->redial_button, FALSE);
2346 gtk_widget_set_sensitive (priv->mic_button, TRUE);
2348 empathy_call_window_update_avatars_visibility (call, self);
2350 g_object_unref (call);
2352 g_mutex_lock (priv->lock);
2354 priv->timer_id = g_timeout_add_seconds (1,
2355 empathy_call_window_update_timer, self);
2357 g_mutex_unlock (priv->lock);
2359 empathy_call_window_update_timer (self);
2365 /* Called from the streaming thread */
2367 empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
2368 GstPad *src, guint media_type, gpointer user_data)
2370 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2371 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2372 gboolean retval = FALSE;
2376 g_mutex_lock (priv->lock);
2378 if (priv->call_state != CONNECTED)
2380 g_timer_start (priv->timer);
2381 priv->timer_id = g_idle_add (empathy_call_window_connected, self);
2382 priv->call_state = CONNECTED;
2387 case TP_MEDIA_STREAM_TYPE_AUDIO:
2388 pad = empathy_call_window_get_audio_sink_pad (self);
2390 case TP_MEDIA_STREAM_TYPE_VIDEO:
2391 gtk_widget_hide (priv->remote_user_avatar_widget);
2392 gtk_widget_show (priv->video_output);
2393 pad = empathy_call_window_get_video_sink_pad (self);
2396 g_assert_not_reached ();
2402 if (GST_PAD_LINK_FAILED (gst_pad_link (src, pad)))
2403 g_warning ("Could not link %s sink pad",
2404 media_type == TP_MEDIA_STREAM_TYPE_AUDIO ? "audio" : "video");
2408 gst_object_unref (pad);
2412 /* If no sink could be linked, try to add fakesink to prevent the whole call
2417 GstElement *fakesink = gst_element_factory_make ("fakesink", NULL);
2419 if (gst_bin_add (GST_BIN (priv->pipeline), fakesink))
2421 GstPad *sinkpad = gst_element_get_static_pad (fakesink, "sink");
2422 if (gst_element_set_state (fakesink, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE ||
2423 GST_PAD_LINK_FAILED (gst_pad_link (src, sinkpad)))
2425 gst_element_set_locked_state (fakesink, TRUE);
2426 gst_element_set_state (fakesink, GST_STATE_NULL);
2427 gst_bin_remove (GST_BIN (priv->pipeline), fakesink);
2431 g_debug ("Could not link real sink, linked fakesink instead");
2433 gst_object_unref (sinkpad);
2437 gst_object_unref (fakesink);
2442 g_mutex_unlock (priv->lock);
2448 empathy_call_window_sink_added_cb (EmpathyCallHandler *handler,
2449 GstPad *sink, guint media_type, gpointer user_data)
2451 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2452 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2454 gboolean retval = FALSE;
2458 case TP_MEDIA_STREAM_TYPE_AUDIO:
2459 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_input))
2461 g_warning ("Could not add audio source to pipeline");
2465 pad = gst_element_get_static_pad (priv->audio_input, "src");
2468 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
2469 g_warning ("Could not get source pad from audio source");
2473 if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
2475 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
2476 g_warning ("Could not link audio source to farsight");
2480 if (gst_element_set_state (priv->audio_input, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2482 g_warning ("Could not start audio source");
2483 gst_element_set_state (priv->audio_input, GST_STATE_NULL);
2484 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
2490 case TP_MEDIA_STREAM_TYPE_VIDEO:
2491 if (priv->video_input != NULL)
2493 if (priv->video_tee != NULL)
2495 pad = gst_element_get_request_pad (priv->video_tee, "src%d");
2496 if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
2498 g_warning ("Could not link videp soure input pipeline");
2501 gst_object_unref (pad);
2508 g_assert_not_reached ();
2515 empathy_call_window_remove_video_input (EmpathyCallWindow *self)
2517 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2518 GstElement *preview;
2520 disable_camera (self);
2522 DEBUG ("remove video input");
2523 preview = empathy_video_widget_get_element (
2524 EMPATHY_VIDEO_WIDGET (priv->video_preview));
2526 gst_element_set_state (priv->video_input, GST_STATE_NULL);
2527 gst_element_set_state (priv->video_tee, GST_STATE_NULL);
2528 gst_element_set_state (preview, GST_STATE_NULL);
2530 gst_bin_remove_many (GST_BIN (priv->pipeline), priv->video_input,
2531 priv->video_tee, preview, NULL);
2533 g_object_unref (priv->video_input);
2534 priv->video_input = NULL;
2535 g_object_unref (priv->video_tee);
2536 priv->video_tee = NULL;
2537 gtk_widget_destroy (priv->video_preview);
2538 priv->video_preview = NULL;
2540 gtk_widget_set_sensitive (priv->tool_button_camera_on, FALSE);
2541 gtk_widget_set_sensitive (priv->tool_button_camera_preview, FALSE);
2545 start_call (EmpathyCallWindow *self)
2547 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2549 priv->call_started = TRUE;
2550 empathy_call_handler_start_call (priv->handler,
2551 gtk_get_current_event_time ());
2553 if (empathy_call_handler_has_initial_video (priv->handler))
2555 /* Enable 'send video' buttons and display the preview */
2556 gtk_toggle_tool_button_set_active (
2557 GTK_TOGGLE_TOOL_BUTTON (priv->tool_button_camera_on), TRUE);
2562 empathy_call_window_bus_message (GstBus *bus, GstMessage *message,
2565 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2566 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2569 empathy_call_handler_bus_message (priv->handler, bus, message);
2571 switch (GST_MESSAGE_TYPE (message))
2573 case GST_MESSAGE_STATE_CHANGED:
2574 if (GST_MESSAGE_SRC (message) == GST_OBJECT (priv->video_input))
2576 gst_message_parse_state_changed (message, NULL, &newstate, NULL);
2577 if (newstate == GST_STATE_PAUSED)
2578 empathy_call_window_setup_video_input (self);
2580 if (GST_MESSAGE_SRC (message) == GST_OBJECT (priv->pipeline) &&
2581 !priv->call_started)
2583 gst_message_parse_state_changed (message, NULL, &newstate, NULL);
2584 if (newstate == GST_STATE_PAUSED)
2586 gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
2587 priv->pipeline_playing = TRUE;
2589 if (priv->start_call_when_playing)
2594 case GST_MESSAGE_ERROR:
2596 GError *error = NULL;
2597 GstElement *gst_error;
2600 gst_message_parse_error (message, &error, &debug);
2601 gst_error = GST_ELEMENT (GST_MESSAGE_SRC (message));
2603 g_message ("Element error: %s -- %s\n", error->message, debug);
2605 if (g_str_has_prefix (gst_element_get_name (gst_error),
2606 VIDEO_INPUT_ERROR_PREFIX))
2608 /* Remove the video input and continue */
2609 if (priv->video_input != NULL)
2610 empathy_call_window_remove_video_input (self);
2611 gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
2615 empathy_call_window_disconnected (self, TRUE);
2617 g_error_free (error);
2628 empathy_call_window_update_avatars_visibility (EmpathyTpCall *call,
2629 EmpathyCallWindow *window)
2631 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2633 if (empathy_tp_call_is_receiving_video (call))
2635 gtk_widget_hide (priv->remote_user_avatar_widget);
2636 gtk_widget_show (priv->video_output);
2640 gtk_widget_hide (priv->video_output);
2641 gtk_widget_show (priv->remote_user_avatar_widget);
2646 call_handler_notify_tp_call_cb (EmpathyCallHandler *handler,
2648 EmpathyCallWindow *self)
2650 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2651 EmpathyTpCall *call;
2653 g_object_get (priv->handler, "tp-call", &call, NULL);
2657 tp_g_signal_connect_object (call, "audio-stream-error",
2658 G_CALLBACK (empathy_call_window_audio_stream_error), self, 0);
2659 tp_g_signal_connect_object (call, "video-stream-error",
2660 G_CALLBACK (empathy_call_window_video_stream_error), self, 0);
2662 g_object_unref (call);
2666 empathy_call_window_realized_cb (GtkWidget *widget, EmpathyCallWindow *window)
2668 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2669 EmpathyTpCall *call;
2671 g_signal_connect (priv->handler, "conference-added",
2672 G_CALLBACK (empathy_call_window_conference_added_cb), window);
2673 g_signal_connect (priv->handler, "request-resource",
2674 G_CALLBACK (empathy_call_window_request_resource_cb), window);
2675 g_signal_connect (priv->handler, "closed",
2676 G_CALLBACK (empathy_call_window_channel_closed_cb), window);
2677 g_signal_connect (priv->handler, "src-pad-added",
2678 G_CALLBACK (empathy_call_window_src_added_cb), window);
2679 g_signal_connect (priv->handler, "sink-pad-added",
2680 G_CALLBACK (empathy_call_window_sink_added_cb), window);
2681 g_signal_connect (priv->handler, "stream-closed",
2682 G_CALLBACK (empathy_call_window_channel_stream_closed_cb), window);
2684 g_object_get (priv->handler, "tp-call", &call, NULL);
2687 tp_g_signal_connect_object (call, "audio-stream-error",
2688 G_CALLBACK (empathy_call_window_audio_stream_error), window,
2690 tp_g_signal_connect_object (call, "video-stream-error",
2691 G_CALLBACK (empathy_call_window_video_stream_error), window,
2694 g_object_unref (call);
2698 /* tp-call doesn't exist yet, we'll connect signals once it has been
2700 g_signal_connect (priv->handler, "notify::tp-call",
2701 G_CALLBACK (call_handler_notify_tp_call_cb), window);
2704 gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
2708 empathy_call_window_delete_cb (GtkWidget *widget, GdkEvent*event,
2709 EmpathyCallWindow *window)
2711 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2713 if (priv->pipeline != NULL)
2715 if (priv->bus_message_source_id != 0)
2717 g_source_remove (priv->bus_message_source_id);
2718 priv->bus_message_source_id = 0;
2721 gst_element_set_state (priv->pipeline, GST_STATE_NULL);
2724 if (priv->call_state == CONNECTING)
2725 empathy_sound_stop (EMPATHY_SOUND_PHONE_OUTGOING);
2731 show_controls (EmpathyCallWindow *window, gboolean set_fullscreen)
2734 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2736 menu = gtk_ui_manager_get_widget (priv->ui_manager,
2741 gtk_widget_hide (priv->sidebar);
2742 gtk_widget_hide (menu);
2743 gtk_widget_hide (priv->vbox);
2744 gtk_widget_hide (priv->statusbar);
2745 gtk_widget_hide (priv->toolbar);
2749 if (priv->sidebar_was_visible_before_fs)
2750 gtk_widget_show (priv->sidebar);
2752 gtk_widget_show (menu);
2753 gtk_widget_show (priv->vbox);
2754 gtk_widget_show (priv->statusbar);
2755 gtk_widget_show (priv->toolbar);
2757 gtk_window_resize (GTK_WINDOW (window), priv->original_width_before_fs,
2758 priv->original_height_before_fs);
2763 show_borders (EmpathyCallWindow *window, gboolean set_fullscreen)
2765 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2767 gtk_container_set_border_width (GTK_CONTAINER (priv->content_hbox),
2768 set_fullscreen ? 0 : CONTENT_HBOX_BORDER_WIDTH);
2769 gtk_box_set_spacing (GTK_BOX (priv->content_hbox),
2770 set_fullscreen ? 0 : CONTENT_HBOX_SPACING);
2771 gtk_box_set_child_packing (GTK_BOX (priv->content_hbox),
2772 priv->video_output, TRUE, TRUE,
2773 set_fullscreen ? 0 : CONTENT_HBOX_CHILDREN_PACKING_PADDING,
2775 gtk_box_set_child_packing (GTK_BOX (priv->content_hbox),
2776 priv->vbox, TRUE, TRUE,
2777 set_fullscreen ? 0 : CONTENT_HBOX_CHILDREN_PACKING_PADDING,
2782 empathy_call_window_state_event_cb (GtkWidget *widget,
2783 GdkEventWindowState *event, EmpathyCallWindow *window)
2785 if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
2787 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2788 gboolean set_fullscreen = event->new_window_state &
2789 GDK_WINDOW_STATE_FULLSCREEN;
2793 gboolean sidebar_was_visible;
2794 GtkAllocation allocation;
2795 gint original_width, original_height;
2797 gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
2798 original_width = allocation.width;
2799 original_height = allocation.height;
2801 g_object_get (priv->sidebar, "visible", &sidebar_was_visible, NULL);
2803 priv->sidebar_was_visible_before_fs = sidebar_was_visible;
2804 priv->original_width_before_fs = original_width;
2805 priv->original_height_before_fs = original_height;
2807 if (priv->video_output_motion_handler_id == 0 &&
2808 priv->video_output != NULL)
2810 priv->video_output_motion_handler_id = g_signal_connect (
2811 G_OBJECT (priv->video_output), "motion-notify-event",
2812 G_CALLBACK (empathy_call_window_video_output_motion_notify),
2818 if (priv->video_output_motion_handler_id != 0)
2820 g_signal_handler_disconnect (G_OBJECT (priv->video_output),
2821 priv->video_output_motion_handler_id);
2822 priv->video_output_motion_handler_id = 0;
2826 empathy_call_window_fullscreen_set_fullscreen (priv->fullscreen,
2828 show_controls (window, set_fullscreen);
2829 show_borders (window, set_fullscreen);
2830 gtk_action_set_stock_id (priv->menu_fullscreen,
2831 (set_fullscreen ? "gtk-leave-fullscreen" : "gtk-fullscreen"));
2832 priv->is_fullscreen = set_fullscreen;
2839 empathy_call_window_sidebar_toggled_cb (GtkToggleButton *toggle,
2840 EmpathyCallWindow *window)
2842 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2844 int w, h, handle_size;
2845 GtkAllocation allocation, sidebar_allocation;
2847 gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
2848 w = allocation.width;
2849 h = allocation.height;
2851 gtk_widget_style_get (priv->pane, "handle_size", &handle_size, NULL);
2853 gtk_widget_get_allocation (priv->sidebar, &sidebar_allocation);
2854 if (gtk_toggle_button_get_active (toggle))
2856 arrow = gtk_arrow_new (GTK_ARROW_LEFT, GTK_SHADOW_NONE);
2857 gtk_widget_show (priv->sidebar);
2858 w += sidebar_allocation.width + handle_size;
2862 arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
2863 w -= sidebar_allocation.width + handle_size;
2864 gtk_widget_hide (priv->sidebar);
2867 gtk_button_set_image (GTK_BUTTON (priv->sidebar_button), arrow);
2870 gtk_window_resize (GTK_WINDOW (window), w, h);
2874 empathy_call_window_set_send_video (EmpathyCallWindow *window,
2877 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2878 EmpathyTpCall *call;
2880 priv->sending_video = (state == CAMERA_STATE_ON);
2882 if (state == CAMERA_STATE_PREVIEW ||
2883 state == CAMERA_STATE_ON)
2885 /* When we start sending video, we want to show the video preview by
2887 display_video_preview (window, TRUE);
2891 display_video_preview (window, FALSE);
2894 if (priv->call_state != CONNECTED)
2897 g_object_get (priv->handler, "tp-call", &call, NULL);
2898 DEBUG ("%s sending video", priv->sending_video ? "start": "stop");
2899 empathy_tp_call_request_video_stream_direction (call, priv->sending_video);
2900 g_object_unref (call);
2904 empathy_call_window_mic_toggled_cb (GtkToggleToolButton *toggle,
2905 EmpathyCallWindow *window)
2907 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2910 active = (gtk_toggle_tool_button_get_active (toggle));
2914 empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
2916 gtk_adjustment_set_value (priv->audio_input_adj, priv->volume * 100);
2920 /* TODO, Instead of setting the input volume to 0 we should probably
2921 * stop sending but this would cause the audio call to drop if both
2922 * sides mute at the same time on certain CMs AFAIK. Need to revisit this
2923 * in the future. GNOME #574574
2925 empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
2927 gtk_adjustment_set_value (priv->audio_input_adj, 0);
2932 empathy_call_window_sidebar_hidden_cb (EmpathySidebar *sidebar,
2933 EmpathyCallWindow *window)
2935 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2937 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->sidebar_button),
2942 empathy_call_window_sidebar_shown_cb (EmpathySidebar *sidebar,
2943 EmpathyCallWindow *window)
2945 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2947 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->sidebar_button),
2952 empathy_call_window_hangup_cb (gpointer object,
2953 EmpathyCallWindow *window)
2955 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2957 empathy_call_handler_stop_call (priv->handler);
2959 if (empathy_call_window_disconnected (window, FALSE))
2960 gtk_widget_destroy (GTK_WIDGET (window));
2964 empathy_call_window_restart_call (EmpathyCallWindow *window)
2966 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2968 create_video_output_widget (window);
2970 g_signal_connect (G_OBJECT (priv->audio_input_adj), "value-changed",
2971 G_CALLBACK (empathy_call_window_mic_volume_changed_cb), window);
2973 /* While the call was disconnected, the input volume might have changed.
2974 * However, since the audio_input source was destroyed, its volume has not
2975 * been updated during that time. That's why we manually update it here */
2976 empathy_call_window_mic_volume_changed_cb (priv->audio_input_adj, window);
2978 priv->outgoing = TRUE;
2979 empathy_call_window_set_state_connecting (window);
2981 if (priv->pipeline_playing)
2982 start_call (window);
2984 /* call will be started when the pipeline is ready */
2985 priv->start_call_when_playing = TRUE;
2988 empathy_call_window_setup_avatars (window, priv->handler);
2990 gtk_action_set_sensitive (priv->redial, FALSE);
2991 gtk_widget_set_sensitive (priv->redial_button, FALSE);
2995 empathy_call_window_redial_cb (gpointer object,
2996 EmpathyCallWindow *window)
2998 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3000 if (priv->call_state == CONNECTED)
3001 priv->call_state = REDIALING;
3003 empathy_call_handler_stop_call (priv->handler);
3005 if (priv->call_state != CONNECTED)
3006 empathy_call_window_restart_call (window);
3010 empathy_call_window_fullscreen_cb (gpointer object,
3011 EmpathyCallWindow *window)
3013 empathy_call_window_fullscreen_toggle (window);
3017 empathy_call_window_fullscreen_toggle (EmpathyCallWindow *window)
3019 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3021 if (priv->is_fullscreen)
3022 gtk_window_unfullscreen (GTK_WINDOW (window));
3024 gtk_window_fullscreen (GTK_WINDOW (window));
3028 empathy_call_window_video_button_press_cb (GtkWidget *video_output,
3029 GdkEventButton *event, EmpathyCallWindow *window)
3031 if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
3033 empathy_call_window_video_menu_popup (window, event->button);
3041 empathy_call_window_key_press_cb (GtkWidget *video_output,
3042 GdkEventKey *event, EmpathyCallWindow *window)
3044 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3046 if (priv->is_fullscreen && event->keyval == GDK_Escape)
3048 /* Since we are in fullscreen mode, toggling will bring us back to
3050 empathy_call_window_fullscreen_toggle (window);
3058 empathy_call_window_video_output_motion_notify (GtkWidget *widget,
3059 GdkEventMotion *event, EmpathyCallWindow *window)
3061 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3063 if (priv->is_fullscreen)
3065 empathy_call_window_fullscreen_show_popup (priv->fullscreen);
3072 empathy_call_window_video_menu_popup (EmpathyCallWindow *window,
3076 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3078 menu = gtk_ui_manager_get_widget (priv->ui_manager,
3080 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
3081 button, gtk_get_current_event_time ());
3082 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
3086 empathy_call_window_status_message (EmpathyCallWindow *window,
3089 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3091 if (priv->context_id == 0)
3093 priv->context_id = gtk_statusbar_get_context_id (
3094 GTK_STATUSBAR (priv->statusbar), "voip call status messages");
3098 gtk_statusbar_pop (GTK_STATUSBAR (priv->statusbar), priv->context_id);
3101 gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar), priv->context_id,
3106 empathy_call_window_volume_changed_cb (GtkScaleButton *button,
3107 gdouble value, EmpathyCallWindow *window)
3109 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3111 if (priv->audio_output == NULL)
3114 empathy_audio_sink_set_volume (EMPATHY_GST_AUDIO_SINK (priv->audio_output),
3118 /* block all the signals related to camera control widgets. This is useful
3119 * when we are manually updating the UI and so don't want to fire the
3122 block_camera_control_signals (EmpathyCallWindow *self)
3124 EmpathyCallWindowPriv *priv = GET_PRIV (self);
3126 g_signal_handlers_block_by_func (priv->tool_button_camera_off,
3127 tool_button_camera_off_toggled_cb, self);
3128 g_signal_handlers_block_by_func (priv->tool_button_camera_preview,
3129 tool_button_camera_preview_toggled_cb, self);
3130 g_signal_handlers_block_by_func (priv->tool_button_camera_on,
3131 tool_button_camera_on_toggled_cb, self);
3132 g_signal_handlers_block_by_func (priv->action_camera,
3133 action_camera_change_cb, self);
3137 unblock_camera_control_signals (EmpathyCallWindow *self)
3139 EmpathyCallWindowPriv *priv = GET_PRIV (self);
3141 g_signal_handlers_unblock_by_func (priv->tool_button_camera_off,
3142 tool_button_camera_off_toggled_cb, self);
3143 g_signal_handlers_unblock_by_func (priv->tool_button_camera_preview,
3144 tool_button_camera_preview_toggled_cb, self);
3145 g_signal_handlers_unblock_by_func (priv->tool_button_camera_on,
3146 tool_button_camera_on_toggled_cb, self);
3147 g_signal_handlers_unblock_by_func (priv->action_camera,
3148 action_camera_change_cb, self);