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 #define SMALL_TOOLBAR_SIZE 36
79 /* If an video input error occurs, the error message will start with "v4l" */
80 #define VIDEO_INPUT_ERROR_PREFIX "v4l"
82 /* The time interval in milliseconds between 2 outgoing rings */
83 #define MS_BETWEEN_RING 500
85 G_DEFINE_TYPE(EmpathyCallWindow, empathy_call_window, GTK_TYPE_WINDOW)
88 PROP_CALL_HANDLER = 1,
100 CAMERA_STATE_OFF = 0,
104 struct _EmpathyCallWindowPriv
106 gboolean dispose_has_run;
107 EmpathyCallHandler *handler;
109 EmpathyContact *contact;
111 EmpathyCameraMonitor *camera_monitor;
116 GtkUIManager *ui_manager;
117 GtkWidget *errors_vbox;
118 /* widget displays the video received from the remote user. This widget is
119 * alive only during call. */
120 ClutterActor *video_output;
121 ClutterActor *video_preview;
122 ClutterActor *preview_hidden_button;
123 GtkWidget *video_container;
124 GtkWidget *remote_user_avatar_widget;
125 GtkWidget *remote_user_avatar_toolbar;
127 GtkWidget *volume_item;
128 GtkWidget *status_label;
129 GtkWidget *redial_button;
130 GtkWidget *mic_button;
131 GtkWidget *camera_button;
132 GtkWidget *dialpad_button;
134 GtkWidget *bottom_toolbar;
137 GtkAction *menu_sidebar;
138 GtkAction *menu_fullscreen;
140 /* The box that contains self and remote avatar and video
141 input/output. When we redial, we destroy and re-create the box */
142 ClutterActor *video_box;
143 ClutterLayoutManager *video_layout;
145 /* We keep a reference on the hbox which contains the main content so we can
146 easilly repack everything when toggling fullscreen */
147 GtkWidget *content_hbox;
149 gulong video_output_motion_handler_id;
150 guint bus_message_source_id;
153 GtkWidget *volume_scale;
154 GtkWidget *volume_progress_bar;
155 GtkAdjustment *audio_input_adj;
157 GtkWidget *dtmf_panel;
160 GtkWidget *details_vbox;
161 GtkWidget *vcodec_encoding_label;
162 GtkWidget *acodec_encoding_label;
163 GtkWidget *vcodec_decoding_label;
164 GtkWidget *acodec_decoding_label;
166 GtkWidget *audio_remote_candidate_label;
167 GtkWidget *audio_local_candidate_label;
168 GtkWidget *video_remote_candidate_label;
169 GtkWidget *video_local_candidate_label;
170 GtkWidget *video_remote_candidate_info_img;
171 GtkWidget *video_local_candidate_info_img;
172 GtkWidget *audio_remote_candidate_info_img;
173 GtkWidget *audio_local_candidate_info_img;
175 GstElement *video_input;
176 GstElement *video_preview_sink;
177 GstElement *video_output_sink;
178 GstElement *audio_input;
179 GstElement *audio_output;
180 GstElement *pipeline;
181 GstElement *video_tee;
190 GtkWidget *video_contrast;
191 GtkWidget *video_brightness;
192 GtkWidget *video_gamma;
195 gboolean call_started;
196 gboolean sending_video;
197 CameraState camera_state;
199 EmpathyCallWindowFullscreen *fullscreen;
200 gboolean is_fullscreen;
205 /* Those fields represent the state of the window before it actually was in
207 gboolean sidebar_was_visible_before_fs;
208 gint original_width_before_fs;
209 gint original_height_before_fs;
211 gint x, y, w, h, sidebar_width;
214 /* TRUE if the call should be started when the pipeline is playing */
215 gboolean start_call_when_playing;
216 /* TRUE if we requested to set the pipeline in the playing state */
217 gboolean pipeline_playing;
219 EmpathySoundManager *sound_mgr;
222 #define GET_PRIV(o) (EMPATHY_CALL_WINDOW (o)->priv)
224 static void empathy_call_window_realized_cb (GtkWidget *widget,
225 EmpathyCallWindow *window);
227 static gboolean empathy_call_window_delete_cb (GtkWidget *widget,
228 GdkEvent *event, EmpathyCallWindow *window);
230 static gboolean empathy_call_window_state_event_cb (GtkWidget *widget,
231 GdkEventWindowState *event, EmpathyCallWindow *window);
233 static void empathy_call_window_set_send_video (EmpathyCallWindow *window,
236 static void empathy_call_window_mic_toggled_cb (
237 GtkToggleToolButton *toggle, EmpathyCallWindow *window);
239 static void empathy_call_window_sidebar_cb (GtkToggleAction *menu,
240 EmpathyCallWindow *self);
242 static void empathy_call_window_sidebar_hidden_cb (EvSidebar *sidebar,
243 EmpathyCallWindow *window);
245 static void empathy_call_window_sidebar_shown_cb (EvSidebar *sidebar,
246 EmpathyCallWindow *window);
248 static void empathy_call_window_sidebar_changed_cb (EvSidebar *sidebar,
250 EmpathyCallWindow *window);
252 static void empathy_call_window_hangup_cb (gpointer object,
253 EmpathyCallWindow *window);
255 static void empathy_call_window_fullscreen_cb (gpointer object,
256 EmpathyCallWindow *window);
258 static void empathy_call_window_fullscreen_toggle (EmpathyCallWindow *window);
260 static gboolean empathy_call_window_video_button_press_cb (
261 GtkWidget *video_output, GdkEventButton *event, EmpathyCallWindow *window);
263 static gboolean empathy_call_window_key_press_cb (GtkWidget *video_output,
264 GdkEventKey *event, EmpathyCallWindow *window);
266 static gboolean empathy_call_window_video_output_motion_notify (
267 GtkWidget *widget, GdkEventMotion *event, EmpathyCallWindow *window);
269 static void empathy_call_window_video_menu_popup (EmpathyCallWindow *window,
272 static void empathy_call_window_redial_cb (gpointer object,
273 EmpathyCallWindow *window);
275 static void empathy_call_window_dialpad_cb (GtkToggleToolButton *button,
276 EmpathyCallWindow *window);
278 static void empathy_call_window_restart_call (EmpathyCallWindow *window);
280 static void empathy_call_window_status_message (EmpathyCallWindow *window,
283 static gboolean empathy_call_window_bus_message (GstBus *bus,
284 GstMessage *message, gpointer user_data);
287 empathy_call_window_volume_changed_cb (GtkScaleButton *button,
288 gdouble value, EmpathyCallWindow *window);
291 empathy_call_window_setup_toolbars (EmpathyCallWindow *self)
293 EmpathyCallWindowPriv *priv = GET_PRIV (self);
294 GtkWidget *volume_button;
295 GtkToolItem *tool_item;
297 /* Add an empty expanded GtkToolItem to the top toolbar */
298 tool_item = gtk_tool_item_new ();
299 gtk_tool_item_set_expand (tool_item, TRUE);
300 gtk_widget_show (GTK_WIDGET (tool_item));
301 gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), tool_item, 0);
303 /* Set the remote avatar */
304 tool_item = gtk_tool_item_new ();
305 priv->remote_user_avatar_toolbar = gtk_image_new ();
306 gtk_container_add (GTK_CONTAINER (tool_item),
307 priv->remote_user_avatar_toolbar);
308 gtk_widget_show_all (GTK_WIDGET (tool_item));
309 gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), tool_item, 0);
311 /* Set the volume button */
312 volume_button = gtk_volume_button_new ();
313 /* FIXME listen to the audiosinks signals and update the button according to
314 * that, for now starting out at 1.0 and assuming only the app changes the
316 gtk_scale_button_set_value (GTK_SCALE_BUTTON (volume_button), 1.0);
317 g_signal_connect (G_OBJECT (volume_button), "value-changed",
318 G_CALLBACK (empathy_call_window_volume_changed_cb), self);
320 gtk_container_add (GTK_CONTAINER (priv->volume_item),
322 gtk_widget_show (GTK_WIDGET (volume_button));
324 /* Add an empty expanded GtkToolItem so the label is at the end */
325 tool_item = gtk_tool_item_new ();
326 gtk_tool_item_set_expand (tool_item, TRUE);
327 gtk_widget_show (GTK_WIDGET (tool_item));
328 gtk_toolbar_insert (GTK_TOOLBAR (priv->bottom_toolbar), tool_item, -1);
330 /* Set the status label */
331 tool_item = gtk_tool_item_new ();
332 priv->status_label = gtk_label_new (NULL);
333 gtk_container_add (GTK_CONTAINER (tool_item),
335 gtk_widget_show_all (GTK_WIDGET (tool_item));
336 gtk_toolbar_insert (GTK_TOOLBAR (priv->bottom_toolbar), tool_item, -1);
340 dtmf_button_pressed_cb (GtkButton *button, EmpathyCallWindow *window)
342 EmpathyCallWindowPriv *priv = GET_PRIV (window);
343 TpyCallChannel *call;
347 g_object_get (priv->handler, "call-channel", &call, NULL);
349 button_quark = g_quark_from_static_string (EMPATHY_DTMF_BUTTON_ID);
350 event = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (button),
353 tpy_call_channel_dtmf_start_tone (call, event);
355 g_object_unref (call);
359 dtmf_button_released_cb (GtkButton *button, EmpathyCallWindow *window)
361 EmpathyCallWindowPriv *priv = GET_PRIV (window);
362 TpyCallChannel *call;
364 g_object_get (priv->handler, "call-channel", &call, NULL);
366 tpy_call_channel_dtmf_stop_tone (call);
368 g_object_unref (call);
372 empathy_call_window_create_video_input_add_slider (EmpathyCallWindow *self,
373 gchar *label_text, GtkWidget *bin)
375 GtkWidget *vbox = gtk_vbox_new (FALSE, 2);
376 GtkWidget *scale = gtk_vscale_new_with_range (0, 100, 10);
377 GtkWidget *label = gtk_label_new (label_text);
379 gtk_widget_set_sensitive (scale, FALSE);
381 gtk_container_add (GTK_CONTAINER (bin), vbox);
383 gtk_range_set_inverted (GTK_RANGE (scale), TRUE);
384 gtk_box_pack_start (GTK_BOX (vbox), scale, TRUE, TRUE, 0);
385 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
391 empathy_call_window_video_contrast_changed_cb (GtkAdjustment *adj,
392 EmpathyCallWindow *self)
395 EmpathyCallWindowPriv *priv = GET_PRIV (self);
397 empathy_video_src_set_channel (priv->video_input,
398 EMPATHY_GST_VIDEO_SRC_CHANNEL_CONTRAST, gtk_adjustment_get_value (adj));
402 empathy_call_window_video_brightness_changed_cb (GtkAdjustment *adj,
403 EmpathyCallWindow *self)
406 EmpathyCallWindowPriv *priv = GET_PRIV (self);
408 empathy_video_src_set_channel (priv->video_input,
409 EMPATHY_GST_VIDEO_SRC_CHANNEL_BRIGHTNESS, gtk_adjustment_get_value (adj));
413 empathy_call_window_video_gamma_changed_cb (GtkAdjustment *adj,
414 EmpathyCallWindow *self)
417 EmpathyCallWindowPriv *priv = GET_PRIV (self);
419 empathy_video_src_set_channel (priv->video_input,
420 EMPATHY_GST_VIDEO_SRC_CHANNEL_GAMMA, gtk_adjustment_get_value (adj));
425 empathy_call_window_create_video_input (EmpathyCallWindow *self)
427 EmpathyCallWindowPriv *priv = GET_PRIV (self);
430 hbox = gtk_hbox_new (TRUE, 3);
432 priv->video_contrast = empathy_call_window_create_video_input_add_slider (
433 self, _("Contrast"), hbox);
435 priv->video_brightness = empathy_call_window_create_video_input_add_slider (
436 self, _("Brightness"), hbox);
438 priv->video_gamma = empathy_call_window_create_video_input_add_slider (
439 self, _("Gamma"), hbox);
445 empathy_call_window_setup_video_input (EmpathyCallWindow *self)
447 EmpathyCallWindowPriv *priv = GET_PRIV (self);
451 supported = empathy_video_src_get_supported_channels (priv->video_input);
453 if (supported & EMPATHY_GST_VIDEO_SRC_SUPPORTS_CONTRAST)
455 adj = gtk_range_get_adjustment (GTK_RANGE (priv->video_contrast));
457 gtk_adjustment_set_value (adj,
458 empathy_video_src_get_channel (priv->video_input,
459 EMPATHY_GST_VIDEO_SRC_CHANNEL_CONTRAST));
461 g_signal_connect (G_OBJECT (adj), "value-changed",
462 G_CALLBACK (empathy_call_window_video_contrast_changed_cb), self);
464 gtk_widget_set_sensitive (priv->video_contrast, TRUE);
467 if (supported & EMPATHY_GST_VIDEO_SRC_SUPPORTS_BRIGHTNESS)
469 adj = gtk_range_get_adjustment (GTK_RANGE (priv->video_brightness));
471 gtk_adjustment_set_value (adj,
472 empathy_video_src_get_channel (priv->video_input,
473 EMPATHY_GST_VIDEO_SRC_CHANNEL_BRIGHTNESS));
475 g_signal_connect (G_OBJECT (adj), "value-changed",
476 G_CALLBACK (empathy_call_window_video_brightness_changed_cb), self);
477 gtk_widget_set_sensitive (priv->video_brightness, TRUE);
480 if (supported & EMPATHY_GST_VIDEO_SRC_SUPPORTS_GAMMA)
482 adj = gtk_range_get_adjustment (GTK_RANGE (priv->video_gamma));
484 gtk_adjustment_set_value (adj,
485 empathy_video_src_get_channel (priv->video_input,
486 EMPATHY_GST_VIDEO_SRC_CHANNEL_GAMMA));
488 g_signal_connect (G_OBJECT (adj), "value-changed",
489 G_CALLBACK (empathy_call_window_video_gamma_changed_cb), self);
490 gtk_widget_set_sensitive (priv->video_gamma, TRUE);
495 empathy_call_window_mic_volume_changed_cb (GtkAdjustment *adj,
496 EmpathyCallWindow *self)
498 EmpathyCallWindowPriv *priv = GET_PRIV (self);
501 volume = gtk_adjustment_get_value (adj)/100.0;
503 /* Don't store the volume because of muting */
504 if (volume > 0 || gtk_toggle_tool_button_get_active (
505 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
506 priv->volume = volume;
508 /* Ensure that the toggle button is active if the volume is > 0 and inactive
509 * if it's smaller than 0 */
510 if ((volume > 0) != gtk_toggle_tool_button_get_active (
511 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
512 gtk_toggle_tool_button_set_active (
513 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button), volume > 0);
515 empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
520 empathy_call_window_audio_input_level_changed_cb (EmpathyGstAudioSrc *src,
521 gdouble level, EmpathyCallWindow *window)
524 EmpathyCallWindowPriv *priv = GET_PRIV (window);
526 value = CLAMP (pow (10, level / 20), 0.0, 1.0);
527 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->volume_progress_bar),
532 empathy_call_window_create_audio_input (EmpathyCallWindow *self)
534 EmpathyCallWindowPriv *priv = GET_PRIV (self);
535 GtkWidget *hbox, *vbox, *label;
537 hbox = gtk_hbox_new (TRUE, 3);
539 vbox = gtk_vbox_new (FALSE, 3);
540 gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 3);
542 priv->volume_scale = gtk_vscale_new_with_range (0, 150, 100);
543 gtk_range_set_inverted (GTK_RANGE (priv->volume_scale), TRUE);
544 label = gtk_label_new (_("Volume"));
546 priv->audio_input_adj = gtk_range_get_adjustment (
547 GTK_RANGE (priv->volume_scale));
548 priv->volume = empathy_audio_src_get_volume (EMPATHY_GST_AUDIO_SRC
549 (priv->audio_input));
550 gtk_adjustment_set_value (priv->audio_input_adj, priv->volume * 100);
552 g_signal_connect (G_OBJECT (priv->audio_input_adj), "value-changed",
553 G_CALLBACK (empathy_call_window_mic_volume_changed_cb), self);
555 gtk_box_pack_start (GTK_BOX (vbox), priv->volume_scale, TRUE, TRUE, 3);
556 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 3);
558 priv->volume_progress_bar = gtk_progress_bar_new ();
560 gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->volume_progress_bar),
561 GTK_ORIENTATION_VERTICAL);
563 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->volume_progress_bar),
566 gtk_box_pack_start (GTK_BOX (hbox), priv->volume_progress_bar, FALSE, FALSE,
573 empathy_call_window_show_video_output (EmpathyCallWindow *self,
576 if (self->priv->video_output != NULL)
577 g_object_set (self->priv->video_output, "visible", show, NULL);
579 gtk_widget_set_visible (self->priv->remote_user_avatar_widget, !show);
583 create_video_output_widget (EmpathyCallWindow *self)
585 EmpathyCallWindowPriv *priv = GET_PRIV (self);
587 g_assert (priv->video_output == NULL);
588 g_assert (priv->pipeline != NULL);
590 priv->video_output = clutter_texture_new ();
592 clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (priv->video_output),
595 priv->video_output_sink = clutter_gst_video_sink_new (
596 CLUTTER_TEXTURE (priv->video_output));
598 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_box),
601 gtk_widget_add_events (priv->video_container,
602 GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK);
603 g_signal_connect (G_OBJECT (priv->video_container), "button-press-event",
604 G_CALLBACK (empathy_call_window_video_button_press_cb), self);
608 create_video_input (EmpathyCallWindow *self)
610 EmpathyCallWindowPriv *priv = GET_PRIV (self);
612 g_assert (priv->video_input == NULL);
613 priv->video_input = empathy_video_src_new ();
614 gst_object_ref (priv->video_input);
615 gst_object_sink (priv->video_input);
619 create_audio_input (EmpathyCallWindow *self)
621 EmpathyCallWindowPriv *priv = GET_PRIV (self);
623 g_assert (priv->audio_input == NULL);
624 priv->audio_input = empathy_audio_src_new ();
625 gst_object_ref (priv->audio_input);
626 gst_object_sink (priv->audio_input);
628 tp_g_signal_connect_object (priv->audio_input, "peak-level-changed",
629 G_CALLBACK (empathy_call_window_audio_input_level_changed_cb),
634 add_video_preview_to_pipeline (EmpathyCallWindow *self)
636 EmpathyCallWindowPriv *priv = GET_PRIV (self);
639 g_assert (priv->video_preview != NULL);
640 g_assert (priv->pipeline != NULL);
641 g_assert (priv->video_input != NULL);
642 g_assert (priv->video_tee != NULL);
644 preview = priv->video_preview_sink;
646 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->video_input))
648 g_warning ("Could not add video input to pipeline");
652 if (!gst_bin_add (GST_BIN (priv->pipeline), preview))
654 g_warning ("Could not add video preview to pipeline");
658 if (!gst_element_link (priv->video_input, priv->video_tee))
660 g_warning ("Could not link video input to video tee");
664 if (!gst_element_link (priv->video_tee, preview))
666 g_warning ("Could not link video tee to video preview");
672 empathy_call_window_disable_camera_cb (GtkAction *action,
673 EmpathyCallWindow *self)
675 clutter_actor_destroy (self->priv->preview_hidden_button);
677 gtk_toggle_tool_button_set_active (
678 GTK_TOGGLE_TOOL_BUTTON (self->priv->camera_button), FALSE);
682 empathy_call_window_minimise_camera_cb (GtkAction *action,
683 EmpathyCallWindow *self)
685 clutter_actor_hide (self->priv->video_preview);
686 clutter_actor_show (self->priv->preview_hidden_button);
690 empathy_call_window_maximise_camera_cb (GtkAction *action,
691 EmpathyCallWindow *self)
693 clutter_actor_show (self->priv->video_preview);
694 clutter_actor_hide (self->priv->preview_hidden_button);
698 empathy_call_window_preview_button_clicked_cb (GtkButton *button,
699 EmpathyCallWindow *self)
703 menu = gtk_ui_manager_get_widget (self->priv->ui_manager,
705 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
706 0, gtk_get_current_event_time ());
707 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
711 empathy_call_window_preview_hidden_button_clicked_cb (GtkButton *button,
712 EmpathyCallWindow *self)
716 menu = gtk_ui_manager_get_widget (self->priv->ui_manager,
717 "/preview-hidden-menu");
718 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
719 0, gtk_get_current_event_time ());
720 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
724 create_video_preview (EmpathyCallWindow *self)
726 EmpathyCallWindowPriv *priv = GET_PRIV (self);
727 ClutterLayoutManager *layout, *layout_center;
728 ClutterActor *preview;
733 g_assert (priv->video_preview == NULL);
735 preview = clutter_texture_new ();
736 clutter_actor_set_size (preview,
737 SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGTH);
738 priv->video_preview_sink = clutter_gst_video_sink_new (
739 CLUTTER_TEXTURE (preview));
741 /* Flip the video preview */
742 clutter_actor_set_rotation (preview,
745 SELF_VIDEO_SECTION_WIDTH * 0.5,
749 /* Add a little offset to the video preview */
750 layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_END,
751 CLUTTER_BIN_ALIGNMENT_START);
752 priv->video_preview = clutter_box_new (layout);
753 clutter_actor_set_size (priv->video_preview,
754 SELF_VIDEO_SECTION_WIDTH + 10, SELF_VIDEO_SECTION_HEIGTH + 10);
756 layout_center = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
757 CLUTTER_BIN_ALIGNMENT_CENTER);
758 box = clutter_box_new (layout_center);
759 clutter_actor_set_size (box,
760 SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGTH);
762 clutter_container_add_actor (CLUTTER_CONTAINER (box), preview);
763 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_preview), box);
765 g_object_set (priv->video_preview_sink,
770 /* Translators: this is an "Info" label. It should be as short
772 button = gtk_button_new_with_label (_("i"));
773 b = gtk_clutter_actor_new_with_contents (button);
775 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (layout_center),
777 CLUTTER_BIN_ALIGNMENT_END,
778 CLUTTER_BIN_ALIGNMENT_END);
780 g_signal_connect (button, "clicked",
781 G_CALLBACK (empathy_call_window_preview_button_clicked_cb),
784 /* Translators: this is an "Info" label. It should be as short
786 button = gtk_button_new_with_label (_("i"));
787 priv->preview_hidden_button =
788 gtk_clutter_actor_new_with_contents (button);
790 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
791 priv->preview_hidden_button,
792 CLUTTER_BIN_ALIGNMENT_START,
793 CLUTTER_BIN_ALIGNMENT_END);
795 clutter_actor_hide (priv->preview_hidden_button);
797 g_signal_connect (button, "clicked",
798 G_CALLBACK (empathy_call_window_preview_hidden_button_clicked_cb),
801 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
803 CLUTTER_BIN_ALIGNMENT_START,
804 CLUTTER_BIN_ALIGNMENT_END);
808 play_camera (EmpathyCallWindow *window,
811 EmpathyCallWindowPriv *priv = GET_PRIV (window);
815 if (priv->video_preview == NULL)
817 create_video_preview (window);
818 add_video_preview_to_pipeline (window);
822 state = GST_STATE_PLAYING;
824 state = GST_STATE_NULL;
826 preview = priv->video_preview_sink;
828 gst_element_set_state (preview, state);
829 gst_element_set_state (priv->video_input, state);
830 gst_element_set_state (priv->video_tee, state);
834 display_video_preview (EmpathyCallWindow *self,
837 EmpathyCallWindowPriv *priv = GET_PRIV (self);
841 /* Display the video preview */
842 DEBUG ("Show video preview");
844 play_camera (self, TRUE);
845 clutter_actor_show (priv->video_preview);
849 /* Hide the video preview */
850 DEBUG ("Hide video preview");
852 if (priv->video_preview != NULL)
854 clutter_actor_hide (priv->video_preview);
855 play_camera (self, FALSE);
861 empathy_call_window_set_state_connecting (EmpathyCallWindow *window)
863 EmpathyCallWindowPriv *priv = GET_PRIV (window);
865 empathy_call_window_status_message (window, _("Connecting…"));
866 priv->call_state = CONNECTING;
869 empathy_sound_manager_start_playing (priv->sound_mgr, GTK_WIDGET (window),
870 EMPATHY_SOUND_PHONE_OUTGOING, MS_BETWEEN_RING);
874 disable_camera (EmpathyCallWindow *self)
876 EmpathyCallWindowPriv *priv = GET_PRIV (self);
878 if (priv->camera_state == CAMERA_STATE_OFF)
881 DEBUG ("Disable camera");
883 display_video_preview (self, FALSE);
885 if (priv->camera_state == CAMERA_STATE_ON)
886 empathy_call_window_set_send_video (self, CAMERA_STATE_OFF);
888 priv->camera_state = CAMERA_STATE_OFF;
892 enable_camera (EmpathyCallWindow *self)
894 EmpathyCallWindowPriv *priv = GET_PRIV (self);
896 if (priv->camera_state == CAMERA_STATE_ON)
899 if (priv->video_input == NULL)
901 DEBUG ("Can't enable camera, no input");
905 DEBUG ("Enable camera");
907 empathy_call_window_set_send_video (self, CAMERA_STATE_ON);
909 priv->camera_state = CAMERA_STATE_ON;
913 empathy_call_window_camera_toggled_cb (GtkToggleToolButton *toggle,
914 EmpathyCallWindow *self)
916 if (gtk_toggle_tool_button_get_active (toggle))
917 enable_camera (self);
919 disable_camera (self);
923 create_pipeline (EmpathyCallWindow *self)
925 EmpathyCallWindowPriv *priv = GET_PRIV (self);
928 g_assert (priv->pipeline == NULL);
930 priv->pipeline = gst_pipeline_new (NULL);
931 priv->pipeline_playing = FALSE;
933 priv->video_tee = gst_element_factory_make ("tee", NULL);
934 gst_object_ref (priv->video_tee);
935 gst_object_sink (priv->video_tee);
937 gst_bin_add (GST_BIN (priv->pipeline), priv->video_tee);
939 bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
940 priv->bus_message_source_id = gst_bus_add_watch (bus,
941 empathy_call_window_bus_message, self);
943 g_object_unref (bus);
947 empathy_call_window_configure_event_cb (GtkWidget *widget,
949 EmpathyCallWindow *self)
951 GdkWindow *gdk_window;
952 GdkWindowState window_state;
954 gtk_window_get_position (GTK_WINDOW (self), &self->priv->x, &self->priv->y);
955 gtk_window_get_size (GTK_WINDOW (self), &self->priv->w, &self->priv->h);
957 gtk_widget_get_preferred_width (self->priv->sidebar,
958 &self->priv->sidebar_width, NULL);
960 gdk_window = gtk_widget_get_window (widget);
961 window_state = gdk_window_get_state (gdk_window);
962 self->priv->maximized = (window_state & GDK_WINDOW_STATE_MAXIMIZED);
968 empathy_call_window_destroyed_cb (GtkWidget *object,
969 EmpathyCallWindow *self)
971 if (gtk_widget_get_visible (self->priv->sidebar))
973 /* Save the geometry as if the sidebar was hidden. */
974 empathy_geometry_save_values (GTK_WINDOW (self),
975 self->priv->x, self->priv->y,
976 self->priv->w - self->priv->sidebar_width, self->priv->h,
977 self->priv->maximized);
982 empathy_call_window_init (EmpathyCallWindow *self)
984 EmpathyCallWindowPriv *priv;
990 ClutterConstraint *size_constraint;
991 ClutterActor *remote_avatar;
992 GtkStyleContext *context;
996 priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
997 EMPATHY_TYPE_CALL_WINDOW, EmpathyCallWindowPriv);
999 filename = empathy_file_lookup ("empathy-call-window.ui", "src");
1000 gui = empathy_builder_get_file (filename,
1001 "call_window_vbox", &top_vbox,
1002 "errors_vbox", &priv->errors_vbox,
1003 "pane", &priv->pane,
1004 "redial", &priv->redial_button,
1005 "volume", &priv->volume_item,
1006 "microphone", &priv->mic_button,
1007 "camera", &priv->camera_button,
1008 "dialpad", &priv->dialpad_button,
1009 "toolbar", &priv->toolbar,
1010 "bottom_toolbar", &priv->bottom_toolbar,
1011 "menuredial", &priv->redial,
1012 "menusidebar", &priv->menu_sidebar,
1013 "ui_manager", &priv->ui_manager,
1014 "menufullscreen", &priv->menu_fullscreen,
1015 "details_vbox", &priv->details_vbox,
1016 "vcodec_encoding_label", &priv->vcodec_encoding_label,
1017 "acodec_encoding_label", &priv->acodec_encoding_label,
1018 "acodec_decoding_label", &priv->acodec_decoding_label,
1019 "vcodec_decoding_label", &priv->vcodec_decoding_label,
1020 "audio_remote_candidate_label", &priv->audio_remote_candidate_label,
1021 "audio_local_candidate_label", &priv->audio_local_candidate_label,
1022 "video_remote_candidate_label", &priv->video_remote_candidate_label,
1023 "video_local_candidate_label", &priv->video_local_candidate_label,
1024 "video_remote_candidate_info_img", &priv->video_remote_candidate_info_img,
1025 "video_local_candidate_info_img", &priv->video_local_candidate_info_img,
1026 "audio_remote_candidate_info_img", &priv->audio_remote_candidate_info_img,
1027 "audio_local_candidate_info_img", &priv->audio_local_candidate_info_img,
1031 empathy_builder_connect (gui, self,
1032 "menuhangup", "activate", empathy_call_window_hangup_cb,
1033 "hangup", "clicked", empathy_call_window_hangup_cb,
1034 "menuredial", "activate", empathy_call_window_redial_cb,
1035 "redial", "clicked", empathy_call_window_redial_cb,
1036 "menusidebar", "toggled", empathy_call_window_sidebar_cb,
1037 "microphone", "toggled", empathy_call_window_mic_toggled_cb,
1038 "camera", "toggled", empathy_call_window_camera_toggled_cb,
1039 "dialpad", "toggled", empathy_call_window_dialpad_cb,
1040 "menufullscreen", "activate", empathy_call_window_fullscreen_cb,
1041 "menupreviewdisable", "activate", empathy_call_window_disable_camera_cb,
1042 "menupreviewminimise", "activate", empathy_call_window_minimise_camera_cb,
1043 "menupreviewmaximise", "activate", empathy_call_window_maximise_camera_cb,
1046 gtk_action_set_sensitive (priv->menu_fullscreen, FALSE);
1048 priv->camera_monitor = empathy_camera_monitor_dup_singleton ();
1050 g_object_bind_property (priv->camera_monitor, "available",
1051 priv->camera_button, "sensitive",
1052 G_BINDING_SYNC_CREATE);
1054 priv->lock = g_mutex_new ();
1056 gtk_container_add (GTK_CONTAINER (self), top_vbox);
1058 priv->content_hbox = gtk_hbox_new (FALSE, CONTENT_HBOX_SPACING);
1059 gtk_container_set_border_width (GTK_CONTAINER (priv->content_hbox),
1060 CONTENT_HBOX_BORDER_WIDTH);
1061 gtk_paned_pack1 (GTK_PANED (priv->pane), priv->content_hbox, TRUE, FALSE);
1063 /* avatar/video box */
1064 priv->video_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
1065 CLUTTER_BIN_ALIGNMENT_CENTER);
1067 priv->video_box = clutter_box_new (priv->video_layout);
1069 priv->video_container = gtk_clutter_embed_new ();
1071 /* Set the background color to that of the rest of the window */
1072 context = gtk_widget_get_style_context (priv->content_hbox);
1073 gtk_style_context_get_background_color (context,
1074 GTK_STATE_FLAG_NORMAL, &rgba);
1075 bg.red = CLAMP (rgba.red * 255.0, 0, 255);
1076 bg.green = CLAMP (rgba.green * 255.0, 0, 255);
1077 bg.blue = CLAMP (rgba.blue * 255.0, 0, 255);
1078 bg.alpha = CLAMP (rgba.alpha * 255.0, 0, 255);
1079 clutter_stage_set_color (
1080 CLUTTER_STAGE (gtk_clutter_embed_get_stage (
1081 GTK_CLUTTER_EMBED (priv->video_container))),
1084 clutter_container_add (
1085 CLUTTER_CONTAINER (gtk_clutter_embed_get_stage (
1086 GTK_CLUTTER_EMBED (priv->video_container))),
1090 size_constraint = clutter_bind_constraint_new (
1091 gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->video_container)),
1092 CLUTTER_BIND_SIZE, 0);
1093 clutter_actor_add_constraint (priv->video_box, size_constraint);
1095 priv->remote_user_avatar_widget = gtk_image_new ();
1096 remote_avatar = gtk_clutter_actor_new_with_contents (
1097 priv->remote_user_avatar_widget);
1099 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_box),
1102 gtk_box_pack_start (GTK_BOX (priv->content_hbox),
1103 priv->video_container, TRUE, TRUE,
1104 CONTENT_HBOX_CHILDREN_PACKING_PADDING);
1106 create_pipeline (self);
1107 create_video_output_widget (self);
1108 create_audio_input (self);
1109 create_video_input (self);
1111 /* The call will be started as soon the pipeline is playing */
1112 priv->start_call_when_playing = TRUE;
1114 empathy_call_window_setup_toolbars (self);
1116 priv->sidebar = ev_sidebar_new ();
1117 g_signal_connect (G_OBJECT (priv->sidebar),
1118 "hide", G_CALLBACK (empathy_call_window_sidebar_hidden_cb), self);
1119 g_signal_connect (G_OBJECT (priv->sidebar),
1120 "show", G_CALLBACK (empathy_call_window_sidebar_shown_cb), self);
1121 g_signal_connect (G_OBJECT (priv->sidebar), "changed",
1122 G_CALLBACK (empathy_call_window_sidebar_changed_cb), self);
1123 gtk_paned_pack2 (GTK_PANED (priv->pane), priv->sidebar, FALSE, FALSE);
1125 page = empathy_call_window_create_audio_input (self);
1126 ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "audio-input",
1127 _("Audio input"), page);
1129 page = empathy_call_window_create_video_input (self);
1130 ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "video-input",
1131 _("Video input"), page);
1133 priv->dtmf_panel = empathy_create_dtmf_dialpad (G_OBJECT (self),
1134 G_CALLBACK (dtmf_button_pressed_cb),
1135 G_CALLBACK (dtmf_button_released_cb));
1136 ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "dialpad",
1137 _("Dialpad"), priv->dtmf_panel);
1139 gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
1141 /* Put the details vbox in a scroll window as it can require a lot of
1142 * horizontal space. */
1143 scroll = gtk_scrolled_window_new (NULL, NULL);
1144 gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll),
1145 priv->details_vbox);
1147 ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "details", _("Details"),
1150 gtk_widget_show_all (top_vbox);
1152 gtk_widget_hide (priv->sidebar);
1154 priv->fullscreen = empathy_call_window_fullscreen_new (self);
1156 empathy_call_window_fullscreen_set_video_widget (priv->fullscreen,
1157 priv->video_container);
1159 g_signal_connect (G_OBJECT (priv->fullscreen->leave_fullscreen_button),
1160 "clicked", G_CALLBACK (empathy_call_window_fullscreen_cb), self);
1162 g_signal_connect (G_OBJECT (self), "realize",
1163 G_CALLBACK (empathy_call_window_realized_cb), self);
1165 g_signal_connect (G_OBJECT (self), "delete-event",
1166 G_CALLBACK (empathy_call_window_delete_cb), self);
1168 g_signal_connect (G_OBJECT (self), "window-state-event",
1169 G_CALLBACK (empathy_call_window_state_event_cb), self);
1171 g_signal_connect (G_OBJECT (self), "key-press-event",
1172 G_CALLBACK (empathy_call_window_key_press_cb), self);
1174 priv->timer = g_timer_new ();
1176 g_object_ref (priv->ui_manager);
1177 g_object_unref (gui);
1179 priv->sound_mgr = empathy_sound_manager_dup_singleton ();
1181 empathy_geometry_bind (GTK_WINDOW (self), "call-window");
1182 /* These signals are used to track the window position and save it
1183 * when the window is destroyed. We need to do this as we don't want
1184 * the window geometry to be saved with the sidebar taken into account. */
1185 g_signal_connect (self, "destroy",
1186 G_CALLBACK (empathy_call_window_destroyed_cb), self);
1187 g_signal_connect (self, "configure-event",
1188 G_CALLBACK (empathy_call_window_configure_event_cb), self);
1189 g_signal_connect (self, "window-state-event",
1190 G_CALLBACK (empathy_call_window_configure_event_cb), self);
1193 /* Instead of specifying a width and a height, we specify only one size. That's
1194 because we want a square avatar icon. */
1196 init_contact_avatar_with_size (EmpathyContact *contact,
1197 GtkWidget *image_widget,
1200 GdkPixbuf *pixbuf_avatar = NULL;
1202 if (contact != NULL)
1204 pixbuf_avatar = empathy_pixbuf_avatar_from_contact_scaled (contact,
1208 if (pixbuf_avatar == NULL)
1210 pixbuf_avatar = empathy_pixbuf_from_icon_name_sized (
1211 EMPATHY_IMAGE_AVATAR_DEFAULT, size);
1214 gtk_image_set_from_pixbuf (GTK_IMAGE (image_widget), pixbuf_avatar);
1216 if (pixbuf_avatar != NULL)
1217 g_object_unref (pixbuf_avatar);
1221 set_window_title (EmpathyCallWindow *self)
1223 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1226 if (priv->contact != NULL)
1228 /* translators: Call is a noun and %s is the contact name. This string
1229 * is used in the window title */
1230 tmp = g_strdup_printf (_("Call with %s"),
1231 empathy_contact_get_alias (priv->contact));
1232 gtk_window_set_title (GTK_WINDOW (self), tmp);
1237 gtk_window_set_title (GTK_WINDOW (self), _("Call with %d participants"));
1242 contact_name_changed_cb (EmpathyContact *contact,
1243 GParamSpec *pspec, EmpathyCallWindow *self)
1245 set_window_title (self);
1249 contact_avatar_changed_cb (EmpathyContact *contact,
1251 EmpathyCallWindow *self)
1254 GtkAllocation allocation;
1255 GtkWidget *avatar_widget;
1257 avatar_widget = self->priv->remote_user_avatar_widget;
1259 gtk_widget_get_allocation (avatar_widget, &allocation);
1260 size = allocation.height;
1264 /* the widget is not allocated yet, set a default size */
1265 size = MIN (REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT,
1266 REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH);
1269 init_contact_avatar_with_size (contact, avatar_widget, size);
1271 avatar_widget = self->priv->remote_user_avatar_toolbar;
1273 gtk_widget_get_allocation (avatar_widget, &allocation);
1274 size = allocation.height;
1278 /* the widget is not allocated yet, set a default size */
1279 size = SMALL_TOOLBAR_SIZE;
1282 init_contact_avatar_with_size (contact, avatar_widget, size);
1286 empathy_call_window_setup_avatars (EmpathyCallWindow *self,
1287 EmpathyCallHandler *handler)
1289 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1291 g_signal_connect (priv->contact, "notify::name",
1292 G_CALLBACK (contact_name_changed_cb), self);
1293 g_signal_connect (priv->contact, "notify::avatar",
1294 G_CALLBACK (contact_avatar_changed_cb), self);
1296 set_window_title (self);
1298 init_contact_avatar_with_size (priv->contact,
1299 priv->remote_user_avatar_widget,
1300 MIN (REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH,
1301 REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT));
1303 init_contact_avatar_with_size (priv->contact,
1304 priv->remote_user_avatar_toolbar,
1305 SMALL_TOOLBAR_SIZE);
1307 /* The remote avatar is shown by default and will be hidden when we receive
1308 video from the remote side. */
1309 clutter_actor_hide (priv->video_output);
1310 gtk_widget_show (priv->remote_user_avatar_widget);
1314 update_send_codec (EmpathyCallWindow *self,
1317 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1324 codec = empathy_call_handler_get_send_audio_codec (priv->handler);
1325 widget = priv->acodec_encoding_label;
1329 codec = empathy_call_handler_get_send_video_codec (priv->handler);
1330 widget = priv->vcodec_encoding_label;
1336 tmp = g_strdup_printf ("%s/%u", codec->encoding_name, codec->clock_rate);
1337 gtk_label_set_text (GTK_LABEL (widget), tmp);
1342 send_audio_codec_notify_cb (GObject *object,
1346 EmpathyCallWindow *self = user_data;
1348 update_send_codec (self, TRUE);
1352 send_video_codec_notify_cb (GObject *object,
1356 EmpathyCallWindow *self = user_data;
1358 update_send_codec (self, FALSE);
1362 update_recv_codec (EmpathyCallWindow *self,
1365 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1368 GString *str = NULL;
1372 codecs = empathy_call_handler_get_recv_audio_codecs (priv->handler);
1373 widget = priv->acodec_decoding_label;
1377 codecs = empathy_call_handler_get_recv_video_codecs (priv->handler);
1378 widget = priv->vcodec_decoding_label;
1384 for (l = codecs; l != NULL; l = g_list_next (l))
1386 FsCodec *codec = l->data;
1389 str = g_string_new (NULL);
1391 g_string_append (str, ", ");
1393 g_string_append_printf (str, "%s/%u", codec->encoding_name,
1397 gtk_label_set_text (GTK_LABEL (widget), str->str);
1398 g_string_free (str, TRUE);
1402 recv_audio_codecs_notify_cb (GObject *object,
1406 EmpathyCallWindow *self = user_data;
1408 update_recv_codec (self, TRUE);
1412 recv_video_codecs_notify_cb (GObject *object,
1416 EmpathyCallWindow *self = user_data;
1418 update_recv_codec (self, FALSE);
1421 static const gchar *
1422 candidate_type_to_str (FsCandidate *candidate)
1424 switch (candidate->type)
1426 case FS_CANDIDATE_TYPE_HOST:
1428 case FS_CANDIDATE_TYPE_SRFLX:
1429 return "server reflexive";
1430 case FS_CANDIDATE_TYPE_PRFLX:
1431 return "peer reflexive";
1432 case FS_CANDIDATE_TYPE_RELAY:
1434 case FS_CANDIDATE_TYPE_MULTICAST:
1441 static const gchar *
1442 candidate_type_to_desc (FsCandidate *candidate)
1444 switch (candidate->type)
1446 case FS_CANDIDATE_TYPE_HOST:
1447 return _("The IP address as seen by the machine");
1448 case FS_CANDIDATE_TYPE_SRFLX:
1449 return _("The IP address as seen by a server on the Internet");
1450 case FS_CANDIDATE_TYPE_PRFLX:
1451 return _("The IP address of the peer as seen by the other side");
1452 case FS_CANDIDATE_TYPE_RELAY:
1453 return _("The IP address of a relay server");
1454 case FS_CANDIDATE_TYPE_MULTICAST:
1455 return _("The IP address of the multicast group");
1462 update_candidat_widget (EmpathyCallWindow *self,
1465 FsCandidate *candidate)
1469 g_assert (candidate != NULL);
1470 str = g_strdup_printf ("%s %u (%s)", candidate->ip,
1471 candidate->port, candidate_type_to_str (candidate));
1473 gtk_label_set_text (GTK_LABEL (label), str);
1474 gtk_widget_set_tooltip_text (img, candidate_type_to_desc (candidate));
1480 candidates_changed_cb (GObject *object,
1482 EmpathyCallWindow *self)
1484 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1485 FsCandidate *candidate = NULL;
1487 if (type == FS_MEDIA_TYPE_VIDEO)
1489 /* Update remote candidate */
1490 candidate = empathy_call_handler_get_video_remote_candidate (
1493 update_candidat_widget (self, priv->video_remote_candidate_label,
1494 priv->video_remote_candidate_info_img, candidate);
1496 /* Update local candidate */
1497 candidate = empathy_call_handler_get_video_local_candidate (
1500 update_candidat_widget (self, priv->video_local_candidate_label,
1501 priv->video_local_candidate_info_img, candidate);
1505 /* Update remote candidate */
1506 candidate = empathy_call_handler_get_audio_remote_candidate (
1509 update_candidat_widget (self, priv->audio_remote_candidate_label,
1510 priv->audio_remote_candidate_info_img, candidate);
1512 /* Update local candidate */
1513 candidate = empathy_call_handler_get_audio_local_candidate (
1516 update_candidat_widget (self, priv->audio_local_candidate_label,
1517 priv->audio_local_candidate_info_img, candidate);
1522 empathy_call_window_constructed (GObject *object)
1524 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
1525 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1526 TpyCallChannel *call;
1528 g_assert (priv->handler != NULL);
1530 g_object_get (priv->handler, "call-channel", &call, NULL);
1531 priv->outgoing = (call == NULL);
1533 g_object_unref (call);
1535 g_object_get (priv->handler, "target-contact", &priv->contact, NULL);
1536 g_assert (priv->contact != NULL);
1538 empathy_call_window_setup_avatars (self, priv->handler);
1539 empathy_call_window_set_state_connecting (self);
1541 if (!empathy_call_handler_has_initial_video (priv->handler))
1543 gtk_toggle_tool_button_set_active (
1544 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), FALSE);
1546 /* If call has InitialVideo, the preview will be started once the call has
1547 * been started (start_call()). */
1549 update_send_codec (self, TRUE);
1550 update_send_codec (self, FALSE);
1551 update_recv_codec (self, TRUE);
1552 update_recv_codec (self, FALSE);
1554 tp_g_signal_connect_object (priv->handler, "notify::send-audio-codec",
1555 G_CALLBACK (send_audio_codec_notify_cb), self, 0);
1556 tp_g_signal_connect_object (priv->handler, "notify::send-video-codec",
1557 G_CALLBACK (send_video_codec_notify_cb), self, 0);
1558 tp_g_signal_connect_object (priv->handler, "notify::recv-audio-codecs",
1559 G_CALLBACK (recv_audio_codecs_notify_cb), self, 0);
1560 tp_g_signal_connect_object (priv->handler, "notify::recv-video-codecs",
1561 G_CALLBACK (recv_video_codecs_notify_cb), self, 0);
1563 tp_g_signal_connect_object (priv->handler, "candidates-changed",
1564 G_CALLBACK (candidates_changed_cb), self, 0);
1567 static void empathy_call_window_dispose (GObject *object);
1568 static void empathy_call_window_finalize (GObject *object);
1571 empathy_call_window_set_property (GObject *object,
1572 guint property_id, const GValue *value, GParamSpec *pspec)
1574 EmpathyCallWindowPriv *priv = GET_PRIV (object);
1576 switch (property_id)
1578 case PROP_CALL_HANDLER:
1579 priv->handler = g_value_dup_object (value);
1582 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1587 empathy_call_window_get_property (GObject *object,
1588 guint property_id, GValue *value, GParamSpec *pspec)
1590 EmpathyCallWindowPriv *priv = GET_PRIV (object);
1592 switch (property_id)
1594 case PROP_CALL_HANDLER:
1595 g_value_set_object (value, priv->handler);
1598 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1603 empathy_call_window_class_init (
1604 EmpathyCallWindowClass *empathy_call_window_class)
1606 GObjectClass *object_class = G_OBJECT_CLASS (empathy_call_window_class);
1607 GParamSpec *param_spec;
1609 g_type_class_add_private (empathy_call_window_class,
1610 sizeof (EmpathyCallWindowPriv));
1612 object_class->constructed = empathy_call_window_constructed;
1613 object_class->set_property = empathy_call_window_set_property;
1614 object_class->get_property = empathy_call_window_get_property;
1616 object_class->dispose = empathy_call_window_dispose;
1617 object_class->finalize = empathy_call_window_finalize;
1619 param_spec = g_param_spec_object ("handler",
1620 "handler", "The call handler",
1621 EMPATHY_TYPE_CALL_HANDLER,
1622 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
1623 g_object_class_install_property (object_class,
1624 PROP_CALL_HANDLER, param_spec);
1628 empathy_call_window_dispose (GObject *object)
1630 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
1631 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1633 if (priv->dispose_has_run)
1636 priv->dispose_has_run = TRUE;
1638 if (priv->handler != NULL)
1640 empathy_call_handler_stop_call (priv->handler);
1641 tp_clear_object (&priv->handler);
1644 if (priv->bus_message_source_id != 0)
1646 g_source_remove (priv->bus_message_source_id);
1647 priv->bus_message_source_id = 0;
1650 if (priv->got_video_src > 0)
1652 g_source_remove (priv->got_video_src);
1653 priv->got_video_src = 0;
1656 tp_clear_object (&priv->pipeline);
1657 tp_clear_object (&priv->video_input);
1658 tp_clear_object (&priv->audio_input);
1659 tp_clear_object (&priv->video_tee);
1660 tp_clear_object (&priv->ui_manager);
1661 tp_clear_object (&priv->fullscreen);
1662 tp_clear_object (&priv->camera_monitor);
1664 g_list_free_full (priv->notifiers, g_object_unref);
1666 if (priv->timer_id != 0)
1667 g_source_remove (priv->timer_id);
1670 if (priv->contact != NULL)
1672 g_signal_handlers_disconnect_by_func (priv->contact,
1673 contact_name_changed_cb, self);
1674 priv->contact = NULL;
1678 tp_clear_object (&priv->sound_mgr);
1680 G_OBJECT_CLASS (empathy_call_window_parent_class)->dispose (object);
1684 disconnect_video_output_motion_handler (EmpathyCallWindow *self)
1686 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1688 if (priv->video_output_motion_handler_id != 0)
1690 g_signal_handler_disconnect (G_OBJECT (priv->video_container),
1691 priv->video_output_motion_handler_id);
1692 priv->video_output_motion_handler_id = 0;
1697 empathy_call_window_finalize (GObject *object)
1699 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
1700 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1702 disconnect_video_output_motion_handler (self);
1704 /* free any data held directly by the object here */
1705 g_mutex_free (priv->lock);
1707 g_timer_destroy (priv->timer);
1709 G_OBJECT_CLASS (empathy_call_window_parent_class)->finalize (object);
1714 empathy_call_window_new (EmpathyCallHandler *handler)
1716 return EMPATHY_CALL_WINDOW (
1717 g_object_new (EMPATHY_TYPE_CALL_WINDOW, "handler", handler, NULL));
1721 empathy_call_window_conference_added_cb (EmpathyCallHandler *handler,
1722 GstElement *conference, gpointer user_data)
1724 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
1725 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1726 FsElementAddedNotifier *notifier;
1729 DEBUG ("Conference added");
1731 /* Add notifier to set the various element properties as needed */
1732 notifier = fs_element_added_notifier_new ();
1733 keyfile = fs_utils_get_default_element_properties (conference);
1735 if (keyfile != NULL)
1736 fs_element_added_notifier_set_properties_from_keyfile (notifier, keyfile);
1738 fs_element_added_notifier_add (notifier, GST_BIN (priv->pipeline));
1740 priv->notifiers = g_list_prepend (priv->notifiers, notifier);
1742 gst_bin_add (GST_BIN (priv->pipeline), conference);
1743 gst_element_set_state (conference, GST_STATE_PLAYING);
1747 empathy_call_window_conference_removed_cb (EmpathyCallHandler *handler,
1748 GstElement *conference, gpointer user_data)
1750 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
1751 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1753 gst_bin_remove (GST_BIN (priv->pipeline), conference);
1754 gst_element_set_state (conference, GST_STATE_NULL);
1758 empathy_call_window_reset_pipeline (EmpathyCallWindow *self)
1760 GstStateChangeReturn state_change_return;
1761 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1763 if (priv->pipeline == NULL)
1766 if (priv->bus_message_source_id != 0)
1768 g_source_remove (priv->bus_message_source_id);
1769 priv->bus_message_source_id = 0;
1772 state_change_return = gst_element_set_state (priv->pipeline, GST_STATE_NULL);
1774 if (state_change_return == GST_STATE_CHANGE_SUCCESS ||
1775 state_change_return == GST_STATE_CHANGE_NO_PREROLL)
1777 if (priv->pipeline != NULL)
1778 g_object_unref (priv->pipeline);
1779 priv->pipeline = NULL;
1781 g_signal_handlers_disconnect_by_func (priv->audio_input_adj,
1782 empathy_call_window_mic_volume_changed_cb, self);
1784 if (priv->audio_output != NULL)
1785 g_object_unref (priv->audio_output);
1786 priv->audio_output = NULL;
1788 if (priv->video_tee != NULL)
1789 g_object_unref (priv->video_tee);
1790 priv->video_tee = NULL;
1792 if (priv->video_preview != NULL)
1793 clutter_actor_destroy (priv->video_preview);
1794 priv->video_preview = NULL;
1796 priv->funnel = NULL;
1798 create_pipeline (self);
1799 /* Call will be started when user will hit the 'redial' button */
1800 priv->start_call_when_playing = FALSE;
1801 gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
1807 g_message ("Error: could not destroy pipeline. Closing call window");
1808 gtk_widget_destroy (GTK_WIDGET (self));
1815 reset_details_pane (EmpathyCallWindow *self)
1817 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1819 gtk_label_set_text (GTK_LABEL (priv->vcodec_encoding_label), _("Unknown"));
1820 gtk_label_set_text (GTK_LABEL (priv->acodec_encoding_label), _("Unknown"));
1821 gtk_label_set_text (GTK_LABEL (priv->vcodec_decoding_label), _("Unknown"));
1822 gtk_label_set_text (GTK_LABEL (priv->acodec_decoding_label), _("Unknown"));
1826 empathy_call_window_disconnected (EmpathyCallWindow *self,
1829 gboolean could_disconnect = FALSE;
1830 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1831 gboolean could_reset_pipeline;
1833 /* Leave full screen mode if needed */
1834 gtk_window_unfullscreen (GTK_WINDOW (self));
1836 gtk_action_set_sensitive (priv->menu_fullscreen, FALSE);
1837 gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
1839 could_reset_pipeline = empathy_call_window_reset_pipeline (self);
1841 if (priv->call_state == CONNECTING)
1842 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
1844 if (priv->call_state != REDIALING)
1845 priv->call_state = DISCONNECTED;
1847 if (could_reset_pipeline)
1849 g_mutex_lock (priv->lock);
1851 g_timer_stop (priv->timer);
1853 if (priv->timer_id != 0)
1854 g_source_remove (priv->timer_id);
1857 g_mutex_unlock (priv->lock);
1860 /* We are about to destroy the window, no need to update it or create
1861 * a video preview */
1864 empathy_call_window_status_message (self, _("Disconnected"));
1866 gtk_action_set_sensitive (priv->redial, TRUE);
1867 gtk_widget_set_sensitive (priv->redial_button, TRUE);
1869 /* Unsensitive the camera and mic button */
1870 gtk_widget_set_sensitive (priv->camera_button, FALSE);
1871 gtk_widget_set_sensitive (priv->mic_button, FALSE);
1873 /* Be sure that the mic button is enabled */
1874 gtk_toggle_tool_button_set_active (
1875 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button), TRUE);
1877 if (priv->camera_state == CAMERA_STATE_ON)
1879 /* Restart the preview with the new pipeline. */
1880 display_video_preview (self, TRUE);
1883 gtk_progress_bar_set_fraction (
1884 GTK_PROGRESS_BAR (priv->volume_progress_bar), 0);
1886 /* destroy the video output; it will be recreated when we'll redial */
1887 disconnect_video_output_motion_handler (self);
1888 if (priv->video_output != NULL)
1889 clutter_actor_destroy (priv->video_output);
1890 priv->video_output = NULL;
1891 if (priv->got_video_src > 0)
1893 g_source_remove (priv->got_video_src);
1894 priv->got_video_src = 0;
1897 gtk_widget_show (priv->remote_user_avatar_widget);
1899 reset_details_pane (self);
1901 priv->sending_video = FALSE;
1902 priv->call_started = FALSE;
1904 could_disconnect = TRUE;
1906 /* TODO: display the self avatar of the preview (depends if the "Always
1907 * Show Video Preview" is enabled or not) */
1910 return could_disconnect;
1915 empathy_call_window_channel_closed_cb (EmpathyCallHandler *handler,
1918 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
1919 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1921 if (empathy_call_window_disconnected (self, TRUE) &&
1922 priv->call_state == REDIALING)
1923 empathy_call_window_restart_call (self);
1927 empathy_call_window_sink_removed_cb (EmpathyCallHandler *handler,
1929 FsMediaType media_type,
1930 EmpathyCallWindow *self)
1932 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1934 DEBUG ("removing content");
1937 * This assumes that there is only one video stream per channel...
1940 if ((guint) media_type == FS_MEDIA_TYPE_VIDEO)
1942 if (priv->funnel != NULL)
1946 output = priv->video_output_sink;
1948 gst_element_set_state (output, GST_STATE_NULL);
1949 gst_element_set_state (priv->funnel, GST_STATE_NULL);
1951 gst_bin_remove (GST_BIN (priv->pipeline), output);
1952 gst_bin_remove (GST_BIN (priv->pipeline), priv->funnel);
1953 priv->funnel = NULL;
1957 else if (media_type == FS_MEDIA_TYPE_AUDIO)
1959 if (priv->audio_output != NULL)
1961 gst_element_set_state (priv->audio_output, GST_STATE_NULL);
1963 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
1964 priv->audio_output = NULL;
1972 /* Called with global lock held */
1974 empathy_call_window_get_video_sink_pad (EmpathyCallWindow *self)
1976 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1980 if (priv->funnel == NULL)
1982 output = priv->video_output_sink;
1984 priv->funnel = gst_element_factory_make ("fsfunnel", NULL);
1988 g_warning ("Could not create fsfunnel");
1992 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->funnel))
1994 gst_object_unref (priv->funnel);
1995 priv->funnel = NULL;
1996 g_warning ("Could not add funnel to pipeline");
2000 if (!gst_bin_add (GST_BIN (priv->pipeline), output))
2002 g_warning ("Could not add the video output widget to the pipeline");
2006 if (!gst_element_link (priv->funnel, output))
2008 g_warning ("Could not link output sink to funnel");
2009 goto error_output_added;
2012 if (gst_element_set_state (output, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2014 g_warning ("Could not start video sink");
2015 goto error_output_added;
2018 if (gst_element_set_state (priv->funnel, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2020 g_warning ("Could not start funnel");
2021 goto error_output_added;
2025 pad = gst_element_get_request_pad (priv->funnel, "sink%d");
2028 g_warning ("Could not get request pad from funnel");
2035 gst_element_set_locked_state (priv->funnel, TRUE);
2036 gst_element_set_locked_state (output, TRUE);
2038 gst_element_set_state (priv->funnel, GST_STATE_NULL);
2039 gst_element_set_state (output, GST_STATE_NULL);
2041 gst_bin_remove (GST_BIN (priv->pipeline), output);
2042 gst_element_set_locked_state (output, FALSE);
2046 gst_bin_remove (GST_BIN (priv->pipeline), priv->funnel);
2047 priv->funnel = NULL;
2052 /* Called with global lock held */
2054 empathy_call_window_get_audio_sink_pad (EmpathyCallWindow *self)
2056 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2058 GstPadTemplate *template;
2060 if (priv->audio_output == NULL)
2062 priv->audio_output = empathy_audio_sink_new ();
2063 g_object_ref_sink (priv->audio_output);
2065 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_output))
2067 g_warning ("Could not add audio sink to pipeline");
2068 g_object_unref (priv->audio_output);
2069 goto error_add_output;
2072 if (gst_element_set_state (priv->audio_output, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2074 g_warning ("Could not start audio sink");
2079 template = gst_element_class_get_pad_template (
2080 GST_ELEMENT_GET_CLASS (priv->audio_output), "sink%d");
2082 pad = gst_element_request_pad (priv->audio_output,
2083 template, NULL, NULL);
2087 g_warning ("Could not get sink pad from sink");
2094 gst_element_set_locked_state (priv->audio_output, TRUE);
2095 gst_element_set_state (priv->audio_output, GST_STATE_NULL);
2096 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
2097 priv->audio_output = NULL;
2105 empathy_call_window_update_timer (gpointer user_data)
2107 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2108 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2112 time_ = g_timer_elapsed (priv->timer, NULL);
2114 /* Translators: 'status - minutes:seconds' the caller has been connected */
2115 str = g_strdup_printf (_("%s — %d:%02dm"),
2116 priv->call_state == HELD ? _("On hold") : _("Connected"),
2117 (int) time_ / 60, (int) time_ % 60);
2118 empathy_call_window_status_message (self, str);
2126 display_error (EmpathyCallWindow *self,
2127 TpyCallChannel *call,
2131 const gchar *details)
2133 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2134 GtkWidget *info_bar;
2135 GtkWidget *content_area;
2142 /* Create info bar */
2143 info_bar = gtk_info_bar_new_with_buttons (GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
2146 gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_WARNING);
2148 content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar));
2150 /* hbox containing the image and the messages vbox */
2151 hbox = gtk_hbox_new (FALSE, 3);
2152 gtk_container_add (GTK_CONTAINER (content_area), hbox);
2155 image = gtk_image_new_from_icon_name (img, GTK_ICON_SIZE_DIALOG);
2156 gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
2158 /* vbox containing the main message and the details expander */
2159 vbox = gtk_vbox_new (FALSE, 3);
2160 gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
2163 txt = g_strdup_printf ("<b>%s</b>\n%s", title, desc);
2165 label = gtk_label_new (NULL);
2166 gtk_label_set_markup (GTK_LABEL (label), txt);
2167 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
2168 gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
2171 gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
2174 if (details != NULL)
2176 GtkWidget *expander;
2178 expander = gtk_expander_new (_("Technical Details"));
2180 txt = g_strdup_printf ("<i>%s</i>", details);
2182 label = gtk_label_new (NULL);
2183 gtk_label_set_markup (GTK_LABEL (label), txt);
2184 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
2185 gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
2188 gtk_container_add (GTK_CONTAINER (expander), label);
2189 gtk_box_pack_start (GTK_BOX (vbox), expander, TRUE, TRUE, 0);
2192 g_signal_connect (info_bar, "response",
2193 G_CALLBACK (gtk_widget_destroy), NULL);
2195 gtk_box_pack_start (GTK_BOX (priv->errors_vbox), info_bar,
2196 FALSE, FALSE, CONTENT_HBOX_CHILDREN_PACKING_PADDING);
2197 gtk_widget_show_all (info_bar);
2201 media_stream_error_to_txt (EmpathyCallWindow *self,
2202 TpyCallChannel *call,
2204 TpMediaStreamError error)
2206 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2207 const gchar *cm = NULL;
2213 case TP_MEDIA_STREAM_ERROR_CODEC_NEGOTIATION_FAILED:
2215 return g_strdup_printf (
2216 _("%s's software does not understand any of the audio formats "
2217 "supported by your computer"),
2218 empathy_contact_get_alias (priv->contact));
2220 return g_strdup_printf (
2221 _("%s's software does not understand any of the video formats "
2222 "supported by your computer"),
2223 empathy_contact_get_alias (priv->contact));
2225 case TP_MEDIA_STREAM_ERROR_CONNECTION_FAILED:
2226 return g_strdup_printf (
2227 _("Can't establish a connection to %s. "
2228 "One of you might be on a network that does not allow "
2229 "direct connections."),
2230 empathy_contact_get_alias (priv->contact));
2232 case TP_MEDIA_STREAM_ERROR_NETWORK_ERROR:
2233 return g_strdup (_("There was a failure on the network"));
2235 case TP_MEDIA_STREAM_ERROR_NO_CODECS:
2237 return g_strdup (_("The audio formats necessary for this call "
2238 "are not installed on your computer"));
2240 return g_strdup (_("The video formats necessary for this call "
2241 "are not installed on your computer"));
2243 case TP_MEDIA_STREAM_ERROR_INVALID_CM_BEHAVIOR:
2244 tp_connection_parse_object_path (
2245 tp_channel_borrow_connection (TP_CHANNEL (call)),
2248 url = g_strdup_printf ("http://bugs.freedesktop.org/enter_bug.cgi?"
2249 "product=Telepathy&component=%s", cm);
2251 result = g_strdup_printf (
2252 _("Something unexpected happened in a Telepathy component. "
2253 "Please <a href=\"%s\">report this bug</a> and attach "
2254 "logs gathered from the 'Debug' window in the Help menu."), url);
2260 case TP_MEDIA_STREAM_ERROR_MEDIA_ERROR:
2261 return g_strdup (_("There was a failure in the call engine"));
2263 case TP_MEDIA_STREAM_ERROR_EOS:
2264 return g_strdup (_("The end of the stream was reached"));
2266 case TP_MEDIA_STREAM_ERROR_UNKNOWN:
2273 empathy_call_window_stream_error (EmpathyCallWindow *self,
2274 TpyCallChannel *call,
2283 desc = media_stream_error_to_txt (self, call, audio, code);
2286 /* No description, use the error message. That's not great as it's not
2287 * localized but it's better than nothing. */
2288 display_error (self, call, icon, title, msg, NULL);
2292 display_error (self, call, icon, title, desc, msg);
2298 empathy_call_window_audio_stream_error (TpyCallChannel *call,
2301 EmpathyCallWindow *self)
2303 empathy_call_window_stream_error (self, call, TRUE, code, msg,
2304 "gnome-stock-mic", _("Can't establish audio stream"));
2308 empathy_call_window_video_stream_error (TpyCallChannel *call,
2311 EmpathyCallWindow *self)
2313 empathy_call_window_stream_error (self, call, FALSE, code, msg,
2314 "camera-web", _("Can't establish video stream"));
2319 empathy_call_window_state_changed_cb (EmpathyCallHandler *handler,
2321 EmpathyCallWindow *self)
2323 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2324 TpyCallChannel *call;
2325 gboolean can_send_video;
2327 if (state != TPY_CALL_STATE_ACCEPTED)
2330 if (priv->call_state == CONNECTED)
2333 g_timer_start (priv->timer);
2334 priv->call_state = CONNECTED;
2336 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
2338 can_send_video = priv->video_input != NULL &&
2339 empathy_contact_can_voip_video (priv->contact) &&
2340 empathy_camera_monitor_get_available (priv->camera_monitor);
2342 g_object_get (priv->handler, "call-channel", &call, NULL);
2344 if (tpy_call_channel_has_dtmf (call))
2345 gtk_widget_set_sensitive (priv->dtmf_panel, TRUE);
2347 if (priv->video_input == NULL)
2348 empathy_call_window_set_send_video (self, CAMERA_STATE_OFF);
2350 gtk_widget_set_sensitive (priv->camera_button, can_send_video);
2352 gtk_action_set_sensitive (priv->redial, FALSE);
2353 gtk_widget_set_sensitive (priv->redial_button, FALSE);
2355 gtk_widget_set_sensitive (priv->mic_button, TRUE);
2357 clutter_actor_hide (priv->video_output);
2358 gtk_widget_show (priv->remote_user_avatar_widget);
2360 g_object_unref (call);
2362 g_mutex_lock (priv->lock);
2364 priv->timer_id = g_timeout_add_seconds (1,
2365 empathy_call_window_update_timer, self);
2367 g_mutex_unlock (priv->lock);
2369 empathy_call_window_update_timer (self);
2371 gtk_action_set_sensitive (priv->menu_fullscreen, TRUE);
2375 empathy_call_window_show_video_output_cb (gpointer user_data)
2377 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2379 if (self->priv->video_output != NULL)
2381 gtk_widget_hide (self->priv->remote_user_avatar_widget);
2382 clutter_actor_show (self->priv->video_output);
2389 empathy_call_window_check_video_cb (gpointer data)
2391 EmpathyCallWindow *self = data;
2393 if (self->priv->got_video)
2395 self->priv->got_video = FALSE;
2399 /* No video in the last N seconds, display the remote avatar */
2400 empathy_call_window_show_video_output (self, FALSE);
2405 /* Called from the streaming thread */
2407 empathy_call_window_video_probe_cb (GstPad *pad,
2408 GstMiniObject *mini_obj,
2409 EmpathyCallWindow *self)
2412 if (GST_IS_EVENT (mini_obj))
2415 if (G_UNLIKELY (!self->priv->got_video))
2417 /* show the remote video */
2418 g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
2419 empathy_call_window_show_video_output_cb,
2420 g_object_ref (self), g_object_unref);
2422 self->priv->got_video = TRUE;
2428 /* Called from the streaming thread */
2430 empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
2431 GstPad *src, guint media_type, gpointer user_data)
2433 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2434 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2435 gboolean retval = FALSE;
2439 g_mutex_lock (priv->lock);
2443 case TP_MEDIA_STREAM_TYPE_AUDIO:
2444 pad = empathy_call_window_get_audio_sink_pad (self);
2446 case TP_MEDIA_STREAM_TYPE_VIDEO:
2447 g_idle_add (empathy_call_window_show_video_output_cb, self);
2448 pad = empathy_call_window_get_video_sink_pad (self);
2450 gst_pad_add_data_probe (src,
2451 G_CALLBACK (empathy_call_window_video_probe_cb), self);
2452 if (priv->got_video_src > 0)
2453 g_source_remove (priv->got_video_src);
2454 priv->got_video_src = g_timeout_add_seconds (5,
2455 empathy_call_window_check_video_cb, self);
2458 g_assert_not_reached ();
2464 if (GST_PAD_LINK_FAILED (gst_pad_link (src, pad)))
2465 g_warning ("Could not link %s sink pad",
2466 media_type == TP_MEDIA_STREAM_TYPE_AUDIO ? "audio" : "video");
2470 gst_object_unref (pad);
2474 /* If no sink could be linked, try to add fakesink to prevent the whole call
2479 GstElement *fakesink = gst_element_factory_make ("fakesink", NULL);
2481 if (gst_bin_add (GST_BIN (priv->pipeline), fakesink))
2483 GstPad *sinkpad = gst_element_get_static_pad (fakesink, "sink");
2484 if (gst_element_set_state (fakesink, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE ||
2485 GST_PAD_LINK_FAILED (gst_pad_link (src, sinkpad)))
2487 gst_element_set_locked_state (fakesink, TRUE);
2488 gst_element_set_state (fakesink, GST_STATE_NULL);
2489 gst_bin_remove (GST_BIN (priv->pipeline), fakesink);
2493 DEBUG ("Could not link real sink, linked fakesink instead");
2495 gst_object_unref (sinkpad);
2499 gst_object_unref (fakesink);
2504 g_mutex_unlock (priv->lock);
2510 empathy_call_window_sink_added_cb (EmpathyCallHandler *handler,
2511 GstPad *sink, FsMediaType media_type, gpointer user_data)
2513 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2514 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2516 gboolean retval = FALSE;
2520 case FS_MEDIA_TYPE_AUDIO:
2521 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_input))
2523 g_warning ("Could not add audio source to pipeline");
2527 pad = gst_element_get_static_pad (priv->audio_input, "src");
2530 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
2531 g_warning ("Could not get source pad from audio source");
2535 if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
2537 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
2538 g_warning ("Could not link audio source to farsight");
2542 if (gst_element_set_state (priv->audio_input, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2544 g_warning ("Could not start audio source");
2545 gst_element_set_state (priv->audio_input, GST_STATE_NULL);
2546 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
2552 case FS_MEDIA_TYPE_VIDEO:
2553 if (priv->video_tee != NULL)
2555 pad = gst_element_get_request_pad (priv->video_tee, "src%d");
2556 if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
2558 g_warning ("Could not link video source input pipeline");
2561 gst_object_unref (pad);
2567 g_assert_not_reached ();
2574 empathy_call_window_remove_video_input (EmpathyCallWindow *self)
2576 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2577 GstElement *preview;
2579 disable_camera (self);
2581 DEBUG ("remove video input");
2582 preview = priv->video_preview_sink;
2584 gst_element_set_state (priv->video_input, GST_STATE_NULL);
2585 gst_element_set_state (priv->video_tee, GST_STATE_NULL);
2586 gst_element_set_state (preview, GST_STATE_NULL);
2588 gst_bin_remove_many (GST_BIN (priv->pipeline), priv->video_input,
2591 g_object_unref (priv->video_input);
2592 priv->video_input = NULL;
2593 g_object_unref (priv->video_tee);
2594 priv->video_tee = NULL;
2595 clutter_actor_destroy (priv->video_preview);
2596 priv->video_preview = NULL;
2598 gtk_widget_set_sensitive (priv->camera_button, FALSE);
2602 start_call (EmpathyCallWindow *self)
2604 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2606 priv->call_started = TRUE;
2607 empathy_call_handler_start_call (priv->handler,
2608 gtk_get_current_event_time ());
2610 if (empathy_call_handler_has_initial_video (priv->handler))
2612 TpyCallChannel *call;
2615 g_object_get (priv->handler, "call-channel", &call, NULL);
2616 s = tpy_call_channel_get_video_state (call);
2618 if (s == TPY_SENDING_STATE_PENDING_SEND ||
2619 s == TPY_SENDING_STATE_SENDING)
2621 /* Enable 'send video' buttons and display the preview */
2622 gtk_toggle_tool_button_set_active (
2623 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), TRUE);
2627 gtk_toggle_tool_button_set_active (
2628 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), FALSE);
2630 if (priv->video_preview == NULL)
2632 create_video_preview (self);
2633 add_video_preview_to_pipeline (self);
2637 g_object_unref (call);
2642 empathy_call_window_bus_message (GstBus *bus, GstMessage *message,
2645 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2646 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2649 empathy_call_handler_bus_message (priv->handler, bus, message);
2651 switch (GST_MESSAGE_TYPE (message))
2653 case GST_MESSAGE_STATE_CHANGED:
2654 if (GST_MESSAGE_SRC (message) == GST_OBJECT (priv->video_input))
2656 gst_message_parse_state_changed (message, NULL, &newstate, NULL);
2657 if (newstate == GST_STATE_PAUSED)
2658 empathy_call_window_setup_video_input (self);
2660 if (GST_MESSAGE_SRC (message) == GST_OBJECT (priv->pipeline) &&
2661 !priv->call_started)
2663 gst_message_parse_state_changed (message, NULL, &newstate, NULL);
2664 if (newstate == GST_STATE_PAUSED)
2666 gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
2667 priv->pipeline_playing = TRUE;
2669 if (priv->start_call_when_playing)
2674 case GST_MESSAGE_ERROR:
2676 GError *error = NULL;
2677 GstElement *gst_error;
2680 gst_message_parse_error (message, &error, &debug);
2681 gst_error = GST_ELEMENT (GST_MESSAGE_SRC (message));
2683 g_message ("Element error: %s -- %s\n", error->message, debug);
2685 if (g_str_has_prefix (gst_element_get_name (gst_error),
2686 VIDEO_INPUT_ERROR_PREFIX))
2688 /* Remove the video input and continue */
2689 if (priv->video_input != NULL)
2690 empathy_call_window_remove_video_input (self);
2691 gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
2695 empathy_call_window_disconnected (self, TRUE);
2697 g_error_free (error);
2700 case GST_MESSAGE_UNKNOWN:
2701 case GST_MESSAGE_EOS:
2702 case GST_MESSAGE_WARNING:
2703 case GST_MESSAGE_INFO:
2704 case GST_MESSAGE_TAG:
2705 case GST_MESSAGE_BUFFERING:
2706 case GST_MESSAGE_STATE_DIRTY:
2707 case GST_MESSAGE_STEP_DONE:
2708 case GST_MESSAGE_CLOCK_PROVIDE:
2709 case GST_MESSAGE_CLOCK_LOST:
2710 case GST_MESSAGE_NEW_CLOCK:
2711 case GST_MESSAGE_STRUCTURE_CHANGE:
2712 case GST_MESSAGE_STREAM_STATUS:
2713 case GST_MESSAGE_APPLICATION:
2714 case GST_MESSAGE_ELEMENT:
2715 case GST_MESSAGE_SEGMENT_START:
2716 case GST_MESSAGE_SEGMENT_DONE:
2717 case GST_MESSAGE_DURATION:
2718 case GST_MESSAGE_ANY:
2727 empathy_call_window_members_changed_cb (TpyCallChannel *call,
2728 GHashTable *members,
2729 EmpathyCallWindow *self)
2731 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2732 GHashTableIter iter;
2733 gpointer key, value;
2734 gboolean held = FALSE;
2736 g_hash_table_iter_init (&iter, members);
2737 while (g_hash_table_iter_next (&iter, &key, &value))
2739 if (GPOINTER_TO_INT (value) & TPY_CALL_MEMBER_FLAG_HELD)
2741 /* This assumes this is a 1-1 call, otherwise one participant
2742 * putting the call on hold wouldn't mean the call is on hold
2750 priv->call_state = HELD;
2751 else if (priv->call_state == HELD)
2752 priv->call_state = CONNECTED;
2756 call_handler_notify_call_cb (EmpathyCallHandler *handler,
2758 EmpathyCallWindow *self)
2760 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2761 TpyCallChannel *call;
2763 g_object_get (priv->handler, "call-channel", &call, NULL);
2768 tp_g_signal_connect_object (call, "audio-stream-error",
2769 G_CALLBACK (empathy_call_window_audio_stream_error), self, 0);
2770 tp_g_signal_connect_object (call, "video-stream-error",
2771 G_CALLBACK (empathy_call_window_video_stream_error), self, 0);
2774 tp_g_signal_connect_object (call, "members-changed",
2775 G_CALLBACK (empathy_call_window_members_changed_cb), self, 0);
2777 g_object_unref (call);
2781 empathy_call_window_realized_cb (GtkWidget *widget, EmpathyCallWindow *window)
2783 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2784 TpyCallChannel *call;
2786 g_signal_connect (priv->handler, "state-changed",
2787 G_CALLBACK (empathy_call_window_state_changed_cb), window);
2788 g_signal_connect (priv->handler, "conference-added",
2789 G_CALLBACK (empathy_call_window_conference_added_cb), window);
2790 g_signal_connect (priv->handler, "conference-removed",
2791 G_CALLBACK (empathy_call_window_conference_removed_cb), window);
2792 g_signal_connect (priv->handler, "closed",
2793 G_CALLBACK (empathy_call_window_channel_closed_cb), window);
2794 g_signal_connect (priv->handler, "src-pad-added",
2795 G_CALLBACK (empathy_call_window_src_added_cb), window);
2796 g_signal_connect (priv->handler, "sink-pad-added",
2797 G_CALLBACK (empathy_call_window_sink_added_cb), window);
2798 g_signal_connect (priv->handler, "sink-pad-removed",
2799 G_CALLBACK (empathy_call_window_sink_removed_cb), window);
2801 g_object_get (priv->handler, "call-channel", &call, NULL);
2804 call_handler_notify_call_cb (priv->handler, NULL, window);
2805 g_object_unref (call);
2809 /* call-channel doesn't exist yet, we'll connect signals once it has been
2811 g_signal_connect (priv->handler, "notify::call-channel",
2812 G_CALLBACK (call_handler_notify_call_cb), window);
2815 gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
2819 empathy_call_window_delete_cb (GtkWidget *widget, GdkEvent*event,
2820 EmpathyCallWindow *window)
2822 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2824 if (priv->pipeline != NULL)
2826 if (priv->bus_message_source_id != 0)
2828 g_source_remove (priv->bus_message_source_id);
2829 priv->bus_message_source_id = 0;
2832 gst_element_set_state (priv->pipeline, GST_STATE_NULL);
2835 if (priv->call_state == CONNECTING)
2836 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
2842 show_controls (EmpathyCallWindow *window, gboolean set_fullscreen)
2845 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2847 menu = gtk_ui_manager_get_widget (priv->ui_manager,
2852 gtk_widget_hide (priv->sidebar);
2853 gtk_widget_hide (menu);
2854 gtk_widget_hide (priv->toolbar);
2858 if (priv->sidebar_was_visible_before_fs)
2859 gtk_widget_show (priv->sidebar);
2861 gtk_widget_show (menu);
2862 gtk_widget_show (priv->toolbar);
2864 gtk_window_resize (GTK_WINDOW (window), priv->original_width_before_fs,
2865 priv->original_height_before_fs);
2870 show_borders (EmpathyCallWindow *window, gboolean set_fullscreen)
2872 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2874 gtk_container_set_border_width (GTK_CONTAINER (priv->content_hbox),
2875 set_fullscreen ? 0 : CONTENT_HBOX_BORDER_WIDTH);
2876 gtk_box_set_spacing (GTK_BOX (priv->content_hbox),
2877 set_fullscreen ? 0 : CONTENT_HBOX_SPACING);
2879 if (priv->video_output != NULL)
2882 gtk_box_set_child_packing (GTK_BOX (priv->content_hbox),
2883 priv->video_output, TRUE, TRUE,
2884 set_fullscreen ? 0 : CONTENT_HBOX_CHILDREN_PACKING_PADDING,
2891 empathy_call_window_state_event_cb (GtkWidget *widget,
2892 GdkEventWindowState *event, EmpathyCallWindow *window)
2894 if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
2896 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2897 gboolean set_fullscreen = event->new_window_state &
2898 GDK_WINDOW_STATE_FULLSCREEN;
2902 gboolean sidebar_was_visible;
2903 GtkAllocation allocation;
2904 gint original_width, original_height;
2906 gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
2907 original_width = allocation.width;
2908 original_height = allocation.height;
2910 g_object_get (priv->sidebar, "visible", &sidebar_was_visible, NULL);
2912 priv->sidebar_was_visible_before_fs = sidebar_was_visible;
2913 priv->original_width_before_fs = original_width;
2914 priv->original_height_before_fs = original_height;
2916 if (priv->video_output_motion_handler_id == 0 &&
2917 priv->video_output != NULL)
2919 priv->video_output_motion_handler_id = g_signal_connect (
2920 G_OBJECT (priv->video_container), "motion-notify-event",
2921 G_CALLBACK (empathy_call_window_video_output_motion_notify),
2927 disconnect_video_output_motion_handler (window);
2930 empathy_call_window_fullscreen_set_fullscreen (priv->fullscreen,
2932 show_controls (window, set_fullscreen);
2933 show_borders (window, set_fullscreen);
2934 gtk_action_set_stock_id (priv->menu_fullscreen,
2935 (set_fullscreen ? "gtk-leave-fullscreen" : "gtk-fullscreen"));
2936 priv->is_fullscreen = set_fullscreen;
2943 empathy_call_window_update_sidebar_buttons (EmpathyCallWindow *window,
2946 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2948 /* Update dialpad button */
2949 g_signal_handlers_block_by_func (priv->dialpad_button,
2950 empathy_call_window_dialpad_cb, window);
2951 gtk_toggle_tool_button_set_active (
2952 GTK_TOGGLE_TOOL_BUTTON (priv->dialpad_button),
2954 g_signal_handlers_unblock_by_func (priv->dialpad_button,
2955 empathy_call_window_dialpad_cb, window);
2957 /* Update sidebar menu */
2958 g_signal_handlers_block_by_func (priv->menu_sidebar,
2959 empathy_call_window_sidebar_cb, window);
2960 gtk_toggle_action_set_active (
2961 GTK_TOGGLE_ACTION (priv->menu_sidebar),
2962 gtk_widget_get_visible (priv->sidebar));
2963 g_signal_handlers_unblock_by_func (priv->menu_sidebar,
2964 empathy_call_window_sidebar_cb, window);
2968 empathy_call_window_show_sidebar (EmpathyCallWindow *window,
2971 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2972 int w, h, sidebar_width, handle_size;
2973 GtkAllocation allocation;
2975 gboolean dialpad_shown;
2977 gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
2978 w = allocation.width;
2979 h = allocation.height;
2981 gtk_widget_style_get (priv->pane, "handle_size", &handle_size, NULL);
2983 gtk_widget_get_preferred_width (priv->sidebar, &sidebar_width, NULL);
2987 gtk_widget_show (priv->sidebar);
2988 w += sidebar_width + handle_size;
2992 w -= sidebar_width + handle_size;
2993 gtk_widget_hide (priv->sidebar);
2997 gtk_window_resize (GTK_WINDOW (window), w, h);
2999 /* Update the 'Dialpad' menu */
3000 page = ev_sidebar_get_current_page (EV_SIDEBAR (priv->sidebar));
3001 dialpad_shown = active && !tp_strdiff (page, "dialpad");
3004 empathy_call_window_update_sidebar_buttons (window, dialpad_shown);
3008 empathy_call_window_set_send_video (EmpathyCallWindow *window,
3011 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3012 TpyCallChannel *call;
3014 priv->sending_video = (state == CAMERA_STATE_ON);
3016 if (state == CAMERA_STATE_ON)
3018 /* When we start sending video, we want to show the video preview by
3020 display_video_preview (window, TRUE);
3024 display_video_preview (window, FALSE);
3027 if (priv->call_state != CONNECTED)
3030 g_object_get (priv->handler, "call-channel", &call, NULL);
3031 DEBUG ("%s sending video", priv->sending_video ? "start": "stop");
3032 tpy_call_channel_send_video (call, priv->sending_video);
3033 g_object_unref (call);
3037 empathy_call_window_mic_toggled_cb (GtkToggleToolButton *toggle,
3038 EmpathyCallWindow *window)
3040 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3043 active = (gtk_toggle_tool_button_get_active (toggle));
3047 empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
3049 gtk_adjustment_set_value (priv->audio_input_adj, priv->volume * 100);
3053 /* TODO, Instead of setting the input volume to 0 we should probably
3054 * stop sending but this would cause the audio call to drop if both
3055 * sides mute at the same time on certain CMs AFAIK. Need to revisit this
3056 * in the future. GNOME #574574
3058 empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
3060 gtk_adjustment_set_value (priv->audio_input_adj, 0);
3065 empathy_call_window_sidebar_hidden_cb (EvSidebar *sidebar,
3066 EmpathyCallWindow *window)
3068 empathy_call_window_show_sidebar (window, FALSE);
3072 empathy_call_window_sidebar_shown_cb (EvSidebar *sidebar,
3073 EmpathyCallWindow *window)
3075 empathy_call_window_show_sidebar (window, TRUE);
3079 empathy_call_window_sidebar_changed_cb (EvSidebar *sidebar,
3081 EmpathyCallWindow *window)
3083 empathy_call_window_update_sidebar_buttons (window,
3084 !tp_strdiff (page, "dialpad"));
3088 empathy_call_window_hangup_cb (gpointer object,
3089 EmpathyCallWindow *window)
3091 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3093 empathy_call_handler_stop_call (priv->handler);
3095 if (empathy_call_window_disconnected (window, FALSE))
3096 gtk_widget_destroy (GTK_WIDGET (window));
3100 empathy_call_window_restart_call (EmpathyCallWindow *window)
3102 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3104 /* Remove error info bars */
3105 gtk_container_forall (GTK_CONTAINER (priv->errors_vbox),
3106 (GtkCallback) gtk_widget_destroy, NULL);
3108 create_video_output_widget (window);
3110 g_signal_connect (G_OBJECT (priv->audio_input_adj), "value-changed",
3111 G_CALLBACK (empathy_call_window_mic_volume_changed_cb), window);
3113 /* While the call was disconnected, the input volume might have changed.
3114 * However, since the audio_input source was destroyed, its volume has not
3115 * been updated during that time. That's why we manually update it here */
3116 empathy_call_window_mic_volume_changed_cb (priv->audio_input_adj, window);
3118 priv->outgoing = TRUE;
3119 empathy_call_window_set_state_connecting (window);
3121 if (priv->pipeline_playing)
3122 start_call (window);
3124 /* call will be started when the pipeline is ready */
3125 priv->start_call_when_playing = TRUE;
3128 empathy_call_window_setup_avatars (window, priv->handler);
3130 gtk_action_set_sensitive (priv->redial, FALSE);
3131 gtk_widget_set_sensitive (priv->redial_button, FALSE);
3135 empathy_call_window_redial_cb (gpointer object,
3136 EmpathyCallWindow *window)
3138 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3140 if (priv->call_state == CONNECTED)
3141 priv->call_state = REDIALING;
3143 empathy_call_handler_stop_call (priv->handler);
3145 if (priv->call_state != CONNECTED)
3146 empathy_call_window_restart_call (window);
3150 empathy_call_window_dialpad_cb (GtkToggleToolButton *button,
3151 EmpathyCallWindow *window)
3153 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3156 active = gtk_toggle_tool_button_get_active (button);
3159 ev_sidebar_set_current_page (EV_SIDEBAR (priv->sidebar), "dialpad");
3161 empathy_call_window_show_sidebar (window, active);
3165 empathy_call_window_sidebar_cb (GtkToggleAction *menu,
3166 EmpathyCallWindow *self)
3168 empathy_call_window_show_sidebar (self,
3169 gtk_toggle_action_get_active (menu));
3173 empathy_call_window_fullscreen_cb (gpointer object,
3174 EmpathyCallWindow *window)
3176 empathy_call_window_fullscreen_toggle (window);
3180 empathy_call_window_fullscreen_toggle (EmpathyCallWindow *window)
3182 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3184 if (priv->is_fullscreen)
3185 gtk_window_unfullscreen (GTK_WINDOW (window));
3187 gtk_window_fullscreen (GTK_WINDOW (window));
3191 empathy_call_window_video_button_press_cb (GtkWidget *video_preview,
3192 GdkEventButton *event, EmpathyCallWindow *window)
3194 if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
3196 empathy_call_window_video_menu_popup (window, event->button);
3204 empathy_call_window_key_press_cb (GtkWidget *video_output,
3205 GdkEventKey *event, EmpathyCallWindow *window)
3207 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3209 if (priv->is_fullscreen && event->keyval == GDK_KEY_Escape)
3211 /* Since we are in fullscreen mode, toggling will bring us back to
3213 empathy_call_window_fullscreen_toggle (window);
3221 empathy_call_window_video_output_motion_notify (GtkWidget *widget,
3222 GdkEventMotion *event, EmpathyCallWindow *window)
3224 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3226 if (priv->is_fullscreen)
3228 empathy_call_window_fullscreen_show_popup (priv->fullscreen);
3235 empathy_call_window_video_menu_popup (EmpathyCallWindow *window,
3239 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3241 menu = gtk_ui_manager_get_widget (priv->ui_manager,
3243 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
3244 button, gtk_get_current_event_time ());
3245 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
3249 empathy_call_window_status_message (EmpathyCallWindow *self,
3252 gtk_label_set_label (GTK_LABEL (self->priv->status_label), message);
3256 empathy_call_window_volume_changed_cb (GtkScaleButton *button,
3257 gdouble value, EmpathyCallWindow *window)
3259 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3261 if (priv->audio_output == NULL)
3264 empathy_audio_sink_set_volume (EMPATHY_GST_AUDIO_SINK (priv->audio_output),