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-utils.h>
48 #include <libempathy-gtk/empathy-avatar-image.h>
49 #include <libempathy-gtk/empathy-ui-utils.h>
50 #include <libempathy-gtk/empathy-sound-manager.h>
51 #include <libempathy-gtk/empathy-geometry.h>
52 #include <libempathy-gtk/empathy-images.h>
54 #define DEBUG_FLAG EMPATHY_DEBUG_VOIP
55 #include <libempathy/empathy-debug.h>
57 #include "empathy-call-window.h"
58 #include "empathy-call-window-fullscreen.h"
59 #include "empathy-call-factory.h"
60 #include "empathy-video-widget.h"
61 #include "empathy-about-dialog.h"
62 #include "empathy-audio-src.h"
63 #include "empathy-audio-sink.h"
64 #include "empathy-video-src.h"
65 #include "empathy-mic-menu.h"
66 #include "empathy-preferences.h"
67 #include "empathy-rounded-actor.h"
69 #define CONTENT_HBOX_BORDER_WIDTH 6
70 #define CONTENT_HBOX_SPACING 3
71 #define CONTENT_HBOX_CHILDREN_PACKING_PADDING 3
73 #define SELF_VIDEO_SECTION_WIDTH 120
74 #define SELF_VIDEO_SECTION_HEIGTH 90
75 #define SELF_VIDEO_SECTION_MARGIN 10
77 #define FLOATING_TOOLBAR_OPACITY 192
78 #define FLOATING_TOOLBAR_WIDTH 280
79 #define FLOATING_TOOLBAR_HEIGHT 36
80 #define FLOATING_TOOLBAR_SPACING 20
82 #define SELF_VIDEO_MARGIN 10
84 /* The avatar's default width and height are set to the same value because we
85 want a square icon. */
86 #define REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH EMPATHY_VIDEO_WIDGET_DEFAULT_HEIGHT
87 #define REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT \
88 EMPATHY_VIDEO_WIDGET_DEFAULT_HEIGHT
90 #define SMALL_TOOLBAR_SIZE 36
92 /* If an video input error occurs, the error message will start with "v4l" */
93 #define VIDEO_INPUT_ERROR_PREFIX "v4l"
95 /* The time interval in milliseconds between 2 outgoing rings */
96 #define MS_BETWEEN_RING 500
98 G_DEFINE_TYPE(EmpathyCallWindow, empathy_call_window, GTK_TYPE_WINDOW)
101 PROP_CALL_HANDLER = 1,
113 CAMERA_STATE_OFF = 0,
119 PREVIEW_POS_TOP_LEFT,
120 PREVIEW_POS_TOP_RIGHT,
121 PREVIEW_POS_BOTTOM_LEFT,
122 PREVIEW_POS_BOTTOM_RIGHT,
125 struct _EmpathyCallWindowPriv
127 gboolean dispose_has_run;
128 EmpathyCallHandler *handler;
130 EmpathyContact *contact;
132 EmpathyCameraMonitor *camera_monitor;
137 GtkUIManager *ui_manager;
138 GtkWidget *errors_vbox;
139 /* widget displays the video received from the remote user. This widget is
140 * alive only during call. */
141 ClutterActor *video_output;
142 ClutterActor *video_preview;
143 ClutterActor *preview_hidden_button;
144 GtkWidget *video_container;
145 GtkWidget *remote_user_avatar_widget;
146 GtkWidget *remote_user_avatar_toolbar;
147 GtkWidget *remote_user_name_toolbar;
148 GtkWidget *status_label;
149 GtkWidget *hangup_button;
150 GtkWidget *audio_call_button;
151 GtkWidget *video_call_button;
152 GtkWidget *mic_button;
153 GtkWidget *camera_button;
154 GtkWidget *dialpad_button;
156 GtkWidget *bottom_toolbar;
157 ClutterActor *floating_toolbar;
159 GtkAction *menu_fullscreen;
161 ClutterState *transitions;
163 /* The box that contains self and remote avatar and video
164 input/output. When we redial, we destroy and re-create the box */
165 ClutterActor *video_box;
166 ClutterLayoutManager *video_layout;
168 /* We keep a reference on the hbox which contains the main content so we can
169 easilly repack everything when toggling fullscreen */
170 GtkWidget *content_hbox;
172 gulong video_output_motion_handler_id;
173 guint bus_message_source_id;
177 GtkWidget *dtmf_panel;
180 GtkWidget *details_vbox;
181 GtkWidget *vcodec_encoding_label;
182 GtkWidget *acodec_encoding_label;
183 GtkWidget *vcodec_decoding_label;
184 GtkWidget *acodec_decoding_label;
186 GtkWidget *audio_remote_candidate_label;
187 GtkWidget *audio_local_candidate_label;
188 GtkWidget *video_remote_candidate_label;
189 GtkWidget *video_local_candidate_label;
190 GtkWidget *video_remote_candidate_info_img;
191 GtkWidget *video_local_candidate_info_img;
192 GtkWidget *audio_remote_candidate_info_img;
193 GtkWidget *audio_local_candidate_info_img;
195 GstElement *video_input;
196 GstElement *video_preview_sink;
197 GstElement *video_output_sink;
198 GstElement *audio_input;
199 GstElement *audio_output;
200 GstElement *pipeline;
201 GstElement *video_tee;
211 gboolean call_started;
212 gboolean sending_video;
213 CameraState camera_state;
215 EmpathyCallWindowFullscreen *fullscreen;
216 gboolean is_fullscreen;
221 guint inactivity_src;
223 /* Those fields represent the state of the window before it actually was in
225 gboolean dialpad_was_visible_before_fs;
226 gint original_width_before_fs;
227 gint original_height_before_fs;
229 gint x, y, w, h, dialpad_width;
232 /* TRUE if the call should be started when the pipeline is playing */
233 gboolean start_call_when_playing;
234 /* TRUE if we requested to set the pipeline in the playing state */
235 gboolean pipeline_playing;
237 EmpathySoundManager *sound_mgr;
240 EmpathyMicMenu *mic_menu;
243 #define GET_PRIV(o) (EMPATHY_CALL_WINDOW (o)->priv)
245 static void empathy_call_window_realized_cb (GtkWidget *widget,
246 EmpathyCallWindow *window);
248 static gboolean empathy_call_window_delete_cb (GtkWidget *widget,
249 GdkEvent *event, EmpathyCallWindow *window);
251 static gboolean empathy_call_window_state_event_cb (GtkWidget *widget,
252 GdkEventWindowState *event, EmpathyCallWindow *window);
254 static void empathy_call_window_set_send_video (EmpathyCallWindow *window,
257 static void empathy_call_window_mic_toggled_cb (
258 GtkToggleToolButton *toggle, EmpathyCallWindow *window);
260 static void empathy_call_window_hangup_cb (gpointer object,
261 EmpathyCallWindow *window);
263 static void empathy_call_window_fullscreen_cb (gpointer object,
264 EmpathyCallWindow *window);
266 static void empathy_call_window_fullscreen_toggle (EmpathyCallWindow *window);
268 static gboolean empathy_call_window_video_button_press_cb (
269 GtkWidget *video_output, GdkEventButton *event, EmpathyCallWindow *window);
271 static gboolean empathy_call_window_key_press_cb (GtkWidget *video_output,
272 GdkEventKey *event, EmpathyCallWindow *window);
274 static gboolean empathy_call_window_video_output_motion_notify (
275 GtkWidget *widget, GdkEventMotion *event, EmpathyCallWindow *window);
277 static void empathy_call_window_video_menu_popup (EmpathyCallWindow *window,
280 static void empathy_call_window_dialpad_cb (GtkToggleToolButton *button,
281 EmpathyCallWindow *window);
283 static void empathy_call_window_restart_call (EmpathyCallWindow *window);
285 static void empathy_call_window_status_message (EmpathyCallWindow *window,
288 static gboolean empathy_call_window_bus_message (GstBus *bus,
289 GstMessage *message, gpointer user_data);
292 empathy_call_window_volume_changed_cb (GtkScaleButton *button,
293 gdouble value, EmpathyCallWindow *window);
296 empathy_call_window_show_hangup_button (EmpathyCallWindow *self,
299 gtk_widget_set_visible (self->priv->hangup_button, show);
300 gtk_widget_set_visible (self->priv->audio_call_button, !show);
301 gtk_widget_set_visible (self->priv->video_call_button, !show);
305 empathy_call_window_audio_call_cb (GtkToggleToolButton *button,
306 EmpathyCallWindow *self)
308 g_object_set (self->priv->handler, "initial-video", FALSE, NULL);
309 empathy_call_window_restart_call (self);
313 empathy_call_window_video_call_cb (GtkToggleToolButton *button,
314 EmpathyCallWindow *self)
316 empathy_call_window_set_send_video (self, CAMERA_STATE_ON);
317 g_object_set (self->priv->handler, "initial-video", TRUE, NULL);
318 empathy_call_window_restart_call (self);
322 dtmf_button_pressed_cb (GtkButton *button, EmpathyCallWindow *window)
324 EmpathyCallWindowPriv *priv = GET_PRIV (window);
325 TpyCallChannel *call;
329 g_object_get (priv->handler, "call-channel", &call, NULL);
331 button_quark = g_quark_from_static_string (EMPATHY_DTMF_BUTTON_ID);
332 event = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (button),
335 tpy_call_channel_dtmf_start_tone (call, event);
337 g_object_unref (call);
341 dtmf_button_released_cb (GtkButton *button, EmpathyCallWindow *window)
343 EmpathyCallWindowPriv *priv = GET_PRIV (window);
344 TpyCallChannel *call;
346 g_object_get (priv->handler, "call-channel", &call, NULL);
348 tpy_call_channel_dtmf_stop_tone (call);
350 g_object_unref (call);
354 empathy_call_window_mic_volume_changed (EmpathyCallWindow *self)
356 EmpathyCallWindowPriv *priv = GET_PRIV (self);
359 volume = g_settings_get_double (priv->settings,
360 EMPATHY_PREFS_CALL_SOUND_VOLUME) / 100.0;
362 /* Don't store the volume because of muting */
363 if (volume > 0 || gtk_toggle_tool_button_get_active (
364 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
365 priv->volume = volume;
367 /* Ensure that the toggle button is active if the volume is > 0 and inactive
368 * if it's smaller than 0 */
369 if ((volume > 0) != gtk_toggle_tool_button_get_active (
370 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
371 gtk_toggle_tool_button_set_active (
372 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button), volume > 0);
374 empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
379 empathy_call_window_prefs_volume_changed_cb (GSettings *settings,
381 EmpathyCallWindow *self)
383 empathy_call_window_mic_volume_changed (self);
387 empathy_call_window_show_video_output (EmpathyCallWindow *self,
390 if (self->priv->video_output != NULL)
391 g_object_set (self->priv->video_output, "visible", show, NULL);
393 gtk_widget_set_visible (self->priv->remote_user_avatar_widget, !show);
395 clutter_actor_raise_top (self->priv->floating_toolbar);
399 create_video_output_widget (EmpathyCallWindow *self)
401 EmpathyCallWindowPriv *priv = GET_PRIV (self);
403 g_assert (priv->video_output == NULL);
404 g_assert (priv->pipeline != NULL);
406 priv->video_output = clutter_texture_new ();
408 clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (priv->video_output),
411 priv->video_output_sink = clutter_gst_video_sink_new (
412 CLUTTER_TEXTURE (priv->video_output));
414 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_box),
417 gtk_widget_add_events (priv->video_container,
418 GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK);
419 g_signal_connect (G_OBJECT (priv->video_container), "button-press-event",
420 G_CALLBACK (empathy_call_window_video_button_press_cb), self);
424 create_video_input (EmpathyCallWindow *self)
426 EmpathyCallWindowPriv *priv = GET_PRIV (self);
428 g_assert (priv->video_input == NULL);
429 priv->video_input = empathy_video_src_new ();
430 gst_object_ref (priv->video_input);
431 gst_object_sink (priv->video_input);
435 create_audio_input (EmpathyCallWindow *self)
437 EmpathyCallWindowPriv *priv = GET_PRIV (self);
439 g_assert (priv->audio_input == NULL);
440 priv->audio_input = empathy_audio_src_new ();
441 gst_object_ref (priv->audio_input);
442 gst_object_sink (priv->audio_input);
446 add_video_preview_to_pipeline (EmpathyCallWindow *self)
448 EmpathyCallWindowPriv *priv = GET_PRIV (self);
451 g_assert (priv->video_preview != NULL);
452 g_assert (priv->pipeline != NULL);
453 g_assert (priv->video_input != NULL);
454 g_assert (priv->video_tee != NULL);
456 preview = priv->video_preview_sink;
458 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->video_input))
460 g_warning ("Could not add video input to pipeline");
464 if (!gst_bin_add (GST_BIN (priv->pipeline), preview))
466 g_warning ("Could not add video preview to pipeline");
470 if (!gst_element_link (priv->video_input, priv->video_tee))
472 g_warning ("Could not link video input to video tee");
476 if (!gst_element_link (priv->video_tee, preview))
478 g_warning ("Could not link video tee to video preview");
484 empathy_call_window_disable_camera_cb (GtkAction *action,
485 EmpathyCallWindow *self)
487 clutter_actor_destroy (self->priv->preview_hidden_button);
489 gtk_toggle_tool_button_set_active (
490 GTK_TOGGLE_TOOL_BUTTON (self->priv->camera_button), FALSE);
494 empathy_call_window_minimise_camera_cb (GtkAction *action,
495 EmpathyCallWindow *self)
497 clutter_actor_hide (self->priv->video_preview);
498 clutter_actor_show (self->priv->preview_hidden_button);
502 empathy_call_window_maximise_camera_cb (GtkAction *action,
503 EmpathyCallWindow *self)
505 clutter_actor_show (self->priv->video_preview);
506 clutter_actor_hide (self->priv->preview_hidden_button);
510 empathy_call_window_preview_button_clicked_cb (GtkButton *button,
511 EmpathyCallWindow *self)
515 menu = gtk_ui_manager_get_widget (self->priv->ui_manager,
517 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
518 0, gtk_get_current_event_time ());
519 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
523 empathy_call_window_preview_hidden_button_clicked_cb (GtkButton *button,
524 EmpathyCallWindow *self)
528 menu = gtk_ui_manager_get_widget (self->priv->ui_manager,
529 "/preview-hidden-menu");
530 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
531 0, gtk_get_current_event_time ());
532 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
536 empathy_call_window_move_video_preview (EmpathyCallWindow *self,
539 ClutterBinLayout *layout = CLUTTER_BIN_LAYOUT (self->priv->video_layout);
541 DEBUG ("moving the video preview to %d", pos);
545 case PREVIEW_POS_TOP_LEFT:
546 clutter_bin_layout_set_alignment (layout,
547 self->priv->video_preview,
548 CLUTTER_BIN_ALIGNMENT_START,
549 CLUTTER_BIN_ALIGNMENT_START);
551 case PREVIEW_POS_TOP_RIGHT:
552 clutter_bin_layout_set_alignment (layout,
553 self->priv->video_preview,
554 CLUTTER_BIN_ALIGNMENT_END,
555 CLUTTER_BIN_ALIGNMENT_START);
557 case PREVIEW_POS_BOTTOM_LEFT:
558 clutter_bin_layout_set_alignment (layout,
559 self->priv->video_preview,
560 CLUTTER_BIN_ALIGNMENT_START,
561 CLUTTER_BIN_ALIGNMENT_END);
563 case PREVIEW_POS_BOTTOM_RIGHT:
564 clutter_bin_layout_set_alignment (layout,
565 self->priv->video_preview,
566 CLUTTER_BIN_ALIGNMENT_END,
567 CLUTTER_BIN_ALIGNMENT_END);
570 g_warn_if_reached ();
575 empathy_call_window_preview_on_drag_end_cb (ClutterDragAction *action,
579 ClutterModifierType modifiers,
580 EmpathyCallWindow *self)
583 PreviewPosition pos = PREVIEW_POS_NONE;
585 clutter_actor_get_geometry (self->priv->video_box, &box);
587 if (0 + SELF_VIDEO_MARGIN <= event_x &&
588 event_x <= (0 + SELF_VIDEO_MARGIN + (gint) SELF_VIDEO_SECTION_WIDTH) &&
589 0 + SELF_VIDEO_MARGIN <= event_y &&
590 event_y <= (0 + SELF_VIDEO_MARGIN + (gint) SELF_VIDEO_SECTION_HEIGTH))
592 pos = PREVIEW_POS_TOP_LEFT;
594 else if (box.width - SELF_VIDEO_MARGIN >= event_x &&
595 event_x >= (box.width - SELF_VIDEO_MARGIN - (gint) SELF_VIDEO_SECTION_WIDTH) &&
596 0 + SELF_VIDEO_MARGIN <= event_y &&
597 event_y <= (0 + SELF_VIDEO_MARGIN + (gint) SELF_VIDEO_SECTION_HEIGTH))
599 pos = PREVIEW_POS_TOP_RIGHT;
601 else if (0 + SELF_VIDEO_MARGIN <= event_x &&
602 event_x <= (0 + SELF_VIDEO_MARGIN + (gint) SELF_VIDEO_SECTION_WIDTH) &&
603 box.height - SELF_VIDEO_MARGIN >= event_y &&
604 event_y >= (box.height - SELF_VIDEO_MARGIN - (gint) SELF_VIDEO_SECTION_HEIGTH))
606 pos = PREVIEW_POS_BOTTOM_LEFT;
608 else if (box.width - SELF_VIDEO_MARGIN >= event_x &&
609 event_x >= (box.width - SELF_VIDEO_MARGIN - (gint) SELF_VIDEO_SECTION_WIDTH) &&
610 box.height - SELF_VIDEO_MARGIN >= event_y &&
611 event_y >= (box.height - SELF_VIDEO_MARGIN - (gint) SELF_VIDEO_SECTION_HEIGTH))
613 pos = PREVIEW_POS_BOTTOM_RIGHT;
616 if (pos != PREVIEW_POS_NONE)
617 empathy_call_window_move_video_preview (self, pos);
621 create_video_preview (EmpathyCallWindow *self)
623 EmpathyCallWindowPriv *priv = GET_PRIV (self);
624 ClutterLayoutManager *layout, *layout_center;
625 ClutterActor *preview;
628 ClutterAction *action;
631 g_assert (priv->video_preview == NULL);
633 preview = clutter_texture_new ();
634 clutter_actor_set_size (preview,
635 SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGTH);
636 priv->video_preview_sink = clutter_gst_video_sink_new (
637 CLUTTER_TEXTURE (preview));
639 /* Flip the video preview */
640 clutter_actor_set_rotation (preview,
643 SELF_VIDEO_SECTION_WIDTH * 0.5,
647 /* Add a little offset to the video preview */
648 layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
649 CLUTTER_BIN_ALIGNMENT_CENTER);
650 priv->video_preview = clutter_box_new (layout);
651 clutter_actor_set_size (priv->video_preview,
652 SELF_VIDEO_SECTION_WIDTH + 2 * SELF_VIDEO_SECTION_MARGIN,
653 SELF_VIDEO_SECTION_HEIGTH + 2 * SELF_VIDEO_SECTION_MARGIN +
654 FLOATING_TOOLBAR_HEIGHT + FLOATING_TOOLBAR_SPACING);
656 layout_center = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
657 CLUTTER_BIN_ALIGNMENT_CENTER);
658 box = clutter_box_new (layout_center);
659 clutter_actor_set_size (box,
660 SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGTH);
662 clutter_container_add_actor (CLUTTER_CONTAINER (box), preview);
663 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_preview), box);
665 g_object_set (priv->video_preview_sink,
670 /* Translators: this is an "Info" label. It should be as short
672 button = gtk_button_new_with_label (_("i"));
673 b = gtk_clutter_actor_new_with_contents (button);
675 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (layout_center),
677 CLUTTER_BIN_ALIGNMENT_END,
678 CLUTTER_BIN_ALIGNMENT_END);
680 g_signal_connect (button, "clicked",
681 G_CALLBACK (empathy_call_window_preview_button_clicked_cb),
684 /* Translators: this is an "Info" label. It should be as short
686 button = gtk_button_new_with_label (_("i"));
687 priv->preview_hidden_button =
688 gtk_clutter_actor_new_with_contents (button);
690 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
691 priv->preview_hidden_button,
692 CLUTTER_BIN_ALIGNMENT_START,
693 CLUTTER_BIN_ALIGNMENT_END);
695 clutter_actor_hide (priv->preview_hidden_button);
697 g_signal_connect (button, "clicked",
698 G_CALLBACK (empathy_call_window_preview_hidden_button_clicked_cb),
701 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
703 CLUTTER_BIN_ALIGNMENT_START,
704 CLUTTER_BIN_ALIGNMENT_END);
706 action = clutter_drag_action_new ();
707 g_signal_connect (action, "drag-end",
708 G_CALLBACK (empathy_call_window_preview_on_drag_end_cb), self);
710 clutter_actor_add_action (preview, action);
711 clutter_actor_set_reactive (preview, TRUE);
715 play_camera (EmpathyCallWindow *window,
718 EmpathyCallWindowPriv *priv = GET_PRIV (window);
722 if (priv->video_preview == NULL)
724 create_video_preview (window);
725 add_video_preview_to_pipeline (window);
729 state = GST_STATE_PLAYING;
731 state = GST_STATE_NULL;
733 preview = priv->video_preview_sink;
735 gst_element_set_state (preview, state);
736 gst_element_set_state (priv->video_input, state);
737 gst_element_set_state (priv->video_tee, state);
741 display_video_preview (EmpathyCallWindow *self,
744 EmpathyCallWindowPriv *priv = GET_PRIV (self);
748 /* Display the video preview */
749 DEBUG ("Show video preview");
751 play_camera (self, TRUE);
752 clutter_actor_show (priv->video_preview);
753 clutter_actor_raise_top (priv->floating_toolbar);
757 /* Hide the video preview */
758 DEBUG ("Hide video preview");
760 if (priv->video_preview != NULL)
762 clutter_actor_hide (priv->video_preview);
763 play_camera (self, FALSE);
769 empathy_call_window_set_state_connecting (EmpathyCallWindow *window)
771 EmpathyCallWindowPriv *priv = GET_PRIV (window);
773 empathy_call_window_status_message (window, _("Connecting…"));
774 priv->call_state = CONNECTING;
777 empathy_sound_manager_start_playing (priv->sound_mgr, GTK_WIDGET (window),
778 EMPATHY_SOUND_PHONE_OUTGOING, MS_BETWEEN_RING);
782 disable_camera (EmpathyCallWindow *self)
784 EmpathyCallWindowPriv *priv = GET_PRIV (self);
786 if (priv->camera_state == CAMERA_STATE_OFF)
789 DEBUG ("Disable camera");
791 display_video_preview (self, FALSE);
793 if (priv->camera_state == CAMERA_STATE_ON)
794 empathy_call_window_set_send_video (self, CAMERA_STATE_OFF);
796 priv->camera_state = CAMERA_STATE_OFF;
800 enable_camera (EmpathyCallWindow *self)
802 EmpathyCallWindowPriv *priv = GET_PRIV (self);
804 if (priv->camera_state == CAMERA_STATE_ON)
807 if (priv->video_input == NULL)
809 DEBUG ("Can't enable camera, no input");
813 DEBUG ("Enable camera");
815 empathy_call_window_set_send_video (self, CAMERA_STATE_ON);
817 priv->camera_state = CAMERA_STATE_ON;
821 empathy_call_window_camera_toggled_cb (GtkToggleToolButton *toggle,
822 EmpathyCallWindow *self)
824 if (gtk_toggle_tool_button_get_active (toggle))
825 enable_camera (self);
827 disable_camera (self);
831 create_pipeline (EmpathyCallWindow *self)
833 EmpathyCallWindowPriv *priv = GET_PRIV (self);
836 g_assert (priv->pipeline == NULL);
838 priv->pipeline = gst_pipeline_new (NULL);
839 priv->pipeline_playing = FALSE;
841 priv->video_tee = gst_element_factory_make ("tee", NULL);
842 gst_object_ref (priv->video_tee);
843 gst_object_sink (priv->video_tee);
845 gst_bin_add (GST_BIN (priv->pipeline), priv->video_tee);
847 bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
848 priv->bus_message_source_id = gst_bus_add_watch (bus,
849 empathy_call_window_bus_message, self);
851 g_object_unref (bus);
855 empathy_call_window_settings_cb (GtkAction *action,
856 EmpathyCallWindow *self)
858 gchar *args = g_strdup_printf ("-p %s",
859 empathy_preferences_tab_to_string (EMPATHY_PREFERENCES_TAB_CALLS));
861 empathy_launch_program (BIN_DIR, "empathy", args);
867 empathy_call_window_contents_cb (GtkAction *action,
868 EmpathyCallWindow *self)
870 empathy_url_show (GTK_WIDGET (self), "ghelp:empathy?audio-video");
874 empathy_call_window_debug_cb (GtkAction *action,
875 EmpathyCallWindow *self)
877 empathy_launch_program (BIN_DIR, "empathy-debugger", "-s Empathy.Call");
881 empathy_call_window_about_cb (GtkAction *action,
882 EmpathyCallWindow *self)
884 empathy_about_dialog_new (GTK_WINDOW (self));
888 empathy_call_window_toolbar_timeout (gpointer data)
890 EmpathyCallWindow *self = data;
892 clutter_state_set_state (self->priv->transitions, "fade-out");
898 empathy_call_window_motion_notify_cb (GtkWidget *widget,
900 EmpathyCallWindow *self)
902 clutter_state_set_state (self->priv->transitions, "fade-in");
904 if (self->priv->inactivity_src > 0)
905 g_source_remove (self->priv->inactivity_src);
907 self->priv->inactivity_src = g_timeout_add_seconds (3,
908 empathy_call_window_toolbar_timeout, self);
914 empathy_call_window_configure_event_cb (GtkWidget *widget,
916 EmpathyCallWindow *self)
918 GdkWindow *gdk_window;
919 GdkWindowState window_state;
921 gtk_window_get_position (GTK_WINDOW (self), &self->priv->x, &self->priv->y);
922 gtk_window_get_size (GTK_WINDOW (self), &self->priv->w, &self->priv->h);
924 gtk_widget_get_preferred_width (self->priv->dtmf_panel,
925 &self->priv->dialpad_width, NULL);
927 gdk_window = gtk_widget_get_window (widget);
928 window_state = gdk_window_get_state (gdk_window);
929 self->priv->maximized = (window_state & GDK_WINDOW_STATE_MAXIMIZED);
935 empathy_call_window_destroyed_cb (GtkWidget *object,
936 EmpathyCallWindow *self)
938 if (gtk_widget_get_visible (self->priv->dtmf_panel))
940 /* Save the geometry as if the dialpad was hidden. */
941 empathy_geometry_save_values (GTK_WINDOW (self),
942 self->priv->x, self->priv->y,
943 self->priv->w - self->priv->dialpad_width, self->priv->h,
944 self->priv->maximized);
949 empathy_call_window_stage_allocation_changed_cb (ClutterActor *stage,
951 ClutterBindConstraint *constraint)
953 ClutterActorBox allocation;
955 clutter_actor_get_allocation_box (stage, &allocation);
957 clutter_bind_constraint_set_offset (constraint,
958 allocation.y2 - allocation.y1 -
959 FLOATING_TOOLBAR_SPACING - FLOATING_TOOLBAR_HEIGHT);
963 empathy_call_window_init (EmpathyCallWindow *self)
965 EmpathyCallWindowPriv *priv;
969 ClutterConstraint *constraint;
970 ClutterActor *remote_avatar;
971 GtkStyleContext *context;
975 priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
976 EMPATHY_TYPE_CALL_WINDOW, EmpathyCallWindowPriv);
978 filename = empathy_file_lookup ("empathy-call-window.ui", "src");
979 gui = empathy_builder_get_file (filename,
980 "call_window_vbox", &top_vbox,
981 "errors_vbox", &priv->errors_vbox,
983 "remote_user_name_toolbar", &priv->remote_user_name_toolbar,
984 "remote_user_avatar_toolbar", &priv->remote_user_avatar_toolbar,
985 "status_label", &priv->status_label,
986 "audiocall", &priv->audio_call_button,
987 "videocall", &priv->video_call_button,
988 "microphone", &priv->mic_button,
989 "camera", &priv->camera_button,
990 "hangup", &priv->hangup_button,
991 "dialpad", &priv->dialpad_button,
992 "toolbar", &priv->toolbar,
993 "bottom_toolbar", &priv->bottom_toolbar,
994 "ui_manager", &priv->ui_manager,
995 "menufullscreen", &priv->menu_fullscreen,
996 "details_vbox", &priv->details_vbox,
997 "vcodec_encoding_label", &priv->vcodec_encoding_label,
998 "acodec_encoding_label", &priv->acodec_encoding_label,
999 "acodec_decoding_label", &priv->acodec_decoding_label,
1000 "vcodec_decoding_label", &priv->vcodec_decoding_label,
1001 "audio_remote_candidate_label", &priv->audio_remote_candidate_label,
1002 "audio_local_candidate_label", &priv->audio_local_candidate_label,
1003 "video_remote_candidate_label", &priv->video_remote_candidate_label,
1004 "video_local_candidate_label", &priv->video_local_candidate_label,
1005 "video_remote_candidate_info_img", &priv->video_remote_candidate_info_img,
1006 "video_local_candidate_info_img", &priv->video_local_candidate_info_img,
1007 "audio_remote_candidate_info_img", &priv->audio_remote_candidate_info_img,
1008 "audio_local_candidate_info_img", &priv->audio_local_candidate_info_img,
1012 empathy_builder_connect (gui, self,
1013 "hangup", "clicked", empathy_call_window_hangup_cb,
1014 "audiocall", "clicked", empathy_call_window_audio_call_cb,
1015 "videocall", "clicked", empathy_call_window_video_call_cb,
1016 "volume", "value-changed", empathy_call_window_volume_changed_cb,
1017 "microphone", "toggled", empathy_call_window_mic_toggled_cb,
1018 "camera", "toggled", empathy_call_window_camera_toggled_cb,
1019 "dialpad", "toggled", empathy_call_window_dialpad_cb,
1020 "menufullscreen", "activate", empathy_call_window_fullscreen_cb,
1021 "menusettings", "activate", empathy_call_window_settings_cb,
1022 "menucontents", "activate", empathy_call_window_contents_cb,
1023 "menudebug", "activate", empathy_call_window_debug_cb,
1024 "menuabout", "activate", empathy_call_window_about_cb,
1025 "menupreviewdisable", "activate", empathy_call_window_disable_camera_cb,
1026 "menupreviewminimise", "activate", empathy_call_window_minimise_camera_cb,
1027 "menupreviewmaximise", "activate", empathy_call_window_maximise_camera_cb,
1030 gtk_action_set_sensitive (priv->menu_fullscreen, FALSE);
1032 priv->camera_monitor = empathy_camera_monitor_dup_singleton ();
1034 g_object_bind_property (priv->camera_monitor, "available",
1035 priv->camera_button, "sensitive",
1036 G_BINDING_SYNC_CREATE);
1038 priv->lock = g_mutex_new ();
1040 gtk_container_add (GTK_CONTAINER (self), top_vbox);
1042 priv->content_hbox = gtk_hbox_new (FALSE, CONTENT_HBOX_SPACING);
1043 gtk_container_set_border_width (GTK_CONTAINER (priv->content_hbox),
1044 CONTENT_HBOX_BORDER_WIDTH);
1045 gtk_box_pack_start (GTK_BOX (priv->pane), priv->content_hbox,
1048 /* avatar/video box */
1049 priv->video_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
1050 CLUTTER_BIN_ALIGNMENT_CENTER);
1052 priv->video_box = clutter_box_new (priv->video_layout);
1054 priv->video_container = gtk_clutter_embed_new ();
1056 /* Set the background color to that of the rest of the window */
1057 context = gtk_widget_get_style_context (priv->content_hbox);
1058 gtk_style_context_get_background_color (context,
1059 GTK_STATE_FLAG_NORMAL, &rgba);
1060 bg.red = CLAMP (rgba.red * 255.0, 0, 255);
1061 bg.green = CLAMP (rgba.green * 255.0, 0, 255);
1062 bg.blue = CLAMP (rgba.blue * 255.0, 0, 255);
1063 bg.alpha = CLAMP (rgba.alpha * 255.0, 0, 255);
1064 clutter_stage_set_color (
1065 CLUTTER_STAGE (gtk_clutter_embed_get_stage (
1066 GTK_CLUTTER_EMBED (priv->video_container))),
1069 clutter_container_add (
1070 CLUTTER_CONTAINER (gtk_clutter_embed_get_stage (
1071 GTK_CLUTTER_EMBED (priv->video_container))),
1075 constraint = clutter_bind_constraint_new (
1076 gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->video_container)),
1077 CLUTTER_BIND_SIZE, 0);
1078 clutter_actor_add_constraint (priv->video_box, constraint);
1080 priv->remote_user_avatar_widget = gtk_image_new ();
1081 remote_avatar = gtk_clutter_actor_new_with_contents (
1082 priv->remote_user_avatar_widget);
1084 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_box),
1087 gtk_box_pack_start (GTK_BOX (priv->content_hbox),
1088 priv->video_container, TRUE, TRUE,
1089 CONTENT_HBOX_CHILDREN_PACKING_PADDING);
1091 create_pipeline (self);
1092 create_video_output_widget (self);
1093 create_audio_input (self);
1094 create_video_input (self);
1096 priv->floating_toolbar = empathy_rounded_actor_new ();
1098 gtk_widget_reparent (priv->bottom_toolbar,
1099 gtk_clutter_actor_get_widget (GTK_CLUTTER_ACTOR (priv->floating_toolbar)));
1101 constraint = clutter_bind_constraint_new (
1102 gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->video_container)),
1105 clutter_actor_add_constraint (priv->floating_toolbar, constraint);
1108 gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->video_container)),
1109 "notify::allocation",
1110 G_CALLBACK (empathy_call_window_stage_allocation_changed_cb),
1113 clutter_actor_set_size (priv->floating_toolbar,
1114 FLOATING_TOOLBAR_WIDTH, FLOATING_TOOLBAR_HEIGHT);
1115 clutter_actor_set_opacity (priv->floating_toolbar, FLOATING_TOOLBAR_OPACITY);
1117 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
1118 priv->floating_toolbar,
1119 CLUTTER_BIN_ALIGNMENT_CENTER,
1120 CLUTTER_BIN_ALIGNMENT_END);
1122 clutter_actor_raise_top (priv->floating_toolbar);
1124 /* Transitions for the floating toolbar */
1125 priv->transitions = clutter_state_new ();
1127 /* all transitions last for 2s */
1128 clutter_state_set_duration (priv->transitions, NULL, NULL, 2000);
1130 /* transition from any state to "fade-out" state */
1131 clutter_state_set (priv->transitions, NULL, "fade-out",
1132 priv->floating_toolbar,
1133 "opacity", CLUTTER_EASE_OUT_QUAD, 0,
1136 /* transition from any state to "fade-in" state */
1137 clutter_state_set (priv->transitions, NULL, "fade-in",
1138 priv->floating_toolbar,
1139 "opacity", CLUTTER_EASE_OUT_QUAD, FLOATING_TOOLBAR_OPACITY,
1142 /* put the actor into the "fade-in" state with no animation */
1143 clutter_state_warp_to_state (priv->transitions, "fade-in");
1145 /* The call will be started as soon the pipeline is playing */
1146 priv->start_call_when_playing = TRUE;
1148 priv->dtmf_panel = empathy_create_dtmf_dialpad (G_OBJECT (self),
1149 G_CALLBACK (dtmf_button_pressed_cb),
1150 G_CALLBACK (dtmf_button_released_cb));
1152 gtk_box_pack_start (GTK_BOX (priv->pane), priv->dtmf_panel,
1155 gtk_box_pack_start (GTK_BOX (priv->pane), priv->details_vbox,
1158 gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
1160 gtk_widget_show_all (top_vbox);
1162 gtk_widget_hide (priv->dtmf_panel);
1163 gtk_widget_hide (priv->details_vbox);
1165 priv->fullscreen = empathy_call_window_fullscreen_new (self);
1167 empathy_call_window_fullscreen_set_video_widget (priv->fullscreen,
1168 priv->video_container);
1170 /* We hide the bottom toolbar after 3s of inactivity and show it
1171 * again on mouse movement */
1172 priv->inactivity_src = g_timeout_add_seconds (3,
1173 empathy_call_window_toolbar_timeout, self);
1175 g_signal_connect (G_OBJECT (priv->fullscreen->leave_fullscreen_button),
1176 "clicked", G_CALLBACK (empathy_call_window_fullscreen_cb), self);
1178 g_signal_connect (G_OBJECT (self), "realize",
1179 G_CALLBACK (empathy_call_window_realized_cb), self);
1181 g_signal_connect (G_OBJECT (self), "delete-event",
1182 G_CALLBACK (empathy_call_window_delete_cb), self);
1184 g_signal_connect (G_OBJECT (self), "window-state-event",
1185 G_CALLBACK (empathy_call_window_state_event_cb), self);
1187 g_signal_connect (G_OBJECT (self), "key-press-event",
1188 G_CALLBACK (empathy_call_window_key_press_cb), self);
1190 g_signal_connect (self, "motion-notify-event",
1191 G_CALLBACK (empathy_call_window_motion_notify_cb), self);
1193 priv->timer = g_timer_new ();
1195 g_object_ref (priv->ui_manager);
1196 g_object_unref (gui);
1198 priv->sound_mgr = empathy_sound_manager_dup_singleton ();
1199 priv->mic_menu = empathy_mic_menu_new (self);
1201 empathy_call_window_show_hangup_button (self, TRUE);
1203 priv->settings = g_settings_new (EMPATHY_PREFS_CALL_SCHEMA);
1205 /* Retrieve initial volume */
1206 priv->volume = g_settings_get_double (priv->settings,
1207 EMPATHY_PREFS_CALL_SOUND_VOLUME) / 100.0;
1209 g_signal_connect (priv->settings, "changed::"EMPATHY_PREFS_CALL_SOUND_VOLUME,
1210 G_CALLBACK (empathy_call_window_prefs_volume_changed_cb), self);
1212 empathy_geometry_bind (GTK_WINDOW (self), "call-window");
1213 /* These signals are used to track the window position and save it
1214 * when the window is destroyed. We need to do this as we don't want
1215 * the window geometry to be saved with the dialpad taken into account. */
1216 g_signal_connect (self, "destroy",
1217 G_CALLBACK (empathy_call_window_destroyed_cb), self);
1218 g_signal_connect (self, "configure-event",
1219 G_CALLBACK (empathy_call_window_configure_event_cb), self);
1220 g_signal_connect (self, "window-state-event",
1221 G_CALLBACK (empathy_call_window_configure_event_cb), self);
1223 /* Don't display labels in both toolbars */
1224 gtk_toolbar_set_style (GTK_TOOLBAR (priv->toolbar), GTK_TOOLBAR_ICONS);
1227 /* Instead of specifying a width and a height, we specify only one size. That's
1228 because we want a square avatar icon. */
1230 init_contact_avatar_with_size (EmpathyContact *contact,
1231 GtkWidget *image_widget,
1234 GdkPixbuf *pixbuf_avatar = NULL;
1236 if (contact != NULL)
1238 pixbuf_avatar = empathy_pixbuf_avatar_from_contact_scaled (contact,
1242 if (pixbuf_avatar == NULL)
1244 pixbuf_avatar = empathy_pixbuf_from_icon_name_sized (
1245 EMPATHY_IMAGE_AVATAR_DEFAULT, size);
1248 gtk_image_set_from_pixbuf (GTK_IMAGE (image_widget), pixbuf_avatar);
1250 if (pixbuf_avatar != NULL)
1251 g_object_unref (pixbuf_avatar);
1255 set_window_title (EmpathyCallWindow *self)
1257 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1260 if (priv->contact != NULL)
1262 /* translators: Call is a noun and %s is the contact name. This string
1263 * is used in the window title */
1264 tmp = g_strdup_printf (_("Call with %s"),
1265 empathy_contact_get_alias (priv->contact));
1266 gtk_window_set_title (GTK_WINDOW (self), tmp);
1271 g_warning ("Unknown remote contact!");
1276 set_remote_user_name (EmpathyCallWindow *self,
1277 EmpathyContact *contact)
1279 const gchar *alias = empathy_contact_get_alias (contact);
1280 const gchar *status = empathy_contact_get_status (contact);
1283 label = g_strdup_printf ("%s\n<small>%s</small>", alias, status);
1284 gtk_label_set_markup (GTK_LABEL (self->priv->remote_user_name_toolbar),
1290 contact_name_changed_cb (EmpathyContact *contact,
1292 EmpathyCallWindow *self)
1294 set_window_title (self);
1295 set_remote_user_name (self, contact);
1299 contact_presence_changed_cb (EmpathyContact *contact,
1301 EmpathyCallWindow *self)
1303 set_remote_user_name (self, contact);
1307 contact_avatar_changed_cb (EmpathyContact *contact,
1309 EmpathyCallWindow *self)
1312 GtkAllocation allocation;
1313 GtkWidget *avatar_widget;
1315 avatar_widget = self->priv->remote_user_avatar_widget;
1317 gtk_widget_get_allocation (avatar_widget, &allocation);
1318 size = allocation.height;
1322 /* the widget is not allocated yet, set a default size */
1323 size = MIN (REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT,
1324 REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH);
1327 init_contact_avatar_with_size (contact, avatar_widget, size);
1329 avatar_widget = self->priv->remote_user_avatar_toolbar;
1331 gtk_widget_get_allocation (avatar_widget, &allocation);
1332 size = allocation.height;
1336 /* the widget is not allocated yet, set a default size */
1337 size = SMALL_TOOLBAR_SIZE;
1340 init_contact_avatar_with_size (contact, avatar_widget, size);
1344 empathy_call_window_setup_avatars (EmpathyCallWindow *self,
1345 EmpathyCallHandler *handler)
1347 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1349 tp_g_signal_connect_object (priv->contact, "notify::name",
1350 G_CALLBACK (contact_name_changed_cb), self, 0);
1351 tp_g_signal_connect_object (priv->contact, "notify::avatar",
1352 G_CALLBACK (contact_avatar_changed_cb), self, 0);
1353 tp_g_signal_connect_object (priv->contact, "notify::presence",
1354 G_CALLBACK (contact_presence_changed_cb), self, 0);
1356 set_window_title (self);
1357 set_remote_user_name (self, priv->contact);
1359 init_contact_avatar_with_size (priv->contact,
1360 priv->remote_user_avatar_widget,
1361 MIN (REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH,
1362 REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT));
1364 init_contact_avatar_with_size (priv->contact,
1365 priv->remote_user_avatar_toolbar,
1366 SMALL_TOOLBAR_SIZE);
1368 /* The remote avatar is shown by default and will be hidden when we receive
1369 video from the remote side. */
1370 clutter_actor_hide (priv->video_output);
1371 gtk_widget_show (priv->remote_user_avatar_widget);
1375 update_send_codec (EmpathyCallWindow *self,
1378 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1385 codec = empathy_call_handler_get_send_audio_codec (priv->handler);
1386 widget = priv->acodec_encoding_label;
1390 codec = empathy_call_handler_get_send_video_codec (priv->handler);
1391 widget = priv->vcodec_encoding_label;
1397 tmp = g_strdup_printf ("%s/%u", codec->encoding_name, codec->clock_rate);
1398 gtk_label_set_text (GTK_LABEL (widget), tmp);
1403 send_audio_codec_notify_cb (GObject *object,
1407 EmpathyCallWindow *self = user_data;
1409 update_send_codec (self, TRUE);
1413 send_video_codec_notify_cb (GObject *object,
1417 EmpathyCallWindow *self = user_data;
1419 update_send_codec (self, FALSE);
1423 update_recv_codec (EmpathyCallWindow *self,
1426 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1429 GString *str = NULL;
1433 codecs = empathy_call_handler_get_recv_audio_codecs (priv->handler);
1434 widget = priv->acodec_decoding_label;
1438 codecs = empathy_call_handler_get_recv_video_codecs (priv->handler);
1439 widget = priv->vcodec_decoding_label;
1445 for (l = codecs; l != NULL; l = g_list_next (l))
1447 FsCodec *codec = l->data;
1450 str = g_string_new (NULL);
1452 g_string_append (str, ", ");
1454 g_string_append_printf (str, "%s/%u", codec->encoding_name,
1458 gtk_label_set_text (GTK_LABEL (widget), str->str);
1459 g_string_free (str, TRUE);
1463 recv_audio_codecs_notify_cb (GObject *object,
1467 EmpathyCallWindow *self = user_data;
1469 update_recv_codec (self, TRUE);
1473 recv_video_codecs_notify_cb (GObject *object,
1477 EmpathyCallWindow *self = user_data;
1479 update_recv_codec (self, FALSE);
1482 static const gchar *
1483 candidate_type_to_str (FsCandidate *candidate)
1485 switch (candidate->type)
1487 case FS_CANDIDATE_TYPE_HOST:
1489 case FS_CANDIDATE_TYPE_SRFLX:
1490 return "server reflexive";
1491 case FS_CANDIDATE_TYPE_PRFLX:
1492 return "peer reflexive";
1493 case FS_CANDIDATE_TYPE_RELAY:
1495 case FS_CANDIDATE_TYPE_MULTICAST:
1502 static const gchar *
1503 candidate_type_to_desc (FsCandidate *candidate)
1505 switch (candidate->type)
1507 case FS_CANDIDATE_TYPE_HOST:
1508 return _("The IP address as seen by the machine");
1509 case FS_CANDIDATE_TYPE_SRFLX:
1510 return _("The IP address as seen by a server on the Internet");
1511 case FS_CANDIDATE_TYPE_PRFLX:
1512 return _("The IP address of the peer as seen by the other side");
1513 case FS_CANDIDATE_TYPE_RELAY:
1514 return _("The IP address of a relay server");
1515 case FS_CANDIDATE_TYPE_MULTICAST:
1516 return _("The IP address of the multicast group");
1523 update_candidat_widget (EmpathyCallWindow *self,
1526 FsCandidate *candidate)
1530 g_assert (candidate != NULL);
1531 str = g_strdup_printf ("%s %u (%s)", candidate->ip,
1532 candidate->port, candidate_type_to_str (candidate));
1534 gtk_label_set_text (GTK_LABEL (label), str);
1535 gtk_widget_set_tooltip_text (img, candidate_type_to_desc (candidate));
1541 candidates_changed_cb (GObject *object,
1543 EmpathyCallWindow *self)
1545 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1546 FsCandidate *candidate = NULL;
1548 if (type == FS_MEDIA_TYPE_VIDEO)
1550 /* Update remote candidate */
1551 candidate = empathy_call_handler_get_video_remote_candidate (
1554 update_candidat_widget (self, priv->video_remote_candidate_label,
1555 priv->video_remote_candidate_info_img, candidate);
1557 /* Update local candidate */
1558 candidate = empathy_call_handler_get_video_local_candidate (
1561 update_candidat_widget (self, priv->video_local_candidate_label,
1562 priv->video_local_candidate_info_img, candidate);
1566 /* Update remote candidate */
1567 candidate = empathy_call_handler_get_audio_remote_candidate (
1570 update_candidat_widget (self, priv->audio_remote_candidate_label,
1571 priv->audio_remote_candidate_info_img, candidate);
1573 /* Update local candidate */
1574 candidate = empathy_call_handler_get_audio_local_candidate (
1577 update_candidat_widget (self, priv->audio_local_candidate_label,
1578 priv->audio_local_candidate_info_img, candidate);
1583 empathy_call_window_constructed (GObject *object)
1585 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
1586 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1587 TpyCallChannel *call;
1589 g_assert (priv->handler != NULL);
1591 g_object_get (priv->handler, "call-channel", &call, NULL);
1592 priv->outgoing = (call == NULL);
1594 g_object_unref (call);
1596 g_object_get (priv->handler, "target-contact", &priv->contact, NULL);
1597 g_assert (priv->contact != NULL);
1599 empathy_call_window_setup_avatars (self, priv->handler);
1600 empathy_call_window_set_state_connecting (self);
1602 if (!empathy_call_handler_has_initial_video (priv->handler))
1604 gtk_toggle_tool_button_set_active (
1605 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), FALSE);
1607 /* If call has InitialVideo, the preview will be started once the call has
1608 * been started (start_call()). */
1610 update_send_codec (self, TRUE);
1611 update_send_codec (self, FALSE);
1612 update_recv_codec (self, TRUE);
1613 update_recv_codec (self, FALSE);
1615 tp_g_signal_connect_object (priv->handler, "notify::send-audio-codec",
1616 G_CALLBACK (send_audio_codec_notify_cb), self, 0);
1617 tp_g_signal_connect_object (priv->handler, "notify::send-video-codec",
1618 G_CALLBACK (send_video_codec_notify_cb), self, 0);
1619 tp_g_signal_connect_object (priv->handler, "notify::recv-audio-codecs",
1620 G_CALLBACK (recv_audio_codecs_notify_cb), self, 0);
1621 tp_g_signal_connect_object (priv->handler, "notify::recv-video-codecs",
1622 G_CALLBACK (recv_video_codecs_notify_cb), self, 0);
1624 tp_g_signal_connect_object (priv->handler, "candidates-changed",
1625 G_CALLBACK (candidates_changed_cb), self, 0);
1628 static void empathy_call_window_dispose (GObject *object);
1629 static void empathy_call_window_finalize (GObject *object);
1632 empathy_call_window_set_property (GObject *object,
1633 guint property_id, const GValue *value, GParamSpec *pspec)
1635 EmpathyCallWindowPriv *priv = GET_PRIV (object);
1637 switch (property_id)
1639 case PROP_CALL_HANDLER:
1640 priv->handler = g_value_dup_object (value);
1643 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1648 empathy_call_window_get_property (GObject *object,
1649 guint property_id, GValue *value, GParamSpec *pspec)
1651 EmpathyCallWindowPriv *priv = GET_PRIV (object);
1653 switch (property_id)
1655 case PROP_CALL_HANDLER:
1656 g_value_set_object (value, priv->handler);
1659 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1664 empathy_call_window_class_init (
1665 EmpathyCallWindowClass *empathy_call_window_class)
1667 GObjectClass *object_class = G_OBJECT_CLASS (empathy_call_window_class);
1668 GParamSpec *param_spec;
1670 g_type_class_add_private (empathy_call_window_class,
1671 sizeof (EmpathyCallWindowPriv));
1673 object_class->constructed = empathy_call_window_constructed;
1674 object_class->set_property = empathy_call_window_set_property;
1675 object_class->get_property = empathy_call_window_get_property;
1677 object_class->dispose = empathy_call_window_dispose;
1678 object_class->finalize = empathy_call_window_finalize;
1680 param_spec = g_param_spec_object ("handler",
1681 "handler", "The call handler",
1682 EMPATHY_TYPE_CALL_HANDLER,
1683 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
1684 g_object_class_install_property (object_class,
1685 PROP_CALL_HANDLER, param_spec);
1689 empathy_call_window_dispose (GObject *object)
1691 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
1692 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1694 if (priv->dispose_has_run)
1697 priv->dispose_has_run = TRUE;
1699 if (priv->handler != NULL)
1701 empathy_call_handler_stop_call (priv->handler);
1702 tp_clear_object (&priv->handler);
1705 if (priv->bus_message_source_id != 0)
1707 g_source_remove (priv->bus_message_source_id);
1708 priv->bus_message_source_id = 0;
1711 if (priv->got_video_src > 0)
1713 g_source_remove (priv->got_video_src);
1714 priv->got_video_src = 0;
1717 if (priv->inactivity_src > 0)
1719 g_source_remove (priv->inactivity_src);
1720 priv->inactivity_src = 0;
1723 tp_clear_object (&priv->pipeline);
1724 tp_clear_object (&priv->video_input);
1725 tp_clear_object (&priv->audio_input);
1726 tp_clear_object (&priv->video_tee);
1727 tp_clear_object (&priv->ui_manager);
1728 tp_clear_object (&priv->fullscreen);
1729 tp_clear_object (&priv->camera_monitor);
1730 tp_clear_object (&priv->settings);
1731 tp_clear_object (&priv->transitions);
1733 g_list_free_full (priv->notifiers, g_object_unref);
1735 if (priv->timer_id != 0)
1736 g_source_remove (priv->timer_id);
1739 if (priv->contact != NULL)
1741 g_signal_handlers_disconnect_by_func (priv->contact,
1742 contact_name_changed_cb, self);
1743 priv->contact = NULL;
1747 tp_clear_object (&priv->sound_mgr);
1749 tp_clear_object (&priv->mic_menu);
1751 G_OBJECT_CLASS (empathy_call_window_parent_class)->dispose (object);
1755 disconnect_video_output_motion_handler (EmpathyCallWindow *self)
1757 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1759 if (priv->video_output_motion_handler_id != 0)
1761 g_signal_handler_disconnect (G_OBJECT (priv->video_container),
1762 priv->video_output_motion_handler_id);
1763 priv->video_output_motion_handler_id = 0;
1768 empathy_call_window_finalize (GObject *object)
1770 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
1771 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1773 disconnect_video_output_motion_handler (self);
1775 /* free any data held directly by the object here */
1776 g_mutex_free (priv->lock);
1778 g_timer_destroy (priv->timer);
1780 G_OBJECT_CLASS (empathy_call_window_parent_class)->finalize (object);
1785 empathy_call_window_new (EmpathyCallHandler *handler)
1787 return EMPATHY_CALL_WINDOW (
1788 g_object_new (EMPATHY_TYPE_CALL_WINDOW, "handler", handler, NULL));
1792 empathy_call_window_conference_added_cb (EmpathyCallHandler *handler,
1793 GstElement *conference, gpointer user_data)
1795 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
1796 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1797 FsElementAddedNotifier *notifier;
1800 DEBUG ("Conference added");
1802 /* Add notifier to set the various element properties as needed */
1803 notifier = fs_element_added_notifier_new ();
1804 keyfile = fs_utils_get_default_element_properties (conference);
1806 if (keyfile != NULL)
1807 fs_element_added_notifier_set_properties_from_keyfile (notifier, keyfile);
1809 fs_element_added_notifier_add (notifier, GST_BIN (priv->pipeline));
1811 priv->notifiers = g_list_prepend (priv->notifiers, notifier);
1813 gst_bin_add (GST_BIN (priv->pipeline), conference);
1814 gst_element_set_state (conference, GST_STATE_PLAYING);
1818 empathy_call_window_conference_removed_cb (EmpathyCallHandler *handler,
1819 GstElement *conference, gpointer user_data)
1821 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
1822 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1824 gst_bin_remove (GST_BIN (priv->pipeline), conference);
1825 gst_element_set_state (conference, GST_STATE_NULL);
1829 empathy_call_window_reset_pipeline (EmpathyCallWindow *self)
1831 GstStateChangeReturn state_change_return;
1832 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1834 if (priv->pipeline == NULL)
1837 if (priv->bus_message_source_id != 0)
1839 g_source_remove (priv->bus_message_source_id);
1840 priv->bus_message_source_id = 0;
1843 state_change_return = gst_element_set_state (priv->pipeline, GST_STATE_NULL);
1845 if (state_change_return == GST_STATE_CHANGE_SUCCESS ||
1846 state_change_return == GST_STATE_CHANGE_NO_PREROLL)
1848 if (priv->pipeline != NULL)
1849 g_object_unref (priv->pipeline);
1850 priv->pipeline = NULL;
1852 if (priv->audio_output != NULL)
1853 g_object_unref (priv->audio_output);
1854 priv->audio_output = NULL;
1856 if (priv->video_tee != NULL)
1857 g_object_unref (priv->video_tee);
1858 priv->video_tee = NULL;
1860 if (priv->video_preview != NULL)
1861 clutter_actor_destroy (priv->video_preview);
1862 priv->video_preview = NULL;
1864 priv->funnel = NULL;
1866 create_pipeline (self);
1867 /* Call will be started when user will hit the 'redial' button */
1868 priv->start_call_when_playing = FALSE;
1869 gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
1875 g_message ("Error: could not destroy pipeline. Closing call window");
1876 gtk_widget_destroy (GTK_WIDGET (self));
1883 reset_details_pane (EmpathyCallWindow *self)
1885 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1887 gtk_label_set_text (GTK_LABEL (priv->vcodec_encoding_label), _("Unknown"));
1888 gtk_label_set_text (GTK_LABEL (priv->acodec_encoding_label), _("Unknown"));
1889 gtk_label_set_text (GTK_LABEL (priv->vcodec_decoding_label), _("Unknown"));
1890 gtk_label_set_text (GTK_LABEL (priv->acodec_decoding_label), _("Unknown"));
1894 empathy_call_window_disconnected (EmpathyCallWindow *self,
1897 gboolean could_disconnect = FALSE;
1898 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1899 gboolean could_reset_pipeline;
1901 /* Leave full screen mode if needed */
1902 gtk_window_unfullscreen (GTK_WINDOW (self));
1904 gtk_action_set_sensitive (priv->menu_fullscreen, FALSE);
1905 gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
1907 could_reset_pipeline = empathy_call_window_reset_pipeline (self);
1909 if (priv->call_state == CONNECTING)
1910 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
1912 if (priv->call_state != REDIALING)
1913 priv->call_state = DISCONNECTED;
1915 if (could_reset_pipeline)
1917 g_mutex_lock (priv->lock);
1919 g_timer_stop (priv->timer);
1921 if (priv->timer_id != 0)
1922 g_source_remove (priv->timer_id);
1925 g_mutex_unlock (priv->lock);
1928 /* We are about to destroy the window, no need to update it or create
1929 * a video preview */
1932 empathy_call_window_status_message (self, _("Disconnected"));
1934 empathy_call_window_show_hangup_button (self, FALSE);
1936 /* Unsensitive the camera and mic button */
1937 gtk_widget_set_sensitive (priv->camera_button, FALSE);
1938 gtk_widget_set_sensitive (priv->mic_button, FALSE);
1940 /* Be sure that the mic button is enabled */
1941 gtk_toggle_tool_button_set_active (
1942 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button), TRUE);
1944 if (priv->camera_state == CAMERA_STATE_ON)
1946 /* Restart the preview with the new pipeline. */
1947 display_video_preview (self, TRUE);
1950 /* destroy the video output; it will be recreated when we'll redial */
1951 disconnect_video_output_motion_handler (self);
1952 if (priv->video_output != NULL)
1953 clutter_actor_destroy (priv->video_output);
1954 priv->video_output = NULL;
1955 if (priv->got_video_src > 0)
1957 g_source_remove (priv->got_video_src);
1958 priv->got_video_src = 0;
1961 gtk_widget_show (priv->remote_user_avatar_widget);
1963 reset_details_pane (self);
1965 priv->sending_video = FALSE;
1966 priv->call_started = FALSE;
1968 could_disconnect = TRUE;
1970 /* TODO: display the self avatar of the preview (depends if the "Always
1971 * Show Video Preview" is enabled or not) */
1974 return could_disconnect;
1979 empathy_call_window_channel_closed_cb (EmpathyCallHandler *handler,
1982 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
1983 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1985 if (empathy_call_window_disconnected (self, TRUE) &&
1986 priv->call_state == REDIALING)
1987 empathy_call_window_restart_call (self);
1991 empathy_call_window_sink_removed_cb (EmpathyCallHandler *handler,
1993 FsMediaType media_type,
1994 EmpathyCallWindow *self)
1996 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1998 DEBUG ("removing content");
2001 * This assumes that there is only one video stream per channel...
2004 if ((guint) media_type == FS_MEDIA_TYPE_VIDEO)
2006 if (priv->funnel != NULL)
2010 output = priv->video_output_sink;
2012 gst_element_set_state (output, GST_STATE_NULL);
2013 gst_element_set_state (priv->funnel, GST_STATE_NULL);
2015 gst_bin_remove (GST_BIN (priv->pipeline), output);
2016 gst_bin_remove (GST_BIN (priv->pipeline), priv->funnel);
2017 priv->funnel = NULL;
2021 else if (media_type == FS_MEDIA_TYPE_AUDIO)
2023 if (priv->audio_output != NULL)
2025 gst_element_set_state (priv->audio_output, GST_STATE_NULL);
2027 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
2028 priv->audio_output = NULL;
2036 /* Called with global lock held */
2038 empathy_call_window_get_video_sink_pad (EmpathyCallWindow *self)
2040 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2044 if (priv->funnel == NULL)
2046 output = priv->video_output_sink;
2048 priv->funnel = gst_element_factory_make ("fsfunnel", NULL);
2052 g_warning ("Could not create fsfunnel");
2056 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->funnel))
2058 gst_object_unref (priv->funnel);
2059 priv->funnel = NULL;
2060 g_warning ("Could not add funnel to pipeline");
2064 if (!gst_bin_add (GST_BIN (priv->pipeline), output))
2066 g_warning ("Could not add the video output widget to the pipeline");
2070 if (!gst_element_link (priv->funnel, output))
2072 g_warning ("Could not link output sink to funnel");
2073 goto error_output_added;
2076 if (gst_element_set_state (output, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2078 g_warning ("Could not start video sink");
2079 goto error_output_added;
2082 if (gst_element_set_state (priv->funnel, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2084 g_warning ("Could not start funnel");
2085 goto error_output_added;
2089 pad = gst_element_get_request_pad (priv->funnel, "sink%d");
2092 g_warning ("Could not get request pad from funnel");
2099 gst_element_set_locked_state (priv->funnel, TRUE);
2100 gst_element_set_locked_state (output, TRUE);
2102 gst_element_set_state (priv->funnel, GST_STATE_NULL);
2103 gst_element_set_state (output, GST_STATE_NULL);
2105 gst_bin_remove (GST_BIN (priv->pipeline), output);
2106 gst_element_set_locked_state (output, FALSE);
2110 gst_bin_remove (GST_BIN (priv->pipeline), priv->funnel);
2111 priv->funnel = NULL;
2116 /* Called with global lock held */
2118 empathy_call_window_get_audio_sink_pad (EmpathyCallWindow *self)
2120 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2122 GstPadTemplate *template;
2124 if (priv->audio_output == NULL)
2126 priv->audio_output = empathy_audio_sink_new ();
2127 g_object_ref_sink (priv->audio_output);
2129 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_output))
2131 g_warning ("Could not add audio sink to pipeline");
2132 g_object_unref (priv->audio_output);
2133 goto error_add_output;
2136 if (gst_element_set_state (priv->audio_output, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2138 g_warning ("Could not start audio sink");
2143 template = gst_element_class_get_pad_template (
2144 GST_ELEMENT_GET_CLASS (priv->audio_output), "sink%d");
2146 pad = gst_element_request_pad (priv->audio_output,
2147 template, NULL, NULL);
2151 g_warning ("Could not get sink pad from sink");
2158 gst_element_set_locked_state (priv->audio_output, TRUE);
2159 gst_element_set_state (priv->audio_output, GST_STATE_NULL);
2160 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
2161 priv->audio_output = NULL;
2169 empathy_call_window_update_timer (gpointer user_data)
2171 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2172 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2173 const gchar *status;
2177 time_ = g_timer_elapsed (priv->timer, NULL);
2179 if (priv->call_state == HELD)
2180 status = _("On hold");
2181 else if (!gtk_toggle_tool_button_get_active (
2182 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
2185 status = _("Duration");
2187 /* Translators: 'status - minutes:seconds' the caller has been connected */
2188 str = g_strdup_printf (_("%s — %d:%02dm"),
2190 (int) time_ / 60, (int) time_ % 60);
2191 empathy_call_window_status_message (self, str);
2199 display_error (EmpathyCallWindow *self,
2200 TpyCallChannel *call,
2204 const gchar *details)
2206 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2207 GtkWidget *info_bar;
2208 GtkWidget *content_area;
2215 /* Create info bar */
2216 info_bar = gtk_info_bar_new_with_buttons (GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
2219 gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_WARNING);
2221 content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar));
2223 /* hbox containing the image and the messages vbox */
2224 hbox = gtk_hbox_new (FALSE, 3);
2225 gtk_container_add (GTK_CONTAINER (content_area), hbox);
2228 image = gtk_image_new_from_icon_name (img, GTK_ICON_SIZE_DIALOG);
2229 gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
2231 /* vbox containing the main message and the details expander */
2232 vbox = gtk_vbox_new (FALSE, 3);
2233 gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
2236 txt = g_strdup_printf ("<b>%s</b>\n%s", title, desc);
2238 label = gtk_label_new (NULL);
2239 gtk_label_set_markup (GTK_LABEL (label), txt);
2240 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
2241 gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
2244 gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
2247 if (details != NULL)
2249 GtkWidget *expander;
2251 expander = gtk_expander_new (_("Technical Details"));
2253 txt = g_strdup_printf ("<i>%s</i>", details);
2255 label = gtk_label_new (NULL);
2256 gtk_label_set_markup (GTK_LABEL (label), txt);
2257 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
2258 gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
2261 gtk_container_add (GTK_CONTAINER (expander), label);
2262 gtk_box_pack_start (GTK_BOX (vbox), expander, TRUE, TRUE, 0);
2265 g_signal_connect (info_bar, "response",
2266 G_CALLBACK (gtk_widget_destroy), NULL);
2268 gtk_box_pack_start (GTK_BOX (priv->errors_vbox), info_bar,
2269 FALSE, FALSE, CONTENT_HBOX_CHILDREN_PACKING_PADDING);
2270 gtk_widget_show_all (info_bar);
2274 media_stream_error_to_txt (EmpathyCallWindow *self,
2275 TpyCallChannel *call,
2277 TpMediaStreamError error)
2279 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2280 const gchar *cm = NULL;
2286 case TP_MEDIA_STREAM_ERROR_CODEC_NEGOTIATION_FAILED:
2288 return g_strdup_printf (
2289 _("%s's software does not understand any of the audio formats "
2290 "supported by your computer"),
2291 empathy_contact_get_alias (priv->contact));
2293 return g_strdup_printf (
2294 _("%s's software does not understand any of the video formats "
2295 "supported by your computer"),
2296 empathy_contact_get_alias (priv->contact));
2298 case TP_MEDIA_STREAM_ERROR_CONNECTION_FAILED:
2299 return g_strdup_printf (
2300 _("Can't establish a connection to %s. "
2301 "One of you might be on a network that does not allow "
2302 "direct connections."),
2303 empathy_contact_get_alias (priv->contact));
2305 case TP_MEDIA_STREAM_ERROR_NETWORK_ERROR:
2306 return g_strdup (_("There was a failure on the network"));
2308 case TP_MEDIA_STREAM_ERROR_NO_CODECS:
2310 return g_strdup (_("The audio formats necessary for this call "
2311 "are not installed on your computer"));
2313 return g_strdup (_("The video formats necessary for this call "
2314 "are not installed on your computer"));
2316 case TP_MEDIA_STREAM_ERROR_INVALID_CM_BEHAVIOR:
2317 tp_connection_parse_object_path (
2318 tp_channel_borrow_connection (TP_CHANNEL (call)),
2321 url = g_strdup_printf ("http://bugs.freedesktop.org/enter_bug.cgi?"
2322 "product=Telepathy&component=%s", cm);
2324 result = g_strdup_printf (
2325 _("Something unexpected happened in a Telepathy component. "
2326 "Please <a href=\"%s\">report this bug</a> and attach "
2327 "logs gathered from the 'Debug' window in the Help menu."), url);
2333 case TP_MEDIA_STREAM_ERROR_MEDIA_ERROR:
2334 return g_strdup (_("There was a failure in the call engine"));
2336 case TP_MEDIA_STREAM_ERROR_EOS:
2337 return g_strdup (_("The end of the stream was reached"));
2339 case TP_MEDIA_STREAM_ERROR_UNKNOWN:
2346 empathy_call_window_stream_error (EmpathyCallWindow *self,
2347 TpyCallChannel *call,
2356 desc = media_stream_error_to_txt (self, call, audio, code);
2359 /* No description, use the error message. That's not great as it's not
2360 * localized but it's better than nothing. */
2361 display_error (self, call, icon, title, msg, NULL);
2365 display_error (self, call, icon, title, desc, msg);
2371 empathy_call_window_audio_stream_error (TpyCallChannel *call,
2374 EmpathyCallWindow *self)
2376 empathy_call_window_stream_error (self, call, TRUE, code, msg,
2377 "gnome-stock-mic", _("Can't establish audio stream"));
2381 empathy_call_window_video_stream_error (TpyCallChannel *call,
2384 EmpathyCallWindow *self)
2386 empathy_call_window_stream_error (self, call, FALSE, code, msg,
2387 "camera-web", _("Can't establish video stream"));
2392 empathy_call_window_state_changed_cb (EmpathyCallHandler *handler,
2394 EmpathyCallWindow *self)
2396 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2397 TpyCallChannel *call;
2398 gboolean can_send_video;
2400 if (state != TPY_CALL_STATE_ACCEPTED)
2403 if (priv->call_state == CONNECTED)
2406 g_timer_start (priv->timer);
2407 priv->call_state = CONNECTED;
2409 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
2411 can_send_video = priv->video_input != NULL &&
2412 empathy_contact_can_voip_video (priv->contact) &&
2413 empathy_camera_monitor_get_available (priv->camera_monitor);
2415 g_object_get (priv->handler, "call-channel", &call, NULL);
2417 if (tpy_call_channel_has_dtmf (call))
2418 gtk_widget_set_sensitive (priv->dtmf_panel, TRUE);
2420 if (priv->video_input == NULL)
2421 empathy_call_window_set_send_video (self, CAMERA_STATE_OFF);
2423 gtk_widget_set_sensitive (priv->camera_button, can_send_video);
2425 empathy_call_window_show_hangup_button (self, TRUE);
2427 gtk_widget_set_sensitive (priv->mic_button, TRUE);
2429 clutter_actor_hide (priv->video_output);
2430 gtk_widget_show (priv->remote_user_avatar_widget);
2432 g_object_unref (call);
2434 g_mutex_lock (priv->lock);
2436 priv->timer_id = g_timeout_add_seconds (1,
2437 empathy_call_window_update_timer, self);
2439 g_mutex_unlock (priv->lock);
2441 empathy_call_window_update_timer (self);
2443 gtk_action_set_sensitive (priv->menu_fullscreen, TRUE);
2447 empathy_call_window_show_video_output_cb (gpointer user_data)
2449 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2451 if (self->priv->video_output != NULL)
2453 gtk_widget_hide (self->priv->remote_user_avatar_widget);
2454 clutter_actor_show (self->priv->video_output);
2455 clutter_actor_raise_top (self->priv->floating_toolbar);
2462 empathy_call_window_check_video_cb (gpointer data)
2464 EmpathyCallWindow *self = data;
2466 if (self->priv->got_video)
2468 self->priv->got_video = FALSE;
2472 /* No video in the last N seconds, display the remote avatar */
2473 empathy_call_window_show_video_output (self, FALSE);
2478 /* Called from the streaming thread */
2480 empathy_call_window_video_probe_cb (GstPad *pad,
2481 GstMiniObject *mini_obj,
2482 EmpathyCallWindow *self)
2485 if (GST_IS_EVENT (mini_obj))
2488 if (G_UNLIKELY (!self->priv->got_video))
2490 /* show the remote video */
2491 g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
2492 empathy_call_window_show_video_output_cb,
2493 g_object_ref (self), g_object_unref);
2495 self->priv->got_video = TRUE;
2501 /* Called from the streaming thread */
2503 empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
2504 GstPad *src, guint media_type, gpointer user_data)
2506 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2507 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2508 gboolean retval = FALSE;
2512 g_mutex_lock (priv->lock);
2516 case TP_MEDIA_STREAM_TYPE_AUDIO:
2517 pad = empathy_call_window_get_audio_sink_pad (self);
2519 case TP_MEDIA_STREAM_TYPE_VIDEO:
2520 g_idle_add (empathy_call_window_show_video_output_cb, self);
2521 pad = empathy_call_window_get_video_sink_pad (self);
2523 gst_pad_add_data_probe (src,
2524 G_CALLBACK (empathy_call_window_video_probe_cb), self);
2525 if (priv->got_video_src > 0)
2526 g_source_remove (priv->got_video_src);
2527 priv->got_video_src = g_timeout_add_seconds (5,
2528 empathy_call_window_check_video_cb, self);
2531 g_assert_not_reached ();
2537 if (GST_PAD_LINK_FAILED (gst_pad_link (src, pad)))
2538 g_warning ("Could not link %s sink pad",
2539 media_type == TP_MEDIA_STREAM_TYPE_AUDIO ? "audio" : "video");
2543 gst_object_unref (pad);
2547 /* If no sink could be linked, try to add fakesink to prevent the whole call
2552 GstElement *fakesink = gst_element_factory_make ("fakesink", NULL);
2554 if (gst_bin_add (GST_BIN (priv->pipeline), fakesink))
2556 GstPad *sinkpad = gst_element_get_static_pad (fakesink, "sink");
2557 if (gst_element_set_state (fakesink, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE ||
2558 GST_PAD_LINK_FAILED (gst_pad_link (src, sinkpad)))
2560 gst_element_set_locked_state (fakesink, TRUE);
2561 gst_element_set_state (fakesink, GST_STATE_NULL);
2562 gst_bin_remove (GST_BIN (priv->pipeline), fakesink);
2566 DEBUG ("Could not link real sink, linked fakesink instead");
2568 gst_object_unref (sinkpad);
2572 gst_object_unref (fakesink);
2577 g_mutex_unlock (priv->lock);
2583 empathy_call_window_sink_added_cb (EmpathyCallHandler *handler,
2584 GstPad *sink, FsMediaType media_type, gpointer user_data)
2586 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2587 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2589 gboolean retval = FALSE;
2593 case FS_MEDIA_TYPE_AUDIO:
2594 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_input))
2596 g_warning ("Could not add audio source to pipeline");
2600 pad = gst_element_get_static_pad (priv->audio_input, "src");
2603 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
2604 g_warning ("Could not get source pad from audio source");
2608 if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
2610 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
2611 g_warning ("Could not link audio source to farsight");
2615 if (gst_element_set_state (priv->audio_input, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2617 g_warning ("Could not start audio source");
2618 gst_element_set_state (priv->audio_input, GST_STATE_NULL);
2619 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
2625 case FS_MEDIA_TYPE_VIDEO:
2626 if (priv->video_tee != NULL)
2628 pad = gst_element_get_request_pad (priv->video_tee, "src%d");
2629 if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
2631 g_warning ("Could not link video source input pipeline");
2634 gst_object_unref (pad);
2640 g_assert_not_reached ();
2647 empathy_call_window_remove_video_input (EmpathyCallWindow *self)
2649 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2650 GstElement *preview;
2652 disable_camera (self);
2654 DEBUG ("remove video input");
2655 preview = priv->video_preview_sink;
2657 gst_element_set_state (priv->video_input, GST_STATE_NULL);
2658 gst_element_set_state (priv->video_tee, GST_STATE_NULL);
2659 gst_element_set_state (preview, GST_STATE_NULL);
2661 gst_bin_remove_many (GST_BIN (priv->pipeline), priv->video_input,
2664 g_object_unref (priv->video_input);
2665 priv->video_input = NULL;
2666 g_object_unref (priv->video_tee);
2667 priv->video_tee = NULL;
2668 clutter_actor_destroy (priv->video_preview);
2669 priv->video_preview = NULL;
2671 gtk_widget_set_sensitive (priv->camera_button, FALSE);
2675 start_call (EmpathyCallWindow *self)
2677 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2679 priv->call_started = TRUE;
2680 empathy_call_handler_start_call (priv->handler,
2681 gtk_get_current_event_time ());
2683 if (empathy_call_handler_has_initial_video (priv->handler))
2685 TpyCallChannel *call;
2688 g_object_get (priv->handler, "call-channel", &call, NULL);
2689 s = tpy_call_channel_get_video_state (call);
2691 if (s == TPY_SENDING_STATE_PENDING_SEND ||
2692 s == TPY_SENDING_STATE_SENDING)
2694 /* Enable 'send video' buttons and display the preview */
2695 gtk_toggle_tool_button_set_active (
2696 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), TRUE);
2700 gtk_toggle_tool_button_set_active (
2701 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), FALSE);
2703 if (priv->video_preview == NULL)
2705 create_video_preview (self);
2706 add_video_preview_to_pipeline (self);
2710 g_object_unref (call);
2715 empathy_call_window_bus_message (GstBus *bus, GstMessage *message,
2718 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2719 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2722 empathy_call_handler_bus_message (priv->handler, bus, message);
2724 switch (GST_MESSAGE_TYPE (message))
2726 case GST_MESSAGE_STATE_CHANGED:
2727 if (GST_MESSAGE_SRC (message) == GST_OBJECT (priv->video_input))
2729 gst_message_parse_state_changed (message, NULL, &newstate, NULL);
2731 if (GST_MESSAGE_SRC (message) == GST_OBJECT (priv->pipeline) &&
2732 !priv->call_started)
2734 gst_message_parse_state_changed (message, NULL, &newstate, NULL);
2735 if (newstate == GST_STATE_PAUSED)
2737 gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
2738 priv->pipeline_playing = TRUE;
2740 if (priv->start_call_when_playing)
2745 case GST_MESSAGE_ERROR:
2747 GError *error = NULL;
2748 GstElement *gst_error;
2751 gst_message_parse_error (message, &error, &debug);
2752 gst_error = GST_ELEMENT (GST_MESSAGE_SRC (message));
2754 g_message ("Element error: %s -- %s\n", error->message, debug);
2756 if (g_str_has_prefix (gst_element_get_name (gst_error),
2757 VIDEO_INPUT_ERROR_PREFIX))
2759 /* Remove the video input and continue */
2760 if (priv->video_input != NULL)
2761 empathy_call_window_remove_video_input (self);
2762 gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
2766 empathy_call_window_disconnected (self, TRUE);
2768 g_error_free (error);
2771 case GST_MESSAGE_UNKNOWN:
2772 case GST_MESSAGE_EOS:
2773 case GST_MESSAGE_WARNING:
2774 case GST_MESSAGE_INFO:
2775 case GST_MESSAGE_TAG:
2776 case GST_MESSAGE_BUFFERING:
2777 case GST_MESSAGE_STATE_DIRTY:
2778 case GST_MESSAGE_STEP_DONE:
2779 case GST_MESSAGE_CLOCK_PROVIDE:
2780 case GST_MESSAGE_CLOCK_LOST:
2781 case GST_MESSAGE_NEW_CLOCK:
2782 case GST_MESSAGE_STRUCTURE_CHANGE:
2783 case GST_MESSAGE_STREAM_STATUS:
2784 case GST_MESSAGE_APPLICATION:
2785 case GST_MESSAGE_ELEMENT:
2786 case GST_MESSAGE_SEGMENT_START:
2787 case GST_MESSAGE_SEGMENT_DONE:
2788 case GST_MESSAGE_DURATION:
2789 case GST_MESSAGE_ANY:
2798 empathy_call_window_members_changed_cb (TpyCallChannel *call,
2799 GHashTable *members,
2800 EmpathyCallWindow *self)
2802 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2803 GHashTableIter iter;
2804 gpointer key, value;
2805 gboolean held = FALSE;
2807 g_hash_table_iter_init (&iter, members);
2808 while (g_hash_table_iter_next (&iter, &key, &value))
2810 if (GPOINTER_TO_INT (value) & TPY_CALL_MEMBER_FLAG_HELD)
2812 /* This assumes this is a 1-1 call, otherwise one participant
2813 * putting the call on hold wouldn't mean the call is on hold
2821 priv->call_state = HELD;
2822 else if (priv->call_state == HELD)
2823 priv->call_state = CONNECTED;
2827 call_handler_notify_call_cb (EmpathyCallHandler *handler,
2829 EmpathyCallWindow *self)
2831 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2832 TpyCallChannel *call;
2834 g_object_get (priv->handler, "call-channel", &call, NULL);
2839 tp_g_signal_connect_object (call, "audio-stream-error",
2840 G_CALLBACK (empathy_call_window_audio_stream_error), self, 0);
2841 tp_g_signal_connect_object (call, "video-stream-error",
2842 G_CALLBACK (empathy_call_window_video_stream_error), self, 0);
2845 tp_g_signal_connect_object (call, "members-changed",
2846 G_CALLBACK (empathy_call_window_members_changed_cb), self, 0);
2848 g_object_unref (call);
2852 empathy_call_window_realized_cb (GtkWidget *widget, EmpathyCallWindow *window)
2854 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2855 TpyCallChannel *call;
2858 /* Make the hangup button twice as wide */
2859 width = gtk_widget_get_allocated_width (priv->hangup_button);
2860 gtk_widget_set_size_request (priv->hangup_button, width * 2, -1);
2862 g_signal_connect (priv->handler, "state-changed",
2863 G_CALLBACK (empathy_call_window_state_changed_cb), window);
2864 g_signal_connect (priv->handler, "conference-added",
2865 G_CALLBACK (empathy_call_window_conference_added_cb), window);
2866 g_signal_connect (priv->handler, "conference-removed",
2867 G_CALLBACK (empathy_call_window_conference_removed_cb), window);
2868 g_signal_connect (priv->handler, "closed",
2869 G_CALLBACK (empathy_call_window_channel_closed_cb), window);
2870 g_signal_connect (priv->handler, "src-pad-added",
2871 G_CALLBACK (empathy_call_window_src_added_cb), window);
2872 g_signal_connect (priv->handler, "sink-pad-added",
2873 G_CALLBACK (empathy_call_window_sink_added_cb), window);
2874 g_signal_connect (priv->handler, "sink-pad-removed",
2875 G_CALLBACK (empathy_call_window_sink_removed_cb), window);
2877 g_object_get (priv->handler, "call-channel", &call, NULL);
2880 call_handler_notify_call_cb (priv->handler, NULL, window);
2881 g_object_unref (call);
2885 /* call-channel doesn't exist yet, we'll connect signals once it has been
2887 g_signal_connect (priv->handler, "notify::call-channel",
2888 G_CALLBACK (call_handler_notify_call_cb), window);
2891 gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
2895 empathy_call_window_delete_cb (GtkWidget *widget, GdkEvent*event,
2896 EmpathyCallWindow *window)
2898 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2900 if (priv->pipeline != NULL)
2902 if (priv->bus_message_source_id != 0)
2904 g_source_remove (priv->bus_message_source_id);
2905 priv->bus_message_source_id = 0;
2908 gst_element_set_state (priv->pipeline, GST_STATE_NULL);
2911 if (priv->call_state == CONNECTING)
2912 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
2918 show_controls (EmpathyCallWindow *window, gboolean set_fullscreen)
2921 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2923 menu = gtk_ui_manager_get_widget (priv->ui_manager,
2928 gtk_widget_hide (priv->dtmf_panel);
2929 gtk_widget_hide (menu);
2930 gtk_widget_hide (priv->toolbar);
2934 if (priv->dialpad_was_visible_before_fs)
2935 gtk_widget_show (priv->dtmf_panel);
2937 gtk_widget_show (menu);
2938 gtk_widget_show (priv->toolbar);
2940 gtk_window_resize (GTK_WINDOW (window), priv->original_width_before_fs,
2941 priv->original_height_before_fs);
2946 show_borders (EmpathyCallWindow *window, gboolean set_fullscreen)
2948 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2950 gtk_container_set_border_width (GTK_CONTAINER (priv->content_hbox),
2951 set_fullscreen ? 0 : CONTENT_HBOX_BORDER_WIDTH);
2952 gtk_box_set_spacing (GTK_BOX (priv->content_hbox),
2953 set_fullscreen ? 0 : CONTENT_HBOX_SPACING);
2955 if (priv->video_output != NULL)
2958 gtk_box_set_child_packing (GTK_BOX (priv->content_hbox),
2959 priv->video_output, TRUE, TRUE,
2960 set_fullscreen ? 0 : CONTENT_HBOX_CHILDREN_PACKING_PADDING,
2967 empathy_call_window_state_event_cb (GtkWidget *widget,
2968 GdkEventWindowState *event, EmpathyCallWindow *window)
2970 if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
2972 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2973 gboolean set_fullscreen = event->new_window_state &
2974 GDK_WINDOW_STATE_FULLSCREEN;
2978 gboolean dialpad_was_visible;
2979 GtkAllocation allocation;
2980 gint original_width, original_height;
2982 gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
2983 original_width = allocation.width;
2984 original_height = allocation.height;
2986 g_object_get (priv->dtmf_panel,
2987 "visible", &dialpad_was_visible,
2990 priv->dialpad_was_visible_before_fs = dialpad_was_visible;
2991 priv->original_width_before_fs = original_width;
2992 priv->original_height_before_fs = original_height;
2994 if (priv->video_output_motion_handler_id == 0 &&
2995 priv->video_output != NULL)
2997 priv->video_output_motion_handler_id = g_signal_connect (
2998 G_OBJECT (priv->video_container), "motion-notify-event",
2999 G_CALLBACK (empathy_call_window_video_output_motion_notify),
3005 disconnect_video_output_motion_handler (window);
3008 empathy_call_window_fullscreen_set_fullscreen (priv->fullscreen,
3010 show_controls (window, set_fullscreen);
3011 show_borders (window, set_fullscreen);
3012 gtk_action_set_stock_id (priv->menu_fullscreen,
3013 (set_fullscreen ? "gtk-leave-fullscreen" : "gtk-fullscreen"));
3014 priv->is_fullscreen = set_fullscreen;
3021 empathy_call_window_show_dialpad (EmpathyCallWindow *window,
3024 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3025 int w, h, dialpad_width;
3026 GtkAllocation allocation;
3028 gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
3029 w = allocation.width;
3030 h = allocation.height;
3032 gtk_widget_get_preferred_width (priv->dtmf_panel, &dialpad_width, NULL);
3036 gtk_widget_show (priv->dtmf_panel);
3042 gtk_widget_hide (priv->dtmf_panel);
3046 gtk_window_resize (GTK_WINDOW (window), w, h);
3050 empathy_call_window_set_send_video (EmpathyCallWindow *window,
3053 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3054 TpyCallChannel *call;
3056 priv->sending_video = (state == CAMERA_STATE_ON);
3058 if (state == CAMERA_STATE_ON)
3060 /* When we start sending video, we want to show the video preview by
3062 display_video_preview (window, TRUE);
3066 display_video_preview (window, FALSE);
3069 if (priv->call_state != CONNECTED)
3072 g_object_get (priv->handler, "call-channel", &call, NULL);
3073 DEBUG ("%s sending video", priv->sending_video ? "start": "stop");
3074 tpy_call_channel_send_video (call, priv->sending_video);
3075 g_object_unref (call);
3079 empathy_call_window_mic_toggled_cb (GtkToggleToolButton *toggle,
3080 EmpathyCallWindow *self)
3082 EmpathyCallWindowPriv *priv = GET_PRIV (self);
3085 active = (gtk_toggle_tool_button_get_active (toggle));
3087 /* We don't want the settings callback to react to this change to avoid
3089 g_signal_handlers_block_by_func (priv->settings,
3090 empathy_call_window_prefs_volume_changed_cb, self);
3094 g_settings_set_double (priv->settings, EMPATHY_PREFS_CALL_SOUND_VOLUME,
3095 priv->volume * 100);
3099 /* TODO, Instead of setting the input volume to 0 we should probably
3100 * stop sending but this would cause the audio call to drop if both
3101 * sides mute at the same time on certain CMs AFAIK. Need to revisit this
3102 * in the future. GNOME #574574
3104 g_settings_set_double (priv->settings, EMPATHY_PREFS_CALL_SOUND_VOLUME,
3108 g_signal_handlers_unblock_by_func (priv->settings,
3109 empathy_call_window_prefs_volume_changed_cb, self);
3113 empathy_call_window_hangup_cb (gpointer object,
3114 EmpathyCallWindow *self)
3116 empathy_call_handler_stop_call (self->priv->handler);
3118 empathy_call_window_disconnected (self, TRUE);
3122 empathy_call_window_restart_call (EmpathyCallWindow *window)
3124 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3126 /* Remove error info bars */
3127 gtk_container_forall (GTK_CONTAINER (priv->errors_vbox),
3128 (GtkCallback) gtk_widget_destroy, NULL);
3130 create_video_output_widget (window);
3132 /* While the call was disconnected, the input volume might have changed.
3133 * However, since the audio_input source was destroyed, its volume has not
3134 * been updated during that time. That's why we manually update it here */
3135 empathy_call_window_mic_volume_changed (window);
3137 priv->outgoing = TRUE;
3138 empathy_call_window_set_state_connecting (window);
3140 if (priv->pipeline_playing)
3141 start_call (window);
3143 /* call will be started when the pipeline is ready */
3144 priv->start_call_when_playing = TRUE;
3146 empathy_call_window_setup_avatars (window, priv->handler);
3148 empathy_call_window_show_hangup_button (window, TRUE);
3152 empathy_call_window_dialpad_cb (GtkToggleToolButton *button,
3153 EmpathyCallWindow *window)
3157 active = gtk_toggle_tool_button_get_active (button);
3159 empathy_call_window_show_dialpad (window, active);
3163 empathy_call_window_fullscreen_cb (gpointer object,
3164 EmpathyCallWindow *window)
3166 empathy_call_window_fullscreen_toggle (window);
3170 empathy_call_window_fullscreen_toggle (EmpathyCallWindow *window)
3172 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3174 if (priv->is_fullscreen)
3175 gtk_window_unfullscreen (GTK_WINDOW (window));
3177 gtk_window_fullscreen (GTK_WINDOW (window));
3181 empathy_call_window_video_button_press_cb (GtkWidget *video_preview,
3182 GdkEventButton *event, EmpathyCallWindow *window)
3184 if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
3186 empathy_call_window_video_menu_popup (window, event->button);
3194 empathy_call_window_key_press_cb (GtkWidget *video_output,
3195 GdkEventKey *event, EmpathyCallWindow *window)
3197 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3199 if (priv->is_fullscreen && event->keyval == GDK_KEY_Escape)
3201 /* Since we are in fullscreen mode, toggling will bring us back to
3203 empathy_call_window_fullscreen_toggle (window);
3211 empathy_call_window_video_output_motion_notify (GtkWidget *widget,
3212 GdkEventMotion *event, EmpathyCallWindow *window)
3214 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3216 if (priv->is_fullscreen)
3218 empathy_call_window_fullscreen_show_popup (priv->fullscreen);
3220 /* Show the bottom toolbar */
3221 empathy_call_window_motion_notify_cb (NULL, NULL, window);
3228 empathy_call_window_video_menu_popup (EmpathyCallWindow *window,
3232 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3234 menu = gtk_ui_manager_get_widget (priv->ui_manager,
3236 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
3237 button, gtk_get_current_event_time ());
3238 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
3242 empathy_call_window_status_message (EmpathyCallWindow *self,
3245 gtk_label_set_label (GTK_LABEL (self->priv->status_label), message);
3249 empathy_call_window_volume_changed_cb (GtkScaleButton *button,
3250 gdouble value, EmpathyCallWindow *window)
3252 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3254 if (priv->audio_output == NULL)
3257 empathy_audio_sink_set_volume (EMPATHY_GST_AUDIO_SINK (priv->audio_output),
3262 empathy_call_window_get_ui_manager (EmpathyCallWindow *window)
3264 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3266 return priv->ui_manager;
3269 EmpathyGstAudioSrc *
3270 empathy_call_window_get_audio_src (EmpathyCallWindow *window)
3272 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3274 return (EmpathyGstAudioSrc *) priv->audio_input;