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_item;
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 GtkWidget *volume_button;
294 volume_button = gtk_volume_button_new ();
295 /* FIXME listen to the audiosinks signals and update the button according to
296 * that, for now starting out at 1.0 and assuming only the app changes the
298 gtk_scale_button_set_value (GTK_SCALE_BUTTON (volume_button), 1.0);
299 g_signal_connect (G_OBJECT (volume_button), "value-changed",
300 G_CALLBACK (empathy_call_window_volume_changed_cb), self);
302 gtk_container_add (GTK_CONTAINER (priv->volume_item),
304 gtk_widget_show (GTK_WIDGET (volume_button));
308 dtmf_button_pressed_cb (GtkButton *button, EmpathyCallWindow *window)
310 EmpathyCallWindowPriv *priv = GET_PRIV (window);
311 TpyCallChannel *call;
315 g_object_get (priv->handler, "call-channel", &call, NULL);
317 button_quark = g_quark_from_static_string (EMPATHY_DTMF_BUTTON_ID);
318 event = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (button),
321 tpy_call_channel_dtmf_start_tone (call, event);
323 g_object_unref (call);
327 dtmf_button_released_cb (GtkButton *button, EmpathyCallWindow *window)
329 EmpathyCallWindowPriv *priv = GET_PRIV (window);
330 TpyCallChannel *call;
332 g_object_get (priv->handler, "call-channel", &call, NULL);
334 tpy_call_channel_dtmf_stop_tone (call);
336 g_object_unref (call);
340 empathy_call_window_create_video_input_add_slider (EmpathyCallWindow *self,
341 gchar *label_text, GtkWidget *bin)
343 GtkWidget *vbox = gtk_vbox_new (FALSE, 2);
344 GtkWidget *scale = gtk_vscale_new_with_range (0, 100, 10);
345 GtkWidget *label = gtk_label_new (label_text);
347 gtk_widget_set_sensitive (scale, FALSE);
349 gtk_container_add (GTK_CONTAINER (bin), vbox);
351 gtk_range_set_inverted (GTK_RANGE (scale), TRUE);
352 gtk_box_pack_start (GTK_BOX (vbox), scale, TRUE, TRUE, 0);
353 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
359 empathy_call_window_video_contrast_changed_cb (GtkAdjustment *adj,
360 EmpathyCallWindow *self)
363 EmpathyCallWindowPriv *priv = GET_PRIV (self);
365 empathy_video_src_set_channel (priv->video_input,
366 EMPATHY_GST_VIDEO_SRC_CHANNEL_CONTRAST, gtk_adjustment_get_value (adj));
370 empathy_call_window_video_brightness_changed_cb (GtkAdjustment *adj,
371 EmpathyCallWindow *self)
374 EmpathyCallWindowPriv *priv = GET_PRIV (self);
376 empathy_video_src_set_channel (priv->video_input,
377 EMPATHY_GST_VIDEO_SRC_CHANNEL_BRIGHTNESS, gtk_adjustment_get_value (adj));
381 empathy_call_window_video_gamma_changed_cb (GtkAdjustment *adj,
382 EmpathyCallWindow *self)
385 EmpathyCallWindowPriv *priv = GET_PRIV (self);
387 empathy_video_src_set_channel (priv->video_input,
388 EMPATHY_GST_VIDEO_SRC_CHANNEL_GAMMA, gtk_adjustment_get_value (adj));
393 empathy_call_window_create_video_input (EmpathyCallWindow *self)
395 EmpathyCallWindowPriv *priv = GET_PRIV (self);
398 hbox = gtk_hbox_new (TRUE, 3);
400 priv->video_contrast = empathy_call_window_create_video_input_add_slider (
401 self, _("Contrast"), hbox);
403 priv->video_brightness = empathy_call_window_create_video_input_add_slider (
404 self, _("Brightness"), hbox);
406 priv->video_gamma = empathy_call_window_create_video_input_add_slider (
407 self, _("Gamma"), hbox);
413 empathy_call_window_setup_video_input (EmpathyCallWindow *self)
415 EmpathyCallWindowPriv *priv = GET_PRIV (self);
419 supported = empathy_video_src_get_supported_channels (priv->video_input);
421 if (supported & EMPATHY_GST_VIDEO_SRC_SUPPORTS_CONTRAST)
423 adj = gtk_range_get_adjustment (GTK_RANGE (priv->video_contrast));
425 gtk_adjustment_set_value (adj,
426 empathy_video_src_get_channel (priv->video_input,
427 EMPATHY_GST_VIDEO_SRC_CHANNEL_CONTRAST));
429 g_signal_connect (G_OBJECT (adj), "value-changed",
430 G_CALLBACK (empathy_call_window_video_contrast_changed_cb), self);
432 gtk_widget_set_sensitive (priv->video_contrast, TRUE);
435 if (supported & EMPATHY_GST_VIDEO_SRC_SUPPORTS_BRIGHTNESS)
437 adj = gtk_range_get_adjustment (GTK_RANGE (priv->video_brightness));
439 gtk_adjustment_set_value (adj,
440 empathy_video_src_get_channel (priv->video_input,
441 EMPATHY_GST_VIDEO_SRC_CHANNEL_BRIGHTNESS));
443 g_signal_connect (G_OBJECT (adj), "value-changed",
444 G_CALLBACK (empathy_call_window_video_brightness_changed_cb), self);
445 gtk_widget_set_sensitive (priv->video_brightness, TRUE);
448 if (supported & EMPATHY_GST_VIDEO_SRC_SUPPORTS_GAMMA)
450 adj = gtk_range_get_adjustment (GTK_RANGE (priv->video_gamma));
452 gtk_adjustment_set_value (adj,
453 empathy_video_src_get_channel (priv->video_input,
454 EMPATHY_GST_VIDEO_SRC_CHANNEL_GAMMA));
456 g_signal_connect (G_OBJECT (adj), "value-changed",
457 G_CALLBACK (empathy_call_window_video_gamma_changed_cb), self);
458 gtk_widget_set_sensitive (priv->video_gamma, TRUE);
463 empathy_call_window_mic_volume_changed_cb (GtkAdjustment *adj,
464 EmpathyCallWindow *self)
466 EmpathyCallWindowPriv *priv = GET_PRIV (self);
469 volume = gtk_adjustment_get_value (adj)/100.0;
471 /* Don't store the volume because of muting */
472 if (volume > 0 || gtk_toggle_tool_button_get_active (
473 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
474 priv->volume = volume;
476 /* Ensure that the toggle button is active if the volume is > 0 and inactive
477 * if it's smaller than 0 */
478 if ((volume > 0) != gtk_toggle_tool_button_get_active (
479 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
480 gtk_toggle_tool_button_set_active (
481 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button), volume > 0);
483 empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
488 empathy_call_window_audio_input_level_changed_cb (EmpathyGstAudioSrc *src,
489 gdouble level, EmpathyCallWindow *window)
492 EmpathyCallWindowPriv *priv = GET_PRIV (window);
494 value = CLAMP (pow (10, level / 20), 0.0, 1.0);
495 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->volume_progress_bar),
500 empathy_call_window_create_audio_input (EmpathyCallWindow *self)
502 EmpathyCallWindowPriv *priv = GET_PRIV (self);
503 GtkWidget *hbox, *vbox, *label;
505 hbox = gtk_hbox_new (TRUE, 3);
507 vbox = gtk_vbox_new (FALSE, 3);
508 gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 3);
510 priv->volume_scale = gtk_vscale_new_with_range (0, 150, 100);
511 gtk_range_set_inverted (GTK_RANGE (priv->volume_scale), TRUE);
512 label = gtk_label_new (_("Volume"));
514 priv->audio_input_adj = gtk_range_get_adjustment (
515 GTK_RANGE (priv->volume_scale));
516 priv->volume = empathy_audio_src_get_volume (EMPATHY_GST_AUDIO_SRC
517 (priv->audio_input));
518 gtk_adjustment_set_value (priv->audio_input_adj, priv->volume * 100);
520 g_signal_connect (G_OBJECT (priv->audio_input_adj), "value-changed",
521 G_CALLBACK (empathy_call_window_mic_volume_changed_cb), self);
523 gtk_box_pack_start (GTK_BOX (vbox), priv->volume_scale, TRUE, TRUE, 3);
524 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 3);
526 priv->volume_progress_bar = gtk_progress_bar_new ();
528 gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->volume_progress_bar),
529 GTK_ORIENTATION_VERTICAL);
531 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->volume_progress_bar),
534 gtk_box_pack_start (GTK_BOX (hbox), priv->volume_progress_bar, FALSE, FALSE,
541 empathy_call_window_show_video_output (EmpathyCallWindow *self,
544 if (self->priv->video_output != NULL)
545 g_object_set (self->priv->video_output, "visible", show, NULL);
547 gtk_widget_set_visible (self->priv->remote_user_avatar_widget, !show);
551 create_video_output_widget (EmpathyCallWindow *self)
553 EmpathyCallWindowPriv *priv = GET_PRIV (self);
555 g_assert (priv->video_output == NULL);
556 g_assert (priv->pipeline != NULL);
558 priv->video_output = clutter_texture_new ();
560 clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (priv->video_output),
563 priv->video_output_sink = clutter_gst_video_sink_new (
564 CLUTTER_TEXTURE (priv->video_output));
566 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_box),
569 gtk_widget_add_events (priv->video_container,
570 GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK);
571 g_signal_connect (G_OBJECT (priv->video_container), "button-press-event",
572 G_CALLBACK (empathy_call_window_video_button_press_cb), self);
576 create_video_input (EmpathyCallWindow *self)
578 EmpathyCallWindowPriv *priv = GET_PRIV (self);
580 g_assert (priv->video_input == NULL);
581 priv->video_input = empathy_video_src_new ();
582 gst_object_ref (priv->video_input);
583 gst_object_sink (priv->video_input);
587 create_audio_input (EmpathyCallWindow *self)
589 EmpathyCallWindowPriv *priv = GET_PRIV (self);
591 g_assert (priv->audio_input == NULL);
592 priv->audio_input = empathy_audio_src_new ();
593 gst_object_ref (priv->audio_input);
594 gst_object_sink (priv->audio_input);
596 tp_g_signal_connect_object (priv->audio_input, "peak-level-changed",
597 G_CALLBACK (empathy_call_window_audio_input_level_changed_cb),
602 add_video_preview_to_pipeline (EmpathyCallWindow *self)
604 EmpathyCallWindowPriv *priv = GET_PRIV (self);
607 g_assert (priv->video_preview != NULL);
608 g_assert (priv->pipeline != NULL);
609 g_assert (priv->video_input != NULL);
610 g_assert (priv->video_tee != NULL);
612 preview = priv->video_preview_sink;
614 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->video_input))
616 g_warning ("Could not add video input to pipeline");
620 if (!gst_bin_add (GST_BIN (priv->pipeline), preview))
622 g_warning ("Could not add video preview to pipeline");
626 if (!gst_element_link (priv->video_input, priv->video_tee))
628 g_warning ("Could not link video input to video tee");
632 if (!gst_element_link (priv->video_tee, preview))
634 g_warning ("Could not link video tee to video preview");
640 empathy_call_window_disable_camera_cb (GtkAction *action,
641 EmpathyCallWindow *self)
643 clutter_actor_destroy (self->priv->preview_hidden_button);
645 gtk_toggle_tool_button_set_active (
646 GTK_TOGGLE_TOOL_BUTTON (self->priv->camera_button), FALSE);
650 empathy_call_window_minimise_camera_cb (GtkAction *action,
651 EmpathyCallWindow *self)
653 clutter_actor_hide (self->priv->video_preview);
654 clutter_actor_show (self->priv->preview_hidden_button);
658 empathy_call_window_maximise_camera_cb (GtkAction *action,
659 EmpathyCallWindow *self)
661 clutter_actor_show (self->priv->video_preview);
662 clutter_actor_hide (self->priv->preview_hidden_button);
666 empathy_call_window_preview_button_clicked_cb (GtkButton *button,
667 EmpathyCallWindow *self)
671 menu = gtk_ui_manager_get_widget (self->priv->ui_manager,
673 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
674 0, gtk_get_current_event_time ());
675 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
679 empathy_call_window_preview_hidden_button_clicked_cb (GtkButton *button,
680 EmpathyCallWindow *self)
684 menu = gtk_ui_manager_get_widget (self->priv->ui_manager,
685 "/preview-hidden-menu");
686 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
687 0, gtk_get_current_event_time ());
688 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
692 create_video_preview (EmpathyCallWindow *self)
694 EmpathyCallWindowPriv *priv = GET_PRIV (self);
695 ClutterLayoutManager *layout, *layout_center;
696 ClutterActor *preview;
701 g_assert (priv->video_preview == NULL);
703 preview = clutter_texture_new ();
704 clutter_actor_set_size (preview,
705 SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGTH);
706 priv->video_preview_sink = clutter_gst_video_sink_new (
707 CLUTTER_TEXTURE (preview));
709 /* Flip the video preview */
710 clutter_actor_set_rotation (preview,
713 SELF_VIDEO_SECTION_WIDTH * 0.5,
717 /* Add a little offset to the video preview */
718 layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_END,
719 CLUTTER_BIN_ALIGNMENT_START);
720 priv->video_preview = clutter_box_new (layout);
721 clutter_actor_set_size (priv->video_preview,
722 SELF_VIDEO_SECTION_WIDTH + 10, SELF_VIDEO_SECTION_HEIGTH + 10);
724 layout_center = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
725 CLUTTER_BIN_ALIGNMENT_CENTER);
726 box = clutter_box_new (layout_center);
727 clutter_actor_set_size (box,
728 SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGTH);
730 clutter_container_add_actor (CLUTTER_CONTAINER (box), preview);
731 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_preview), box);
733 g_object_set (priv->video_preview_sink,
738 /* Translators: this is an "Info" label. It should be as short
740 button = gtk_button_new_with_label (_("i"));
741 b = gtk_clutter_actor_new_with_contents (button);
743 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (layout_center),
745 CLUTTER_BIN_ALIGNMENT_END,
746 CLUTTER_BIN_ALIGNMENT_END);
748 g_signal_connect (button, "clicked",
749 G_CALLBACK (empathy_call_window_preview_button_clicked_cb),
752 /* Translators: this is an "Info" label. It should be as short
754 button = gtk_button_new_with_label (_("i"));
755 priv->preview_hidden_button =
756 gtk_clutter_actor_new_with_contents (button);
758 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
759 priv->preview_hidden_button,
760 CLUTTER_BIN_ALIGNMENT_START,
761 CLUTTER_BIN_ALIGNMENT_END);
763 clutter_actor_hide (priv->preview_hidden_button);
765 g_signal_connect (button, "clicked",
766 G_CALLBACK (empathy_call_window_preview_hidden_button_clicked_cb),
769 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
771 CLUTTER_BIN_ALIGNMENT_START,
772 CLUTTER_BIN_ALIGNMENT_END);
776 play_camera (EmpathyCallWindow *window,
779 EmpathyCallWindowPriv *priv = GET_PRIV (window);
783 if (priv->video_preview == NULL)
785 create_video_preview (window);
786 add_video_preview_to_pipeline (window);
790 state = GST_STATE_PLAYING;
792 state = GST_STATE_NULL;
794 preview = priv->video_preview_sink;
796 gst_element_set_state (preview, state);
797 gst_element_set_state (priv->video_input, state);
798 gst_element_set_state (priv->video_tee, state);
802 display_video_preview (EmpathyCallWindow *self,
805 EmpathyCallWindowPriv *priv = GET_PRIV (self);
809 /* Display the video preview */
810 DEBUG ("Show video preview");
812 play_camera (self, TRUE);
813 clutter_actor_show (priv->video_preview);
817 /* Hide the video preview */
818 DEBUG ("Hide video preview");
820 if (priv->video_preview != NULL)
822 clutter_actor_hide (priv->video_preview);
823 play_camera (self, FALSE);
829 empathy_call_window_set_state_connecting (EmpathyCallWindow *window)
831 EmpathyCallWindowPriv *priv = GET_PRIV (window);
833 empathy_call_window_status_message (window, _("Connecting…"));
834 priv->call_state = CONNECTING;
837 empathy_sound_manager_start_playing (priv->sound_mgr, GTK_WIDGET (window),
838 EMPATHY_SOUND_PHONE_OUTGOING, MS_BETWEEN_RING);
842 disable_camera (EmpathyCallWindow *self)
844 EmpathyCallWindowPriv *priv = GET_PRIV (self);
846 if (priv->camera_state == CAMERA_STATE_OFF)
849 DEBUG ("Disable camera");
851 display_video_preview (self, FALSE);
853 if (priv->camera_state == CAMERA_STATE_ON)
854 empathy_call_window_set_send_video (self, CAMERA_STATE_OFF);
856 priv->camera_state = CAMERA_STATE_OFF;
860 enable_camera (EmpathyCallWindow *self)
862 EmpathyCallWindowPriv *priv = GET_PRIV (self);
864 if (priv->camera_state == CAMERA_STATE_ON)
867 if (priv->video_input == NULL)
869 DEBUG ("Can't enable camera, no input");
873 DEBUG ("Enable camera");
875 empathy_call_window_set_send_video (self, CAMERA_STATE_ON);
877 priv->camera_state = CAMERA_STATE_ON;
881 empathy_call_window_camera_toggled_cb (GtkToggleToolButton *toggle,
882 EmpathyCallWindow *self)
884 if (gtk_toggle_tool_button_get_active (toggle))
885 enable_camera (self);
887 disable_camera (self);
891 create_pipeline (EmpathyCallWindow *self)
893 EmpathyCallWindowPriv *priv = GET_PRIV (self);
896 g_assert (priv->pipeline == NULL);
898 priv->pipeline = gst_pipeline_new (NULL);
899 priv->pipeline_playing = FALSE;
901 priv->video_tee = gst_element_factory_make ("tee", NULL);
902 gst_object_ref (priv->video_tee);
903 gst_object_sink (priv->video_tee);
905 gst_bin_add (GST_BIN (priv->pipeline), priv->video_tee);
907 bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
908 priv->bus_message_source_id = gst_bus_add_watch (bus,
909 empathy_call_window_bus_message, self);
911 g_object_unref (bus);
915 empathy_call_window_configure_event_cb (GtkWidget *widget,
917 EmpathyCallWindow *self)
919 GdkWindow *gdk_window;
920 GdkWindowState window_state;
922 gtk_window_get_position (GTK_WINDOW (self), &self->priv->x, &self->priv->y);
923 gtk_window_get_size (GTK_WINDOW (self), &self->priv->w, &self->priv->h);
925 gtk_widget_get_preferred_width (self->priv->sidebar,
926 &self->priv->sidebar_width, NULL);
928 gdk_window = gtk_widget_get_window (widget);
929 window_state = gdk_window_get_state (gdk_window);
930 self->priv->maximized = (window_state & GDK_WINDOW_STATE_MAXIMIZED);
936 empathy_call_window_destroyed_cb (GtkWidget *object,
937 EmpathyCallWindow *self)
939 if (gtk_widget_get_visible (self->priv->sidebar))
941 /* Save the geometry as if the sidebar was hidden. */
942 empathy_geometry_save_values (GTK_WINDOW (self),
943 self->priv->x, self->priv->y,
944 self->priv->w - self->priv->sidebar_width, self->priv->h,
945 self->priv->maximized);
950 empathy_call_window_init (EmpathyCallWindow *self)
952 EmpathyCallWindowPriv *priv;
958 ClutterConstraint *size_constraint;
959 ClutterActor *remote_avatar;
960 GtkStyleContext *context;
964 priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
965 EMPATHY_TYPE_CALL_WINDOW, EmpathyCallWindowPriv);
967 filename = empathy_file_lookup ("empathy-call-window.ui", "src");
968 gui = empathy_builder_get_file (filename,
969 "call_window_vbox", &top_vbox,
970 "errors_vbox", &priv->errors_vbox,
972 "statusbar", &priv->statusbar,
973 "redial", &priv->redial_button,
974 "volume", &priv->volume_item,
975 "microphone", &priv->mic_button,
976 "camera", &priv->camera_button,
977 "dialpad", &priv->dialpad_button,
978 "toolbar", &priv->toolbar,
979 "menuredial", &priv->redial,
980 "menusidebar", &priv->menu_sidebar,
981 "ui_manager", &priv->ui_manager,
982 "menufullscreen", &priv->menu_fullscreen,
983 "details_vbox", &priv->details_vbox,
984 "vcodec_encoding_label", &priv->vcodec_encoding_label,
985 "acodec_encoding_label", &priv->acodec_encoding_label,
986 "acodec_decoding_label", &priv->acodec_decoding_label,
987 "vcodec_decoding_label", &priv->vcodec_decoding_label,
988 "audio_remote_candidate_label", &priv->audio_remote_candidate_label,
989 "audio_local_candidate_label", &priv->audio_local_candidate_label,
990 "video_remote_candidate_label", &priv->video_remote_candidate_label,
991 "video_local_candidate_label", &priv->video_local_candidate_label,
992 "video_remote_candidate_info_img", &priv->video_remote_candidate_info_img,
993 "video_local_candidate_info_img", &priv->video_local_candidate_info_img,
994 "audio_remote_candidate_info_img", &priv->audio_remote_candidate_info_img,
995 "audio_local_candidate_info_img", &priv->audio_local_candidate_info_img,
999 empathy_builder_connect (gui, self,
1000 "menuhangup", "activate", empathy_call_window_hangup_cb,
1001 "hangup", "clicked", empathy_call_window_hangup_cb,
1002 "menuredial", "activate", empathy_call_window_redial_cb,
1003 "redial", "clicked", empathy_call_window_redial_cb,
1004 "menusidebar", "toggled", empathy_call_window_sidebar_cb,
1005 "microphone", "toggled", empathy_call_window_mic_toggled_cb,
1006 "camera", "toggled", empathy_call_window_camera_toggled_cb,
1007 "dialpad", "toggled", empathy_call_window_dialpad_cb,
1008 "menufullscreen", "activate", empathy_call_window_fullscreen_cb,
1009 "menupreviewdisable", "activate", empathy_call_window_disable_camera_cb,
1010 "menupreviewminimise", "activate", empathy_call_window_minimise_camera_cb,
1011 "menupreviewmaximise", "activate", empathy_call_window_maximise_camera_cb,
1014 gtk_action_set_sensitive (priv->menu_fullscreen, FALSE);
1016 priv->camera_monitor = empathy_camera_monitor_dup_singleton ();
1018 g_object_bind_property (priv->camera_monitor, "available",
1019 priv->camera_button, "sensitive",
1020 G_BINDING_SYNC_CREATE);
1022 priv->lock = g_mutex_new ();
1024 gtk_container_add (GTK_CONTAINER (self), top_vbox);
1026 priv->content_hbox = gtk_hbox_new (FALSE, CONTENT_HBOX_SPACING);
1027 gtk_container_set_border_width (GTK_CONTAINER (priv->content_hbox),
1028 CONTENT_HBOX_BORDER_WIDTH);
1029 gtk_paned_pack1 (GTK_PANED (priv->pane), priv->content_hbox, TRUE, FALSE);
1031 /* avatar/video box */
1032 priv->video_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
1033 CLUTTER_BIN_ALIGNMENT_CENTER);
1035 priv->video_box = clutter_box_new (priv->video_layout);
1037 priv->video_container = gtk_clutter_embed_new ();
1039 /* Set the background color to that of the rest of the window */
1040 context = gtk_widget_get_style_context (priv->content_hbox);
1041 gtk_style_context_get_background_color (context,
1042 GTK_STATE_FLAG_NORMAL, &rgba);
1043 bg.red = CLAMP (rgba.red * 255.0, 0, 255);
1044 bg.green = CLAMP (rgba.green * 255.0, 0, 255);
1045 bg.blue = CLAMP (rgba.blue * 255.0, 0, 255);
1046 bg.alpha = CLAMP (rgba.alpha * 255.0, 0, 255);
1047 clutter_stage_set_color (
1048 CLUTTER_STAGE (gtk_clutter_embed_get_stage (
1049 GTK_CLUTTER_EMBED (priv->video_container))),
1052 clutter_container_add (
1053 CLUTTER_CONTAINER (gtk_clutter_embed_get_stage (
1054 GTK_CLUTTER_EMBED (priv->video_container))),
1058 size_constraint = clutter_bind_constraint_new (
1059 gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->video_container)),
1060 CLUTTER_BIND_SIZE, 0);
1061 clutter_actor_add_constraint (priv->video_box, size_constraint);
1063 priv->remote_user_avatar_widget = gtk_image_new ();
1064 remote_avatar = gtk_clutter_actor_new_with_contents (
1065 priv->remote_user_avatar_widget);
1067 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_box),
1070 gtk_box_pack_start (GTK_BOX (priv->content_hbox),
1071 priv->video_container, TRUE, TRUE,
1072 CONTENT_HBOX_CHILDREN_PACKING_PADDING);
1074 create_pipeline (self);
1075 create_video_output_widget (self);
1076 create_audio_input (self);
1077 create_video_input (self);
1079 /* The call will be started as soon the pipeline is playing */
1080 priv->start_call_when_playing = TRUE;
1082 empathy_call_window_setup_toolbar (self);
1084 priv->sidebar = ev_sidebar_new ();
1085 g_signal_connect (G_OBJECT (priv->sidebar),
1086 "hide", G_CALLBACK (empathy_call_window_sidebar_hidden_cb), self);
1087 g_signal_connect (G_OBJECT (priv->sidebar),
1088 "show", G_CALLBACK (empathy_call_window_sidebar_shown_cb), self);
1089 g_signal_connect (G_OBJECT (priv->sidebar), "changed",
1090 G_CALLBACK (empathy_call_window_sidebar_changed_cb), self);
1091 gtk_paned_pack2 (GTK_PANED (priv->pane), priv->sidebar, FALSE, FALSE);
1093 page = empathy_call_window_create_audio_input (self);
1094 ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "audio-input",
1095 _("Audio input"), page);
1097 page = empathy_call_window_create_video_input (self);
1098 ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "video-input",
1099 _("Video input"), page);
1101 priv->dtmf_panel = empathy_create_dtmf_dialpad (G_OBJECT (self),
1102 G_CALLBACK (dtmf_button_pressed_cb),
1103 G_CALLBACK (dtmf_button_released_cb));
1104 ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "dialpad",
1105 _("Dialpad"), priv->dtmf_panel);
1107 gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
1109 /* Put the details vbox in a scroll window as it can require a lot of
1110 * horizontal space. */
1111 scroll = gtk_scrolled_window_new (NULL, NULL);
1112 gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll),
1113 priv->details_vbox);
1115 ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "details", _("Details"),
1118 gtk_widget_show_all (top_vbox);
1120 gtk_widget_hide (priv->sidebar);
1122 priv->fullscreen = empathy_call_window_fullscreen_new (self);
1124 empathy_call_window_fullscreen_set_video_widget (priv->fullscreen,
1125 priv->video_container);
1127 g_signal_connect (G_OBJECT (priv->fullscreen->leave_fullscreen_button),
1128 "clicked", G_CALLBACK (empathy_call_window_fullscreen_cb), self);
1130 g_signal_connect (G_OBJECT (self), "realize",
1131 G_CALLBACK (empathy_call_window_realized_cb), self);
1133 g_signal_connect (G_OBJECT (self), "delete-event",
1134 G_CALLBACK (empathy_call_window_delete_cb), self);
1136 g_signal_connect (G_OBJECT (self), "window-state-event",
1137 G_CALLBACK (empathy_call_window_state_event_cb), self);
1139 g_signal_connect (G_OBJECT (self), "key-press-event",
1140 G_CALLBACK (empathy_call_window_key_press_cb), self);
1142 priv->timer = g_timer_new ();
1144 g_object_ref (priv->ui_manager);
1145 g_object_unref (gui);
1147 priv->sound_mgr = empathy_sound_manager_dup_singleton ();
1149 empathy_geometry_bind (GTK_WINDOW (self), "call-window");
1150 /* These signals are used to track the window position and save it
1151 * when the window is destroyed. We need to do this as we don't want
1152 * the window geometry to be saved with the sidebar taken into account. */
1153 g_signal_connect (self, "destroy",
1154 G_CALLBACK (empathy_call_window_destroyed_cb), self);
1155 g_signal_connect (self, "configure-event",
1156 G_CALLBACK (empathy_call_window_configure_event_cb), self);
1157 g_signal_connect (self, "window-state-event",
1158 G_CALLBACK (empathy_call_window_configure_event_cb), self);
1161 /* Instead of specifying a width and a height, we specify only one size. That's
1162 because we want a square avatar icon. */
1164 init_contact_avatar_with_size (EmpathyContact *contact,
1165 GtkWidget *image_widget,
1168 GdkPixbuf *pixbuf_avatar = NULL;
1170 if (contact != NULL)
1172 pixbuf_avatar = empathy_pixbuf_avatar_from_contact_scaled (contact,
1176 if (pixbuf_avatar == NULL)
1178 pixbuf_avatar = empathy_pixbuf_from_icon_name_sized (
1179 EMPATHY_IMAGE_AVATAR_DEFAULT, size);
1182 gtk_image_set_from_pixbuf (GTK_IMAGE (image_widget), pixbuf_avatar);
1184 if (pixbuf_avatar != NULL)
1185 g_object_unref (pixbuf_avatar);
1189 set_window_title (EmpathyCallWindow *self)
1191 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1194 if (priv->contact != NULL)
1196 /* translators: Call is a noun and %s is the contact name. This string
1197 * is used in the window title */
1198 tmp = g_strdup_printf (_("Call with %s"),
1199 empathy_contact_get_alias (priv->contact));
1200 gtk_window_set_title (GTK_WINDOW (self), tmp);
1205 gtk_window_set_title (GTK_WINDOW (self), _("Call with %d participants"));
1210 contact_name_changed_cb (EmpathyContact *contact,
1211 GParamSpec *pspec, EmpathyCallWindow *self)
1213 set_window_title (self);
1217 contact_avatar_changed_cb (EmpathyContact *contact,
1218 GParamSpec *pspec, GtkWidget *avatar_widget)
1221 GtkAllocation allocation;
1223 gtk_widget_get_allocation (avatar_widget, &allocation);
1224 size = allocation.height;
1228 /* the widget is not allocated yet, set a default size */
1229 size = MIN (REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT,
1230 REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH);
1233 init_contact_avatar_with_size (contact, avatar_widget, size);
1237 empathy_call_window_setup_avatars (EmpathyCallWindow *self,
1238 EmpathyCallHandler *handler)
1240 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1242 g_signal_connect (priv->contact, "notify::name",
1243 G_CALLBACK (contact_name_changed_cb), self);
1244 g_signal_connect (priv->contact, "notify::avatar",
1245 G_CALLBACK (contact_avatar_changed_cb),
1246 priv->remote_user_avatar_widget);
1248 set_window_title (self);
1250 init_contact_avatar_with_size (priv->contact,
1251 priv->remote_user_avatar_widget,
1252 MIN (REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH,
1253 REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT));
1255 /* The remote avatar is shown by default and will be hidden when we receive
1256 video from the remote side. */
1257 clutter_actor_hide (priv->video_output);
1258 gtk_widget_show (priv->remote_user_avatar_widget);
1262 update_send_codec (EmpathyCallWindow *self,
1265 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1272 codec = empathy_call_handler_get_send_audio_codec (priv->handler);
1273 widget = priv->acodec_encoding_label;
1277 codec = empathy_call_handler_get_send_video_codec (priv->handler);
1278 widget = priv->vcodec_encoding_label;
1284 tmp = g_strdup_printf ("%s/%u", codec->encoding_name, codec->clock_rate);
1285 gtk_label_set_text (GTK_LABEL (widget), tmp);
1290 send_audio_codec_notify_cb (GObject *object,
1294 EmpathyCallWindow *self = user_data;
1296 update_send_codec (self, TRUE);
1300 send_video_codec_notify_cb (GObject *object,
1304 EmpathyCallWindow *self = user_data;
1306 update_send_codec (self, FALSE);
1310 update_recv_codec (EmpathyCallWindow *self,
1313 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1316 GString *str = NULL;
1320 codecs = empathy_call_handler_get_recv_audio_codecs (priv->handler);
1321 widget = priv->acodec_decoding_label;
1325 codecs = empathy_call_handler_get_recv_video_codecs (priv->handler);
1326 widget = priv->vcodec_decoding_label;
1332 for (l = codecs; l != NULL; l = g_list_next (l))
1334 FsCodec *codec = l->data;
1337 str = g_string_new (NULL);
1339 g_string_append (str, ", ");
1341 g_string_append_printf (str, "%s/%u", codec->encoding_name,
1345 gtk_label_set_text (GTK_LABEL (widget), str->str);
1346 g_string_free (str, TRUE);
1350 recv_audio_codecs_notify_cb (GObject *object,
1354 EmpathyCallWindow *self = user_data;
1356 update_recv_codec (self, TRUE);
1360 recv_video_codecs_notify_cb (GObject *object,
1364 EmpathyCallWindow *self = user_data;
1366 update_recv_codec (self, FALSE);
1369 static const gchar *
1370 candidate_type_to_str (FsCandidate *candidate)
1372 switch (candidate->type)
1374 case FS_CANDIDATE_TYPE_HOST:
1376 case FS_CANDIDATE_TYPE_SRFLX:
1377 return "server reflexive";
1378 case FS_CANDIDATE_TYPE_PRFLX:
1379 return "peer reflexive";
1380 case FS_CANDIDATE_TYPE_RELAY:
1382 case FS_CANDIDATE_TYPE_MULTICAST:
1389 static const gchar *
1390 candidate_type_to_desc (FsCandidate *candidate)
1392 switch (candidate->type)
1394 case FS_CANDIDATE_TYPE_HOST:
1395 return _("The IP address as seen by the machine");
1396 case FS_CANDIDATE_TYPE_SRFLX:
1397 return _("The IP address as seen by a server on the Internet");
1398 case FS_CANDIDATE_TYPE_PRFLX:
1399 return _("The IP address of the peer as seen by the other side");
1400 case FS_CANDIDATE_TYPE_RELAY:
1401 return _("The IP address of a relay server");
1402 case FS_CANDIDATE_TYPE_MULTICAST:
1403 return _("The IP address of the multicast group");
1410 update_candidat_widget (EmpathyCallWindow *self,
1413 FsCandidate *candidate)
1417 g_assert (candidate != NULL);
1418 str = g_strdup_printf ("%s %u (%s)", candidate->ip,
1419 candidate->port, candidate_type_to_str (candidate));
1421 gtk_label_set_text (GTK_LABEL (label), str);
1422 gtk_widget_set_tooltip_text (img, candidate_type_to_desc (candidate));
1428 candidates_changed_cb (GObject *object,
1430 EmpathyCallWindow *self)
1432 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1433 FsCandidate *candidate = NULL;
1435 if (type == FS_MEDIA_TYPE_VIDEO)
1437 /* Update remote candidate */
1438 candidate = empathy_call_handler_get_video_remote_candidate (
1441 update_candidat_widget (self, priv->video_remote_candidate_label,
1442 priv->video_remote_candidate_info_img, candidate);
1444 /* Update local candidate */
1445 candidate = empathy_call_handler_get_video_local_candidate (
1448 update_candidat_widget (self, priv->video_local_candidate_label,
1449 priv->video_local_candidate_info_img, candidate);
1453 /* Update remote candidate */
1454 candidate = empathy_call_handler_get_audio_remote_candidate (
1457 update_candidat_widget (self, priv->audio_remote_candidate_label,
1458 priv->audio_remote_candidate_info_img, candidate);
1460 /* Update local candidate */
1461 candidate = empathy_call_handler_get_audio_local_candidate (
1464 update_candidat_widget (self, priv->audio_local_candidate_label,
1465 priv->audio_local_candidate_info_img, candidate);
1470 empathy_call_window_constructed (GObject *object)
1472 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
1473 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1474 TpyCallChannel *call;
1476 g_assert (priv->handler != NULL);
1478 g_object_get (priv->handler, "call-channel", &call, NULL);
1479 priv->outgoing = (call == NULL);
1481 g_object_unref (call);
1483 g_object_get (priv->handler, "target-contact", &priv->contact, NULL);
1484 g_assert (priv->contact != NULL);
1486 empathy_call_window_setup_avatars (self, priv->handler);
1487 empathy_call_window_set_state_connecting (self);
1489 if (!empathy_call_handler_has_initial_video (priv->handler))
1491 gtk_toggle_tool_button_set_active (
1492 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), FALSE);
1494 /* If call has InitialVideo, the preview will be started once the call has
1495 * been started (start_call()). */
1497 update_send_codec (self, TRUE);
1498 update_send_codec (self, FALSE);
1499 update_recv_codec (self, TRUE);
1500 update_recv_codec (self, FALSE);
1502 tp_g_signal_connect_object (priv->handler, "notify::send-audio-codec",
1503 G_CALLBACK (send_audio_codec_notify_cb), self, 0);
1504 tp_g_signal_connect_object (priv->handler, "notify::send-video-codec",
1505 G_CALLBACK (send_video_codec_notify_cb), self, 0);
1506 tp_g_signal_connect_object (priv->handler, "notify::recv-audio-codecs",
1507 G_CALLBACK (recv_audio_codecs_notify_cb), self, 0);
1508 tp_g_signal_connect_object (priv->handler, "notify::recv-video-codecs",
1509 G_CALLBACK (recv_video_codecs_notify_cb), self, 0);
1511 tp_g_signal_connect_object (priv->handler, "candidates-changed",
1512 G_CALLBACK (candidates_changed_cb), self, 0);
1515 static void empathy_call_window_dispose (GObject *object);
1516 static void empathy_call_window_finalize (GObject *object);
1519 empathy_call_window_set_property (GObject *object,
1520 guint property_id, const GValue *value, GParamSpec *pspec)
1522 EmpathyCallWindowPriv *priv = GET_PRIV (object);
1524 switch (property_id)
1526 case PROP_CALL_HANDLER:
1527 priv->handler = g_value_dup_object (value);
1530 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1535 empathy_call_window_get_property (GObject *object,
1536 guint property_id, GValue *value, GParamSpec *pspec)
1538 EmpathyCallWindowPriv *priv = GET_PRIV (object);
1540 switch (property_id)
1542 case PROP_CALL_HANDLER:
1543 g_value_set_object (value, priv->handler);
1546 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1551 empathy_call_window_class_init (
1552 EmpathyCallWindowClass *empathy_call_window_class)
1554 GObjectClass *object_class = G_OBJECT_CLASS (empathy_call_window_class);
1555 GParamSpec *param_spec;
1557 g_type_class_add_private (empathy_call_window_class,
1558 sizeof (EmpathyCallWindowPriv));
1560 object_class->constructed = empathy_call_window_constructed;
1561 object_class->set_property = empathy_call_window_set_property;
1562 object_class->get_property = empathy_call_window_get_property;
1564 object_class->dispose = empathy_call_window_dispose;
1565 object_class->finalize = empathy_call_window_finalize;
1567 param_spec = g_param_spec_object ("handler",
1568 "handler", "The call handler",
1569 EMPATHY_TYPE_CALL_HANDLER,
1570 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
1571 g_object_class_install_property (object_class,
1572 PROP_CALL_HANDLER, param_spec);
1576 empathy_call_window_dispose (GObject *object)
1578 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
1579 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1581 if (priv->dispose_has_run)
1584 priv->dispose_has_run = TRUE;
1586 if (priv->handler != NULL)
1588 empathy_call_handler_stop_call (priv->handler);
1589 tp_clear_object (&priv->handler);
1592 if (priv->bus_message_source_id != 0)
1594 g_source_remove (priv->bus_message_source_id);
1595 priv->bus_message_source_id = 0;
1598 if (priv->got_video_src > 0)
1600 g_source_remove (priv->got_video_src);
1601 priv->got_video_src = 0;
1604 tp_clear_object (&priv->pipeline);
1605 tp_clear_object (&priv->video_input);
1606 tp_clear_object (&priv->audio_input);
1607 tp_clear_object (&priv->video_tee);
1608 tp_clear_object (&priv->ui_manager);
1609 tp_clear_object (&priv->fullscreen);
1610 tp_clear_object (&priv->camera_monitor);
1612 g_list_free_full (priv->notifiers, g_object_unref);
1614 if (priv->timer_id != 0)
1615 g_source_remove (priv->timer_id);
1618 if (priv->contact != NULL)
1620 g_signal_handlers_disconnect_by_func (priv->contact,
1621 contact_name_changed_cb, self);
1622 priv->contact = NULL;
1626 tp_clear_object (&priv->sound_mgr);
1628 G_OBJECT_CLASS (empathy_call_window_parent_class)->dispose (object);
1632 disconnect_video_output_motion_handler (EmpathyCallWindow *self)
1634 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1636 if (priv->video_output_motion_handler_id != 0)
1638 g_signal_handler_disconnect (G_OBJECT (priv->video_container),
1639 priv->video_output_motion_handler_id);
1640 priv->video_output_motion_handler_id = 0;
1645 empathy_call_window_finalize (GObject *object)
1647 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
1648 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1650 disconnect_video_output_motion_handler (self);
1652 /* free any data held directly by the object here */
1653 g_mutex_free (priv->lock);
1655 g_timer_destroy (priv->timer);
1657 G_OBJECT_CLASS (empathy_call_window_parent_class)->finalize (object);
1662 empathy_call_window_new (EmpathyCallHandler *handler)
1664 return EMPATHY_CALL_WINDOW (
1665 g_object_new (EMPATHY_TYPE_CALL_WINDOW, "handler", handler, NULL));
1669 empathy_call_window_conference_added_cb (EmpathyCallHandler *handler,
1670 GstElement *conference, gpointer user_data)
1672 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
1673 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1674 FsElementAddedNotifier *notifier;
1677 DEBUG ("Conference added");
1679 /* Add notifier to set the various element properties as needed */
1680 notifier = fs_element_added_notifier_new ();
1681 keyfile = fs_utils_get_default_element_properties (conference);
1683 if (keyfile != NULL)
1684 fs_element_added_notifier_set_properties_from_keyfile (notifier, keyfile);
1686 fs_element_added_notifier_add (notifier, GST_BIN (priv->pipeline));
1688 priv->notifiers = g_list_prepend (priv->notifiers, notifier);
1690 gst_bin_add (GST_BIN (priv->pipeline), conference);
1691 gst_element_set_state (conference, GST_STATE_PLAYING);
1695 empathy_call_window_conference_removed_cb (EmpathyCallHandler *handler,
1696 GstElement *conference, gpointer user_data)
1698 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
1699 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1701 gst_bin_remove (GST_BIN (priv->pipeline), conference);
1702 gst_element_set_state (conference, GST_STATE_NULL);
1706 empathy_call_window_reset_pipeline (EmpathyCallWindow *self)
1708 GstStateChangeReturn state_change_return;
1709 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1711 if (priv->pipeline == NULL)
1714 if (priv->bus_message_source_id != 0)
1716 g_source_remove (priv->bus_message_source_id);
1717 priv->bus_message_source_id = 0;
1720 state_change_return = gst_element_set_state (priv->pipeline, GST_STATE_NULL);
1722 if (state_change_return == GST_STATE_CHANGE_SUCCESS ||
1723 state_change_return == GST_STATE_CHANGE_NO_PREROLL)
1725 if (priv->pipeline != NULL)
1726 g_object_unref (priv->pipeline);
1727 priv->pipeline = NULL;
1729 g_signal_handlers_disconnect_by_func (priv->audio_input_adj,
1730 empathy_call_window_mic_volume_changed_cb, self);
1732 if (priv->audio_output != NULL)
1733 g_object_unref (priv->audio_output);
1734 priv->audio_output = NULL;
1736 if (priv->video_tee != NULL)
1737 g_object_unref (priv->video_tee);
1738 priv->video_tee = NULL;
1740 if (priv->video_preview != NULL)
1741 clutter_actor_destroy (priv->video_preview);
1742 priv->video_preview = NULL;
1744 priv->funnel = NULL;
1746 create_pipeline (self);
1747 /* Call will be started when user will hit the 'redial' button */
1748 priv->start_call_when_playing = FALSE;
1749 gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
1755 g_message ("Error: could not destroy pipeline. Closing call window");
1756 gtk_widget_destroy (GTK_WIDGET (self));
1763 reset_details_pane (EmpathyCallWindow *self)
1765 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1767 gtk_label_set_text (GTK_LABEL (priv->vcodec_encoding_label), _("Unknown"));
1768 gtk_label_set_text (GTK_LABEL (priv->acodec_encoding_label), _("Unknown"));
1769 gtk_label_set_text (GTK_LABEL (priv->vcodec_decoding_label), _("Unknown"));
1770 gtk_label_set_text (GTK_LABEL (priv->acodec_decoding_label), _("Unknown"));
1774 empathy_call_window_disconnected (EmpathyCallWindow *self,
1777 gboolean could_disconnect = FALSE;
1778 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1779 gboolean could_reset_pipeline;
1781 /* Leave full screen mode if needed */
1782 gtk_window_unfullscreen (GTK_WINDOW (self));
1784 gtk_action_set_sensitive (priv->menu_fullscreen, FALSE);
1785 gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
1787 could_reset_pipeline = empathy_call_window_reset_pipeline (self);
1789 if (priv->call_state == CONNECTING)
1790 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
1792 if (priv->call_state != REDIALING)
1793 priv->call_state = DISCONNECTED;
1795 if (could_reset_pipeline)
1797 g_mutex_lock (priv->lock);
1799 g_timer_stop (priv->timer);
1801 if (priv->timer_id != 0)
1802 g_source_remove (priv->timer_id);
1805 g_mutex_unlock (priv->lock);
1808 /* We are about to destroy the window, no need to update it or create
1809 * a video preview */
1812 empathy_call_window_status_message (self, _("Disconnected"));
1814 gtk_action_set_sensitive (priv->redial, TRUE);
1815 gtk_widget_set_sensitive (priv->redial_button, TRUE);
1817 /* Unsensitive the camera and mic button */
1818 gtk_widget_set_sensitive (priv->camera_button, FALSE);
1819 gtk_widget_set_sensitive (priv->mic_button, FALSE);
1821 /* Be sure that the mic button is enabled */
1822 gtk_toggle_tool_button_set_active (
1823 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button), TRUE);
1825 if (priv->camera_state == CAMERA_STATE_ON)
1827 /* Restart the preview with the new pipeline. */
1828 display_video_preview (self, TRUE);
1831 gtk_progress_bar_set_fraction (
1832 GTK_PROGRESS_BAR (priv->volume_progress_bar), 0);
1834 /* destroy the video output; it will be recreated when we'll redial */
1835 disconnect_video_output_motion_handler (self);
1836 if (priv->video_output != NULL)
1837 clutter_actor_destroy (priv->video_output);
1838 priv->video_output = NULL;
1839 if (priv->got_video_src > 0)
1841 g_source_remove (priv->got_video_src);
1842 priv->got_video_src = 0;
1845 gtk_widget_show (priv->remote_user_avatar_widget);
1847 reset_details_pane (self);
1849 priv->sending_video = FALSE;
1850 priv->call_started = FALSE;
1852 could_disconnect = TRUE;
1854 /* TODO: display the self avatar of the preview (depends if the "Always
1855 * Show Video Preview" is enabled or not) */
1858 return could_disconnect;
1863 empathy_call_window_channel_closed_cb (EmpathyCallHandler *handler,
1866 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
1867 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1869 if (empathy_call_window_disconnected (self, TRUE) &&
1870 priv->call_state == REDIALING)
1871 empathy_call_window_restart_call (self);
1875 empathy_call_window_sink_removed_cb (EmpathyCallHandler *handler,
1877 FsMediaType media_type,
1878 EmpathyCallWindow *self)
1880 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1882 DEBUG ("removing content");
1885 * This assumes that there is only one video stream per channel...
1888 if ((guint) media_type == FS_MEDIA_TYPE_VIDEO)
1890 if (priv->funnel != NULL)
1894 output = priv->video_output_sink;
1896 gst_element_set_state (output, GST_STATE_NULL);
1897 gst_element_set_state (priv->funnel, GST_STATE_NULL);
1899 gst_bin_remove (GST_BIN (priv->pipeline), output);
1900 gst_bin_remove (GST_BIN (priv->pipeline), priv->funnel);
1901 priv->funnel = NULL;
1905 else if (media_type == FS_MEDIA_TYPE_AUDIO)
1907 if (priv->audio_output != NULL)
1909 gst_element_set_state (priv->audio_output, GST_STATE_NULL);
1911 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
1912 priv->audio_output = NULL;
1920 /* Called with global lock held */
1922 empathy_call_window_get_video_sink_pad (EmpathyCallWindow *self)
1924 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1928 if (priv->funnel == NULL)
1930 output = priv->video_output_sink;
1932 priv->funnel = gst_element_factory_make ("fsfunnel", NULL);
1936 g_warning ("Could not create fsfunnel");
1940 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->funnel))
1942 gst_object_unref (priv->funnel);
1943 priv->funnel = NULL;
1944 g_warning ("Could not add funnel to pipeline");
1948 if (!gst_bin_add (GST_BIN (priv->pipeline), output))
1950 g_warning ("Could not add the video output widget to the pipeline");
1954 if (!gst_element_link (priv->funnel, output))
1956 g_warning ("Could not link output sink to funnel");
1957 goto error_output_added;
1960 if (gst_element_set_state (output, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
1962 g_warning ("Could not start video sink");
1963 goto error_output_added;
1966 if (gst_element_set_state (priv->funnel, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
1968 g_warning ("Could not start funnel");
1969 goto error_output_added;
1973 pad = gst_element_get_request_pad (priv->funnel, "sink%d");
1976 g_warning ("Could not get request pad from funnel");
1983 gst_element_set_locked_state (priv->funnel, TRUE);
1984 gst_element_set_locked_state (output, TRUE);
1986 gst_element_set_state (priv->funnel, GST_STATE_NULL);
1987 gst_element_set_state (output, GST_STATE_NULL);
1989 gst_bin_remove (GST_BIN (priv->pipeline), output);
1990 gst_element_set_locked_state (output, FALSE);
1994 gst_bin_remove (GST_BIN (priv->pipeline), priv->funnel);
1995 priv->funnel = NULL;
2000 /* Called with global lock held */
2002 empathy_call_window_get_audio_sink_pad (EmpathyCallWindow *self)
2004 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2006 GstPadTemplate *template;
2008 if (priv->audio_output == NULL)
2010 priv->audio_output = empathy_audio_sink_new ();
2011 g_object_ref_sink (priv->audio_output);
2013 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_output))
2015 g_warning ("Could not add audio sink to pipeline");
2016 g_object_unref (priv->audio_output);
2017 goto error_add_output;
2020 if (gst_element_set_state (priv->audio_output, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2022 g_warning ("Could not start audio sink");
2027 template = gst_element_class_get_pad_template (
2028 GST_ELEMENT_GET_CLASS (priv->audio_output), "sink%d");
2030 pad = gst_element_request_pad (priv->audio_output,
2031 template, NULL, NULL);
2035 g_warning ("Could not get sink pad from sink");
2042 gst_element_set_locked_state (priv->audio_output, TRUE);
2043 gst_element_set_state (priv->audio_output, GST_STATE_NULL);
2044 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
2045 priv->audio_output = NULL;
2053 empathy_call_window_update_timer (gpointer user_data)
2055 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2056 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2060 time_ = g_timer_elapsed (priv->timer, NULL);
2062 /* Translators: 'status - minutes:seconds' the caller has been connected */
2063 str = g_strdup_printf (_("%s — %d:%02dm"),
2064 priv->call_state == HELD ? _("On hold") : _("Connected"),
2065 (int) time_ / 60, (int) time_ % 60);
2066 empathy_call_window_status_message (self, str);
2074 display_error (EmpathyCallWindow *self,
2075 TpyCallChannel *call,
2079 const gchar *details)
2081 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2082 GtkWidget *info_bar;
2083 GtkWidget *content_area;
2090 /* Create info bar */
2091 info_bar = gtk_info_bar_new_with_buttons (GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
2094 gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_WARNING);
2096 content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar));
2098 /* hbox containing the image and the messages vbox */
2099 hbox = gtk_hbox_new (FALSE, 3);
2100 gtk_container_add (GTK_CONTAINER (content_area), hbox);
2103 image = gtk_image_new_from_icon_name (img, GTK_ICON_SIZE_DIALOG);
2104 gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
2106 /* vbox containing the main message and the details expander */
2107 vbox = gtk_vbox_new (FALSE, 3);
2108 gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
2111 txt = g_strdup_printf ("<b>%s</b>\n%s", title, desc);
2113 label = gtk_label_new (NULL);
2114 gtk_label_set_markup (GTK_LABEL (label), txt);
2115 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
2116 gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
2119 gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
2122 if (details != NULL)
2124 GtkWidget *expander;
2126 expander = gtk_expander_new (_("Technical Details"));
2128 txt = g_strdup_printf ("<i>%s</i>", details);
2130 label = gtk_label_new (NULL);
2131 gtk_label_set_markup (GTK_LABEL (label), txt);
2132 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
2133 gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
2136 gtk_container_add (GTK_CONTAINER (expander), label);
2137 gtk_box_pack_start (GTK_BOX (vbox), expander, TRUE, TRUE, 0);
2140 g_signal_connect (info_bar, "response",
2141 G_CALLBACK (gtk_widget_destroy), NULL);
2143 gtk_box_pack_start (GTK_BOX (priv->errors_vbox), info_bar,
2144 FALSE, FALSE, CONTENT_HBOX_CHILDREN_PACKING_PADDING);
2145 gtk_widget_show_all (info_bar);
2149 media_stream_error_to_txt (EmpathyCallWindow *self,
2150 TpyCallChannel *call,
2152 TpMediaStreamError error)
2154 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2155 const gchar *cm = NULL;
2161 case TP_MEDIA_STREAM_ERROR_CODEC_NEGOTIATION_FAILED:
2163 return g_strdup_printf (
2164 _("%s's software does not understand any of the audio formats "
2165 "supported by your computer"),
2166 empathy_contact_get_alias (priv->contact));
2168 return g_strdup_printf (
2169 _("%s's software does not understand any of the video formats "
2170 "supported by your computer"),
2171 empathy_contact_get_alias (priv->contact));
2173 case TP_MEDIA_STREAM_ERROR_CONNECTION_FAILED:
2174 return g_strdup_printf (
2175 _("Can't establish a connection to %s. "
2176 "One of you might be on a network that does not allow "
2177 "direct connections."),
2178 empathy_contact_get_alias (priv->contact));
2180 case TP_MEDIA_STREAM_ERROR_NETWORK_ERROR:
2181 return g_strdup (_("There was a failure on the network"));
2183 case TP_MEDIA_STREAM_ERROR_NO_CODECS:
2185 return g_strdup (_("The audio formats necessary for this call "
2186 "are not installed on your computer"));
2188 return g_strdup (_("The video formats necessary for this call "
2189 "are not installed on your computer"));
2191 case TP_MEDIA_STREAM_ERROR_INVALID_CM_BEHAVIOR:
2192 tp_connection_parse_object_path (
2193 tp_channel_borrow_connection (TP_CHANNEL (call)),
2196 url = g_strdup_printf ("http://bugs.freedesktop.org/enter_bug.cgi?"
2197 "product=Telepathy&component=%s", cm);
2199 result = g_strdup_printf (
2200 _("Something unexpected happened in a Telepathy component. "
2201 "Please <a href=\"%s\">report this bug</a> and attach "
2202 "logs gathered from the 'Debug' window in the Help menu."), url);
2208 case TP_MEDIA_STREAM_ERROR_MEDIA_ERROR:
2209 return g_strdup (_("There was a failure in the call engine"));
2211 case TP_MEDIA_STREAM_ERROR_EOS:
2212 return g_strdup (_("The end of the stream was reached"));
2214 case TP_MEDIA_STREAM_ERROR_UNKNOWN:
2221 empathy_call_window_stream_error (EmpathyCallWindow *self,
2222 TpyCallChannel *call,
2231 desc = media_stream_error_to_txt (self, call, audio, code);
2234 /* No description, use the error message. That's not great as it's not
2235 * localized but it's better than nothing. */
2236 display_error (self, call, icon, title, msg, NULL);
2240 display_error (self, call, icon, title, desc, msg);
2246 empathy_call_window_audio_stream_error (TpyCallChannel *call,
2249 EmpathyCallWindow *self)
2251 empathy_call_window_stream_error (self, call, TRUE, code, msg,
2252 "gnome-stock-mic", _("Can't establish audio stream"));
2256 empathy_call_window_video_stream_error (TpyCallChannel *call,
2259 EmpathyCallWindow *self)
2261 empathy_call_window_stream_error (self, call, FALSE, code, msg,
2262 "camera-web", _("Can't establish video stream"));
2267 empathy_call_window_state_changed_cb (EmpathyCallHandler *handler,
2269 EmpathyCallWindow *self)
2271 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2272 TpyCallChannel *call;
2273 gboolean can_send_video;
2275 if (state != TPY_CALL_STATE_ACCEPTED)
2278 if (priv->call_state == CONNECTED)
2281 g_timer_start (priv->timer);
2282 priv->call_state = CONNECTED;
2284 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
2286 can_send_video = priv->video_input != NULL &&
2287 empathy_contact_can_voip_video (priv->contact) &&
2288 empathy_camera_monitor_get_available (priv->camera_monitor);
2290 g_object_get (priv->handler, "call-channel", &call, NULL);
2292 if (tpy_call_channel_has_dtmf (call))
2293 gtk_widget_set_sensitive (priv->dtmf_panel, TRUE);
2295 if (priv->video_input == NULL)
2296 empathy_call_window_set_send_video (self, CAMERA_STATE_OFF);
2298 gtk_widget_set_sensitive (priv->camera_button, can_send_video);
2300 gtk_action_set_sensitive (priv->redial, FALSE);
2301 gtk_widget_set_sensitive (priv->redial_button, FALSE);
2303 gtk_widget_set_sensitive (priv->mic_button, TRUE);
2305 clutter_actor_hide (priv->video_output);
2306 gtk_widget_show (priv->remote_user_avatar_widget);
2308 g_object_unref (call);
2310 g_mutex_lock (priv->lock);
2312 priv->timer_id = g_timeout_add_seconds (1,
2313 empathy_call_window_update_timer, self);
2315 g_mutex_unlock (priv->lock);
2317 empathy_call_window_update_timer (self);
2319 gtk_action_set_sensitive (priv->menu_fullscreen, TRUE);
2323 empathy_call_window_show_video_output_cb (gpointer user_data)
2325 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2327 if (self->priv->video_output != NULL)
2329 gtk_widget_hide (self->priv->remote_user_avatar_widget);
2330 clutter_actor_show (self->priv->video_output);
2337 empathy_call_window_check_video_cb (gpointer data)
2339 EmpathyCallWindow *self = data;
2341 if (self->priv->got_video)
2343 self->priv->got_video = FALSE;
2347 /* No video in the last N seconds, display the remote avatar */
2348 empathy_call_window_show_video_output (self, FALSE);
2353 /* Called from the streaming thread */
2355 empathy_call_window_video_probe_cb (GstPad *pad,
2356 GstMiniObject *mini_obj,
2357 EmpathyCallWindow *self)
2360 if (GST_IS_EVENT (mini_obj))
2363 if (G_UNLIKELY (!self->priv->got_video))
2365 /* show the remote video */
2366 g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
2367 empathy_call_window_show_video_output_cb,
2368 g_object_ref (self), g_object_unref);
2370 self->priv->got_video = TRUE;
2376 /* Called from the streaming thread */
2378 empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
2379 GstPad *src, guint media_type, gpointer user_data)
2381 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2382 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2383 gboolean retval = FALSE;
2387 g_mutex_lock (priv->lock);
2391 case TP_MEDIA_STREAM_TYPE_AUDIO:
2392 pad = empathy_call_window_get_audio_sink_pad (self);
2394 case TP_MEDIA_STREAM_TYPE_VIDEO:
2395 g_idle_add (empathy_call_window_show_video_output_cb, self);
2396 pad = empathy_call_window_get_video_sink_pad (self);
2398 gst_pad_add_data_probe (src,
2399 G_CALLBACK (empathy_call_window_video_probe_cb), self);
2400 if (priv->got_video_src > 0)
2401 g_source_remove (priv->got_video_src);
2402 priv->got_video_src = g_timeout_add_seconds (5,
2403 empathy_call_window_check_video_cb, self);
2406 g_assert_not_reached ();
2412 if (GST_PAD_LINK_FAILED (gst_pad_link (src, pad)))
2413 g_warning ("Could not link %s sink pad",
2414 media_type == TP_MEDIA_STREAM_TYPE_AUDIO ? "audio" : "video");
2418 gst_object_unref (pad);
2422 /* If no sink could be linked, try to add fakesink to prevent the whole call
2427 GstElement *fakesink = gst_element_factory_make ("fakesink", NULL);
2429 if (gst_bin_add (GST_BIN (priv->pipeline), fakesink))
2431 GstPad *sinkpad = gst_element_get_static_pad (fakesink, "sink");
2432 if (gst_element_set_state (fakesink, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE ||
2433 GST_PAD_LINK_FAILED (gst_pad_link (src, sinkpad)))
2435 gst_element_set_locked_state (fakesink, TRUE);
2436 gst_element_set_state (fakesink, GST_STATE_NULL);
2437 gst_bin_remove (GST_BIN (priv->pipeline), fakesink);
2441 DEBUG ("Could not link real sink, linked fakesink instead");
2443 gst_object_unref (sinkpad);
2447 gst_object_unref (fakesink);
2452 g_mutex_unlock (priv->lock);
2458 empathy_call_window_sink_added_cb (EmpathyCallHandler *handler,
2459 GstPad *sink, FsMediaType media_type, gpointer user_data)
2461 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2462 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2464 gboolean retval = FALSE;
2468 case FS_MEDIA_TYPE_AUDIO:
2469 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_input))
2471 g_warning ("Could not add audio source to pipeline");
2475 pad = gst_element_get_static_pad (priv->audio_input, "src");
2478 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
2479 g_warning ("Could not get source pad from audio source");
2483 if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
2485 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
2486 g_warning ("Could not link audio source to farsight");
2490 if (gst_element_set_state (priv->audio_input, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2492 g_warning ("Could not start audio source");
2493 gst_element_set_state (priv->audio_input, GST_STATE_NULL);
2494 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
2500 case FS_MEDIA_TYPE_VIDEO:
2501 if (priv->video_tee != NULL)
2503 pad = gst_element_get_request_pad (priv->video_tee, "src%d");
2504 if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
2506 g_warning ("Could not link video source input pipeline");
2509 gst_object_unref (pad);
2515 g_assert_not_reached ();
2522 empathy_call_window_remove_video_input (EmpathyCallWindow *self)
2524 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2525 GstElement *preview;
2527 disable_camera (self);
2529 DEBUG ("remove video input");
2530 preview = priv->video_preview_sink;
2532 gst_element_set_state (priv->video_input, GST_STATE_NULL);
2533 gst_element_set_state (priv->video_tee, GST_STATE_NULL);
2534 gst_element_set_state (preview, GST_STATE_NULL);
2536 gst_bin_remove_many (GST_BIN (priv->pipeline), priv->video_input,
2539 g_object_unref (priv->video_input);
2540 priv->video_input = NULL;
2541 g_object_unref (priv->video_tee);
2542 priv->video_tee = NULL;
2543 clutter_actor_destroy (priv->video_preview);
2544 priv->video_preview = NULL;
2546 gtk_widget_set_sensitive (priv->camera_button, FALSE);
2550 start_call (EmpathyCallWindow *self)
2552 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2554 priv->call_started = TRUE;
2555 empathy_call_handler_start_call (priv->handler,
2556 gtk_get_current_event_time ());
2558 if (empathy_call_handler_has_initial_video (priv->handler))
2560 TpyCallChannel *call;
2563 g_object_get (priv->handler, "call-channel", &call, NULL);
2564 s = tpy_call_channel_get_video_state (call);
2566 if (s == TPY_SENDING_STATE_PENDING_SEND ||
2567 s == TPY_SENDING_STATE_SENDING)
2569 /* Enable 'send video' buttons and display the preview */
2570 gtk_toggle_tool_button_set_active (
2571 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), TRUE);
2575 gtk_toggle_tool_button_set_active (
2576 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), FALSE);
2578 if (priv->video_preview == NULL)
2580 create_video_preview (self);
2581 add_video_preview_to_pipeline (self);
2585 g_object_unref (call);
2590 empathy_call_window_bus_message (GstBus *bus, GstMessage *message,
2593 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2594 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2597 empathy_call_handler_bus_message (priv->handler, bus, message);
2599 switch (GST_MESSAGE_TYPE (message))
2601 case GST_MESSAGE_STATE_CHANGED:
2602 if (GST_MESSAGE_SRC (message) == GST_OBJECT (priv->video_input))
2604 gst_message_parse_state_changed (message, NULL, &newstate, NULL);
2605 if (newstate == GST_STATE_PAUSED)
2606 empathy_call_window_setup_video_input (self);
2608 if (GST_MESSAGE_SRC (message) == GST_OBJECT (priv->pipeline) &&
2609 !priv->call_started)
2611 gst_message_parse_state_changed (message, NULL, &newstate, NULL);
2612 if (newstate == GST_STATE_PAUSED)
2614 gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
2615 priv->pipeline_playing = TRUE;
2617 if (priv->start_call_when_playing)
2622 case GST_MESSAGE_ERROR:
2624 GError *error = NULL;
2625 GstElement *gst_error;
2628 gst_message_parse_error (message, &error, &debug);
2629 gst_error = GST_ELEMENT (GST_MESSAGE_SRC (message));
2631 g_message ("Element error: %s -- %s\n", error->message, debug);
2633 if (g_str_has_prefix (gst_element_get_name (gst_error),
2634 VIDEO_INPUT_ERROR_PREFIX))
2636 /* Remove the video input and continue */
2637 if (priv->video_input != NULL)
2638 empathy_call_window_remove_video_input (self);
2639 gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
2643 empathy_call_window_disconnected (self, TRUE);
2645 g_error_free (error);
2648 case GST_MESSAGE_UNKNOWN:
2649 case GST_MESSAGE_EOS:
2650 case GST_MESSAGE_WARNING:
2651 case GST_MESSAGE_INFO:
2652 case GST_MESSAGE_TAG:
2653 case GST_MESSAGE_BUFFERING:
2654 case GST_MESSAGE_STATE_DIRTY:
2655 case GST_MESSAGE_STEP_DONE:
2656 case GST_MESSAGE_CLOCK_PROVIDE:
2657 case GST_MESSAGE_CLOCK_LOST:
2658 case GST_MESSAGE_NEW_CLOCK:
2659 case GST_MESSAGE_STRUCTURE_CHANGE:
2660 case GST_MESSAGE_STREAM_STATUS:
2661 case GST_MESSAGE_APPLICATION:
2662 case GST_MESSAGE_ELEMENT:
2663 case GST_MESSAGE_SEGMENT_START:
2664 case GST_MESSAGE_SEGMENT_DONE:
2665 case GST_MESSAGE_DURATION:
2666 case GST_MESSAGE_ANY:
2675 empathy_call_window_members_changed_cb (TpyCallChannel *call,
2676 GHashTable *members,
2677 EmpathyCallWindow *self)
2679 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2680 GHashTableIter iter;
2681 gpointer key, value;
2682 gboolean held = FALSE;
2684 g_hash_table_iter_init (&iter, members);
2685 while (g_hash_table_iter_next (&iter, &key, &value))
2687 if (GPOINTER_TO_INT (value) & TPY_CALL_MEMBER_FLAG_HELD)
2689 /* This assumes this is a 1-1 call, otherwise one participant
2690 * putting the call on hold wouldn't mean the call is on hold
2698 priv->call_state = HELD;
2699 else if (priv->call_state == HELD)
2700 priv->call_state = CONNECTED;
2704 call_handler_notify_call_cb (EmpathyCallHandler *handler,
2706 EmpathyCallWindow *self)
2708 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2709 TpyCallChannel *call;
2711 g_object_get (priv->handler, "call-channel", &call, NULL);
2716 tp_g_signal_connect_object (call, "audio-stream-error",
2717 G_CALLBACK (empathy_call_window_audio_stream_error), self, 0);
2718 tp_g_signal_connect_object (call, "video-stream-error",
2719 G_CALLBACK (empathy_call_window_video_stream_error), self, 0);
2722 tp_g_signal_connect_object (call, "members-changed",
2723 G_CALLBACK (empathy_call_window_members_changed_cb), self, 0);
2725 g_object_unref (call);
2729 empathy_call_window_realized_cb (GtkWidget *widget, EmpathyCallWindow *window)
2731 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2732 TpyCallChannel *call;
2734 g_signal_connect (priv->handler, "state-changed",
2735 G_CALLBACK (empathy_call_window_state_changed_cb), window);
2736 g_signal_connect (priv->handler, "conference-added",
2737 G_CALLBACK (empathy_call_window_conference_added_cb), window);
2738 g_signal_connect (priv->handler, "conference-removed",
2739 G_CALLBACK (empathy_call_window_conference_removed_cb), window);
2740 g_signal_connect (priv->handler, "closed",
2741 G_CALLBACK (empathy_call_window_channel_closed_cb), window);
2742 g_signal_connect (priv->handler, "src-pad-added",
2743 G_CALLBACK (empathy_call_window_src_added_cb), window);
2744 g_signal_connect (priv->handler, "sink-pad-added",
2745 G_CALLBACK (empathy_call_window_sink_added_cb), window);
2746 g_signal_connect (priv->handler, "sink-pad-removed",
2747 G_CALLBACK (empathy_call_window_sink_removed_cb), window);
2749 g_object_get (priv->handler, "call-channel", &call, NULL);
2752 call_handler_notify_call_cb (priv->handler, NULL, window);
2753 g_object_unref (call);
2757 /* call-channel doesn't exist yet, we'll connect signals once it has been
2759 g_signal_connect (priv->handler, "notify::call-channel",
2760 G_CALLBACK (call_handler_notify_call_cb), window);
2763 gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
2767 empathy_call_window_delete_cb (GtkWidget *widget, GdkEvent*event,
2768 EmpathyCallWindow *window)
2770 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2772 if (priv->pipeline != NULL)
2774 if (priv->bus_message_source_id != 0)
2776 g_source_remove (priv->bus_message_source_id);
2777 priv->bus_message_source_id = 0;
2780 gst_element_set_state (priv->pipeline, GST_STATE_NULL);
2783 if (priv->call_state == CONNECTING)
2784 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
2790 show_controls (EmpathyCallWindow *window, gboolean set_fullscreen)
2793 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2795 menu = gtk_ui_manager_get_widget (priv->ui_manager,
2800 gtk_widget_hide (priv->sidebar);
2801 gtk_widget_hide (menu);
2802 gtk_widget_hide (priv->statusbar);
2803 gtk_widget_hide (priv->toolbar);
2807 if (priv->sidebar_was_visible_before_fs)
2808 gtk_widget_show (priv->sidebar);
2810 gtk_widget_show (menu);
2811 gtk_widget_show (priv->statusbar);
2812 gtk_widget_show (priv->toolbar);
2814 gtk_window_resize (GTK_WINDOW (window), priv->original_width_before_fs,
2815 priv->original_height_before_fs);
2820 show_borders (EmpathyCallWindow *window, gboolean set_fullscreen)
2822 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2824 gtk_container_set_border_width (GTK_CONTAINER (priv->content_hbox),
2825 set_fullscreen ? 0 : CONTENT_HBOX_BORDER_WIDTH);
2826 gtk_box_set_spacing (GTK_BOX (priv->content_hbox),
2827 set_fullscreen ? 0 : CONTENT_HBOX_SPACING);
2829 if (priv->video_output != NULL)
2832 gtk_box_set_child_packing (GTK_BOX (priv->content_hbox),
2833 priv->video_output, TRUE, TRUE,
2834 set_fullscreen ? 0 : CONTENT_HBOX_CHILDREN_PACKING_PADDING,
2841 empathy_call_window_state_event_cb (GtkWidget *widget,
2842 GdkEventWindowState *event, EmpathyCallWindow *window)
2844 if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
2846 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2847 gboolean set_fullscreen = event->new_window_state &
2848 GDK_WINDOW_STATE_FULLSCREEN;
2852 gboolean sidebar_was_visible;
2853 GtkAllocation allocation;
2854 gint original_width, original_height;
2856 gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
2857 original_width = allocation.width;
2858 original_height = allocation.height;
2860 g_object_get (priv->sidebar, "visible", &sidebar_was_visible, NULL);
2862 priv->sidebar_was_visible_before_fs = sidebar_was_visible;
2863 priv->original_width_before_fs = original_width;
2864 priv->original_height_before_fs = original_height;
2866 if (priv->video_output_motion_handler_id == 0 &&
2867 priv->video_output != NULL)
2869 priv->video_output_motion_handler_id = g_signal_connect (
2870 G_OBJECT (priv->video_container), "motion-notify-event",
2871 G_CALLBACK (empathy_call_window_video_output_motion_notify),
2877 disconnect_video_output_motion_handler (window);
2880 empathy_call_window_fullscreen_set_fullscreen (priv->fullscreen,
2882 show_controls (window, set_fullscreen);
2883 show_borders (window, set_fullscreen);
2884 gtk_action_set_stock_id (priv->menu_fullscreen,
2885 (set_fullscreen ? "gtk-leave-fullscreen" : "gtk-fullscreen"));
2886 priv->is_fullscreen = set_fullscreen;
2893 empathy_call_window_update_sidebar_buttons (EmpathyCallWindow *window,
2896 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2898 /* Update dialpad button */
2899 g_signal_handlers_block_by_func (priv->dialpad_button,
2900 empathy_call_window_dialpad_cb, window);
2901 gtk_toggle_tool_button_set_active (
2902 GTK_TOGGLE_TOOL_BUTTON (priv->dialpad_button),
2904 g_signal_handlers_unblock_by_func (priv->dialpad_button,
2905 empathy_call_window_dialpad_cb, window);
2907 /* Update sidebar menu */
2908 g_signal_handlers_block_by_func (priv->menu_sidebar,
2909 empathy_call_window_sidebar_cb, window);
2910 gtk_toggle_action_set_active (
2911 GTK_TOGGLE_ACTION (priv->menu_sidebar),
2912 gtk_widget_get_visible (priv->sidebar));
2913 g_signal_handlers_unblock_by_func (priv->menu_sidebar,
2914 empathy_call_window_sidebar_cb, window);
2918 empathy_call_window_show_sidebar (EmpathyCallWindow *window,
2921 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2922 int w, h, sidebar_width, handle_size;
2923 GtkAllocation allocation;
2925 gboolean dialpad_shown;
2927 gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
2928 w = allocation.width;
2929 h = allocation.height;
2931 gtk_widget_style_get (priv->pane, "handle_size", &handle_size, NULL);
2933 gtk_widget_get_preferred_width (priv->sidebar, &sidebar_width, NULL);
2937 gtk_widget_show (priv->sidebar);
2938 w += sidebar_width + handle_size;
2942 w -= sidebar_width + handle_size;
2943 gtk_widget_hide (priv->sidebar);
2947 gtk_window_resize (GTK_WINDOW (window), w, h);
2949 /* Update the 'Dialpad' menu */
2950 page = ev_sidebar_get_current_page (EV_SIDEBAR (priv->sidebar));
2951 dialpad_shown = active && !tp_strdiff (page, "dialpad");
2954 empathy_call_window_update_sidebar_buttons (window, dialpad_shown);
2958 empathy_call_window_set_send_video (EmpathyCallWindow *window,
2961 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2962 TpyCallChannel *call;
2964 priv->sending_video = (state == CAMERA_STATE_ON);
2966 if (state == CAMERA_STATE_ON)
2968 /* When we start sending video, we want to show the video preview by
2970 display_video_preview (window, TRUE);
2974 display_video_preview (window, FALSE);
2977 if (priv->call_state != CONNECTED)
2980 g_object_get (priv->handler, "call-channel", &call, NULL);
2981 DEBUG ("%s sending video", priv->sending_video ? "start": "stop");
2982 tpy_call_channel_send_video (call, priv->sending_video);
2983 g_object_unref (call);
2987 empathy_call_window_mic_toggled_cb (GtkToggleToolButton *toggle,
2988 EmpathyCallWindow *window)
2990 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2993 active = (gtk_toggle_tool_button_get_active (toggle));
2997 empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
2999 gtk_adjustment_set_value (priv->audio_input_adj, priv->volume * 100);
3003 /* TODO, Instead of setting the input volume to 0 we should probably
3004 * stop sending but this would cause the audio call to drop if both
3005 * sides mute at the same time on certain CMs AFAIK. Need to revisit this
3006 * in the future. GNOME #574574
3008 empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
3010 gtk_adjustment_set_value (priv->audio_input_adj, 0);
3015 empathy_call_window_sidebar_hidden_cb (EvSidebar *sidebar,
3016 EmpathyCallWindow *window)
3018 empathy_call_window_show_sidebar (window, FALSE);
3022 empathy_call_window_sidebar_shown_cb (EvSidebar *sidebar,
3023 EmpathyCallWindow *window)
3025 empathy_call_window_show_sidebar (window, TRUE);
3029 empathy_call_window_sidebar_changed_cb (EvSidebar *sidebar,
3031 EmpathyCallWindow *window)
3033 empathy_call_window_update_sidebar_buttons (window,
3034 !tp_strdiff (page, "dialpad"));
3038 empathy_call_window_hangup_cb (gpointer object,
3039 EmpathyCallWindow *window)
3041 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3043 empathy_call_handler_stop_call (priv->handler);
3045 if (empathy_call_window_disconnected (window, FALSE))
3046 gtk_widget_destroy (GTK_WIDGET (window));
3050 empathy_call_window_restart_call (EmpathyCallWindow *window)
3052 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3054 /* Remove error info bars */
3055 gtk_container_forall (GTK_CONTAINER (priv->errors_vbox),
3056 (GtkCallback) gtk_widget_destroy, NULL);
3058 create_video_output_widget (window);
3060 g_signal_connect (G_OBJECT (priv->audio_input_adj), "value-changed",
3061 G_CALLBACK (empathy_call_window_mic_volume_changed_cb), window);
3063 /* While the call was disconnected, the input volume might have changed.
3064 * However, since the audio_input source was destroyed, its volume has not
3065 * been updated during that time. That's why we manually update it here */
3066 empathy_call_window_mic_volume_changed_cb (priv->audio_input_adj, window);
3068 priv->outgoing = TRUE;
3069 empathy_call_window_set_state_connecting (window);
3071 if (priv->pipeline_playing)
3072 start_call (window);
3074 /* call will be started when the pipeline is ready */
3075 priv->start_call_when_playing = TRUE;
3078 empathy_call_window_setup_avatars (window, priv->handler);
3080 gtk_action_set_sensitive (priv->redial, FALSE);
3081 gtk_widget_set_sensitive (priv->redial_button, FALSE);
3085 empathy_call_window_redial_cb (gpointer object,
3086 EmpathyCallWindow *window)
3088 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3090 if (priv->call_state == CONNECTED)
3091 priv->call_state = REDIALING;
3093 empathy_call_handler_stop_call (priv->handler);
3095 if (priv->call_state != CONNECTED)
3096 empathy_call_window_restart_call (window);
3100 empathy_call_window_dialpad_cb (GtkToggleToolButton *button,
3101 EmpathyCallWindow *window)
3103 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3106 active = gtk_toggle_tool_button_get_active (button);
3109 ev_sidebar_set_current_page (EV_SIDEBAR (priv->sidebar), "dialpad");
3111 empathy_call_window_show_sidebar (window, active);
3115 empathy_call_window_sidebar_cb (GtkToggleAction *menu,
3116 EmpathyCallWindow *self)
3118 empathy_call_window_show_sidebar (self,
3119 gtk_toggle_action_get_active (menu));
3123 empathy_call_window_fullscreen_cb (gpointer object,
3124 EmpathyCallWindow *window)
3126 empathy_call_window_fullscreen_toggle (window);
3130 empathy_call_window_fullscreen_toggle (EmpathyCallWindow *window)
3132 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3134 if (priv->is_fullscreen)
3135 gtk_window_unfullscreen (GTK_WINDOW (window));
3137 gtk_window_fullscreen (GTK_WINDOW (window));
3141 empathy_call_window_video_button_press_cb (GtkWidget *video_preview,
3142 GdkEventButton *event, EmpathyCallWindow *window)
3144 if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
3146 empathy_call_window_video_menu_popup (window, event->button);
3154 empathy_call_window_key_press_cb (GtkWidget *video_output,
3155 GdkEventKey *event, EmpathyCallWindow *window)
3157 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3159 if (priv->is_fullscreen && event->keyval == GDK_KEY_Escape)
3161 /* Since we are in fullscreen mode, toggling will bring us back to
3163 empathy_call_window_fullscreen_toggle (window);
3171 empathy_call_window_video_output_motion_notify (GtkWidget *widget,
3172 GdkEventMotion *event, EmpathyCallWindow *window)
3174 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3176 if (priv->is_fullscreen)
3178 empathy_call_window_fullscreen_show_popup (priv->fullscreen);
3185 empathy_call_window_video_menu_popup (EmpathyCallWindow *window,
3189 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3191 menu = gtk_ui_manager_get_widget (priv->ui_manager,
3193 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
3194 button, gtk_get_current_event_time ());
3195 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
3199 empathy_call_window_status_message (EmpathyCallWindow *window,
3202 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3204 if (priv->context_id == 0)
3206 priv->context_id = gtk_statusbar_get_context_id (
3207 GTK_STATUSBAR (priv->statusbar), "voip call status messages");
3211 gtk_statusbar_pop (GTK_STATUSBAR (priv->statusbar), priv->context_id);
3214 gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar), priv->context_id,
3219 empathy_call_window_volume_changed_cb (GtkScaleButton *button,
3220 gdouble value, EmpathyCallWindow *window)
3222 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3224 if (priv->audio_output == NULL)
3227 empathy_audio_sink_set_volume (EMPATHY_GST_AUDIO_SINK (priv->audio_output),