2 * empathy-call-window.c - Source for EmpathyCallWindow
3 * Copyright (C) 2008-2011 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 <clutter/clutter.h>
33 #include <clutter-gtk/clutter-gtk.h>
34 #include <clutter-gst/clutter-gst.h>
36 #include <telepathy-glib/util.h>
37 #include <telepathy-farstream/telepathy-farstream.h>
38 #include <telepathy-glib/util.h>
40 #include <gst/farsight/fs-element-added-notifier.h>
41 #include <gst/farsight/fs-utils.h>
43 #include <libempathy/empathy-camera-monitor.h>
44 #include <libempathy/empathy-gsettings.h>
45 #include <libempathy/empathy-tp-contact-factory.h>
46 #include <libempathy/empathy-utils.h>
48 #include <libempathy-gtk/empathy-avatar-image.h>
49 #include <libempathy-gtk/empathy-ui-utils.h>
50 #include <libempathy-gtk/empathy-sound-manager.h>
51 #include <libempathy-gtk/empathy-geometry.h>
52 #include <libempathy-gtk/empathy-images.h>
54 #define DEBUG_FLAG EMPATHY_DEBUG_VOIP
55 #include <libempathy/empathy-debug.h>
57 #include "empathy-call-window.h"
58 #include "empathy-call-window-fullscreen.h"
59 #include "empathy-call-factory.h"
60 #include "empathy-video-widget.h"
61 #include "empathy-audio-src.h"
62 #include "empathy-audio-sink.h"
63 #include "empathy-video-src.h"
64 #include "ev-sidebar.h"
66 #define CONTENT_HBOX_BORDER_WIDTH 6
67 #define CONTENT_HBOX_SPACING 3
68 #define CONTENT_HBOX_CHILDREN_PACKING_PADDING 3
70 #define SELF_VIDEO_SECTION_WIDTH 120
71 #define SELF_VIDEO_SECTION_HEIGTH 90
73 /* The avatar's default width and height are set to the same value because we
74 want a square icon. */
75 #define REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH EMPATHY_VIDEO_WIDGET_DEFAULT_HEIGHT
76 #define REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT \
77 EMPATHY_VIDEO_WIDGET_DEFAULT_HEIGHT
79 #define SMALL_TOOLBAR_SIZE 36
81 /* If an video input error occurs, the error message will start with "v4l" */
82 #define VIDEO_INPUT_ERROR_PREFIX "v4l"
84 /* The time interval in milliseconds between 2 outgoing rings */
85 #define MS_BETWEEN_RING 500
87 G_DEFINE_TYPE(EmpathyCallWindow, empathy_call_window, GTK_TYPE_WINDOW)
90 PROP_CALL_HANDLER = 1,
102 CAMERA_STATE_OFF = 0,
106 struct _EmpathyCallWindowPriv
108 gboolean dispose_has_run;
109 EmpathyCallHandler *handler;
111 EmpathyContact *contact;
113 EmpathyCameraMonitor *camera_monitor;
118 GtkUIManager *ui_manager;
119 GtkWidget *errors_vbox;
120 /* widget displays the video received from the remote user. This widget is
121 * alive only during call. */
122 ClutterActor *video_output;
123 ClutterActor *video_preview;
124 ClutterActor *preview_hidden_button;
125 GtkWidget *video_container;
126 GtkWidget *remote_user_avatar_widget;
127 GtkWidget *remote_user_avatar_toolbar;
128 GtkWidget *remote_user_name_toolbar;
130 GtkWidget *status_label;
131 GtkWidget *hangup_button;
132 GtkWidget *audio_call_button;
133 GtkWidget *video_call_button;
134 GtkWidget *mic_button;
135 GtkWidget *camera_button;
136 GtkWidget *dialpad_button;
138 GtkWidget *bottom_toolbar;
140 GtkAction *menu_sidebar;
141 GtkAction *menu_fullscreen;
143 /* The box that contains self and remote avatar and video
144 input/output. When we redial, we destroy and re-create the box */
145 ClutterActor *video_box;
146 ClutterLayoutManager *video_layout;
148 /* We keep a reference on the hbox which contains the main content so we can
149 easilly repack everything when toggling fullscreen */
150 GtkWidget *content_hbox;
152 gulong video_output_motion_handler_id;
153 guint bus_message_source_id;
157 GtkWidget *dtmf_panel;
160 GtkWidget *details_vbox;
161 GtkWidget *vcodec_encoding_label;
162 GtkWidget *acodec_encoding_label;
163 GtkWidget *vcodec_decoding_label;
164 GtkWidget *acodec_decoding_label;
166 GtkWidget *audio_remote_candidate_label;
167 GtkWidget *audio_local_candidate_label;
168 GtkWidget *video_remote_candidate_label;
169 GtkWidget *video_local_candidate_label;
170 GtkWidget *video_remote_candidate_info_img;
171 GtkWidget *video_local_candidate_info_img;
172 GtkWidget *audio_remote_candidate_info_img;
173 GtkWidget *audio_local_candidate_info_img;
175 GstElement *video_input;
176 GstElement *video_preview_sink;
177 GstElement *video_output_sink;
178 GstElement *audio_input;
179 GstElement *audio_output;
180 GstElement *pipeline;
181 GstElement *video_tee;
190 GtkWidget *video_contrast;
191 GtkWidget *video_brightness;
192 GtkWidget *video_gamma;
195 gboolean call_started;
196 gboolean sending_video;
197 CameraState camera_state;
199 EmpathyCallWindowFullscreen *fullscreen;
200 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 gint x, y, w, h, sidebar_width;
214 /* TRUE if the call should be started when the pipeline is playing */
215 gboolean start_call_when_playing;
216 /* TRUE if we requested to set the pipeline in the playing state */
217 gboolean pipeline_playing;
219 EmpathySoundManager *sound_mgr;
224 #define GET_PRIV(o) (EMPATHY_CALL_WINDOW (o)->priv)
226 static void empathy_call_window_realized_cb (GtkWidget *widget,
227 EmpathyCallWindow *window);
229 static gboolean empathy_call_window_delete_cb (GtkWidget *widget,
230 GdkEvent *event, EmpathyCallWindow *window);
232 static gboolean empathy_call_window_state_event_cb (GtkWidget *widget,
233 GdkEventWindowState *event, EmpathyCallWindow *window);
235 static void empathy_call_window_set_send_video (EmpathyCallWindow *window,
238 static void empathy_call_window_mic_toggled_cb (
239 GtkToggleToolButton *toggle, EmpathyCallWindow *window);
241 static void empathy_call_window_sidebar_cb (GtkToggleAction *menu,
242 EmpathyCallWindow *self);
244 static void empathy_call_window_sidebar_hidden_cb (EvSidebar *sidebar,
245 EmpathyCallWindow *window);
247 static void empathy_call_window_sidebar_shown_cb (EvSidebar *sidebar,
248 EmpathyCallWindow *window);
250 static void empathy_call_window_sidebar_changed_cb (EvSidebar *sidebar,
252 EmpathyCallWindow *window);
254 static void empathy_call_window_hangup_cb (gpointer object,
255 EmpathyCallWindow *window);
257 static void empathy_call_window_fullscreen_cb (gpointer object,
258 EmpathyCallWindow *window);
260 static void empathy_call_window_fullscreen_toggle (EmpathyCallWindow *window);
262 static gboolean empathy_call_window_video_button_press_cb (
263 GtkWidget *video_output, GdkEventButton *event, EmpathyCallWindow *window);
265 static gboolean empathy_call_window_key_press_cb (GtkWidget *video_output,
266 GdkEventKey *event, EmpathyCallWindow *window);
268 static gboolean empathy_call_window_video_output_motion_notify (
269 GtkWidget *widget, GdkEventMotion *event, EmpathyCallWindow *window);
271 static void empathy_call_window_video_menu_popup (EmpathyCallWindow *window,
274 static void empathy_call_window_dialpad_cb (GtkToggleToolButton *button,
275 EmpathyCallWindow *window);
277 static void empathy_call_window_restart_call (EmpathyCallWindow *window);
279 static void empathy_call_window_status_message (EmpathyCallWindow *window,
282 static gboolean empathy_call_window_bus_message (GstBus *bus,
283 GstMessage *message, gpointer user_data);
286 empathy_call_window_volume_changed_cb (GtkScaleButton *button,
287 gdouble value, EmpathyCallWindow *window);
290 empathy_call_window_show_hangup_button (EmpathyCallWindow *self,
293 gtk_widget_set_visible (self->priv->hangup_button, show);
294 gtk_widget_set_visible (self->priv->audio_call_button, !show);
295 gtk_widget_set_visible (self->priv->video_call_button, !show);
299 empathy_call_window_audio_call_cb (GtkToggleToolButton *button,
300 EmpathyCallWindow *self)
302 g_object_set (self->priv->handler, "initial-video", FALSE, NULL);
303 empathy_call_window_restart_call (self);
307 empathy_call_window_video_call_cb (GtkToggleToolButton *button,
308 EmpathyCallWindow *self)
310 empathy_call_window_set_send_video (self, CAMERA_STATE_ON);
311 g_object_set (self->priv->handler, "initial-video", TRUE, NULL);
312 empathy_call_window_restart_call (self);
316 dtmf_button_pressed_cb (GtkButton *button, EmpathyCallWindow *window)
318 EmpathyCallWindowPriv *priv = GET_PRIV (window);
319 TpyCallChannel *call;
323 g_object_get (priv->handler, "call-channel", &call, NULL);
325 button_quark = g_quark_from_static_string (EMPATHY_DTMF_BUTTON_ID);
326 event = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (button),
329 tpy_call_channel_dtmf_start_tone (call, event);
331 g_object_unref (call);
335 dtmf_button_released_cb (GtkButton *button, EmpathyCallWindow *window)
337 EmpathyCallWindowPriv *priv = GET_PRIV (window);
338 TpyCallChannel *call;
340 g_object_get (priv->handler, "call-channel", &call, NULL);
342 tpy_call_channel_dtmf_stop_tone (call);
344 g_object_unref (call);
348 empathy_call_window_create_video_input_add_slider (EmpathyCallWindow *self,
349 gchar *label_text, GtkWidget *bin)
351 GtkWidget *vbox = gtk_vbox_new (FALSE, 2);
352 GtkWidget *scale = gtk_vscale_new_with_range (0, 100, 10);
353 GtkWidget *label = gtk_label_new (label_text);
355 gtk_widget_set_sensitive (scale, FALSE);
357 gtk_container_add (GTK_CONTAINER (bin), vbox);
359 gtk_range_set_inverted (GTK_RANGE (scale), TRUE);
360 gtk_box_pack_start (GTK_BOX (vbox), scale, TRUE, TRUE, 0);
361 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
367 empathy_call_window_video_contrast_changed_cb (GtkAdjustment *adj,
368 EmpathyCallWindow *self)
371 EmpathyCallWindowPriv *priv = GET_PRIV (self);
373 empathy_video_src_set_channel (priv->video_input,
374 EMPATHY_GST_VIDEO_SRC_CHANNEL_CONTRAST, gtk_adjustment_get_value (adj));
378 empathy_call_window_video_brightness_changed_cb (GtkAdjustment *adj,
379 EmpathyCallWindow *self)
382 EmpathyCallWindowPriv *priv = GET_PRIV (self);
384 empathy_video_src_set_channel (priv->video_input,
385 EMPATHY_GST_VIDEO_SRC_CHANNEL_BRIGHTNESS, gtk_adjustment_get_value (adj));
389 empathy_call_window_video_gamma_changed_cb (GtkAdjustment *adj,
390 EmpathyCallWindow *self)
393 EmpathyCallWindowPriv *priv = GET_PRIV (self);
395 empathy_video_src_set_channel (priv->video_input,
396 EMPATHY_GST_VIDEO_SRC_CHANNEL_GAMMA, gtk_adjustment_get_value (adj));
401 empathy_call_window_create_video_input (EmpathyCallWindow *self)
403 EmpathyCallWindowPriv *priv = GET_PRIV (self);
406 hbox = gtk_hbox_new (TRUE, 3);
408 priv->video_contrast = empathy_call_window_create_video_input_add_slider (
409 self, _("Contrast"), hbox);
411 priv->video_brightness = empathy_call_window_create_video_input_add_slider (
412 self, _("Brightness"), hbox);
414 priv->video_gamma = empathy_call_window_create_video_input_add_slider (
415 self, _("Gamma"), hbox);
421 empathy_call_window_setup_video_input (EmpathyCallWindow *self)
423 EmpathyCallWindowPriv *priv = GET_PRIV (self);
427 supported = empathy_video_src_get_supported_channels (priv->video_input);
429 if (supported & EMPATHY_GST_VIDEO_SRC_SUPPORTS_CONTRAST)
431 adj = gtk_range_get_adjustment (GTK_RANGE (priv->video_contrast));
433 gtk_adjustment_set_value (adj,
434 empathy_video_src_get_channel (priv->video_input,
435 EMPATHY_GST_VIDEO_SRC_CHANNEL_CONTRAST));
437 g_signal_connect (G_OBJECT (adj), "value-changed",
438 G_CALLBACK (empathy_call_window_video_contrast_changed_cb), self);
440 gtk_widget_set_sensitive (priv->video_contrast, TRUE);
443 if (supported & EMPATHY_GST_VIDEO_SRC_SUPPORTS_BRIGHTNESS)
445 adj = gtk_range_get_adjustment (GTK_RANGE (priv->video_brightness));
447 gtk_adjustment_set_value (adj,
448 empathy_video_src_get_channel (priv->video_input,
449 EMPATHY_GST_VIDEO_SRC_CHANNEL_BRIGHTNESS));
451 g_signal_connect (G_OBJECT (adj), "value-changed",
452 G_CALLBACK (empathy_call_window_video_brightness_changed_cb), self);
453 gtk_widget_set_sensitive (priv->video_brightness, TRUE);
456 if (supported & EMPATHY_GST_VIDEO_SRC_SUPPORTS_GAMMA)
458 adj = gtk_range_get_adjustment (GTK_RANGE (priv->video_gamma));
460 gtk_adjustment_set_value (adj,
461 empathy_video_src_get_channel (priv->video_input,
462 EMPATHY_GST_VIDEO_SRC_CHANNEL_GAMMA));
464 g_signal_connect (G_OBJECT (adj), "value-changed",
465 G_CALLBACK (empathy_call_window_video_gamma_changed_cb), self);
466 gtk_widget_set_sensitive (priv->video_gamma, TRUE);
471 empathy_call_window_mic_volume_changed (EmpathyCallWindow *self)
473 EmpathyCallWindowPriv *priv = GET_PRIV (self);
476 volume = g_settings_get_double (priv->settings,
477 EMPATHY_PREFS_CALL_SOUND_VOLUME) / 100.0;
479 /* Don't store the volume because of muting */
480 if (volume > 0 || gtk_toggle_tool_button_get_active (
481 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
482 priv->volume = volume;
484 /* Ensure that the toggle button is active if the volume is > 0 and inactive
485 * if it's smaller than 0 */
486 if ((volume > 0) != gtk_toggle_tool_button_get_active (
487 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
488 gtk_toggle_tool_button_set_active (
489 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button), volume > 0);
491 empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
496 empathy_call_window_prefs_volume_changed_cb (GSettings *settings,
498 EmpathyCallWindow *self)
500 empathy_call_window_mic_volume_changed (self);
504 empathy_call_window_show_video_output (EmpathyCallWindow *self,
507 if (self->priv->video_output != NULL)
508 g_object_set (self->priv->video_output, "visible", show, NULL);
510 gtk_widget_set_visible (self->priv->remote_user_avatar_widget, !show);
514 create_video_output_widget (EmpathyCallWindow *self)
516 EmpathyCallWindowPriv *priv = GET_PRIV (self);
518 g_assert (priv->video_output == NULL);
519 g_assert (priv->pipeline != NULL);
521 priv->video_output = clutter_texture_new ();
523 clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (priv->video_output),
526 priv->video_output_sink = clutter_gst_video_sink_new (
527 CLUTTER_TEXTURE (priv->video_output));
529 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_box),
532 gtk_widget_add_events (priv->video_container,
533 GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK);
534 g_signal_connect (G_OBJECT (priv->video_container), "button-press-event",
535 G_CALLBACK (empathy_call_window_video_button_press_cb), self);
539 create_video_input (EmpathyCallWindow *self)
541 EmpathyCallWindowPriv *priv = GET_PRIV (self);
543 g_assert (priv->video_input == NULL);
544 priv->video_input = empathy_video_src_new ();
545 gst_object_ref (priv->video_input);
546 gst_object_sink (priv->video_input);
550 create_audio_input (EmpathyCallWindow *self)
552 EmpathyCallWindowPriv *priv = GET_PRIV (self);
554 g_assert (priv->audio_input == NULL);
555 priv->audio_input = empathy_audio_src_new ();
556 gst_object_ref (priv->audio_input);
557 gst_object_sink (priv->audio_input);
561 add_video_preview_to_pipeline (EmpathyCallWindow *self)
563 EmpathyCallWindowPriv *priv = GET_PRIV (self);
566 g_assert (priv->video_preview != NULL);
567 g_assert (priv->pipeline != NULL);
568 g_assert (priv->video_input != NULL);
569 g_assert (priv->video_tee != NULL);
571 preview = priv->video_preview_sink;
573 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->video_input))
575 g_warning ("Could not add video input to pipeline");
579 if (!gst_bin_add (GST_BIN (priv->pipeline), preview))
581 g_warning ("Could not add video preview to pipeline");
585 if (!gst_element_link (priv->video_input, priv->video_tee))
587 g_warning ("Could not link video input to video tee");
591 if (!gst_element_link (priv->video_tee, preview))
593 g_warning ("Could not link video tee to video preview");
599 empathy_call_window_disable_camera_cb (GtkAction *action,
600 EmpathyCallWindow *self)
602 clutter_actor_destroy (self->priv->preview_hidden_button);
604 gtk_toggle_tool_button_set_active (
605 GTK_TOGGLE_TOOL_BUTTON (self->priv->camera_button), FALSE);
609 empathy_call_window_minimise_camera_cb (GtkAction *action,
610 EmpathyCallWindow *self)
612 clutter_actor_hide (self->priv->video_preview);
613 clutter_actor_show (self->priv->preview_hidden_button);
617 empathy_call_window_maximise_camera_cb (GtkAction *action,
618 EmpathyCallWindow *self)
620 clutter_actor_show (self->priv->video_preview);
621 clutter_actor_hide (self->priv->preview_hidden_button);
625 empathy_call_window_preview_button_clicked_cb (GtkButton *button,
626 EmpathyCallWindow *self)
630 menu = gtk_ui_manager_get_widget (self->priv->ui_manager,
632 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
633 0, gtk_get_current_event_time ());
634 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
638 empathy_call_window_preview_hidden_button_clicked_cb (GtkButton *button,
639 EmpathyCallWindow *self)
643 menu = gtk_ui_manager_get_widget (self->priv->ui_manager,
644 "/preview-hidden-menu");
645 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
646 0, gtk_get_current_event_time ());
647 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
651 create_video_preview (EmpathyCallWindow *self)
653 EmpathyCallWindowPriv *priv = GET_PRIV (self);
654 ClutterLayoutManager *layout, *layout_center;
655 ClutterActor *preview;
660 g_assert (priv->video_preview == NULL);
662 preview = clutter_texture_new ();
663 clutter_actor_set_size (preview,
664 SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGTH);
665 priv->video_preview_sink = clutter_gst_video_sink_new (
666 CLUTTER_TEXTURE (preview));
668 /* Flip the video preview */
669 clutter_actor_set_rotation (preview,
672 SELF_VIDEO_SECTION_WIDTH * 0.5,
676 /* Add a little offset to the video preview */
677 layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_END,
678 CLUTTER_BIN_ALIGNMENT_START);
679 priv->video_preview = clutter_box_new (layout);
680 clutter_actor_set_size (priv->video_preview,
681 SELF_VIDEO_SECTION_WIDTH + 10, SELF_VIDEO_SECTION_HEIGTH + 10);
683 layout_center = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
684 CLUTTER_BIN_ALIGNMENT_CENTER);
685 box = clutter_box_new (layout_center);
686 clutter_actor_set_size (box,
687 SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGTH);
689 clutter_container_add_actor (CLUTTER_CONTAINER (box), preview);
690 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_preview), box);
692 g_object_set (priv->video_preview_sink,
697 /* Translators: this is an "Info" label. It should be as short
699 button = gtk_button_new_with_label (_("i"));
700 b = gtk_clutter_actor_new_with_contents (button);
702 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (layout_center),
704 CLUTTER_BIN_ALIGNMENT_END,
705 CLUTTER_BIN_ALIGNMENT_END);
707 g_signal_connect (button, "clicked",
708 G_CALLBACK (empathy_call_window_preview_button_clicked_cb),
711 /* Translators: this is an "Info" label. It should be as short
713 button = gtk_button_new_with_label (_("i"));
714 priv->preview_hidden_button =
715 gtk_clutter_actor_new_with_contents (button);
717 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
718 priv->preview_hidden_button,
719 CLUTTER_BIN_ALIGNMENT_START,
720 CLUTTER_BIN_ALIGNMENT_END);
722 clutter_actor_hide (priv->preview_hidden_button);
724 g_signal_connect (button, "clicked",
725 G_CALLBACK (empathy_call_window_preview_hidden_button_clicked_cb),
728 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
730 CLUTTER_BIN_ALIGNMENT_START,
731 CLUTTER_BIN_ALIGNMENT_END);
735 play_camera (EmpathyCallWindow *window,
738 EmpathyCallWindowPriv *priv = GET_PRIV (window);
742 if (priv->video_preview == NULL)
744 create_video_preview (window);
745 add_video_preview_to_pipeline (window);
749 state = GST_STATE_PLAYING;
751 state = GST_STATE_NULL;
753 preview = priv->video_preview_sink;
755 gst_element_set_state (preview, state);
756 gst_element_set_state (priv->video_input, state);
757 gst_element_set_state (priv->video_tee, state);
761 display_video_preview (EmpathyCallWindow *self,
764 EmpathyCallWindowPriv *priv = GET_PRIV (self);
768 /* Display the video preview */
769 DEBUG ("Show video preview");
771 play_camera (self, TRUE);
772 clutter_actor_show (priv->video_preview);
776 /* Hide the video preview */
777 DEBUG ("Hide video preview");
779 if (priv->video_preview != NULL)
781 clutter_actor_hide (priv->video_preview);
782 play_camera (self, FALSE);
788 empathy_call_window_set_state_connecting (EmpathyCallWindow *window)
790 EmpathyCallWindowPriv *priv = GET_PRIV (window);
792 empathy_call_window_status_message (window, _("Connecting…"));
793 priv->call_state = CONNECTING;
796 empathy_sound_manager_start_playing (priv->sound_mgr, GTK_WIDGET (window),
797 EMPATHY_SOUND_PHONE_OUTGOING, MS_BETWEEN_RING);
801 disable_camera (EmpathyCallWindow *self)
803 EmpathyCallWindowPriv *priv = GET_PRIV (self);
805 if (priv->camera_state == CAMERA_STATE_OFF)
808 DEBUG ("Disable camera");
810 display_video_preview (self, FALSE);
812 if (priv->camera_state == CAMERA_STATE_ON)
813 empathy_call_window_set_send_video (self, CAMERA_STATE_OFF);
815 priv->camera_state = CAMERA_STATE_OFF;
819 enable_camera (EmpathyCallWindow *self)
821 EmpathyCallWindowPriv *priv = GET_PRIV (self);
823 if (priv->camera_state == CAMERA_STATE_ON)
826 if (priv->video_input == NULL)
828 DEBUG ("Can't enable camera, no input");
832 DEBUG ("Enable camera");
834 empathy_call_window_set_send_video (self, CAMERA_STATE_ON);
836 priv->camera_state = CAMERA_STATE_ON;
840 empathy_call_window_camera_toggled_cb (GtkToggleToolButton *toggle,
841 EmpathyCallWindow *self)
843 if (gtk_toggle_tool_button_get_active (toggle))
844 enable_camera (self);
846 disable_camera (self);
850 create_pipeline (EmpathyCallWindow *self)
852 EmpathyCallWindowPriv *priv = GET_PRIV (self);
855 g_assert (priv->pipeline == NULL);
857 priv->pipeline = gst_pipeline_new (NULL);
858 priv->pipeline_playing = FALSE;
860 priv->video_tee = gst_element_factory_make ("tee", NULL);
861 gst_object_ref (priv->video_tee);
862 gst_object_sink (priv->video_tee);
864 gst_bin_add (GST_BIN (priv->pipeline), priv->video_tee);
866 bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
867 priv->bus_message_source_id = gst_bus_add_watch (bus,
868 empathy_call_window_bus_message, self);
870 g_object_unref (bus);
874 empathy_call_window_configure_event_cb (GtkWidget *widget,
876 EmpathyCallWindow *self)
878 GdkWindow *gdk_window;
879 GdkWindowState window_state;
881 gtk_window_get_position (GTK_WINDOW (self), &self->priv->x, &self->priv->y);
882 gtk_window_get_size (GTK_WINDOW (self), &self->priv->w, &self->priv->h);
884 gtk_widget_get_preferred_width (self->priv->sidebar,
885 &self->priv->sidebar_width, NULL);
887 gdk_window = gtk_widget_get_window (widget);
888 window_state = gdk_window_get_state (gdk_window);
889 self->priv->maximized = (window_state & GDK_WINDOW_STATE_MAXIMIZED);
895 empathy_call_window_destroyed_cb (GtkWidget *object,
896 EmpathyCallWindow *self)
898 if (gtk_widget_get_visible (self->priv->sidebar))
900 /* Save the geometry as if the sidebar was hidden. */
901 empathy_geometry_save_values (GTK_WINDOW (self),
902 self->priv->x, self->priv->y,
903 self->priv->w - self->priv->sidebar_width, self->priv->h,
904 self->priv->maximized);
909 empathy_call_window_init (EmpathyCallWindow *self)
911 EmpathyCallWindowPriv *priv;
917 ClutterConstraint *size_constraint;
918 ClutterActor *remote_avatar;
919 GtkStyleContext *context;
923 priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
924 EMPATHY_TYPE_CALL_WINDOW, EmpathyCallWindowPriv);
926 filename = empathy_file_lookup ("empathy-call-window.ui", "src");
927 gui = empathy_builder_get_file (filename,
928 "call_window_vbox", &top_vbox,
929 "errors_vbox", &priv->errors_vbox,
931 "remote_user_name_toolbar", &priv->remote_user_name_toolbar,
932 "remote_user_avatar_toolbar", &priv->remote_user_avatar_toolbar,
933 "status_label", &priv->status_label,
934 "audiocall", &priv->audio_call_button,
935 "videocall", &priv->video_call_button,
936 "microphone", &priv->mic_button,
937 "camera", &priv->camera_button,
938 "hangup", &priv->hangup_button,
939 "dialpad", &priv->dialpad_button,
940 "toolbar", &priv->toolbar,
941 "bottom_toolbar", &priv->bottom_toolbar,
942 "menusidebar", &priv->menu_sidebar,
943 "ui_manager", &priv->ui_manager,
944 "menufullscreen", &priv->menu_fullscreen,
945 "details_vbox", &priv->details_vbox,
946 "vcodec_encoding_label", &priv->vcodec_encoding_label,
947 "acodec_encoding_label", &priv->acodec_encoding_label,
948 "acodec_decoding_label", &priv->acodec_decoding_label,
949 "vcodec_decoding_label", &priv->vcodec_decoding_label,
950 "audio_remote_candidate_label", &priv->audio_remote_candidate_label,
951 "audio_local_candidate_label", &priv->audio_local_candidate_label,
952 "video_remote_candidate_label", &priv->video_remote_candidate_label,
953 "video_local_candidate_label", &priv->video_local_candidate_label,
954 "video_remote_candidate_info_img", &priv->video_remote_candidate_info_img,
955 "video_local_candidate_info_img", &priv->video_local_candidate_info_img,
956 "audio_remote_candidate_info_img", &priv->audio_remote_candidate_info_img,
957 "audio_local_candidate_info_img", &priv->audio_local_candidate_info_img,
961 empathy_builder_connect (gui, self,
962 "menuhangup", "activate", empathy_call_window_hangup_cb,
963 "hangup", "clicked", empathy_call_window_hangup_cb,
964 "audiocall", "clicked", empathy_call_window_audio_call_cb,
965 "videocall", "clicked", empathy_call_window_video_call_cb,
966 "menusidebar", "toggled", empathy_call_window_sidebar_cb,
967 "volume", "value-changed", empathy_call_window_volume_changed_cb,
968 "microphone", "toggled", empathy_call_window_mic_toggled_cb,
969 "camera", "toggled", empathy_call_window_camera_toggled_cb,
970 "dialpad", "toggled", empathy_call_window_dialpad_cb,
971 "menufullscreen", "activate", empathy_call_window_fullscreen_cb,
972 "menupreviewdisable", "activate", empathy_call_window_disable_camera_cb,
973 "menupreviewminimise", "activate", empathy_call_window_minimise_camera_cb,
974 "menupreviewmaximise", "activate", empathy_call_window_maximise_camera_cb,
977 gtk_action_set_sensitive (priv->menu_fullscreen, FALSE);
979 priv->camera_monitor = empathy_camera_monitor_dup_singleton ();
981 g_object_bind_property (priv->camera_monitor, "available",
982 priv->camera_button, "sensitive",
983 G_BINDING_SYNC_CREATE);
985 priv->lock = g_mutex_new ();
987 gtk_container_add (GTK_CONTAINER (self), top_vbox);
989 priv->content_hbox = gtk_hbox_new (FALSE, CONTENT_HBOX_SPACING);
990 gtk_container_set_border_width (GTK_CONTAINER (priv->content_hbox),
991 CONTENT_HBOX_BORDER_WIDTH);
992 gtk_paned_pack1 (GTK_PANED (priv->pane), priv->content_hbox, TRUE, FALSE);
994 /* avatar/video box */
995 priv->video_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
996 CLUTTER_BIN_ALIGNMENT_CENTER);
998 priv->video_box = clutter_box_new (priv->video_layout);
1000 priv->video_container = gtk_clutter_embed_new ();
1002 /* Set the background color to that of the rest of the window */
1003 context = gtk_widget_get_style_context (priv->content_hbox);
1004 gtk_style_context_get_background_color (context,
1005 GTK_STATE_FLAG_NORMAL, &rgba);
1006 bg.red = CLAMP (rgba.red * 255.0, 0, 255);
1007 bg.green = CLAMP (rgba.green * 255.0, 0, 255);
1008 bg.blue = CLAMP (rgba.blue * 255.0, 0, 255);
1009 bg.alpha = CLAMP (rgba.alpha * 255.0, 0, 255);
1010 clutter_stage_set_color (
1011 CLUTTER_STAGE (gtk_clutter_embed_get_stage (
1012 GTK_CLUTTER_EMBED (priv->video_container))),
1015 clutter_container_add (
1016 CLUTTER_CONTAINER (gtk_clutter_embed_get_stage (
1017 GTK_CLUTTER_EMBED (priv->video_container))),
1021 size_constraint = clutter_bind_constraint_new (
1022 gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->video_container)),
1023 CLUTTER_BIND_SIZE, 0);
1024 clutter_actor_add_constraint (priv->video_box, size_constraint);
1026 priv->remote_user_avatar_widget = gtk_image_new ();
1027 remote_avatar = gtk_clutter_actor_new_with_contents (
1028 priv->remote_user_avatar_widget);
1030 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_box),
1033 gtk_box_pack_start (GTK_BOX (priv->content_hbox),
1034 priv->video_container, TRUE, TRUE,
1035 CONTENT_HBOX_CHILDREN_PACKING_PADDING);
1037 create_pipeline (self);
1038 create_video_output_widget (self);
1039 create_audio_input (self);
1040 create_video_input (self);
1042 /* The call will be started as soon the pipeline is playing */
1043 priv->start_call_when_playing = TRUE;
1045 priv->sidebar = ev_sidebar_new ();
1046 g_signal_connect (G_OBJECT (priv->sidebar),
1047 "hide", G_CALLBACK (empathy_call_window_sidebar_hidden_cb), self);
1048 g_signal_connect (G_OBJECT (priv->sidebar),
1049 "show", G_CALLBACK (empathy_call_window_sidebar_shown_cb), self);
1050 g_signal_connect (G_OBJECT (priv->sidebar), "changed",
1051 G_CALLBACK (empathy_call_window_sidebar_changed_cb), self);
1052 gtk_paned_pack2 (GTK_PANED (priv->pane), priv->sidebar, FALSE, FALSE);
1054 page = empathy_call_window_create_video_input (self);
1055 ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "video-input",
1056 _("Video input"), page);
1058 priv->dtmf_panel = empathy_create_dtmf_dialpad (G_OBJECT (self),
1059 G_CALLBACK (dtmf_button_pressed_cb),
1060 G_CALLBACK (dtmf_button_released_cb));
1061 ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "dialpad",
1062 _("Dialpad"), priv->dtmf_panel);
1064 gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
1066 /* Put the details vbox in a scroll window as it can require a lot of
1067 * horizontal space. */
1068 scroll = gtk_scrolled_window_new (NULL, NULL);
1069 gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll),
1070 priv->details_vbox);
1072 ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "details", _("Details"),
1075 gtk_widget_show_all (top_vbox);
1077 gtk_widget_hide (priv->sidebar);
1079 priv->fullscreen = empathy_call_window_fullscreen_new (self);
1081 empathy_call_window_fullscreen_set_video_widget (priv->fullscreen,
1082 priv->video_container);
1084 g_signal_connect (G_OBJECT (priv->fullscreen->leave_fullscreen_button),
1085 "clicked", G_CALLBACK (empathy_call_window_fullscreen_cb), self);
1087 g_signal_connect (G_OBJECT (self), "realize",
1088 G_CALLBACK (empathy_call_window_realized_cb), self);
1090 g_signal_connect (G_OBJECT (self), "delete-event",
1091 G_CALLBACK (empathy_call_window_delete_cb), self);
1093 g_signal_connect (G_OBJECT (self), "window-state-event",
1094 G_CALLBACK (empathy_call_window_state_event_cb), self);
1096 g_signal_connect (G_OBJECT (self), "key-press-event",
1097 G_CALLBACK (empathy_call_window_key_press_cb), self);
1099 priv->timer = g_timer_new ();
1101 g_object_ref (priv->ui_manager);
1102 g_object_unref (gui);
1104 priv->sound_mgr = empathy_sound_manager_dup_singleton ();
1106 empathy_call_window_show_hangup_button (self, TRUE);
1108 priv->settings = g_settings_new (EMPATHY_PREFS_CALL_SCHEMA);
1109 g_signal_connect (priv->settings, "changed::"EMPATHY_PREFS_CALL_SOUND_VOLUME,
1110 G_CALLBACK (empathy_call_window_prefs_volume_changed_cb), self);
1112 empathy_geometry_bind (GTK_WINDOW (self), "call-window");
1113 /* These signals are used to track the window position and save it
1114 * when the window is destroyed. We need to do this as we don't want
1115 * the window geometry to be saved with the sidebar taken into account. */
1116 g_signal_connect (self, "destroy",
1117 G_CALLBACK (empathy_call_window_destroyed_cb), self);
1118 g_signal_connect (self, "configure-event",
1119 G_CALLBACK (empathy_call_window_configure_event_cb), self);
1120 g_signal_connect (self, "window-state-event",
1121 G_CALLBACK (empathy_call_window_configure_event_cb), self);
1124 /* Instead of specifying a width and a height, we specify only one size. That's
1125 because we want a square avatar icon. */
1127 init_contact_avatar_with_size (EmpathyContact *contact,
1128 GtkWidget *image_widget,
1131 GdkPixbuf *pixbuf_avatar = NULL;
1133 if (contact != NULL)
1135 pixbuf_avatar = empathy_pixbuf_avatar_from_contact_scaled (contact,
1139 if (pixbuf_avatar == NULL)
1141 pixbuf_avatar = empathy_pixbuf_from_icon_name_sized (
1142 EMPATHY_IMAGE_AVATAR_DEFAULT, size);
1145 gtk_image_set_from_pixbuf (GTK_IMAGE (image_widget), pixbuf_avatar);
1147 if (pixbuf_avatar != NULL)
1148 g_object_unref (pixbuf_avatar);
1152 set_window_title (EmpathyCallWindow *self)
1154 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1157 if (priv->contact != NULL)
1159 /* translators: Call is a noun and %s is the contact name. This string
1160 * is used in the window title */
1161 tmp = g_strdup_printf (_("Call with %s"),
1162 empathy_contact_get_alias (priv->contact));
1163 gtk_window_set_title (GTK_WINDOW (self), tmp);
1168 gtk_window_set_title (GTK_WINDOW (self), _("Call with %d participants"));
1173 set_remote_user_name (EmpathyCallWindow *self,
1174 EmpathyContact *contact)
1176 const gchar *alias = empathy_contact_get_alias (contact);
1177 const gchar *status = empathy_contact_get_status (contact);
1180 label = g_strdup_printf ("%s\n<small>%s</small>", alias, status);
1181 gtk_label_set_markup (GTK_LABEL (self->priv->remote_user_name_toolbar),
1187 contact_name_changed_cb (EmpathyContact *contact,
1189 EmpathyCallWindow *self)
1191 set_window_title (self);
1192 set_remote_user_name (self, contact);
1196 contact_presence_changed_cb (EmpathyContact *contact,
1198 EmpathyCallWindow *self)
1200 set_remote_user_name (self, contact);
1204 contact_avatar_changed_cb (EmpathyContact *contact,
1206 EmpathyCallWindow *self)
1209 GtkAllocation allocation;
1210 GtkWidget *avatar_widget;
1212 avatar_widget = self->priv->remote_user_avatar_widget;
1214 gtk_widget_get_allocation (avatar_widget, &allocation);
1215 size = allocation.height;
1219 /* the widget is not allocated yet, set a default size */
1220 size = MIN (REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT,
1221 REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH);
1224 init_contact_avatar_with_size (contact, avatar_widget, size);
1226 avatar_widget = self->priv->remote_user_avatar_toolbar;
1228 gtk_widget_get_allocation (avatar_widget, &allocation);
1229 size = allocation.height;
1233 /* the widget is not allocated yet, set a default size */
1234 size = SMALL_TOOLBAR_SIZE;
1237 init_contact_avatar_with_size (contact, avatar_widget, size);
1241 empathy_call_window_setup_avatars (EmpathyCallWindow *self,
1242 EmpathyCallHandler *handler)
1244 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1246 tp_g_signal_connect_object (priv->contact, "notify::name",
1247 G_CALLBACK (contact_name_changed_cb), self, 0);
1248 tp_g_signal_connect_object (priv->contact, "notify::avatar",
1249 G_CALLBACK (contact_avatar_changed_cb), self, 0);
1250 tp_g_signal_connect_object (priv->contact, "notify::presence",
1251 G_CALLBACK (contact_presence_changed_cb), self, 0);
1253 set_window_title (self);
1254 set_remote_user_name (self, priv->contact);
1256 init_contact_avatar_with_size (priv->contact,
1257 priv->remote_user_avatar_widget,
1258 MIN (REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH,
1259 REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT));
1261 init_contact_avatar_with_size (priv->contact,
1262 priv->remote_user_avatar_toolbar,
1263 SMALL_TOOLBAR_SIZE);
1265 /* The remote avatar is shown by default and will be hidden when we receive
1266 video from the remote side. */
1267 clutter_actor_hide (priv->video_output);
1268 gtk_widget_show (priv->remote_user_avatar_widget);
1272 update_send_codec (EmpathyCallWindow *self,
1275 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1282 codec = empathy_call_handler_get_send_audio_codec (priv->handler);
1283 widget = priv->acodec_encoding_label;
1287 codec = empathy_call_handler_get_send_video_codec (priv->handler);
1288 widget = priv->vcodec_encoding_label;
1294 tmp = g_strdup_printf ("%s/%u", codec->encoding_name, codec->clock_rate);
1295 gtk_label_set_text (GTK_LABEL (widget), tmp);
1300 send_audio_codec_notify_cb (GObject *object,
1304 EmpathyCallWindow *self = user_data;
1306 update_send_codec (self, TRUE);
1310 send_video_codec_notify_cb (GObject *object,
1314 EmpathyCallWindow *self = user_data;
1316 update_send_codec (self, FALSE);
1320 update_recv_codec (EmpathyCallWindow *self,
1323 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1326 GString *str = NULL;
1330 codecs = empathy_call_handler_get_recv_audio_codecs (priv->handler);
1331 widget = priv->acodec_decoding_label;
1335 codecs = empathy_call_handler_get_recv_video_codecs (priv->handler);
1336 widget = priv->vcodec_decoding_label;
1342 for (l = codecs; l != NULL; l = g_list_next (l))
1344 FsCodec *codec = l->data;
1347 str = g_string_new (NULL);
1349 g_string_append (str, ", ");
1351 g_string_append_printf (str, "%s/%u", codec->encoding_name,
1355 gtk_label_set_text (GTK_LABEL (widget), str->str);
1356 g_string_free (str, TRUE);
1360 recv_audio_codecs_notify_cb (GObject *object,
1364 EmpathyCallWindow *self = user_data;
1366 update_recv_codec (self, TRUE);
1370 recv_video_codecs_notify_cb (GObject *object,
1374 EmpathyCallWindow *self = user_data;
1376 update_recv_codec (self, FALSE);
1379 static const gchar *
1380 candidate_type_to_str (FsCandidate *candidate)
1382 switch (candidate->type)
1384 case FS_CANDIDATE_TYPE_HOST:
1386 case FS_CANDIDATE_TYPE_SRFLX:
1387 return "server reflexive";
1388 case FS_CANDIDATE_TYPE_PRFLX:
1389 return "peer reflexive";
1390 case FS_CANDIDATE_TYPE_RELAY:
1392 case FS_CANDIDATE_TYPE_MULTICAST:
1399 static const gchar *
1400 candidate_type_to_desc (FsCandidate *candidate)
1402 switch (candidate->type)
1404 case FS_CANDIDATE_TYPE_HOST:
1405 return _("The IP address as seen by the machine");
1406 case FS_CANDIDATE_TYPE_SRFLX:
1407 return _("The IP address as seen by a server on the Internet");
1408 case FS_CANDIDATE_TYPE_PRFLX:
1409 return _("The IP address of the peer as seen by the other side");
1410 case FS_CANDIDATE_TYPE_RELAY:
1411 return _("The IP address of a relay server");
1412 case FS_CANDIDATE_TYPE_MULTICAST:
1413 return _("The IP address of the multicast group");
1420 update_candidat_widget (EmpathyCallWindow *self,
1423 FsCandidate *candidate)
1427 g_assert (candidate != NULL);
1428 str = g_strdup_printf ("%s %u (%s)", candidate->ip,
1429 candidate->port, candidate_type_to_str (candidate));
1431 gtk_label_set_text (GTK_LABEL (label), str);
1432 gtk_widget_set_tooltip_text (img, candidate_type_to_desc (candidate));
1438 candidates_changed_cb (GObject *object,
1440 EmpathyCallWindow *self)
1442 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1443 FsCandidate *candidate = NULL;
1445 if (type == FS_MEDIA_TYPE_VIDEO)
1447 /* Update remote candidate */
1448 candidate = empathy_call_handler_get_video_remote_candidate (
1451 update_candidat_widget (self, priv->video_remote_candidate_label,
1452 priv->video_remote_candidate_info_img, candidate);
1454 /* Update local candidate */
1455 candidate = empathy_call_handler_get_video_local_candidate (
1458 update_candidat_widget (self, priv->video_local_candidate_label,
1459 priv->video_local_candidate_info_img, candidate);
1463 /* Update remote candidate */
1464 candidate = empathy_call_handler_get_audio_remote_candidate (
1467 update_candidat_widget (self, priv->audio_remote_candidate_label,
1468 priv->audio_remote_candidate_info_img, candidate);
1470 /* Update local candidate */
1471 candidate = empathy_call_handler_get_audio_local_candidate (
1474 update_candidat_widget (self, priv->audio_local_candidate_label,
1475 priv->audio_local_candidate_info_img, candidate);
1480 empathy_call_window_constructed (GObject *object)
1482 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
1483 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1484 TpyCallChannel *call;
1486 g_assert (priv->handler != NULL);
1488 g_object_get (priv->handler, "call-channel", &call, NULL);
1489 priv->outgoing = (call == NULL);
1491 g_object_unref (call);
1493 g_object_get (priv->handler, "target-contact", &priv->contact, NULL);
1494 g_assert (priv->contact != NULL);
1496 empathy_call_window_setup_avatars (self, priv->handler);
1497 empathy_call_window_set_state_connecting (self);
1499 if (!empathy_call_handler_has_initial_video (priv->handler))
1501 gtk_toggle_tool_button_set_active (
1502 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), FALSE);
1504 /* If call has InitialVideo, the preview will be started once the call has
1505 * been started (start_call()). */
1507 update_send_codec (self, TRUE);
1508 update_send_codec (self, FALSE);
1509 update_recv_codec (self, TRUE);
1510 update_recv_codec (self, FALSE);
1512 tp_g_signal_connect_object (priv->handler, "notify::send-audio-codec",
1513 G_CALLBACK (send_audio_codec_notify_cb), self, 0);
1514 tp_g_signal_connect_object (priv->handler, "notify::send-video-codec",
1515 G_CALLBACK (send_video_codec_notify_cb), self, 0);
1516 tp_g_signal_connect_object (priv->handler, "notify::recv-audio-codecs",
1517 G_CALLBACK (recv_audio_codecs_notify_cb), self, 0);
1518 tp_g_signal_connect_object (priv->handler, "notify::recv-video-codecs",
1519 G_CALLBACK (recv_video_codecs_notify_cb), self, 0);
1521 tp_g_signal_connect_object (priv->handler, "candidates-changed",
1522 G_CALLBACK (candidates_changed_cb), self, 0);
1525 static void empathy_call_window_dispose (GObject *object);
1526 static void empathy_call_window_finalize (GObject *object);
1529 empathy_call_window_set_property (GObject *object,
1530 guint property_id, const GValue *value, GParamSpec *pspec)
1532 EmpathyCallWindowPriv *priv = GET_PRIV (object);
1534 switch (property_id)
1536 case PROP_CALL_HANDLER:
1537 priv->handler = g_value_dup_object (value);
1540 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1545 empathy_call_window_get_property (GObject *object,
1546 guint property_id, GValue *value, GParamSpec *pspec)
1548 EmpathyCallWindowPriv *priv = GET_PRIV (object);
1550 switch (property_id)
1552 case PROP_CALL_HANDLER:
1553 g_value_set_object (value, priv->handler);
1556 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1561 empathy_call_window_class_init (
1562 EmpathyCallWindowClass *empathy_call_window_class)
1564 GObjectClass *object_class = G_OBJECT_CLASS (empathy_call_window_class);
1565 GParamSpec *param_spec;
1567 g_type_class_add_private (empathy_call_window_class,
1568 sizeof (EmpathyCallWindowPriv));
1570 object_class->constructed = empathy_call_window_constructed;
1571 object_class->set_property = empathy_call_window_set_property;
1572 object_class->get_property = empathy_call_window_get_property;
1574 object_class->dispose = empathy_call_window_dispose;
1575 object_class->finalize = empathy_call_window_finalize;
1577 param_spec = g_param_spec_object ("handler",
1578 "handler", "The call handler",
1579 EMPATHY_TYPE_CALL_HANDLER,
1580 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
1581 g_object_class_install_property (object_class,
1582 PROP_CALL_HANDLER, param_spec);
1586 empathy_call_window_dispose (GObject *object)
1588 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
1589 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1591 if (priv->dispose_has_run)
1594 priv->dispose_has_run = TRUE;
1596 if (priv->handler != NULL)
1598 empathy_call_handler_stop_call (priv->handler);
1599 tp_clear_object (&priv->handler);
1602 if (priv->bus_message_source_id != 0)
1604 g_source_remove (priv->bus_message_source_id);
1605 priv->bus_message_source_id = 0;
1608 if (priv->got_video_src > 0)
1610 g_source_remove (priv->got_video_src);
1611 priv->got_video_src = 0;
1614 tp_clear_object (&priv->pipeline);
1615 tp_clear_object (&priv->video_input);
1616 tp_clear_object (&priv->audio_input);
1617 tp_clear_object (&priv->video_tee);
1618 tp_clear_object (&priv->ui_manager);
1619 tp_clear_object (&priv->fullscreen);
1620 tp_clear_object (&priv->camera_monitor);
1621 tp_clear_object (&priv->settings);
1623 g_list_free_full (priv->notifiers, g_object_unref);
1625 if (priv->timer_id != 0)
1626 g_source_remove (priv->timer_id);
1629 if (priv->contact != NULL)
1631 g_signal_handlers_disconnect_by_func (priv->contact,
1632 contact_name_changed_cb, self);
1633 priv->contact = NULL;
1637 tp_clear_object (&priv->sound_mgr);
1639 G_OBJECT_CLASS (empathy_call_window_parent_class)->dispose (object);
1643 disconnect_video_output_motion_handler (EmpathyCallWindow *self)
1645 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1647 if (priv->video_output_motion_handler_id != 0)
1649 g_signal_handler_disconnect (G_OBJECT (priv->video_container),
1650 priv->video_output_motion_handler_id);
1651 priv->video_output_motion_handler_id = 0;
1656 empathy_call_window_finalize (GObject *object)
1658 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
1659 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1661 disconnect_video_output_motion_handler (self);
1663 /* free any data held directly by the object here */
1664 g_mutex_free (priv->lock);
1666 g_timer_destroy (priv->timer);
1668 G_OBJECT_CLASS (empathy_call_window_parent_class)->finalize (object);
1673 empathy_call_window_new (EmpathyCallHandler *handler)
1675 return EMPATHY_CALL_WINDOW (
1676 g_object_new (EMPATHY_TYPE_CALL_WINDOW, "handler", handler, NULL));
1680 empathy_call_window_conference_added_cb (EmpathyCallHandler *handler,
1681 GstElement *conference, gpointer user_data)
1683 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
1684 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1685 FsElementAddedNotifier *notifier;
1688 DEBUG ("Conference added");
1690 /* Add notifier to set the various element properties as needed */
1691 notifier = fs_element_added_notifier_new ();
1692 keyfile = fs_utils_get_default_element_properties (conference);
1694 if (keyfile != NULL)
1695 fs_element_added_notifier_set_properties_from_keyfile (notifier, keyfile);
1697 fs_element_added_notifier_add (notifier, GST_BIN (priv->pipeline));
1699 priv->notifiers = g_list_prepend (priv->notifiers, notifier);
1701 gst_bin_add (GST_BIN (priv->pipeline), conference);
1702 gst_element_set_state (conference, GST_STATE_PLAYING);
1706 empathy_call_window_conference_removed_cb (EmpathyCallHandler *handler,
1707 GstElement *conference, gpointer user_data)
1709 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
1710 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1712 gst_bin_remove (GST_BIN (priv->pipeline), conference);
1713 gst_element_set_state (conference, GST_STATE_NULL);
1717 empathy_call_window_reset_pipeline (EmpathyCallWindow *self)
1719 GstStateChangeReturn state_change_return;
1720 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1722 if (priv->pipeline == NULL)
1725 if (priv->bus_message_source_id != 0)
1727 g_source_remove (priv->bus_message_source_id);
1728 priv->bus_message_source_id = 0;
1731 state_change_return = gst_element_set_state (priv->pipeline, GST_STATE_NULL);
1733 if (state_change_return == GST_STATE_CHANGE_SUCCESS ||
1734 state_change_return == GST_STATE_CHANGE_NO_PREROLL)
1736 if (priv->pipeline != NULL)
1737 g_object_unref (priv->pipeline);
1738 priv->pipeline = NULL;
1740 if (priv->audio_output != NULL)
1741 g_object_unref (priv->audio_output);
1742 priv->audio_output = NULL;
1744 if (priv->video_tee != NULL)
1745 g_object_unref (priv->video_tee);
1746 priv->video_tee = NULL;
1748 if (priv->video_preview != NULL)
1749 clutter_actor_destroy (priv->video_preview);
1750 priv->video_preview = NULL;
1752 priv->funnel = NULL;
1754 create_pipeline (self);
1755 /* Call will be started when user will hit the 'redial' button */
1756 priv->start_call_when_playing = FALSE;
1757 gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
1763 g_message ("Error: could not destroy pipeline. Closing call window");
1764 gtk_widget_destroy (GTK_WIDGET (self));
1771 reset_details_pane (EmpathyCallWindow *self)
1773 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1775 gtk_label_set_text (GTK_LABEL (priv->vcodec_encoding_label), _("Unknown"));
1776 gtk_label_set_text (GTK_LABEL (priv->acodec_encoding_label), _("Unknown"));
1777 gtk_label_set_text (GTK_LABEL (priv->vcodec_decoding_label), _("Unknown"));
1778 gtk_label_set_text (GTK_LABEL (priv->acodec_decoding_label), _("Unknown"));
1782 empathy_call_window_disconnected (EmpathyCallWindow *self,
1785 gboolean could_disconnect = FALSE;
1786 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1787 gboolean could_reset_pipeline;
1789 /* Leave full screen mode if needed */
1790 gtk_window_unfullscreen (GTK_WINDOW (self));
1792 gtk_action_set_sensitive (priv->menu_fullscreen, FALSE);
1793 gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
1795 could_reset_pipeline = empathy_call_window_reset_pipeline (self);
1797 if (priv->call_state == CONNECTING)
1798 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
1800 if (priv->call_state != REDIALING)
1801 priv->call_state = DISCONNECTED;
1803 if (could_reset_pipeline)
1805 g_mutex_lock (priv->lock);
1807 g_timer_stop (priv->timer);
1809 if (priv->timer_id != 0)
1810 g_source_remove (priv->timer_id);
1813 g_mutex_unlock (priv->lock);
1816 /* We are about to destroy the window, no need to update it or create
1817 * a video preview */
1820 empathy_call_window_status_message (self, _("Disconnected"));
1822 empathy_call_window_show_hangup_button (self, FALSE);
1824 /* Unsensitive the camera and mic button */
1825 gtk_widget_set_sensitive (priv->camera_button, FALSE);
1826 gtk_widget_set_sensitive (priv->mic_button, FALSE);
1828 /* Be sure that the mic button is enabled */
1829 gtk_toggle_tool_button_set_active (
1830 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button), TRUE);
1832 if (priv->camera_state == CAMERA_STATE_ON)
1834 /* Restart the preview with the new pipeline. */
1835 display_video_preview (self, TRUE);
1838 /* destroy the video output; it will be recreated when we'll redial */
1839 disconnect_video_output_motion_handler (self);
1840 if (priv->video_output != NULL)
1841 clutter_actor_destroy (priv->video_output);
1842 priv->video_output = NULL;
1843 if (priv->got_video_src > 0)
1845 g_source_remove (priv->got_video_src);
1846 priv->got_video_src = 0;
1849 gtk_widget_show (priv->remote_user_avatar_widget);
1851 reset_details_pane (self);
1853 priv->sending_video = FALSE;
1854 priv->call_started = FALSE;
1856 could_disconnect = TRUE;
1858 /* TODO: display the self avatar of the preview (depends if the "Always
1859 * Show Video Preview" is enabled or not) */
1862 return could_disconnect;
1867 empathy_call_window_channel_closed_cb (EmpathyCallHandler *handler,
1870 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
1871 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1873 if (empathy_call_window_disconnected (self, TRUE) &&
1874 priv->call_state == REDIALING)
1875 empathy_call_window_restart_call (self);
1879 empathy_call_window_sink_removed_cb (EmpathyCallHandler *handler,
1881 FsMediaType media_type,
1882 EmpathyCallWindow *self)
1884 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1886 DEBUG ("removing content");
1889 * This assumes that there is only one video stream per channel...
1892 if ((guint) media_type == FS_MEDIA_TYPE_VIDEO)
1894 if (priv->funnel != NULL)
1898 output = priv->video_output_sink;
1900 gst_element_set_state (output, GST_STATE_NULL);
1901 gst_element_set_state (priv->funnel, GST_STATE_NULL);
1903 gst_bin_remove (GST_BIN (priv->pipeline), output);
1904 gst_bin_remove (GST_BIN (priv->pipeline), priv->funnel);
1905 priv->funnel = NULL;
1909 else if (media_type == FS_MEDIA_TYPE_AUDIO)
1911 if (priv->audio_output != NULL)
1913 gst_element_set_state (priv->audio_output, GST_STATE_NULL);
1915 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
1916 priv->audio_output = NULL;
1924 /* Called with global lock held */
1926 empathy_call_window_get_video_sink_pad (EmpathyCallWindow *self)
1928 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1932 if (priv->funnel == NULL)
1934 output = priv->video_output_sink;
1936 priv->funnel = gst_element_factory_make ("fsfunnel", NULL);
1940 g_warning ("Could not create fsfunnel");
1944 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->funnel))
1946 gst_object_unref (priv->funnel);
1947 priv->funnel = NULL;
1948 g_warning ("Could not add funnel to pipeline");
1952 if (!gst_bin_add (GST_BIN (priv->pipeline), output))
1954 g_warning ("Could not add the video output widget to the pipeline");
1958 if (!gst_element_link (priv->funnel, output))
1960 g_warning ("Could not link output sink to funnel");
1961 goto error_output_added;
1964 if (gst_element_set_state (output, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
1966 g_warning ("Could not start video sink");
1967 goto error_output_added;
1970 if (gst_element_set_state (priv->funnel, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
1972 g_warning ("Could not start funnel");
1973 goto error_output_added;
1977 pad = gst_element_get_request_pad (priv->funnel, "sink%d");
1980 g_warning ("Could not get request pad from funnel");
1987 gst_element_set_locked_state (priv->funnel, TRUE);
1988 gst_element_set_locked_state (output, TRUE);
1990 gst_element_set_state (priv->funnel, GST_STATE_NULL);
1991 gst_element_set_state (output, GST_STATE_NULL);
1993 gst_bin_remove (GST_BIN (priv->pipeline), output);
1994 gst_element_set_locked_state (output, FALSE);
1998 gst_bin_remove (GST_BIN (priv->pipeline), priv->funnel);
1999 priv->funnel = NULL;
2004 /* Called with global lock held */
2006 empathy_call_window_get_audio_sink_pad (EmpathyCallWindow *self)
2008 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2010 GstPadTemplate *template;
2012 if (priv->audio_output == NULL)
2014 priv->audio_output = empathy_audio_sink_new ();
2015 g_object_ref_sink (priv->audio_output);
2017 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_output))
2019 g_warning ("Could not add audio sink to pipeline");
2020 g_object_unref (priv->audio_output);
2021 goto error_add_output;
2024 if (gst_element_set_state (priv->audio_output, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2026 g_warning ("Could not start audio sink");
2031 template = gst_element_class_get_pad_template (
2032 GST_ELEMENT_GET_CLASS (priv->audio_output), "sink%d");
2034 pad = gst_element_request_pad (priv->audio_output,
2035 template, NULL, NULL);
2039 g_warning ("Could not get sink pad from sink");
2046 gst_element_set_locked_state (priv->audio_output, TRUE);
2047 gst_element_set_state (priv->audio_output, GST_STATE_NULL);
2048 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
2049 priv->audio_output = NULL;
2057 empathy_call_window_update_timer (gpointer user_data)
2059 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2060 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2064 time_ = g_timer_elapsed (priv->timer, NULL);
2066 /* Translators: 'status - minutes:seconds' the caller has been connected */
2067 str = g_strdup_printf (_("%s — %d:%02dm"),
2068 priv->call_state == HELD ? _("On hold") : _("Connected"),
2069 (int) time_ / 60, (int) time_ % 60);
2070 empathy_call_window_status_message (self, str);
2078 display_error (EmpathyCallWindow *self,
2079 TpyCallChannel *call,
2083 const gchar *details)
2085 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2086 GtkWidget *info_bar;
2087 GtkWidget *content_area;
2094 /* Create info bar */
2095 info_bar = gtk_info_bar_new_with_buttons (GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
2098 gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_WARNING);
2100 content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar));
2102 /* hbox containing the image and the messages vbox */
2103 hbox = gtk_hbox_new (FALSE, 3);
2104 gtk_container_add (GTK_CONTAINER (content_area), hbox);
2107 image = gtk_image_new_from_icon_name (img, GTK_ICON_SIZE_DIALOG);
2108 gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
2110 /* vbox containing the main message and the details expander */
2111 vbox = gtk_vbox_new (FALSE, 3);
2112 gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
2115 txt = g_strdup_printf ("<b>%s</b>\n%s", title, desc);
2117 label = gtk_label_new (NULL);
2118 gtk_label_set_markup (GTK_LABEL (label), txt);
2119 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
2120 gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
2123 gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
2126 if (details != NULL)
2128 GtkWidget *expander;
2130 expander = gtk_expander_new (_("Technical Details"));
2132 txt = g_strdup_printf ("<i>%s</i>", details);
2134 label = gtk_label_new (NULL);
2135 gtk_label_set_markup (GTK_LABEL (label), txt);
2136 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
2137 gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
2140 gtk_container_add (GTK_CONTAINER (expander), label);
2141 gtk_box_pack_start (GTK_BOX (vbox), expander, TRUE, TRUE, 0);
2144 g_signal_connect (info_bar, "response",
2145 G_CALLBACK (gtk_widget_destroy), NULL);
2147 gtk_box_pack_start (GTK_BOX (priv->errors_vbox), info_bar,
2148 FALSE, FALSE, CONTENT_HBOX_CHILDREN_PACKING_PADDING);
2149 gtk_widget_show_all (info_bar);
2153 media_stream_error_to_txt (EmpathyCallWindow *self,
2154 TpyCallChannel *call,
2156 TpMediaStreamError error)
2158 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2159 const gchar *cm = NULL;
2165 case TP_MEDIA_STREAM_ERROR_CODEC_NEGOTIATION_FAILED:
2167 return g_strdup_printf (
2168 _("%s's software does not understand any of the audio formats "
2169 "supported by your computer"),
2170 empathy_contact_get_alias (priv->contact));
2172 return g_strdup_printf (
2173 _("%s's software does not understand any of the video formats "
2174 "supported by your computer"),
2175 empathy_contact_get_alias (priv->contact));
2177 case TP_MEDIA_STREAM_ERROR_CONNECTION_FAILED:
2178 return g_strdup_printf (
2179 _("Can't establish a connection to %s. "
2180 "One of you might be on a network that does not allow "
2181 "direct connections."),
2182 empathy_contact_get_alias (priv->contact));
2184 case TP_MEDIA_STREAM_ERROR_NETWORK_ERROR:
2185 return g_strdup (_("There was a failure on the network"));
2187 case TP_MEDIA_STREAM_ERROR_NO_CODECS:
2189 return g_strdup (_("The audio formats necessary for this call "
2190 "are not installed on your computer"));
2192 return g_strdup (_("The video formats necessary for this call "
2193 "are not installed on your computer"));
2195 case TP_MEDIA_STREAM_ERROR_INVALID_CM_BEHAVIOR:
2196 tp_connection_parse_object_path (
2197 tp_channel_borrow_connection (TP_CHANNEL (call)),
2200 url = g_strdup_printf ("http://bugs.freedesktop.org/enter_bug.cgi?"
2201 "product=Telepathy&component=%s", cm);
2203 result = g_strdup_printf (
2204 _("Something unexpected happened in a Telepathy component. "
2205 "Please <a href=\"%s\">report this bug</a> and attach "
2206 "logs gathered from the 'Debug' window in the Help menu."), url);
2212 case TP_MEDIA_STREAM_ERROR_MEDIA_ERROR:
2213 return g_strdup (_("There was a failure in the call engine"));
2215 case TP_MEDIA_STREAM_ERROR_EOS:
2216 return g_strdup (_("The end of the stream was reached"));
2218 case TP_MEDIA_STREAM_ERROR_UNKNOWN:
2225 empathy_call_window_stream_error (EmpathyCallWindow *self,
2226 TpyCallChannel *call,
2235 desc = media_stream_error_to_txt (self, call, audio, code);
2238 /* No description, use the error message. That's not great as it's not
2239 * localized but it's better than nothing. */
2240 display_error (self, call, icon, title, msg, NULL);
2244 display_error (self, call, icon, title, desc, msg);
2250 empathy_call_window_audio_stream_error (TpyCallChannel *call,
2253 EmpathyCallWindow *self)
2255 empathy_call_window_stream_error (self, call, TRUE, code, msg,
2256 "gnome-stock-mic", _("Can't establish audio stream"));
2260 empathy_call_window_video_stream_error (TpyCallChannel *call,
2263 EmpathyCallWindow *self)
2265 empathy_call_window_stream_error (self, call, FALSE, code, msg,
2266 "camera-web", _("Can't establish video stream"));
2271 empathy_call_window_state_changed_cb (EmpathyCallHandler *handler,
2273 EmpathyCallWindow *self)
2275 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2276 TpyCallChannel *call;
2277 gboolean can_send_video;
2279 if (state != TPY_CALL_STATE_ACCEPTED)
2282 if (priv->call_state == CONNECTED)
2285 g_timer_start (priv->timer);
2286 priv->call_state = CONNECTED;
2288 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
2290 can_send_video = priv->video_input != NULL &&
2291 empathy_contact_can_voip_video (priv->contact) &&
2292 empathy_camera_monitor_get_available (priv->camera_monitor);
2294 g_object_get (priv->handler, "call-channel", &call, NULL);
2296 if (tpy_call_channel_has_dtmf (call))
2297 gtk_widget_set_sensitive (priv->dtmf_panel, TRUE);
2299 if (priv->video_input == NULL)
2300 empathy_call_window_set_send_video (self, CAMERA_STATE_OFF);
2302 gtk_widget_set_sensitive (priv->camera_button, can_send_video);
2304 empathy_call_window_show_hangup_button (self, TRUE);
2306 gtk_widget_set_sensitive (priv->mic_button, TRUE);
2308 clutter_actor_hide (priv->video_output);
2309 gtk_widget_show (priv->remote_user_avatar_widget);
2311 g_object_unref (call);
2313 g_mutex_lock (priv->lock);
2315 priv->timer_id = g_timeout_add_seconds (1,
2316 empathy_call_window_update_timer, self);
2318 g_mutex_unlock (priv->lock);
2320 empathy_call_window_update_timer (self);
2322 gtk_action_set_sensitive (priv->menu_fullscreen, TRUE);
2326 empathy_call_window_show_video_output_cb (gpointer user_data)
2328 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2330 if (self->priv->video_output != NULL)
2332 gtk_widget_hide (self->priv->remote_user_avatar_widget);
2333 clutter_actor_show (self->priv->video_output);
2340 empathy_call_window_check_video_cb (gpointer data)
2342 EmpathyCallWindow *self = data;
2344 if (self->priv->got_video)
2346 self->priv->got_video = FALSE;
2350 /* No video in the last N seconds, display the remote avatar */
2351 empathy_call_window_show_video_output (self, FALSE);
2356 /* Called from the streaming thread */
2358 empathy_call_window_video_probe_cb (GstPad *pad,
2359 GstMiniObject *mini_obj,
2360 EmpathyCallWindow *self)
2363 if (GST_IS_EVENT (mini_obj))
2366 if (G_UNLIKELY (!self->priv->got_video))
2368 /* show the remote video */
2369 g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
2370 empathy_call_window_show_video_output_cb,
2371 g_object_ref (self), g_object_unref);
2373 self->priv->got_video = TRUE;
2379 /* Called from the streaming thread */
2381 empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
2382 GstPad *src, guint media_type, gpointer user_data)
2384 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2385 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2386 gboolean retval = FALSE;
2390 g_mutex_lock (priv->lock);
2394 case TP_MEDIA_STREAM_TYPE_AUDIO:
2395 pad = empathy_call_window_get_audio_sink_pad (self);
2397 case TP_MEDIA_STREAM_TYPE_VIDEO:
2398 g_idle_add (empathy_call_window_show_video_output_cb, self);
2399 pad = empathy_call_window_get_video_sink_pad (self);
2401 gst_pad_add_data_probe (src,
2402 G_CALLBACK (empathy_call_window_video_probe_cb), self);
2403 if (priv->got_video_src > 0)
2404 g_source_remove (priv->got_video_src);
2405 priv->got_video_src = g_timeout_add_seconds (5,
2406 empathy_call_window_check_video_cb, self);
2409 g_assert_not_reached ();
2415 if (GST_PAD_LINK_FAILED (gst_pad_link (src, pad)))
2416 g_warning ("Could not link %s sink pad",
2417 media_type == TP_MEDIA_STREAM_TYPE_AUDIO ? "audio" : "video");
2421 gst_object_unref (pad);
2425 /* If no sink could be linked, try to add fakesink to prevent the whole call
2430 GstElement *fakesink = gst_element_factory_make ("fakesink", NULL);
2432 if (gst_bin_add (GST_BIN (priv->pipeline), fakesink))
2434 GstPad *sinkpad = gst_element_get_static_pad (fakesink, "sink");
2435 if (gst_element_set_state (fakesink, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE ||
2436 GST_PAD_LINK_FAILED (gst_pad_link (src, sinkpad)))
2438 gst_element_set_locked_state (fakesink, TRUE);
2439 gst_element_set_state (fakesink, GST_STATE_NULL);
2440 gst_bin_remove (GST_BIN (priv->pipeline), fakesink);
2444 DEBUG ("Could not link real sink, linked fakesink instead");
2446 gst_object_unref (sinkpad);
2450 gst_object_unref (fakesink);
2455 g_mutex_unlock (priv->lock);
2461 empathy_call_window_sink_added_cb (EmpathyCallHandler *handler,
2462 GstPad *sink, FsMediaType media_type, gpointer user_data)
2464 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2465 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2467 gboolean retval = FALSE;
2471 case FS_MEDIA_TYPE_AUDIO:
2472 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_input))
2474 g_warning ("Could not add audio source to pipeline");
2478 pad = gst_element_get_static_pad (priv->audio_input, "src");
2481 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
2482 g_warning ("Could not get source pad from audio source");
2486 if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
2488 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
2489 g_warning ("Could not link audio source to farsight");
2493 if (gst_element_set_state (priv->audio_input, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2495 g_warning ("Could not start audio source");
2496 gst_element_set_state (priv->audio_input, GST_STATE_NULL);
2497 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
2503 case FS_MEDIA_TYPE_VIDEO:
2504 if (priv->video_tee != NULL)
2506 pad = gst_element_get_request_pad (priv->video_tee, "src%d");
2507 if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
2509 g_warning ("Could not link video source input pipeline");
2512 gst_object_unref (pad);
2518 g_assert_not_reached ();
2525 empathy_call_window_remove_video_input (EmpathyCallWindow *self)
2527 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2528 GstElement *preview;
2530 disable_camera (self);
2532 DEBUG ("remove video input");
2533 preview = priv->video_preview_sink;
2535 gst_element_set_state (priv->video_input, GST_STATE_NULL);
2536 gst_element_set_state (priv->video_tee, GST_STATE_NULL);
2537 gst_element_set_state (preview, GST_STATE_NULL);
2539 gst_bin_remove_many (GST_BIN (priv->pipeline), priv->video_input,
2542 g_object_unref (priv->video_input);
2543 priv->video_input = NULL;
2544 g_object_unref (priv->video_tee);
2545 priv->video_tee = NULL;
2546 clutter_actor_destroy (priv->video_preview);
2547 priv->video_preview = NULL;
2549 gtk_widget_set_sensitive (priv->camera_button, FALSE);
2553 start_call (EmpathyCallWindow *self)
2555 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2557 priv->call_started = TRUE;
2558 empathy_call_handler_start_call (priv->handler,
2559 gtk_get_current_event_time ());
2561 if (empathy_call_handler_has_initial_video (priv->handler))
2563 TpyCallChannel *call;
2566 g_object_get (priv->handler, "call-channel", &call, NULL);
2567 s = tpy_call_channel_get_video_state (call);
2569 if (s == TPY_SENDING_STATE_PENDING_SEND ||
2570 s == TPY_SENDING_STATE_SENDING)
2572 /* Enable 'send video' buttons and display the preview */
2573 gtk_toggle_tool_button_set_active (
2574 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), TRUE);
2578 gtk_toggle_tool_button_set_active (
2579 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), FALSE);
2581 if (priv->video_preview == NULL)
2583 create_video_preview (self);
2584 add_video_preview_to_pipeline (self);
2588 g_object_unref (call);
2593 empathy_call_window_bus_message (GstBus *bus, GstMessage *message,
2596 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2597 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2600 empathy_call_handler_bus_message (priv->handler, bus, message);
2602 switch (GST_MESSAGE_TYPE (message))
2604 case GST_MESSAGE_STATE_CHANGED:
2605 if (GST_MESSAGE_SRC (message) == GST_OBJECT (priv->video_input))
2607 gst_message_parse_state_changed (message, NULL, &newstate, NULL);
2608 if (newstate == GST_STATE_PAUSED)
2609 empathy_call_window_setup_video_input (self);
2611 if (GST_MESSAGE_SRC (message) == GST_OBJECT (priv->pipeline) &&
2612 !priv->call_started)
2614 gst_message_parse_state_changed (message, NULL, &newstate, NULL);
2615 if (newstate == GST_STATE_PAUSED)
2617 gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
2618 priv->pipeline_playing = TRUE;
2620 if (priv->start_call_when_playing)
2625 case GST_MESSAGE_ERROR:
2627 GError *error = NULL;
2628 GstElement *gst_error;
2631 gst_message_parse_error (message, &error, &debug);
2632 gst_error = GST_ELEMENT (GST_MESSAGE_SRC (message));
2634 g_message ("Element error: %s -- %s\n", error->message, debug);
2636 if (g_str_has_prefix (gst_element_get_name (gst_error),
2637 VIDEO_INPUT_ERROR_PREFIX))
2639 /* Remove the video input and continue */
2640 if (priv->video_input != NULL)
2641 empathy_call_window_remove_video_input (self);
2642 gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
2646 empathy_call_window_disconnected (self, TRUE);
2648 g_error_free (error);
2651 case GST_MESSAGE_UNKNOWN:
2652 case GST_MESSAGE_EOS:
2653 case GST_MESSAGE_WARNING:
2654 case GST_MESSAGE_INFO:
2655 case GST_MESSAGE_TAG:
2656 case GST_MESSAGE_BUFFERING:
2657 case GST_MESSAGE_STATE_DIRTY:
2658 case GST_MESSAGE_STEP_DONE:
2659 case GST_MESSAGE_CLOCK_PROVIDE:
2660 case GST_MESSAGE_CLOCK_LOST:
2661 case GST_MESSAGE_NEW_CLOCK:
2662 case GST_MESSAGE_STRUCTURE_CHANGE:
2663 case GST_MESSAGE_STREAM_STATUS:
2664 case GST_MESSAGE_APPLICATION:
2665 case GST_MESSAGE_ELEMENT:
2666 case GST_MESSAGE_SEGMENT_START:
2667 case GST_MESSAGE_SEGMENT_DONE:
2668 case GST_MESSAGE_DURATION:
2669 case GST_MESSAGE_ANY:
2678 empathy_call_window_members_changed_cb (TpyCallChannel *call,
2679 GHashTable *members,
2680 EmpathyCallWindow *self)
2682 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2683 GHashTableIter iter;
2684 gpointer key, value;
2685 gboolean held = FALSE;
2687 g_hash_table_iter_init (&iter, members);
2688 while (g_hash_table_iter_next (&iter, &key, &value))
2690 if (GPOINTER_TO_INT (value) & TPY_CALL_MEMBER_FLAG_HELD)
2692 /* This assumes this is a 1-1 call, otherwise one participant
2693 * putting the call on hold wouldn't mean the call is on hold
2701 priv->call_state = HELD;
2702 else if (priv->call_state == HELD)
2703 priv->call_state = CONNECTED;
2707 call_handler_notify_call_cb (EmpathyCallHandler *handler,
2709 EmpathyCallWindow *self)
2711 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2712 TpyCallChannel *call;
2714 g_object_get (priv->handler, "call-channel", &call, NULL);
2719 tp_g_signal_connect_object (call, "audio-stream-error",
2720 G_CALLBACK (empathy_call_window_audio_stream_error), self, 0);
2721 tp_g_signal_connect_object (call, "video-stream-error",
2722 G_CALLBACK (empathy_call_window_video_stream_error), self, 0);
2725 tp_g_signal_connect_object (call, "members-changed",
2726 G_CALLBACK (empathy_call_window_members_changed_cb), self, 0);
2728 g_object_unref (call);
2732 empathy_call_window_realized_cb (GtkWidget *widget, EmpathyCallWindow *window)
2734 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2735 TpyCallChannel *call;
2738 /* Make the hangup button twice as wide */
2739 width = gtk_widget_get_allocated_width (priv->hangup_button);
2740 gtk_widget_set_size_request (priv->hangup_button, width * 2, -1);
2742 g_signal_connect (priv->handler, "state-changed",
2743 G_CALLBACK (empathy_call_window_state_changed_cb), window);
2744 g_signal_connect (priv->handler, "conference-added",
2745 G_CALLBACK (empathy_call_window_conference_added_cb), window);
2746 g_signal_connect (priv->handler, "conference-removed",
2747 G_CALLBACK (empathy_call_window_conference_removed_cb), window);
2748 g_signal_connect (priv->handler, "closed",
2749 G_CALLBACK (empathy_call_window_channel_closed_cb), window);
2750 g_signal_connect (priv->handler, "src-pad-added",
2751 G_CALLBACK (empathy_call_window_src_added_cb), window);
2752 g_signal_connect (priv->handler, "sink-pad-added",
2753 G_CALLBACK (empathy_call_window_sink_added_cb), window);
2754 g_signal_connect (priv->handler, "sink-pad-removed",
2755 G_CALLBACK (empathy_call_window_sink_removed_cb), window);
2757 g_object_get (priv->handler, "call-channel", &call, NULL);
2760 call_handler_notify_call_cb (priv->handler, NULL, window);
2761 g_object_unref (call);
2765 /* call-channel doesn't exist yet, we'll connect signals once it has been
2767 g_signal_connect (priv->handler, "notify::call-channel",
2768 G_CALLBACK (call_handler_notify_call_cb), window);
2771 gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
2775 empathy_call_window_delete_cb (GtkWidget *widget, GdkEvent*event,
2776 EmpathyCallWindow *window)
2778 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2780 if (priv->pipeline != NULL)
2782 if (priv->bus_message_source_id != 0)
2784 g_source_remove (priv->bus_message_source_id);
2785 priv->bus_message_source_id = 0;
2788 gst_element_set_state (priv->pipeline, GST_STATE_NULL);
2791 if (priv->call_state == CONNECTING)
2792 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
2798 show_controls (EmpathyCallWindow *window, gboolean set_fullscreen)
2801 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2803 menu = gtk_ui_manager_get_widget (priv->ui_manager,
2808 gtk_widget_hide (priv->sidebar);
2809 gtk_widget_hide (menu);
2810 gtk_widget_hide (priv->toolbar);
2814 if (priv->sidebar_was_visible_before_fs)
2815 gtk_widget_show (priv->sidebar);
2817 gtk_widget_show (menu);
2818 gtk_widget_show (priv->toolbar);
2820 gtk_window_resize (GTK_WINDOW (window), priv->original_width_before_fs,
2821 priv->original_height_before_fs);
2826 show_borders (EmpathyCallWindow *window, gboolean set_fullscreen)
2828 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2830 gtk_container_set_border_width (GTK_CONTAINER (priv->content_hbox),
2831 set_fullscreen ? 0 : CONTENT_HBOX_BORDER_WIDTH);
2832 gtk_box_set_spacing (GTK_BOX (priv->content_hbox),
2833 set_fullscreen ? 0 : CONTENT_HBOX_SPACING);
2835 if (priv->video_output != NULL)
2838 gtk_box_set_child_packing (GTK_BOX (priv->content_hbox),
2839 priv->video_output, TRUE, TRUE,
2840 set_fullscreen ? 0 : CONTENT_HBOX_CHILDREN_PACKING_PADDING,
2847 empathy_call_window_state_event_cb (GtkWidget *widget,
2848 GdkEventWindowState *event, EmpathyCallWindow *window)
2850 if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
2852 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2853 gboolean set_fullscreen = event->new_window_state &
2854 GDK_WINDOW_STATE_FULLSCREEN;
2858 gboolean sidebar_was_visible;
2859 GtkAllocation allocation;
2860 gint original_width, original_height;
2862 gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
2863 original_width = allocation.width;
2864 original_height = allocation.height;
2866 g_object_get (priv->sidebar, "visible", &sidebar_was_visible, NULL);
2868 priv->sidebar_was_visible_before_fs = sidebar_was_visible;
2869 priv->original_width_before_fs = original_width;
2870 priv->original_height_before_fs = original_height;
2872 if (priv->video_output_motion_handler_id == 0 &&
2873 priv->video_output != NULL)
2875 priv->video_output_motion_handler_id = g_signal_connect (
2876 G_OBJECT (priv->video_container), "motion-notify-event",
2877 G_CALLBACK (empathy_call_window_video_output_motion_notify),
2883 disconnect_video_output_motion_handler (window);
2886 empathy_call_window_fullscreen_set_fullscreen (priv->fullscreen,
2888 show_controls (window, set_fullscreen);
2889 show_borders (window, set_fullscreen);
2890 gtk_action_set_stock_id (priv->menu_fullscreen,
2891 (set_fullscreen ? "gtk-leave-fullscreen" : "gtk-fullscreen"));
2892 priv->is_fullscreen = set_fullscreen;
2899 empathy_call_window_update_sidebar_buttons (EmpathyCallWindow *window,
2902 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2904 /* Update dialpad button */
2905 g_signal_handlers_block_by_func (priv->dialpad_button,
2906 empathy_call_window_dialpad_cb, window);
2907 gtk_toggle_tool_button_set_active (
2908 GTK_TOGGLE_TOOL_BUTTON (priv->dialpad_button),
2910 g_signal_handlers_unblock_by_func (priv->dialpad_button,
2911 empathy_call_window_dialpad_cb, window);
2913 /* Update sidebar menu */
2914 g_signal_handlers_block_by_func (priv->menu_sidebar,
2915 empathy_call_window_sidebar_cb, window);
2916 gtk_toggle_action_set_active (
2917 GTK_TOGGLE_ACTION (priv->menu_sidebar),
2918 gtk_widget_get_visible (priv->sidebar));
2919 g_signal_handlers_unblock_by_func (priv->menu_sidebar,
2920 empathy_call_window_sidebar_cb, window);
2924 empathy_call_window_show_sidebar (EmpathyCallWindow *window,
2927 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2928 int w, h, sidebar_width, handle_size;
2929 GtkAllocation allocation;
2931 gboolean dialpad_shown;
2933 gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
2934 w = allocation.width;
2935 h = allocation.height;
2937 gtk_widget_style_get (priv->pane, "handle_size", &handle_size, NULL);
2939 gtk_widget_get_preferred_width (priv->sidebar, &sidebar_width, NULL);
2943 gtk_widget_show (priv->sidebar);
2944 w += sidebar_width + handle_size;
2948 w -= sidebar_width + handle_size;
2949 gtk_widget_hide (priv->sidebar);
2953 gtk_window_resize (GTK_WINDOW (window), w, h);
2955 /* Update the 'Dialpad' menu */
2956 page = ev_sidebar_get_current_page (EV_SIDEBAR (priv->sidebar));
2957 dialpad_shown = active && !tp_strdiff (page, "dialpad");
2960 empathy_call_window_update_sidebar_buttons (window, dialpad_shown);
2964 empathy_call_window_set_send_video (EmpathyCallWindow *window,
2967 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2968 TpyCallChannel *call;
2970 priv->sending_video = (state == CAMERA_STATE_ON);
2972 if (state == CAMERA_STATE_ON)
2974 /* When we start sending video, we want to show the video preview by
2976 display_video_preview (window, TRUE);
2980 display_video_preview (window, FALSE);
2983 if (priv->call_state != CONNECTED)
2986 g_object_get (priv->handler, "call-channel", &call, NULL);
2987 DEBUG ("%s sending video", priv->sending_video ? "start": "stop");
2988 tpy_call_channel_send_video (call, priv->sending_video);
2989 g_object_unref (call);
2993 empathy_call_window_mic_toggled_cb (GtkToggleToolButton *toggle,
2994 EmpathyCallWindow *window)
2996 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2999 active = (gtk_toggle_tool_button_get_active (toggle));
3003 g_settings_set_double (priv->settings, EMPATHY_PREFS_CALL_SOUND_VOLUME,
3004 priv->volume * 100);
3008 /* TODO, Instead of setting the input volume to 0 we should probably
3009 * stop sending but this would cause the audio call to drop if both
3010 * sides mute at the same time on certain CMs AFAIK. Need to revisit this
3011 * in the future. GNOME #574574
3013 g_settings_set_double (priv->settings, EMPATHY_PREFS_CALL_SOUND_VOLUME,
3019 empathy_call_window_sidebar_hidden_cb (EvSidebar *sidebar,
3020 EmpathyCallWindow *window)
3022 empathy_call_window_show_sidebar (window, FALSE);
3026 empathy_call_window_sidebar_shown_cb (EvSidebar *sidebar,
3027 EmpathyCallWindow *window)
3029 empathy_call_window_show_sidebar (window, TRUE);
3033 empathy_call_window_sidebar_changed_cb (EvSidebar *sidebar,
3035 EmpathyCallWindow *window)
3037 empathy_call_window_update_sidebar_buttons (window,
3038 !tp_strdiff (page, "dialpad"));
3042 empathy_call_window_hangup_cb (gpointer object,
3043 EmpathyCallWindow *window)
3045 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3047 empathy_call_handler_stop_call (priv->handler);
3049 if (empathy_call_window_disconnected (window, FALSE))
3050 gtk_widget_destroy (GTK_WIDGET (window));
3054 empathy_call_window_restart_call (EmpathyCallWindow *window)
3056 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3058 /* Remove error info bars */
3059 gtk_container_forall (GTK_CONTAINER (priv->errors_vbox),
3060 (GtkCallback) gtk_widget_destroy, NULL);
3062 create_video_output_widget (window);
3064 /* While the call was disconnected, the input volume might have changed.
3065 * However, since the audio_input source was destroyed, its volume has not
3066 * been updated during that time. That's why we manually update it here */
3067 empathy_call_window_mic_volume_changed (window);
3069 priv->outgoing = TRUE;
3070 empathy_call_window_set_state_connecting (window);
3072 if (priv->pipeline_playing)
3073 start_call (window);
3075 /* call will be started when the pipeline is ready */
3076 priv->start_call_when_playing = TRUE;
3078 empathy_call_window_setup_avatars (window, priv->handler);
3080 empathy_call_window_show_hangup_button (window, TRUE);
3084 empathy_call_window_dialpad_cb (GtkToggleToolButton *button,
3085 EmpathyCallWindow *window)
3087 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3090 active = gtk_toggle_tool_button_get_active (button);
3093 ev_sidebar_set_current_page (EV_SIDEBAR (priv->sidebar), "dialpad");
3095 empathy_call_window_show_sidebar (window, active);
3099 empathy_call_window_sidebar_cb (GtkToggleAction *menu,
3100 EmpathyCallWindow *self)
3102 empathy_call_window_show_sidebar (self,
3103 gtk_toggle_action_get_active (menu));
3107 empathy_call_window_fullscreen_cb (gpointer object,
3108 EmpathyCallWindow *window)
3110 empathy_call_window_fullscreen_toggle (window);
3114 empathy_call_window_fullscreen_toggle (EmpathyCallWindow *window)
3116 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3118 if (priv->is_fullscreen)
3119 gtk_window_unfullscreen (GTK_WINDOW (window));
3121 gtk_window_fullscreen (GTK_WINDOW (window));
3125 empathy_call_window_video_button_press_cb (GtkWidget *video_preview,
3126 GdkEventButton *event, EmpathyCallWindow *window)
3128 if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
3130 empathy_call_window_video_menu_popup (window, event->button);
3138 empathy_call_window_key_press_cb (GtkWidget *video_output,
3139 GdkEventKey *event, EmpathyCallWindow *window)
3141 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3143 if (priv->is_fullscreen && event->keyval == GDK_KEY_Escape)
3145 /* Since we are in fullscreen mode, toggling will bring us back to
3147 empathy_call_window_fullscreen_toggle (window);
3155 empathy_call_window_video_output_motion_notify (GtkWidget *widget,
3156 GdkEventMotion *event, EmpathyCallWindow *window)
3158 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3160 if (priv->is_fullscreen)
3162 empathy_call_window_fullscreen_show_popup (priv->fullscreen);
3169 empathy_call_window_video_menu_popup (EmpathyCallWindow *window,
3173 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3175 menu = gtk_ui_manager_get_widget (priv->ui_manager,
3177 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
3178 button, gtk_get_current_event_time ());
3179 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
3183 empathy_call_window_status_message (EmpathyCallWindow *self,
3186 gtk_label_set_label (GTK_LABEL (self->priv->status_label), message);
3190 empathy_call_window_volume_changed_cb (GtkScaleButton *button,
3191 gdouble value, EmpathyCallWindow *window)
3193 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3195 if (priv->audio_output == NULL)
3198 empathy_audio_sink_set_volume (EMPATHY_GST_AUDIO_SINK (priv->audio_output),