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,
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 GtkWidget *dtmf_panel;
204 GtkWidget *details_vbox;
205 GtkWidget *vcodec_encoding_label;
206 GtkWidget *acodec_encoding_label;
207 GtkWidget *vcodec_decoding_label;
208 GtkWidget *acodec_decoding_label;
210 GtkWidget *audio_remote_candidate_label;
211 GtkWidget *audio_local_candidate_label;
212 GtkWidget *video_remote_candidate_label;
213 GtkWidget *video_local_candidate_label;
214 GtkWidget *video_remote_candidate_info_img;
215 GtkWidget *video_local_candidate_info_img;
216 GtkWidget *audio_remote_candidate_info_img;
217 GtkWidget *audio_local_candidate_info_img;
219 GstElement *video_input;
220 GstElement *video_preview_sink;
221 GstElement *video_output_sink;
222 GstElement *audio_input;
223 GstElement *audio_output;
224 GstElement *pipeline;
225 GstElement *video_tee;
235 gboolean call_started;
236 gboolean sending_video;
237 CameraState camera_state;
239 EmpathyCallWindowFullscreen *fullscreen;
240 gboolean is_fullscreen;
245 guint inactivity_src;
247 /* Those fields represent the state of the window before it actually was in
249 gboolean dialpad_was_visible_before_fs;
250 gint original_width_before_fs;
251 gint original_height_before_fs;
253 gint x, y, w, h, dialpad_width;
256 /* TRUE if the call should be started when the pipeline is playing */
257 gboolean start_call_when_playing;
258 /* TRUE if we requested to set the pipeline in the playing state */
259 gboolean pipeline_playing;
261 EmpathySoundManager *sound_mgr;
264 EmpathyMicMenu *mic_menu;
265 EmpathyCameraMenu *camera_menu;
268 #define GET_PRIV(o) (EMPATHY_CALL_WINDOW (o)->priv)
270 static void empathy_call_window_realized_cb (GtkWidget *widget,
271 EmpathyCallWindow *window);
273 static gboolean empathy_call_window_delete_cb (GtkWidget *widget,
274 GdkEvent *event, EmpathyCallWindow *window);
276 static gboolean empathy_call_window_state_event_cb (GtkWidget *widget,
277 GdkEventWindowState *event, EmpathyCallWindow *window);
279 static void empathy_call_window_set_send_video (EmpathyCallWindow *window,
282 static void empathy_call_window_mic_toggled_cb (
283 GtkToggleToolButton *toggle, EmpathyCallWindow *window);
285 static void empathy_call_window_hangup_cb (gpointer object,
286 EmpathyCallWindow *window);
288 static void empathy_call_window_fullscreen_cb (gpointer object,
289 EmpathyCallWindow *window);
291 static void empathy_call_window_fullscreen_toggle (EmpathyCallWindow *window);
293 static gboolean empathy_call_window_video_button_press_cb (
294 GtkWidget *video_output, GdkEventButton *event, EmpathyCallWindow *window);
296 static gboolean empathy_call_window_key_press_cb (GtkWidget *video_output,
297 GdkEventKey *event, EmpathyCallWindow *window);
299 static gboolean empathy_call_window_video_output_motion_notify (
300 GtkWidget *widget, GdkEventMotion *event, EmpathyCallWindow *window);
302 static void empathy_call_window_video_menu_popup (EmpathyCallWindow *window,
305 static void empathy_call_window_connect_handler (EmpathyCallWindow *self);
307 static void empathy_call_window_dialpad_cb (GtkToggleToolButton *button,
308 EmpathyCallWindow *window);
310 static void empathy_call_window_restart_call (EmpathyCallWindow *window);
312 static void empathy_call_window_status_message (EmpathyCallWindow *window,
315 static gboolean empathy_call_window_bus_message (GstBus *bus,
316 GstMessage *message, gpointer user_data);
319 empathy_call_window_volume_changed_cb (GtkScaleButton *button,
320 gdouble value, EmpathyCallWindow *window);
323 empathy_call_window_show_hangup_button (EmpathyCallWindow *self,
326 gtk_widget_set_visible (self->priv->hangup_button, show);
327 gtk_widget_set_visible (self->priv->audio_call_button, !show);
328 gtk_widget_set_visible (self->priv->video_call_button, !show);
332 empathy_call_window_audio_call_cb (GtkToggleToolButton *button,
333 EmpathyCallWindow *self)
335 g_object_set (self->priv->handler, "initial-video", FALSE, NULL);
336 empathy_call_window_restart_call (self);
340 empathy_call_window_video_call_cb (GtkToggleToolButton *button,
341 EmpathyCallWindow *self)
343 empathy_call_window_set_send_video (self, CAMERA_STATE_ON);
344 g_object_set (self->priv->handler, "initial-video", TRUE, NULL);
345 empathy_call_window_restart_call (self);
349 dtmf_button_pressed_cb (GtkButton *button, EmpathyCallWindow *window)
351 EmpathyCallWindowPriv *priv = GET_PRIV (window);
352 TpyCallChannel *call;
356 g_object_get (priv->handler, "call-channel", &call, NULL);
358 button_quark = g_quark_from_static_string (EMPATHY_DTMF_BUTTON_ID);
359 event = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (button),
362 tpy_call_channel_dtmf_start_tone (call, event);
364 g_object_unref (call);
368 dtmf_button_released_cb (GtkButton *button, EmpathyCallWindow *window)
370 EmpathyCallWindowPriv *priv = GET_PRIV (window);
371 TpyCallChannel *call;
373 g_object_get (priv->handler, "call-channel", &call, NULL);
375 tpy_call_channel_dtmf_stop_tone (call);
377 g_object_unref (call);
381 empathy_call_window_mic_volume_changed (EmpathyCallWindow *self)
383 EmpathyCallWindowPriv *priv = GET_PRIV (self);
386 volume = g_settings_get_double (priv->settings,
387 EMPATHY_PREFS_CALL_SOUND_VOLUME) / 100.0;
389 /* Don't store the volume because of muting */
390 if (volume > 0 || gtk_toggle_tool_button_get_active (
391 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
392 priv->volume = volume;
394 /* Ensure that the toggle button is active if the volume is > 0 and inactive
395 * if it's smaller than 0 */
396 if ((volume > 0) != gtk_toggle_tool_button_get_active (
397 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
398 gtk_toggle_tool_button_set_active (
399 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button), volume > 0);
401 empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
406 empathy_call_window_prefs_volume_changed_cb (GSettings *settings,
408 EmpathyCallWindow *self)
410 empathy_call_window_mic_volume_changed (self);
414 empathy_call_window_raise_actors (EmpathyCallWindow *self)
416 clutter_actor_raise_top (self->priv->floating_toolbar);
418 clutter_actor_raise_top (self->priv->preview_rectangle_box1);
419 clutter_actor_raise_top (self->priv->preview_rectangle_box2);
420 clutter_actor_raise_top (self->priv->preview_rectangle_box3);
421 clutter_actor_raise_top (self->priv->preview_rectangle_box4);
425 empathy_call_window_show_video_output (EmpathyCallWindow *self,
428 if (self->priv->video_output != NULL)
429 g_object_set (self->priv->video_output, "visible", show, NULL);
431 gtk_widget_set_visible (self->priv->remote_user_avatar_widget, !show);
433 empathy_call_window_raise_actors (self);
437 create_video_output_widget (EmpathyCallWindow *self)
439 EmpathyCallWindowPriv *priv = GET_PRIV (self);
441 g_assert (priv->video_output == NULL);
442 g_assert (priv->pipeline != NULL);
444 priv->video_output = clutter_texture_new ();
446 clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (priv->video_output),
449 priv->video_output_sink = clutter_gst_video_sink_new (
450 CLUTTER_TEXTURE (priv->video_output));
452 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_box),
455 gtk_widget_add_events (priv->video_container,
456 GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK);
457 g_signal_connect (G_OBJECT (priv->video_container), "button-press-event",
458 G_CALLBACK (empathy_call_window_video_button_press_cb), self);
462 create_video_input (EmpathyCallWindow *self)
464 EmpathyCallWindowPriv *priv = GET_PRIV (self);
466 g_assert (priv->video_input == NULL);
467 priv->video_input = empathy_video_src_new ();
468 gst_object_ref (priv->video_input);
469 gst_object_sink (priv->video_input);
473 create_audio_input (EmpathyCallWindow *self)
475 EmpathyCallWindowPriv *priv = GET_PRIV (self);
477 g_assert (priv->audio_input == NULL);
478 priv->audio_input = empathy_audio_src_new ();
479 gst_object_ref (priv->audio_input);
480 gst_object_sink (priv->audio_input);
484 add_video_preview_to_pipeline (EmpathyCallWindow *self)
486 EmpathyCallWindowPriv *priv = GET_PRIV (self);
489 g_assert (priv->video_preview != NULL);
490 g_assert (priv->pipeline != NULL);
491 g_assert (priv->video_input != NULL);
492 g_assert (priv->video_tee != NULL);
494 preview = priv->video_preview_sink;
496 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->video_input))
498 g_warning ("Could not add video input to pipeline");
502 if (!gst_bin_add (GST_BIN (priv->pipeline), preview))
504 g_warning ("Could not add video preview to pipeline");
508 if (!gst_element_link (priv->video_input, priv->video_tee))
510 g_warning ("Could not link video input to video tee");
514 if (!gst_element_link (priv->video_tee, preview))
516 g_warning ("Could not link video tee to video preview");
522 empathy_call_window_disable_camera_cb (GtkAction *action,
523 EmpathyCallWindow *self)
525 clutter_actor_destroy (self->priv->preview_hidden_button);
527 gtk_toggle_tool_button_set_active (
528 GTK_TOGGLE_TOOL_BUTTON (self->priv->camera_button), FALSE);
532 empathy_call_window_minimise_camera_cb (GtkAction *action,
533 EmpathyCallWindow *self)
535 clutter_actor_hide (self->priv->video_preview);
536 clutter_actor_show (self->priv->preview_hidden_button);
540 empathy_call_window_maximise_camera_cb (GtkAction *action,
541 EmpathyCallWindow *self)
543 clutter_actor_show (self->priv->video_preview);
544 clutter_actor_hide (self->priv->preview_hidden_button);
548 empathy_call_window_swap_camera_cb (GtkAction *action,
549 EmpathyCallWindow *self)
551 const GList *cameras, *l;
554 DEBUG ("Swapping the camera");
556 cameras = empathy_camera_monitor_get_cameras (self->priv->camera_monitor);
557 current_cam = empathy_video_src_dup_device (
558 EMPATHY_GST_VIDEO_SRC (self->priv->video_input));
560 for (l = cameras; l != NULL; l = l->next)
562 EmpathyCamera *camera = l->data;
564 if (!tp_strdiff (camera->device, current_cam))
569 next = l->next->data;
571 next = cameras->data;
573 /* EmpathyCameraMenu will update itself and do the actual change
575 g_settings_set_string (self->priv->settings,
576 EMPATHY_PREFS_CALL_CAMERA_DEVICE,
583 g_free (current_cam);
587 empathy_call_window_camera_added_cb (EmpathyCameraMonitor *monitor,
588 EmpathyCamera *camera,
589 EmpathyCallWindow *self)
591 const GList *cameras = empathy_camera_monitor_get_cameras (monitor);
593 gtk_action_set_visible (self->priv->menu_swap_camera,
594 g_list_length ((GList *) cameras) >= 2);
598 empathy_call_window_camera_removed_cb (EmpathyCameraMonitor *monitor,
599 EmpathyCamera *camera,
600 EmpathyCallWindow *self)
602 const GList *cameras = empathy_camera_monitor_get_cameras (monitor);
604 gtk_action_set_visible (self->priv->menu_swap_camera,
605 g_list_length ((GList *) cameras) >= 2);
609 empathy_call_window_preview_button_clicked_cb (GtkButton *button,
610 EmpathyCallWindow *self)
614 menu = gtk_ui_manager_get_widget (self->priv->ui_manager,
616 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
617 0, gtk_get_current_event_time ());
618 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
622 empathy_call_window_preview_hidden_button_clicked_cb (GtkButton *button,
623 EmpathyCallWindow *self)
627 menu = gtk_ui_manager_get_widget (self->priv->ui_manager,
628 "/preview-hidden-menu");
629 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
630 0, gtk_get_current_event_time ());
631 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
634 static ClutterActor *
635 empathy_call_window_create_preview_rectangle (EmpathyCallWindow *self,
637 ClutterBinAlignment x,
638 ClutterBinAlignment y)
640 ClutterLayoutManager *layout1, *layout2;
641 ClutterActor *rectangle;
642 ClutterActor *box1, *box2;
644 layout1 = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
645 CLUTTER_BIN_ALIGNMENT_START);
647 box1 = clutter_box_new (layout1);
651 rectangle = empathy_rounded_rectangle_new (
652 SELF_VIDEO_SECTION_WIDTH + 5,
653 SELF_VIDEO_SECTION_HEIGHT + 5);
655 clutter_actor_set_size (box1,
656 SELF_VIDEO_SECTION_WIDTH + 2 * SELF_VIDEO_SECTION_MARGIN,
657 SELF_VIDEO_SECTION_HEIGHT + 2 * SELF_VIDEO_SECTION_MARGIN +
658 FLOATING_TOOLBAR_HEIGHT + FLOATING_TOOLBAR_SPACING);
660 layout2 = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
661 CLUTTER_BIN_ALIGNMENT_CENTER);
663 /* We have a box with the margins and the video in the middle inside
664 * a bigger box with an extra bottom margin so we're not on top of
665 * the floating toolbar. */
666 box2 = clutter_box_new (layout2);
668 clutter_actor_set_size (box2,
669 SELF_VIDEO_SECTION_WIDTH + 2 * SELF_VIDEO_SECTION_MARGIN,
670 SELF_VIDEO_SECTION_HEIGHT + 2 * SELF_VIDEO_SECTION_MARGIN);
672 clutter_container_add_actor (CLUTTER_CONTAINER (box1), box2);
673 clutter_container_add_actor (CLUTTER_CONTAINER (box2), rectangle);
675 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (self->priv->video_layout),
678 clutter_actor_hide (rectangle);
684 empathy_call_window_create_preview_rectangles (EmpathyCallWindow *self)
686 self->priv->preview_rectangle1 =
687 empathy_call_window_create_preview_rectangle (self,
688 &self->priv->preview_rectangle_box1,
689 CLUTTER_BIN_ALIGNMENT_START, CLUTTER_BIN_ALIGNMENT_START);
690 self->priv->preview_rectangle2 =
691 empathy_call_window_create_preview_rectangle (self,
692 &self->priv->preview_rectangle_box2,
693 CLUTTER_BIN_ALIGNMENT_START, CLUTTER_BIN_ALIGNMENT_END);
694 self->priv->preview_rectangle3 =
695 empathy_call_window_create_preview_rectangle (self,
696 &self->priv->preview_rectangle_box3,
697 CLUTTER_BIN_ALIGNMENT_END, CLUTTER_BIN_ALIGNMENT_START);
698 self->priv->preview_rectangle4 =
699 empathy_call_window_create_preview_rectangle (self,
700 &self->priv->preview_rectangle_box4,
701 CLUTTER_BIN_ALIGNMENT_END, CLUTTER_BIN_ALIGNMENT_END);
705 empathy_call_window_show_preview_rectangles (EmpathyCallWindow *self,
708 g_object_set (self->priv->preview_rectangle1, "visible", show, NULL);
709 g_object_set (self->priv->preview_rectangle2, "visible", show, NULL);
710 g_object_set (self->priv->preview_rectangle3, "visible", show, NULL);
711 g_object_set (self->priv->preview_rectangle4, "visible", show, NULL);
714 static PreviewPosition
715 empathy_call_window_get_preview_position (EmpathyCallWindow *self,
720 PreviewPosition pos = PREVIEW_POS_NONE;
722 if (!clutter_actor_has_allocation (self->priv->video_box))
725 clutter_actor_get_geometry (self->priv->video_box, &box);
727 if (0 + SELF_VIDEO_SECTION_MARGIN <= event_x &&
728 event_x <= (0 + SELF_VIDEO_SECTION_MARGIN + (gint) SELF_VIDEO_SECTION_WIDTH) &&
729 0 + SELF_VIDEO_SECTION_MARGIN <= event_y &&
730 event_y <= (0 + SELF_VIDEO_SECTION_MARGIN + (gint) SELF_VIDEO_SECTION_HEIGHT))
732 pos = PREVIEW_POS_TOP_LEFT;
734 else if (box.width - SELF_VIDEO_SECTION_MARGIN >= event_x &&
735 event_x >= (box.width - SELF_VIDEO_SECTION_MARGIN - (gint) SELF_VIDEO_SECTION_WIDTH) &&
736 0 + SELF_VIDEO_SECTION_MARGIN <= event_y &&
737 event_y <= (0 + SELF_VIDEO_SECTION_MARGIN + (gint) SELF_VIDEO_SECTION_HEIGHT))
739 pos = PREVIEW_POS_TOP_RIGHT;
741 else if (0 + SELF_VIDEO_SECTION_MARGIN <= event_x &&
742 event_x <= (0 + SELF_VIDEO_SECTION_MARGIN + (gint) SELF_VIDEO_SECTION_WIDTH) &&
743 box.height - SELF_VIDEO_SECTION_MARGIN - FLOATING_TOOLBAR_HEIGHT - FLOATING_TOOLBAR_SPACING >= event_y &&
744 event_y >= (box.height - SELF_VIDEO_SECTION_MARGIN - FLOATING_TOOLBAR_HEIGHT - FLOATING_TOOLBAR_SPACING - (gint) SELF_VIDEO_SECTION_HEIGHT))
746 pos = PREVIEW_POS_BOTTOM_LEFT;
748 else if (box.width - SELF_VIDEO_SECTION_MARGIN >= event_x &&
749 event_x >= (box.width - SELF_VIDEO_SECTION_MARGIN - (gint) SELF_VIDEO_SECTION_WIDTH) &&
750 box.height - SELF_VIDEO_SECTION_MARGIN - SELF_VIDEO_SECTION_MARGIN - FLOATING_TOOLBAR_HEIGHT - FLOATING_TOOLBAR_SPACING >= event_y &&
751 event_y >= (box.height - SELF_VIDEO_SECTION_MARGIN - FLOATING_TOOLBAR_HEIGHT - FLOATING_TOOLBAR_SPACING - (gint) SELF_VIDEO_SECTION_HEIGHT))
753 pos = PREVIEW_POS_BOTTOM_RIGHT;
759 static ClutterActor *
760 empathy_call_window_get_preview_rectangle (EmpathyCallWindow *self,
763 ClutterActor *rectangle;
767 case PREVIEW_POS_TOP_LEFT:
768 rectangle = self->priv->preview_rectangle1;
770 case PREVIEW_POS_TOP_RIGHT:
771 rectangle = self->priv->preview_rectangle3;
773 case PREVIEW_POS_BOTTOM_LEFT:
774 rectangle = self->priv->preview_rectangle2;
776 case PREVIEW_POS_BOTTOM_RIGHT:
777 rectangle = self->priv->preview_rectangle4;
787 empathy_call_window_move_video_preview (EmpathyCallWindow *self,
790 ClutterBinLayout *layout = CLUTTER_BIN_LAYOUT (self->priv->video_layout);
792 DEBUG ("moving the video preview to %d", pos);
794 self->priv->preview_pos = pos;
798 case PREVIEW_POS_TOP_LEFT:
799 clutter_bin_layout_set_alignment (layout,
800 self->priv->video_preview,
801 CLUTTER_BIN_ALIGNMENT_START,
802 CLUTTER_BIN_ALIGNMENT_START);
804 case PREVIEW_POS_TOP_RIGHT:
805 clutter_bin_layout_set_alignment (layout,
806 self->priv->video_preview,
807 CLUTTER_BIN_ALIGNMENT_END,
808 CLUTTER_BIN_ALIGNMENT_START);
810 case PREVIEW_POS_BOTTOM_LEFT:
811 clutter_bin_layout_set_alignment (layout,
812 self->priv->video_preview,
813 CLUTTER_BIN_ALIGNMENT_START,
814 CLUTTER_BIN_ALIGNMENT_END);
816 case PREVIEW_POS_BOTTOM_RIGHT:
817 clutter_bin_layout_set_alignment (layout,
818 self->priv->video_preview,
819 CLUTTER_BIN_ALIGNMENT_END,
820 CLUTTER_BIN_ALIGNMENT_END);
823 g_warn_if_reached ();
826 g_settings_set_enum (self->priv->settings, "camera-position", pos);
830 empathy_call_window_highlight_preview_rectangle (EmpathyCallWindow *self,
833 ClutterActor *rectangle;
835 rectangle = empathy_call_window_get_preview_rectangle (self, pos);
837 empathy_rounded_rectangle_set_border_width (
838 EMPATHY_ROUNDED_RECTANGLE (rectangle), 5);
839 empathy_rounded_rectangle_set_border_color (
840 EMPATHY_ROUNDED_RECTANGLE (rectangle), CLUTTER_COLOR_Red);
844 empathy_call_window_darken_preview_rectangle (EmpathyCallWindow *self,
845 ClutterActor *rectangle)
847 empathy_rounded_rectangle_set_border_width (
848 EMPATHY_ROUNDED_RECTANGLE (rectangle), 1);
849 empathy_rounded_rectangle_set_border_color (
850 EMPATHY_ROUNDED_RECTANGLE (rectangle), CLUTTER_COLOR_Black);
854 empathy_call_window_darken_preview_rectangles (EmpathyCallWindow *self)
856 ClutterActor *rectangle;
858 rectangle = empathy_call_window_get_preview_rectangle (self,
859 self->priv->preview_pos);
861 /* We don't want to darken the rectangle where the preview
864 if (self->priv->preview_rectangle1 != rectangle)
865 empathy_call_window_darken_preview_rectangle (self,
866 self->priv->preview_rectangle1);
868 if (self->priv->preview_rectangle2 != rectangle)
869 empathy_call_window_darken_preview_rectangle (self,
870 self->priv->preview_rectangle2);
872 if (self->priv->preview_rectangle3 != rectangle)
873 empathy_call_window_darken_preview_rectangle (self,
874 self->priv->preview_rectangle3);
876 if (self->priv->preview_rectangle4 != rectangle)
877 empathy_call_window_darken_preview_rectangle (self,
878 self->priv->preview_rectangle4);
882 empathy_call_window_preview_on_drag_begin_cb (ClutterDragAction *action,
886 ClutterModifierType modifiers,
887 EmpathyCallWindow *self)
889 ClutterActor *stage = clutter_actor_get_stage (actor);
892 self->priv->drag_preview = clutter_clone_new (actor);
894 clutter_container_add_actor (CLUTTER_CONTAINER (stage),
895 self->priv->drag_preview);
897 clutter_actor_transform_stage_point (actor, event_x, event_y,
900 clutter_actor_set_position (self->priv->drag_preview,
901 event_x - rel_x, event_y - rel_y);
903 clutter_drag_action_set_drag_handle (action,
904 self->priv->drag_preview);
906 clutter_actor_set_opacity (actor, 0);
907 clutter_actor_hide (self->priv->preview_shown_button);
909 empathy_call_window_show_preview_rectangles (self, TRUE);
910 empathy_call_window_darken_preview_rectangles (self);
914 empathy_call_window_preview_on_drag_end_cb (ClutterDragAction *action,
918 ClutterModifierType modifiers,
919 EmpathyCallWindow *self)
923 /* Get the position before destroying the drag actor, otherwise the
924 * preview_box allocation won't be valid and we won't be able to
925 * calculate the position. */
926 pos = empathy_call_window_get_preview_position (self, event_x, event_y);
928 /* Destroy the video preview copy that we were dragging */
929 clutter_actor_destroy (self->priv->drag_preview);
930 self->priv->drag_preview = NULL;
932 clutter_actor_set_opacity (actor, 255);
933 clutter_actor_show (self->priv->preview_shown_button);
935 if (pos != PREVIEW_POS_NONE)
936 empathy_call_window_move_video_preview (self, pos);
938 empathy_call_window_show_preview_rectangles (self, FALSE);
942 empathy_call_window_preview_on_drag_motion_cb (ClutterDragAction *action,
946 EmpathyCallWindow *self)
949 gfloat event_x, event_y;
951 clutter_drag_action_get_motion_coords (action, &event_x, &event_y);
953 pos = empathy_call_window_get_preview_position (self, event_x, event_y);
955 if (pos != PREVIEW_POS_NONE)
956 empathy_call_window_highlight_preview_rectangle (self, pos);
958 empathy_call_window_darken_preview_rectangles (self);
962 empathy_call_window_preview_enter_event_cb (ClutterActor *actor,
963 ClutterCrossingEvent *event,
964 EmpathyCallWindow *self)
966 ClutterActor *rectangle;
968 rectangle = empathy_call_window_get_preview_rectangle (self,
969 self->priv->preview_pos);
971 empathy_call_window_highlight_preview_rectangle (self,
972 self->priv->preview_pos);
974 clutter_actor_show (rectangle);
980 empathy_call_window_preview_leave_event_cb (ClutterActor *actor,
981 ClutterCrossingEvent *event,
982 EmpathyCallWindow *self)
984 ClutterActor *rectangle;
986 rectangle = empathy_call_window_get_preview_rectangle (self,
987 self->priv->preview_pos);
989 empathy_call_window_darken_preview_rectangle (self, rectangle);
991 clutter_actor_hide (rectangle);
997 create_video_preview (EmpathyCallWindow *self)
999 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1000 ClutterLayoutManager *layout, *layout_center, *layout_end;
1001 ClutterActor *preview;
1004 ClutterAction *action;
1006 PreviewPosition pos;
1008 g_assert (priv->video_preview == NULL);
1010 pos = g_settings_get_enum (priv->settings, "camera-position");
1012 preview = empathy_rounded_texture_new ();
1013 clutter_actor_set_size (preview,
1014 SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGHT);
1015 priv->video_preview_sink = clutter_gst_video_sink_new (
1016 CLUTTER_TEXTURE (preview));
1018 /* Add a little offset to the video preview */
1019 layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
1020 CLUTTER_BIN_ALIGNMENT_START);
1021 priv->video_preview = clutter_box_new (layout);
1022 clutter_actor_set_size (priv->video_preview,
1023 SELF_VIDEO_SECTION_WIDTH + 2 * SELF_VIDEO_SECTION_MARGIN,
1024 SELF_VIDEO_SECTION_HEIGHT + 2 * SELF_VIDEO_SECTION_MARGIN +
1025 FLOATING_TOOLBAR_HEIGHT + FLOATING_TOOLBAR_SPACING);
1027 /* We have a box with the margins and the video in the middle inside
1028 * a bigger box with an extra bottom margin so we're not on top of
1029 * the floating toolbar. */
1030 layout_center = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
1031 CLUTTER_BIN_ALIGNMENT_CENTER);
1032 box = clutter_box_new (layout_center);
1033 clutter_actor_set_size (box,
1034 SELF_VIDEO_SECTION_WIDTH + 2 * SELF_VIDEO_SECTION_MARGIN,
1035 SELF_VIDEO_SECTION_HEIGHT + 2 * SELF_VIDEO_SECTION_MARGIN);
1037 clutter_container_add_actor (CLUTTER_CONTAINER (box), preview);
1038 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_preview), box);
1040 g_object_set (priv->video_preview_sink,
1045 /* Translators: this is an "Info" label. It should be as short
1047 button = gtk_button_new_with_label (_("i"));
1048 priv->preview_shown_button = b = empathy_rounded_actor_new ();
1050 GTK_CONTAINER (gtk_clutter_actor_get_widget (GTK_CLUTTER_ACTOR (b))),
1052 clutter_actor_set_size (b, 24, 24);
1054 layout_end = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_END,
1055 CLUTTER_BIN_ALIGNMENT_END);
1056 box = clutter_box_new (layout_end);
1057 clutter_actor_set_size (box,
1058 SELF_VIDEO_SECTION_WIDTH,
1059 SELF_VIDEO_SECTION_HEIGHT + SELF_VIDEO_SECTION_MARGIN);
1061 clutter_container_add_actor (CLUTTER_CONTAINER (box), b);
1062 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_preview), box);
1064 g_signal_connect (button, "clicked",
1065 G_CALLBACK (empathy_call_window_preview_button_clicked_cb),
1068 /* Translators: this is an "Info" label. It should be as short
1070 button = gtk_button_new_with_label (_("i"));
1071 b = empathy_rounded_actor_new ();
1073 GTK_CONTAINER (gtk_clutter_actor_get_widget (GTK_CLUTTER_ACTOR (b))),
1075 clutter_actor_set_size (b, 24, 24);
1076 priv->preview_hidden_button = b;
1078 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
1079 priv->preview_hidden_button,
1080 CLUTTER_BIN_ALIGNMENT_START,
1081 CLUTTER_BIN_ALIGNMENT_END);
1083 self->priv->preview_pos = PREVIEW_POS_BOTTOM_LEFT;
1085 clutter_actor_hide (priv->preview_hidden_button);
1087 g_signal_connect (button, "clicked",
1088 G_CALLBACK (empathy_call_window_preview_hidden_button_clicked_cb),
1091 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
1092 priv->video_preview,
1093 CLUTTER_BIN_ALIGNMENT_START,
1094 CLUTTER_BIN_ALIGNMENT_END);
1096 empathy_call_window_move_video_preview (self, pos);
1098 action = clutter_drag_action_new ();
1099 g_signal_connect (action, "drag-begin",
1100 G_CALLBACK (empathy_call_window_preview_on_drag_begin_cb), self);
1101 g_signal_connect (action, "drag-end",
1102 G_CALLBACK (empathy_call_window_preview_on_drag_end_cb), self);
1103 g_signal_connect (action, "drag-motion",
1104 G_CALLBACK (empathy_call_window_preview_on_drag_motion_cb), self);
1106 g_signal_connect (preview, "enter-event",
1107 G_CALLBACK (empathy_call_window_preview_enter_event_cb), self);
1108 g_signal_connect (preview, "leave-event",
1109 G_CALLBACK (empathy_call_window_preview_leave_event_cb), self);
1111 clutter_actor_add_action (preview, action);
1112 clutter_actor_set_reactive (preview, TRUE);
1113 clutter_actor_set_reactive (priv->preview_shown_button, TRUE);
1117 empathy_call_window_play_camera (EmpathyCallWindow *window,
1120 EmpathyCallWindowPriv *priv = GET_PRIV (window);
1121 GstElement *preview;
1124 if (priv->video_preview == NULL)
1126 create_video_preview (window);
1127 add_video_preview_to_pipeline (window);
1131 state = GST_STATE_PLAYING;
1133 state = GST_STATE_NULL;
1135 preview = priv->video_preview_sink;
1137 gst_element_set_state (preview, state);
1138 gst_element_set_state (priv->video_input, state);
1139 gst_element_set_state (priv->video_tee, state);
1143 display_video_preview (EmpathyCallWindow *self,
1146 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1150 /* Display the video preview */
1151 DEBUG ("Show video preview");
1153 empathy_call_window_play_camera (self, TRUE);
1154 clutter_actor_show (priv->video_preview);
1155 clutter_actor_raise_top (priv->floating_toolbar);
1159 /* Hide the video preview */
1160 DEBUG ("Hide video preview");
1162 if (priv->video_preview != NULL)
1164 clutter_actor_hide (priv->video_preview);
1165 empathy_call_window_play_camera (self, FALSE);
1171 empathy_call_window_set_state_connecting (EmpathyCallWindow *window)
1173 EmpathyCallWindowPriv *priv = GET_PRIV (window);
1175 empathy_call_window_status_message (window, _("Connecting…"));
1176 priv->call_state = CONNECTING;
1178 /* Show the toolbar */
1179 clutter_state_set_state (priv->transitions, "fade-in");
1182 empathy_sound_manager_start_playing (priv->sound_mgr, GTK_WIDGET (window),
1183 EMPATHY_SOUND_PHONE_OUTGOING, MS_BETWEEN_RING);
1187 disable_camera (EmpathyCallWindow *self)
1189 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1191 if (priv->camera_state == CAMERA_STATE_OFF)
1194 DEBUG ("Disable camera");
1196 display_video_preview (self, FALSE);
1198 if (priv->camera_state == CAMERA_STATE_ON)
1199 empathy_call_window_set_send_video (self, CAMERA_STATE_OFF);
1201 priv->camera_state = CAMERA_STATE_OFF;
1205 enable_camera (EmpathyCallWindow *self)
1207 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1209 if (priv->camera_state == CAMERA_STATE_ON)
1212 if (priv->video_input == NULL)
1214 DEBUG ("Can't enable camera, no input");
1218 DEBUG ("Enable camera");
1220 empathy_call_window_set_send_video (self, CAMERA_STATE_ON);
1222 priv->camera_state = CAMERA_STATE_ON;
1226 empathy_call_window_camera_toggled_cb (GtkToggleToolButton *toggle,
1227 EmpathyCallWindow *self)
1229 if (gtk_toggle_tool_button_get_active (toggle))
1230 enable_camera (self);
1232 disable_camera (self);
1236 create_pipeline (EmpathyCallWindow *self)
1238 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1241 g_assert (priv->pipeline == NULL);
1243 priv->pipeline = gst_pipeline_new (NULL);
1244 priv->pipeline_playing = FALSE;
1246 priv->video_tee = gst_element_factory_make ("tee", NULL);
1247 gst_object_ref (priv->video_tee);
1248 gst_object_sink (priv->video_tee);
1250 gst_bin_add (GST_BIN (priv->pipeline), priv->video_tee);
1252 bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
1253 priv->bus_message_source_id = gst_bus_add_watch (bus,
1254 empathy_call_window_bus_message, self);
1256 g_object_unref (bus);
1260 empathy_call_window_settings_cb (GtkAction *action,
1261 EmpathyCallWindow *self)
1263 gchar *args = g_strdup_printf ("-p %s",
1264 empathy_preferences_tab_to_string (EMPATHY_PREFERENCES_TAB_CALLS));
1266 empathy_launch_program (BIN_DIR, "empathy", args);
1272 empathy_call_window_contents_cb (GtkAction *action,
1273 EmpathyCallWindow *self)
1275 empathy_url_show (GTK_WIDGET (self), "ghelp:empathy?audio-video");
1279 empathy_call_window_debug_cb (GtkAction *action,
1280 EmpathyCallWindow *self)
1282 empathy_launch_program (BIN_DIR, "empathy-debugger", "-s Empathy.Call");
1286 empathy_call_window_about_cb (GtkAction *action,
1287 EmpathyCallWindow *self)
1289 empathy_about_dialog_new (GTK_WINDOW (self));
1293 empathy_call_window_toolbar_timeout (gpointer data)
1295 EmpathyCallWindow *self = data;
1297 /* We don't want to hide the toolbar if we're not in a call, as
1298 * to show the call status all the time. */
1299 if (self->priv->call_state != CONNECTING &&
1300 self->priv->call_state != DISCONNECTED)
1301 clutter_state_set_state (self->priv->transitions, "fade-out");
1307 empathy_call_window_motion_notify_cb (GtkWidget *widget,
1309 EmpathyCallWindow *self)
1311 clutter_state_set_state (self->priv->transitions, "fade-in");
1313 if (self->priv->inactivity_src > 0)
1314 g_source_remove (self->priv->inactivity_src);
1316 self->priv->inactivity_src = g_timeout_add_seconds (3,
1317 empathy_call_window_toolbar_timeout, self);
1323 empathy_call_window_configure_event_cb (GtkWidget *widget,
1325 EmpathyCallWindow *self)
1327 GdkWindow *gdk_window;
1328 GdkWindowState window_state;
1330 gtk_window_get_position (GTK_WINDOW (self), &self->priv->x, &self->priv->y);
1331 gtk_window_get_size (GTK_WINDOW (self), &self->priv->w, &self->priv->h);
1333 gtk_widget_get_preferred_width (self->priv->dtmf_panel,
1334 &self->priv->dialpad_width, NULL);
1336 gdk_window = gtk_widget_get_window (widget);
1337 window_state = gdk_window_get_state (gdk_window);
1338 self->priv->maximized = (window_state & GDK_WINDOW_STATE_MAXIMIZED);
1344 empathy_call_window_destroyed_cb (GtkWidget *object,
1345 EmpathyCallWindow *self)
1347 if (gtk_widget_get_visible (self->priv->dtmf_panel))
1349 /* Save the geometry as if the dialpad was hidden. */
1350 empathy_geometry_save_values (GTK_WINDOW (self),
1351 self->priv->x, self->priv->y,
1352 self->priv->w - self->priv->dialpad_width, self->priv->h,
1353 self->priv->maximized);
1358 empathy_call_window_stage_allocation_changed_cb (ClutterActor *stage,
1360 ClutterBindConstraint *constraint)
1362 ClutterActorBox allocation;
1364 clutter_actor_get_allocation_box (stage, &allocation);
1366 clutter_bind_constraint_set_offset (constraint,
1367 allocation.y2 - allocation.y1 -
1368 FLOATING_TOOLBAR_SPACING - FLOATING_TOOLBAR_HEIGHT);
1372 empathy_call_window_incoming_call_response_cb (GtkDialog *dialog,
1374 EmpathyCallWindow *self)
1376 switch (response_id)
1378 case GTK_RESPONSE_ACCEPT:
1379 tp_channel_dispatch_operation_handle_with_async (
1380 self->priv->pending_cdo, EMPATHY_CALL_BUS_NAME, NULL, NULL);
1382 tp_clear_object (&self->priv->pending_cdo);
1383 tp_clear_object (&self->priv->pending_channel);
1384 tp_clear_object (&self->priv->pending_context);
1387 case GTK_RESPONSE_CANCEL:
1388 tp_channel_dispatch_operation_close_channels_async (
1389 self->priv->pending_cdo, NULL, NULL);
1391 empathy_call_window_status_message (self, _("Disconnected"));
1392 self->priv->call_state = DISCONNECTED;
1395 g_warn_if_reached ();
1400 empathy_call_window_set_state_ringing (EmpathyCallWindow *self)
1404 g_assert (self->priv->call_state != CONNECTED);
1406 video = tpy_call_channel_has_initial_video (self->priv->pending_channel);
1408 empathy_call_window_status_message (self, _("Incoming call"));
1409 self->priv->call_state = RINGING;
1411 self->priv->incoming_call_dialog = gtk_message_dialog_new (
1412 GTK_WINDOW (self), GTK_DIALOG_MODAL,
1413 GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
1414 video ? _("Incoming video call from %s") : _("Incoming call from %s"),
1415 empathy_contact_get_alias (self->priv->contact));
1417 gtk_dialog_add_buttons (GTK_DIALOG (self->priv->incoming_call_dialog),
1418 _("Reject"), GTK_RESPONSE_CANCEL,
1419 _("Answer"), GTK_RESPONSE_ACCEPT,
1422 g_signal_connect (self->priv->incoming_call_dialog, "response",
1423 G_CALLBACK (empathy_call_window_incoming_call_response_cb), self);
1424 gtk_widget_show (self->priv->incoming_call_dialog);
1428 empathy_call_window_cdo_invalidated_cb (TpProxy *channel,
1432 EmpathyCallWindow *self)
1434 tp_clear_object (&self->priv->pending_cdo);
1435 tp_clear_object (&self->priv->pending_channel);
1436 tp_clear_object (&self->priv->pending_context);
1438 /* We don't know if the incoming call has been accepted or not, so we
1439 * assume it hasn't and if it has, we'll set the proper status when
1440 * we get the new handler. */
1441 empathy_call_window_status_message (self, _("Disconnected"));
1442 self->priv->call_state = DISCONNECTED;
1444 gtk_widget_destroy (self->priv->incoming_call_dialog);
1445 self->priv->incoming_call_dialog = NULL;
1449 empathy_call_window_start_ringing (EmpathyCallWindow *self,
1450 TpyCallChannel *channel,
1451 TpChannelDispatchOperation *dispatch_operation,
1452 TpAddDispatchOperationContext *context)
1454 g_assert (self->priv->pending_channel == NULL);
1455 g_assert (self->priv->pending_context == NULL);
1456 g_assert (self->priv->pending_cdo == NULL);
1458 /* Start ringing and delay until the user answers or hangs. */
1459 self->priv->pending_channel = g_object_ref (channel);
1460 self->priv->pending_context = g_object_ref (context);
1461 self->priv->pending_cdo = g_object_ref (dispatch_operation);
1463 g_signal_connect (self->priv->pending_cdo, "invalidated",
1464 G_CALLBACK (empathy_call_window_cdo_invalidated_cb), self);
1466 empathy_call_window_set_state_ringing (self);
1467 tp_add_dispatch_operation_context_accept (context);
1471 empathy_call_window_init (EmpathyCallWindow *self)
1473 EmpathyCallWindowPriv *priv;
1475 GtkWidget *top_vbox;
1477 ClutterConstraint *constraint;
1478 ClutterActor *remote_avatar;
1479 GtkStyleContext *context;
1483 priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
1484 EMPATHY_TYPE_CALL_WINDOW, EmpathyCallWindowPriv);
1486 filename = empathy_file_lookup ("empathy-call-window.ui", "src");
1487 gui = empathy_builder_get_file (filename,
1488 "call_window_vbox", &top_vbox,
1489 "errors_vbox", &priv->errors_vbox,
1490 "pane", &priv->pane,
1491 "remote_user_name_toolbar", &priv->remote_user_name_toolbar,
1492 "remote_user_avatar_toolbar", &priv->remote_user_avatar_toolbar,
1493 "status_label", &priv->status_label,
1494 "audiocall", &priv->audio_call_button,
1495 "videocall", &priv->video_call_button,
1496 "microphone", &priv->mic_button,
1497 "camera", &priv->camera_button,
1498 "hangup", &priv->hangup_button,
1499 "dialpad", &priv->dialpad_button,
1500 "toolbar", &priv->toolbar,
1501 "bottom_toolbar", &priv->bottom_toolbar,
1502 "ui_manager", &priv->ui_manager,
1503 "menufullscreen", &priv->menu_fullscreen,
1504 "menupreviewswap", &priv->menu_swap_camera,
1505 "details_vbox", &priv->details_vbox,
1506 "vcodec_encoding_label", &priv->vcodec_encoding_label,
1507 "acodec_encoding_label", &priv->acodec_encoding_label,
1508 "acodec_decoding_label", &priv->acodec_decoding_label,
1509 "vcodec_decoding_label", &priv->vcodec_decoding_label,
1510 "audio_remote_candidate_label", &priv->audio_remote_candidate_label,
1511 "audio_local_candidate_label", &priv->audio_local_candidate_label,
1512 "video_remote_candidate_label", &priv->video_remote_candidate_label,
1513 "video_local_candidate_label", &priv->video_local_candidate_label,
1514 "video_remote_candidate_info_img", &priv->video_remote_candidate_info_img,
1515 "video_local_candidate_info_img", &priv->video_local_candidate_info_img,
1516 "audio_remote_candidate_info_img", &priv->audio_remote_candidate_info_img,
1517 "audio_local_candidate_info_img", &priv->audio_local_candidate_info_img,
1521 empathy_builder_connect (gui, self,
1522 "hangup", "clicked", empathy_call_window_hangup_cb,
1523 "audiocall", "clicked", empathy_call_window_audio_call_cb,
1524 "videocall", "clicked", empathy_call_window_video_call_cb,
1525 "volume", "value-changed", empathy_call_window_volume_changed_cb,
1526 "microphone", "toggled", empathy_call_window_mic_toggled_cb,
1527 "camera", "toggled", empathy_call_window_camera_toggled_cb,
1528 "dialpad", "toggled", empathy_call_window_dialpad_cb,
1529 "menufullscreen", "activate", empathy_call_window_fullscreen_cb,
1530 "menusettings", "activate", empathy_call_window_settings_cb,
1531 "menucontents", "activate", empathy_call_window_contents_cb,
1532 "menudebug", "activate", empathy_call_window_debug_cb,
1533 "menuabout", "activate", empathy_call_window_about_cb,
1534 "menupreviewdisable", "activate", empathy_call_window_disable_camera_cb,
1535 "menupreviewminimise", "activate", empathy_call_window_minimise_camera_cb,
1536 "menupreviewmaximise", "activate", empathy_call_window_maximise_camera_cb,
1537 "menupreviewswap", "activate", empathy_call_window_swap_camera_cb,
1540 gtk_action_set_sensitive (priv->menu_fullscreen, FALSE);
1542 priv->camera_monitor = empathy_camera_monitor_dup_singleton ();
1544 g_object_bind_property (priv->camera_monitor, "available",
1545 priv->camera_button, "sensitive",
1546 G_BINDING_SYNC_CREATE);
1548 g_signal_connect (priv->camera_monitor, "added",
1549 G_CALLBACK (empathy_call_window_camera_added_cb), self);
1550 g_signal_connect (priv->camera_monitor, "removed",
1551 G_CALLBACK (empathy_call_window_camera_removed_cb), self);
1553 priv->lock = g_mutex_new ();
1555 gtk_container_add (GTK_CONTAINER (self), top_vbox);
1557 priv->content_hbox = gtk_hbox_new (FALSE, CONTENT_HBOX_SPACING);
1558 gtk_container_set_border_width (GTK_CONTAINER (priv->content_hbox),
1559 CONTENT_HBOX_BORDER_WIDTH);
1560 gtk_box_pack_start (GTK_BOX (priv->pane), priv->content_hbox,
1563 /* avatar/video box */
1564 priv->video_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
1565 CLUTTER_BIN_ALIGNMENT_CENTER);
1567 priv->video_box = clutter_box_new (priv->video_layout);
1569 priv->video_container = gtk_clutter_embed_new ();
1571 /* Set the background color to that of the rest of the window */
1572 context = gtk_widget_get_style_context (priv->content_hbox);
1573 gtk_style_context_get_background_color (context,
1574 GTK_STATE_FLAG_NORMAL, &rgba);
1575 bg.red = CLAMP (rgba.red * 255.0, 0, 255);
1576 bg.green = CLAMP (rgba.green * 255.0, 0, 255);
1577 bg.blue = CLAMP (rgba.blue * 255.0, 0, 255);
1578 bg.alpha = CLAMP (rgba.alpha * 255.0, 0, 255);
1579 clutter_stage_set_color (
1580 CLUTTER_STAGE (gtk_clutter_embed_get_stage (
1581 GTK_CLUTTER_EMBED (priv->video_container))),
1584 clutter_container_add (
1585 CLUTTER_CONTAINER (gtk_clutter_embed_get_stage (
1586 GTK_CLUTTER_EMBED (priv->video_container))),
1590 constraint = clutter_bind_constraint_new (
1591 gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->video_container)),
1592 CLUTTER_BIND_SIZE, 0);
1593 clutter_actor_add_constraint (priv->video_box, constraint);
1595 priv->remote_user_avatar_widget = gtk_image_new ();
1596 remote_avatar = gtk_clutter_actor_new_with_contents (
1597 priv->remote_user_avatar_widget);
1599 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_box),
1602 empathy_call_window_create_preview_rectangles (self);
1604 gtk_box_pack_start (GTK_BOX (priv->content_hbox),
1605 priv->video_container, TRUE, TRUE,
1606 CONTENT_HBOX_CHILDREN_PACKING_PADDING);
1608 create_pipeline (self);
1609 create_video_output_widget (self);
1610 create_audio_input (self);
1611 create_video_input (self);
1613 priv->floating_toolbar = empathy_rounded_actor_new ();
1615 gtk_widget_reparent (priv->bottom_toolbar,
1616 gtk_clutter_actor_get_widget (GTK_CLUTTER_ACTOR (priv->floating_toolbar)));
1618 constraint = clutter_bind_constraint_new (
1619 gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->video_container)),
1622 clutter_actor_add_constraint (priv->floating_toolbar, constraint);
1625 gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->video_container)),
1626 "notify::allocation",
1627 G_CALLBACK (empathy_call_window_stage_allocation_changed_cb),
1630 clutter_actor_set_size (priv->floating_toolbar,
1631 FLOATING_TOOLBAR_WIDTH, FLOATING_TOOLBAR_HEIGHT);
1632 clutter_actor_set_opacity (priv->floating_toolbar, FLOATING_TOOLBAR_OPACITY);
1634 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
1635 priv->floating_toolbar,
1636 CLUTTER_BIN_ALIGNMENT_CENTER,
1637 CLUTTER_BIN_ALIGNMENT_END);
1639 clutter_actor_raise_top (priv->floating_toolbar);
1641 /* Transitions for the floating toolbar */
1642 priv->transitions = clutter_state_new ();
1644 /* all transitions last for 2s */
1645 clutter_state_set_duration (priv->transitions, NULL, NULL, 2000);
1647 /* transition from any state to "fade-out" state */
1648 clutter_state_set (priv->transitions, NULL, "fade-out",
1649 priv->floating_toolbar,
1650 "opacity", CLUTTER_EASE_OUT_QUAD, 0,
1653 /* transition from any state to "fade-in" state */
1654 clutter_state_set (priv->transitions, NULL, "fade-in",
1655 priv->floating_toolbar,
1656 "opacity", CLUTTER_EASE_OUT_QUAD, FLOATING_TOOLBAR_OPACITY,
1659 /* put the actor into the "fade-in" state with no animation */
1660 clutter_state_warp_to_state (priv->transitions, "fade-in");
1662 /* The call will be started as soon the pipeline is playing */
1663 priv->start_call_when_playing = TRUE;
1665 priv->dtmf_panel = empathy_create_dtmf_dialpad (G_OBJECT (self),
1666 G_CALLBACK (dtmf_button_pressed_cb),
1667 G_CALLBACK (dtmf_button_released_cb));
1669 gtk_box_pack_start (GTK_BOX (priv->pane), priv->dtmf_panel,
1672 gtk_box_pack_start (GTK_BOX (priv->pane), priv->details_vbox,
1675 gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
1677 gtk_widget_show_all (top_vbox);
1679 gtk_widget_hide (priv->dtmf_panel);
1680 gtk_widget_hide (priv->details_vbox);
1682 priv->fullscreen = empathy_call_window_fullscreen_new (self);
1684 empathy_call_window_fullscreen_set_video_widget (priv->fullscreen,
1685 priv->video_container);
1687 /* We hide the bottom toolbar after 3s of inactivity and show it
1688 * again on mouse movement */
1689 priv->inactivity_src = g_timeout_add_seconds (3,
1690 empathy_call_window_toolbar_timeout, self);
1692 g_signal_connect (G_OBJECT (priv->fullscreen->leave_fullscreen_button),
1693 "clicked", G_CALLBACK (empathy_call_window_fullscreen_cb), self);
1695 g_signal_connect (G_OBJECT (self), "realize",
1696 G_CALLBACK (empathy_call_window_realized_cb), self);
1698 g_signal_connect (G_OBJECT (self), "delete-event",
1699 G_CALLBACK (empathy_call_window_delete_cb), self);
1701 g_signal_connect (G_OBJECT (self), "window-state-event",
1702 G_CALLBACK (empathy_call_window_state_event_cb), self);
1704 g_signal_connect (G_OBJECT (self), "key-press-event",
1705 G_CALLBACK (empathy_call_window_key_press_cb), self);
1707 g_signal_connect (self, "motion-notify-event",
1708 G_CALLBACK (empathy_call_window_motion_notify_cb), self);
1710 priv->timer = g_timer_new ();
1712 g_object_ref (priv->ui_manager);
1713 g_object_unref (gui);
1715 priv->sound_mgr = empathy_sound_manager_dup_singleton ();
1716 priv->mic_menu = empathy_mic_menu_new (self);
1717 priv->camera_menu = empathy_camera_menu_new (self);
1719 empathy_call_window_show_hangup_button (self, TRUE);
1721 priv->settings = g_settings_new (EMPATHY_PREFS_CALL_SCHEMA);
1723 /* Retrieve initial volume */
1724 priv->volume = g_settings_get_double (priv->settings,
1725 EMPATHY_PREFS_CALL_SOUND_VOLUME) / 100.0;
1727 g_signal_connect (priv->settings, "changed::"EMPATHY_PREFS_CALL_SOUND_VOLUME,
1728 G_CALLBACK (empathy_call_window_prefs_volume_changed_cb), self);
1730 empathy_geometry_bind (GTK_WINDOW (self), "call-window");
1731 /* These signals are used to track the window position and save it
1732 * when the window is destroyed. We need to do this as we don't want
1733 * the window geometry to be saved with the dialpad taken into account. */
1734 g_signal_connect (self, "destroy",
1735 G_CALLBACK (empathy_call_window_destroyed_cb), self);
1736 g_signal_connect (self, "configure-event",
1737 G_CALLBACK (empathy_call_window_configure_event_cb), self);
1738 g_signal_connect (self, "window-state-event",
1739 G_CALLBACK (empathy_call_window_configure_event_cb), self);
1741 /* Don't display labels in both toolbars */
1742 gtk_toolbar_set_style (GTK_TOOLBAR (priv->toolbar), GTK_TOOLBAR_ICONS);
1745 /* Instead of specifying a width and a height, we specify only one size. That's
1746 because we want a square avatar icon. */
1748 init_contact_avatar_with_size (EmpathyContact *contact,
1749 GtkWidget *image_widget,
1752 GdkPixbuf *pixbuf_avatar = NULL;
1754 if (contact != NULL)
1756 pixbuf_avatar = empathy_pixbuf_avatar_from_contact_scaled (contact,
1760 if (pixbuf_avatar == NULL)
1762 pixbuf_avatar = empathy_pixbuf_from_icon_name_sized (
1763 EMPATHY_IMAGE_AVATAR_DEFAULT, size);
1766 gtk_image_set_from_pixbuf (GTK_IMAGE (image_widget), pixbuf_avatar);
1768 if (pixbuf_avatar != NULL)
1769 g_object_unref (pixbuf_avatar);
1773 set_window_title (EmpathyCallWindow *self)
1775 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1778 if (priv->contact != NULL)
1780 /* translators: Call is a noun and %s is the contact name. This string
1781 * is used in the window title */
1782 tmp = g_strdup_printf (_("Call with %s"),
1783 empathy_contact_get_alias (priv->contact));
1784 gtk_window_set_title (GTK_WINDOW (self), tmp);
1789 g_warning ("Unknown remote contact!");
1794 set_remote_user_name (EmpathyCallWindow *self,
1795 EmpathyContact *contact)
1797 const gchar *alias = empathy_contact_get_alias (contact);
1798 const gchar *status = empathy_contact_get_status (contact);
1801 label = g_strdup_printf ("%s\n<small>%s</small>", alias, status);
1802 gtk_label_set_markup (GTK_LABEL (self->priv->remote_user_name_toolbar),
1808 contact_name_changed_cb (EmpathyContact *contact,
1810 EmpathyCallWindow *self)
1812 set_window_title (self);
1813 set_remote_user_name (self, contact);
1817 contact_presence_changed_cb (EmpathyContact *contact,
1819 EmpathyCallWindow *self)
1821 set_remote_user_name (self, contact);
1825 contact_avatar_changed_cb (EmpathyContact *contact,
1827 EmpathyCallWindow *self)
1830 GtkAllocation allocation;
1831 GtkWidget *avatar_widget;
1833 avatar_widget = self->priv->remote_user_avatar_widget;
1835 gtk_widget_get_allocation (avatar_widget, &allocation);
1836 size = allocation.height;
1840 /* the widget is not allocated yet, set a default size */
1841 size = MIN (REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT,
1842 REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH);
1845 init_contact_avatar_with_size (contact, avatar_widget, size);
1847 avatar_widget = self->priv->remote_user_avatar_toolbar;
1849 gtk_widget_get_allocation (avatar_widget, &allocation);
1850 size = allocation.height;
1854 /* the widget is not allocated yet, set a default size */
1855 size = SMALL_TOOLBAR_SIZE;
1858 init_contact_avatar_with_size (contact, avatar_widget, size);
1862 empathy_call_window_setup_avatars (EmpathyCallWindow *self,
1863 EmpathyCallHandler *handler)
1865 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1867 tp_g_signal_connect_object (priv->contact, "notify::name",
1868 G_CALLBACK (contact_name_changed_cb), self, 0);
1869 tp_g_signal_connect_object (priv->contact, "notify::avatar",
1870 G_CALLBACK (contact_avatar_changed_cb), self, 0);
1871 tp_g_signal_connect_object (priv->contact, "notify::presence",
1872 G_CALLBACK (contact_presence_changed_cb), self, 0);
1874 set_window_title (self);
1875 set_remote_user_name (self, priv->contact);
1877 init_contact_avatar_with_size (priv->contact,
1878 priv->remote_user_avatar_widget,
1879 MIN (REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH,
1880 REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT));
1882 init_contact_avatar_with_size (priv->contact,
1883 priv->remote_user_avatar_toolbar,
1884 SMALL_TOOLBAR_SIZE);
1886 /* The remote avatar is shown by default and will be hidden when we receive
1887 video from the remote side. */
1888 clutter_actor_hide (priv->video_output);
1889 gtk_widget_show (priv->remote_user_avatar_widget);
1893 update_send_codec (EmpathyCallWindow *self,
1896 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1903 codec = empathy_call_handler_get_send_audio_codec (priv->handler);
1904 widget = priv->acodec_encoding_label;
1908 codec = empathy_call_handler_get_send_video_codec (priv->handler);
1909 widget = priv->vcodec_encoding_label;
1915 tmp = g_strdup_printf ("%s/%u", codec->encoding_name, codec->clock_rate);
1916 gtk_label_set_text (GTK_LABEL (widget), tmp);
1921 send_audio_codec_notify_cb (GObject *object,
1925 EmpathyCallWindow *self = user_data;
1927 update_send_codec (self, TRUE);
1931 send_video_codec_notify_cb (GObject *object,
1935 EmpathyCallWindow *self = user_data;
1937 update_send_codec (self, FALSE);
1941 update_recv_codec (EmpathyCallWindow *self,
1944 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1947 GString *str = NULL;
1951 codecs = empathy_call_handler_get_recv_audio_codecs (priv->handler);
1952 widget = priv->acodec_decoding_label;
1956 codecs = empathy_call_handler_get_recv_video_codecs (priv->handler);
1957 widget = priv->vcodec_decoding_label;
1963 for (l = codecs; l != NULL; l = g_list_next (l))
1965 FsCodec *codec = l->data;
1968 str = g_string_new (NULL);
1970 g_string_append (str, ", ");
1972 g_string_append_printf (str, "%s/%u", codec->encoding_name,
1976 gtk_label_set_text (GTK_LABEL (widget), str->str);
1977 g_string_free (str, TRUE);
1981 recv_audio_codecs_notify_cb (GObject *object,
1985 EmpathyCallWindow *self = user_data;
1987 update_recv_codec (self, TRUE);
1991 recv_video_codecs_notify_cb (GObject *object,
1995 EmpathyCallWindow *self = user_data;
1997 update_recv_codec (self, FALSE);
2000 static const gchar *
2001 candidate_type_to_str (FsCandidate *candidate)
2003 switch (candidate->type)
2005 case FS_CANDIDATE_TYPE_HOST:
2007 case FS_CANDIDATE_TYPE_SRFLX:
2008 return "server reflexive";
2009 case FS_CANDIDATE_TYPE_PRFLX:
2010 return "peer reflexive";
2011 case FS_CANDIDATE_TYPE_RELAY:
2013 case FS_CANDIDATE_TYPE_MULTICAST:
2020 static const gchar *
2021 candidate_type_to_desc (FsCandidate *candidate)
2023 switch (candidate->type)
2025 case FS_CANDIDATE_TYPE_HOST:
2026 return _("The IP address as seen by the machine");
2027 case FS_CANDIDATE_TYPE_SRFLX:
2028 return _("The IP address as seen by a server on the Internet");
2029 case FS_CANDIDATE_TYPE_PRFLX:
2030 return _("The IP address of the peer as seen by the other side");
2031 case FS_CANDIDATE_TYPE_RELAY:
2032 return _("The IP address of a relay server");
2033 case FS_CANDIDATE_TYPE_MULTICAST:
2034 return _("The IP address of the multicast group");
2041 update_candidat_widget (EmpathyCallWindow *self,
2044 FsCandidate *candidate)
2048 g_assert (candidate != NULL);
2049 str = g_strdup_printf ("%s %u (%s)", candidate->ip,
2050 candidate->port, candidate_type_to_str (candidate));
2052 gtk_label_set_text (GTK_LABEL (label), str);
2053 gtk_widget_set_tooltip_text (img, candidate_type_to_desc (candidate));
2059 candidates_changed_cb (GObject *object,
2061 EmpathyCallWindow *self)
2063 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2064 FsCandidate *candidate = NULL;
2066 if (type == FS_MEDIA_TYPE_VIDEO)
2068 /* Update remote candidate */
2069 candidate = empathy_call_handler_get_video_remote_candidate (
2072 update_candidat_widget (self, priv->video_remote_candidate_label,
2073 priv->video_remote_candidate_info_img, candidate);
2075 /* Update local candidate */
2076 candidate = empathy_call_handler_get_video_local_candidate (
2079 update_candidat_widget (self, priv->video_local_candidate_label,
2080 priv->video_local_candidate_info_img, candidate);
2084 /* Update remote candidate */
2085 candidate = empathy_call_handler_get_audio_remote_candidate (
2088 update_candidat_widget (self, priv->audio_remote_candidate_label,
2089 priv->audio_remote_candidate_info_img, candidate);
2091 /* Update local candidate */
2092 candidate = empathy_call_handler_get_audio_local_candidate (
2095 update_candidat_widget (self, priv->audio_local_candidate_label,
2096 priv->audio_local_candidate_info_img, candidate);
2101 empathy_call_window_constructed (GObject *object)
2103 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
2104 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2105 TpyCallChannel *call;
2107 g_assert (priv->handler != NULL);
2109 g_object_get (priv->handler, "call-channel", &call, NULL);
2110 priv->outgoing = (call == NULL);
2112 g_object_unref (call);
2114 g_object_get (priv->handler, "target-contact", &priv->contact, NULL);
2115 g_assert (priv->contact != NULL);
2117 if (!empathy_contact_can_voip_video (priv->contact))
2119 gtk_widget_set_sensitive (priv->video_call_button, FALSE);
2120 gtk_widget_set_sensitive (priv->camera_button, FALSE);
2123 empathy_call_window_setup_avatars (self, priv->handler);
2124 empathy_call_window_set_state_connecting (self);
2126 if (!empathy_call_handler_has_initial_video (priv->handler))
2128 gtk_toggle_tool_button_set_active (
2129 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), FALSE);
2131 /* If call has InitialVideo, the preview will be started once the call has
2132 * been started (start_call()). */
2134 update_send_codec (self, TRUE);
2135 update_send_codec (self, FALSE);
2136 update_recv_codec (self, TRUE);
2137 update_recv_codec (self, FALSE);
2139 tp_g_signal_connect_object (priv->handler, "notify::send-audio-codec",
2140 G_CALLBACK (send_audio_codec_notify_cb), self, 0);
2141 tp_g_signal_connect_object (priv->handler, "notify::send-video-codec",
2142 G_CALLBACK (send_video_codec_notify_cb), self, 0);
2143 tp_g_signal_connect_object (priv->handler, "notify::recv-audio-codecs",
2144 G_CALLBACK (recv_audio_codecs_notify_cb), self, 0);
2145 tp_g_signal_connect_object (priv->handler, "notify::recv-video-codecs",
2146 G_CALLBACK (recv_video_codecs_notify_cb), self, 0);
2148 tp_g_signal_connect_object (priv->handler, "candidates-changed",
2149 G_CALLBACK (candidates_changed_cb), self, 0);
2152 static void empathy_call_window_dispose (GObject *object);
2153 static void empathy_call_window_finalize (GObject *object);
2156 empathy_call_window_set_property (GObject *object,
2157 guint property_id, const GValue *value, GParamSpec *pspec)
2159 EmpathyCallWindowPriv *priv = GET_PRIV (object);
2161 switch (property_id)
2163 case PROP_CALL_HANDLER:
2164 priv->handler = g_value_dup_object (value);
2167 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
2172 empathy_call_window_get_property (GObject *object,
2173 guint property_id, GValue *value, GParamSpec *pspec)
2175 EmpathyCallWindowPriv *priv = GET_PRIV (object);
2177 switch (property_id)
2179 case PROP_CALL_HANDLER:
2180 g_value_set_object (value, priv->handler);
2183 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
2188 empathy_call_window_class_init (
2189 EmpathyCallWindowClass *empathy_call_window_class)
2191 GObjectClass *object_class = G_OBJECT_CLASS (empathy_call_window_class);
2192 GParamSpec *param_spec;
2194 g_type_class_add_private (empathy_call_window_class,
2195 sizeof (EmpathyCallWindowPriv));
2197 object_class->constructed = empathy_call_window_constructed;
2198 object_class->set_property = empathy_call_window_set_property;
2199 object_class->get_property = empathy_call_window_get_property;
2201 object_class->dispose = empathy_call_window_dispose;
2202 object_class->finalize = empathy_call_window_finalize;
2204 param_spec = g_param_spec_object ("handler",
2205 "handler", "The call handler",
2206 EMPATHY_TYPE_CALL_HANDLER,
2207 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
2208 g_object_class_install_property (object_class,
2209 PROP_CALL_HANDLER, param_spec);
2213 empathy_call_window_dispose (GObject *object)
2215 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
2216 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2218 if (priv->dispose_has_run)
2221 priv->dispose_has_run = TRUE;
2223 if (priv->handler != NULL)
2225 empathy_call_handler_stop_call (priv->handler);
2226 tp_clear_object (&priv->handler);
2229 if (priv->bus_message_source_id != 0)
2231 g_source_remove (priv->bus_message_source_id);
2232 priv->bus_message_source_id = 0;
2235 if (priv->got_video_src > 0)
2237 g_source_remove (priv->got_video_src);
2238 priv->got_video_src = 0;
2241 if (priv->inactivity_src > 0)
2243 g_source_remove (priv->inactivity_src);
2244 priv->inactivity_src = 0;
2247 tp_clear_object (&priv->pipeline);
2248 tp_clear_object (&priv->video_input);
2249 tp_clear_object (&priv->audio_input);
2250 tp_clear_object (&priv->video_tee);
2251 tp_clear_object (&priv->ui_manager);
2252 tp_clear_object (&priv->fullscreen);
2253 tp_clear_object (&priv->camera_monitor);
2254 tp_clear_object (&priv->settings);
2255 tp_clear_object (&priv->sound_mgr);
2256 tp_clear_object (&priv->mic_menu);
2257 tp_clear_object (&priv->camera_menu);
2259 g_list_free_full (priv->notifiers, g_object_unref);
2261 if (priv->timer_id != 0)
2262 g_source_remove (priv->timer_id);
2265 if (priv->contact != NULL)
2267 g_signal_handlers_disconnect_by_func (priv->contact,
2268 contact_name_changed_cb, self);
2269 priv->contact = NULL;
2272 G_OBJECT_CLASS (empathy_call_window_parent_class)->dispose (object);
2276 disconnect_video_output_motion_handler (EmpathyCallWindow *self)
2278 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2280 if (priv->video_output_motion_handler_id != 0)
2282 g_signal_handler_disconnect (G_OBJECT (priv->video_container),
2283 priv->video_output_motion_handler_id);
2284 priv->video_output_motion_handler_id = 0;
2289 empathy_call_window_finalize (GObject *object)
2291 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
2292 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2294 disconnect_video_output_motion_handler (self);
2296 /* free any data held directly by the object here */
2297 g_mutex_free (priv->lock);
2299 g_timer_destroy (priv->timer);
2301 G_OBJECT_CLASS (empathy_call_window_parent_class)->finalize (object);
2306 empathy_call_window_new (EmpathyCallHandler *handler)
2308 return EMPATHY_CALL_WINDOW (
2309 g_object_new (EMPATHY_TYPE_CALL_WINDOW, "handler", handler, NULL));
2313 empathy_call_window_present (EmpathyCallWindow *self,
2314 EmpathyCallHandler *handler)
2316 g_return_if_fail (EMPATHY_IS_CALL_HANDLER (handler));
2318 tp_clear_object (&self->priv->handler);
2319 self->priv->handler = g_object_ref (handler);
2320 empathy_call_window_connect_handler (self);
2322 empathy_window_present (GTK_WINDOW (self));
2323 empathy_call_window_restart_call (self);
2327 empathy_call_window_conference_added_cb (EmpathyCallHandler *handler,
2328 GstElement *conference, gpointer user_data)
2330 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2331 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2332 FsElementAddedNotifier *notifier;
2335 DEBUG ("Conference added");
2337 /* Add notifier to set the various element properties as needed */
2338 notifier = fs_element_added_notifier_new ();
2339 keyfile = fs_utils_get_default_element_properties (conference);
2341 if (keyfile != NULL)
2342 fs_element_added_notifier_set_properties_from_keyfile (notifier, keyfile);
2344 fs_element_added_notifier_add (notifier, GST_BIN (priv->pipeline));
2346 priv->notifiers = g_list_prepend (priv->notifiers, notifier);
2348 gst_bin_add (GST_BIN (priv->pipeline), conference);
2349 gst_element_set_state (conference, GST_STATE_PLAYING);
2353 empathy_call_window_conference_removed_cb (EmpathyCallHandler *handler,
2354 GstElement *conference, gpointer user_data)
2356 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2357 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2359 gst_bin_remove (GST_BIN (priv->pipeline), conference);
2360 gst_element_set_state (conference, GST_STATE_NULL);
2364 empathy_call_window_reset_pipeline (EmpathyCallWindow *self)
2366 GstStateChangeReturn state_change_return;
2367 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2369 if (priv->pipeline == NULL)
2372 if (priv->bus_message_source_id != 0)
2374 g_source_remove (priv->bus_message_source_id);
2375 priv->bus_message_source_id = 0;
2378 state_change_return = gst_element_set_state (priv->pipeline, GST_STATE_NULL);
2380 if (state_change_return == GST_STATE_CHANGE_SUCCESS ||
2381 state_change_return == GST_STATE_CHANGE_NO_PREROLL)
2383 if (priv->pipeline != NULL)
2384 g_object_unref (priv->pipeline);
2385 priv->pipeline = NULL;
2387 if (priv->audio_output != NULL)
2388 g_object_unref (priv->audio_output);
2389 priv->audio_output = NULL;
2391 if (priv->video_tee != NULL)
2392 g_object_unref (priv->video_tee);
2393 priv->video_tee = NULL;
2395 if (priv->video_preview != NULL)
2396 clutter_actor_destroy (priv->video_preview);
2397 priv->video_preview = NULL;
2399 /* If we destroy the preview while it's being dragged, we won't
2400 * get the ::drag-end signal, so manually destroy the clone */
2401 if (priv->drag_preview != NULL)
2403 clutter_actor_destroy (priv->drag_preview);
2404 empathy_call_window_show_preview_rectangles (self, FALSE);
2405 priv->drag_preview = NULL;
2408 priv->funnel = NULL;
2410 create_pipeline (self);
2411 /* Call will be started when user will hit the 'redial' button */
2412 priv->start_call_when_playing = FALSE;
2413 gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
2419 g_message ("Error: could not destroy pipeline. Closing call window");
2420 gtk_widget_destroy (GTK_WIDGET (self));
2427 reset_details_pane (EmpathyCallWindow *self)
2429 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2431 gtk_label_set_text (GTK_LABEL (priv->vcodec_encoding_label), _("Unknown"));
2432 gtk_label_set_text (GTK_LABEL (priv->acodec_encoding_label), _("Unknown"));
2433 gtk_label_set_text (GTK_LABEL (priv->vcodec_decoding_label), _("Unknown"));
2434 gtk_label_set_text (GTK_LABEL (priv->acodec_decoding_label), _("Unknown"));
2438 empathy_call_window_disconnected (EmpathyCallWindow *self,
2441 gboolean could_disconnect = FALSE;
2442 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2443 gboolean could_reset_pipeline;
2445 /* Leave full screen mode if needed */
2446 gtk_window_unfullscreen (GTK_WINDOW (self));
2448 gtk_action_set_sensitive (priv->menu_fullscreen, FALSE);
2449 gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
2451 could_reset_pipeline = empathy_call_window_reset_pipeline (self);
2453 if (priv->call_state == CONNECTING)
2454 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
2456 if (priv->call_state != REDIALING)
2457 priv->call_state = DISCONNECTED;
2459 /* Show the toolbar */
2460 clutter_state_set_state (priv->transitions, "fade-in");
2462 if (could_reset_pipeline)
2464 g_mutex_lock (priv->lock);
2466 g_timer_stop (priv->timer);
2468 if (priv->timer_id != 0)
2469 g_source_remove (priv->timer_id);
2472 g_mutex_unlock (priv->lock);
2475 /* We are about to destroy the window, no need to update it or create
2476 * a video preview */
2479 empathy_call_window_status_message (self, _("Disconnected"));
2481 empathy_call_window_show_hangup_button (self, FALSE);
2483 /* Unsensitive the camera and mic button */
2484 gtk_widget_set_sensitive (priv->camera_button, FALSE);
2485 gtk_widget_set_sensitive (priv->mic_button, FALSE);
2487 /* Be sure that the mic button is enabled */
2488 gtk_toggle_tool_button_set_active (
2489 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button), TRUE);
2491 if (priv->camera_state == CAMERA_STATE_ON)
2493 /* Restart the preview with the new pipeline. */
2494 display_video_preview (self, TRUE);
2497 /* destroy the video output; it will be recreated when we'll redial */
2498 disconnect_video_output_motion_handler (self);
2499 if (priv->video_output != NULL)
2500 clutter_actor_destroy (priv->video_output);
2501 priv->video_output = NULL;
2502 if (priv->got_video_src > 0)
2504 g_source_remove (priv->got_video_src);
2505 priv->got_video_src = 0;
2508 gtk_widget_show (priv->remote_user_avatar_widget);
2510 reset_details_pane (self);
2512 priv->sending_video = FALSE;
2513 priv->call_started = FALSE;
2515 could_disconnect = TRUE;
2517 /* TODO: display the self avatar of the preview (depends if the "Always
2518 * Show Video Preview" is enabled or not) */
2521 return could_disconnect;
2526 empathy_call_window_channel_closed_cb (EmpathyCallHandler *handler,
2529 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2530 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2532 if (empathy_call_window_disconnected (self, TRUE) &&
2533 priv->call_state == REDIALING)
2534 empathy_call_window_restart_call (self);
2538 empathy_call_window_sink_removed_cb (EmpathyCallHandler *handler,
2540 FsMediaType media_type,
2541 EmpathyCallWindow *self)
2543 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2545 DEBUG ("removing content");
2548 * This assumes that there is only one video stream per channel...
2551 if ((guint) media_type == FS_MEDIA_TYPE_VIDEO)
2553 if (priv->funnel != NULL)
2557 output = priv->video_output_sink;
2559 gst_element_set_state (output, GST_STATE_NULL);
2560 gst_element_set_state (priv->funnel, GST_STATE_NULL);
2562 gst_bin_remove (GST_BIN (priv->pipeline), output);
2563 gst_bin_remove (GST_BIN (priv->pipeline), priv->funnel);
2564 priv->funnel = NULL;
2568 else if (media_type == FS_MEDIA_TYPE_AUDIO)
2570 if (priv->audio_output != NULL)
2572 gst_element_set_state (priv->audio_output, GST_STATE_NULL);
2574 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
2575 priv->audio_output = NULL;
2583 /* Called with global lock held */
2585 empathy_call_window_get_video_sink_pad (EmpathyCallWindow *self)
2587 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2591 if (priv->funnel == NULL)
2593 output = priv->video_output_sink;
2595 priv->funnel = gst_element_factory_make ("fsfunnel", NULL);
2599 g_warning ("Could not create fsfunnel");
2603 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->funnel))
2605 gst_object_unref (priv->funnel);
2606 priv->funnel = NULL;
2607 g_warning ("Could not add funnel to pipeline");
2611 if (!gst_bin_add (GST_BIN (priv->pipeline), output))
2613 g_warning ("Could not add the video output widget to the pipeline");
2617 if (!gst_element_link (priv->funnel, output))
2619 g_warning ("Could not link output sink to funnel");
2620 goto error_output_added;
2623 if (gst_element_set_state (output, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2625 g_warning ("Could not start video sink");
2626 goto error_output_added;
2629 if (gst_element_set_state (priv->funnel, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2631 g_warning ("Could not start funnel");
2632 goto error_output_added;
2636 pad = gst_element_get_request_pad (priv->funnel, "sink%d");
2639 g_warning ("Could not get request pad from funnel");
2646 gst_element_set_locked_state (priv->funnel, TRUE);
2647 gst_element_set_locked_state (output, TRUE);
2649 gst_element_set_state (priv->funnel, GST_STATE_NULL);
2650 gst_element_set_state (output, GST_STATE_NULL);
2652 gst_bin_remove (GST_BIN (priv->pipeline), output);
2653 gst_element_set_locked_state (output, FALSE);
2657 gst_bin_remove (GST_BIN (priv->pipeline), priv->funnel);
2658 priv->funnel = NULL;
2663 /* Called with global lock held */
2665 empathy_call_window_get_audio_sink_pad (EmpathyCallWindow *self)
2667 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2669 GstPadTemplate *template;
2671 if (priv->audio_output == NULL)
2673 priv->audio_output = empathy_audio_sink_new ();
2674 g_object_ref_sink (priv->audio_output);
2676 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_output))
2678 g_warning ("Could not add audio sink to pipeline");
2679 g_object_unref (priv->audio_output);
2680 goto error_add_output;
2683 if (gst_element_set_state (priv->audio_output, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2685 g_warning ("Could not start audio sink");
2690 template = gst_element_class_get_pad_template (
2691 GST_ELEMENT_GET_CLASS (priv->audio_output), "sink%d");
2693 pad = gst_element_request_pad (priv->audio_output,
2694 template, NULL, NULL);
2698 g_warning ("Could not get sink pad from sink");
2705 gst_element_set_locked_state (priv->audio_output, TRUE);
2706 gst_element_set_state (priv->audio_output, GST_STATE_NULL);
2707 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
2708 priv->audio_output = NULL;
2716 empathy_call_window_update_timer (gpointer user_data)
2718 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2719 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2720 const gchar *status;
2724 time_ = g_timer_elapsed (priv->timer, NULL);
2726 if (priv->call_state == HELD)
2727 status = _("On hold");
2728 else if (!gtk_toggle_tool_button_get_active (
2729 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
2732 status = _("Duration");
2734 /* Translators: 'status - minutes:seconds' the caller has been connected */
2735 str = g_strdup_printf (_("%s — %d:%02dm"),
2737 (int) time_ / 60, (int) time_ % 60);
2738 empathy_call_window_status_message (self, str);
2746 display_error (EmpathyCallWindow *self,
2747 TpyCallChannel *call,
2751 const gchar *details)
2753 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2754 GtkWidget *info_bar;
2755 GtkWidget *content_area;
2762 /* Create info bar */
2763 info_bar = gtk_info_bar_new_with_buttons (GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
2766 gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_WARNING);
2768 content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar));
2770 /* hbox containing the image and the messages vbox */
2771 hbox = gtk_hbox_new (FALSE, 3);
2772 gtk_container_add (GTK_CONTAINER (content_area), hbox);
2775 image = gtk_image_new_from_icon_name (img, GTK_ICON_SIZE_DIALOG);
2776 gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
2778 /* vbox containing the main message and the details expander */
2779 vbox = gtk_vbox_new (FALSE, 3);
2780 gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
2783 txt = g_strdup_printf ("<b>%s</b>\n%s", title, desc);
2785 label = gtk_label_new (NULL);
2786 gtk_label_set_markup (GTK_LABEL (label), txt);
2787 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
2788 gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
2791 gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
2794 if (details != NULL)
2796 GtkWidget *expander;
2798 expander = gtk_expander_new (_("Technical Details"));
2800 txt = g_strdup_printf ("<i>%s</i>", details);
2802 label = gtk_label_new (NULL);
2803 gtk_label_set_markup (GTK_LABEL (label), txt);
2804 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
2805 gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
2808 gtk_container_add (GTK_CONTAINER (expander), label);
2809 gtk_box_pack_start (GTK_BOX (vbox), expander, TRUE, TRUE, 0);
2812 g_signal_connect (info_bar, "response",
2813 G_CALLBACK (gtk_widget_destroy), NULL);
2815 gtk_box_pack_start (GTK_BOX (priv->errors_vbox), info_bar,
2816 FALSE, FALSE, CONTENT_HBOX_CHILDREN_PACKING_PADDING);
2817 gtk_widget_show_all (info_bar);
2821 media_stream_error_to_txt (EmpathyCallWindow *self,
2822 TpyCallChannel *call,
2824 TpMediaStreamError error)
2826 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2827 const gchar *cm = NULL;
2833 case TP_MEDIA_STREAM_ERROR_CODEC_NEGOTIATION_FAILED:
2835 return g_strdup_printf (
2836 _("%s's software does not understand any of the audio formats "
2837 "supported by your computer"),
2838 empathy_contact_get_alias (priv->contact));
2840 return g_strdup_printf (
2841 _("%s's software does not understand any of the video formats "
2842 "supported by your computer"),
2843 empathy_contact_get_alias (priv->contact));
2845 case TP_MEDIA_STREAM_ERROR_CONNECTION_FAILED:
2846 return g_strdup_printf (
2847 _("Can't establish a connection to %s. "
2848 "One of you might be on a network that does not allow "
2849 "direct connections."),
2850 empathy_contact_get_alias (priv->contact));
2852 case TP_MEDIA_STREAM_ERROR_NETWORK_ERROR:
2853 return g_strdup (_("There was a failure on the network"));
2855 case TP_MEDIA_STREAM_ERROR_NO_CODECS:
2857 return g_strdup (_("The audio formats necessary for this call "
2858 "are not installed on your computer"));
2860 return g_strdup (_("The video formats necessary for this call "
2861 "are not installed on your computer"));
2863 case TP_MEDIA_STREAM_ERROR_INVALID_CM_BEHAVIOR:
2864 tp_connection_parse_object_path (
2865 tp_channel_borrow_connection (TP_CHANNEL (call)),
2868 url = g_strdup_printf ("http://bugs.freedesktop.org/enter_bug.cgi?"
2869 "product=Telepathy&component=%s", cm);
2871 result = g_strdup_printf (
2872 _("Something unexpected happened in a Telepathy component. "
2873 "Please <a href=\"%s\">report this bug</a> and attach "
2874 "logs gathered from the 'Debug' window in the Help menu."), url);
2880 case TP_MEDIA_STREAM_ERROR_MEDIA_ERROR:
2881 return g_strdup (_("There was a failure in the call engine"));
2883 case TP_MEDIA_STREAM_ERROR_EOS:
2884 return g_strdup (_("The end of the stream was reached"));
2886 case TP_MEDIA_STREAM_ERROR_UNKNOWN:
2893 empathy_call_window_stream_error (EmpathyCallWindow *self,
2894 TpyCallChannel *call,
2903 desc = media_stream_error_to_txt (self, call, audio, code);
2906 /* No description, use the error message. That's not great as it's not
2907 * localized but it's better than nothing. */
2908 display_error (self, call, icon, title, msg, NULL);
2912 display_error (self, call, icon, title, desc, msg);
2918 empathy_call_window_audio_stream_error (TpyCallChannel *call,
2921 EmpathyCallWindow *self)
2923 empathy_call_window_stream_error (self, call, TRUE, code, msg,
2924 "gnome-stock-mic", _("Can't establish audio stream"));
2928 empathy_call_window_video_stream_error (TpyCallChannel *call,
2931 EmpathyCallWindow *self)
2933 empathy_call_window_stream_error (self, call, FALSE, code, msg,
2934 "camera-web", _("Can't establish video stream"));
2939 empathy_call_window_state_changed_cb (EmpathyCallHandler *handler,
2941 EmpathyCallWindow *self)
2943 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2944 TpyCallChannel *call;
2945 gboolean can_send_video;
2947 if (state != TPY_CALL_STATE_ACCEPTED)
2950 if (priv->call_state == CONNECTED)
2953 g_timer_start (priv->timer);
2954 priv->call_state = CONNECTED;
2956 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
2958 can_send_video = priv->video_input != NULL &&
2959 empathy_contact_can_voip_video (priv->contact) &&
2960 empathy_camera_monitor_get_available (priv->camera_monitor);
2962 g_object_get (priv->handler, "call-channel", &call, NULL);
2964 if (tpy_call_channel_has_dtmf (call))
2965 gtk_widget_set_sensitive (priv->dtmf_panel, TRUE);
2967 if (priv->video_input == NULL)
2968 empathy_call_window_set_send_video (self, CAMERA_STATE_OFF);
2970 gtk_widget_set_sensitive (priv->camera_button, can_send_video);
2972 empathy_call_window_show_hangup_button (self, TRUE);
2974 gtk_widget_set_sensitive (priv->mic_button, TRUE);
2976 clutter_actor_hide (priv->video_output);
2977 gtk_widget_show (priv->remote_user_avatar_widget);
2979 g_object_unref (call);
2981 g_mutex_lock (priv->lock);
2983 priv->timer_id = g_timeout_add_seconds (1,
2984 empathy_call_window_update_timer, self);
2986 g_mutex_unlock (priv->lock);
2988 empathy_call_window_update_timer (self);
2990 gtk_action_set_sensitive (priv->menu_fullscreen, TRUE);
2994 empathy_call_window_show_video_output_cb (gpointer user_data)
2996 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2998 if (self->priv->video_output != NULL)
3000 gtk_widget_hide (self->priv->remote_user_avatar_widget);
3001 clutter_actor_show (self->priv->video_output);
3002 empathy_call_window_raise_actors (self);
3009 empathy_call_window_check_video_cb (gpointer data)
3011 EmpathyCallWindow *self = data;
3013 if (self->priv->got_video)
3015 self->priv->got_video = FALSE;
3019 /* No video in the last N seconds, display the remote avatar */
3020 empathy_call_window_show_video_output (self, FALSE);
3025 /* Called from the streaming thread */
3027 empathy_call_window_video_probe_cb (GstPad *pad,
3028 GstMiniObject *mini_obj,
3029 EmpathyCallWindow *self)
3032 if (GST_IS_EVENT (mini_obj))
3035 if (G_UNLIKELY (!self->priv->got_video))
3037 /* show the remote video */
3038 g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
3039 empathy_call_window_show_video_output_cb,
3040 g_object_ref (self), g_object_unref);
3042 self->priv->got_video = TRUE;
3048 /* Called from the streaming thread */
3050 empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
3051 GstPad *src, guint media_type, gpointer user_data)
3053 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
3054 EmpathyCallWindowPriv *priv = GET_PRIV (self);
3055 gboolean retval = FALSE;
3059 g_mutex_lock (priv->lock);
3063 case TP_MEDIA_STREAM_TYPE_AUDIO:
3064 pad = empathy_call_window_get_audio_sink_pad (self);
3066 case TP_MEDIA_STREAM_TYPE_VIDEO:
3067 g_idle_add (empathy_call_window_show_video_output_cb, self);
3068 pad = empathy_call_window_get_video_sink_pad (self);
3070 gst_pad_add_data_probe (src,
3071 G_CALLBACK (empathy_call_window_video_probe_cb), self);
3072 if (priv->got_video_src > 0)
3073 g_source_remove (priv->got_video_src);
3074 priv->got_video_src = g_timeout_add_seconds (5,
3075 empathy_call_window_check_video_cb, self);
3078 g_assert_not_reached ();
3084 if (GST_PAD_LINK_FAILED (gst_pad_link (src, pad)))
3085 g_warning ("Could not link %s sink pad",
3086 media_type == TP_MEDIA_STREAM_TYPE_AUDIO ? "audio" : "video");
3090 gst_object_unref (pad);
3094 /* If no sink could be linked, try to add fakesink to prevent the whole call
3099 GstElement *fakesink = gst_element_factory_make ("fakesink", NULL);
3101 if (gst_bin_add (GST_BIN (priv->pipeline), fakesink))
3103 GstPad *sinkpad = gst_element_get_static_pad (fakesink, "sink");
3104 if (gst_element_set_state (fakesink, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE ||
3105 GST_PAD_LINK_FAILED (gst_pad_link (src, sinkpad)))
3107 gst_element_set_locked_state (fakesink, TRUE);
3108 gst_element_set_state (fakesink, GST_STATE_NULL);
3109 gst_bin_remove (GST_BIN (priv->pipeline), fakesink);
3113 DEBUG ("Could not link real sink, linked fakesink instead");
3115 gst_object_unref (sinkpad);
3119 gst_object_unref (fakesink);
3124 g_mutex_unlock (priv->lock);
3130 empathy_call_window_sink_added_cb (EmpathyCallHandler *handler,
3131 GstPad *sink, FsMediaType media_type, gpointer user_data)
3133 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
3134 EmpathyCallWindowPriv *priv = GET_PRIV (self);
3136 gboolean retval = FALSE;
3140 case FS_MEDIA_TYPE_AUDIO:
3141 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_input))
3143 g_warning ("Could not add audio source to pipeline");
3147 pad = gst_element_get_static_pad (priv->audio_input, "src");
3150 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
3151 g_warning ("Could not get source pad from audio source");
3155 if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
3157 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
3158 g_warning ("Could not link audio source to farsight");
3162 if (gst_element_set_state (priv->audio_input, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
3164 g_warning ("Could not start audio source");
3165 gst_element_set_state (priv->audio_input, GST_STATE_NULL);
3166 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
3172 case FS_MEDIA_TYPE_VIDEO:
3173 if (priv->video_tee != NULL)
3175 pad = gst_element_get_request_pad (priv->video_tee, "src%d");
3176 if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
3178 g_warning ("Could not link video source input pipeline");
3181 gst_object_unref (pad);
3187 g_assert_not_reached ();
3194 empathy_call_window_remove_video_input (EmpathyCallWindow *self)
3196 EmpathyCallWindowPriv *priv = GET_PRIV (self);
3197 GstElement *preview;
3199 disable_camera (self);
3201 DEBUG ("remove video input");
3202 preview = priv->video_preview_sink;
3204 gst_element_set_state (priv->video_input, GST_STATE_NULL);
3205 gst_element_set_state (priv->video_tee, GST_STATE_NULL);
3206 gst_element_set_state (preview, GST_STATE_NULL);
3208 gst_bin_remove_many (GST_BIN (priv->pipeline), priv->video_input,
3211 g_object_unref (priv->video_input);
3212 priv->video_input = NULL;
3213 g_object_unref (priv->video_tee);
3214 priv->video_tee = NULL;
3215 clutter_actor_destroy (priv->video_preview);
3216 priv->video_preview = NULL;
3218 gtk_widget_set_sensitive (priv->camera_button, FALSE);
3222 start_call (EmpathyCallWindow *self)
3224 EmpathyCallWindowPriv *priv = GET_PRIV (self);
3226 priv->call_started = TRUE;
3227 empathy_call_handler_start_call (priv->handler,
3228 gtk_get_current_event_time ());
3230 if (empathy_call_handler_has_initial_video (priv->handler))
3232 TpyCallChannel *call;
3235 g_object_get (priv->handler, "call-channel", &call, NULL);
3236 s = tpy_call_channel_get_video_state (call);
3238 if (s == TPY_SENDING_STATE_PENDING_SEND ||
3239 s == TPY_SENDING_STATE_SENDING)
3241 /* Enable 'send video' buttons and display the preview */
3242 gtk_toggle_tool_button_set_active (
3243 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), TRUE);
3247 gtk_toggle_tool_button_set_active (
3248 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), FALSE);
3250 if (priv->video_preview == NULL)
3252 create_video_preview (self);
3253 add_video_preview_to_pipeline (self);
3257 g_object_unref (call);
3262 empathy_call_window_bus_message (GstBus *bus, GstMessage *message,
3265 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
3266 EmpathyCallWindowPriv *priv = GET_PRIV (self);
3269 empathy_call_handler_bus_message (priv->handler, bus, message);
3271 switch (GST_MESSAGE_TYPE (message))
3273 case GST_MESSAGE_STATE_CHANGED:
3274 if (GST_MESSAGE_SRC (message) == GST_OBJECT (priv->video_input))
3276 gst_message_parse_state_changed (message, NULL, &newstate, NULL);
3278 if (GST_MESSAGE_SRC (message) == GST_OBJECT (priv->pipeline) &&
3279 !priv->call_started)
3281 gst_message_parse_state_changed (message, NULL, &newstate, NULL);
3282 if (newstate == GST_STATE_PAUSED)
3284 gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
3285 priv->pipeline_playing = TRUE;
3287 if (priv->start_call_when_playing)
3292 case GST_MESSAGE_ERROR:
3294 GError *error = NULL;
3295 GstElement *gst_error;
3298 gst_message_parse_error (message, &error, &debug);
3299 gst_error = GST_ELEMENT (GST_MESSAGE_SRC (message));
3301 g_message ("Element error: %s -- %s\n", error->message, debug);
3303 if (g_str_has_prefix (gst_element_get_name (gst_error),
3304 VIDEO_INPUT_ERROR_PREFIX))
3306 /* Remove the video input and continue */
3307 if (priv->video_input != NULL)
3308 empathy_call_window_remove_video_input (self);
3309 gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
3313 empathy_call_window_disconnected (self, TRUE);
3315 g_error_free (error);
3318 case GST_MESSAGE_UNKNOWN:
3319 case GST_MESSAGE_EOS:
3320 case GST_MESSAGE_WARNING:
3321 case GST_MESSAGE_INFO:
3322 case GST_MESSAGE_TAG:
3323 case GST_MESSAGE_BUFFERING:
3324 case GST_MESSAGE_STATE_DIRTY:
3325 case GST_MESSAGE_STEP_DONE:
3326 case GST_MESSAGE_CLOCK_PROVIDE:
3327 case GST_MESSAGE_CLOCK_LOST:
3328 case GST_MESSAGE_NEW_CLOCK:
3329 case GST_MESSAGE_STRUCTURE_CHANGE:
3330 case GST_MESSAGE_STREAM_STATUS:
3331 case GST_MESSAGE_APPLICATION:
3332 case GST_MESSAGE_ELEMENT:
3333 case GST_MESSAGE_SEGMENT_START:
3334 case GST_MESSAGE_SEGMENT_DONE:
3335 case GST_MESSAGE_DURATION:
3336 case GST_MESSAGE_ANY:
3345 empathy_call_window_members_changed_cb (TpyCallChannel *call,
3346 GHashTable *members,
3347 EmpathyCallWindow *self)
3349 EmpathyCallWindowPriv *priv = GET_PRIV (self);
3350 GHashTableIter iter;
3351 gpointer key, value;
3352 gboolean held = FALSE;
3354 g_hash_table_iter_init (&iter, members);
3355 while (g_hash_table_iter_next (&iter, &key, &value))
3357 if (GPOINTER_TO_INT (value) & TPY_CALL_MEMBER_FLAG_HELD)
3359 /* This assumes this is a 1-1 call, otherwise one participant
3360 * putting the call on hold wouldn't mean the call is on hold
3368 priv->call_state = HELD;
3369 else if (priv->call_state == HELD)
3370 priv->call_state = CONNECTED;
3374 call_handler_notify_call_cb (EmpathyCallHandler *handler,
3376 EmpathyCallWindow *self)
3378 EmpathyCallWindowPriv *priv = GET_PRIV (self);
3379 TpyCallChannel *call;
3381 g_object_get (priv->handler, "call-channel", &call, NULL);
3386 tp_g_signal_connect_object (call, "audio-stream-error",
3387 G_CALLBACK (empathy_call_window_audio_stream_error), self, 0);
3388 tp_g_signal_connect_object (call, "video-stream-error",
3389 G_CALLBACK (empathy_call_window_video_stream_error), self, 0);
3392 tp_g_signal_connect_object (call, "members-changed",
3393 G_CALLBACK (empathy_call_window_members_changed_cb), self, 0);
3395 g_object_unref (call);
3399 empathy_call_window_connect_handler (EmpathyCallWindow *self)
3401 EmpathyCallWindowPriv *priv = GET_PRIV (self);
3402 TpyCallChannel *call;
3404 g_signal_connect (priv->handler, "state-changed",
3405 G_CALLBACK (empathy_call_window_state_changed_cb), self);
3406 g_signal_connect (priv->handler, "conference-added",
3407 G_CALLBACK (empathy_call_window_conference_added_cb), self);
3408 g_signal_connect (priv->handler, "conference-removed",
3409 G_CALLBACK (empathy_call_window_conference_removed_cb), self);
3410 g_signal_connect (priv->handler, "closed",
3411 G_CALLBACK (empathy_call_window_channel_closed_cb), self);
3412 g_signal_connect (priv->handler, "src-pad-added",
3413 G_CALLBACK (empathy_call_window_src_added_cb), self);
3414 g_signal_connect (priv->handler, "sink-pad-added",
3415 G_CALLBACK (empathy_call_window_sink_added_cb), self);
3416 g_signal_connect (priv->handler, "sink-pad-removed",
3417 G_CALLBACK (empathy_call_window_sink_removed_cb), self);
3419 g_object_get (priv->handler, "call-channel", &call, NULL);
3422 call_handler_notify_call_cb (priv->handler, NULL, self);
3423 g_object_unref (call);
3427 /* call-channel doesn't exist yet, we'll connect signals once it has been
3429 g_signal_connect (priv->handler, "notify::call-channel",
3430 G_CALLBACK (call_handler_notify_call_cb), self);
3435 empathy_call_window_realized_cb (GtkWidget *widget,
3436 EmpathyCallWindow *self)
3440 /* Make the hangup button twice as wide */
3441 width = gtk_widget_get_allocated_width (self->priv->hangup_button);
3442 gtk_widget_set_size_request (self->priv->hangup_button, width * 2, -1);
3444 empathy_call_window_connect_handler (self);
3446 gst_element_set_state (self->priv->pipeline, GST_STATE_PAUSED);
3450 empathy_call_window_delete_cb (GtkWidget *widget, GdkEvent*event,
3451 EmpathyCallWindow *window)
3453 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3455 if (priv->pipeline != NULL)
3457 if (priv->bus_message_source_id != 0)
3459 g_source_remove (priv->bus_message_source_id);
3460 priv->bus_message_source_id = 0;
3463 gst_element_set_state (priv->pipeline, GST_STATE_NULL);
3466 if (priv->call_state == CONNECTING)
3467 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
3473 show_controls (EmpathyCallWindow *window, gboolean set_fullscreen)
3476 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3478 menu = gtk_ui_manager_get_widget (priv->ui_manager,
3483 gtk_widget_hide (priv->dtmf_panel);
3484 gtk_widget_hide (menu);
3485 gtk_widget_hide (priv->toolbar);
3489 if (priv->dialpad_was_visible_before_fs)
3490 gtk_widget_show (priv->dtmf_panel);
3492 gtk_widget_show (menu);
3493 gtk_widget_show (priv->toolbar);
3495 gtk_window_resize (GTK_WINDOW (window), priv->original_width_before_fs,
3496 priv->original_height_before_fs);
3501 show_borders (EmpathyCallWindow *window, gboolean set_fullscreen)
3503 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3505 gtk_container_set_border_width (GTK_CONTAINER (priv->content_hbox),
3506 set_fullscreen ? 0 : CONTENT_HBOX_BORDER_WIDTH);
3507 gtk_box_set_spacing (GTK_BOX (priv->content_hbox),
3508 set_fullscreen ? 0 : CONTENT_HBOX_SPACING);
3510 if (priv->video_output != NULL)
3513 gtk_box_set_child_packing (GTK_BOX (priv->content_hbox),
3514 priv->video_output, TRUE, TRUE,
3515 set_fullscreen ? 0 : CONTENT_HBOX_CHILDREN_PACKING_PADDING,
3522 empathy_call_window_state_event_cb (GtkWidget *widget,
3523 GdkEventWindowState *event, EmpathyCallWindow *window)
3525 if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
3527 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3528 gboolean set_fullscreen = event->new_window_state &
3529 GDK_WINDOW_STATE_FULLSCREEN;
3533 gboolean dialpad_was_visible;
3534 GtkAllocation allocation;
3535 gint original_width, original_height;
3537 gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
3538 original_width = allocation.width;
3539 original_height = allocation.height;
3541 g_object_get (priv->dtmf_panel,
3542 "visible", &dialpad_was_visible,
3545 priv->dialpad_was_visible_before_fs = dialpad_was_visible;
3546 priv->original_width_before_fs = original_width;
3547 priv->original_height_before_fs = original_height;
3549 if (priv->video_output_motion_handler_id == 0 &&
3550 priv->video_output != NULL)
3552 priv->video_output_motion_handler_id = g_signal_connect (
3553 G_OBJECT (priv->video_container), "motion-notify-event",
3554 G_CALLBACK (empathy_call_window_video_output_motion_notify),
3560 disconnect_video_output_motion_handler (window);
3563 empathy_call_window_fullscreen_set_fullscreen (priv->fullscreen,
3565 show_controls (window, set_fullscreen);
3566 show_borders (window, set_fullscreen);
3567 gtk_action_set_stock_id (priv->menu_fullscreen,
3568 (set_fullscreen ? "gtk-leave-fullscreen" : "gtk-fullscreen"));
3569 priv->is_fullscreen = set_fullscreen;
3576 empathy_call_window_show_dialpad (EmpathyCallWindow *window,
3579 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3580 int w, h, dialpad_width;
3581 GtkAllocation allocation;
3583 gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
3584 w = allocation.width;
3585 h = allocation.height;
3587 gtk_widget_get_preferred_width (priv->dtmf_panel, &dialpad_width, NULL);
3591 gtk_widget_show (priv->dtmf_panel);
3597 gtk_widget_hide (priv->dtmf_panel);
3601 gtk_window_resize (GTK_WINDOW (window), w, h);
3605 empathy_call_window_set_send_video (EmpathyCallWindow *window,
3608 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3609 TpyCallChannel *call;
3611 priv->sending_video = (state == CAMERA_STATE_ON);
3613 if (state == CAMERA_STATE_ON)
3615 /* When we start sending video, we want to show the video preview by
3617 display_video_preview (window, TRUE);
3621 display_video_preview (window, FALSE);
3624 if (priv->call_state != CONNECTED)
3627 g_object_get (priv->handler, "call-channel", &call, NULL);
3628 DEBUG ("%s sending video", priv->sending_video ? "start": "stop");
3629 tpy_call_channel_send_video (call, priv->sending_video);
3630 g_object_unref (call);
3634 empathy_call_window_mic_toggled_cb (GtkToggleToolButton *toggle,
3635 EmpathyCallWindow *self)
3637 EmpathyCallWindowPriv *priv = GET_PRIV (self);
3640 active = (gtk_toggle_tool_button_get_active (toggle));
3642 /* We don't want the settings callback to react to this change to avoid
3644 g_signal_handlers_block_by_func (priv->settings,
3645 empathy_call_window_prefs_volume_changed_cb, self);
3649 g_settings_set_double (priv->settings, EMPATHY_PREFS_CALL_SOUND_VOLUME,
3650 priv->volume * 100);
3654 /* TODO, Instead of setting the input volume to 0 we should probably
3655 * stop sending but this would cause the audio call to drop if both
3656 * sides mute at the same time on certain CMs AFAIK. Need to revisit this
3657 * in the future. GNOME #574574
3659 g_settings_set_double (priv->settings, EMPATHY_PREFS_CALL_SOUND_VOLUME,
3663 g_signal_handlers_unblock_by_func (priv->settings,
3664 empathy_call_window_prefs_volume_changed_cb, self);
3668 empathy_call_window_hangup_cb (gpointer object,
3669 EmpathyCallWindow *self)
3671 empathy_call_handler_stop_call (self->priv->handler);
3673 empathy_call_window_disconnected (self, TRUE);
3677 empathy_call_window_restart_call (EmpathyCallWindow *window)
3679 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3681 /* Remove error info bars */
3682 gtk_container_forall (GTK_CONTAINER (priv->errors_vbox),
3683 (GtkCallback) gtk_widget_destroy, NULL);
3685 create_video_output_widget (window);
3687 /* While the call was disconnected, the input volume might have changed.
3688 * However, since the audio_input source was destroyed, its volume has not
3689 * been updated during that time. That's why we manually update it here */
3690 empathy_call_window_mic_volume_changed (window);
3692 priv->outgoing = TRUE;
3693 empathy_call_window_set_state_connecting (window);
3695 if (priv->pipeline_playing)
3696 start_call (window);
3698 /* call will be started when the pipeline is ready */
3699 priv->start_call_when_playing = TRUE;
3701 empathy_call_window_setup_avatars (window, priv->handler);
3703 empathy_call_window_show_hangup_button (window, TRUE);
3707 empathy_call_window_dialpad_cb (GtkToggleToolButton *button,
3708 EmpathyCallWindow *window)
3712 active = gtk_toggle_tool_button_get_active (button);
3714 empathy_call_window_show_dialpad (window, active);
3718 empathy_call_window_fullscreen_cb (gpointer object,
3719 EmpathyCallWindow *window)
3721 empathy_call_window_fullscreen_toggle (window);
3725 empathy_call_window_fullscreen_toggle (EmpathyCallWindow *window)
3727 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3729 if (priv->is_fullscreen)
3730 gtk_window_unfullscreen (GTK_WINDOW (window));
3732 gtk_window_fullscreen (GTK_WINDOW (window));
3736 empathy_call_window_video_button_press_cb (GtkWidget *video_preview,
3737 GdkEventButton *event, EmpathyCallWindow *window)
3739 if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
3741 empathy_call_window_video_menu_popup (window, event->button);
3749 empathy_call_window_key_press_cb (GtkWidget *video_output,
3750 GdkEventKey *event, EmpathyCallWindow *window)
3752 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3754 if (priv->is_fullscreen && event->keyval == GDK_KEY_Escape)
3756 /* Since we are in fullscreen mode, toggling will bring us back to
3758 empathy_call_window_fullscreen_toggle (window);
3766 empathy_call_window_video_output_motion_notify (GtkWidget *widget,
3767 GdkEventMotion *event, EmpathyCallWindow *window)
3769 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3771 if (priv->is_fullscreen)
3773 empathy_call_window_fullscreen_show_popup (priv->fullscreen);
3775 /* Show the bottom toolbar */
3776 empathy_call_window_motion_notify_cb (NULL, NULL, window);
3783 empathy_call_window_video_menu_popup (EmpathyCallWindow *window,
3787 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3789 menu = gtk_ui_manager_get_widget (priv->ui_manager,
3791 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
3792 button, gtk_get_current_event_time ());
3793 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
3797 empathy_call_window_status_message (EmpathyCallWindow *self,
3800 gtk_label_set_label (GTK_LABEL (self->priv->status_label), message);
3804 empathy_call_window_volume_changed_cb (GtkScaleButton *button,
3805 gdouble value, EmpathyCallWindow *window)
3807 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3809 if (priv->audio_output == NULL)
3812 empathy_audio_sink_set_volume (EMPATHY_GST_AUDIO_SINK (priv->audio_output),
3817 empathy_call_window_get_ui_manager (EmpathyCallWindow *window)
3819 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3821 return priv->ui_manager;
3824 EmpathyGstAudioSrc *
3825 empathy_call_window_get_audio_src (EmpathyCallWindow *window)
3827 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3829 return (EmpathyGstAudioSrc *) priv->audio_input;
3832 EmpathyGstVideoSrc *
3833 empathy_call_window_get_video_src (EmpathyCallWindow *self)
3835 return EMPATHY_GST_VIDEO_SRC (self->priv->video_input);