2 * empathy-call-window.c - Source for EmpathyCallWindow
3 * Copyright (C) 2008-2011 Collabora Ltd.
4 * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 #include <gdk/gdkkeysyms.h>
30 #include <glib/gi18n.h>
32 #include <clutter/clutter.h>
33 #include <clutter-gtk/clutter-gtk.h>
34 #include <clutter-gst/clutter-gst.h>
36 #include <telepathy-glib/util.h>
37 #include <telepathy-farstream/telepathy-farstream.h>
38 #include <telepathy-glib/util.h>
40 #include <gst/farsight/fs-element-added-notifier.h>
41 #include <gst/farsight/fs-utils.h>
43 #include <libempathy/empathy-camera-monitor.h>
44 #include <libempathy/empathy-tp-contact-factory.h>
45 #include <libempathy/empathy-utils.h>
46 #include <libempathy-gtk/empathy-avatar-image.h>
47 #include <libempathy-gtk/empathy-ui-utils.h>
48 #include <libempathy-gtk/empathy-sound-manager.h>
49 #include <libempathy-gtk/empathy-geometry.h>
50 #include <libempathy-gtk/empathy-images.h>
52 #define DEBUG_FLAG EMPATHY_DEBUG_VOIP
53 #include <libempathy/empathy-debug.h>
55 #include "empathy-call-window.h"
56 #include "empathy-call-window-fullscreen.h"
57 #include "empathy-call-factory.h"
58 #include "empathy-video-widget.h"
59 #include "empathy-audio-src.h"
60 #include "empathy-audio-sink.h"
61 #include "empathy-video-src.h"
62 #include "ev-sidebar.h"
64 #define CONTENT_HBOX_BORDER_WIDTH 6
65 #define CONTENT_HBOX_SPACING 3
66 #define CONTENT_HBOX_CHILDREN_PACKING_PADDING 3
68 #define SELF_VIDEO_SECTION_WIDTH 120
69 #define SELF_VIDEO_SECTION_HEIGTH 90
71 /* The avatar's default width and height are set to the same value because we
72 want a square icon. */
73 #define REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH EMPATHY_VIDEO_WIDGET_DEFAULT_HEIGHT
74 #define REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT \
75 EMPATHY_VIDEO_WIDGET_DEFAULT_HEIGHT
77 /* If an video input error occurs, the error message will start with "v4l" */
78 #define VIDEO_INPUT_ERROR_PREFIX "v4l"
80 /* The time interval in milliseconds between 2 outgoing rings */
81 #define MS_BETWEEN_RING 500
83 G_DEFINE_TYPE(EmpathyCallWindow, empathy_call_window, GTK_TYPE_WINDOW)
86 PROP_CALL_HANDLER = 1,
102 struct _EmpathyCallWindowPriv
104 gboolean dispose_has_run;
105 EmpathyCallHandler *handler;
107 EmpathyContact *contact;
109 EmpathyCameraMonitor *camera_monitor;
114 GtkUIManager *ui_manager;
115 GtkWidget *errors_vbox;
116 /* widget displays the video received from the remote user. This widget is
117 * alive only during call. */
118 ClutterActor *video_output;
119 ClutterActor *video_preview;
120 ClutterActor *preview_hidden_button;
121 GtkWidget *video_container;
122 GtkWidget *remote_user_avatar_widget;
124 GtkWidget *volume_item;
125 GtkWidget *status_label;
126 GtkWidget *redial_button;
127 GtkWidget *mic_button;
128 GtkWidget *camera_button;
129 GtkWidget *dialpad_button;
131 GtkWidget *bottom_toolbar;
134 GtkAction *menu_sidebar;
135 GtkAction *menu_fullscreen;
137 /* The box that contains self and remote avatar and video
138 input/output. When we redial, we destroy and re-create the box */
139 ClutterActor *video_box;
140 ClutterLayoutManager *video_layout;
142 /* We keep a reference on the hbox which contains the main content so we can
143 easilly repack everything when toggling fullscreen */
144 GtkWidget *content_hbox;
146 gulong video_output_motion_handler_id;
147 guint bus_message_source_id;
150 GtkWidget *volume_scale;
151 GtkWidget *volume_progress_bar;
152 GtkAdjustment *audio_input_adj;
154 GtkWidget *dtmf_panel;
157 GtkWidget *details_vbox;
158 GtkWidget *vcodec_encoding_label;
159 GtkWidget *acodec_encoding_label;
160 GtkWidget *vcodec_decoding_label;
161 GtkWidget *acodec_decoding_label;
163 GtkWidget *audio_remote_candidate_label;
164 GtkWidget *audio_local_candidate_label;
165 GtkWidget *video_remote_candidate_label;
166 GtkWidget *video_local_candidate_label;
167 GtkWidget *video_remote_candidate_info_img;
168 GtkWidget *video_local_candidate_info_img;
169 GtkWidget *audio_remote_candidate_info_img;
170 GtkWidget *audio_local_candidate_info_img;
172 GstElement *video_input;
173 GstElement *video_preview_sink;
174 GstElement *video_output_sink;
175 GstElement *audio_input;
176 GstElement *audio_output;
177 GstElement *pipeline;
178 GstElement *video_tee;
187 GtkWidget *video_contrast;
188 GtkWidget *video_brightness;
189 GtkWidget *video_gamma;
192 gboolean call_started;
193 gboolean sending_video;
194 CameraState camera_state;
196 EmpathyCallWindowFullscreen *fullscreen;
197 gboolean is_fullscreen;
202 /* Those fields represent the state of the window before it actually was in
204 gboolean sidebar_was_visible_before_fs;
205 gint original_width_before_fs;
206 gint original_height_before_fs;
208 gint x, y, w, h, sidebar_width;
211 /* TRUE if the call should be started when the pipeline is playing */
212 gboolean start_call_when_playing;
213 /* TRUE if we requested to set the pipeline in the playing state */
214 gboolean pipeline_playing;
216 EmpathySoundManager *sound_mgr;
219 #define GET_PRIV(o) (EMPATHY_CALL_WINDOW (o)->priv)
221 static void empathy_call_window_realized_cb (GtkWidget *widget,
222 EmpathyCallWindow *window);
224 static gboolean empathy_call_window_delete_cb (GtkWidget *widget,
225 GdkEvent *event, EmpathyCallWindow *window);
227 static gboolean empathy_call_window_state_event_cb (GtkWidget *widget,
228 GdkEventWindowState *event, EmpathyCallWindow *window);
230 static void empathy_call_window_set_send_video (EmpathyCallWindow *window,
233 static void empathy_call_window_mic_toggled_cb (
234 GtkToggleToolButton *toggle, EmpathyCallWindow *window);
236 static void empathy_call_window_sidebar_cb (GtkToggleAction *menu,
237 EmpathyCallWindow *self);
239 static void empathy_call_window_sidebar_hidden_cb (EvSidebar *sidebar,
240 EmpathyCallWindow *window);
242 static void empathy_call_window_sidebar_shown_cb (EvSidebar *sidebar,
243 EmpathyCallWindow *window);
245 static void empathy_call_window_sidebar_changed_cb (EvSidebar *sidebar,
247 EmpathyCallWindow *window);
249 static void empathy_call_window_hangup_cb (gpointer object,
250 EmpathyCallWindow *window);
252 static void empathy_call_window_fullscreen_cb (gpointer object,
253 EmpathyCallWindow *window);
255 static void empathy_call_window_fullscreen_toggle (EmpathyCallWindow *window);
257 static gboolean empathy_call_window_video_button_press_cb (
258 GtkWidget *video_output, GdkEventButton *event, EmpathyCallWindow *window);
260 static gboolean empathy_call_window_key_press_cb (GtkWidget *video_output,
261 GdkEventKey *event, EmpathyCallWindow *window);
263 static gboolean empathy_call_window_video_output_motion_notify (
264 GtkWidget *widget, GdkEventMotion *event, EmpathyCallWindow *window);
266 static void empathy_call_window_video_menu_popup (EmpathyCallWindow *window,
269 static void empathy_call_window_redial_cb (gpointer object,
270 EmpathyCallWindow *window);
272 static void empathy_call_window_dialpad_cb (GtkToggleToolButton *button,
273 EmpathyCallWindow *window);
275 static void empathy_call_window_restart_call (EmpathyCallWindow *window);
277 static void empathy_call_window_status_message (EmpathyCallWindow *window,
280 static gboolean empathy_call_window_bus_message (GstBus *bus,
281 GstMessage *message, gpointer user_data);
284 empathy_call_window_volume_changed_cb (GtkScaleButton *button,
285 gdouble value, EmpathyCallWindow *window);
288 empathy_call_window_setup_toolbars (EmpathyCallWindow *self)
290 EmpathyCallWindowPriv *priv = GET_PRIV (self);
291 GtkWidget *volume_button;
292 GtkToolItem *tool_item;
294 /* Set the volume button */
295 volume_button = gtk_volume_button_new ();
296 /* FIXME listen to the audiosinks signals and update the button according to
297 * that, for now starting out at 1.0 and assuming only the app changes the
299 gtk_scale_button_set_value (GTK_SCALE_BUTTON (volume_button), 1.0);
300 g_signal_connect (G_OBJECT (volume_button), "value-changed",
301 G_CALLBACK (empathy_call_window_volume_changed_cb), self);
303 gtk_container_add (GTK_CONTAINER (priv->volume_item),
305 gtk_widget_show (GTK_WIDGET (volume_button));
307 /* Add an empty expanded GtkToolItem so the label is at the end */
308 tool_item = gtk_tool_item_new ();
309 gtk_tool_item_set_expand (tool_item, TRUE);
310 gtk_widget_show (GTK_WIDGET (tool_item));
311 gtk_toolbar_insert (GTK_TOOLBAR (priv->bottom_toolbar), tool_item, -1);
313 /* Set the status label */
314 tool_item = gtk_tool_item_new ();
315 priv->status_label = gtk_label_new (NULL);
316 gtk_container_add (GTK_CONTAINER (tool_item),
318 gtk_widget_show_all (GTK_WIDGET (tool_item));
319 gtk_toolbar_insert (GTK_TOOLBAR (priv->bottom_toolbar), tool_item, -1);
323 dtmf_button_pressed_cb (GtkButton *button, EmpathyCallWindow *window)
325 EmpathyCallWindowPriv *priv = GET_PRIV (window);
326 TpyCallChannel *call;
330 g_object_get (priv->handler, "call-channel", &call, NULL);
332 button_quark = g_quark_from_static_string (EMPATHY_DTMF_BUTTON_ID);
333 event = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (button),
336 tpy_call_channel_dtmf_start_tone (call, event);
338 g_object_unref (call);
342 dtmf_button_released_cb (GtkButton *button, EmpathyCallWindow *window)
344 EmpathyCallWindowPriv *priv = GET_PRIV (window);
345 TpyCallChannel *call;
347 g_object_get (priv->handler, "call-channel", &call, NULL);
349 tpy_call_channel_dtmf_stop_tone (call);
351 g_object_unref (call);
355 empathy_call_window_create_video_input_add_slider (EmpathyCallWindow *self,
356 gchar *label_text, GtkWidget *bin)
358 GtkWidget *vbox = gtk_vbox_new (FALSE, 2);
359 GtkWidget *scale = gtk_vscale_new_with_range (0, 100, 10);
360 GtkWidget *label = gtk_label_new (label_text);
362 gtk_widget_set_sensitive (scale, FALSE);
364 gtk_container_add (GTK_CONTAINER (bin), vbox);
366 gtk_range_set_inverted (GTK_RANGE (scale), TRUE);
367 gtk_box_pack_start (GTK_BOX (vbox), scale, TRUE, TRUE, 0);
368 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
374 empathy_call_window_video_contrast_changed_cb (GtkAdjustment *adj,
375 EmpathyCallWindow *self)
378 EmpathyCallWindowPriv *priv = GET_PRIV (self);
380 empathy_video_src_set_channel (priv->video_input,
381 EMPATHY_GST_VIDEO_SRC_CHANNEL_CONTRAST, gtk_adjustment_get_value (adj));
385 empathy_call_window_video_brightness_changed_cb (GtkAdjustment *adj,
386 EmpathyCallWindow *self)
389 EmpathyCallWindowPriv *priv = GET_PRIV (self);
391 empathy_video_src_set_channel (priv->video_input,
392 EMPATHY_GST_VIDEO_SRC_CHANNEL_BRIGHTNESS, gtk_adjustment_get_value (adj));
396 empathy_call_window_video_gamma_changed_cb (GtkAdjustment *adj,
397 EmpathyCallWindow *self)
400 EmpathyCallWindowPriv *priv = GET_PRIV (self);
402 empathy_video_src_set_channel (priv->video_input,
403 EMPATHY_GST_VIDEO_SRC_CHANNEL_GAMMA, gtk_adjustment_get_value (adj));
408 empathy_call_window_create_video_input (EmpathyCallWindow *self)
410 EmpathyCallWindowPriv *priv = GET_PRIV (self);
413 hbox = gtk_hbox_new (TRUE, 3);
415 priv->video_contrast = empathy_call_window_create_video_input_add_slider (
416 self, _("Contrast"), hbox);
418 priv->video_brightness = empathy_call_window_create_video_input_add_slider (
419 self, _("Brightness"), hbox);
421 priv->video_gamma = empathy_call_window_create_video_input_add_slider (
422 self, _("Gamma"), hbox);
428 empathy_call_window_setup_video_input (EmpathyCallWindow *self)
430 EmpathyCallWindowPriv *priv = GET_PRIV (self);
434 supported = empathy_video_src_get_supported_channels (priv->video_input);
436 if (supported & EMPATHY_GST_VIDEO_SRC_SUPPORTS_CONTRAST)
438 adj = gtk_range_get_adjustment (GTK_RANGE (priv->video_contrast));
440 gtk_adjustment_set_value (adj,
441 empathy_video_src_get_channel (priv->video_input,
442 EMPATHY_GST_VIDEO_SRC_CHANNEL_CONTRAST));
444 g_signal_connect (G_OBJECT (adj), "value-changed",
445 G_CALLBACK (empathy_call_window_video_contrast_changed_cb), self);
447 gtk_widget_set_sensitive (priv->video_contrast, TRUE);
450 if (supported & EMPATHY_GST_VIDEO_SRC_SUPPORTS_BRIGHTNESS)
452 adj = gtk_range_get_adjustment (GTK_RANGE (priv->video_brightness));
454 gtk_adjustment_set_value (adj,
455 empathy_video_src_get_channel (priv->video_input,
456 EMPATHY_GST_VIDEO_SRC_CHANNEL_BRIGHTNESS));
458 g_signal_connect (G_OBJECT (adj), "value-changed",
459 G_CALLBACK (empathy_call_window_video_brightness_changed_cb), self);
460 gtk_widget_set_sensitive (priv->video_brightness, TRUE);
463 if (supported & EMPATHY_GST_VIDEO_SRC_SUPPORTS_GAMMA)
465 adj = gtk_range_get_adjustment (GTK_RANGE (priv->video_gamma));
467 gtk_adjustment_set_value (adj,
468 empathy_video_src_get_channel (priv->video_input,
469 EMPATHY_GST_VIDEO_SRC_CHANNEL_GAMMA));
471 g_signal_connect (G_OBJECT (adj), "value-changed",
472 G_CALLBACK (empathy_call_window_video_gamma_changed_cb), self);
473 gtk_widget_set_sensitive (priv->video_gamma, TRUE);
478 empathy_call_window_mic_volume_changed_cb (GtkAdjustment *adj,
479 EmpathyCallWindow *self)
481 EmpathyCallWindowPriv *priv = GET_PRIV (self);
484 volume = gtk_adjustment_get_value (adj)/100.0;
486 /* Don't store the volume because of muting */
487 if (volume > 0 || gtk_toggle_tool_button_get_active (
488 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
489 priv->volume = volume;
491 /* Ensure that the toggle button is active if the volume is > 0 and inactive
492 * if it's smaller than 0 */
493 if ((volume > 0) != gtk_toggle_tool_button_get_active (
494 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
495 gtk_toggle_tool_button_set_active (
496 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button), volume > 0);
498 empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
503 empathy_call_window_audio_input_level_changed_cb (EmpathyGstAudioSrc *src,
504 gdouble level, EmpathyCallWindow *window)
507 EmpathyCallWindowPriv *priv = GET_PRIV (window);
509 value = CLAMP (pow (10, level / 20), 0.0, 1.0);
510 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->volume_progress_bar),
515 empathy_call_window_create_audio_input (EmpathyCallWindow *self)
517 EmpathyCallWindowPriv *priv = GET_PRIV (self);
518 GtkWidget *hbox, *vbox, *label;
520 hbox = gtk_hbox_new (TRUE, 3);
522 vbox = gtk_vbox_new (FALSE, 3);
523 gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 3);
525 priv->volume_scale = gtk_vscale_new_with_range (0, 150, 100);
526 gtk_range_set_inverted (GTK_RANGE (priv->volume_scale), TRUE);
527 label = gtk_label_new (_("Volume"));
529 priv->audio_input_adj = gtk_range_get_adjustment (
530 GTK_RANGE (priv->volume_scale));
531 priv->volume = empathy_audio_src_get_volume (EMPATHY_GST_AUDIO_SRC
532 (priv->audio_input));
533 gtk_adjustment_set_value (priv->audio_input_adj, priv->volume * 100);
535 g_signal_connect (G_OBJECT (priv->audio_input_adj), "value-changed",
536 G_CALLBACK (empathy_call_window_mic_volume_changed_cb), self);
538 gtk_box_pack_start (GTK_BOX (vbox), priv->volume_scale, TRUE, TRUE, 3);
539 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 3);
541 priv->volume_progress_bar = gtk_progress_bar_new ();
543 gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->volume_progress_bar),
544 GTK_ORIENTATION_VERTICAL);
546 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->volume_progress_bar),
549 gtk_box_pack_start (GTK_BOX (hbox), priv->volume_progress_bar, FALSE, FALSE,
556 empathy_call_window_show_video_output (EmpathyCallWindow *self,
559 if (self->priv->video_output != NULL)
560 g_object_set (self->priv->video_output, "visible", show, NULL);
562 gtk_widget_set_visible (self->priv->remote_user_avatar_widget, !show);
566 create_video_output_widget (EmpathyCallWindow *self)
568 EmpathyCallWindowPriv *priv = GET_PRIV (self);
570 g_assert (priv->video_output == NULL);
571 g_assert (priv->pipeline != NULL);
573 priv->video_output = clutter_texture_new ();
575 clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (priv->video_output),
578 priv->video_output_sink = clutter_gst_video_sink_new (
579 CLUTTER_TEXTURE (priv->video_output));
581 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_box),
584 gtk_widget_add_events (priv->video_container,
585 GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK);
586 g_signal_connect (G_OBJECT (priv->video_container), "button-press-event",
587 G_CALLBACK (empathy_call_window_video_button_press_cb), self);
591 create_video_input (EmpathyCallWindow *self)
593 EmpathyCallWindowPriv *priv = GET_PRIV (self);
595 g_assert (priv->video_input == NULL);
596 priv->video_input = empathy_video_src_new ();
597 gst_object_ref (priv->video_input);
598 gst_object_sink (priv->video_input);
602 create_audio_input (EmpathyCallWindow *self)
604 EmpathyCallWindowPriv *priv = GET_PRIV (self);
606 g_assert (priv->audio_input == NULL);
607 priv->audio_input = empathy_audio_src_new ();
608 gst_object_ref (priv->audio_input);
609 gst_object_sink (priv->audio_input);
611 tp_g_signal_connect_object (priv->audio_input, "peak-level-changed",
612 G_CALLBACK (empathy_call_window_audio_input_level_changed_cb),
617 add_video_preview_to_pipeline (EmpathyCallWindow *self)
619 EmpathyCallWindowPriv *priv = GET_PRIV (self);
622 g_assert (priv->video_preview != NULL);
623 g_assert (priv->pipeline != NULL);
624 g_assert (priv->video_input != NULL);
625 g_assert (priv->video_tee != NULL);
627 preview = priv->video_preview_sink;
629 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->video_input))
631 g_warning ("Could not add video input to pipeline");
635 if (!gst_bin_add (GST_BIN (priv->pipeline), preview))
637 g_warning ("Could not add video preview to pipeline");
641 if (!gst_element_link (priv->video_input, priv->video_tee))
643 g_warning ("Could not link video input to video tee");
647 if (!gst_element_link (priv->video_tee, preview))
649 g_warning ("Could not link video tee to video preview");
655 empathy_call_window_disable_camera_cb (GtkAction *action,
656 EmpathyCallWindow *self)
658 clutter_actor_destroy (self->priv->preview_hidden_button);
660 gtk_toggle_tool_button_set_active (
661 GTK_TOGGLE_TOOL_BUTTON (self->priv->camera_button), FALSE);
665 empathy_call_window_minimise_camera_cb (GtkAction *action,
666 EmpathyCallWindow *self)
668 clutter_actor_hide (self->priv->video_preview);
669 clutter_actor_show (self->priv->preview_hidden_button);
673 empathy_call_window_maximise_camera_cb (GtkAction *action,
674 EmpathyCallWindow *self)
676 clutter_actor_show (self->priv->video_preview);
677 clutter_actor_hide (self->priv->preview_hidden_button);
681 empathy_call_window_preview_button_clicked_cb (GtkButton *button,
682 EmpathyCallWindow *self)
686 menu = gtk_ui_manager_get_widget (self->priv->ui_manager,
688 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
689 0, gtk_get_current_event_time ());
690 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
694 empathy_call_window_preview_hidden_button_clicked_cb (GtkButton *button,
695 EmpathyCallWindow *self)
699 menu = gtk_ui_manager_get_widget (self->priv->ui_manager,
700 "/preview-hidden-menu");
701 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
702 0, gtk_get_current_event_time ());
703 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
707 create_video_preview (EmpathyCallWindow *self)
709 EmpathyCallWindowPriv *priv = GET_PRIV (self);
710 ClutterLayoutManager *layout, *layout_center;
711 ClutterActor *preview;
716 g_assert (priv->video_preview == NULL);
718 preview = clutter_texture_new ();
719 clutter_actor_set_size (preview,
720 SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGTH);
721 priv->video_preview_sink = clutter_gst_video_sink_new (
722 CLUTTER_TEXTURE (preview));
724 /* Flip the video preview */
725 clutter_actor_set_rotation (preview,
728 SELF_VIDEO_SECTION_WIDTH * 0.5,
732 /* Add a little offset to the video preview */
733 layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_END,
734 CLUTTER_BIN_ALIGNMENT_START);
735 priv->video_preview = clutter_box_new (layout);
736 clutter_actor_set_size (priv->video_preview,
737 SELF_VIDEO_SECTION_WIDTH + 10, SELF_VIDEO_SECTION_HEIGTH + 10);
739 layout_center = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
740 CLUTTER_BIN_ALIGNMENT_CENTER);
741 box = clutter_box_new (layout_center);
742 clutter_actor_set_size (box,
743 SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGTH);
745 clutter_container_add_actor (CLUTTER_CONTAINER (box), preview);
746 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_preview), box);
748 g_object_set (priv->video_preview_sink,
753 /* Translators: this is an "Info" label. It should be as short
755 button = gtk_button_new_with_label (_("i"));
756 b = gtk_clutter_actor_new_with_contents (button);
758 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (layout_center),
760 CLUTTER_BIN_ALIGNMENT_END,
761 CLUTTER_BIN_ALIGNMENT_END);
763 g_signal_connect (button, "clicked",
764 G_CALLBACK (empathy_call_window_preview_button_clicked_cb),
767 /* Translators: this is an "Info" label. It should be as short
769 button = gtk_button_new_with_label (_("i"));
770 priv->preview_hidden_button =
771 gtk_clutter_actor_new_with_contents (button);
773 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
774 priv->preview_hidden_button,
775 CLUTTER_BIN_ALIGNMENT_START,
776 CLUTTER_BIN_ALIGNMENT_END);
778 clutter_actor_hide (priv->preview_hidden_button);
780 g_signal_connect (button, "clicked",
781 G_CALLBACK (empathy_call_window_preview_hidden_button_clicked_cb),
784 clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
786 CLUTTER_BIN_ALIGNMENT_START,
787 CLUTTER_BIN_ALIGNMENT_END);
791 play_camera (EmpathyCallWindow *window,
794 EmpathyCallWindowPriv *priv = GET_PRIV (window);
798 if (priv->video_preview == NULL)
800 create_video_preview (window);
801 add_video_preview_to_pipeline (window);
805 state = GST_STATE_PLAYING;
807 state = GST_STATE_NULL;
809 preview = priv->video_preview_sink;
811 gst_element_set_state (preview, state);
812 gst_element_set_state (priv->video_input, state);
813 gst_element_set_state (priv->video_tee, state);
817 display_video_preview (EmpathyCallWindow *self,
820 EmpathyCallWindowPriv *priv = GET_PRIV (self);
824 /* Display the video preview */
825 DEBUG ("Show video preview");
827 play_camera (self, TRUE);
828 clutter_actor_show (priv->video_preview);
832 /* Hide the video preview */
833 DEBUG ("Hide video preview");
835 if (priv->video_preview != NULL)
837 clutter_actor_hide (priv->video_preview);
838 play_camera (self, FALSE);
844 empathy_call_window_set_state_connecting (EmpathyCallWindow *window)
846 EmpathyCallWindowPriv *priv = GET_PRIV (window);
848 empathy_call_window_status_message (window, _("Connecting…"));
849 priv->call_state = CONNECTING;
852 empathy_sound_manager_start_playing (priv->sound_mgr, GTK_WIDGET (window),
853 EMPATHY_SOUND_PHONE_OUTGOING, MS_BETWEEN_RING);
857 disable_camera (EmpathyCallWindow *self)
859 EmpathyCallWindowPriv *priv = GET_PRIV (self);
861 if (priv->camera_state == CAMERA_STATE_OFF)
864 DEBUG ("Disable camera");
866 display_video_preview (self, FALSE);
868 if (priv->camera_state == CAMERA_STATE_ON)
869 empathy_call_window_set_send_video (self, CAMERA_STATE_OFF);
871 priv->camera_state = CAMERA_STATE_OFF;
875 enable_camera (EmpathyCallWindow *self)
877 EmpathyCallWindowPriv *priv = GET_PRIV (self);
879 if (priv->camera_state == CAMERA_STATE_ON)
882 if (priv->video_input == NULL)
884 DEBUG ("Can't enable camera, no input");
888 DEBUG ("Enable camera");
890 empathy_call_window_set_send_video (self, CAMERA_STATE_ON);
892 priv->camera_state = CAMERA_STATE_ON;
896 empathy_call_window_camera_toggled_cb (GtkToggleToolButton *toggle,
897 EmpathyCallWindow *self)
899 if (gtk_toggle_tool_button_get_active (toggle))
900 enable_camera (self);
902 disable_camera (self);
906 create_pipeline (EmpathyCallWindow *self)
908 EmpathyCallWindowPriv *priv = GET_PRIV (self);
911 g_assert (priv->pipeline == NULL);
913 priv->pipeline = gst_pipeline_new (NULL);
914 priv->pipeline_playing = FALSE;
916 priv->video_tee = gst_element_factory_make ("tee", NULL);
917 gst_object_ref (priv->video_tee);
918 gst_object_sink (priv->video_tee);
920 gst_bin_add (GST_BIN (priv->pipeline), priv->video_tee);
922 bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
923 priv->bus_message_source_id = gst_bus_add_watch (bus,
924 empathy_call_window_bus_message, self);
926 g_object_unref (bus);
930 empathy_call_window_configure_event_cb (GtkWidget *widget,
932 EmpathyCallWindow *self)
934 GdkWindow *gdk_window;
935 GdkWindowState window_state;
937 gtk_window_get_position (GTK_WINDOW (self), &self->priv->x, &self->priv->y);
938 gtk_window_get_size (GTK_WINDOW (self), &self->priv->w, &self->priv->h);
940 gtk_widget_get_preferred_width (self->priv->sidebar,
941 &self->priv->sidebar_width, NULL);
943 gdk_window = gtk_widget_get_window (widget);
944 window_state = gdk_window_get_state (gdk_window);
945 self->priv->maximized = (window_state & GDK_WINDOW_STATE_MAXIMIZED);
951 empathy_call_window_destroyed_cb (GtkWidget *object,
952 EmpathyCallWindow *self)
954 if (gtk_widget_get_visible (self->priv->sidebar))
956 /* Save the geometry as if the sidebar was hidden. */
957 empathy_geometry_save_values (GTK_WINDOW (self),
958 self->priv->x, self->priv->y,
959 self->priv->w - self->priv->sidebar_width, self->priv->h,
960 self->priv->maximized);
965 empathy_call_window_init (EmpathyCallWindow *self)
967 EmpathyCallWindowPriv *priv;
973 ClutterConstraint *size_constraint;
974 ClutterActor *remote_avatar;
975 GtkStyleContext *context;
979 priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
980 EMPATHY_TYPE_CALL_WINDOW, EmpathyCallWindowPriv);
982 filename = empathy_file_lookup ("empathy-call-window.ui", "src");
983 gui = empathy_builder_get_file (filename,
984 "call_window_vbox", &top_vbox,
985 "errors_vbox", &priv->errors_vbox,
987 "redial", &priv->redial_button,
988 "volume", &priv->volume_item,
989 "microphone", &priv->mic_button,
990 "camera", &priv->camera_button,
991 "dialpad", &priv->dialpad_button,
992 "toolbar", &priv->toolbar,
993 "bottom_toolbar", &priv->bottom_toolbar,
994 "menuredial", &priv->redial,
995 "menusidebar", &priv->menu_sidebar,
996 "ui_manager", &priv->ui_manager,
997 "menufullscreen", &priv->menu_fullscreen,
998 "details_vbox", &priv->details_vbox,
999 "vcodec_encoding_label", &priv->vcodec_encoding_label,
1000 "acodec_encoding_label", &priv->acodec_encoding_label,
1001 "acodec_decoding_label", &priv->acodec_decoding_label,
1002 "vcodec_decoding_label", &priv->vcodec_decoding_label,
1003 "audio_remote_candidate_label", &priv->audio_remote_candidate_label,
1004 "audio_local_candidate_label", &priv->audio_local_candidate_label,
1005 "video_remote_candidate_label", &priv->video_remote_candidate_label,
1006 "video_local_candidate_label", &priv->video_local_candidate_label,
1007 "video_remote_candidate_info_img", &priv->video_remote_candidate_info_img,
1008 "video_local_candidate_info_img", &priv->video_local_candidate_info_img,
1009 "audio_remote_candidate_info_img", &priv->audio_remote_candidate_info_img,
1010 "audio_local_candidate_info_img", &priv->audio_local_candidate_info_img,
1014 empathy_builder_connect (gui, self,
1015 "menuhangup", "activate", empathy_call_window_hangup_cb,
1016 "hangup", "clicked", empathy_call_window_hangup_cb,
1017 "menuredial", "activate", empathy_call_window_redial_cb,
1018 "redial", "clicked", empathy_call_window_redial_cb,
1019 "menusidebar", "toggled", empathy_call_window_sidebar_cb,
1020 "microphone", "toggled", empathy_call_window_mic_toggled_cb,
1021 "camera", "toggled", empathy_call_window_camera_toggled_cb,
1022 "dialpad", "toggled", empathy_call_window_dialpad_cb,
1023 "menufullscreen", "activate", empathy_call_window_fullscreen_cb,
1024 "menupreviewdisable", "activate", empathy_call_window_disable_camera_cb,
1025 "menupreviewminimise", "activate", empathy_call_window_minimise_camera_cb,
1026 "menupreviewmaximise", "activate", empathy_call_window_maximise_camera_cb,
1029 gtk_action_set_sensitive (priv->menu_fullscreen, FALSE);
1031 priv->camera_monitor = empathy_camera_monitor_dup_singleton ();
1033 g_object_bind_property (priv->camera_monitor, "available",
1034 priv->camera_button, "sensitive",
1035 G_BINDING_SYNC_CREATE);
1037 priv->lock = g_mutex_new ();
1039 gtk_container_add (GTK_CONTAINER (self), top_vbox);
1041 priv->content_hbox = gtk_hbox_new (FALSE, CONTENT_HBOX_SPACING);
1042 gtk_container_set_border_width (GTK_CONTAINER (priv->content_hbox),
1043 CONTENT_HBOX_BORDER_WIDTH);
1044 gtk_paned_pack1 (GTK_PANED (priv->pane), priv->content_hbox, TRUE, FALSE);
1046 /* avatar/video box */
1047 priv->video_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
1048 CLUTTER_BIN_ALIGNMENT_CENTER);
1050 priv->video_box = clutter_box_new (priv->video_layout);
1052 priv->video_container = gtk_clutter_embed_new ();
1054 /* Set the background color to that of the rest of the window */
1055 context = gtk_widget_get_style_context (priv->content_hbox);
1056 gtk_style_context_get_background_color (context,
1057 GTK_STATE_FLAG_NORMAL, &rgba);
1058 bg.red = CLAMP (rgba.red * 255.0, 0, 255);
1059 bg.green = CLAMP (rgba.green * 255.0, 0, 255);
1060 bg.blue = CLAMP (rgba.blue * 255.0, 0, 255);
1061 bg.alpha = CLAMP (rgba.alpha * 255.0, 0, 255);
1062 clutter_stage_set_color (
1063 CLUTTER_STAGE (gtk_clutter_embed_get_stage (
1064 GTK_CLUTTER_EMBED (priv->video_container))),
1067 clutter_container_add (
1068 CLUTTER_CONTAINER (gtk_clutter_embed_get_stage (
1069 GTK_CLUTTER_EMBED (priv->video_container))),
1073 size_constraint = clutter_bind_constraint_new (
1074 gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->video_container)),
1075 CLUTTER_BIND_SIZE, 0);
1076 clutter_actor_add_constraint (priv->video_box, size_constraint);
1078 priv->remote_user_avatar_widget = gtk_image_new ();
1079 remote_avatar = gtk_clutter_actor_new_with_contents (
1080 priv->remote_user_avatar_widget);
1082 clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_box),
1085 gtk_box_pack_start (GTK_BOX (priv->content_hbox),
1086 priv->video_container, TRUE, TRUE,
1087 CONTENT_HBOX_CHILDREN_PACKING_PADDING);
1089 create_pipeline (self);
1090 create_video_output_widget (self);
1091 create_audio_input (self);
1092 create_video_input (self);
1094 /* The call will be started as soon the pipeline is playing */
1095 priv->start_call_when_playing = TRUE;
1097 empathy_call_window_setup_toolbars (self);
1099 priv->sidebar = ev_sidebar_new ();
1100 g_signal_connect (G_OBJECT (priv->sidebar),
1101 "hide", G_CALLBACK (empathy_call_window_sidebar_hidden_cb), self);
1102 g_signal_connect (G_OBJECT (priv->sidebar),
1103 "show", G_CALLBACK (empathy_call_window_sidebar_shown_cb), self);
1104 g_signal_connect (G_OBJECT (priv->sidebar), "changed",
1105 G_CALLBACK (empathy_call_window_sidebar_changed_cb), self);
1106 gtk_paned_pack2 (GTK_PANED (priv->pane), priv->sidebar, FALSE, FALSE);
1108 page = empathy_call_window_create_audio_input (self);
1109 ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "audio-input",
1110 _("Audio input"), page);
1112 page = empathy_call_window_create_video_input (self);
1113 ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "video-input",
1114 _("Video input"), page);
1116 priv->dtmf_panel = empathy_create_dtmf_dialpad (G_OBJECT (self),
1117 G_CALLBACK (dtmf_button_pressed_cb),
1118 G_CALLBACK (dtmf_button_released_cb));
1119 ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "dialpad",
1120 _("Dialpad"), priv->dtmf_panel);
1122 gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
1124 /* Put the details vbox in a scroll window as it can require a lot of
1125 * horizontal space. */
1126 scroll = gtk_scrolled_window_new (NULL, NULL);
1127 gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll),
1128 priv->details_vbox);
1130 ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "details", _("Details"),
1133 gtk_widget_show_all (top_vbox);
1135 gtk_widget_hide (priv->sidebar);
1137 priv->fullscreen = empathy_call_window_fullscreen_new (self);
1139 empathy_call_window_fullscreen_set_video_widget (priv->fullscreen,
1140 priv->video_container);
1142 g_signal_connect (G_OBJECT (priv->fullscreen->leave_fullscreen_button),
1143 "clicked", G_CALLBACK (empathy_call_window_fullscreen_cb), self);
1145 g_signal_connect (G_OBJECT (self), "realize",
1146 G_CALLBACK (empathy_call_window_realized_cb), self);
1148 g_signal_connect (G_OBJECT (self), "delete-event",
1149 G_CALLBACK (empathy_call_window_delete_cb), self);
1151 g_signal_connect (G_OBJECT (self), "window-state-event",
1152 G_CALLBACK (empathy_call_window_state_event_cb), self);
1154 g_signal_connect (G_OBJECT (self), "key-press-event",
1155 G_CALLBACK (empathy_call_window_key_press_cb), self);
1157 priv->timer = g_timer_new ();
1159 g_object_ref (priv->ui_manager);
1160 g_object_unref (gui);
1162 priv->sound_mgr = empathy_sound_manager_dup_singleton ();
1164 empathy_geometry_bind (GTK_WINDOW (self), "call-window");
1165 /* These signals are used to track the window position and save it
1166 * when the window is destroyed. We need to do this as we don't want
1167 * the window geometry to be saved with the sidebar taken into account. */
1168 g_signal_connect (self, "destroy",
1169 G_CALLBACK (empathy_call_window_destroyed_cb), self);
1170 g_signal_connect (self, "configure-event",
1171 G_CALLBACK (empathy_call_window_configure_event_cb), self);
1172 g_signal_connect (self, "window-state-event",
1173 G_CALLBACK (empathy_call_window_configure_event_cb), self);
1176 /* Instead of specifying a width and a height, we specify only one size. That's
1177 because we want a square avatar icon. */
1179 init_contact_avatar_with_size (EmpathyContact *contact,
1180 GtkWidget *image_widget,
1183 GdkPixbuf *pixbuf_avatar = NULL;
1185 if (contact != NULL)
1187 pixbuf_avatar = empathy_pixbuf_avatar_from_contact_scaled (contact,
1191 if (pixbuf_avatar == NULL)
1193 pixbuf_avatar = empathy_pixbuf_from_icon_name_sized (
1194 EMPATHY_IMAGE_AVATAR_DEFAULT, size);
1197 gtk_image_set_from_pixbuf (GTK_IMAGE (image_widget), pixbuf_avatar);
1199 if (pixbuf_avatar != NULL)
1200 g_object_unref (pixbuf_avatar);
1204 set_window_title (EmpathyCallWindow *self)
1206 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1209 if (priv->contact != NULL)
1211 /* translators: Call is a noun and %s is the contact name. This string
1212 * is used in the window title */
1213 tmp = g_strdup_printf (_("Call with %s"),
1214 empathy_contact_get_alias (priv->contact));
1215 gtk_window_set_title (GTK_WINDOW (self), tmp);
1220 gtk_window_set_title (GTK_WINDOW (self), _("Call with %d participants"));
1225 contact_name_changed_cb (EmpathyContact *contact,
1226 GParamSpec *pspec, EmpathyCallWindow *self)
1228 set_window_title (self);
1232 contact_avatar_changed_cb (EmpathyContact *contact,
1233 GParamSpec *pspec, GtkWidget *avatar_widget)
1236 GtkAllocation allocation;
1238 gtk_widget_get_allocation (avatar_widget, &allocation);
1239 size = allocation.height;
1243 /* the widget is not allocated yet, set a default size */
1244 size = MIN (REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT,
1245 REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH);
1248 init_contact_avatar_with_size (contact, avatar_widget, size);
1252 empathy_call_window_setup_avatars (EmpathyCallWindow *self,
1253 EmpathyCallHandler *handler)
1255 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1257 g_signal_connect (priv->contact, "notify::name",
1258 G_CALLBACK (contact_name_changed_cb), self);
1259 g_signal_connect (priv->contact, "notify::avatar",
1260 G_CALLBACK (contact_avatar_changed_cb),
1261 priv->remote_user_avatar_widget);
1263 set_window_title (self);
1265 init_contact_avatar_with_size (priv->contact,
1266 priv->remote_user_avatar_widget,
1267 MIN (REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH,
1268 REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT));
1270 /* The remote avatar is shown by default and will be hidden when we receive
1271 video from the remote side. */
1272 clutter_actor_hide (priv->video_output);
1273 gtk_widget_show (priv->remote_user_avatar_widget);
1277 update_send_codec (EmpathyCallWindow *self,
1280 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1287 codec = empathy_call_handler_get_send_audio_codec (priv->handler);
1288 widget = priv->acodec_encoding_label;
1292 codec = empathy_call_handler_get_send_video_codec (priv->handler);
1293 widget = priv->vcodec_encoding_label;
1299 tmp = g_strdup_printf ("%s/%u", codec->encoding_name, codec->clock_rate);
1300 gtk_label_set_text (GTK_LABEL (widget), tmp);
1305 send_audio_codec_notify_cb (GObject *object,
1309 EmpathyCallWindow *self = user_data;
1311 update_send_codec (self, TRUE);
1315 send_video_codec_notify_cb (GObject *object,
1319 EmpathyCallWindow *self = user_data;
1321 update_send_codec (self, FALSE);
1325 update_recv_codec (EmpathyCallWindow *self,
1328 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1331 GString *str = NULL;
1335 codecs = empathy_call_handler_get_recv_audio_codecs (priv->handler);
1336 widget = priv->acodec_decoding_label;
1340 codecs = empathy_call_handler_get_recv_video_codecs (priv->handler);
1341 widget = priv->vcodec_decoding_label;
1347 for (l = codecs; l != NULL; l = g_list_next (l))
1349 FsCodec *codec = l->data;
1352 str = g_string_new (NULL);
1354 g_string_append (str, ", ");
1356 g_string_append_printf (str, "%s/%u", codec->encoding_name,
1360 gtk_label_set_text (GTK_LABEL (widget), str->str);
1361 g_string_free (str, TRUE);
1365 recv_audio_codecs_notify_cb (GObject *object,
1369 EmpathyCallWindow *self = user_data;
1371 update_recv_codec (self, TRUE);
1375 recv_video_codecs_notify_cb (GObject *object,
1379 EmpathyCallWindow *self = user_data;
1381 update_recv_codec (self, FALSE);
1384 static const gchar *
1385 candidate_type_to_str (FsCandidate *candidate)
1387 switch (candidate->type)
1389 case FS_CANDIDATE_TYPE_HOST:
1391 case FS_CANDIDATE_TYPE_SRFLX:
1392 return "server reflexive";
1393 case FS_CANDIDATE_TYPE_PRFLX:
1394 return "peer reflexive";
1395 case FS_CANDIDATE_TYPE_RELAY:
1397 case FS_CANDIDATE_TYPE_MULTICAST:
1404 static const gchar *
1405 candidate_type_to_desc (FsCandidate *candidate)
1407 switch (candidate->type)
1409 case FS_CANDIDATE_TYPE_HOST:
1410 return _("The IP address as seen by the machine");
1411 case FS_CANDIDATE_TYPE_SRFLX:
1412 return _("The IP address as seen by a server on the Internet");
1413 case FS_CANDIDATE_TYPE_PRFLX:
1414 return _("The IP address of the peer as seen by the other side");
1415 case FS_CANDIDATE_TYPE_RELAY:
1416 return _("The IP address of a relay server");
1417 case FS_CANDIDATE_TYPE_MULTICAST:
1418 return _("The IP address of the multicast group");
1425 update_candidat_widget (EmpathyCallWindow *self,
1428 FsCandidate *candidate)
1432 g_assert (candidate != NULL);
1433 str = g_strdup_printf ("%s %u (%s)", candidate->ip,
1434 candidate->port, candidate_type_to_str (candidate));
1436 gtk_label_set_text (GTK_LABEL (label), str);
1437 gtk_widget_set_tooltip_text (img, candidate_type_to_desc (candidate));
1443 candidates_changed_cb (GObject *object,
1445 EmpathyCallWindow *self)
1447 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1448 FsCandidate *candidate = NULL;
1450 if (type == FS_MEDIA_TYPE_VIDEO)
1452 /* Update remote candidate */
1453 candidate = empathy_call_handler_get_video_remote_candidate (
1456 update_candidat_widget (self, priv->video_remote_candidate_label,
1457 priv->video_remote_candidate_info_img, candidate);
1459 /* Update local candidate */
1460 candidate = empathy_call_handler_get_video_local_candidate (
1463 update_candidat_widget (self, priv->video_local_candidate_label,
1464 priv->video_local_candidate_info_img, candidate);
1468 /* Update remote candidate */
1469 candidate = empathy_call_handler_get_audio_remote_candidate (
1472 update_candidat_widget (self, priv->audio_remote_candidate_label,
1473 priv->audio_remote_candidate_info_img, candidate);
1475 /* Update local candidate */
1476 candidate = empathy_call_handler_get_audio_local_candidate (
1479 update_candidat_widget (self, priv->audio_local_candidate_label,
1480 priv->audio_local_candidate_info_img, candidate);
1485 empathy_call_window_constructed (GObject *object)
1487 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
1488 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1489 TpyCallChannel *call;
1491 g_assert (priv->handler != NULL);
1493 g_object_get (priv->handler, "call-channel", &call, NULL);
1494 priv->outgoing = (call == NULL);
1496 g_object_unref (call);
1498 g_object_get (priv->handler, "target-contact", &priv->contact, NULL);
1499 g_assert (priv->contact != NULL);
1501 empathy_call_window_setup_avatars (self, priv->handler);
1502 empathy_call_window_set_state_connecting (self);
1504 if (!empathy_call_handler_has_initial_video (priv->handler))
1506 gtk_toggle_tool_button_set_active (
1507 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), FALSE);
1509 /* If call has InitialVideo, the preview will be started once the call has
1510 * been started (start_call()). */
1512 update_send_codec (self, TRUE);
1513 update_send_codec (self, FALSE);
1514 update_recv_codec (self, TRUE);
1515 update_recv_codec (self, FALSE);
1517 tp_g_signal_connect_object (priv->handler, "notify::send-audio-codec",
1518 G_CALLBACK (send_audio_codec_notify_cb), self, 0);
1519 tp_g_signal_connect_object (priv->handler, "notify::send-video-codec",
1520 G_CALLBACK (send_video_codec_notify_cb), self, 0);
1521 tp_g_signal_connect_object (priv->handler, "notify::recv-audio-codecs",
1522 G_CALLBACK (recv_audio_codecs_notify_cb), self, 0);
1523 tp_g_signal_connect_object (priv->handler, "notify::recv-video-codecs",
1524 G_CALLBACK (recv_video_codecs_notify_cb), self, 0);
1526 tp_g_signal_connect_object (priv->handler, "candidates-changed",
1527 G_CALLBACK (candidates_changed_cb), self, 0);
1530 static void empathy_call_window_dispose (GObject *object);
1531 static void empathy_call_window_finalize (GObject *object);
1534 empathy_call_window_set_property (GObject *object,
1535 guint property_id, const GValue *value, GParamSpec *pspec)
1537 EmpathyCallWindowPriv *priv = GET_PRIV (object);
1539 switch (property_id)
1541 case PROP_CALL_HANDLER:
1542 priv->handler = g_value_dup_object (value);
1545 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1550 empathy_call_window_get_property (GObject *object,
1551 guint property_id, GValue *value, GParamSpec *pspec)
1553 EmpathyCallWindowPriv *priv = GET_PRIV (object);
1555 switch (property_id)
1557 case PROP_CALL_HANDLER:
1558 g_value_set_object (value, priv->handler);
1561 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1566 empathy_call_window_class_init (
1567 EmpathyCallWindowClass *empathy_call_window_class)
1569 GObjectClass *object_class = G_OBJECT_CLASS (empathy_call_window_class);
1570 GParamSpec *param_spec;
1572 g_type_class_add_private (empathy_call_window_class,
1573 sizeof (EmpathyCallWindowPriv));
1575 object_class->constructed = empathy_call_window_constructed;
1576 object_class->set_property = empathy_call_window_set_property;
1577 object_class->get_property = empathy_call_window_get_property;
1579 object_class->dispose = empathy_call_window_dispose;
1580 object_class->finalize = empathy_call_window_finalize;
1582 param_spec = g_param_spec_object ("handler",
1583 "handler", "The call handler",
1584 EMPATHY_TYPE_CALL_HANDLER,
1585 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
1586 g_object_class_install_property (object_class,
1587 PROP_CALL_HANDLER, param_spec);
1591 empathy_call_window_dispose (GObject *object)
1593 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
1594 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1596 if (priv->dispose_has_run)
1599 priv->dispose_has_run = TRUE;
1601 if (priv->handler != NULL)
1603 empathy_call_handler_stop_call (priv->handler);
1604 tp_clear_object (&priv->handler);
1607 if (priv->bus_message_source_id != 0)
1609 g_source_remove (priv->bus_message_source_id);
1610 priv->bus_message_source_id = 0;
1613 if (priv->got_video_src > 0)
1615 g_source_remove (priv->got_video_src);
1616 priv->got_video_src = 0;
1619 tp_clear_object (&priv->pipeline);
1620 tp_clear_object (&priv->video_input);
1621 tp_clear_object (&priv->audio_input);
1622 tp_clear_object (&priv->video_tee);
1623 tp_clear_object (&priv->ui_manager);
1624 tp_clear_object (&priv->fullscreen);
1625 tp_clear_object (&priv->camera_monitor);
1627 g_list_free_full (priv->notifiers, g_object_unref);
1629 if (priv->timer_id != 0)
1630 g_source_remove (priv->timer_id);
1633 if (priv->contact != NULL)
1635 g_signal_handlers_disconnect_by_func (priv->contact,
1636 contact_name_changed_cb, self);
1637 priv->contact = NULL;
1641 tp_clear_object (&priv->sound_mgr);
1643 G_OBJECT_CLASS (empathy_call_window_parent_class)->dispose (object);
1647 disconnect_video_output_motion_handler (EmpathyCallWindow *self)
1649 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1651 if (priv->video_output_motion_handler_id != 0)
1653 g_signal_handler_disconnect (G_OBJECT (priv->video_container),
1654 priv->video_output_motion_handler_id);
1655 priv->video_output_motion_handler_id = 0;
1660 empathy_call_window_finalize (GObject *object)
1662 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
1663 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1665 disconnect_video_output_motion_handler (self);
1667 /* free any data held directly by the object here */
1668 g_mutex_free (priv->lock);
1670 g_timer_destroy (priv->timer);
1672 G_OBJECT_CLASS (empathy_call_window_parent_class)->finalize (object);
1677 empathy_call_window_new (EmpathyCallHandler *handler)
1679 return EMPATHY_CALL_WINDOW (
1680 g_object_new (EMPATHY_TYPE_CALL_WINDOW, "handler", handler, NULL));
1684 empathy_call_window_conference_added_cb (EmpathyCallHandler *handler,
1685 GstElement *conference, gpointer user_data)
1687 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
1688 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1689 FsElementAddedNotifier *notifier;
1692 DEBUG ("Conference added");
1694 /* Add notifier to set the various element properties as needed */
1695 notifier = fs_element_added_notifier_new ();
1696 keyfile = fs_utils_get_default_element_properties (conference);
1698 if (keyfile != NULL)
1699 fs_element_added_notifier_set_properties_from_keyfile (notifier, keyfile);
1701 fs_element_added_notifier_add (notifier, GST_BIN (priv->pipeline));
1703 priv->notifiers = g_list_prepend (priv->notifiers, notifier);
1705 gst_bin_add (GST_BIN (priv->pipeline), conference);
1706 gst_element_set_state (conference, GST_STATE_PLAYING);
1710 empathy_call_window_conference_removed_cb (EmpathyCallHandler *handler,
1711 GstElement *conference, gpointer user_data)
1713 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
1714 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1716 gst_bin_remove (GST_BIN (priv->pipeline), conference);
1717 gst_element_set_state (conference, GST_STATE_NULL);
1721 empathy_call_window_reset_pipeline (EmpathyCallWindow *self)
1723 GstStateChangeReturn state_change_return;
1724 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1726 if (priv->pipeline == NULL)
1729 if (priv->bus_message_source_id != 0)
1731 g_source_remove (priv->bus_message_source_id);
1732 priv->bus_message_source_id = 0;
1735 state_change_return = gst_element_set_state (priv->pipeline, GST_STATE_NULL);
1737 if (state_change_return == GST_STATE_CHANGE_SUCCESS ||
1738 state_change_return == GST_STATE_CHANGE_NO_PREROLL)
1740 if (priv->pipeline != NULL)
1741 g_object_unref (priv->pipeline);
1742 priv->pipeline = NULL;
1744 g_signal_handlers_disconnect_by_func (priv->audio_input_adj,
1745 empathy_call_window_mic_volume_changed_cb, self);
1747 if (priv->audio_output != NULL)
1748 g_object_unref (priv->audio_output);
1749 priv->audio_output = NULL;
1751 if (priv->video_tee != NULL)
1752 g_object_unref (priv->video_tee);
1753 priv->video_tee = NULL;
1755 if (priv->video_preview != NULL)
1756 clutter_actor_destroy (priv->video_preview);
1757 priv->video_preview = NULL;
1759 priv->funnel = NULL;
1761 create_pipeline (self);
1762 /* Call will be started when user will hit the 'redial' button */
1763 priv->start_call_when_playing = FALSE;
1764 gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
1770 g_message ("Error: could not destroy pipeline. Closing call window");
1771 gtk_widget_destroy (GTK_WIDGET (self));
1778 reset_details_pane (EmpathyCallWindow *self)
1780 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1782 gtk_label_set_text (GTK_LABEL (priv->vcodec_encoding_label), _("Unknown"));
1783 gtk_label_set_text (GTK_LABEL (priv->acodec_encoding_label), _("Unknown"));
1784 gtk_label_set_text (GTK_LABEL (priv->vcodec_decoding_label), _("Unknown"));
1785 gtk_label_set_text (GTK_LABEL (priv->acodec_decoding_label), _("Unknown"));
1789 empathy_call_window_disconnected (EmpathyCallWindow *self,
1792 gboolean could_disconnect = FALSE;
1793 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1794 gboolean could_reset_pipeline;
1796 /* Leave full screen mode if needed */
1797 gtk_window_unfullscreen (GTK_WINDOW (self));
1799 gtk_action_set_sensitive (priv->menu_fullscreen, FALSE);
1800 gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
1802 could_reset_pipeline = empathy_call_window_reset_pipeline (self);
1804 if (priv->call_state == CONNECTING)
1805 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
1807 if (priv->call_state != REDIALING)
1808 priv->call_state = DISCONNECTED;
1810 if (could_reset_pipeline)
1812 g_mutex_lock (priv->lock);
1814 g_timer_stop (priv->timer);
1816 if (priv->timer_id != 0)
1817 g_source_remove (priv->timer_id);
1820 g_mutex_unlock (priv->lock);
1823 /* We are about to destroy the window, no need to update it or create
1824 * a video preview */
1827 empathy_call_window_status_message (self, _("Disconnected"));
1829 gtk_action_set_sensitive (priv->redial, TRUE);
1830 gtk_widget_set_sensitive (priv->redial_button, TRUE);
1832 /* Unsensitive the camera and mic button */
1833 gtk_widget_set_sensitive (priv->camera_button, FALSE);
1834 gtk_widget_set_sensitive (priv->mic_button, FALSE);
1836 /* Be sure that the mic button is enabled */
1837 gtk_toggle_tool_button_set_active (
1838 GTK_TOGGLE_TOOL_BUTTON (priv->mic_button), TRUE);
1840 if (priv->camera_state == CAMERA_STATE_ON)
1842 /* Restart the preview with the new pipeline. */
1843 display_video_preview (self, TRUE);
1846 gtk_progress_bar_set_fraction (
1847 GTK_PROGRESS_BAR (priv->volume_progress_bar), 0);
1849 /* destroy the video output; it will be recreated when we'll redial */
1850 disconnect_video_output_motion_handler (self);
1851 if (priv->video_output != NULL)
1852 clutter_actor_destroy (priv->video_output);
1853 priv->video_output = NULL;
1854 if (priv->got_video_src > 0)
1856 g_source_remove (priv->got_video_src);
1857 priv->got_video_src = 0;
1860 gtk_widget_show (priv->remote_user_avatar_widget);
1862 reset_details_pane (self);
1864 priv->sending_video = FALSE;
1865 priv->call_started = FALSE;
1867 could_disconnect = TRUE;
1869 /* TODO: display the self avatar of the preview (depends if the "Always
1870 * Show Video Preview" is enabled or not) */
1873 return could_disconnect;
1878 empathy_call_window_channel_closed_cb (EmpathyCallHandler *handler,
1881 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
1882 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1884 if (empathy_call_window_disconnected (self, TRUE) &&
1885 priv->call_state == REDIALING)
1886 empathy_call_window_restart_call (self);
1890 empathy_call_window_sink_removed_cb (EmpathyCallHandler *handler,
1892 FsMediaType media_type,
1893 EmpathyCallWindow *self)
1895 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1897 DEBUG ("removing content");
1900 * This assumes that there is only one video stream per channel...
1903 if ((guint) media_type == FS_MEDIA_TYPE_VIDEO)
1905 if (priv->funnel != NULL)
1909 output = priv->video_output_sink;
1911 gst_element_set_state (output, GST_STATE_NULL);
1912 gst_element_set_state (priv->funnel, GST_STATE_NULL);
1914 gst_bin_remove (GST_BIN (priv->pipeline), output);
1915 gst_bin_remove (GST_BIN (priv->pipeline), priv->funnel);
1916 priv->funnel = NULL;
1920 else if (media_type == FS_MEDIA_TYPE_AUDIO)
1922 if (priv->audio_output != NULL)
1924 gst_element_set_state (priv->audio_output, GST_STATE_NULL);
1926 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
1927 priv->audio_output = NULL;
1935 /* Called with global lock held */
1937 empathy_call_window_get_video_sink_pad (EmpathyCallWindow *self)
1939 EmpathyCallWindowPriv *priv = GET_PRIV (self);
1943 if (priv->funnel == NULL)
1945 output = priv->video_output_sink;
1947 priv->funnel = gst_element_factory_make ("fsfunnel", NULL);
1951 g_warning ("Could not create fsfunnel");
1955 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->funnel))
1957 gst_object_unref (priv->funnel);
1958 priv->funnel = NULL;
1959 g_warning ("Could not add funnel to pipeline");
1963 if (!gst_bin_add (GST_BIN (priv->pipeline), output))
1965 g_warning ("Could not add the video output widget to the pipeline");
1969 if (!gst_element_link (priv->funnel, output))
1971 g_warning ("Could not link output sink to funnel");
1972 goto error_output_added;
1975 if (gst_element_set_state (output, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
1977 g_warning ("Could not start video sink");
1978 goto error_output_added;
1981 if (gst_element_set_state (priv->funnel, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
1983 g_warning ("Could not start funnel");
1984 goto error_output_added;
1988 pad = gst_element_get_request_pad (priv->funnel, "sink%d");
1991 g_warning ("Could not get request pad from funnel");
1998 gst_element_set_locked_state (priv->funnel, TRUE);
1999 gst_element_set_locked_state (output, TRUE);
2001 gst_element_set_state (priv->funnel, GST_STATE_NULL);
2002 gst_element_set_state (output, GST_STATE_NULL);
2004 gst_bin_remove (GST_BIN (priv->pipeline), output);
2005 gst_element_set_locked_state (output, FALSE);
2009 gst_bin_remove (GST_BIN (priv->pipeline), priv->funnel);
2010 priv->funnel = NULL;
2015 /* Called with global lock held */
2017 empathy_call_window_get_audio_sink_pad (EmpathyCallWindow *self)
2019 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2021 GstPadTemplate *template;
2023 if (priv->audio_output == NULL)
2025 priv->audio_output = empathy_audio_sink_new ();
2026 g_object_ref_sink (priv->audio_output);
2028 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_output))
2030 g_warning ("Could not add audio sink to pipeline");
2031 g_object_unref (priv->audio_output);
2032 goto error_add_output;
2035 if (gst_element_set_state (priv->audio_output, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2037 g_warning ("Could not start audio sink");
2042 template = gst_element_class_get_pad_template (
2043 GST_ELEMENT_GET_CLASS (priv->audio_output), "sink%d");
2045 pad = gst_element_request_pad (priv->audio_output,
2046 template, NULL, NULL);
2050 g_warning ("Could not get sink pad from sink");
2057 gst_element_set_locked_state (priv->audio_output, TRUE);
2058 gst_element_set_state (priv->audio_output, GST_STATE_NULL);
2059 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
2060 priv->audio_output = NULL;
2068 empathy_call_window_update_timer (gpointer user_data)
2070 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2071 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2075 time_ = g_timer_elapsed (priv->timer, NULL);
2077 /* Translators: 'status - minutes:seconds' the caller has been connected */
2078 str = g_strdup_printf (_("%s — %d:%02dm"),
2079 priv->call_state == HELD ? _("On hold") : _("Connected"),
2080 (int) time_ / 60, (int) time_ % 60);
2081 empathy_call_window_status_message (self, str);
2089 display_error (EmpathyCallWindow *self,
2090 TpyCallChannel *call,
2094 const gchar *details)
2096 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2097 GtkWidget *info_bar;
2098 GtkWidget *content_area;
2105 /* Create info bar */
2106 info_bar = gtk_info_bar_new_with_buttons (GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
2109 gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_WARNING);
2111 content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar));
2113 /* hbox containing the image and the messages vbox */
2114 hbox = gtk_hbox_new (FALSE, 3);
2115 gtk_container_add (GTK_CONTAINER (content_area), hbox);
2118 image = gtk_image_new_from_icon_name (img, GTK_ICON_SIZE_DIALOG);
2119 gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
2121 /* vbox containing the main message and the details expander */
2122 vbox = gtk_vbox_new (FALSE, 3);
2123 gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
2126 txt = g_strdup_printf ("<b>%s</b>\n%s", title, desc);
2128 label = gtk_label_new (NULL);
2129 gtk_label_set_markup (GTK_LABEL (label), txt);
2130 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
2131 gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
2134 gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
2137 if (details != NULL)
2139 GtkWidget *expander;
2141 expander = gtk_expander_new (_("Technical Details"));
2143 txt = g_strdup_printf ("<i>%s</i>", details);
2145 label = gtk_label_new (NULL);
2146 gtk_label_set_markup (GTK_LABEL (label), txt);
2147 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
2148 gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
2151 gtk_container_add (GTK_CONTAINER (expander), label);
2152 gtk_box_pack_start (GTK_BOX (vbox), expander, TRUE, TRUE, 0);
2155 g_signal_connect (info_bar, "response",
2156 G_CALLBACK (gtk_widget_destroy), NULL);
2158 gtk_box_pack_start (GTK_BOX (priv->errors_vbox), info_bar,
2159 FALSE, FALSE, CONTENT_HBOX_CHILDREN_PACKING_PADDING);
2160 gtk_widget_show_all (info_bar);
2164 media_stream_error_to_txt (EmpathyCallWindow *self,
2165 TpyCallChannel *call,
2167 TpMediaStreamError error)
2169 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2170 const gchar *cm = NULL;
2176 case TP_MEDIA_STREAM_ERROR_CODEC_NEGOTIATION_FAILED:
2178 return g_strdup_printf (
2179 _("%s's software does not understand any of the audio formats "
2180 "supported by your computer"),
2181 empathy_contact_get_alias (priv->contact));
2183 return g_strdup_printf (
2184 _("%s's software does not understand any of the video formats "
2185 "supported by your computer"),
2186 empathy_contact_get_alias (priv->contact));
2188 case TP_MEDIA_STREAM_ERROR_CONNECTION_FAILED:
2189 return g_strdup_printf (
2190 _("Can't establish a connection to %s. "
2191 "One of you might be on a network that does not allow "
2192 "direct connections."),
2193 empathy_contact_get_alias (priv->contact));
2195 case TP_MEDIA_STREAM_ERROR_NETWORK_ERROR:
2196 return g_strdup (_("There was a failure on the network"));
2198 case TP_MEDIA_STREAM_ERROR_NO_CODECS:
2200 return g_strdup (_("The audio formats necessary for this call "
2201 "are not installed on your computer"));
2203 return g_strdup (_("The video formats necessary for this call "
2204 "are not installed on your computer"));
2206 case TP_MEDIA_STREAM_ERROR_INVALID_CM_BEHAVIOR:
2207 tp_connection_parse_object_path (
2208 tp_channel_borrow_connection (TP_CHANNEL (call)),
2211 url = g_strdup_printf ("http://bugs.freedesktop.org/enter_bug.cgi?"
2212 "product=Telepathy&component=%s", cm);
2214 result = g_strdup_printf (
2215 _("Something unexpected happened in a Telepathy component. "
2216 "Please <a href=\"%s\">report this bug</a> and attach "
2217 "logs gathered from the 'Debug' window in the Help menu."), url);
2223 case TP_MEDIA_STREAM_ERROR_MEDIA_ERROR:
2224 return g_strdup (_("There was a failure in the call engine"));
2226 case TP_MEDIA_STREAM_ERROR_EOS:
2227 return g_strdup (_("The end of the stream was reached"));
2229 case TP_MEDIA_STREAM_ERROR_UNKNOWN:
2236 empathy_call_window_stream_error (EmpathyCallWindow *self,
2237 TpyCallChannel *call,
2246 desc = media_stream_error_to_txt (self, call, audio, code);
2249 /* No description, use the error message. That's not great as it's not
2250 * localized but it's better than nothing. */
2251 display_error (self, call, icon, title, msg, NULL);
2255 display_error (self, call, icon, title, desc, msg);
2261 empathy_call_window_audio_stream_error (TpyCallChannel *call,
2264 EmpathyCallWindow *self)
2266 empathy_call_window_stream_error (self, call, TRUE, code, msg,
2267 "gnome-stock-mic", _("Can't establish audio stream"));
2271 empathy_call_window_video_stream_error (TpyCallChannel *call,
2274 EmpathyCallWindow *self)
2276 empathy_call_window_stream_error (self, call, FALSE, code, msg,
2277 "camera-web", _("Can't establish video stream"));
2282 empathy_call_window_state_changed_cb (EmpathyCallHandler *handler,
2284 EmpathyCallWindow *self)
2286 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2287 TpyCallChannel *call;
2288 gboolean can_send_video;
2290 if (state != TPY_CALL_STATE_ACCEPTED)
2293 if (priv->call_state == CONNECTED)
2296 g_timer_start (priv->timer);
2297 priv->call_state = CONNECTED;
2299 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
2301 can_send_video = priv->video_input != NULL &&
2302 empathy_contact_can_voip_video (priv->contact) &&
2303 empathy_camera_monitor_get_available (priv->camera_monitor);
2305 g_object_get (priv->handler, "call-channel", &call, NULL);
2307 if (tpy_call_channel_has_dtmf (call))
2308 gtk_widget_set_sensitive (priv->dtmf_panel, TRUE);
2310 if (priv->video_input == NULL)
2311 empathy_call_window_set_send_video (self, CAMERA_STATE_OFF);
2313 gtk_widget_set_sensitive (priv->camera_button, can_send_video);
2315 gtk_action_set_sensitive (priv->redial, FALSE);
2316 gtk_widget_set_sensitive (priv->redial_button, FALSE);
2318 gtk_widget_set_sensitive (priv->mic_button, TRUE);
2320 clutter_actor_hide (priv->video_output);
2321 gtk_widget_show (priv->remote_user_avatar_widget);
2323 g_object_unref (call);
2325 g_mutex_lock (priv->lock);
2327 priv->timer_id = g_timeout_add_seconds (1,
2328 empathy_call_window_update_timer, self);
2330 g_mutex_unlock (priv->lock);
2332 empathy_call_window_update_timer (self);
2334 gtk_action_set_sensitive (priv->menu_fullscreen, TRUE);
2338 empathy_call_window_show_video_output_cb (gpointer user_data)
2340 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2342 if (self->priv->video_output != NULL)
2344 gtk_widget_hide (self->priv->remote_user_avatar_widget);
2345 clutter_actor_show (self->priv->video_output);
2352 empathy_call_window_check_video_cb (gpointer data)
2354 EmpathyCallWindow *self = data;
2356 if (self->priv->got_video)
2358 self->priv->got_video = FALSE;
2362 /* No video in the last N seconds, display the remote avatar */
2363 empathy_call_window_show_video_output (self, FALSE);
2368 /* Called from the streaming thread */
2370 empathy_call_window_video_probe_cb (GstPad *pad,
2371 GstMiniObject *mini_obj,
2372 EmpathyCallWindow *self)
2375 if (GST_IS_EVENT (mini_obj))
2378 if (G_UNLIKELY (!self->priv->got_video))
2380 /* show the remote video */
2381 g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
2382 empathy_call_window_show_video_output_cb,
2383 g_object_ref (self), g_object_unref);
2385 self->priv->got_video = TRUE;
2391 /* Called from the streaming thread */
2393 empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
2394 GstPad *src, guint media_type, gpointer user_data)
2396 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2397 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2398 gboolean retval = FALSE;
2402 g_mutex_lock (priv->lock);
2406 case TP_MEDIA_STREAM_TYPE_AUDIO:
2407 pad = empathy_call_window_get_audio_sink_pad (self);
2409 case TP_MEDIA_STREAM_TYPE_VIDEO:
2410 g_idle_add (empathy_call_window_show_video_output_cb, self);
2411 pad = empathy_call_window_get_video_sink_pad (self);
2413 gst_pad_add_data_probe (src,
2414 G_CALLBACK (empathy_call_window_video_probe_cb), self);
2415 if (priv->got_video_src > 0)
2416 g_source_remove (priv->got_video_src);
2417 priv->got_video_src = g_timeout_add_seconds (5,
2418 empathy_call_window_check_video_cb, self);
2421 g_assert_not_reached ();
2427 if (GST_PAD_LINK_FAILED (gst_pad_link (src, pad)))
2428 g_warning ("Could not link %s sink pad",
2429 media_type == TP_MEDIA_STREAM_TYPE_AUDIO ? "audio" : "video");
2433 gst_object_unref (pad);
2437 /* If no sink could be linked, try to add fakesink to prevent the whole call
2442 GstElement *fakesink = gst_element_factory_make ("fakesink", NULL);
2444 if (gst_bin_add (GST_BIN (priv->pipeline), fakesink))
2446 GstPad *sinkpad = gst_element_get_static_pad (fakesink, "sink");
2447 if (gst_element_set_state (fakesink, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE ||
2448 GST_PAD_LINK_FAILED (gst_pad_link (src, sinkpad)))
2450 gst_element_set_locked_state (fakesink, TRUE);
2451 gst_element_set_state (fakesink, GST_STATE_NULL);
2452 gst_bin_remove (GST_BIN (priv->pipeline), fakesink);
2456 DEBUG ("Could not link real sink, linked fakesink instead");
2458 gst_object_unref (sinkpad);
2462 gst_object_unref (fakesink);
2467 g_mutex_unlock (priv->lock);
2473 empathy_call_window_sink_added_cb (EmpathyCallHandler *handler,
2474 GstPad *sink, FsMediaType media_type, gpointer user_data)
2476 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2477 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2479 gboolean retval = FALSE;
2483 case FS_MEDIA_TYPE_AUDIO:
2484 if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_input))
2486 g_warning ("Could not add audio source to pipeline");
2490 pad = gst_element_get_static_pad (priv->audio_input, "src");
2493 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
2494 g_warning ("Could not get source pad from audio source");
2498 if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
2500 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
2501 g_warning ("Could not link audio source to farsight");
2505 if (gst_element_set_state (priv->audio_input, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
2507 g_warning ("Could not start audio source");
2508 gst_element_set_state (priv->audio_input, GST_STATE_NULL);
2509 gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
2515 case FS_MEDIA_TYPE_VIDEO:
2516 if (priv->video_tee != NULL)
2518 pad = gst_element_get_request_pad (priv->video_tee, "src%d");
2519 if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
2521 g_warning ("Could not link video source input pipeline");
2524 gst_object_unref (pad);
2530 g_assert_not_reached ();
2537 empathy_call_window_remove_video_input (EmpathyCallWindow *self)
2539 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2540 GstElement *preview;
2542 disable_camera (self);
2544 DEBUG ("remove video input");
2545 preview = priv->video_preview_sink;
2547 gst_element_set_state (priv->video_input, GST_STATE_NULL);
2548 gst_element_set_state (priv->video_tee, GST_STATE_NULL);
2549 gst_element_set_state (preview, GST_STATE_NULL);
2551 gst_bin_remove_many (GST_BIN (priv->pipeline), priv->video_input,
2554 g_object_unref (priv->video_input);
2555 priv->video_input = NULL;
2556 g_object_unref (priv->video_tee);
2557 priv->video_tee = NULL;
2558 clutter_actor_destroy (priv->video_preview);
2559 priv->video_preview = NULL;
2561 gtk_widget_set_sensitive (priv->camera_button, FALSE);
2565 start_call (EmpathyCallWindow *self)
2567 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2569 priv->call_started = TRUE;
2570 empathy_call_handler_start_call (priv->handler,
2571 gtk_get_current_event_time ());
2573 if (empathy_call_handler_has_initial_video (priv->handler))
2575 TpyCallChannel *call;
2578 g_object_get (priv->handler, "call-channel", &call, NULL);
2579 s = tpy_call_channel_get_video_state (call);
2581 if (s == TPY_SENDING_STATE_PENDING_SEND ||
2582 s == TPY_SENDING_STATE_SENDING)
2584 /* Enable 'send video' buttons and display the preview */
2585 gtk_toggle_tool_button_set_active (
2586 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), TRUE);
2590 gtk_toggle_tool_button_set_active (
2591 GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), FALSE);
2593 if (priv->video_preview == NULL)
2595 create_video_preview (self);
2596 add_video_preview_to_pipeline (self);
2600 g_object_unref (call);
2605 empathy_call_window_bus_message (GstBus *bus, GstMessage *message,
2608 EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
2609 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2612 empathy_call_handler_bus_message (priv->handler, bus, message);
2614 switch (GST_MESSAGE_TYPE (message))
2616 case GST_MESSAGE_STATE_CHANGED:
2617 if (GST_MESSAGE_SRC (message) == GST_OBJECT (priv->video_input))
2619 gst_message_parse_state_changed (message, NULL, &newstate, NULL);
2620 if (newstate == GST_STATE_PAUSED)
2621 empathy_call_window_setup_video_input (self);
2623 if (GST_MESSAGE_SRC (message) == GST_OBJECT (priv->pipeline) &&
2624 !priv->call_started)
2626 gst_message_parse_state_changed (message, NULL, &newstate, NULL);
2627 if (newstate == GST_STATE_PAUSED)
2629 gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
2630 priv->pipeline_playing = TRUE;
2632 if (priv->start_call_when_playing)
2637 case GST_MESSAGE_ERROR:
2639 GError *error = NULL;
2640 GstElement *gst_error;
2643 gst_message_parse_error (message, &error, &debug);
2644 gst_error = GST_ELEMENT (GST_MESSAGE_SRC (message));
2646 g_message ("Element error: %s -- %s\n", error->message, debug);
2648 if (g_str_has_prefix (gst_element_get_name (gst_error),
2649 VIDEO_INPUT_ERROR_PREFIX))
2651 /* Remove the video input and continue */
2652 if (priv->video_input != NULL)
2653 empathy_call_window_remove_video_input (self);
2654 gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
2658 empathy_call_window_disconnected (self, TRUE);
2660 g_error_free (error);
2663 case GST_MESSAGE_UNKNOWN:
2664 case GST_MESSAGE_EOS:
2665 case GST_MESSAGE_WARNING:
2666 case GST_MESSAGE_INFO:
2667 case GST_MESSAGE_TAG:
2668 case GST_MESSAGE_BUFFERING:
2669 case GST_MESSAGE_STATE_DIRTY:
2670 case GST_MESSAGE_STEP_DONE:
2671 case GST_MESSAGE_CLOCK_PROVIDE:
2672 case GST_MESSAGE_CLOCK_LOST:
2673 case GST_MESSAGE_NEW_CLOCK:
2674 case GST_MESSAGE_STRUCTURE_CHANGE:
2675 case GST_MESSAGE_STREAM_STATUS:
2676 case GST_MESSAGE_APPLICATION:
2677 case GST_MESSAGE_ELEMENT:
2678 case GST_MESSAGE_SEGMENT_START:
2679 case GST_MESSAGE_SEGMENT_DONE:
2680 case GST_MESSAGE_DURATION:
2681 case GST_MESSAGE_ANY:
2690 empathy_call_window_members_changed_cb (TpyCallChannel *call,
2691 GHashTable *members,
2692 EmpathyCallWindow *self)
2694 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2695 GHashTableIter iter;
2696 gpointer key, value;
2697 gboolean held = FALSE;
2699 g_hash_table_iter_init (&iter, members);
2700 while (g_hash_table_iter_next (&iter, &key, &value))
2702 if (GPOINTER_TO_INT (value) & TPY_CALL_MEMBER_FLAG_HELD)
2704 /* This assumes this is a 1-1 call, otherwise one participant
2705 * putting the call on hold wouldn't mean the call is on hold
2713 priv->call_state = HELD;
2714 else if (priv->call_state == HELD)
2715 priv->call_state = CONNECTED;
2719 call_handler_notify_call_cb (EmpathyCallHandler *handler,
2721 EmpathyCallWindow *self)
2723 EmpathyCallWindowPriv *priv = GET_PRIV (self);
2724 TpyCallChannel *call;
2726 g_object_get (priv->handler, "call-channel", &call, NULL);
2731 tp_g_signal_connect_object (call, "audio-stream-error",
2732 G_CALLBACK (empathy_call_window_audio_stream_error), self, 0);
2733 tp_g_signal_connect_object (call, "video-stream-error",
2734 G_CALLBACK (empathy_call_window_video_stream_error), self, 0);
2737 tp_g_signal_connect_object (call, "members-changed",
2738 G_CALLBACK (empathy_call_window_members_changed_cb), self, 0);
2740 g_object_unref (call);
2744 empathy_call_window_realized_cb (GtkWidget *widget, EmpathyCallWindow *window)
2746 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2747 TpyCallChannel *call;
2749 g_signal_connect (priv->handler, "state-changed",
2750 G_CALLBACK (empathy_call_window_state_changed_cb), window);
2751 g_signal_connect (priv->handler, "conference-added",
2752 G_CALLBACK (empathy_call_window_conference_added_cb), window);
2753 g_signal_connect (priv->handler, "conference-removed",
2754 G_CALLBACK (empathy_call_window_conference_removed_cb), window);
2755 g_signal_connect (priv->handler, "closed",
2756 G_CALLBACK (empathy_call_window_channel_closed_cb), window);
2757 g_signal_connect (priv->handler, "src-pad-added",
2758 G_CALLBACK (empathy_call_window_src_added_cb), window);
2759 g_signal_connect (priv->handler, "sink-pad-added",
2760 G_CALLBACK (empathy_call_window_sink_added_cb), window);
2761 g_signal_connect (priv->handler, "sink-pad-removed",
2762 G_CALLBACK (empathy_call_window_sink_removed_cb), window);
2764 g_object_get (priv->handler, "call-channel", &call, NULL);
2767 call_handler_notify_call_cb (priv->handler, NULL, window);
2768 g_object_unref (call);
2772 /* call-channel doesn't exist yet, we'll connect signals once it has been
2774 g_signal_connect (priv->handler, "notify::call-channel",
2775 G_CALLBACK (call_handler_notify_call_cb), window);
2778 gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
2782 empathy_call_window_delete_cb (GtkWidget *widget, GdkEvent*event,
2783 EmpathyCallWindow *window)
2785 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2787 if (priv->pipeline != NULL)
2789 if (priv->bus_message_source_id != 0)
2791 g_source_remove (priv->bus_message_source_id);
2792 priv->bus_message_source_id = 0;
2795 gst_element_set_state (priv->pipeline, GST_STATE_NULL);
2798 if (priv->call_state == CONNECTING)
2799 empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
2805 show_controls (EmpathyCallWindow *window, gboolean set_fullscreen)
2808 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2810 menu = gtk_ui_manager_get_widget (priv->ui_manager,
2815 gtk_widget_hide (priv->sidebar);
2816 gtk_widget_hide (menu);
2817 gtk_widget_hide (priv->toolbar);
2821 if (priv->sidebar_was_visible_before_fs)
2822 gtk_widget_show (priv->sidebar);
2824 gtk_widget_show (menu);
2825 gtk_widget_show (priv->toolbar);
2827 gtk_window_resize (GTK_WINDOW (window), priv->original_width_before_fs,
2828 priv->original_height_before_fs);
2833 show_borders (EmpathyCallWindow *window, gboolean set_fullscreen)
2835 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2837 gtk_container_set_border_width (GTK_CONTAINER (priv->content_hbox),
2838 set_fullscreen ? 0 : CONTENT_HBOX_BORDER_WIDTH);
2839 gtk_box_set_spacing (GTK_BOX (priv->content_hbox),
2840 set_fullscreen ? 0 : CONTENT_HBOX_SPACING);
2842 if (priv->video_output != NULL)
2845 gtk_box_set_child_packing (GTK_BOX (priv->content_hbox),
2846 priv->video_output, TRUE, TRUE,
2847 set_fullscreen ? 0 : CONTENT_HBOX_CHILDREN_PACKING_PADDING,
2854 empathy_call_window_state_event_cb (GtkWidget *widget,
2855 GdkEventWindowState *event, EmpathyCallWindow *window)
2857 if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
2859 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2860 gboolean set_fullscreen = event->new_window_state &
2861 GDK_WINDOW_STATE_FULLSCREEN;
2865 gboolean sidebar_was_visible;
2866 GtkAllocation allocation;
2867 gint original_width, original_height;
2869 gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
2870 original_width = allocation.width;
2871 original_height = allocation.height;
2873 g_object_get (priv->sidebar, "visible", &sidebar_was_visible, NULL);
2875 priv->sidebar_was_visible_before_fs = sidebar_was_visible;
2876 priv->original_width_before_fs = original_width;
2877 priv->original_height_before_fs = original_height;
2879 if (priv->video_output_motion_handler_id == 0 &&
2880 priv->video_output != NULL)
2882 priv->video_output_motion_handler_id = g_signal_connect (
2883 G_OBJECT (priv->video_container), "motion-notify-event",
2884 G_CALLBACK (empathy_call_window_video_output_motion_notify),
2890 disconnect_video_output_motion_handler (window);
2893 empathy_call_window_fullscreen_set_fullscreen (priv->fullscreen,
2895 show_controls (window, set_fullscreen);
2896 show_borders (window, set_fullscreen);
2897 gtk_action_set_stock_id (priv->menu_fullscreen,
2898 (set_fullscreen ? "gtk-leave-fullscreen" : "gtk-fullscreen"));
2899 priv->is_fullscreen = set_fullscreen;
2906 empathy_call_window_update_sidebar_buttons (EmpathyCallWindow *window,
2909 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2911 /* Update dialpad button */
2912 g_signal_handlers_block_by_func (priv->dialpad_button,
2913 empathy_call_window_dialpad_cb, window);
2914 gtk_toggle_tool_button_set_active (
2915 GTK_TOGGLE_TOOL_BUTTON (priv->dialpad_button),
2917 g_signal_handlers_unblock_by_func (priv->dialpad_button,
2918 empathy_call_window_dialpad_cb, window);
2920 /* Update sidebar menu */
2921 g_signal_handlers_block_by_func (priv->menu_sidebar,
2922 empathy_call_window_sidebar_cb, window);
2923 gtk_toggle_action_set_active (
2924 GTK_TOGGLE_ACTION (priv->menu_sidebar),
2925 gtk_widget_get_visible (priv->sidebar));
2926 g_signal_handlers_unblock_by_func (priv->menu_sidebar,
2927 empathy_call_window_sidebar_cb, window);
2931 empathy_call_window_show_sidebar (EmpathyCallWindow *window,
2934 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2935 int w, h, sidebar_width, handle_size;
2936 GtkAllocation allocation;
2938 gboolean dialpad_shown;
2940 gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
2941 w = allocation.width;
2942 h = allocation.height;
2944 gtk_widget_style_get (priv->pane, "handle_size", &handle_size, NULL);
2946 gtk_widget_get_preferred_width (priv->sidebar, &sidebar_width, NULL);
2950 gtk_widget_show (priv->sidebar);
2951 w += sidebar_width + handle_size;
2955 w -= sidebar_width + handle_size;
2956 gtk_widget_hide (priv->sidebar);
2960 gtk_window_resize (GTK_WINDOW (window), w, h);
2962 /* Update the 'Dialpad' menu */
2963 page = ev_sidebar_get_current_page (EV_SIDEBAR (priv->sidebar));
2964 dialpad_shown = active && !tp_strdiff (page, "dialpad");
2967 empathy_call_window_update_sidebar_buttons (window, dialpad_shown);
2971 empathy_call_window_set_send_video (EmpathyCallWindow *window,
2974 EmpathyCallWindowPriv *priv = GET_PRIV (window);
2975 TpyCallChannel *call;
2977 priv->sending_video = (state == CAMERA_STATE_ON);
2979 if (state == CAMERA_STATE_ON)
2981 /* When we start sending video, we want to show the video preview by
2983 display_video_preview (window, TRUE);
2987 display_video_preview (window, FALSE);
2990 if (priv->call_state != CONNECTED)
2993 g_object_get (priv->handler, "call-channel", &call, NULL);
2994 DEBUG ("%s sending video", priv->sending_video ? "start": "stop");
2995 tpy_call_channel_send_video (call, priv->sending_video);
2996 g_object_unref (call);
3000 empathy_call_window_mic_toggled_cb (GtkToggleToolButton *toggle,
3001 EmpathyCallWindow *window)
3003 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3006 active = (gtk_toggle_tool_button_get_active (toggle));
3010 empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
3012 gtk_adjustment_set_value (priv->audio_input_adj, priv->volume * 100);
3016 /* TODO, Instead of setting the input volume to 0 we should probably
3017 * stop sending but this would cause the audio call to drop if both
3018 * sides mute at the same time on certain CMs AFAIK. Need to revisit this
3019 * in the future. GNOME #574574
3021 empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
3023 gtk_adjustment_set_value (priv->audio_input_adj, 0);
3028 empathy_call_window_sidebar_hidden_cb (EvSidebar *sidebar,
3029 EmpathyCallWindow *window)
3031 empathy_call_window_show_sidebar (window, FALSE);
3035 empathy_call_window_sidebar_shown_cb (EvSidebar *sidebar,
3036 EmpathyCallWindow *window)
3038 empathy_call_window_show_sidebar (window, TRUE);
3042 empathy_call_window_sidebar_changed_cb (EvSidebar *sidebar,
3044 EmpathyCallWindow *window)
3046 empathy_call_window_update_sidebar_buttons (window,
3047 !tp_strdiff (page, "dialpad"));
3051 empathy_call_window_hangup_cb (gpointer object,
3052 EmpathyCallWindow *window)
3054 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3056 empathy_call_handler_stop_call (priv->handler);
3058 if (empathy_call_window_disconnected (window, FALSE))
3059 gtk_widget_destroy (GTK_WIDGET (window));
3063 empathy_call_window_restart_call (EmpathyCallWindow *window)
3065 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3067 /* Remove error info bars */
3068 gtk_container_forall (GTK_CONTAINER (priv->errors_vbox),
3069 (GtkCallback) gtk_widget_destroy, NULL);
3071 create_video_output_widget (window);
3073 g_signal_connect (G_OBJECT (priv->audio_input_adj), "value-changed",
3074 G_CALLBACK (empathy_call_window_mic_volume_changed_cb), window);
3076 /* While the call was disconnected, the input volume might have changed.
3077 * However, since the audio_input source was destroyed, its volume has not
3078 * been updated during that time. That's why we manually update it here */
3079 empathy_call_window_mic_volume_changed_cb (priv->audio_input_adj, window);
3081 priv->outgoing = TRUE;
3082 empathy_call_window_set_state_connecting (window);
3084 if (priv->pipeline_playing)
3085 start_call (window);
3087 /* call will be started when the pipeline is ready */
3088 priv->start_call_when_playing = TRUE;
3091 empathy_call_window_setup_avatars (window, priv->handler);
3093 gtk_action_set_sensitive (priv->redial, FALSE);
3094 gtk_widget_set_sensitive (priv->redial_button, FALSE);
3098 empathy_call_window_redial_cb (gpointer object,
3099 EmpathyCallWindow *window)
3101 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3103 if (priv->call_state == CONNECTED)
3104 priv->call_state = REDIALING;
3106 empathy_call_handler_stop_call (priv->handler);
3108 if (priv->call_state != CONNECTED)
3109 empathy_call_window_restart_call (window);
3113 empathy_call_window_dialpad_cb (GtkToggleToolButton *button,
3114 EmpathyCallWindow *window)
3116 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3119 active = gtk_toggle_tool_button_get_active (button);
3122 ev_sidebar_set_current_page (EV_SIDEBAR (priv->sidebar), "dialpad");
3124 empathy_call_window_show_sidebar (window, active);
3128 empathy_call_window_sidebar_cb (GtkToggleAction *menu,
3129 EmpathyCallWindow *self)
3131 empathy_call_window_show_sidebar (self,
3132 gtk_toggle_action_get_active (menu));
3136 empathy_call_window_fullscreen_cb (gpointer object,
3137 EmpathyCallWindow *window)
3139 empathy_call_window_fullscreen_toggle (window);
3143 empathy_call_window_fullscreen_toggle (EmpathyCallWindow *window)
3145 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3147 if (priv->is_fullscreen)
3148 gtk_window_unfullscreen (GTK_WINDOW (window));
3150 gtk_window_fullscreen (GTK_WINDOW (window));
3154 empathy_call_window_video_button_press_cb (GtkWidget *video_preview,
3155 GdkEventButton *event, EmpathyCallWindow *window)
3157 if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
3159 empathy_call_window_video_menu_popup (window, event->button);
3167 empathy_call_window_key_press_cb (GtkWidget *video_output,
3168 GdkEventKey *event, EmpathyCallWindow *window)
3170 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3172 if (priv->is_fullscreen && event->keyval == GDK_KEY_Escape)
3174 /* Since we are in fullscreen mode, toggling will bring us back to
3176 empathy_call_window_fullscreen_toggle (window);
3184 empathy_call_window_video_output_motion_notify (GtkWidget *widget,
3185 GdkEventMotion *event, EmpathyCallWindow *window)
3187 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3189 if (priv->is_fullscreen)
3191 empathy_call_window_fullscreen_show_popup (priv->fullscreen);
3198 empathy_call_window_video_menu_popup (EmpathyCallWindow *window,
3202 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3204 menu = gtk_ui_manager_get_widget (priv->ui_manager,
3206 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
3207 button, gtk_get_current_event_time ());
3208 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
3212 empathy_call_window_status_message (EmpathyCallWindow *self,
3215 gtk_label_set_label (GTK_LABEL (self->priv->status_label), message);
3219 empathy_call_window_volume_changed_cb (GtkScaleButton *button,
3220 gdouble value, EmpathyCallWindow *window)
3222 EmpathyCallWindowPriv *priv = GET_PRIV (window);
3224 if (priv->audio_output == NULL)
3227 empathy_audio_sink_set_volume (EMPATHY_GST_AUDIO_SINK (priv->audio_output),