2 * empathy-call-window.c - Source for EmpathyCallWindow
3 * Copyright (C) 2008-2011 Collabora Ltd.
4 * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 #include <gdk/gdkkeysyms.h>
30 #include <glib/gi18n.h>
32 #include <clutter/clutter.h>
33 #include <clutter-gtk/clutter-gtk.h>
34 #include <clutter-gst/clutter-gst.h>
36 #include <telepathy-glib/util.h>
37 #include <telepathy-farstream/telepathy-farstream.h>
38 #include <telepathy-glib/util.h>
40 #include <gst/farsight/fs-element-added-notifier.h>
41 #include <gst/farsight/fs-utils.h>
43 #include <libempathy/empathy-camera-monitor.h>
44 #include <libempathy/empathy-gsettings.h>
45 #include <libempathy/empathy-tp-contact-factory.h>
46 #include <libempathy/empathy-request-util.h>
47 #include <libempathy/empathy-utils.h>
49 #include <libempathy-gtk/empathy-avatar-image.h>
50 #include <libempathy-gtk/empathy-ui-utils.h>
51 #include <libempathy-gtk/empathy-sound-manager.h>
52 #include <libempathy-gtk/empathy-geometry.h>
53 #include <libempathy-gtk/empathy-images.h>
55 #define DEBUG_FLAG EMPATHY_DEBUG_VOIP
56 #include <libempathy/empathy-debug.h>
58 #include "empathy-call-window.h"
59 #include "empathy-call-window-fullscreen.h"
60 #include "empathy-call-factory.h"
61 #include "empathy-video-widget.h"
62 #include "empathy-about-dialog.h"
63 #include "empathy-audio-src.h"
64 #include "empathy-audio-sink.h"
65 #include "empathy-video-src.h"
66 #include "empathy-mic-menu.h"
67 #include "empathy-preferences.h"
68 #include "empathy-rounded-actor.h"
69 #include "empathy-rounded-rectangle.h"
70 #include "empathy-rounded-texture.h"
71 #include "empathy-camera-menu.h"
73 #define CONTENT_HBOX_BORDER_WIDTH 6
74 #define CONTENT_HBOX_SPACING 3
75 #define CONTENT_HBOX_CHILDREN_PACKING_PADDING 3
77 #define SELF_VIDEO_SECTION_WIDTH 120
78 #define SELF_VIDEO_SECTION_HEIGHT 90
79 #define SELF_VIDEO_SECTION_MARGIN 10
81 #define FLOATING_TOOLBAR_OPACITY 192
82 #define FLOATING_TOOLBAR_WIDTH 280
83 #define FLOATING_TOOLBAR_HEIGHT 36
84 #define FLOATING_TOOLBAR_SPACING 20
86 /* The avatar's default width and height are set to the same value because we
87 want a square icon. */
88 #define REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH EMPATHY_VIDEO_WIDGET_DEFAULT_HEIGHT
89 #define REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT \
90 EMPATHY_VIDEO_WIDGET_DEFAULT_HEIGHT
92 #define SMALL_TOOLBAR_SIZE 36
94 /* If an video input error occurs, the error message will start with "v4l" */
95 #define VIDEO_INPUT_ERROR_PREFIX "v4l"
97 /* The time interval in milliseconds between 2 outgoing rings */
98 #define MS_BETWEEN_RING 500
100 G_DEFINE_TYPE(EmpathyCallWindow, empathy_call_window, GTK_TYPE_WINDOW)
103 PROP_CALL_HANDLER = 1,
107 RINGING, /* Incoming call */
108 CONNECTING, /* Outgoing call */
109 CONNECTED, /* Connected */
110 HELD, /* Connected, but on hold */
111 DISCONNECTED, /* Disconnected */
112 REDIALING /* Redialing (special case of CONNECTING) */
116 CAMERA_STATE_OFF = 0,
122 PREVIEW_POS_TOP_LEFT,
123 PREVIEW_POS_TOP_RIGHT,
124 PREVIEW_POS_BOTTOM_LEFT,
125 PREVIEW_POS_BOTTOM_RIGHT,
128 struct _EmpathyCallWindowPriv
130 gboolean dispose_has_run;
131 EmpathyCallHandler *handler;
133 EmpathyContact *contact;
135 EmpathyCameraMonitor *camera_monitor;
140 GtkUIManager *ui_manager;
141 GtkWidget *errors_vbox;
142 /* widget displays the video received from the remote user. This widget is
143 * alive only during call. */
144 ClutterActor *video_output;
145 ClutterActor *video_preview;
146 ClutterActor *drag_preview;
147 ClutterActor *preview_shown_button;
148 ClutterActor *preview_hidden_button;
149 ClutterActor *preview_rectangle1;
150 ClutterActor *preview_rectangle2;
151 ClutterActor *preview_rectangle3;
152 ClutterActor *preview_rectangle4;
153 ClutterActor *preview_rectangle_box1;
154 ClutterActor *preview_rectangle_box2;
155 ClutterActor *preview_rectangle_box3;
156 ClutterActor *preview_rectangle_box4;
157 GtkWidget *video_container;
158 GtkWidget *remote_user_avatar_widget;
159 GtkWidget *remote_user_avatar_toolbar;
160 GtkWidget *remote_user_name_toolbar;
161 GtkWidget *status_label;
162 GtkWidget *hangup_button;
163 GtkWidget *audio_call_button;
164 GtkWidget *video_call_button;
165 GtkWidget *mic_button;
166 GtkWidget *camera_button;
167 GtkWidget *dialpad_button;
169 GtkWidget *bottom_toolbar;
170 ClutterActor *floating_toolbar;
172 GtkAction *menu_fullscreen;
173 GtkAction *menu_swap_camera;
175 ClutterState *transitions;
177 /* The box that contains self and remote avatar and video
178 input/output. When we redial, we destroy and re-create the box */
179 ClutterActor *video_box;
180 ClutterLayoutManager *video_layout;
182 /* Coordinates of the preview drag event's start. */
183 PreviewPosition preview_pos;
185 /* We keep a reference on the hbox which contains the main content so we can
186 easilly repack everything when toggling fullscreen */
187 GtkWidget *content_hbox;
189 /* These are used to accept or reject an incoming call when the status
191 GtkWidget *incoming_call_dialog;
192 TpyCallChannel *pending_channel;
193 TpChannelDispatchOperation *pending_cdo;
194 TpAddDispatchOperationContext *pending_context;
196 gulong video_output_motion_handler_id;
197 guint bus_message_source_id;
201 /* String that contains the queued tones to send after the current ones
204 gboolean sending_tones;
205 GtkWidget *dtmf_panel;
208 GtkWidget *details_vbox;
209 GtkWidget *vcodec_encoding_label;
210 GtkWidget *acodec_encoding_label;
211 GtkWidget *vcodec_decoding_label;
212 GtkWidget *acodec_decoding_label;
214 GtkWidget *audio_remote_candidate_label;
215 GtkWidget *audio_local_candidate_label;
216 GtkWidget *video_remote_candidate_label;
217 GtkWidget *video_local_candidate_label;
218 GtkWidget *video_remote_candidate_info_img;
219 GtkWidget *video_local_candidate_info_img;
220 GtkWidget *audio_remote_candidate_info_img;
221 GtkWidget *audio_local_candidate_info_img;
223 GstElement *video_input;
224 GstElement *video_preview_sink;
225 GstElement *video_output_sink;
226 GstElement *audio_input;
227 GstElement *audio_output;
228 GstElement *pipeline;
229 GstElement *video_tee;
239 gboolean call_started;
240 gboolean sending_video;
241 CameraState camera_state;
243 EmpathyCallWindowFullscreen *fullscreen;
244 gboolean is_fullscreen;
249 guint inactivity_src;
251 /* Those fields represent the state of the window before it actually was in
253 gboolean dialpad_was_visible_before_fs;
254 gint original_width_before_fs;
255 gint original_height_before_fs;
257 gint x, y, w, h, dialpad_width;
260 /* TRUE if the call should be started when the pipeline is playing */
261 gboolean start_call_when_playing;
262 /* TRUE if we requested to set the pipeline in the playing state */
263 gboolean pipeline_playing;
265 EmpathySoundManager *sound_mgr;
268 EmpathyMicMenu *mic_menu;
269 EmpathyCameraMenu *camera_menu;
272 #define GET_PRIV(o) (EMPATHY_CALL_WINDOW (o)->priv)
274 static void empathy_call_window_realized_cb (GtkWidget *widget,
275 EmpathyCallWindow *window);
277 static gboolean empathy_call_window_delete_cb (GtkWidget *widget,
278 GdkEvent *event, EmpathyCallWindow *window);
280 static gboolean empathy_call_window_state_event_cb (GtkWidget *widget,
281 GdkEventWindowState *event, EmpathyCallWindow *window);
283 static void empathy_call_window_set_send_video (EmpathyCallWindow *window,
286 static void empathy_call_window_mic_toggled_cb (
287 GtkToggleToolButton *toggle, EmpathyCallWindow *window);
289 static void empathy_call_window_hangup_cb (gpointer object,
290 EmpathyCallWindow *window);
292 static void empathy_call_window_fullscreen_cb (gpointer object,
293 EmpathyCallWindow *window);
295 static void empathy_call_window_fullscreen_toggle (EmpathyCallWindow *window);
297 static gboolean empathy_call_window_video_button_press_cb (
298 GtkWidget *video_output, GdkEventButton *event, EmpathyCallWindow *window);
300 static gboolean empathy_call_window_key_press_cb (GtkWidget *video_output,
301 GdkEventKey *event, EmpathyCallWindow *window);
303 static gboolean empathy_call_window_video_output_motion_notify (
304 GtkWidget *widget, GdkEventMotion *event, EmpathyCallWindow *window);
306 static void empathy_call_window_video_menu_popup (EmpathyCallWindow *window,
309 static void empathy_call_window_connect_handler (EmpathyCallWindow *self);
311 static void empathy_call_window_dialpad_cb (GtkToggleToolButton *button,
312 EmpathyCallWindow *window);
314 static void empathy_call_window_restart_call (EmpathyCallWindow *window);
316 static void empathy_call_window_status_message (EmpathyCallWindow *window,
319 static gboolean empathy_call_window_bus_message (GstBus *bus,
320 GstMessage *message, gpointer user_data);
323 empathy_call_window_volume_changed_cb (GtkScaleButton *button,
324 gdouble value, EmpathyCallWindow *window);
327 empathy_call_window_show_hangup_button (EmpathyCallWindow *self,
330 gtk_widget_set_visible (self->priv->hangup_button, show);
331 gtk_widget_set_visible (self->priv->audio_call_button, !show);
332 gtk_widget_set_visible (self->priv->video_call_button, !show);
336 empathy_call_window_audio_call_cb (GtkToggleToolButton *button,
337 EmpathyCallWindow *self)
339 g_object_set (self->priv->handler, "initial-video", FALSE, NULL);
340 empathy_call_window_restart_call (self);
344 empathy_call_window_video_call_cb (GtkToggleToolButton *button,
345 EmpathyCallWindow *self)
347 empathy_call_window_set_send_video (self, CAMERA_STATE_ON);
348 g_object_set (self->priv->handler, "initial-video", TRUE, NULL);
349 empathy_call_window_restart_call (self);
353 empathy_call_window_emit_tones (EmpathyCallWindow *self)
357 if (tp_str_empty (self->priv->tones->str))
360 g_object_get (self->priv->handler, "call-channel", &channel, NULL);
362 DEBUG ("Emitting multiple tones: %s", self->priv->tones->str);
364 tp_cli_channel_interface_dtmf_call_multiple_tones (channel, -1,
365 self->priv->tones->str,
366 NULL, NULL, NULL, NULL);
368 self->priv->sending_tones = TRUE;
370 g_string_set_size (self->priv->tones, 0);
372 g_object_unref (channel);
376 empathy_call_window_maybe_emit_tones (EmpathyCallWindow *self)
378 if (self->priv->sending_tones)
381 empathy_call_window_emit_tones (self);
385 empathy_call_window_tones_stopped_cb (TpChannel *proxy,
386 gboolean arg_cancelled,
388 GObject *weak_object)
390 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
392 self->priv->sending_tones = FALSE;
394 empathy_call_window_emit_tones (self);
398 dtmf_button_pressed_cb (GtkButton *button,
399 EmpathyCallWindow *self)
401 EmpathyCallWindowPriv *priv = GET_PRIV (self);
405 button_quark = g_quark_from_static_string (EMPATHY_DTMF_BUTTON_ID);
406 event = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (button),
409 g_string_append_c (priv->tones, tp_dtmf_event_to_char (event));
411 empathy_call_window_maybe_emit_tones (self);
414 /* empathy_create_dtmf_dialpad() requires a callback, even if empty */
416 dtmf_button_released_cb (GtkButton *button,
417 EmpathyCallWindow *self)
422 empathy_call_window_mic_volume_changed (EmpathyCallWindow *self)
424 EmpathyCallWindowPriv *priv = GET_PRIV (self);
427 volume = g_settings_get_double (priv->settings,
428 EMPATHY_PREFS_CALL_SOUND_VOLUME) / 100.0;
430 /* Don't store the volume because of muting */
431 if (volume > 0 || gtk_toggle_tool_button_get_active (
432 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
433 priv->volume = volume;
435 /* Ensure that the toggle button is active if the volume is > 0 and inactive
436 * if it's smaller than 0 */
437 if ((volume > 0) != gtk_toggle_tool_button_get_active (
438 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
439 gtk_toggle_tool_button_set_active (
440 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button), volume > 0);
442 empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
447 empathy_call_window_prefs_volume_changed_cb (GSettings *settings,
449 EmpathyCallWindow *self)
451 empathy_call_window_mic_volume_changed (self);
455 empathy_call_window_raise_actors (EmpathyCallWindow *self)
457 clutter_actor_raise_top (self->priv->floating_toolbar);
459 clutter_actor_raise_top (self->priv->preview_rectangle_box1);
460 clutter_actor_raise_top (self->priv->preview_rectangle_box2);
461 clutter_actor_raise_top (self->priv->preview_rectangle_box3);
462 clutter_actor_raise_top (self->priv->preview_rectangle_box4);
466 empathy_call_window_show_video_output (EmpathyCallWindow *self,
469 if (self->priv->video_output != NULL)
470 g_object_set (self->priv->video_output, "visible", show, NULL);
472 gtk_widget_set_visible (self->priv->remote_user_avatar_widget, !show);
474 empathy_call_window_raise_actors (self);
478 create_video_output_widget (EmpathyCallWindow *self)
480 EmpathyCallWindowPriv *priv = GET_PRIV (self);
482 g_assert (priv->video_output == NULL);
483 g_assert (priv->pipeline != NULL);
485 priv->video_output = clutter_texture_new ();
487 clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (priv->video_output),
490 priv->video_output_sink = clutter_gst_video_sink_new (
491 CLUTTER_TEXTURE (priv->video_output));
493 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_box),
496 gtk_widget_add_events (priv->video_container,
497 GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK);
498 g_signal_connect (G_OBJECT (priv->video_container), "button-press-event",
499 G_CALLBACK (empathy_call_window_video_button_press_cb), self);
503 create_video_input (EmpathyCallWindow *self)
505 EmpathyCallWindowPriv *priv = GET_PRIV (self);
507 g_assert (priv->video_input == NULL);
508 priv->video_input = empathy_video_src_new ();
509 gst_object_ref (priv->video_input);
510 gst_object_sink (priv->video_input);
514 create_audio_input (EmpathyCallWindow *self)
516 EmpathyCallWindowPriv *priv = GET_PRIV (self);
518 g_assert (priv->audio_input == NULL);
519 priv->audio_input = empathy_audio_src_new ();
520 gst_object_ref (priv->audio_input);
521 gst_object_sink (priv->audio_input);
525 add_video_preview_to_pipeline (EmpathyCallWindow *self)
527 EmpathyCallWindowPriv *priv = GET_PRIV (self);
530 g_assert (priv->video_preview != NULL);
531 g_assert (priv->pipeline != NULL);
532 g_assert (priv->video_input != NULL);
533 g_assert (priv->video_tee != NULL);
535 preview = priv->video_preview_sink;
537 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->video_input))
539 g_warning ("Could not add video input to pipeline");
543 if (!gst_bin_add (GST_BIN (priv->pipeline), preview))
545 g_warning ("Could not add video preview to pipeline");
549 if (!gst_element_link (priv->video_input, priv->video_tee))
551 g_warning ("Could not link video input to video tee");
555 if (!gst_element_link (priv->video_tee, preview))
557 g_warning ("Could not link video tee to video preview");
563 empathy_call_window_disable_camera_cb (GtkAction *action,
564 EmpathyCallWindow *self)
566 clutter_actor_destroy (self->priv->preview_hidden_button);
568 gtk_toggle_tool_button_set_active (
569 GTK_TOGGLE_TOOL_BUTTON (self->priv->camera_button), FALSE);
573 empathy_call_window_minimise_camera_cb (GtkAction *action,
574 EmpathyCallWindow *self)
576 clutter_actor_hide (self->priv->video_preview);
577 clutter_actor_show (self->priv->preview_hidden_button);
581 empathy_call_window_maximise_camera_cb (GtkAction *action,
582 EmpathyCallWindow *self)
584 clutter_actor_show (self->priv->video_preview);
585 clutter_actor_hide (self->priv->preview_hidden_button);
589 empathy_call_window_swap_camera_cb (GtkAction *action,
590 EmpathyCallWindow *self)
592 const GList *cameras, *l;
595 DEBUG ("Swapping the camera");
597 cameras = empathy_camera_monitor_get_cameras (self->priv->camera_monitor);
598 current_cam = empathy_video_src_dup_device (
599 EMPATHY_GST_VIDEO_SRC (self->priv->video_input));
601 for (l = cameras; l != NULL; l = l->next)
603 EmpathyCamera *camera = l->data;
605 if (!tp_strdiff (camera->device, current_cam))
610 next = l->next->data;
612 next = cameras->data;
614 /* EmpathyCameraMenu will update itself and do the actual change
616 g_settings_set_string (self->priv->settings,
617 EMPATHY_PREFS_CALL_CAMERA_DEVICE,
624 g_free (current_cam);
628 empathy_call_window_camera_added_cb (EmpathyCameraMonitor *monitor,
629 EmpathyCamera *camera,
630 EmpathyCallWindow *self)
632 const GList *cameras = empathy_camera_monitor_get_cameras (monitor);
634 gtk_action_set_visible (self->priv->menu_swap_camera,
635 g_list_length ((GList *) cameras) >= 2);
639 empathy_call_window_camera_removed_cb (EmpathyCameraMonitor *monitor,
640 EmpathyCamera *camera,
641 EmpathyCallWindow *self)
643 const GList *cameras = empathy_camera_monitor_get_cameras (monitor);
645 gtk_action_set_visible (self->priv->menu_swap_camera,
646 g_list_length ((GList *) cameras) >= 2);
650 empathy_call_window_preview_button_clicked_cb (GtkButton *button,
651 EmpathyCallWindow *self)
655 menu = gtk_ui_manager_get_widget (self->priv->ui_manager,
657 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
658 0, gtk_get_current_event_time ());
659 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
663 empathy_call_window_preview_hidden_button_clicked_cb (GtkButton *button,
664 EmpathyCallWindow *self)
668 menu = gtk_ui_manager_get_widget (self->priv->ui_manager,
669 "/preview-hidden-menu");
670 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
671 0, gtk_get_current_event_time ());
672 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
675 static ClutterActor *
676 empathy_call_window_create_preview_rectangle (EmpathyCallWindow *self,
678 ClutterBinAlignment x,
679 ClutterBinAlignment y)
681 ClutterLayoutManager *layout1, *layout2;
682 ClutterActor *rectangle;
683 ClutterActor *box1, *box2;
685 layout1 = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
686 CLUTTER_BIN_ALIGNMENT_START);
688 box1 = clutter_box_new (layout1);
692 rectangle = empathy_rounded_rectangle_new (
693 SELF_VIDEO_SECTION_WIDTH + 5,
694 SELF_VIDEO_SECTION_HEIGHT + 5);
696 clutter_actor_set_size (box1,
697 SELF_VIDEO_SECTION_WIDTH + 2 * SELF_VIDEO_SECTION_MARGIN,
698 SELF_VIDEO_SECTION_HEIGHT + 2 * SELF_VIDEO_SECTION_MARGIN +
699 FLOATING_TOOLBAR_HEIGHT + FLOATING_TOOLBAR_SPACING);
701 layout2 = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
702 CLUTTER_BIN_ALIGNMENT_CENTER);
704 /* We have a box with the margins and the video in the middle inside
705 * a bigger box with an extra bottom margin so we're not on top of
706 * the floating toolbar. */
707 box2 = clutter_box_new (layout2);
709 clutter_actor_set_size (box2,
710 SELF_VIDEO_SECTION_WIDTH + 2 * SELF_VIDEO_SECTION_MARGIN,
711 SELF_VIDEO_SECTION_HEIGHT + 2 * SELF_VIDEO_SECTION_MARGIN);
713 clutter_container_add_actor (CLUTTER_CONTAINER (box1), box2);
714 clutter_container_add_actor (CLUTTER_CONTAINER (box2), rectangle);
716 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (self->priv->video_layout),
719 clutter_actor_hide (rectangle);
725 empathy_call_window_create_preview_rectangles (EmpathyCallWindow *self)
727 self->priv->preview_rectangle1 =
728 empathy_call_window_create_preview_rectangle (self,
729 &self->priv->preview_rectangle_box1,
730 CLUTTER_BIN_ALIGNMENT_START, CLUTTER_BIN_ALIGNMENT_START);
731 self->priv->preview_rectangle2 =
732 empathy_call_window_create_preview_rectangle (self,
733 &self->priv->preview_rectangle_box2,
734 CLUTTER_BIN_ALIGNMENT_START, CLUTTER_BIN_ALIGNMENT_END);
735 self->priv->preview_rectangle3 =
736 empathy_call_window_create_preview_rectangle (self,
737 &self->priv->preview_rectangle_box3,
738 CLUTTER_BIN_ALIGNMENT_END, CLUTTER_BIN_ALIGNMENT_START);
739 self->priv->preview_rectangle4 =
740 empathy_call_window_create_preview_rectangle (self,
741 &self->priv->preview_rectangle_box4,
742 CLUTTER_BIN_ALIGNMENT_END, CLUTTER_BIN_ALIGNMENT_END);
746 empathy_call_window_show_preview_rectangles (EmpathyCallWindow *self,
749 g_object_set (self->priv->preview_rectangle1, "visible", show, NULL);
750 g_object_set (self->priv->preview_rectangle2, "visible", show, NULL);
751 g_object_set (self->priv->preview_rectangle3, "visible", show, NULL);
752 g_object_set (self->priv->preview_rectangle4, "visible", show, NULL);
755 static PreviewPosition
756 empathy_call_window_get_preview_position (EmpathyCallWindow *self,
761 PreviewPosition pos = PREVIEW_POS_NONE;
763 if (!clutter_actor_has_allocation (self->priv->video_box))
766 clutter_actor_get_geometry (self->priv->video_box, &box);
768 if (0 + SELF_VIDEO_SECTION_MARGIN <= event_x &&
769 event_x <= (0 + SELF_VIDEO_SECTION_MARGIN + (gint) SELF_VIDEO_SECTION_WIDTH) &&
770 0 + SELF_VIDEO_SECTION_MARGIN <= event_y &&
771 event_y <= (0 + SELF_VIDEO_SECTION_MARGIN + (gint) SELF_VIDEO_SECTION_HEIGHT))
773 pos = PREVIEW_POS_TOP_LEFT;
775 else if (box.width - SELF_VIDEO_SECTION_MARGIN >= event_x &&
776 event_x >= (box.width - SELF_VIDEO_SECTION_MARGIN - (gint) SELF_VIDEO_SECTION_WIDTH) &&
777 0 + SELF_VIDEO_SECTION_MARGIN <= event_y &&
778 event_y <= (0 + SELF_VIDEO_SECTION_MARGIN + (gint) SELF_VIDEO_SECTION_HEIGHT))
780 pos = PREVIEW_POS_TOP_RIGHT;
782 else if (0 + SELF_VIDEO_SECTION_MARGIN <= event_x &&
783 event_x <= (0 + SELF_VIDEO_SECTION_MARGIN + (gint) SELF_VIDEO_SECTION_WIDTH) &&
784 box.height - SELF_VIDEO_SECTION_MARGIN - FLOATING_TOOLBAR_HEIGHT - FLOATING_TOOLBAR_SPACING >= event_y &&
785 event_y >= (box.height - SELF_VIDEO_SECTION_MARGIN - FLOATING_TOOLBAR_HEIGHT - FLOATING_TOOLBAR_SPACING - (gint) SELF_VIDEO_SECTION_HEIGHT))
787 pos = PREVIEW_POS_BOTTOM_LEFT;
789 else if (box.width - SELF_VIDEO_SECTION_MARGIN >= event_x &&
790 event_x >= (box.width - SELF_VIDEO_SECTION_MARGIN - (gint) SELF_VIDEO_SECTION_WIDTH) &&
791 box.height - SELF_VIDEO_SECTION_MARGIN - SELF_VIDEO_SECTION_MARGIN - FLOATING_TOOLBAR_HEIGHT - FLOATING_TOOLBAR_SPACING >= event_y &&
792 event_y >= (box.height - SELF_VIDEO_SECTION_MARGIN - FLOATING_TOOLBAR_HEIGHT - FLOATING_TOOLBAR_SPACING - (gint) SELF_VIDEO_SECTION_HEIGHT))
794 pos = PREVIEW_POS_BOTTOM_RIGHT;
800 static ClutterActor *
801 empathy_call_window_get_preview_rectangle (EmpathyCallWindow *self,
804 ClutterActor *rectangle;
808 case PREVIEW_POS_TOP_LEFT:
809 rectangle = self->priv->preview_rectangle1;
811 case PREVIEW_POS_TOP_RIGHT:
812 rectangle = self->priv->preview_rectangle3;
814 case PREVIEW_POS_BOTTOM_LEFT:
815 rectangle = self->priv->preview_rectangle2;
817 case PREVIEW_POS_BOTTOM_RIGHT:
818 rectangle = self->priv->preview_rectangle4;
828 empathy_call_window_move_video_preview (EmpathyCallWindow *self,
831 ClutterBinLayout *layout = CLUTTER_BIN_LAYOUT (self->priv->video_layout);
833 DEBUG ("moving the video preview to %d", pos);
835 self->priv->preview_pos = pos;
839 case PREVIEW_POS_TOP_LEFT:
840 clutter_bin_layout_set_alignment (layout,
841 self->priv->video_preview,
842 CLUTTER_BIN_ALIGNMENT_START,
843 CLUTTER_BIN_ALIGNMENT_START);
845 case PREVIEW_POS_TOP_RIGHT:
846 clutter_bin_layout_set_alignment (layout,
847 self->priv->video_preview,
848 CLUTTER_BIN_ALIGNMENT_END,
849 CLUTTER_BIN_ALIGNMENT_START);
851 case PREVIEW_POS_BOTTOM_LEFT:
852 clutter_bin_layout_set_alignment (layout,
853 self->priv->video_preview,
854 CLUTTER_BIN_ALIGNMENT_START,
855 CLUTTER_BIN_ALIGNMENT_END);
857 case PREVIEW_POS_BOTTOM_RIGHT:
858 clutter_bin_layout_set_alignment (layout,
859 self->priv->video_preview,
860 CLUTTER_BIN_ALIGNMENT_END,
861 CLUTTER_BIN_ALIGNMENT_END);
864 g_warn_if_reached ();
867 g_settings_set_enum (self->priv->settings, "camera-position", pos);
871 empathy_call_window_highlight_preview_rectangle (EmpathyCallWindow *self,
874 ClutterActor *rectangle;
876 rectangle = empathy_call_window_get_preview_rectangle (self, pos);
878 empathy_rounded_rectangle_set_border_width (
879 EMPATHY_ROUNDED_RECTANGLE (rectangle), 5);
880 empathy_rounded_rectangle_set_border_color (
881 EMPATHY_ROUNDED_RECTANGLE (rectangle), CLUTTER_COLOR_Red);
885 empathy_call_window_darken_preview_rectangle (EmpathyCallWindow *self,
886 ClutterActor *rectangle)
888 empathy_rounded_rectangle_set_border_width (
889 EMPATHY_ROUNDED_RECTANGLE (rectangle), 1);
890 empathy_rounded_rectangle_set_border_color (
891 EMPATHY_ROUNDED_RECTANGLE (rectangle), CLUTTER_COLOR_Black);
895 empathy_call_window_darken_preview_rectangles (EmpathyCallWindow *self)
897 ClutterActor *rectangle;
899 rectangle = empathy_call_window_get_preview_rectangle (self,
900 self->priv->preview_pos);
902 /* We don't want to darken the rectangle where the preview
905 if (self->priv->preview_rectangle1 != rectangle)
906 empathy_call_window_darken_preview_rectangle (self,
907 self->priv->preview_rectangle1);
909 if (self->priv->preview_rectangle2 != rectangle)
910 empathy_call_window_darken_preview_rectangle (self,
911 self->priv->preview_rectangle2);
913 if (self->priv->preview_rectangle3 != rectangle)
914 empathy_call_window_darken_preview_rectangle (self,
915 self->priv->preview_rectangle3);
917 if (self->priv->preview_rectangle4 != rectangle)
918 empathy_call_window_darken_preview_rectangle (self,
919 self->priv->preview_rectangle4);
923 empathy_call_window_preview_on_drag_begin_cb (ClutterDragAction *action,
927 ClutterModifierType modifiers,
928 EmpathyCallWindow *self)
930 ClutterActor *stage = clutter_actor_get_stage (actor);
933 self->priv->drag_preview = clutter_clone_new (actor);
935 clutter_container_add_actor (CLUTTER_CONTAINER (stage),
936 self->priv->drag_preview);
938 clutter_actor_transform_stage_point (actor, event_x, event_y,
941 clutter_actor_set_position (self->priv->drag_preview,
942 event_x - rel_x, event_y - rel_y);
944 clutter_drag_action_set_drag_handle (action,
945 self->priv->drag_preview);
947 clutter_actor_set_opacity (actor, 0);
948 clutter_actor_hide (self->priv->preview_shown_button);
950 empathy_call_window_show_preview_rectangles (self, TRUE);
951 empathy_call_window_darken_preview_rectangles (self);
955 empathy_call_window_preview_on_drag_end_cb (ClutterDragAction *action,
959 ClutterModifierType modifiers,
960 EmpathyCallWindow *self)
964 /* Get the position before destroying the drag actor, otherwise the
965 * preview_box allocation won't be valid and we won't be able to
966 * calculate the position. */
967 pos = empathy_call_window_get_preview_position (self, event_x, event_y);
969 /* Destroy the video preview copy that we were dragging */
970 clutter_actor_destroy (self->priv->drag_preview);
971 self->priv->drag_preview = NULL;
973 clutter_actor_set_opacity (actor, 255);
974 clutter_actor_show (self->priv->preview_shown_button);
976 if (pos != PREVIEW_POS_NONE)
977 empathy_call_window_move_video_preview (self, pos);
979 empathy_call_window_show_preview_rectangles (self, FALSE);
983 empathy_call_window_preview_on_drag_motion_cb (ClutterDragAction *action,
987 EmpathyCallWindow *self)
990 gfloat event_x, event_y;
992 clutter_drag_action_get_motion_coords (action, &event_x, &event_y);
994 pos = empathy_call_window_get_preview_position (self, event_x, event_y);
996 if (pos != PREVIEW_POS_NONE)
997 empathy_call_window_highlight_preview_rectangle (self, pos);
999 empathy_call_window_darken_preview_rectangles (self);
1003 empathy_call_window_preview_enter_event_cb (ClutterActor *actor,
1004 ClutterCrossingEvent *event,
1005 EmpathyCallWindow *self)
1007 ClutterActor *rectangle;
1009 rectangle = empathy_call_window_get_preview_rectangle (self,
1010 self->priv->preview_pos);
1012 empathy_call_window_highlight_preview_rectangle (self,
1013 self->priv->preview_pos);
1015 clutter_actor_show (rectangle);
1021 empathy_call_window_preview_leave_event_cb (ClutterActor *actor,
1022 ClutterCrossingEvent *event,
1023 EmpathyCallWindow *self)
1025 ClutterActor *rectangle;
1027 rectangle = empathy_call_window_get_preview_rectangle (self,
1028 self->priv->preview_pos);
1030 empathy_call_window_darken_preview_rectangle (self, rectangle);
1032 clutter_actor_hide (rectangle);
1038 create_video_preview (EmpathyCallWindow *self)
1040 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1041 ClutterLayoutManager *layout, *layout_center, *layout_end;
1042 ClutterActor *preview;
1045 ClutterAction *action;
1047 PreviewPosition pos;
1049 g_assert (priv->video_preview == NULL);
1051 pos = g_settings_get_enum (priv->settings, "camera-position");
1053 preview = empathy_rounded_texture_new ();
1054 clutter_actor_set_size (preview,
1055 SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGHT);
1056 priv->video_preview_sink = clutter_gst_video_sink_new (
1057 CLUTTER_TEXTURE (preview));
1059 /* Add a little offset to the video preview */
1060 layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
1061 CLUTTER_BIN_ALIGNMENT_START);
1062 priv->video_preview = clutter_box_new (layout);
1063 clutter_actor_set_size (priv->video_preview,
1064 SELF_VIDEO_SECTION_WIDTH + 2 * SELF_VIDEO_SECTION_MARGIN,
1065 SELF_VIDEO_SECTION_HEIGHT + 2 * SELF_VIDEO_SECTION_MARGIN +
1066 FLOATING_TOOLBAR_HEIGHT + FLOATING_TOOLBAR_SPACING);
1068 /* We have a box with the margins and the video in the middle inside
1069 * a bigger box with an extra bottom margin so we're not on top of
1070 * the floating toolbar. */
1071 layout_center = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
1072 CLUTTER_BIN_ALIGNMENT_CENTER);
1073 box = clutter_box_new (layout_center);
1074 clutter_actor_set_size (box,
1075 SELF_VIDEO_SECTION_WIDTH + 2 * SELF_VIDEO_SECTION_MARGIN,
1076 SELF_VIDEO_SECTION_HEIGHT + 2 * SELF_VIDEO_SECTION_MARGIN);
1078 clutter_container_add_actor (CLUTTER_CONTAINER (box), preview);
1079 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_preview), box);
1081 g_object_set (priv->video_preview_sink,
1086 /* Translators: this is an "Info" label. It should be as short
1088 button = gtk_button_new_with_label (_("i"));
1089 priv->preview_shown_button = b = empathy_rounded_actor_new ();
1091 GTK_CONTAINER (gtk_clutter_actor_get_widget (GTK_CLUTTER_ACTOR (b))),
1093 clutter_actor_set_size (b, 24, 24);
1095 layout_end = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_END,
1096 CLUTTER_BIN_ALIGNMENT_END);
1097 box = clutter_box_new (layout_end);
1098 clutter_actor_set_size (box,
1099 SELF_VIDEO_SECTION_WIDTH,
1100 SELF_VIDEO_SECTION_HEIGHT + SELF_VIDEO_SECTION_MARGIN);
1102 clutter_container_add_actor (CLUTTER_CONTAINER (box), b);
1103 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_preview), box);
1105 g_signal_connect (button, "clicked",
1106 G_CALLBACK (empathy_call_window_preview_button_clicked_cb),
1109 /* Translators: this is an "Info" label. It should be as short
1111 button = gtk_button_new_with_label (_("i"));
1112 b = empathy_rounded_actor_new ();
1114 GTK_CONTAINER (gtk_clutter_actor_get_widget (GTK_CLUTTER_ACTOR (b))),
1116 clutter_actor_set_size (b, 24, 24);
1117 priv->preview_hidden_button = b;
1119 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
1120 priv->preview_hidden_button,
1121 CLUTTER_BIN_ALIGNMENT_START,
1122 CLUTTER_BIN_ALIGNMENT_END);
1124 self->priv->preview_pos = PREVIEW_POS_BOTTOM_LEFT;
1126 clutter_actor_hide (priv->preview_hidden_button);
1128 g_signal_connect (button, "clicked",
1129 G_CALLBACK (empathy_call_window_preview_hidden_button_clicked_cb),
1132 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
1133 priv->video_preview,
1134 CLUTTER_BIN_ALIGNMENT_START,
1135 CLUTTER_BIN_ALIGNMENT_END);
1137 empathy_call_window_move_video_preview (self, pos);
1139 action = clutter_drag_action_new ();
1140 g_signal_connect (action, "drag-begin",
1141 G_CALLBACK (empathy_call_window_preview_on_drag_begin_cb), self);
1142 g_signal_connect (action, "drag-end",
1143 G_CALLBACK (empathy_call_window_preview_on_drag_end_cb), self);
1144 g_signal_connect (action, "drag-motion",
1145 G_CALLBACK (empathy_call_window_preview_on_drag_motion_cb), self);
1147 g_signal_connect (preview, "enter-event",
1148 G_CALLBACK (empathy_call_window_preview_enter_event_cb), self);
1149 g_signal_connect (preview, "leave-event",
1150 G_CALLBACK (empathy_call_window_preview_leave_event_cb), self);
1152 clutter_actor_add_action (preview, action);
1153 clutter_actor_set_reactive (preview, TRUE);
1154 clutter_actor_set_reactive (priv->preview_shown_button, TRUE);
1158 empathy_call_window_play_camera (EmpathyCallWindow *window,
1161 EmpathyCallWindowPriv *priv = GET_PRIV (window);
1162 GstElement *preview;
1165 if (priv->video_preview == NULL)
1167 create_video_preview (window);
1168 add_video_preview_to_pipeline (window);
1172 state = GST_STATE_PLAYING;
1174 state = GST_STATE_NULL;
1176 preview = priv->video_preview_sink;
1178 gst_element_set_state (preview, state);
1179 gst_element_set_state (priv->video_input, state);
1180 gst_element_set_state (priv->video_tee, state);
1184 display_video_preview (EmpathyCallWindow *self,
1187 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1191 /* Display the video preview */
1192 DEBUG ("Show video preview");
1194 empathy_call_window_play_camera (self, TRUE);
1195 clutter_actor_show (priv->video_preview);
1196 clutter_actor_raise_top (priv->floating_toolbar);
1200 /* Hide the video preview */
1201 DEBUG ("Hide video preview");
1203 if (priv->video_preview != NULL)
1205 clutter_actor_hide (priv->video_preview);
1206 empathy_call_window_play_camera (self, FALSE);
1212 empathy_call_window_set_state_connecting (EmpathyCallWindow *window)
1214 EmpathyCallWindowPriv *priv = GET_PRIV (window);
1216 empathy_call_window_status_message (window, _("Connecting…"));
1217 priv->call_state = CONNECTING;
1219 /* Show the toolbar */
1220 clutter_state_set_state (priv->transitions, "fade-in");
1223 empathy_sound_manager_start_playing (priv->sound_mgr, GTK_WIDGET (window),
1224 EMPATHY_SOUND_PHONE_OUTGOING, MS_BETWEEN_RING);
1228 disable_camera (EmpathyCallWindow *self)
1230 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1232 if (priv->camera_state == CAMERA_STATE_OFF)
1235 DEBUG ("Disable camera");
1237 display_video_preview (self, FALSE);
1239 if (priv->camera_state == CAMERA_STATE_ON)
1240 empathy_call_window_set_send_video (self, CAMERA_STATE_OFF);
1242 priv->camera_state = CAMERA_STATE_OFF;
1246 enable_camera (EmpathyCallWindow *self)
1248 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1250 if (priv->camera_state == CAMERA_STATE_ON)
1253 if (priv->video_input == NULL)
1255 DEBUG ("Can't enable camera, no input");
1259 DEBUG ("Enable camera");
1261 empathy_call_window_set_send_video (self, CAMERA_STATE_ON);
1263 priv->camera_state = CAMERA_STATE_ON;
1267 empathy_call_window_camera_toggled_cb (GtkToggleToolButton *toggle,
1268 EmpathyCallWindow *self)
1270 if (gtk_toggle_tool_button_get_active (toggle))
1271 enable_camera (self);
1273 disable_camera (self);
1277 create_pipeline (EmpathyCallWindow *self)
1279 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1282 g_assert (priv->pipeline == NULL);
1284 priv->pipeline = gst_pipeline_new (NULL);
1285 priv->pipeline_playing = FALSE;
1287 priv->video_tee = gst_element_factory_make ("tee", NULL);
1288 gst_object_ref (priv->video_tee);
1289 gst_object_sink (priv->video_tee);
1291 gst_bin_add (GST_BIN (priv->pipeline), priv->video_tee);
1293 bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
1294 priv->bus_message_source_id = gst_bus_add_watch (bus,
1295 empathy_call_window_bus_message, self);
1297 g_object_unref (bus);
1301 empathy_call_window_settings_cb (GtkAction *action,
1302 EmpathyCallWindow *self)
1304 gchar *args = g_strdup_printf ("-p %s",
1305 empathy_preferences_tab_to_string (EMPATHY_PREFERENCES_TAB_CALLS));
1307 empathy_launch_program (BIN_DIR, "empathy", args);
1313 empathy_call_window_contents_cb (GtkAction *action,
1314 EmpathyCallWindow *self)
1316 empathy_url_show (GTK_WIDGET (self), "ghelp:empathy?audio-video");
1320 empathy_call_window_debug_cb (GtkAction *action,
1321 EmpathyCallWindow *self)
1323 empathy_launch_program (BIN_DIR, "empathy-debugger", "-s Empathy.Call");
1327 empathy_call_window_about_cb (GtkAction *action,
1328 EmpathyCallWindow *self)
1330 empathy_about_dialog_new (GTK_WINDOW (self));
1334 empathy_call_window_toolbar_timeout (gpointer data)
1336 EmpathyCallWindow *self = data;
1338 /* We don't want to hide the toolbar if we're not in a call, as
1339 * to show the call status all the time. */
1340 if (self->priv->call_state != CONNECTING &&
1341 self->priv->call_state != DISCONNECTED)
1342 clutter_state_set_state (self->priv->transitions, "fade-out");
1348 empathy_call_window_motion_notify_cb (GtkWidget *widget,
1350 EmpathyCallWindow *self)
1352 clutter_state_set_state (self->priv->transitions, "fade-in");
1354 if (self->priv->inactivity_src > 0)
1355 g_source_remove (self->priv->inactivity_src);
1357 self->priv->inactivity_src = g_timeout_add_seconds (3,
1358 empathy_call_window_toolbar_timeout, self);
1364 empathy_call_window_configure_event_cb (GtkWidget *widget,
1366 EmpathyCallWindow *self)
1368 GdkWindow *gdk_window;
1369 GdkWindowState window_state;
1371 gtk_window_get_position (GTK_WINDOW (self), &self->priv->x, &self->priv->y);
1372 gtk_window_get_size (GTK_WINDOW (self), &self->priv->w, &self->priv->h);
1374 gtk_widget_get_preferred_width (self->priv->dtmf_panel,
1375 &self->priv->dialpad_width, NULL);
1377 gdk_window = gtk_widget_get_window (widget);
1378 window_state = gdk_window_get_state (gdk_window);
1379 self->priv->maximized = (window_state & GDK_WINDOW_STATE_MAXIMIZED);
1385 empathy_call_window_destroyed_cb (GtkWidget *object,
1386 EmpathyCallWindow *self)
1388 if (gtk_widget_get_visible (self->priv->dtmf_panel))
1390 /* Save the geometry as if the dialpad was hidden. */
1391 empathy_geometry_save_values (GTK_WINDOW (self),
1392 self->priv->x, self->priv->y,
1393 self->priv->w - self->priv->dialpad_width, self->priv->h,
1394 self->priv->maximized);
1399 empathy_call_window_stage_allocation_changed_cb (ClutterActor *stage,
1401 ClutterBindConstraint *constraint)
1403 ClutterActorBox allocation;
1405 clutter_actor_get_allocation_box (stage, &allocation);
1407 clutter_bind_constraint_set_offset (constraint,
1408 allocation.y2 - allocation.y1 -
1409 FLOATING_TOOLBAR_SPACING - FLOATING_TOOLBAR_HEIGHT);
1413 empathy_call_window_incoming_call_response_cb (GtkDialog *dialog,
1415 EmpathyCallWindow *self)
1417 switch (response_id)
1419 case GTK_RESPONSE_ACCEPT:
1420 tp_channel_dispatch_operation_handle_with_async (
1421 self->priv->pending_cdo, EMPATHY_CALL_BUS_NAME, NULL, NULL);
1423 tp_clear_object (&self->priv->pending_cdo);
1424 tp_clear_object (&self->priv->pending_channel);
1425 tp_clear_object (&self->priv->pending_context);
1428 case GTK_RESPONSE_CANCEL:
1429 tp_channel_dispatch_operation_close_channels_async (
1430 self->priv->pending_cdo, NULL, NULL);
1432 empathy_call_window_status_message (self, _("Disconnected"));
1433 self->priv->call_state = DISCONNECTED;
1436 g_warn_if_reached ();
1441 empathy_call_window_set_state_ringing (EmpathyCallWindow *self)
1445 g_assert (self->priv->call_state != CONNECTED);
1447 video = tpy_call_channel_has_initial_video (self->priv->pending_channel);
1449 empathy_call_window_status_message (self, _("Incoming call"));
1450 self->priv->call_state = RINGING;
1452 self->priv->incoming_call_dialog = gtk_message_dialog_new (
1453 GTK_WINDOW (self), GTK_DIALOG_MODAL,
1454 GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
1455 video ? _("Incoming video call from %s") : _("Incoming call from %s"),
1456 empathy_contact_get_alias (self->priv->contact));
1458 gtk_dialog_add_buttons (GTK_DIALOG (self->priv->incoming_call_dialog),
1459 _("Reject"), GTK_RESPONSE_CANCEL,
1460 _("Answer"), GTK_RESPONSE_ACCEPT,
1463 g_signal_connect (self->priv->incoming_call_dialog, "response",
1464 G_CALLBACK (empathy_call_window_incoming_call_response_cb), self);
1465 gtk_widget_show (self->priv->incoming_call_dialog);
1469 empathy_call_window_cdo_invalidated_cb (TpProxy *channel,
1473 EmpathyCallWindow *self)
1475 tp_clear_object (&self->priv->pending_cdo);
1476 tp_clear_object (&self->priv->pending_channel);
1477 tp_clear_object (&self->priv->pending_context);
1479 /* We don't know if the incoming call has been accepted or not, so we
1480 * assume it hasn't and if it has, we'll set the proper status when
1481 * we get the new handler. */
1482 empathy_call_window_status_message (self, _("Disconnected"));
1483 self->priv->call_state = DISCONNECTED;
1485 gtk_widget_destroy (self->priv->incoming_call_dialog);
1486 self->priv->incoming_call_dialog = NULL;
1490 empathy_call_window_start_ringing (EmpathyCallWindow *self,
1491 TpyCallChannel *channel,
1492 TpChannelDispatchOperation *dispatch_operation,
1493 TpAddDispatchOperationContext *context)
1495 g_assert (self->priv->pending_channel == NULL);
1496 g_assert (self->priv->pending_context == NULL);
1497 g_assert (self->priv->pending_cdo == NULL);
1499 /* Start ringing and delay until the user answers or hangs. */
1500 self->priv->pending_channel = g_object_ref (channel);
1501 self->priv->pending_context = g_object_ref (context);
1502 self->priv->pending_cdo = g_object_ref (dispatch_operation);
1504 g_signal_connect (self->priv->pending_cdo, "invalidated",
1505 G_CALLBACK (empathy_call_window_cdo_invalidated_cb), self);
1507 empathy_call_window_set_state_ringing (self);
1508 tp_add_dispatch_operation_context_accept (context);
1512 empathy_call_window_init (EmpathyCallWindow *self)
1514 EmpathyCallWindowPriv *priv;
1516 GtkWidget *top_vbox;
1518 ClutterConstraint *constraint;
1519 ClutterActor *remote_avatar;
1520 GtkStyleContext *context;
1524 priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
1525 EMPATHY_TYPE_CALL_WINDOW, EmpathyCallWindowPriv);
1527 filename = empathy_file_lookup ("empathy-call-window.ui", "src");
1528 gui = empathy_builder_get_file (filename,
1529 "call_window_vbox", &top_vbox,
1530 "errors_vbox", &priv->errors_vbox,
1531 "pane", &priv->pane,
1532 "remote_user_name_toolbar", &priv->remote_user_name_toolbar,
1533 "remote_user_avatar_toolbar", &priv->remote_user_avatar_toolbar,
1534 "status_label", &priv->status_label,
1535 "audiocall", &priv->audio_call_button,
1536 "videocall", &priv->video_call_button,
1537 "microphone", &priv->mic_button,
1538 "camera", &priv->camera_button,
1539 "hangup", &priv->hangup_button,
1540 "dialpad", &priv->dialpad_button,
1541 "toolbar", &priv->toolbar,
1542 "bottom_toolbar", &priv->bottom_toolbar,
1543 "ui_manager", &priv->ui_manager,
1544 "menufullscreen", &priv->menu_fullscreen,
1545 "menupreviewswap", &priv->menu_swap_camera,
1546 "details_vbox", &priv->details_vbox,
1547 "vcodec_encoding_label", &priv->vcodec_encoding_label,
1548 "acodec_encoding_label", &priv->acodec_encoding_label,
1549 "acodec_decoding_label", &priv->acodec_decoding_label,
1550 "vcodec_decoding_label", &priv->vcodec_decoding_label,
1551 "audio_remote_candidate_label", &priv->audio_remote_candidate_label,
1552 "audio_local_candidate_label", &priv->audio_local_candidate_label,
1553 "video_remote_candidate_label", &priv->video_remote_candidate_label,
1554 "video_local_candidate_label", &priv->video_local_candidate_label,
1555 "video_remote_candidate_info_img", &priv->video_remote_candidate_info_img,
1556 "video_local_candidate_info_img", &priv->video_local_candidate_info_img,
1557 "audio_remote_candidate_info_img", &priv->audio_remote_candidate_info_img,
1558 "audio_local_candidate_info_img", &priv->audio_local_candidate_info_img,
1562 empathy_builder_connect (gui, self,
1563 "hangup", "clicked", empathy_call_window_hangup_cb,
1564 "audiocall", "clicked", empathy_call_window_audio_call_cb,
1565 "videocall", "clicked", empathy_call_window_video_call_cb,
1566 "volume", "value-changed", empathy_call_window_volume_changed_cb,
1567 "microphone", "toggled", empathy_call_window_mic_toggled_cb,
1568 "camera", "toggled", empathy_call_window_camera_toggled_cb,
1569 "dialpad", "toggled", empathy_call_window_dialpad_cb,
1570 "menufullscreen", "activate", empathy_call_window_fullscreen_cb,
1571 "menusettings", "activate", empathy_call_window_settings_cb,
1572 "menucontents", "activate", empathy_call_window_contents_cb,
1573 "menudebug", "activate", empathy_call_window_debug_cb,
1574 "menuabout", "activate", empathy_call_window_about_cb,
1575 "menupreviewdisable", "activate", empathy_call_window_disable_camera_cb,
1576 "menupreviewminimise", "activate", empathy_call_window_minimise_camera_cb,
1577 "menupreviewmaximise", "activate", empathy_call_window_maximise_camera_cb,
1578 "menupreviewswap", "activate", empathy_call_window_swap_camera_cb,
1581 gtk_action_set_sensitive (priv->menu_fullscreen, FALSE);
1583 priv->camera_monitor = empathy_camera_monitor_dup_singleton ();
1585 g_object_bind_property (priv->camera_monitor, "available",
1586 priv->camera_button, "sensitive",
1587 G_BINDING_SYNC_CREATE);
1589 g_signal_connect (priv->camera_monitor, "added",
1590 G_CALLBACK (empathy_call_window_camera_added_cb), self);
1591 g_signal_connect (priv->camera_monitor, "removed",
1592 G_CALLBACK (empathy_call_window_camera_removed_cb), self);
1594 priv->lock = g_mutex_new ();
1596 gtk_container_add (GTK_CONTAINER (self), top_vbox);
1598 priv->content_hbox = gtk_hbox_new (FALSE, CONTENT_HBOX_SPACING);
1599 gtk_container_set_border_width (GTK_CONTAINER (priv->content_hbox),
1600 CONTENT_HBOX_BORDER_WIDTH);
1601 gtk_box_pack_start (GTK_BOX (priv->pane), priv->content_hbox,
1604 /* avatar/video box */
1605 priv->video_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
1606 CLUTTER_BIN_ALIGNMENT_CENTER);
1608 priv->video_box = clutter_box_new (priv->video_layout);
1610 priv->video_container = gtk_clutter_embed_new ();
1612 /* Set the background color to that of the rest of the window */
1613 context = gtk_widget_get_style_context (priv->content_hbox);
1614 gtk_style_context_get_background_color (context,
1615 GTK_STATE_FLAG_NORMAL, &rgba);
1616 bg.red = CLAMP (rgba.red * 255.0, 0, 255);
1617 bg.green = CLAMP (rgba.green * 255.0, 0, 255);
1618 bg.blue = CLAMP (rgba.blue * 255.0, 0, 255);
1619 bg.alpha = CLAMP (rgba.alpha * 255.0, 0, 255);
1620 clutter_stage_set_color (
1621 CLUTTER_STAGE (gtk_clutter_embed_get_stage (
1622 GTK_CLUTTER_EMBED (priv->video_container))),
1625 clutter_container_add (
1626 CLUTTER_CONTAINER (gtk_clutter_embed_get_stage (
1627 GTK_CLUTTER_EMBED (priv->video_container))),
1631 constraint = clutter_bind_constraint_new (
1632 gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->video_container)),
1633 CLUTTER_BIND_SIZE, 0);
1634 clutter_actor_add_constraint (priv->video_box, constraint);
1636 priv->remote_user_avatar_widget = gtk_image_new ();
1637 remote_avatar = gtk_clutter_actor_new_with_contents (
1638 priv->remote_user_avatar_widget);
1640 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_box),
1643 empathy_call_window_create_preview_rectangles (self);
1645 gtk_box_pack_start (GTK_BOX (priv->content_hbox),
1646 priv->video_container, TRUE, TRUE,
1647 CONTENT_HBOX_CHILDREN_PACKING_PADDING);
1649 create_pipeline (self);
1650 create_video_output_widget (self);
1651 create_audio_input (self);
1652 create_video_input (self);
1654 priv->floating_toolbar = empathy_rounded_actor_new ();
1656 gtk_widget_reparent (priv->bottom_toolbar,
1657 gtk_clutter_actor_get_widget (GTK_CLUTTER_ACTOR (priv->floating_toolbar)));
1659 constraint = clutter_bind_constraint_new (
1660 gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->video_container)),
1663 clutter_actor_add_constraint (priv->floating_toolbar, constraint);
1666 gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->video_container)),
1667 "notify::allocation",
1668 G_CALLBACK (empathy_call_window_stage_allocation_changed_cb),
1671 clutter_actor_set_size (priv->floating_toolbar,
1672 FLOATING_TOOLBAR_WIDTH, FLOATING_TOOLBAR_HEIGHT);
1673 clutter_actor_set_opacity (priv->floating_toolbar, FLOATING_TOOLBAR_OPACITY);
1675 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
1676 priv->floating_toolbar,
1677 CLUTTER_BIN_ALIGNMENT_CENTER,
1678 CLUTTER_BIN_ALIGNMENT_END);
1680 clutter_actor_raise_top (priv->floating_toolbar);
1682 /* Transitions for the floating toolbar */
1683 priv->transitions = clutter_state_new ();
1685 /* all transitions last for 2s */
1686 clutter_state_set_duration (priv->transitions, NULL, NULL, 2000);
1688 /* transition from any state to "fade-out" state */
1689 clutter_state_set (priv->transitions, NULL, "fade-out",
1690 priv->floating_toolbar,
1691 "opacity", CLUTTER_EASE_OUT_QUAD, 0,
1694 /* transition from any state to "fade-in" state */
1695 clutter_state_set (priv->transitions, NULL, "fade-in",
1696 priv->floating_toolbar,
1697 "opacity", CLUTTER_EASE_OUT_QUAD, FLOATING_TOOLBAR_OPACITY,
1700 /* put the actor into the "fade-in" state with no animation */
1701 clutter_state_warp_to_state (priv->transitions, "fade-in");
1703 /* The call will be started as soon the pipeline is playing */
1704 priv->start_call_when_playing = TRUE;
1706 priv->dtmf_panel = empathy_create_dtmf_dialpad (G_OBJECT (self),
1707 G_CALLBACK (dtmf_button_pressed_cb),
1708 G_CALLBACK (dtmf_button_released_cb));
1710 priv->tones = g_string_new ("");
1712 gtk_box_pack_start (GTK_BOX (priv->pane), priv->dtmf_panel,
1715 gtk_box_pack_start (GTK_BOX (priv->pane), priv->details_vbox,
1718 gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
1720 gtk_widget_show_all (top_vbox);
1722 gtk_widget_hide (priv->dtmf_panel);
1723 gtk_widget_hide (priv->details_vbox);
1725 priv->fullscreen = empathy_call_window_fullscreen_new (self);
1727 empathy_call_window_fullscreen_set_video_widget (priv->fullscreen,
1728 priv->video_container);
1730 /* We hide the bottom toolbar after 3s of inactivity and show it
1731 * again on mouse movement */
1732 priv->inactivity_src = g_timeout_add_seconds (3,
1733 empathy_call_window_toolbar_timeout, self);
1735 g_signal_connect (G_OBJECT (priv->fullscreen->leave_fullscreen_button),
1736 "clicked", G_CALLBACK (empathy_call_window_fullscreen_cb), self);
1738 g_signal_connect (G_OBJECT (self), "realize",
1739 G_CALLBACK (empathy_call_window_realized_cb), self);
1741 g_signal_connect (G_OBJECT (self), "delete-event",
1742 G_CALLBACK (empathy_call_window_delete_cb), self);
1744 g_signal_connect (G_OBJECT (self), "window-state-event",
1745 G_CALLBACK (empathy_call_window_state_event_cb), self);
1747 g_signal_connect (G_OBJECT (self), "key-press-event",
1748 G_CALLBACK (empathy_call_window_key_press_cb), self);
1750 g_signal_connect (self, "motion-notify-event",
1751 G_CALLBACK (empathy_call_window_motion_notify_cb), self);
1753 priv->timer = g_timer_new ();
1755 g_object_ref (priv->ui_manager);
1756 g_object_unref (gui);
1758 priv->sound_mgr = empathy_sound_manager_dup_singleton ();
1759 priv->mic_menu = empathy_mic_menu_new (self);
1760 priv->camera_menu = empathy_camera_menu_new (self);
1762 empathy_call_window_show_hangup_button (self, TRUE);
1764 priv->settings = g_settings_new (EMPATHY_PREFS_CALL_SCHEMA);
1766 /* Retrieve initial volume */
1767 priv->volume = g_settings_get_double (priv->settings,
1768 EMPATHY_PREFS_CALL_SOUND_VOLUME) / 100.0;
1770 g_signal_connect (priv->settings, "changed::"EMPATHY_PREFS_CALL_SOUND_VOLUME,
1771 G_CALLBACK (empathy_call_window_prefs_volume_changed_cb), self);
1773 empathy_geometry_bind (GTK_WINDOW (self), "call-window");
1774 /* These signals are used to track the window position and save it
1775 * when the window is destroyed. We need to do this as we don't want
1776 * the window geometry to be saved with the dialpad taken into account. */
1777 g_signal_connect (self, "destroy",
1778 G_CALLBACK (empathy_call_window_destroyed_cb), self);
1779 g_signal_connect (self, "configure-event",
1780 G_CALLBACK (empathy_call_window_configure_event_cb), self);
1781 g_signal_connect (self, "window-state-event",
1782 G_CALLBACK (empathy_call_window_configure_event_cb), self);
1784 /* Don't display labels in both toolbars */
1785 gtk_toolbar_set_style (GTK_TOOLBAR (priv->toolbar), GTK_TOOLBAR_ICONS);
1788 /* Instead of specifying a width and a height, we specify only one size. That's
1789 because we want a square avatar icon. */
1791 init_contact_avatar_with_size (EmpathyContact *contact,
1792 GtkWidget *image_widget,
1795 GdkPixbuf *pixbuf_avatar = NULL;
1797 if (contact != NULL)
1799 pixbuf_avatar = empathy_pixbuf_avatar_from_contact_scaled (contact,
1803 if (pixbuf_avatar == NULL)
1805 pixbuf_avatar = empathy_pixbuf_from_icon_name_sized (
1806 EMPATHY_IMAGE_AVATAR_DEFAULT, size);
1809 gtk_image_set_from_pixbuf (GTK_IMAGE (image_widget), pixbuf_avatar);
1811 if (pixbuf_avatar != NULL)
1812 g_object_unref (pixbuf_avatar);
1816 set_window_title (EmpathyCallWindow *self)
1818 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1821 if (priv->contact != NULL)
1823 /* translators: Call is a noun and %s is the contact name. This string
1824 * is used in the window title */
1825 tmp = g_strdup_printf (_("Call with %s"),
1826 empathy_contact_get_alias (priv->contact));
1827 gtk_window_set_title (GTK_WINDOW (self), tmp);
1832 g_warning ("Unknown remote contact!");
1837 set_remote_user_name (EmpathyCallWindow *self,
1838 EmpathyContact *contact)
1840 const gchar *alias = empathy_contact_get_alias (contact);
1841 const gchar *status = empathy_contact_get_status (contact);
1844 label = g_strdup_printf ("%s\n<small>%s</small>", alias, status);
1845 gtk_label_set_markup (GTK_LABEL (self->priv->remote_user_name_toolbar),
1851 contact_name_changed_cb (EmpathyContact *contact,
1853 EmpathyCallWindow *self)
1855 set_window_title (self);
1856 set_remote_user_name (self, contact);
1860 contact_presence_changed_cb (EmpathyContact *contact,
1862 EmpathyCallWindow *self)
1864 set_remote_user_name (self, contact);
1868 contact_avatar_changed_cb (EmpathyContact *contact,
1870 EmpathyCallWindow *self)
1873 GtkAllocation allocation;
1874 GtkWidget *avatar_widget;
1876 avatar_widget = self->priv->remote_user_avatar_widget;
1878 gtk_widget_get_allocation (avatar_widget, &allocation);
1879 size = allocation.height;
1883 /* the widget is not allocated yet, set a default size */
1884 size = MIN (REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT,
1885 REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH);
1888 init_contact_avatar_with_size (contact, avatar_widget, size);
1890 avatar_widget = self->priv->remote_user_avatar_toolbar;
1892 gtk_widget_get_allocation (avatar_widget, &allocation);
1893 size = allocation.height;
1897 /* the widget is not allocated yet, set a default size */
1898 size = SMALL_TOOLBAR_SIZE;
1901 init_contact_avatar_with_size (contact, avatar_widget, size);
1905 empathy_call_window_setup_avatars (EmpathyCallWindow *self,
1906 EmpathyCallHandler *handler)
1908 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1910 tp_g_signal_connect_object (priv->contact, "notify::name",
1911 G_CALLBACK (contact_name_changed_cb), self, 0);
1912 tp_g_signal_connect_object (priv->contact, "notify::avatar",
1913 G_CALLBACK (contact_avatar_changed_cb), self, 0);
1914 tp_g_signal_connect_object (priv->contact, "notify::presence",
1915 G_CALLBACK (contact_presence_changed_cb), self, 0);
1917 set_window_title (self);
1918 set_remote_user_name (self, priv->contact);
1920 init_contact_avatar_with_size (priv->contact,
1921 priv->remote_user_avatar_widget,
1922 MIN (REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH,
1923 REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT));
1925 init_contact_avatar_with_size (priv->contact,
1926 priv->remote_user_avatar_toolbar,
1927 SMALL_TOOLBAR_SIZE);
1929 /* The remote avatar is shown by default and will be hidden when we receive
1930 video from the remote side. */
1931 clutter_actor_hide (priv->video_output);
1932 gtk_widget_show (priv->remote_user_avatar_widget);
1936 update_send_codec (EmpathyCallWindow *self,
1939 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1946 codec = empathy_call_handler_get_send_audio_codec (priv->handler);
1947 widget = priv->acodec_encoding_label;
1951 codec = empathy_call_handler_get_send_video_codec (priv->handler);
1952 widget = priv->vcodec_encoding_label;
1958 tmp = g_strdup_printf ("%s/%u", codec->encoding_name, codec->clock_rate);
1959 gtk_label_set_text (GTK_LABEL (widget), tmp);
1964 send_audio_codec_notify_cb (GObject *object,
1968 EmpathyCallWindow *self = user_data;
1970 update_send_codec (self, TRUE);
1974 send_video_codec_notify_cb (GObject *object,
1978 EmpathyCallWindow *self = user_data;
1980 update_send_codec (self, FALSE);
1984 update_recv_codec (EmpathyCallWindow *self,
1987 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1990 GString *str = NULL;
1994 codecs = empathy_call_handler_get_recv_audio_codecs (priv->handler);
1995 widget = priv->acodec_decoding_label;
1999 codecs = empathy_call_handler_get_recv_video_codecs (priv->handler);
2000 widget = priv->vcodec_decoding_label;
2006 for (l = codecs; l != NULL; l = g_list_next (l))
2008 FsCodec *codec = l->data;
2011 str = g_string_new (NULL);
2013 g_string_append (str, ", ");
2015 g_string_append_printf (str, "%s/%u", codec->encoding_name,
2019 gtk_label_set_text (GTK_LABEL (widget), str->str);
2020 g_string_free (str, TRUE);
2024 recv_audio_codecs_notify_cb (GObject *object,
2028 EmpathyCallWindow *self = user_data;
2030 update_recv_codec (self, TRUE);
2034 recv_video_codecs_notify_cb (GObject *object,
2038 EmpathyCallWindow *self = user_data;
2040 update_recv_codec (self, FALSE);
2043 static const gchar *
2044 candidate_type_to_str (FsCandidate *candidate)
2046 switch (candidate->type)
2048 case FS_CANDIDATE_TYPE_HOST:
2050 case FS_CANDIDATE_TYPE_SRFLX:
2051 return "server reflexive";
2052 case FS_CANDIDATE_TYPE_PRFLX:
2053 return "peer reflexive";
2054 case FS_CANDIDATE_TYPE_RELAY:
2056 case FS_CANDIDATE_TYPE_MULTICAST:
2063 static const gchar *
2064 candidate_type_to_desc (FsCandidate *candidate)
2066 switch (candidate->type)
2068 case FS_CANDIDATE_TYPE_HOST:
2069 return _("The IP address as seen by the machine");
2070 case FS_CANDIDATE_TYPE_SRFLX:
2071 return _("The IP address as seen by a server on the Internet");
2072 case FS_CANDIDATE_TYPE_PRFLX:
2073 return _("The IP address of the peer as seen by the other side");
2074 case FS_CANDIDATE_TYPE_RELAY:
2075 return _("The IP address of a relay server");
2076 case FS_CANDIDATE_TYPE_MULTICAST:
2077 return _("The IP address of the multicast group");
2084 update_candidat_widget (EmpathyCallWindow *self,
2087 FsCandidate *candidate)
2091 g_assert (candidate != NULL);
2092 str = g_strdup_printf ("%s %u (%s)", candidate->ip,
2093 candidate->port, candidate_type_to_str (candidate));
2095 gtk_label_set_text (GTK_LABEL (label), str);
2096 gtk_widget_set_tooltip_text (img, candidate_type_to_desc (candidate));
2102 candidates_changed_cb (GObject *object,
2104 EmpathyCallWindow *self)
2106 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2107 FsCandidate *candidate = NULL;
2109 if (type == FS_MEDIA_TYPE_VIDEO)
2111 /* Update remote candidate */
2112 candidate = empathy_call_handler_get_video_remote_candidate (
2115 update_candidat_widget (self, priv->video_remote_candidate_label,
2116 priv->video_remote_candidate_info_img, candidate);
2118 /* Update local candidate */
2119 candidate = empathy_call_handler_get_video_local_candidate (
2122 update_candidat_widget (self, priv->video_local_candidate_label,
2123 priv->video_local_candidate_info_img, candidate);
2127 /* Update remote candidate */
2128 candidate = empathy_call_handler_get_audio_remote_candidate (
2131 update_candidat_widget (self, priv->audio_remote_candidate_label,
2132 priv->audio_remote_candidate_info_img, candidate);
2134 /* Update local candidate */
2135 candidate = empathy_call_handler_get_audio_local_candidate (
2138 update_candidat_widget (self, priv->audio_local_candidate_label,
2139 priv->audio_local_candidate_info_img, candidate);
2144 empathy_call_window_constructed (GObject *object)
2146 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
2147 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2148 TpyCallChannel *call;
2150 g_assert (priv->handler != NULL);
2152 g_object_get (priv->handler, "call-channel", &call, NULL);
2153 priv->outgoing = (call == NULL);
2155 g_object_unref (call);
2157 g_object_get (priv->handler, "target-contact", &priv->contact, NULL);
2158 g_assert (priv->contact != NULL);
2160 if (!empathy_contact_can_voip_video (priv->contact))
2162 gtk_widget_set_sensitive (priv->video_call_button, FALSE);
2163 gtk_widget_set_sensitive (priv->camera_button, FALSE);
2166 empathy_call_window_setup_avatars (self, priv->handler);
2167 empathy_call_window_set_state_connecting (self);
2169 if (!empathy_call_handler_has_initial_video (priv->handler))
2171 gtk_toggle_tool_button_set_active (
2172 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), FALSE);
2174 /* If call has InitialVideo, the preview will be started once the call has
2175 * been started (start_call()). */
2177 update_send_codec (self, TRUE);
2178 update_send_codec (self, FALSE);
2179 update_recv_codec (self, TRUE);
2180 update_recv_codec (self, FALSE);
2182 tp_g_signal_connect_object (priv->handler, "notify::send-audio-codec",
2183 G_CALLBACK (send_audio_codec_notify_cb), self, 0);
2184 tp_g_signal_connect_object (priv->handler, "notify::send-video-codec",
2185 G_CALLBACK (send_video_codec_notify_cb), self, 0);
2186 tp_g_signal_connect_object (priv->handler, "notify::recv-audio-codecs",
2187 G_CALLBACK (recv_audio_codecs_notify_cb), self, 0);
2188 tp_g_signal_connect_object (priv->handler, "notify::recv-video-codecs",
2189 G_CALLBACK (recv_video_codecs_notify_cb), self, 0);
2191 tp_g_signal_connect_object (priv->handler, "candidates-changed",
2192 G_CALLBACK (candidates_changed_cb), self, 0);
2195 static void empathy_call_window_dispose (GObject *object);
2196 static void empathy_call_window_finalize (GObject *object);
2199 empathy_call_window_set_property (GObject *object,
2200 guint property_id, const GValue *value, GParamSpec *pspec)
2202 EmpathyCallWindowPriv *priv = GET_PRIV (object);
2204 switch (property_id)
2206 case PROP_CALL_HANDLER:
2207 priv->handler = g_value_dup_object (value);
2210 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
2215 empathy_call_window_get_property (GObject *object,
2216 guint property_id, GValue *value, GParamSpec *pspec)
2218 EmpathyCallWindowPriv *priv = GET_PRIV (object);
2220 switch (property_id)
2222 case PROP_CALL_HANDLER:
2223 g_value_set_object (value, priv->handler);
2226 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
2231 empathy_call_window_class_init (
2232 EmpathyCallWindowClass *empathy_call_window_class)
2234 GObjectClass *object_class = G_OBJECT_CLASS (empathy_call_window_class);
2235 GParamSpec *param_spec;
2237 g_type_class_add_private (empathy_call_window_class,
2238 sizeof (EmpathyCallWindowPriv));
2240 object_class->constructed = empathy_call_window_constructed;
2241 object_class->set_property = empathy_call_window_set_property;
2242 object_class->get_property = empathy_call_window_get_property;
2244 object_class->dispose = empathy_call_window_dispose;
2245 object_class->finalize = empathy_call_window_finalize;
2247 param_spec = g_param_spec_object ("handler",
2248 "handler", "The call handler",
2249 EMPATHY_TYPE_CALL_HANDLER,
2250 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
2251 g_object_class_install_property (object_class,
2252 PROP_CALL_HANDLER, param_spec);
2256 empathy_call_window_dispose (GObject *object)
2258 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
2259 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2261 if (priv->dispose_has_run)
2264 priv->dispose_has_run = TRUE;
2266 if (priv->handler != NULL)
2268 empathy_call_handler_stop_call (priv->handler);
2269 tp_clear_object (&priv->handler);
2272 if (priv->bus_message_source_id != 0)
2274 g_source_remove (priv->bus_message_source_id);
2275 priv->bus_message_source_id = 0;
2278 if (priv->got_video_src > 0)
2280 g_source_remove (priv->got_video_src);
2281 priv->got_video_src = 0;
2284 if (priv->inactivity_src > 0)
2286 g_source_remove (priv->inactivity_src);
2287 priv->inactivity_src = 0;
2290 tp_clear_object (&priv->pipeline);
2291 tp_clear_object (&priv->video_input);
2292 tp_clear_object (&priv->audio_input);
2293 tp_clear_object (&priv->video_tee);
2294 tp_clear_object (&priv->ui_manager);
2295 tp_clear_object (&priv->fullscreen);
2296 tp_clear_object (&priv->camera_monitor);
2297 tp_clear_object (&priv->settings);
2298 tp_clear_object (&priv->sound_mgr);
2299 tp_clear_object (&priv->mic_menu);
2300 tp_clear_object (&priv->camera_menu);
2302 g_list_free_full (priv->notifiers, g_object_unref);
2304 if (priv->timer_id != 0)
2305 g_source_remove (priv->timer_id);
2308 if (priv->contact != NULL)
2310 g_signal_handlers_disconnect_by_func (priv->contact,
2311 contact_name_changed_cb, self);
2312 priv->contact = NULL;
2315 G_OBJECT_CLASS (empathy_call_window_parent_class)->dispose (object);
2319 disconnect_video_output_motion_handler (EmpathyCallWindow *self)
2321 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2323 if (priv->video_output_motion_handler_id != 0)
2325 g_signal_handler_disconnect (G_OBJECT (priv->video_container),
2326 priv->video_output_motion_handler_id);
2327 priv->video_output_motion_handler_id = 0;
2332 empathy_call_window_finalize (GObject *object)
2334 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
2335 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2337 disconnect_video_output_motion_handler (self);
2339 /* free any data held directly by the object here */
2340 g_mutex_free (priv->lock);
2342 g_timer_destroy (priv->timer);
2344 g_string_free (priv->tones, TRUE);
2346 G_OBJECT_CLASS (empathy_call_window_parent_class)->finalize (object);
2351 empathy_call_window_new (EmpathyCallHandler *handler)
2353 return EMPATHY_CALL_WINDOW (
2354 g_object_new (EMPATHY_TYPE_CALL_WINDOW, "handler", handler, NULL));
2358 empathy_call_window_present (EmpathyCallWindow *self,
2359 EmpathyCallHandler *handler)
2361 g_return_if_fail (EMPATHY_IS_CALL_HANDLER (handler));
2363 tp_clear_object (&self->priv->handler);
2364 self->priv->handler = g_object_ref (handler);
2365 empathy_call_window_connect_handler (self);
2367 empathy_window_present (GTK_WINDOW (self));
2368 empathy_call_window_restart_call (self);
2372 empathy_call_window_conference_added_cb (EmpathyCallHandler *handler,
2373 GstElement *conference, gpointer user_data)
2375 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2376 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2377 FsElementAddedNotifier *notifier;
2380 DEBUG ("Conference added");
2382 /* Add notifier to set the various element properties as needed */
2383 notifier = fs_element_added_notifier_new ();
2384 keyfile = fs_utils_get_default_element_properties (conference);
2386 if (keyfile != NULL)
2387 fs_element_added_notifier_set_properties_from_keyfile (notifier, keyfile);
2389 fs_element_added_notifier_add (notifier, GST_BIN (priv->pipeline));
2391 priv->notifiers = g_list_prepend (priv->notifiers, notifier);
2393 gst_bin_add (GST_BIN (priv->pipeline), conference);
2394 gst_element_set_state (conference, GST_STATE_PLAYING);
2398 empathy_call_window_conference_removed_cb (EmpathyCallHandler *handler,
2399 GstElement *conference, gpointer user_data)
2401 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2402 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2404 gst_bin_remove (GST_BIN (priv->pipeline), conference);
2405 gst_element_set_state (conference, GST_STATE_NULL);
2409 empathy_call_window_reset_pipeline (EmpathyCallWindow *self)
2411 GstStateChangeReturn state_change_return;
2412 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2414 if (priv->pipeline == NULL)
2417 if (priv->bus_message_source_id != 0)
2419 g_source_remove (priv->bus_message_source_id);
2420 priv->bus_message_source_id = 0;
2423 state_change_return = gst_element_set_state (priv->pipeline, GST_STATE_NULL);
2425 if (state_change_return == GST_STATE_CHANGE_SUCCESS ||
2426 state_change_return == GST_STATE_CHANGE_NO_PREROLL)
2428 if (priv->pipeline != NULL)
2429 g_object_unref (priv->pipeline);
2430 priv->pipeline = NULL;
2432 if (priv->audio_output != NULL)
2433 g_object_unref (priv->audio_output);
2434 priv->audio_output = NULL;
2436 if (priv->video_tee != NULL)
2437 g_object_unref (priv->video_tee);
2438 priv->video_tee = NULL;
2440 if (priv->video_preview != NULL)
2441 clutter_actor_destroy (priv->video_preview);
2442 priv->video_preview = NULL;
2444 /* If we destroy the preview while it's being dragged, we won't
2445 * get the ::drag-end signal, so manually destroy the clone */
2446 if (priv->drag_preview != NULL)
2448 clutter_actor_destroy (priv->drag_preview);
2449 empathy_call_window_show_preview_rectangles (self, FALSE);
2450 priv->drag_preview = NULL;
2453 priv->funnel = NULL;
2455 create_pipeline (self);
2456 /* Call will be started when user will hit the 'redial' button */
2457 priv->start_call_when_playing = FALSE;
2458 gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
2464 g_message ("Error: could not destroy pipeline. Closing call window");
2465 gtk_widget_destroy (GTK_WIDGET (self));
2472 reset_details_pane (EmpathyCallWindow *self)
2474 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2476 gtk_label_set_text (GTK_LABEL (priv->vcodec_encoding_label), _("Unknown"));
2477 gtk_label_set_text (GTK_LABEL (priv->acodec_encoding_label), _("Unknown"));
2478 gtk_label_set_text (GTK_LABEL (priv->vcodec_decoding_label), _("Unknown"));
2479 gtk_label_set_text (GTK_LABEL (priv->acodec_decoding_label), _("Unknown"));
2483 empathy_call_window_disconnected (EmpathyCallWindow *self,
2486 gboolean could_disconnect = FALSE;
2487 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2488 gboolean could_reset_pipeline;
2490 /* Leave full screen mode if needed */
2491 gtk_window_unfullscreen (GTK_WINDOW (self));
2493 gtk_action_set_sensitive (priv->menu_fullscreen, FALSE);
2494 gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
2496 priv->sending_tones = FALSE;
2497 g_string_set_size (priv->tones, 0);
2499 could_reset_pipeline = empathy_call_window_reset_pipeline (self);
2501 if (priv->call_state == CONNECTING)
2502 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
2504 if (priv->call_state != REDIALING)
2505 priv->call_state = DISCONNECTED;
2507 /* Show the toolbar */
2508 clutter_state_set_state (priv->transitions, "fade-in");
2510 if (could_reset_pipeline)
2512 g_mutex_lock (priv->lock);
2514 g_timer_stop (priv->timer);
2516 if (priv->timer_id != 0)
2517 g_source_remove (priv->timer_id);
2520 g_mutex_unlock (priv->lock);
2523 /* We are about to destroy the window, no need to update it or create
2524 * a video preview */
2527 empathy_call_window_status_message (self, _("Disconnected"));
2529 empathy_call_window_show_hangup_button (self, FALSE);
2531 /* Unsensitive the camera and mic button */
2532 gtk_widget_set_sensitive (priv->camera_button, FALSE);
2533 gtk_widget_set_sensitive (priv->mic_button, FALSE);
2535 /* Be sure that the mic button is enabled */
2536 gtk_toggle_tool_button_set_active (
2537 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button), TRUE);
2539 if (priv->camera_state == CAMERA_STATE_ON)
2541 /* Restart the preview with the new pipeline. */
2542 display_video_preview (self, TRUE);
2545 /* destroy the video output; it will be recreated when we'll redial */
2546 disconnect_video_output_motion_handler (self);
2547 if (priv->video_output != NULL)
2548 clutter_actor_destroy (priv->video_output);
2549 priv->video_output = NULL;
2550 if (priv->got_video_src > 0)
2552 g_source_remove (priv->got_video_src);
2553 priv->got_video_src = 0;
2556 gtk_widget_show (priv->remote_user_avatar_widget);
2558 reset_details_pane (self);
2560 priv->sending_video = FALSE;
2561 priv->call_started = FALSE;
2563 could_disconnect = TRUE;
2565 /* TODO: display the self avatar of the preview (depends if the "Always
2566 * Show Video Preview" is enabled or not) */
2569 return could_disconnect;
2574 empathy_call_window_channel_closed_cb (EmpathyCallHandler *handler,
2577 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2578 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2580 if (empathy_call_window_disconnected (self, TRUE) &&
2581 priv->call_state == REDIALING)
2582 empathy_call_window_restart_call (self);
2586 empathy_call_window_sink_removed_cb (EmpathyCallHandler *handler,
2588 FsMediaType media_type,
2589 EmpathyCallWindow *self)
2591 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2593 DEBUG ("removing content");
2596 * This assumes that there is only one video stream per channel...
2599 if ((guint) media_type == FS_MEDIA_TYPE_VIDEO)
2601 if (priv->funnel != NULL)
2605 output = priv->video_output_sink;
2607 gst_element_set_state (output, GST_STATE_NULL);
2608 gst_element_set_state (priv->funnel, GST_STATE_NULL);
2610 gst_bin_remove (GST_BIN (priv->pipeline), output);
2611 gst_bin_remove (GST_BIN (priv->pipeline), priv->funnel);
2612 priv->funnel = NULL;
2616 else if (media_type == FS_MEDIA_TYPE_AUDIO)
2618 if (priv->audio_output != NULL)
2620 gst_element_set_state (priv->audio_output, GST_STATE_NULL);
2622 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
2623 priv->audio_output = NULL;
2631 /* Called with global lock held */
2633 empathy_call_window_get_video_sink_pad (EmpathyCallWindow *self)
2635 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2639 if (priv->funnel == NULL)
2641 output = priv->video_output_sink;
2643 priv->funnel = gst_element_factory_make ("fsfunnel", NULL);
2647 g_warning ("Could not create fsfunnel");
2651 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->funnel))
2653 gst_object_unref (priv->funnel);
2654 priv->funnel = NULL;
2655 g_warning ("Could not add funnel to pipeline");
2659 if (!gst_bin_add (GST_BIN (priv->pipeline), output))
2661 g_warning ("Could not add the video output widget to the pipeline");
2665 if (!gst_element_link (priv->funnel, output))
2667 g_warning ("Could not link output sink to funnel");
2668 goto error_output_added;
2671 if (gst_element_set_state (output, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2673 g_warning ("Could not start video sink");
2674 goto error_output_added;
2677 if (gst_element_set_state (priv->funnel, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2679 g_warning ("Could not start funnel");
2680 goto error_output_added;
2684 pad = gst_element_get_request_pad (priv->funnel, "sink%d");
2687 g_warning ("Could not get request pad from funnel");
2694 gst_element_set_locked_state (priv->funnel, TRUE);
2695 gst_element_set_locked_state (output, TRUE);
2697 gst_element_set_state (priv->funnel, GST_STATE_NULL);
2698 gst_element_set_state (output, GST_STATE_NULL);
2700 gst_bin_remove (GST_BIN (priv->pipeline), output);
2701 gst_element_set_locked_state (output, FALSE);
2705 gst_bin_remove (GST_BIN (priv->pipeline), priv->funnel);
2706 priv->funnel = NULL;
2711 /* Called with global lock held */
2713 empathy_call_window_get_audio_sink_pad (EmpathyCallWindow *self)
2715 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2717 GstPadTemplate *template;
2719 if (priv->audio_output == NULL)
2721 priv->audio_output = empathy_audio_sink_new ();
2722 g_object_ref_sink (priv->audio_output);
2724 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_output))
2726 g_warning ("Could not add audio sink to pipeline");
2727 g_object_unref (priv->audio_output);
2728 goto error_add_output;
2731 if (gst_element_set_state (priv->audio_output, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2733 g_warning ("Could not start audio sink");
2738 template = gst_element_class_get_pad_template (
2739 GST_ELEMENT_GET_CLASS (priv->audio_output), "sink%d");
2741 pad = gst_element_request_pad (priv->audio_output,
2742 template, NULL, NULL);
2746 g_warning ("Could not get sink pad from sink");
2753 gst_element_set_locked_state (priv->audio_output, TRUE);
2754 gst_element_set_state (priv->audio_output, GST_STATE_NULL);
2755 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
2756 priv->audio_output = NULL;
2764 empathy_call_window_update_timer (gpointer user_data)
2766 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2767 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2768 const gchar *status;
2772 time_ = g_timer_elapsed (priv->timer, NULL);
2774 if (priv->call_state == HELD)
2775 status = _("On hold");
2776 else if (!gtk_toggle_tool_button_get_active (
2777 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
2780 status = _("Duration");
2782 /* Translators: 'status - minutes:seconds' the caller has been connected */
2783 str = g_strdup_printf (_("%s — %d:%02dm"),
2785 (int) time_ / 60, (int) time_ % 60);
2786 empathy_call_window_status_message (self, str);
2794 display_error (EmpathyCallWindow *self,
2795 TpyCallChannel *call,
2799 const gchar *details)
2801 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2802 GtkWidget *info_bar;
2803 GtkWidget *content_area;
2810 /* Create info bar */
2811 info_bar = gtk_info_bar_new_with_buttons (GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
2814 gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_WARNING);
2816 content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar));
2818 /* hbox containing the image and the messages vbox */
2819 hbox = gtk_hbox_new (FALSE, 3);
2820 gtk_container_add (GTK_CONTAINER (content_area), hbox);
2823 image = gtk_image_new_from_icon_name (img, GTK_ICON_SIZE_DIALOG);
2824 gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
2826 /* vbox containing the main message and the details expander */
2827 vbox = gtk_vbox_new (FALSE, 3);
2828 gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
2831 txt = g_strdup_printf ("<b>%s</b>\n%s", title, desc);
2833 label = gtk_label_new (NULL);
2834 gtk_label_set_markup (GTK_LABEL (label), txt);
2835 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
2836 gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
2839 gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
2842 if (details != NULL)
2844 GtkWidget *expander;
2846 expander = gtk_expander_new (_("Technical Details"));
2848 txt = g_strdup_printf ("<i>%s</i>", details);
2850 label = gtk_label_new (NULL);
2851 gtk_label_set_markup (GTK_LABEL (label), txt);
2852 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
2853 gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
2856 gtk_container_add (GTK_CONTAINER (expander), label);
2857 gtk_box_pack_start (GTK_BOX (vbox), expander, TRUE, TRUE, 0);
2860 g_signal_connect (info_bar, "response",
2861 G_CALLBACK (gtk_widget_destroy), NULL);
2863 gtk_box_pack_start (GTK_BOX (priv->errors_vbox), info_bar,
2864 FALSE, FALSE, CONTENT_HBOX_CHILDREN_PACKING_PADDING);
2865 gtk_widget_show_all (info_bar);
2869 media_stream_error_to_txt (EmpathyCallWindow *self,
2870 TpyCallChannel *call,
2872 TpMediaStreamError error)
2874 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2875 const gchar *cm = NULL;
2881 case TP_MEDIA_STREAM_ERROR_CODEC_NEGOTIATION_FAILED:
2883 return g_strdup_printf (
2884 _("%s's software does not understand any of the audio formats "
2885 "supported by your computer"),
2886 empathy_contact_get_alias (priv->contact));
2888 return g_strdup_printf (
2889 _("%s's software does not understand any of the video formats "
2890 "supported by your computer"),
2891 empathy_contact_get_alias (priv->contact));
2893 case TP_MEDIA_STREAM_ERROR_CONNECTION_FAILED:
2894 return g_strdup_printf (
2895 _("Can't establish a connection to %s. "
2896 "One of you might be on a network that does not allow "
2897 "direct connections."),
2898 empathy_contact_get_alias (priv->contact));
2900 case TP_MEDIA_STREAM_ERROR_NETWORK_ERROR:
2901 return g_strdup (_("There was a failure on the network"));
2903 case TP_MEDIA_STREAM_ERROR_NO_CODECS:
2905 return g_strdup (_("The audio formats necessary for this call "
2906 "are not installed on your computer"));
2908 return g_strdup (_("The video formats necessary for this call "
2909 "are not installed on your computer"));
2911 case TP_MEDIA_STREAM_ERROR_INVALID_CM_BEHAVIOR:
2912 tp_connection_parse_object_path (
2913 tp_channel_borrow_connection (TP_CHANNEL (call)),
2916 url = g_strdup_printf ("http://bugs.freedesktop.org/enter_bug.cgi?"
2917 "product=Telepathy&component=%s", cm);
2919 result = g_strdup_printf (
2920 _("Something unexpected happened in a Telepathy component. "
2921 "Please <a href=\"%s\">report this bug</a> and attach "
2922 "logs gathered from the 'Debug' window in the Help menu."), url);
2928 case TP_MEDIA_STREAM_ERROR_MEDIA_ERROR:
2929 return g_strdup (_("There was a failure in the call engine"));
2931 case TP_MEDIA_STREAM_ERROR_EOS:
2932 return g_strdup (_("The end of the stream was reached"));
2934 case TP_MEDIA_STREAM_ERROR_UNKNOWN:
2941 empathy_call_window_stream_error (EmpathyCallWindow *self,
2942 TpyCallChannel *call,
2951 desc = media_stream_error_to_txt (self, call, audio, code);
2954 /* No description, use the error message. That's not great as it's not
2955 * localized but it's better than nothing. */
2956 display_error (self, call, icon, title, msg, NULL);
2960 display_error (self, call, icon, title, desc, msg);
2966 empathy_call_window_audio_stream_error (TpyCallChannel *call,
2969 EmpathyCallWindow *self)
2971 empathy_call_window_stream_error (self, call, TRUE, code, msg,
2972 "gnome-stock-mic", _("Can't establish audio stream"));
2976 empathy_call_window_video_stream_error (TpyCallChannel *call,
2979 EmpathyCallWindow *self)
2981 empathy_call_window_stream_error (self, call, FALSE, code, msg,
2982 "camera-web", _("Can't establish video stream"));
2987 empathy_call_window_state_changed_cb (EmpathyCallHandler *handler,
2989 EmpathyCallWindow *self)
2991 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2992 TpyCallChannel *call;
2993 gboolean can_send_video;
2995 if (state != TPY_CALL_STATE_ACCEPTED)
2998 if (priv->call_state == CONNECTED)
3001 g_timer_start (priv->timer);
3002 priv->call_state = CONNECTED;
3004 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
3006 can_send_video = priv->video_input != NULL &&
3007 empathy_contact_can_voip_video (priv->contact) &&
3008 empathy_camera_monitor_get_available (priv->camera_monitor);
3010 g_object_get (priv->handler, "call-channel", &call, NULL);
3012 if (tpy_call_channel_has_dtmf (call))
3013 gtk_widget_set_sensitive (priv->dtmf_panel, TRUE);
3015 if (priv->video_input == NULL)
3016 empathy_call_window_set_send_video (self, CAMERA_STATE_OFF);
3018 gtk_widget_set_sensitive (priv->camera_button, can_send_video);
3020 empathy_call_window_show_hangup_button (self, TRUE);
3022 gtk_widget_set_sensitive (priv->mic_button, TRUE);
3024 clutter_actor_hide (priv->video_output);
3025 gtk_widget_show (priv->remote_user_avatar_widget);
3027 g_object_unref (call);
3029 g_mutex_lock (priv->lock);
3031 priv->timer_id = g_timeout_add_seconds (1,
3032 empathy_call_window_update_timer, self);
3034 g_mutex_unlock (priv->lock);
3036 empathy_call_window_update_timer (self);
3038 gtk_action_set_sensitive (priv->menu_fullscreen, TRUE);
3042 empathy_call_window_show_video_output_cb (gpointer user_data)
3044 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
3046 if (self->priv->video_output != NULL)
3048 gtk_widget_hide (self->priv->remote_user_avatar_widget);
3049 clutter_actor_show (self->priv->video_output);
3050 empathy_call_window_raise_actors (self);
3057 empathy_call_window_check_video_cb (gpointer data)
3059 EmpathyCallWindow *self = data;
3061 if (self->priv->got_video)
3063 self->priv->got_video = FALSE;
3067 /* No video in the last N seconds, display the remote avatar */
3068 empathy_call_window_show_video_output (self, FALSE);
3073 /* Called from the streaming thread */
3075 empathy_call_window_video_probe_cb (GstPad *pad,
3076 GstMiniObject *mini_obj,
3077 EmpathyCallWindow *self)
3080 if (GST_IS_EVENT (mini_obj))
3083 if (G_UNLIKELY (!self->priv->got_video))
3085 /* show the remote video */
3086 g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
3087 empathy_call_window_show_video_output_cb,
3088 g_object_ref (self), g_object_unref);
3090 self->priv->got_video = TRUE;
3096 /* Called from the streaming thread */
3098 empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
3099 GstPad *src, guint media_type, gpointer user_data)
3101 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
3102 EmpathyCallWindowPriv *priv = GET_PRIV (self);
3103 gboolean retval = FALSE;
3107 g_mutex_lock (priv->lock);
3111 case TP_MEDIA_STREAM_TYPE_AUDIO:
3112 pad = empathy_call_window_get_audio_sink_pad (self);
3114 case TP_MEDIA_STREAM_TYPE_VIDEO:
3115 g_idle_add (empathy_call_window_show_video_output_cb, self);
3116 pad = empathy_call_window_get_video_sink_pad (self);
3118 gst_pad_add_data_probe (src,
3119 G_CALLBACK (empathy_call_window_video_probe_cb), self);
3120 if (priv->got_video_src > 0)
3121 g_source_remove (priv->got_video_src);
3122 priv->got_video_src = g_timeout_add_seconds (5,
3123 empathy_call_window_check_video_cb, self);
3126 g_assert_not_reached ();
3132 if (GST_PAD_LINK_FAILED (gst_pad_link (src, pad)))
3133 g_warning ("Could not link %s sink pad",
3134 media_type == TP_MEDIA_STREAM_TYPE_AUDIO ? "audio" : "video");
3138 gst_object_unref (pad);
3142 /* If no sink could be linked, try to add fakesink to prevent the whole call
3147 GstElement *fakesink = gst_element_factory_make ("fakesink", NULL);
3149 if (gst_bin_add (GST_BIN (priv->pipeline), fakesink))
3151 GstPad *sinkpad = gst_element_get_static_pad (fakesink, "sink");
3152 if (gst_element_set_state (fakesink, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE ||
3153 GST_PAD_LINK_FAILED (gst_pad_link (src, sinkpad)))
3155 gst_element_set_locked_state (fakesink, TRUE);
3156 gst_element_set_state (fakesink, GST_STATE_NULL);
3157 gst_bin_remove (GST_BIN (priv->pipeline), fakesink);
3161 DEBUG ("Could not link real sink, linked fakesink instead");
3163 gst_object_unref (sinkpad);
3167 gst_object_unref (fakesink);
3172 g_mutex_unlock (priv->lock);
3178 empathy_call_window_sink_added_cb (EmpathyCallHandler *handler,
3179 GstPad *sink, FsMediaType media_type, gpointer user_data)
3181 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
3182 EmpathyCallWindowPriv *priv = GET_PRIV (self);
3184 gboolean retval = FALSE;
3188 case FS_MEDIA_TYPE_AUDIO:
3189 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_input))
3191 g_warning ("Could not add audio source to pipeline");
3195 pad = gst_element_get_static_pad (priv->audio_input, "src");
3198 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
3199 g_warning ("Could not get source pad from audio source");
3203 if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
3205 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
3206 g_warning ("Could not link audio source to farsight");
3210 if (gst_element_set_state (priv->audio_input, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
3212 g_warning ("Could not start audio source");
3213 gst_element_set_state (priv->audio_input, GST_STATE_NULL);
3214 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
3220 case FS_MEDIA_TYPE_VIDEO:
3221 if (priv->video_tee != NULL)
3223 pad = gst_element_get_request_pad (priv->video_tee, "src%d");
3224 if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
3226 g_warning ("Could not link video source input pipeline");
3229 gst_object_unref (pad);
3235 g_assert_not_reached ();
3242 empathy_call_window_remove_video_input (EmpathyCallWindow *self)
3244 EmpathyCallWindowPriv *priv = GET_PRIV (self);
3245 GstElement *preview;
3247 disable_camera (self);
3249 DEBUG ("remove video input");
3250 preview = priv->video_preview_sink;
3252 gst_element_set_state (priv->video_input, GST_STATE_NULL);
3253 gst_element_set_state (priv->video_tee, GST_STATE_NULL);
3254 gst_element_set_state (preview, GST_STATE_NULL);
3256 gst_bin_remove_many (GST_BIN (priv->pipeline), priv->video_input,
3259 g_object_unref (priv->video_input);
3260 priv->video_input = NULL;
3261 g_object_unref (priv->video_tee);
3262 priv->video_tee = NULL;
3263 clutter_actor_destroy (priv->video_preview);
3264 priv->video_preview = NULL;
3266 gtk_widget_set_sensitive (priv->camera_button, FALSE);
3270 start_call (EmpathyCallWindow *self)
3272 EmpathyCallWindowPriv *priv = GET_PRIV (self);
3274 priv->call_started = TRUE;
3275 empathy_call_handler_start_call (priv->handler,
3276 gtk_get_current_event_time ());
3278 if (empathy_call_handler_has_initial_video (priv->handler))
3280 TpyCallChannel *call;
3283 g_object_get (priv->handler, "call-channel", &call, NULL);
3284 s = tpy_call_channel_get_video_state (call);
3286 if (s == TPY_SENDING_STATE_PENDING_SEND ||
3287 s == TPY_SENDING_STATE_SENDING)
3289 /* Enable 'send video' buttons and display the preview */
3290 gtk_toggle_tool_button_set_active (
3291 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), TRUE);
3295 gtk_toggle_tool_button_set_active (
3296 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), FALSE);
3298 if (priv->video_preview == NULL)
3300 create_video_preview (self);
3301 add_video_preview_to_pipeline (self);
3305 g_object_unref (call);
3310 empathy_call_window_bus_message (GstBus *bus, GstMessage *message,
3313 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
3314 EmpathyCallWindowPriv *priv = GET_PRIV (self);
3317 empathy_call_handler_bus_message (priv->handler, bus, message);
3319 switch (GST_MESSAGE_TYPE (message))
3321 case GST_MESSAGE_STATE_CHANGED:
3322 if (GST_MESSAGE_SRC (message) == GST_OBJECT (priv->video_input))
3324 gst_message_parse_state_changed (message, NULL, &newstate, NULL);
3326 if (GST_MESSAGE_SRC (message) == GST_OBJECT (priv->pipeline) &&
3327 !priv->call_started)
3329 gst_message_parse_state_changed (message, NULL, &newstate, NULL);
3330 if (newstate == GST_STATE_PAUSED)
3332 gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
3333 priv->pipeline_playing = TRUE;
3335 if (priv->start_call_when_playing)
3340 case GST_MESSAGE_ERROR:
3342 GError *error = NULL;
3343 GstElement *gst_error;
3346 gst_message_parse_error (message, &error, &debug);
3347 gst_error = GST_ELEMENT (GST_MESSAGE_SRC (message));
3349 g_message ("Element error: %s -- %s\n", error->message, debug);
3351 if (g_str_has_prefix (gst_element_get_name (gst_error),
3352 VIDEO_INPUT_ERROR_PREFIX))
3354 /* Remove the video input and continue */
3355 if (priv->video_input != NULL)
3356 empathy_call_window_remove_video_input (self);
3357 gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
3361 empathy_call_window_disconnected (self, TRUE);
3363 g_error_free (error);
3366 case GST_MESSAGE_UNKNOWN:
3367 case GST_MESSAGE_EOS:
3368 case GST_MESSAGE_WARNING:
3369 case GST_MESSAGE_INFO:
3370 case GST_MESSAGE_TAG:
3371 case GST_MESSAGE_BUFFERING:
3372 case GST_MESSAGE_STATE_DIRTY:
3373 case GST_MESSAGE_STEP_DONE:
3374 case GST_MESSAGE_CLOCK_PROVIDE:
3375 case GST_MESSAGE_CLOCK_LOST:
3376 case GST_MESSAGE_NEW_CLOCK:
3377 case GST_MESSAGE_STRUCTURE_CHANGE:
3378 case GST_MESSAGE_STREAM_STATUS:
3379 case GST_MESSAGE_APPLICATION:
3380 case GST_MESSAGE_ELEMENT:
3381 case GST_MESSAGE_SEGMENT_START:
3382 case GST_MESSAGE_SEGMENT_DONE:
3383 case GST_MESSAGE_DURATION:
3384 case GST_MESSAGE_ANY:
3393 empathy_call_window_members_changed_cb (TpyCallChannel *call,
3394 GHashTable *members,
3395 EmpathyCallWindow *self)
3397 EmpathyCallWindowPriv *priv = GET_PRIV (self);
3398 GHashTableIter iter;
3399 gpointer key, value;
3400 gboolean held = FALSE;
3402 g_hash_table_iter_init (&iter, members);
3403 while (g_hash_table_iter_next (&iter, &key, &value))
3405 if (GPOINTER_TO_INT (value) & TPY_CALL_MEMBER_FLAG_HELD)
3407 /* This assumes this is a 1-1 call, otherwise one participant
3408 * putting the call on hold wouldn't mean the call is on hold
3416 priv->call_state = HELD;
3417 else if (priv->call_state == HELD)
3418 priv->call_state = CONNECTED;
3422 call_handler_notify_call_cb (EmpathyCallHandler *handler,
3424 EmpathyCallWindow *self)
3426 EmpathyCallWindowPriv *priv = GET_PRIV (self);
3427 TpyCallChannel *call;
3429 g_object_get (priv->handler, "call-channel", &call, NULL);
3434 tp_g_signal_connect_object (call, "audio-stream-error",
3435 G_CALLBACK (empathy_call_window_audio_stream_error), self, 0);
3436 tp_g_signal_connect_object (call, "video-stream-error",
3437 G_CALLBACK (empathy_call_window_video_stream_error), self, 0);
3440 tp_g_signal_connect_object (call, "members-changed",
3441 G_CALLBACK (empathy_call_window_members_changed_cb), self, 0);
3443 tp_cli_channel_interface_dtmf_connect_to_stopped_tones (TP_CHANNEL (call),
3444 empathy_call_window_tones_stopped_cb, self, NULL,
3445 G_OBJECT (call), NULL);
3447 g_object_unref (call);
3451 empathy_call_window_connect_handler (EmpathyCallWindow *self)
3453 EmpathyCallWindowPriv *priv = GET_PRIV (self);
3454 TpyCallChannel *call;
3456 g_signal_connect (priv->handler, "state-changed",
3457 G_CALLBACK (empathy_call_window_state_changed_cb), self);
3458 g_signal_connect (priv->handler, "conference-added",
3459 G_CALLBACK (empathy_call_window_conference_added_cb), self);
3460 g_signal_connect (priv->handler, "conference-removed",
3461 G_CALLBACK (empathy_call_window_conference_removed_cb), self);
3462 g_signal_connect (priv->handler, "closed",
3463 G_CALLBACK (empathy_call_window_channel_closed_cb), self);
3464 g_signal_connect (priv->handler, "src-pad-added",
3465 G_CALLBACK (empathy_call_window_src_added_cb), self);
3466 g_signal_connect (priv->handler, "sink-pad-added",
3467 G_CALLBACK (empathy_call_window_sink_added_cb), self);
3468 g_signal_connect (priv->handler, "sink-pad-removed",
3469 G_CALLBACK (empathy_call_window_sink_removed_cb), self);
3471 g_object_get (priv->handler, "call-channel", &call, NULL);
3474 call_handler_notify_call_cb (priv->handler, NULL, self);
3475 g_object_unref (call);
3479 /* call-channel doesn't exist yet, we'll connect signals once it has been
3481 g_signal_connect (priv->handler, "notify::call-channel",
3482 G_CALLBACK (call_handler_notify_call_cb), self);
3487 empathy_call_window_realized_cb (GtkWidget *widget,
3488 EmpathyCallWindow *self)
3492 /* Make the hangup button twice as wide */
3493 width = gtk_widget_get_allocated_width (self->priv->hangup_button);
3494 gtk_widget_set_size_request (self->priv->hangup_button, width * 2, -1);
3496 empathy_call_window_connect_handler (self);
3498 gst_element_set_state (self->priv->pipeline, GST_STATE_PAUSED);
3502 empathy_call_window_delete_cb (GtkWidget *widget, GdkEvent*event,
3503 EmpathyCallWindow *window)
3505 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3507 if (priv->pipeline != NULL)
3509 if (priv->bus_message_source_id != 0)
3511 g_source_remove (priv->bus_message_source_id);
3512 priv->bus_message_source_id = 0;
3515 gst_element_set_state (priv->pipeline, GST_STATE_NULL);
3518 if (priv->call_state == CONNECTING)
3519 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
3525 show_controls (EmpathyCallWindow *window, gboolean set_fullscreen)
3528 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3530 menu = gtk_ui_manager_get_widget (priv->ui_manager,
3535 gtk_widget_hide (priv->dtmf_panel);
3536 gtk_widget_hide (menu);
3537 gtk_widget_hide (priv->toolbar);
3541 if (priv->dialpad_was_visible_before_fs)
3542 gtk_widget_show (priv->dtmf_panel);
3544 gtk_widget_show (menu);
3545 gtk_widget_show (priv->toolbar);
3547 gtk_window_resize (GTK_WINDOW (window), priv->original_width_before_fs,
3548 priv->original_height_before_fs);
3553 show_borders (EmpathyCallWindow *window, gboolean set_fullscreen)
3555 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3557 gtk_container_set_border_width (GTK_CONTAINER (priv->content_hbox),
3558 set_fullscreen ? 0 : CONTENT_HBOX_BORDER_WIDTH);
3559 gtk_box_set_spacing (GTK_BOX (priv->content_hbox),
3560 set_fullscreen ? 0 : CONTENT_HBOX_SPACING);
3562 if (priv->video_output != NULL)
3565 gtk_box_set_child_packing (GTK_BOX (priv->content_hbox),
3566 priv->video_output, TRUE, TRUE,
3567 set_fullscreen ? 0 : CONTENT_HBOX_CHILDREN_PACKING_PADDING,
3574 empathy_call_window_state_event_cb (GtkWidget *widget,
3575 GdkEventWindowState *event, EmpathyCallWindow *window)
3577 if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
3579 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3580 gboolean set_fullscreen = event->new_window_state &
3581 GDK_WINDOW_STATE_FULLSCREEN;
3585 gboolean dialpad_was_visible;
3586 GtkAllocation allocation;
3587 gint original_width, original_height;
3589 gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
3590 original_width = allocation.width;
3591 original_height = allocation.height;
3593 g_object_get (priv->dtmf_panel,
3594 "visible", &dialpad_was_visible,
3597 priv->dialpad_was_visible_before_fs = dialpad_was_visible;
3598 priv->original_width_before_fs = original_width;
3599 priv->original_height_before_fs = original_height;
3601 if (priv->video_output_motion_handler_id == 0 &&
3602 priv->video_output != NULL)
3604 priv->video_output_motion_handler_id = g_signal_connect (
3605 G_OBJECT (priv->video_container), "motion-notify-event",
3606 G_CALLBACK (empathy_call_window_video_output_motion_notify),
3612 disconnect_video_output_motion_handler (window);
3615 empathy_call_window_fullscreen_set_fullscreen (priv->fullscreen,
3617 show_controls (window, set_fullscreen);
3618 show_borders (window, set_fullscreen);
3619 gtk_action_set_stock_id (priv->menu_fullscreen,
3620 (set_fullscreen ? "gtk-leave-fullscreen" : "gtk-fullscreen"));
3621 priv->is_fullscreen = set_fullscreen;
3628 empathy_call_window_show_dialpad (EmpathyCallWindow *window,
3631 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3632 int w, h, dialpad_width;
3633 GtkAllocation allocation;
3635 gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
3636 w = allocation.width;
3637 h = allocation.height;
3639 gtk_widget_get_preferred_width (priv->dtmf_panel, &dialpad_width, NULL);
3643 gtk_widget_show (priv->dtmf_panel);
3649 gtk_widget_hide (priv->dtmf_panel);
3653 gtk_window_resize (GTK_WINDOW (window), w, h);
3657 empathy_call_window_set_send_video (EmpathyCallWindow *window,
3660 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3661 TpyCallChannel *call;
3663 priv->sending_video = (state == CAMERA_STATE_ON);
3665 if (state == CAMERA_STATE_ON)
3667 /* When we start sending video, we want to show the video preview by
3669 display_video_preview (window, TRUE);
3673 display_video_preview (window, FALSE);
3676 if (priv->call_state != CONNECTED)
3679 g_object_get (priv->handler, "call-channel", &call, NULL);
3680 DEBUG ("%s sending video", priv->sending_video ? "start": "stop");
3681 tpy_call_channel_send_video (call, priv->sending_video);
3682 g_object_unref (call);
3686 empathy_call_window_mic_toggled_cb (GtkToggleToolButton *toggle,
3687 EmpathyCallWindow *self)
3689 EmpathyCallWindowPriv *priv = GET_PRIV (self);
3692 active = (gtk_toggle_tool_button_get_active (toggle));
3694 /* We don't want the settings callback to react to this change to avoid
3696 g_signal_handlers_block_by_func (priv->settings,
3697 empathy_call_window_prefs_volume_changed_cb, self);
3701 g_settings_set_double (priv->settings, EMPATHY_PREFS_CALL_SOUND_VOLUME,
3702 priv->volume * 100);
3706 /* TODO, Instead of setting the input volume to 0 we should probably
3707 * stop sending but this would cause the audio call to drop if both
3708 * sides mute at the same time on certain CMs AFAIK. Need to revisit this
3709 * in the future. GNOME #574574
3711 g_settings_set_double (priv->settings, EMPATHY_PREFS_CALL_SOUND_VOLUME,
3715 g_signal_handlers_unblock_by_func (priv->settings,
3716 empathy_call_window_prefs_volume_changed_cb, self);
3720 empathy_call_window_hangup_cb (gpointer object,
3721 EmpathyCallWindow *self)
3723 empathy_call_handler_stop_call (self->priv->handler);
3725 empathy_call_window_disconnected (self, TRUE);
3729 empathy_call_window_restart_call (EmpathyCallWindow *window)
3731 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3733 /* Remove error info bars */
3734 gtk_container_forall (GTK_CONTAINER (priv->errors_vbox),
3735 (GtkCallback) gtk_widget_destroy, NULL);
3737 create_video_output_widget (window);
3739 /* While the call was disconnected, the input volume might have changed.
3740 * However, since the audio_input source was destroyed, its volume has not
3741 * been updated during that time. That's why we manually update it here */
3742 empathy_call_window_mic_volume_changed (window);
3744 priv->outgoing = TRUE;
3745 empathy_call_window_set_state_connecting (window);
3747 if (priv->pipeline_playing)
3748 start_call (window);
3750 /* call will be started when the pipeline is ready */
3751 priv->start_call_when_playing = TRUE;
3753 empathy_call_window_setup_avatars (window, priv->handler);
3755 empathy_call_window_show_hangup_button (window, TRUE);
3759 empathy_call_window_dialpad_cb (GtkToggleToolButton *button,
3760 EmpathyCallWindow *window)
3764 active = gtk_toggle_tool_button_get_active (button);
3766 empathy_call_window_show_dialpad (window, active);
3770 empathy_call_window_fullscreen_cb (gpointer object,
3771 EmpathyCallWindow *window)
3773 empathy_call_window_fullscreen_toggle (window);
3777 empathy_call_window_fullscreen_toggle (EmpathyCallWindow *window)
3779 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3781 if (priv->is_fullscreen)
3782 gtk_window_unfullscreen (GTK_WINDOW (window));
3784 gtk_window_fullscreen (GTK_WINDOW (window));
3788 empathy_call_window_video_button_press_cb (GtkWidget *video_preview,
3789 GdkEventButton *event, EmpathyCallWindow *window)
3791 if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
3793 empathy_call_window_video_menu_popup (window, event->button);
3801 empathy_call_window_key_press_cb (GtkWidget *video_output,
3802 GdkEventKey *event, EmpathyCallWindow *window)
3804 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3806 if (priv->is_fullscreen && event->keyval == GDK_KEY_Escape)
3808 /* Since we are in fullscreen mode, toggling will bring us back to
3810 empathy_call_window_fullscreen_toggle (window);
3818 empathy_call_window_video_output_motion_notify (GtkWidget *widget,
3819 GdkEventMotion *event, EmpathyCallWindow *window)
3821 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3823 if (priv->is_fullscreen)
3825 empathy_call_window_fullscreen_show_popup (priv->fullscreen);
3827 /* Show the bottom toolbar */
3828 empathy_call_window_motion_notify_cb (NULL, NULL, window);
3835 empathy_call_window_video_menu_popup (EmpathyCallWindow *window,
3839 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3841 menu = gtk_ui_manager_get_widget (priv->ui_manager,
3843 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
3844 button, gtk_get_current_event_time ());
3845 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
3849 empathy_call_window_status_message (EmpathyCallWindow *self,
3852 gtk_label_set_label (GTK_LABEL (self->priv->status_label), message);
3856 empathy_call_window_volume_changed_cb (GtkScaleButton *button,
3857 gdouble value, EmpathyCallWindow *window)
3859 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3861 if (priv->audio_output == NULL)
3864 empathy_audio_sink_set_volume (EMPATHY_GST_AUDIO_SINK (priv->audio_output),
3869 empathy_call_window_get_ui_manager (EmpathyCallWindow *window)
3871 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3873 return priv->ui_manager;
3876 EmpathyGstAudioSrc *
3877 empathy_call_window_get_audio_src (EmpathyCallWindow *window)
3879 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3881 return (EmpathyGstAudioSrc *) priv->audio_input;
3884 EmpathyGstVideoSrc *
3885 empathy_call_window_get_video_src (EmpathyCallWindow *self)
3887 return EMPATHY_GST_VIDEO_SRC (self->priv->video_input);