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-tp-contact-factory.h>
45 #include <libempathy/empathy-utils.h>
46 #include <libempathy-gtk/empathy-avatar-image.h>
47 #include <libempathy-gtk/empathy-ui-utils.h>
48 #include <libempathy-gtk/empathy-sound-manager.h>
49 #include <libempathy-gtk/empathy-geometry.h>
50 #include <libempathy-gtk/empathy-images.h>
52 #define DEBUG_FLAG EMPATHY_DEBUG_VOIP
53 #include <libempathy/empathy-debug.h>
55 #include "empathy-call-window.h"
56 #include "empathy-call-window-fullscreen.h"
57 #include "empathy-call-factory.h"
58 #include "empathy-video-widget.h"
59 #include "empathy-audio-src.h"
60 #include "empathy-audio-sink.h"
61 #include "empathy-video-src.h"
62 #include "ev-sidebar.h"
64 #define CONTENT_HBOX_BORDER_WIDTH 6
65 #define CONTENT_HBOX_SPACING 3
66 #define CONTENT_HBOX_CHILDREN_PACKING_PADDING 3
68 #define SELF_VIDEO_SECTION_WIDTH 120
69 #define SELF_VIDEO_SECTION_HEIGTH 90
71 /* The avatar's default width and height are set to the same value because we
72 want a square icon. */
73 #define REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH EMPATHY_VIDEO_WIDGET_DEFAULT_HEIGHT
74 #define REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT \
75 EMPATHY_VIDEO_WIDGET_DEFAULT_HEIGHT
77 /* If an video input error occurs, the error message will start with "v4l" */
78 #define VIDEO_INPUT_ERROR_PREFIX "v4l"
80 /* The time interval in milliseconds between 2 outgoing rings */
81 #define MS_BETWEEN_RING 500
83 G_DEFINE_TYPE(EmpathyCallWindow, empathy_call_window, GTK_TYPE_WINDOW)
86 PROP_CALL_HANDLER = 1,
102 struct _EmpathyCallWindowPriv
104 gboolean dispose_has_run;
105 EmpathyCallHandler *handler;
107 EmpathyContact *contact;
109 EmpathyCameraMonitor *camera_monitor;
114 GtkUIManager *ui_manager;
115 GtkWidget *errors_vbox;
116 /* widget displays the video received from the remote user. This widget is
117 * alive only during call. */
118 ClutterActor *video_output;
119 ClutterActor *video_preview;
120 ClutterActor *preview_hidden_button;
121 GtkWidget *video_container;
122 GtkWidget *remote_user_avatar_widget;
124 GtkWidget *statusbar;
125 GtkWidget *volume_button;
126 GtkWidget *redial_button;
127 GtkWidget *mic_button;
128 GtkWidget *camera_button;
129 GtkWidget *dialpad_button;
133 GtkAction *menu_sidebar;
134 GtkAction *menu_fullscreen;
136 /* The box that contains self and remote avatar and video
137 input/output. When we redial, we destroy and re-create the box */
138 ClutterActor *video_box;
139 ClutterLayoutManager *video_layout;
141 /* We keep a reference on the hbox which contains the main content so we can
142 easilly repack everything when toggling fullscreen */
143 GtkWidget *content_hbox;
145 gulong video_output_motion_handler_id;
146 guint bus_message_source_id;
149 GtkWidget *volume_scale;
150 GtkWidget *volume_progress_bar;
151 GtkAdjustment *audio_input_adj;
153 GtkWidget *dtmf_panel;
156 GtkWidget *details_vbox;
157 GtkWidget *vcodec_encoding_label;
158 GtkWidget *acodec_encoding_label;
159 GtkWidget *vcodec_decoding_label;
160 GtkWidget *acodec_decoding_label;
162 GtkWidget *audio_remote_candidate_label;
163 GtkWidget *audio_local_candidate_label;
164 GtkWidget *video_remote_candidate_label;
165 GtkWidget *video_local_candidate_label;
166 GtkWidget *video_remote_candidate_info_img;
167 GtkWidget *video_local_candidate_info_img;
168 GtkWidget *audio_remote_candidate_info_img;
169 GtkWidget *audio_local_candidate_info_img;
171 GstElement *video_input;
172 GstElement *video_preview_sink;
173 GstElement *video_output_sink;
174 GstElement *audio_input;
175 GstElement *audio_output;
176 GstElement *pipeline;
177 GstElement *video_tee;
188 GtkWidget *video_contrast;
189 GtkWidget *video_brightness;
190 GtkWidget *video_gamma;
193 gboolean call_started;
194 gboolean sending_video;
195 CameraState camera_state;
197 EmpathyCallWindowFullscreen *fullscreen;
198 gboolean is_fullscreen;
203 /* Those fields represent the state of the window before it actually was in
205 gboolean sidebar_was_visible_before_fs;
206 gint original_width_before_fs;
207 gint original_height_before_fs;
209 gint x, y, w, h, sidebar_width;
212 /* TRUE if the call should be started when the pipeline is playing */
213 gboolean start_call_when_playing;
214 /* TRUE if we requested to set the pipeline in the playing state */
215 gboolean pipeline_playing;
217 EmpathySoundManager *sound_mgr;
220 #define GET_PRIV(o) (EMPATHY_CALL_WINDOW (o)->priv)
222 static void empathy_call_window_realized_cb (GtkWidget *widget,
223 EmpathyCallWindow *window);
225 static gboolean empathy_call_window_delete_cb (GtkWidget *widget,
226 GdkEvent *event, EmpathyCallWindow *window);
228 static gboolean empathy_call_window_state_event_cb (GtkWidget *widget,
229 GdkEventWindowState *event, EmpathyCallWindow *window);
231 static void empathy_call_window_set_send_video (EmpathyCallWindow *window,
234 static void empathy_call_window_mic_toggled_cb (
235 GtkToggleToolButton *toggle, EmpathyCallWindow *window);
237 static void empathy_call_window_sidebar_cb (GtkToggleAction *menu,
238 EmpathyCallWindow *self);
240 static void empathy_call_window_sidebar_hidden_cb (EvSidebar *sidebar,
241 EmpathyCallWindow *window);
243 static void empathy_call_window_sidebar_shown_cb (EvSidebar *sidebar,
244 EmpathyCallWindow *window);
246 static void empathy_call_window_sidebar_changed_cb (EvSidebar *sidebar,
248 EmpathyCallWindow *window);
250 static void empathy_call_window_hangup_cb (gpointer object,
251 EmpathyCallWindow *window);
253 static void empathy_call_window_fullscreen_cb (gpointer object,
254 EmpathyCallWindow *window);
256 static void empathy_call_window_fullscreen_toggle (EmpathyCallWindow *window);
258 static gboolean empathy_call_window_video_button_press_cb (
259 GtkWidget *video_output, GdkEventButton *event, EmpathyCallWindow *window);
261 static gboolean empathy_call_window_key_press_cb (GtkWidget *video_output,
262 GdkEventKey *event, EmpathyCallWindow *window);
264 static gboolean empathy_call_window_video_output_motion_notify (
265 GtkWidget *widget, GdkEventMotion *event, EmpathyCallWindow *window);
267 static void empathy_call_window_video_menu_popup (EmpathyCallWindow *window,
270 static void empathy_call_window_redial_cb (gpointer object,
271 EmpathyCallWindow *window);
273 static void empathy_call_window_dialpad_cb (GtkToggleToolButton *button,
274 EmpathyCallWindow *window);
276 static void empathy_call_window_restart_call (EmpathyCallWindow *window);
278 static void empathy_call_window_status_message (EmpathyCallWindow *window,
281 static gboolean empathy_call_window_bus_message (GstBus *bus,
282 GstMessage *message, gpointer user_data);
285 empathy_call_window_volume_changed_cb (GtkScaleButton *button,
286 gdouble value, EmpathyCallWindow *window);
289 empathy_call_window_setup_toolbar (EmpathyCallWindow *self)
291 EmpathyCallWindowPriv *priv = GET_PRIV (self);
292 GtkToolItem *tool_item;
294 /* Add an empty expanded GtkToolItem so the volume button is at the end of
296 tool_item = gtk_tool_item_new ();
297 gtk_tool_item_set_expand (tool_item, TRUE);
298 gtk_widget_show (GTK_WIDGET (tool_item));
299 gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), tool_item, -1);
301 priv->volume_button = gtk_volume_button_new ();
302 /* FIXME listen to the audiosinks signals and update the button according to
303 * that, for now starting out at 1.0 and assuming only the app changes the
305 gtk_scale_button_set_value (GTK_SCALE_BUTTON (priv->volume_button), 1.0);
306 g_signal_connect (G_OBJECT (priv->volume_button), "value-changed",
307 G_CALLBACK (empathy_call_window_volume_changed_cb), self);
309 tool_item = gtk_tool_item_new ();
310 gtk_container_add (GTK_CONTAINER (tool_item), priv->volume_button);
311 gtk_widget_show_all (GTK_WIDGET (tool_item));
312 gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), tool_item, -1);
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_cb (GtkAdjustment *adj,
472 EmpathyCallWindow *self)
474 EmpathyCallWindowPriv *priv = GET_PRIV (self);
477 volume = gtk_adjustment_get_value (adj)/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_audio_input_level_changed_cb (EmpathyGstAudioSrc *src,
497 gdouble level, EmpathyCallWindow *window)
500 EmpathyCallWindowPriv *priv = GET_PRIV (window);
502 value = CLAMP (pow (10, level / 20), 0.0, 1.0);
503 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->volume_progress_bar),
508 empathy_call_window_create_audio_input (EmpathyCallWindow *self)
510 EmpathyCallWindowPriv *priv = GET_PRIV (self);
511 GtkWidget *hbox, *vbox, *label;
513 hbox = gtk_hbox_new (TRUE, 3);
515 vbox = gtk_vbox_new (FALSE, 3);
516 gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 3);
518 priv->volume_scale = gtk_vscale_new_with_range (0, 150, 100);
519 gtk_range_set_inverted (GTK_RANGE (priv->volume_scale), TRUE);
520 label = gtk_label_new (_("Volume"));
522 priv->audio_input_adj = gtk_range_get_adjustment (
523 GTK_RANGE (priv->volume_scale));
524 priv->volume = empathy_audio_src_get_volume (EMPATHY_GST_AUDIO_SRC
525 (priv->audio_input));
526 gtk_adjustment_set_value (priv->audio_input_adj, priv->volume * 100);
528 g_signal_connect (G_OBJECT (priv->audio_input_adj), "value-changed",
529 G_CALLBACK (empathy_call_window_mic_volume_changed_cb), self);
531 gtk_box_pack_start (GTK_BOX (vbox), priv->volume_scale, TRUE, TRUE, 3);
532 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 3);
534 priv->volume_progress_bar = gtk_progress_bar_new ();
536 gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->volume_progress_bar),
537 GTK_ORIENTATION_VERTICAL);
539 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->volume_progress_bar),
542 gtk_box_pack_start (GTK_BOX (hbox), priv->volume_progress_bar, FALSE, FALSE,
549 empathy_call_window_show_video_output (EmpathyCallWindow *self,
552 if (self->priv->video_output != NULL)
553 g_object_set (self->priv->video_output, "visible", show, NULL);
555 gtk_widget_set_visible (self->priv->remote_user_avatar_widget, !show);
559 create_video_output_widget (EmpathyCallWindow *self)
561 EmpathyCallWindowPriv *priv = GET_PRIV (self);
563 g_assert (priv->video_output == NULL);
564 g_assert (priv->pipeline != NULL);
566 priv->video_output = clutter_texture_new ();
568 clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (priv->video_output),
571 priv->video_output_sink = clutter_gst_video_sink_new (
572 CLUTTER_TEXTURE (priv->video_output));
574 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_box),
577 gtk_widget_add_events (priv->video_container,
578 GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK);
579 g_signal_connect (G_OBJECT (priv->video_container), "button-press-event",
580 G_CALLBACK (empathy_call_window_video_button_press_cb), self);
584 create_video_input (EmpathyCallWindow *self)
586 EmpathyCallWindowPriv *priv = GET_PRIV (self);
588 g_assert (priv->video_input == NULL);
589 priv->video_input = empathy_video_src_new ();
590 gst_object_ref (priv->video_input);
591 gst_object_sink (priv->video_input);
595 create_audio_input (EmpathyCallWindow *self)
597 EmpathyCallWindowPriv *priv = GET_PRIV (self);
599 g_assert (priv->audio_input == NULL);
600 priv->audio_input = empathy_audio_src_new ();
601 gst_object_ref (priv->audio_input);
602 gst_object_sink (priv->audio_input);
604 tp_g_signal_connect_object (priv->audio_input, "peak-level-changed",
605 G_CALLBACK (empathy_call_window_audio_input_level_changed_cb),
610 add_video_preview_to_pipeline (EmpathyCallWindow *self)
612 EmpathyCallWindowPriv *priv = GET_PRIV (self);
615 g_assert (priv->video_preview != NULL);
616 g_assert (priv->pipeline != NULL);
617 g_assert (priv->video_input != NULL);
618 g_assert (priv->video_tee != NULL);
620 preview = priv->video_preview_sink;
622 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->video_input))
624 g_warning ("Could not add video input to pipeline");
628 if (!gst_bin_add (GST_BIN (priv->pipeline), preview))
630 g_warning ("Could not add video preview to pipeline");
634 if (!gst_element_link (priv->video_input, priv->video_tee))
636 g_warning ("Could not link video input to video tee");
640 if (!gst_element_link (priv->video_tee, preview))
642 g_warning ("Could not link video tee to video preview");
648 empathy_call_window_disable_camera_cb (GtkAction *action,
649 EmpathyCallWindow *self)
651 clutter_actor_destroy (self->priv->preview_hidden_button);
653 gtk_toggle_tool_button_set_active (
654 GTK_TOGGLE_TOOL_BUTTON (self->priv->camera_button), FALSE);
658 empathy_call_window_minimise_camera_cb (GtkAction *action,
659 EmpathyCallWindow *self)
661 clutter_actor_hide (self->priv->video_preview);
662 clutter_actor_show (self->priv->preview_hidden_button);
666 empathy_call_window_maximise_camera_cb (GtkAction *action,
667 EmpathyCallWindow *self)
669 clutter_actor_show (self->priv->video_preview);
670 clutter_actor_hide (self->priv->preview_hidden_button);
674 empathy_call_window_preview_button_clicked_cb (GtkButton *button,
675 EmpathyCallWindow *self)
679 menu = gtk_ui_manager_get_widget (self->priv->ui_manager,
681 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
682 0, gtk_get_current_event_time ());
683 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
687 empathy_call_window_preview_hidden_button_clicked_cb (GtkButton *button,
688 EmpathyCallWindow *self)
692 menu = gtk_ui_manager_get_widget (self->priv->ui_manager,
693 "/preview-hidden-menu");
694 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
695 0, gtk_get_current_event_time ());
696 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
700 create_video_preview (EmpathyCallWindow *self)
702 EmpathyCallWindowPriv *priv = GET_PRIV (self);
703 ClutterLayoutManager *layout, *layout_center;
704 ClutterActor *preview;
709 g_assert (priv->video_preview == NULL);
711 preview = clutter_texture_new ();
712 clutter_actor_set_size (preview,
713 SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGTH);
714 priv->video_preview_sink = clutter_gst_video_sink_new (
715 CLUTTER_TEXTURE (preview));
717 /* Flip the video preview */
718 clutter_actor_set_rotation (preview,
721 SELF_VIDEO_SECTION_WIDTH * 0.5,
725 /* Add a little offset to the video preview */
726 layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_END,
727 CLUTTER_BIN_ALIGNMENT_START);
728 priv->video_preview = clutter_box_new (layout);
729 clutter_actor_set_size (priv->video_preview,
730 SELF_VIDEO_SECTION_WIDTH + 10, SELF_VIDEO_SECTION_HEIGTH + 10);
732 layout_center = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
733 CLUTTER_BIN_ALIGNMENT_CENTER);
734 box = clutter_box_new (layout_center);
735 clutter_actor_set_size (box,
736 SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGTH);
738 clutter_container_add_actor (CLUTTER_CONTAINER (box), preview);
739 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_preview), box);
741 g_object_set (priv->video_preview_sink,
746 /* Translators: this is an "Info" label. It should be as short
748 button = gtk_button_new_with_label (_("i"));
749 b = gtk_clutter_actor_new_with_contents (button);
751 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (layout_center),
753 CLUTTER_BIN_ALIGNMENT_END,
754 CLUTTER_BIN_ALIGNMENT_END);
756 g_signal_connect (button, "clicked",
757 G_CALLBACK (empathy_call_window_preview_button_clicked_cb),
760 /* Translators: this is an "Info" label. It should be as short
762 button = gtk_button_new_with_label (_("i"));
763 priv->preview_hidden_button =
764 gtk_clutter_actor_new_with_contents (button);
766 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
767 priv->preview_hidden_button,
768 CLUTTER_BIN_ALIGNMENT_START,
769 CLUTTER_BIN_ALIGNMENT_END);
771 clutter_actor_hide (priv->preview_hidden_button);
773 g_signal_connect (button, "clicked",
774 G_CALLBACK (empathy_call_window_preview_hidden_button_clicked_cb),
777 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
779 CLUTTER_BIN_ALIGNMENT_START,
780 CLUTTER_BIN_ALIGNMENT_END);
784 play_camera (EmpathyCallWindow *window,
787 EmpathyCallWindowPriv *priv = GET_PRIV (window);
791 if (priv->video_preview == NULL)
793 create_video_preview (window);
794 add_video_preview_to_pipeline (window);
798 state = GST_STATE_PLAYING;
800 state = GST_STATE_NULL;
802 preview = priv->video_preview_sink;
804 gst_element_set_state (preview, state);
805 gst_element_set_state (priv->video_input, state);
806 gst_element_set_state (priv->video_tee, state);
810 display_video_preview (EmpathyCallWindow *self,
813 EmpathyCallWindowPriv *priv = GET_PRIV (self);
817 /* Display the video preview */
818 DEBUG ("Show video preview");
820 play_camera (self, TRUE);
821 clutter_actor_show (priv->video_preview);
825 /* Hide the video preview */
826 DEBUG ("Hide video preview");
828 if (priv->video_preview != NULL)
830 clutter_actor_hide (priv->video_preview);
831 play_camera (self, FALSE);
837 empathy_call_window_set_state_connecting (EmpathyCallWindow *window)
839 EmpathyCallWindowPriv *priv = GET_PRIV (window);
841 empathy_call_window_status_message (window, _("Connecting…"));
842 priv->call_state = CONNECTING;
845 empathy_sound_manager_start_playing (priv->sound_mgr, GTK_WIDGET (window),
846 EMPATHY_SOUND_PHONE_OUTGOING, MS_BETWEEN_RING);
850 disable_camera (EmpathyCallWindow *self)
852 EmpathyCallWindowPriv *priv = GET_PRIV (self);
854 if (priv->camera_state == CAMERA_STATE_OFF)
857 DEBUG ("Disable camera");
859 display_video_preview (self, FALSE);
861 if (priv->camera_state == CAMERA_STATE_ON)
862 empathy_call_window_set_send_video (self, CAMERA_STATE_OFF);
864 priv->camera_state = CAMERA_STATE_OFF;
868 enable_camera (EmpathyCallWindow *self)
870 EmpathyCallWindowPriv *priv = GET_PRIV (self);
872 if (priv->camera_state == CAMERA_STATE_ON)
875 if (priv->video_input == NULL)
877 DEBUG ("Can't enable camera, no input");
881 DEBUG ("Enable camera");
883 empathy_call_window_set_send_video (self, CAMERA_STATE_ON);
885 priv->camera_state = CAMERA_STATE_ON;
889 empathy_call_window_camera_toggled_cb (GtkToggleToolButton *toggle,
890 EmpathyCallWindow *self)
892 if (gtk_toggle_tool_button_get_active (toggle))
893 enable_camera (self);
895 disable_camera (self);
899 create_pipeline (EmpathyCallWindow *self)
901 EmpathyCallWindowPriv *priv = GET_PRIV (self);
904 g_assert (priv->pipeline == NULL);
906 priv->pipeline = gst_pipeline_new (NULL);
907 priv->pipeline_playing = FALSE;
909 priv->video_tee = gst_element_factory_make ("tee", NULL);
910 gst_object_ref (priv->video_tee);
911 gst_object_sink (priv->video_tee);
913 gst_bin_add (GST_BIN (priv->pipeline), priv->video_tee);
915 bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
916 priv->bus_message_source_id = gst_bus_add_watch (bus,
917 empathy_call_window_bus_message, self);
919 g_object_unref (bus);
923 empathy_call_window_configure_event_cb (GtkWidget *widget,
925 EmpathyCallWindow *self)
927 GdkWindow *gdk_window;
928 GdkWindowState window_state;
930 gtk_window_get_position (GTK_WINDOW (self), &self->priv->x, &self->priv->y);
931 gtk_window_get_size (GTK_WINDOW (self), &self->priv->w, &self->priv->h);
933 gtk_widget_get_preferred_width (self->priv->sidebar,
934 &self->priv->sidebar_width, NULL);
936 gdk_window = gtk_widget_get_window (widget);
937 window_state = gdk_window_get_state (gdk_window);
938 self->priv->maximized = (window_state & GDK_WINDOW_STATE_MAXIMIZED);
944 empathy_call_window_destroyed_cb (GtkWidget *object,
945 EmpathyCallWindow *self)
947 if (gtk_widget_get_visible (self->priv->sidebar))
949 /* Save the geometry as if the sidebar was hidden. */
950 empathy_geometry_save_values (GTK_WINDOW (self),
951 self->priv->x, self->priv->y,
952 self->priv->w - self->priv->sidebar_width, self->priv->h,
953 self->priv->maximized);
958 empathy_call_window_init (EmpathyCallWindow *self)
960 EmpathyCallWindowPriv *priv;
966 ClutterConstraint *size_constraint;
967 ClutterActor *remote_avatar;
968 GtkStyleContext *context;
972 priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
973 EMPATHY_TYPE_CALL_WINDOW, EmpathyCallWindowPriv);
975 filename = empathy_file_lookup ("empathy-call-window.ui", "src");
976 gui = empathy_builder_get_file (filename,
977 "call_window_vbox", &top_vbox,
978 "errors_vbox", &priv->errors_vbox,
980 "statusbar", &priv->statusbar,
981 "redial", &priv->redial_button,
982 "microphone", &priv->mic_button,
983 "camera", &priv->camera_button,
984 "dialpad", &priv->dialpad_button,
985 "toolbar", &priv->toolbar,
986 "menuredial", &priv->redial,
987 "menusidebar", &priv->menu_sidebar,
988 "ui_manager", &priv->ui_manager,
989 "menufullscreen", &priv->menu_fullscreen,
990 "details_vbox", &priv->details_vbox,
991 "vcodec_encoding_label", &priv->vcodec_encoding_label,
992 "acodec_encoding_label", &priv->acodec_encoding_label,
993 "acodec_decoding_label", &priv->acodec_decoding_label,
994 "vcodec_decoding_label", &priv->vcodec_decoding_label,
995 "audio_remote_candidate_label", &priv->audio_remote_candidate_label,
996 "audio_local_candidate_label", &priv->audio_local_candidate_label,
997 "video_remote_candidate_label", &priv->video_remote_candidate_label,
998 "video_local_candidate_label", &priv->video_local_candidate_label,
999 "video_remote_candidate_info_img", &priv->video_remote_candidate_info_img,
1000 "video_local_candidate_info_img", &priv->video_local_candidate_info_img,
1001 "audio_remote_candidate_info_img", &priv->audio_remote_candidate_info_img,
1002 "audio_local_candidate_info_img", &priv->audio_local_candidate_info_img,
1006 empathy_builder_connect (gui, self,
1007 "menuhangup", "activate", empathy_call_window_hangup_cb,
1008 "hangup", "clicked", empathy_call_window_hangup_cb,
1009 "menuredial", "activate", empathy_call_window_redial_cb,
1010 "redial", "clicked", empathy_call_window_redial_cb,
1011 "menusidebar", "toggled", empathy_call_window_sidebar_cb,
1012 "microphone", "toggled", empathy_call_window_mic_toggled_cb,
1013 "camera", "toggled", empathy_call_window_camera_toggled_cb,
1014 "dialpad", "toggled", empathy_call_window_dialpad_cb,
1015 "menufullscreen", "activate", empathy_call_window_fullscreen_cb,
1016 "menupreviewdisable", "activate", empathy_call_window_disable_camera_cb,
1017 "menupreviewminimise", "activate", empathy_call_window_minimise_camera_cb,
1018 "menupreviewmaximise", "activate", empathy_call_window_maximise_camera_cb,
1021 gtk_action_set_sensitive (priv->menu_fullscreen, FALSE);
1023 priv->camera_monitor = empathy_camera_monitor_dup_singleton ();
1025 g_object_bind_property (priv->camera_monitor, "available",
1026 priv->camera_button, "sensitive",
1027 G_BINDING_SYNC_CREATE);
1029 priv->lock = g_mutex_new ();
1031 gtk_container_add (GTK_CONTAINER (self), top_vbox);
1033 priv->content_hbox = gtk_hbox_new (FALSE, CONTENT_HBOX_SPACING);
1034 gtk_container_set_border_width (GTK_CONTAINER (priv->content_hbox),
1035 CONTENT_HBOX_BORDER_WIDTH);
1036 gtk_paned_pack1 (GTK_PANED (priv->pane), priv->content_hbox, TRUE, FALSE);
1038 /* avatar/video box */
1039 priv->video_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
1040 CLUTTER_BIN_ALIGNMENT_CENTER);
1042 priv->video_box = clutter_box_new (priv->video_layout);
1044 priv->video_container = gtk_clutter_embed_new ();
1046 /* Set the background color to that of the rest of the window */
1047 context = gtk_widget_get_style_context (priv->content_hbox);
1048 gtk_style_context_get_background_color (context,
1049 GTK_STATE_FLAG_NORMAL, &rgba);
1050 bg.red = CLAMP (rgba.red * 255.0, 0, 255);
1051 bg.green = CLAMP (rgba.green * 255.0, 0, 255);
1052 bg.blue = CLAMP (rgba.blue * 255.0, 0, 255);
1053 bg.alpha = CLAMP (rgba.alpha * 255.0, 0, 255);
1054 clutter_stage_set_color (
1055 CLUTTER_STAGE (gtk_clutter_embed_get_stage (
1056 GTK_CLUTTER_EMBED (priv->video_container))),
1059 clutter_container_add (
1060 CLUTTER_CONTAINER (gtk_clutter_embed_get_stage (
1061 GTK_CLUTTER_EMBED (priv->video_container))),
1065 size_constraint = clutter_bind_constraint_new (
1066 gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->video_container)),
1067 CLUTTER_BIND_SIZE, 0);
1068 clutter_actor_add_constraint (priv->video_box, size_constraint);
1070 priv->remote_user_avatar_widget = gtk_image_new ();
1071 remote_avatar = gtk_clutter_actor_new_with_contents (
1072 priv->remote_user_avatar_widget);
1074 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_box),
1077 gtk_box_pack_start (GTK_BOX (priv->content_hbox),
1078 priv->video_container, TRUE, TRUE,
1079 CONTENT_HBOX_CHILDREN_PACKING_PADDING);
1081 create_pipeline (self);
1082 create_video_output_widget (self);
1083 create_audio_input (self);
1084 create_video_input (self);
1086 /* The call will be started as soon the pipeline is playing */
1087 priv->start_call_when_playing = TRUE;
1089 empathy_call_window_setup_toolbar (self);
1091 priv->sidebar = ev_sidebar_new ();
1092 g_signal_connect (G_OBJECT (priv->sidebar),
1093 "hide", G_CALLBACK (empathy_call_window_sidebar_hidden_cb), self);
1094 g_signal_connect (G_OBJECT (priv->sidebar),
1095 "show", G_CALLBACK (empathy_call_window_sidebar_shown_cb), self);
1096 g_signal_connect (G_OBJECT (priv->sidebar), "changed",
1097 G_CALLBACK (empathy_call_window_sidebar_changed_cb), self);
1098 gtk_paned_pack2 (GTK_PANED (priv->pane), priv->sidebar, FALSE, FALSE);
1100 page = empathy_call_window_create_audio_input (self);
1101 ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "audio-input",
1102 _("Audio input"), page);
1104 page = empathy_call_window_create_video_input (self);
1105 ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "video-input",
1106 _("Video input"), page);
1108 priv->dtmf_panel = empathy_create_dtmf_dialpad (G_OBJECT (self),
1109 G_CALLBACK (dtmf_button_pressed_cb),
1110 G_CALLBACK (dtmf_button_released_cb));
1111 ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "dialpad",
1112 _("Dialpad"), priv->dtmf_panel);
1114 gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
1116 /* Put the details vbox in a scroll window as it can require a lot of
1117 * horizontal space. */
1118 scroll = gtk_scrolled_window_new (NULL, NULL);
1119 gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll),
1120 priv->details_vbox);
1122 ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "details", _("Details"),
1125 gtk_widget_show_all (top_vbox);
1127 gtk_widget_hide (priv->sidebar);
1129 priv->fullscreen = empathy_call_window_fullscreen_new (self);
1131 empathy_call_window_fullscreen_set_video_widget (priv->fullscreen,
1132 priv->video_container);
1134 g_signal_connect (G_OBJECT (priv->fullscreen->leave_fullscreen_button),
1135 "clicked", G_CALLBACK (empathy_call_window_fullscreen_cb), self);
1137 g_signal_connect (G_OBJECT (self), "realize",
1138 G_CALLBACK (empathy_call_window_realized_cb), self);
1140 g_signal_connect (G_OBJECT (self), "delete-event",
1141 G_CALLBACK (empathy_call_window_delete_cb), self);
1143 g_signal_connect (G_OBJECT (self), "window-state-event",
1144 G_CALLBACK (empathy_call_window_state_event_cb), self);
1146 g_signal_connect (G_OBJECT (self), "key-press-event",
1147 G_CALLBACK (empathy_call_window_key_press_cb), self);
1149 priv->timer = g_timer_new ();
1151 g_object_ref (priv->ui_manager);
1152 g_object_unref (gui);
1154 priv->sound_mgr = empathy_sound_manager_dup_singleton ();
1156 empathy_geometry_bind (GTK_WINDOW (self), "call-window");
1157 /* These signals are used to track the window position and save it
1158 * when the window is destroyed. We need to do this as we don't want
1159 * the window geometry to be saved with the sidebar taken into account. */
1160 g_signal_connect (self, "destroy",
1161 G_CALLBACK (empathy_call_window_destroyed_cb), self);
1162 g_signal_connect (self, "configure-event",
1163 G_CALLBACK (empathy_call_window_configure_event_cb), self);
1164 g_signal_connect (self, "window-state-event",
1165 G_CALLBACK (empathy_call_window_configure_event_cb), self);
1168 /* Instead of specifying a width and a height, we specify only one size. That's
1169 because we want a square avatar icon. */
1171 init_contact_avatar_with_size (EmpathyContact *contact,
1172 GtkWidget *image_widget,
1175 GdkPixbuf *pixbuf_avatar = NULL;
1177 if (contact != NULL)
1179 pixbuf_avatar = empathy_pixbuf_avatar_from_contact_scaled (contact,
1183 if (pixbuf_avatar == NULL)
1185 pixbuf_avatar = empathy_pixbuf_from_icon_name_sized (
1186 EMPATHY_IMAGE_AVATAR_DEFAULT, size);
1189 gtk_image_set_from_pixbuf (GTK_IMAGE (image_widget), pixbuf_avatar);
1191 if (pixbuf_avatar != NULL)
1192 g_object_unref (pixbuf_avatar);
1196 set_window_title (EmpathyCallWindow *self)
1198 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1201 if (priv->contact != NULL)
1203 /* translators: Call is a noun and %s is the contact name. This string
1204 * is used in the window title */
1205 tmp = g_strdup_printf (_("Call with %s"),
1206 empathy_contact_get_alias (priv->contact));
1207 gtk_window_set_title (GTK_WINDOW (self), tmp);
1212 gtk_window_set_title (GTK_WINDOW (self), _("Call with %d participants"));
1217 contact_name_changed_cb (EmpathyContact *contact,
1218 GParamSpec *pspec, EmpathyCallWindow *self)
1220 set_window_title (self);
1224 contact_avatar_changed_cb (EmpathyContact *contact,
1225 GParamSpec *pspec, GtkWidget *avatar_widget)
1228 GtkAllocation allocation;
1230 gtk_widget_get_allocation (avatar_widget, &allocation);
1231 size = allocation.height;
1235 /* the widget is not allocated yet, set a default size */
1236 size = MIN (REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT,
1237 REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH);
1240 init_contact_avatar_with_size (contact, avatar_widget, size);
1244 empathy_call_window_setup_avatars (EmpathyCallWindow *self,
1245 EmpathyCallHandler *handler)
1247 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1249 g_signal_connect (priv->contact, "notify::name",
1250 G_CALLBACK (contact_name_changed_cb), self);
1251 g_signal_connect (priv->contact, "notify::avatar",
1252 G_CALLBACK (contact_avatar_changed_cb),
1253 priv->remote_user_avatar_widget);
1255 set_window_title (self);
1257 init_contact_avatar_with_size (priv->contact,
1258 priv->remote_user_avatar_widget,
1259 MIN (REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH,
1260 REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT));
1262 /* The remote avatar is shown by default and will be hidden when we receive
1263 video from the remote side. */
1264 clutter_actor_hide (priv->video_output);
1265 gtk_widget_show (priv->remote_user_avatar_widget);
1269 update_send_codec (EmpathyCallWindow *self,
1272 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1279 codec = empathy_call_handler_get_send_audio_codec (priv->handler);
1280 widget = priv->acodec_encoding_label;
1284 codec = empathy_call_handler_get_send_video_codec (priv->handler);
1285 widget = priv->vcodec_encoding_label;
1291 tmp = g_strdup_printf ("%s/%u", codec->encoding_name, codec->clock_rate);
1292 gtk_label_set_text (GTK_LABEL (widget), tmp);
1297 send_audio_codec_notify_cb (GObject *object,
1301 EmpathyCallWindow *self = user_data;
1303 update_send_codec (self, TRUE);
1307 send_video_codec_notify_cb (GObject *object,
1311 EmpathyCallWindow *self = user_data;
1313 update_send_codec (self, FALSE);
1317 update_recv_codec (EmpathyCallWindow *self,
1320 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1323 GString *str = NULL;
1327 codecs = empathy_call_handler_get_recv_audio_codecs (priv->handler);
1328 widget = priv->acodec_decoding_label;
1332 codecs = empathy_call_handler_get_recv_video_codecs (priv->handler);
1333 widget = priv->vcodec_decoding_label;
1339 for (l = codecs; l != NULL; l = g_list_next (l))
1341 FsCodec *codec = l->data;
1344 str = g_string_new (NULL);
1346 g_string_append (str, ", ");
1348 g_string_append_printf (str, "%s/%u", codec->encoding_name,
1352 gtk_label_set_text (GTK_LABEL (widget), str->str);
1353 g_string_free (str, TRUE);
1357 recv_audio_codecs_notify_cb (GObject *object,
1361 EmpathyCallWindow *self = user_data;
1363 update_recv_codec (self, TRUE);
1367 recv_video_codecs_notify_cb (GObject *object,
1371 EmpathyCallWindow *self = user_data;
1373 update_recv_codec (self, FALSE);
1376 static const gchar *
1377 candidate_type_to_str (FsCandidate *candidate)
1379 switch (candidate->type)
1381 case FS_CANDIDATE_TYPE_HOST:
1383 case FS_CANDIDATE_TYPE_SRFLX:
1384 return "server reflexive";
1385 case FS_CANDIDATE_TYPE_PRFLX:
1386 return "peer reflexive";
1387 case FS_CANDIDATE_TYPE_RELAY:
1389 case FS_CANDIDATE_TYPE_MULTICAST:
1396 static const gchar *
1397 candidate_type_to_desc (FsCandidate *candidate)
1399 switch (candidate->type)
1401 case FS_CANDIDATE_TYPE_HOST:
1402 return _("The IP address as seen by the machine");
1403 case FS_CANDIDATE_TYPE_SRFLX:
1404 return _("The IP address as seen by a server on the Internet");
1405 case FS_CANDIDATE_TYPE_PRFLX:
1406 return _("The IP address of the peer as seen by the other side");
1407 case FS_CANDIDATE_TYPE_RELAY:
1408 return _("The IP address of a relay server");
1409 case FS_CANDIDATE_TYPE_MULTICAST:
1410 return _("The IP address of the multicast group");
1417 update_candidat_widget (EmpathyCallWindow *self,
1420 FsCandidate *candidate)
1424 g_assert (candidate != NULL);
1425 str = g_strdup_printf ("%s %u (%s)", candidate->ip,
1426 candidate->port, candidate_type_to_str (candidate));
1428 gtk_label_set_text (GTK_LABEL (label), str);
1429 gtk_widget_set_tooltip_text (img, candidate_type_to_desc (candidate));
1435 candidates_changed_cb (GObject *object,
1437 EmpathyCallWindow *self)
1439 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1440 FsCandidate *candidate = NULL;
1442 if (type == FS_MEDIA_TYPE_VIDEO)
1444 /* Update remote candidate */
1445 candidate = empathy_call_handler_get_video_remote_candidate (
1448 update_candidat_widget (self, priv->video_remote_candidate_label,
1449 priv->video_remote_candidate_info_img, candidate);
1451 /* Update local candidate */
1452 candidate = empathy_call_handler_get_video_local_candidate (
1455 update_candidat_widget (self, priv->video_local_candidate_label,
1456 priv->video_local_candidate_info_img, candidate);
1460 /* Update remote candidate */
1461 candidate = empathy_call_handler_get_audio_remote_candidate (
1464 update_candidat_widget (self, priv->audio_remote_candidate_label,
1465 priv->audio_remote_candidate_info_img, candidate);
1467 /* Update local candidate */
1468 candidate = empathy_call_handler_get_audio_local_candidate (
1471 update_candidat_widget (self, priv->audio_local_candidate_label,
1472 priv->audio_local_candidate_info_img, candidate);
1477 empathy_call_window_constructed (GObject *object)
1479 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
1480 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1481 TpyCallChannel *call;
1483 g_assert (priv->handler != NULL);
1485 g_object_get (priv->handler, "call-channel", &call, NULL);
1486 priv->outgoing = (call == NULL);
1488 g_object_unref (call);
1490 g_object_get (priv->handler, "target-contact", &priv->contact, NULL);
1491 g_assert (priv->contact != NULL);
1493 empathy_call_window_setup_avatars (self, priv->handler);
1494 empathy_call_window_set_state_connecting (self);
1496 if (!empathy_call_handler_has_initial_video (priv->handler))
1498 gtk_toggle_tool_button_set_active (
1499 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), FALSE);
1501 /* If call has InitialVideo, the preview will be started once the call has
1502 * been started (start_call()). */
1504 update_send_codec (self, TRUE);
1505 update_send_codec (self, FALSE);
1506 update_recv_codec (self, TRUE);
1507 update_recv_codec (self, FALSE);
1509 tp_g_signal_connect_object (priv->handler, "notify::send-audio-codec",
1510 G_CALLBACK (send_audio_codec_notify_cb), self, 0);
1511 tp_g_signal_connect_object (priv->handler, "notify::send-video-codec",
1512 G_CALLBACK (send_video_codec_notify_cb), self, 0);
1513 tp_g_signal_connect_object (priv->handler, "notify::recv-audio-codecs",
1514 G_CALLBACK (recv_audio_codecs_notify_cb), self, 0);
1515 tp_g_signal_connect_object (priv->handler, "notify::recv-video-codecs",
1516 G_CALLBACK (recv_video_codecs_notify_cb), self, 0);
1518 tp_g_signal_connect_object (priv->handler, "candidates-changed",
1519 G_CALLBACK (candidates_changed_cb), self, 0);
1522 static void empathy_call_window_dispose (GObject *object);
1523 static void empathy_call_window_finalize (GObject *object);
1526 empathy_call_window_set_property (GObject *object,
1527 guint property_id, const GValue *value, GParamSpec *pspec)
1529 EmpathyCallWindowPriv *priv = GET_PRIV (object);
1531 switch (property_id)
1533 case PROP_CALL_HANDLER:
1534 priv->handler = g_value_dup_object (value);
1537 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1542 empathy_call_window_get_property (GObject *object,
1543 guint property_id, GValue *value, GParamSpec *pspec)
1545 EmpathyCallWindowPriv *priv = GET_PRIV (object);
1547 switch (property_id)
1549 case PROP_CALL_HANDLER:
1550 g_value_set_object (value, priv->handler);
1553 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1558 empathy_call_window_class_init (
1559 EmpathyCallWindowClass *empathy_call_window_class)
1561 GObjectClass *object_class = G_OBJECT_CLASS (empathy_call_window_class);
1562 GParamSpec *param_spec;
1564 g_type_class_add_private (empathy_call_window_class,
1565 sizeof (EmpathyCallWindowPriv));
1567 object_class->constructed = empathy_call_window_constructed;
1568 object_class->set_property = empathy_call_window_set_property;
1569 object_class->get_property = empathy_call_window_get_property;
1571 object_class->dispose = empathy_call_window_dispose;
1572 object_class->finalize = empathy_call_window_finalize;
1574 param_spec = g_param_spec_object ("handler",
1575 "handler", "The call handler",
1576 EMPATHY_TYPE_CALL_HANDLER,
1577 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
1578 g_object_class_install_property (object_class,
1579 PROP_CALL_HANDLER, param_spec);
1583 empathy_call_window_dispose (GObject *object)
1585 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
1586 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1588 if (priv->dispose_has_run)
1591 priv->dispose_has_run = TRUE;
1593 if (priv->handler != NULL)
1595 empathy_call_handler_stop_call (priv->handler);
1596 tp_clear_object (&priv->handler);
1599 if (priv->bus_message_source_id != 0)
1601 g_source_remove (priv->bus_message_source_id);
1602 priv->bus_message_source_id = 0;
1605 if (priv->got_video_src > 0)
1607 g_source_remove (priv->got_video_src);
1608 priv->got_video_src = 0;
1611 tp_clear_object (&priv->pipeline);
1612 tp_clear_object (&priv->video_input);
1613 tp_clear_object (&priv->audio_input);
1614 tp_clear_object (&priv->video_tee);
1615 tp_clear_object (&priv->ui_manager);
1616 tp_clear_object (&priv->fullscreen);
1617 tp_clear_object (&priv->camera_monitor);
1619 g_list_free_full (priv->notifiers, g_object_unref);
1621 if (priv->timer_id != 0)
1622 g_source_remove (priv->timer_id);
1625 if (priv->contact != NULL)
1627 g_signal_handlers_disconnect_by_func (priv->contact,
1628 contact_name_changed_cb, self);
1629 priv->contact = NULL;
1633 tp_clear_object (&priv->sound_mgr);
1635 G_OBJECT_CLASS (empathy_call_window_parent_class)->dispose (object);
1639 disconnect_video_output_motion_handler (EmpathyCallWindow *self)
1641 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1643 if (priv->video_output_motion_handler_id != 0)
1645 g_signal_handler_disconnect (G_OBJECT (priv->video_container),
1646 priv->video_output_motion_handler_id);
1647 priv->video_output_motion_handler_id = 0;
1652 empathy_call_window_finalize (GObject *object)
1654 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
1655 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1657 disconnect_video_output_motion_handler (self);
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);
1681 FsElementAddedNotifier *notifier;
1684 DEBUG ("Conference added");
1686 /* Add notifier to set the various element properties as needed */
1687 notifier = fs_element_added_notifier_new ();
1688 keyfile = fs_utils_get_default_element_properties (conference);
1690 if (keyfile != NULL)
1691 fs_element_added_notifier_set_properties_from_keyfile (notifier, keyfile);
1693 fs_element_added_notifier_add (notifier, GST_BIN (priv->pipeline));
1695 priv->notifiers = g_list_prepend (priv->notifiers, notifier);
1697 gst_bin_add (GST_BIN (priv->pipeline), conference);
1698 gst_element_set_state (conference, GST_STATE_PLAYING);
1702 empathy_call_window_conference_removed_cb (EmpathyCallHandler *handler,
1703 GstElement *conference, gpointer user_data)
1705 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
1706 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1708 gst_bin_remove (GST_BIN (priv->pipeline), conference);
1709 gst_element_set_state (conference, GST_STATE_NULL);
1713 empathy_call_window_reset_pipeline (EmpathyCallWindow *self)
1715 GstStateChangeReturn state_change_return;
1716 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1718 if (priv->pipeline == NULL)
1721 if (priv->bus_message_source_id != 0)
1723 g_source_remove (priv->bus_message_source_id);
1724 priv->bus_message_source_id = 0;
1727 state_change_return = gst_element_set_state (priv->pipeline, GST_STATE_NULL);
1729 if (state_change_return == GST_STATE_CHANGE_SUCCESS ||
1730 state_change_return == GST_STATE_CHANGE_NO_PREROLL)
1732 if (priv->pipeline != NULL)
1733 g_object_unref (priv->pipeline);
1734 priv->pipeline = NULL;
1736 g_signal_handlers_disconnect_by_func (priv->audio_input_adj,
1737 empathy_call_window_mic_volume_changed_cb, self);
1739 if (priv->audio_output != NULL)
1740 g_object_unref (priv->audio_output);
1741 priv->audio_output = NULL;
1743 if (priv->video_tee != NULL)
1744 g_object_unref (priv->video_tee);
1745 priv->video_tee = NULL;
1747 if (priv->video_preview != NULL)
1748 clutter_actor_destroy (priv->video_preview);
1749 priv->video_preview = NULL;
1751 priv->funnel = NULL;
1753 create_pipeline (self);
1754 /* Call will be started when user will hit the 'redial' button */
1755 priv->start_call_when_playing = FALSE;
1756 gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
1762 g_message ("Error: could not destroy pipeline. Closing call window");
1763 gtk_widget_destroy (GTK_WIDGET (self));
1770 reset_details_pane (EmpathyCallWindow *self)
1772 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1774 gtk_label_set_text (GTK_LABEL (priv->vcodec_encoding_label), _("Unknown"));
1775 gtk_label_set_text (GTK_LABEL (priv->acodec_encoding_label), _("Unknown"));
1776 gtk_label_set_text (GTK_LABEL (priv->vcodec_decoding_label), _("Unknown"));
1777 gtk_label_set_text (GTK_LABEL (priv->acodec_decoding_label), _("Unknown"));
1781 empathy_call_window_disconnected (EmpathyCallWindow *self,
1784 gboolean could_disconnect = FALSE;
1785 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1786 gboolean could_reset_pipeline;
1788 /* Leave full screen mode if needed */
1789 gtk_window_unfullscreen (GTK_WINDOW (self));
1791 gtk_action_set_sensitive (priv->menu_fullscreen, FALSE);
1792 gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
1794 could_reset_pipeline = empathy_call_window_reset_pipeline (self);
1796 if (priv->call_state == CONNECTING)
1797 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
1799 if (priv->call_state != REDIALING)
1800 priv->call_state = DISCONNECTED;
1802 if (could_reset_pipeline)
1804 g_mutex_lock (priv->lock);
1806 g_timer_stop (priv->timer);
1808 if (priv->timer_id != 0)
1809 g_source_remove (priv->timer_id);
1812 g_mutex_unlock (priv->lock);
1815 /* We are about to destroy the window, no need to update it or create
1816 * a video preview */
1819 empathy_call_window_status_message (self, _("Disconnected"));
1821 gtk_action_set_sensitive (priv->redial, TRUE);
1822 gtk_widget_set_sensitive (priv->redial_button, TRUE);
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 gtk_progress_bar_set_fraction (
1839 GTK_PROGRESS_BAR (priv->volume_progress_bar), 0);
1841 /* destroy the video output; it will be recreated when we'll redial */
1842 disconnect_video_output_motion_handler (self);
1843 if (priv->video_output != NULL)
1844 clutter_actor_destroy (priv->video_output);
1845 priv->video_output = NULL;
1846 if (priv->got_video_src > 0)
1848 g_source_remove (priv->got_video_src);
1849 priv->got_video_src = 0;
1852 gtk_widget_show (priv->remote_user_avatar_widget);
1854 reset_details_pane (self);
1856 priv->sending_video = FALSE;
1857 priv->call_started = FALSE;
1859 could_disconnect = TRUE;
1861 /* TODO: display the self avatar of the preview (depends if the "Always
1862 * Show Video Preview" is enabled or not) */
1865 return could_disconnect;
1870 empathy_call_window_channel_closed_cb (EmpathyCallHandler *handler,
1873 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
1874 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1876 if (empathy_call_window_disconnected (self, TRUE) &&
1877 priv->call_state == REDIALING)
1878 empathy_call_window_restart_call (self);
1882 empathy_call_window_sink_removed_cb (EmpathyCallHandler *handler,
1884 FsMediaType media_type,
1885 EmpathyCallWindow *self)
1887 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1889 DEBUG ("removing content");
1892 * This assumes that there is only one video stream per channel...
1895 if ((guint) media_type == FS_MEDIA_TYPE_VIDEO)
1897 if (priv->funnel != NULL)
1901 output = priv->video_output_sink;
1903 gst_element_set_state (output, GST_STATE_NULL);
1904 gst_element_set_state (priv->funnel, GST_STATE_NULL);
1906 gst_bin_remove (GST_BIN (priv->pipeline), output);
1907 gst_bin_remove (GST_BIN (priv->pipeline), priv->funnel);
1908 priv->funnel = NULL;
1912 else if (media_type == FS_MEDIA_TYPE_AUDIO)
1914 if (priv->audio_output != NULL)
1916 gst_element_set_state (priv->audio_output, GST_STATE_NULL);
1918 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
1919 priv->audio_output = NULL;
1927 /* Called with global lock held */
1929 empathy_call_window_get_video_sink_pad (EmpathyCallWindow *self)
1931 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1935 if (priv->funnel == NULL)
1937 output = priv->video_output_sink;
1939 priv->funnel = gst_element_factory_make ("fsfunnel", NULL);
1943 g_warning ("Could not create fsfunnel");
1947 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->funnel))
1949 gst_object_unref (priv->funnel);
1950 priv->funnel = NULL;
1951 g_warning ("Could not add funnel to pipeline");
1955 if (!gst_bin_add (GST_BIN (priv->pipeline), output))
1957 g_warning ("Could not add the video output widget to the pipeline");
1961 if (!gst_element_link (priv->funnel, output))
1963 g_warning ("Could not link output sink to funnel");
1964 goto error_output_added;
1967 if (gst_element_set_state (output, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
1969 g_warning ("Could not start video sink");
1970 goto error_output_added;
1973 if (gst_element_set_state (priv->funnel, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
1975 g_warning ("Could not start funnel");
1976 goto error_output_added;
1980 pad = gst_element_get_request_pad (priv->funnel, "sink%d");
1983 g_warning ("Could not get request pad from funnel");
1990 gst_element_set_locked_state (priv->funnel, TRUE);
1991 gst_element_set_locked_state (output, TRUE);
1993 gst_element_set_state (priv->funnel, GST_STATE_NULL);
1994 gst_element_set_state (output, GST_STATE_NULL);
1996 gst_bin_remove (GST_BIN (priv->pipeline), output);
1997 gst_element_set_locked_state (output, FALSE);
2001 gst_bin_remove (GST_BIN (priv->pipeline), priv->funnel);
2002 priv->funnel = NULL;
2007 /* Called with global lock held */
2009 empathy_call_window_get_audio_sink_pad (EmpathyCallWindow *self)
2011 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2013 GstPadTemplate *template;
2015 if (priv->audio_output == NULL)
2017 priv->audio_output = empathy_audio_sink_new ();
2018 g_object_ref_sink (priv->audio_output);
2020 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_output))
2022 g_warning ("Could not add audio sink to pipeline");
2023 g_object_unref (priv->audio_output);
2024 goto error_add_output;
2027 if (gst_element_set_state (priv->audio_output, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2029 g_warning ("Could not start audio sink");
2034 template = gst_element_class_get_pad_template (
2035 GST_ELEMENT_GET_CLASS (priv->audio_output), "sink%d");
2037 pad = gst_element_request_pad (priv->audio_output,
2038 template, NULL, NULL);
2042 g_warning ("Could not get sink pad from sink");
2049 gst_element_set_locked_state (priv->audio_output, TRUE);
2050 gst_element_set_state (priv->audio_output, GST_STATE_NULL);
2051 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
2052 priv->audio_output = NULL;
2060 empathy_call_window_update_timer (gpointer user_data)
2062 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2063 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2067 time_ = g_timer_elapsed (priv->timer, NULL);
2069 /* Translators: 'status - minutes:seconds' the caller has been connected */
2070 str = g_strdup_printf (_("%s — %d:%02dm"),
2071 priv->call_state == HELD ? _("On hold") : _("Connected"),
2072 (int) time_ / 60, (int) time_ % 60);
2073 empathy_call_window_status_message (self, str);
2081 display_error (EmpathyCallWindow *self,
2082 TpyCallChannel *call,
2086 const gchar *details)
2088 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2089 GtkWidget *info_bar;
2090 GtkWidget *content_area;
2097 /* Create info bar */
2098 info_bar = gtk_info_bar_new_with_buttons (GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
2101 gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_WARNING);
2103 content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar));
2105 /* hbox containing the image and the messages vbox */
2106 hbox = gtk_hbox_new (FALSE, 3);
2107 gtk_container_add (GTK_CONTAINER (content_area), hbox);
2110 image = gtk_image_new_from_icon_name (img, GTK_ICON_SIZE_DIALOG);
2111 gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
2113 /* vbox containing the main message and the details expander */
2114 vbox = gtk_vbox_new (FALSE, 3);
2115 gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
2118 txt = g_strdup_printf ("<b>%s</b>\n%s", title, desc);
2120 label = gtk_label_new (NULL);
2121 gtk_label_set_markup (GTK_LABEL (label), txt);
2122 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
2123 gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
2126 gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
2129 if (details != NULL)
2131 GtkWidget *expander;
2133 expander = gtk_expander_new (_("Technical Details"));
2135 txt = g_strdup_printf ("<i>%s</i>", details);
2137 label = gtk_label_new (NULL);
2138 gtk_label_set_markup (GTK_LABEL (label), txt);
2139 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
2140 gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
2143 gtk_container_add (GTK_CONTAINER (expander), label);
2144 gtk_box_pack_start (GTK_BOX (vbox), expander, TRUE, TRUE, 0);
2147 g_signal_connect (info_bar, "response",
2148 G_CALLBACK (gtk_widget_destroy), NULL);
2150 gtk_box_pack_start (GTK_BOX (priv->errors_vbox), info_bar,
2151 FALSE, FALSE, CONTENT_HBOX_CHILDREN_PACKING_PADDING);
2152 gtk_widget_show_all (info_bar);
2156 media_stream_error_to_txt (EmpathyCallWindow *self,
2157 TpyCallChannel *call,
2159 TpMediaStreamError error)
2161 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2162 const gchar *cm = NULL;
2168 case TP_MEDIA_STREAM_ERROR_CODEC_NEGOTIATION_FAILED:
2170 return g_strdup_printf (
2171 _("%s's software does not understand any of the audio formats "
2172 "supported by your computer"),
2173 empathy_contact_get_alias (priv->contact));
2175 return g_strdup_printf (
2176 _("%s's software does not understand any of the video formats "
2177 "supported by your computer"),
2178 empathy_contact_get_alias (priv->contact));
2180 case TP_MEDIA_STREAM_ERROR_CONNECTION_FAILED:
2181 return g_strdup_printf (
2182 _("Can't establish a connection to %s. "
2183 "One of you might be on a network that does not allow "
2184 "direct connections."),
2185 empathy_contact_get_alias (priv->contact));
2187 case TP_MEDIA_STREAM_ERROR_NETWORK_ERROR:
2188 return g_strdup (_("There was a failure on the network"));
2190 case TP_MEDIA_STREAM_ERROR_NO_CODECS:
2192 return g_strdup (_("The audio formats necessary for this call "
2193 "are not installed on your computer"));
2195 return g_strdup (_("The video formats necessary for this call "
2196 "are not installed on your computer"));
2198 case TP_MEDIA_STREAM_ERROR_INVALID_CM_BEHAVIOR:
2199 tp_connection_parse_object_path (
2200 tp_channel_borrow_connection (TP_CHANNEL (call)),
2203 url = g_strdup_printf ("http://bugs.freedesktop.org/enter_bug.cgi?"
2204 "product=Telepathy&component=%s", cm);
2206 result = g_strdup_printf (
2207 _("Something unexpected happened in a Telepathy component. "
2208 "Please <a href=\"%s\">report this bug</a> and attach "
2209 "logs gathered from the 'Debug' window in the Help menu."), url);
2215 case TP_MEDIA_STREAM_ERROR_MEDIA_ERROR:
2216 return g_strdup (_("There was a failure in the call engine"));
2218 case TP_MEDIA_STREAM_ERROR_EOS:
2219 return g_strdup (_("The end of the stream was reached"));
2221 case TP_MEDIA_STREAM_ERROR_UNKNOWN:
2228 empathy_call_window_stream_error (EmpathyCallWindow *self,
2229 TpyCallChannel *call,
2238 desc = media_stream_error_to_txt (self, call, audio, code);
2241 /* No description, use the error message. That's not great as it's not
2242 * localized but it's better than nothing. */
2243 display_error (self, call, icon, title, msg, NULL);
2247 display_error (self, call, icon, title, desc, msg);
2253 empathy_call_window_audio_stream_error (TpyCallChannel *call,
2256 EmpathyCallWindow *self)
2258 empathy_call_window_stream_error (self, call, TRUE, code, msg,
2259 "gnome-stock-mic", _("Can't establish audio stream"));
2263 empathy_call_window_video_stream_error (TpyCallChannel *call,
2266 EmpathyCallWindow *self)
2268 empathy_call_window_stream_error (self, call, FALSE, code, msg,
2269 "camera-web", _("Can't establish video stream"));
2274 empathy_call_window_state_changed_cb (EmpathyCallHandler *handler,
2276 EmpathyCallWindow *self)
2278 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2279 TpyCallChannel *call;
2280 gboolean can_send_video;
2282 if (state != TPY_CALL_STATE_ACCEPTED)
2285 if (priv->call_state == CONNECTED)
2288 g_timer_start (priv->timer);
2289 priv->call_state = CONNECTED;
2291 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
2293 can_send_video = priv->video_input != NULL &&
2294 empathy_contact_can_voip_video (priv->contact) &&
2295 empathy_camera_monitor_get_available (priv->camera_monitor);
2297 g_object_get (priv->handler, "call-channel", &call, NULL);
2299 if (tpy_call_channel_has_dtmf (call))
2300 gtk_widget_set_sensitive (priv->dtmf_panel, TRUE);
2302 if (priv->video_input == NULL)
2303 empathy_call_window_set_send_video (self, CAMERA_STATE_OFF);
2305 gtk_widget_set_sensitive (priv->camera_button, can_send_video);
2307 gtk_action_set_sensitive (priv->redial, FALSE);
2308 gtk_widget_set_sensitive (priv->redial_button, FALSE);
2310 gtk_widget_set_sensitive (priv->mic_button, TRUE);
2312 clutter_actor_hide (priv->video_output);
2313 gtk_widget_show (priv->remote_user_avatar_widget);
2315 g_object_unref (call);
2317 g_mutex_lock (priv->lock);
2319 priv->timer_id = g_timeout_add_seconds (1,
2320 empathy_call_window_update_timer, self);
2322 g_mutex_unlock (priv->lock);
2324 empathy_call_window_update_timer (self);
2326 gtk_action_set_sensitive (priv->menu_fullscreen, TRUE);
2330 empathy_call_window_show_video_output_cb (gpointer user_data)
2332 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2334 if (self->priv->video_output != NULL)
2336 gtk_widget_hide (self->priv->remote_user_avatar_widget);
2337 clutter_actor_show (self->priv->video_output);
2344 empathy_call_window_check_video_cb (gpointer data)
2346 EmpathyCallWindow *self = data;
2348 if (self->priv->got_video)
2350 self->priv->got_video = FALSE;
2354 /* No video in the last N seconds, display the remote avatar */
2355 empathy_call_window_show_video_output (self, FALSE);
2360 /* Called from the streaming thread */
2362 empathy_call_window_video_probe_cb (GstPad *pad,
2363 GstMiniObject *mini_obj,
2364 EmpathyCallWindow *self)
2367 if (GST_IS_EVENT (mini_obj))
2370 if (G_UNLIKELY (!self->priv->got_video))
2372 /* show the remote video */
2373 g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
2374 empathy_call_window_show_video_output_cb,
2375 g_object_ref (self), g_object_unref);
2377 self->priv->got_video = TRUE;
2383 /* Called from the streaming thread */
2385 empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
2386 GstPad *src, guint media_type, gpointer user_data)
2388 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2389 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2390 gboolean retval = FALSE;
2394 g_mutex_lock (priv->lock);
2398 case TP_MEDIA_STREAM_TYPE_AUDIO:
2399 pad = empathy_call_window_get_audio_sink_pad (self);
2401 case TP_MEDIA_STREAM_TYPE_VIDEO:
2402 g_idle_add (empathy_call_window_show_video_output_cb, self);
2403 pad = empathy_call_window_get_video_sink_pad (self);
2405 gst_pad_add_data_probe (src,
2406 G_CALLBACK (empathy_call_window_video_probe_cb), self);
2407 if (priv->got_video_src > 0)
2408 g_source_remove (priv->got_video_src);
2409 priv->got_video_src = g_timeout_add_seconds (5,
2410 empathy_call_window_check_video_cb, self);
2413 g_assert_not_reached ();
2419 if (GST_PAD_LINK_FAILED (gst_pad_link (src, pad)))
2420 g_warning ("Could not link %s sink pad",
2421 media_type == TP_MEDIA_STREAM_TYPE_AUDIO ? "audio" : "video");
2425 gst_object_unref (pad);
2429 /* If no sink could be linked, try to add fakesink to prevent the whole call
2434 GstElement *fakesink = gst_element_factory_make ("fakesink", NULL);
2436 if (gst_bin_add (GST_BIN (priv->pipeline), fakesink))
2438 GstPad *sinkpad = gst_element_get_static_pad (fakesink, "sink");
2439 if (gst_element_set_state (fakesink, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE ||
2440 GST_PAD_LINK_FAILED (gst_pad_link (src, sinkpad)))
2442 gst_element_set_locked_state (fakesink, TRUE);
2443 gst_element_set_state (fakesink, GST_STATE_NULL);
2444 gst_bin_remove (GST_BIN (priv->pipeline), fakesink);
2448 DEBUG ("Could not link real sink, linked fakesink instead");
2450 gst_object_unref (sinkpad);
2454 gst_object_unref (fakesink);
2459 g_mutex_unlock (priv->lock);
2465 empathy_call_window_sink_added_cb (EmpathyCallHandler *handler,
2466 GstPad *sink, FsMediaType media_type, gpointer user_data)
2468 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2469 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2471 gboolean retval = FALSE;
2475 case FS_MEDIA_TYPE_AUDIO:
2476 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_input))
2478 g_warning ("Could not add audio source to pipeline");
2482 pad = gst_element_get_static_pad (priv->audio_input, "src");
2485 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
2486 g_warning ("Could not get source pad from audio source");
2490 if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
2492 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
2493 g_warning ("Could not link audio source to farsight");
2497 if (gst_element_set_state (priv->audio_input, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2499 g_warning ("Could not start audio source");
2500 gst_element_set_state (priv->audio_input, GST_STATE_NULL);
2501 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
2507 case FS_MEDIA_TYPE_VIDEO:
2508 if (priv->video_tee != NULL)
2510 pad = gst_element_get_request_pad (priv->video_tee, "src%d");
2511 if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
2513 g_warning ("Could not link video source input pipeline");
2516 gst_object_unref (pad);
2522 g_assert_not_reached ();
2529 empathy_call_window_remove_video_input (EmpathyCallWindow *self)
2531 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2532 GstElement *preview;
2534 disable_camera (self);
2536 DEBUG ("remove video input");
2537 preview = priv->video_preview_sink;
2539 gst_element_set_state (priv->video_input, GST_STATE_NULL);
2540 gst_element_set_state (priv->video_tee, GST_STATE_NULL);
2541 gst_element_set_state (preview, GST_STATE_NULL);
2543 gst_bin_remove_many (GST_BIN (priv->pipeline), priv->video_input,
2546 g_object_unref (priv->video_input);
2547 priv->video_input = NULL;
2548 g_object_unref (priv->video_tee);
2549 priv->video_tee = NULL;
2550 clutter_actor_destroy (priv->video_preview);
2551 priv->video_preview = NULL;
2553 gtk_widget_set_sensitive (priv->camera_button, FALSE);
2557 start_call (EmpathyCallWindow *self)
2559 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2561 priv->call_started = TRUE;
2562 empathy_call_handler_start_call (priv->handler,
2563 gtk_get_current_event_time ());
2565 if (empathy_call_handler_has_initial_video (priv->handler))
2567 TpyCallChannel *call;
2570 g_object_get (priv->handler, "call-channel", &call, NULL);
2571 s = tpy_call_channel_get_video_state (call);
2573 if (s == TPY_SENDING_STATE_PENDING_SEND ||
2574 s == TPY_SENDING_STATE_SENDING)
2576 /* Enable 'send video' buttons and display the preview */
2577 gtk_toggle_tool_button_set_active (
2578 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), TRUE);
2582 gtk_toggle_tool_button_set_active (
2583 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), FALSE);
2585 if (priv->video_preview == NULL)
2587 create_video_preview (self);
2588 add_video_preview_to_pipeline (self);
2592 g_object_unref (call);
2597 empathy_call_window_bus_message (GstBus *bus, GstMessage *message,
2600 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2601 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2604 empathy_call_handler_bus_message (priv->handler, bus, message);
2606 switch (GST_MESSAGE_TYPE (message))
2608 case GST_MESSAGE_STATE_CHANGED:
2609 if (GST_MESSAGE_SRC (message) == GST_OBJECT (priv->video_input))
2611 gst_message_parse_state_changed (message, NULL, &newstate, NULL);
2612 if (newstate == GST_STATE_PAUSED)
2613 empathy_call_window_setup_video_input (self);
2615 if (GST_MESSAGE_SRC (message) == GST_OBJECT (priv->pipeline) &&
2616 !priv->call_started)
2618 gst_message_parse_state_changed (message, NULL, &newstate, NULL);
2619 if (newstate == GST_STATE_PAUSED)
2621 gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
2622 priv->pipeline_playing = TRUE;
2624 if (priv->start_call_when_playing)
2629 case GST_MESSAGE_ERROR:
2631 GError *error = NULL;
2632 GstElement *gst_error;
2635 gst_message_parse_error (message, &error, &debug);
2636 gst_error = GST_ELEMENT (GST_MESSAGE_SRC (message));
2638 g_message ("Element error: %s -- %s\n", error->message, debug);
2640 if (g_str_has_prefix (gst_element_get_name (gst_error),
2641 VIDEO_INPUT_ERROR_PREFIX))
2643 /* Remove the video input and continue */
2644 if (priv->video_input != NULL)
2645 empathy_call_window_remove_video_input (self);
2646 gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
2650 empathy_call_window_disconnected (self, TRUE);
2652 g_error_free (error);
2655 case GST_MESSAGE_UNKNOWN:
2656 case GST_MESSAGE_EOS:
2657 case GST_MESSAGE_WARNING:
2658 case GST_MESSAGE_INFO:
2659 case GST_MESSAGE_TAG:
2660 case GST_MESSAGE_BUFFERING:
2661 case GST_MESSAGE_STATE_DIRTY:
2662 case GST_MESSAGE_STEP_DONE:
2663 case GST_MESSAGE_CLOCK_PROVIDE:
2664 case GST_MESSAGE_CLOCK_LOST:
2665 case GST_MESSAGE_NEW_CLOCK:
2666 case GST_MESSAGE_STRUCTURE_CHANGE:
2667 case GST_MESSAGE_STREAM_STATUS:
2668 case GST_MESSAGE_APPLICATION:
2669 case GST_MESSAGE_ELEMENT:
2670 case GST_MESSAGE_SEGMENT_START:
2671 case GST_MESSAGE_SEGMENT_DONE:
2672 case GST_MESSAGE_DURATION:
2673 case GST_MESSAGE_ANY:
2682 empathy_call_window_members_changed_cb (TpyCallChannel *call,
2683 GHashTable *members,
2684 EmpathyCallWindow *self)
2686 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2687 GHashTableIter iter;
2688 gpointer key, value;
2689 gboolean held = FALSE;
2691 g_hash_table_iter_init (&iter, members);
2692 while (g_hash_table_iter_next (&iter, &key, &value))
2694 if (GPOINTER_TO_INT (value) & TPY_CALL_MEMBER_FLAG_HELD)
2696 /* This assumes this is a 1-1 call, otherwise one participant
2697 * putting the call on hold wouldn't mean the call is on hold
2705 priv->call_state = HELD;
2706 else if (priv->call_state == HELD)
2707 priv->call_state = CONNECTED;
2711 call_handler_notify_call_cb (EmpathyCallHandler *handler,
2713 EmpathyCallWindow *self)
2715 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2716 TpyCallChannel *call;
2718 g_object_get (priv->handler, "call-channel", &call, NULL);
2723 tp_g_signal_connect_object (call, "audio-stream-error",
2724 G_CALLBACK (empathy_call_window_audio_stream_error), self, 0);
2725 tp_g_signal_connect_object (call, "video-stream-error",
2726 G_CALLBACK (empathy_call_window_video_stream_error), self, 0);
2729 tp_g_signal_connect_object (call, "members-changed",
2730 G_CALLBACK (empathy_call_window_members_changed_cb), self, 0);
2732 g_object_unref (call);
2736 empathy_call_window_realized_cb (GtkWidget *widget, EmpathyCallWindow *window)
2738 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2739 TpyCallChannel *call;
2741 g_signal_connect (priv->handler, "state-changed",
2742 G_CALLBACK (empathy_call_window_state_changed_cb), window);
2743 g_signal_connect (priv->handler, "conference-added",
2744 G_CALLBACK (empathy_call_window_conference_added_cb), window);
2745 g_signal_connect (priv->handler, "conference-removed",
2746 G_CALLBACK (empathy_call_window_conference_removed_cb), window);
2747 g_signal_connect (priv->handler, "closed",
2748 G_CALLBACK (empathy_call_window_channel_closed_cb), window);
2749 g_signal_connect (priv->handler, "src-pad-added",
2750 G_CALLBACK (empathy_call_window_src_added_cb), window);
2751 g_signal_connect (priv->handler, "sink-pad-added",
2752 G_CALLBACK (empathy_call_window_sink_added_cb), window);
2753 g_signal_connect (priv->handler, "sink-pad-removed",
2754 G_CALLBACK (empathy_call_window_sink_removed_cb), window);
2756 g_object_get (priv->handler, "call-channel", &call, NULL);
2759 call_handler_notify_call_cb (priv->handler, NULL, window);
2760 g_object_unref (call);
2764 /* call-channel doesn't exist yet, we'll connect signals once it has been
2766 g_signal_connect (priv->handler, "notify::call-channel",
2767 G_CALLBACK (call_handler_notify_call_cb), window);
2770 gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
2774 empathy_call_window_delete_cb (GtkWidget *widget, GdkEvent*event,
2775 EmpathyCallWindow *window)
2777 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2779 if (priv->pipeline != NULL)
2781 if (priv->bus_message_source_id != 0)
2783 g_source_remove (priv->bus_message_source_id);
2784 priv->bus_message_source_id = 0;
2787 gst_element_set_state (priv->pipeline, GST_STATE_NULL);
2790 if (priv->call_state == CONNECTING)
2791 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
2797 show_controls (EmpathyCallWindow *window, gboolean set_fullscreen)
2800 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2802 menu = gtk_ui_manager_get_widget (priv->ui_manager,
2807 gtk_widget_hide (priv->sidebar);
2808 gtk_widget_hide (menu);
2809 gtk_widget_hide (priv->statusbar);
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->statusbar);
2819 gtk_widget_show (priv->toolbar);
2821 gtk_window_resize (GTK_WINDOW (window), priv->original_width_before_fs,
2822 priv->original_height_before_fs);
2827 show_borders (EmpathyCallWindow *window, gboolean set_fullscreen)
2829 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2831 gtk_container_set_border_width (GTK_CONTAINER (priv->content_hbox),
2832 set_fullscreen ? 0 : CONTENT_HBOX_BORDER_WIDTH);
2833 gtk_box_set_spacing (GTK_BOX (priv->content_hbox),
2834 set_fullscreen ? 0 : CONTENT_HBOX_SPACING);
2836 if (priv->video_output != NULL)
2839 gtk_box_set_child_packing (GTK_BOX (priv->content_hbox),
2840 priv->video_output, TRUE, TRUE,
2841 set_fullscreen ? 0 : CONTENT_HBOX_CHILDREN_PACKING_PADDING,
2848 empathy_call_window_state_event_cb (GtkWidget *widget,
2849 GdkEventWindowState *event, EmpathyCallWindow *window)
2851 if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
2853 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2854 gboolean set_fullscreen = event->new_window_state &
2855 GDK_WINDOW_STATE_FULLSCREEN;
2859 gboolean sidebar_was_visible;
2860 GtkAllocation allocation;
2861 gint original_width, original_height;
2863 gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
2864 original_width = allocation.width;
2865 original_height = allocation.height;
2867 g_object_get (priv->sidebar, "visible", &sidebar_was_visible, NULL);
2869 priv->sidebar_was_visible_before_fs = sidebar_was_visible;
2870 priv->original_width_before_fs = original_width;
2871 priv->original_height_before_fs = original_height;
2873 if (priv->video_output_motion_handler_id == 0 &&
2874 priv->video_output != NULL)
2876 priv->video_output_motion_handler_id = g_signal_connect (
2877 G_OBJECT (priv->video_container), "motion-notify-event",
2878 G_CALLBACK (empathy_call_window_video_output_motion_notify),
2884 disconnect_video_output_motion_handler (window);
2887 empathy_call_window_fullscreen_set_fullscreen (priv->fullscreen,
2889 show_controls (window, set_fullscreen);
2890 show_borders (window, set_fullscreen);
2891 gtk_action_set_stock_id (priv->menu_fullscreen,
2892 (set_fullscreen ? "gtk-leave-fullscreen" : "gtk-fullscreen"));
2893 priv->is_fullscreen = set_fullscreen;
2900 empathy_call_window_update_sidebar_buttons (EmpathyCallWindow *window,
2903 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2905 /* Update dialpad button */
2906 g_signal_handlers_block_by_func (priv->dialpad_button,
2907 empathy_call_window_dialpad_cb, window);
2908 gtk_toggle_tool_button_set_active (
2909 GTK_TOGGLE_TOOL_BUTTON (priv->dialpad_button),
2911 g_signal_handlers_unblock_by_func (priv->dialpad_button,
2912 empathy_call_window_dialpad_cb, window);
2914 /* Update sidebar menu */
2915 g_signal_handlers_block_by_func (priv->menu_sidebar,
2916 empathy_call_window_sidebar_cb, window);
2917 gtk_toggle_action_set_active (
2918 GTK_TOGGLE_ACTION (priv->menu_sidebar),
2919 gtk_widget_get_visible (priv->sidebar));
2920 g_signal_handlers_unblock_by_func (priv->menu_sidebar,
2921 empathy_call_window_sidebar_cb, window);
2925 empathy_call_window_show_sidebar (EmpathyCallWindow *window,
2928 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2929 int w, h, sidebar_width, handle_size;
2930 GtkAllocation allocation;
2932 gboolean dialpad_shown;
2934 gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
2935 w = allocation.width;
2936 h = allocation.height;
2938 gtk_widget_style_get (priv->pane, "handle_size", &handle_size, NULL);
2940 gtk_widget_get_preferred_width (priv->sidebar, &sidebar_width, NULL);
2944 gtk_widget_show (priv->sidebar);
2945 w += sidebar_width + handle_size;
2949 w -= sidebar_width + handle_size;
2950 gtk_widget_hide (priv->sidebar);
2954 gtk_window_resize (GTK_WINDOW (window), w, h);
2956 /* Update the 'Dialpad' menu */
2957 page = ev_sidebar_get_current_page (EV_SIDEBAR (priv->sidebar));
2958 dialpad_shown = active && !tp_strdiff (page, "dialpad");
2961 empathy_call_window_update_sidebar_buttons (window, dialpad_shown);
2965 empathy_call_window_set_send_video (EmpathyCallWindow *window,
2968 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2969 TpyCallChannel *call;
2971 priv->sending_video = (state == CAMERA_STATE_ON);
2973 if (state == CAMERA_STATE_ON)
2975 /* When we start sending video, we want to show the video preview by
2977 display_video_preview (window, TRUE);
2981 display_video_preview (window, FALSE);
2984 if (priv->call_state != CONNECTED)
2987 g_object_get (priv->handler, "call-channel", &call, NULL);
2988 DEBUG ("%s sending video", priv->sending_video ? "start": "stop");
2989 tpy_call_channel_send_video (call, priv->sending_video);
2990 g_object_unref (call);
2994 empathy_call_window_mic_toggled_cb (GtkToggleToolButton *toggle,
2995 EmpathyCallWindow *window)
2997 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3000 active = (gtk_toggle_tool_button_get_active (toggle));
3004 empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
3006 gtk_adjustment_set_value (priv->audio_input_adj, priv->volume * 100);
3010 /* TODO, Instead of setting the input volume to 0 we should probably
3011 * stop sending but this would cause the audio call to drop if both
3012 * sides mute at the same time on certain CMs AFAIK. Need to revisit this
3013 * in the future. GNOME #574574
3015 empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
3017 gtk_adjustment_set_value (priv->audio_input_adj, 0);
3022 empathy_call_window_sidebar_hidden_cb (EvSidebar *sidebar,
3023 EmpathyCallWindow *window)
3025 empathy_call_window_show_sidebar (window, FALSE);
3029 empathy_call_window_sidebar_shown_cb (EvSidebar *sidebar,
3030 EmpathyCallWindow *window)
3032 empathy_call_window_show_sidebar (window, TRUE);
3036 empathy_call_window_sidebar_changed_cb (EvSidebar *sidebar,
3038 EmpathyCallWindow *window)
3040 empathy_call_window_update_sidebar_buttons (window,
3041 !tp_strdiff (page, "dialpad"));
3045 empathy_call_window_hangup_cb (gpointer object,
3046 EmpathyCallWindow *window)
3048 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3050 empathy_call_handler_stop_call (priv->handler);
3052 if (empathy_call_window_disconnected (window, FALSE))
3053 gtk_widget_destroy (GTK_WIDGET (window));
3057 empathy_call_window_restart_call (EmpathyCallWindow *window)
3059 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3061 /* Remove error info bars */
3062 gtk_container_forall (GTK_CONTAINER (priv->errors_vbox),
3063 (GtkCallback) gtk_widget_destroy, NULL);
3065 create_video_output_widget (window);
3067 g_signal_connect (G_OBJECT (priv->audio_input_adj), "value-changed",
3068 G_CALLBACK (empathy_call_window_mic_volume_changed_cb), window);
3070 /* While the call was disconnected, the input volume might have changed.
3071 * However, since the audio_input source was destroyed, its volume has not
3072 * been updated during that time. That's why we manually update it here */
3073 empathy_call_window_mic_volume_changed_cb (priv->audio_input_adj, window);
3075 priv->outgoing = TRUE;
3076 empathy_call_window_set_state_connecting (window);
3078 if (priv->pipeline_playing)
3079 start_call (window);
3081 /* call will be started when the pipeline is ready */
3082 priv->start_call_when_playing = TRUE;
3085 empathy_call_window_setup_avatars (window, priv->handler);
3087 gtk_action_set_sensitive (priv->redial, FALSE);
3088 gtk_widget_set_sensitive (priv->redial_button, FALSE);
3092 empathy_call_window_redial_cb (gpointer object,
3093 EmpathyCallWindow *window)
3095 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3097 if (priv->call_state == CONNECTED)
3098 priv->call_state = REDIALING;
3100 empathy_call_handler_stop_call (priv->handler);
3102 if (priv->call_state != CONNECTED)
3103 empathy_call_window_restart_call (window);
3107 empathy_call_window_dialpad_cb (GtkToggleToolButton *button,
3108 EmpathyCallWindow *window)
3110 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3113 active = gtk_toggle_tool_button_get_active (button);
3116 ev_sidebar_set_current_page (EV_SIDEBAR (priv->sidebar), "dialpad");
3118 empathy_call_window_show_sidebar (window, active);
3122 empathy_call_window_sidebar_cb (GtkToggleAction *menu,
3123 EmpathyCallWindow *self)
3125 empathy_call_window_show_sidebar (self,
3126 gtk_toggle_action_get_active (menu));
3130 empathy_call_window_fullscreen_cb (gpointer object,
3131 EmpathyCallWindow *window)
3133 empathy_call_window_fullscreen_toggle (window);
3137 empathy_call_window_fullscreen_toggle (EmpathyCallWindow *window)
3139 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3141 if (priv->is_fullscreen)
3142 gtk_window_unfullscreen (GTK_WINDOW (window));
3144 gtk_window_fullscreen (GTK_WINDOW (window));
3148 empathy_call_window_video_button_press_cb (GtkWidget *video_preview,
3149 GdkEventButton *event, EmpathyCallWindow *window)
3151 if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
3153 empathy_call_window_video_menu_popup (window, event->button);
3161 empathy_call_window_key_press_cb (GtkWidget *video_output,
3162 GdkEventKey *event, EmpathyCallWindow *window)
3164 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3166 if (priv->is_fullscreen && event->keyval == GDK_KEY_Escape)
3168 /* Since we are in fullscreen mode, toggling will bring us back to
3170 empathy_call_window_fullscreen_toggle (window);
3178 empathy_call_window_video_output_motion_notify (GtkWidget *widget,
3179 GdkEventMotion *event, EmpathyCallWindow *window)
3181 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3183 if (priv->is_fullscreen)
3185 empathy_call_window_fullscreen_show_popup (priv->fullscreen);
3192 empathy_call_window_video_menu_popup (EmpathyCallWindow *window,
3196 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3198 menu = gtk_ui_manager_get_widget (priv->ui_manager,
3200 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
3201 button, gtk_get_current_event_time ());
3202 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
3206 empathy_call_window_status_message (EmpathyCallWindow *window,
3209 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3211 if (priv->context_id == 0)
3213 priv->context_id = gtk_statusbar_get_context_id (
3214 GTK_STATUSBAR (priv->statusbar), "voip call status messages");
3218 gtk_statusbar_pop (GTK_STATUSBAR (priv->statusbar), priv->context_id);
3221 gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar), priv->context_id,
3226 empathy_call_window_volume_changed_cb (GtkScaleButton *button,
3227 gdouble value, EmpathyCallWindow *window)
3229 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3231 if (priv->audio_output == NULL)
3234 empathy_audio_sink_set_volume (EMPATHY_GST_AUDIO_SINK (priv->audio_output),