#include <gtk/gtk.h>
#include <glib/gi18n.h>
+#include <clutter/clutter.h>
+#include <clutter-gtk/clutter-gtk.h>
+#include <clutter-gst/clutter-gst.h>
+
#include <telepathy-glib/util.h>
#include <telepathy-farstream/telepathy-farstream.h>
#include <telepathy-glib/util.h>
#include <gst/farsight/fs-element-added-notifier.h>
#include <gst/farsight/fs-utils.h>
+#include <libempathy/empathy-camera-monitor.h>
+#include <libempathy/empathy-gsettings.h>
#include <libempathy/empathy-tp-contact-factory.h>
#include <libempathy/empathy-utils.h>
+
#include <libempathy-gtk/empathy-avatar-image.h>
#include <libempathy-gtk/empathy-ui-utils.h>
#include <libempathy-gtk/empathy-sound-manager.h>
#include "empathy-audio-src.h"
#include "empathy-audio-sink.h"
#include "empathy-video-src.h"
-#include "ev-sidebar.h"
-
-#define BUTTON_ID "empathy-call-dtmf-button-id"
#define CONTENT_HBOX_BORDER_WIDTH 6
#define CONTENT_HBOX_SPACING 3
#define CONTENT_HBOX_CHILDREN_PACKING_PADDING 3
-#define SELF_VIDEO_SECTION_WIDTH 160
-#define SELF_VIDEO_SECTION_HEIGTH 120
+#define SELF_VIDEO_SECTION_WIDTH 120
+#define SELF_VIDEO_SECTION_HEIGTH 90
/* The avatar's default width and height are set to the same value because we
want a square icon. */
#define REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT \
EMPATHY_VIDEO_WIDGET_DEFAULT_HEIGHT
+#define SMALL_TOOLBAR_SIZE 36
+
/* If an video input error occurs, the error message will start with "v4l" */
#define VIDEO_INPUT_ERROR_PREFIX "v4l"
typedef enum {
CONNECTING,
CONNECTED,
+ HELD,
DISCONNECTED,
REDIALING
} CallState;
typedef enum {
CAMERA_STATE_OFF = 0,
- CAMERA_STATE_PREVIEW,
CAMERA_STATE_ON,
} CameraState;
EmpathyContact *contact;
+ EmpathyCameraMonitor *camera_monitor;
+
guint call_state;
gboolean outgoing;
GtkWidget *errors_vbox;
/* widget displays the video received from the remote user. This widget is
* alive only during call. */
- GtkWidget *video_output;
- GtkWidget *video_preview;
+ ClutterActor *video_output;
+ ClutterActor *video_preview;
+ ClutterActor *preview_hidden_button;
+ GtkWidget *video_container;
GtkWidget *remote_user_avatar_widget;
- GtkWidget *self_user_avatar_widget;
- GtkWidget *sidebar;
- GtkWidget *sidebar_button;
- GtkWidget *statusbar;
- GtkWidget *volume_button;
- GtkWidget *redial_button;
+ GtkWidget *remote_user_avatar_toolbar;
+ GtkWidget *remote_user_name_toolbar;
+ GtkWidget *status_label;
+ GtkWidget *hangup_button;
+ GtkWidget *audio_call_button;
+ GtkWidget *video_call_button;
GtkWidget *mic_button;
+ GtkWidget *camera_button;
+ GtkWidget *dialpad_button;
GtkWidget *toolbar;
+ GtkWidget *bottom_toolbar;
GtkWidget *pane;
- GtkAction *redial;
GtkAction *menu_fullscreen;
- GtkAction *action_camera_on;
- GtkWidget *tool_button_camera_off;
- GtkWidget *tool_button_camera_preview;
- GtkWidget *tool_button_camera_on;
-
- /* The frames and boxes that contain self and remote avatar and video
- input/output. When we redial, we destroy and re-create the boxes */
- GtkWidget *remote_user_output_frame;
- GtkWidget *self_user_output_frame;
- GtkWidget *remote_user_output_hbox;
- GtkWidget *self_user_output_hbox;
+
+ /* The box that contains self and remote avatar and video
+ input/output. When we redial, we destroy and re-create the box */
+ ClutterActor *video_box;
+ ClutterLayoutManager *video_layout;
/* We keep a reference on the hbox which contains the main content so we can
easilly repack everything when toggling fullscreen */
GtkWidget *content_hbox;
- /* This vbox is contained in the content_hbox and it contains the
- self_user_output_frame and the sidebar button. When toggling fullscreen,
- it needs to be repacked. We keep a reference on it for easier access. */
- GtkWidget *vbox;
-
gulong video_output_motion_handler_id;
guint bus_message_source_id;
gdouble volume;
- GtkWidget *volume_scale;
- GtkWidget *volume_progress_bar;
- GtkAdjustment *audio_input_adj;
GtkWidget *dtmf_panel;
GtkWidget *audio_local_candidate_info_img;
GstElement *video_input;
+ GstElement *video_preview_sink;
+ GstElement *video_output_sink;
GstElement *audio_input;
GstElement *audio_output;
GstElement *pipeline;
GstElement *video_tee;
GstElement *funnel;
- GstElement *liveadder;
GList *notifiers;
- guint context_id;
-
GTimer *timer;
guint timer_id;
- GtkWidget *video_contrast;
- GtkWidget *video_brightness;
- GtkWidget *video_gamma;
-
GMutex *lock;
gboolean call_started;
gboolean sending_video;
EmpathyCallWindowFullscreen *fullscreen;
gboolean is_fullscreen;
+ gboolean got_video;
+ guint got_video_src;
+
/* Those fields represent the state of the window before it actually was in
fullscreen mode. */
- gboolean sidebar_was_visible_before_fs;
+ gboolean dialpad_was_visible_before_fs;
gint original_width_before_fs;
gint original_height_before_fs;
+ gint x, y, w, h, dialpad_width;
+ gboolean maximized;
+
/* TRUE if the call should be started when the pipeline is playing */
gboolean start_call_when_playing;
/* TRUE if we requested to set the pipeline in the playing state */
gboolean pipeline_playing;
EmpathySoundManager *sound_mgr;
+
+ GSettings *settings;
};
#define GET_PRIV(o) (EMPATHY_CALL_WINDOW (o)->priv)
static gboolean empathy_call_window_state_event_cb (GtkWidget *widget,
GdkEventWindowState *event, EmpathyCallWindow *window);
-static void empathy_call_window_sidebar_toggled_cb (GtkToggleButton *toggle,
- EmpathyCallWindow *window);
-
static void empathy_call_window_set_send_video (EmpathyCallWindow *window,
CameraState state);
static void empathy_call_window_mic_toggled_cb (
GtkToggleToolButton *toggle, EmpathyCallWindow *window);
-static void empathy_call_window_sidebar_hidden_cb (EvSidebar *sidebar,
- EmpathyCallWindow *window);
-
-static void empathy_call_window_sidebar_shown_cb (EvSidebar *sidebar,
- EmpathyCallWindow *window);
-
static void empathy_call_window_hangup_cb (gpointer object,
EmpathyCallWindow *window);
static void empathy_call_window_video_menu_popup (EmpathyCallWindow *window,
guint button);
-static void empathy_call_window_redial_cb (gpointer object,
+static void empathy_call_window_dialpad_cb (GtkToggleToolButton *button,
EmpathyCallWindow *window);
static void empathy_call_window_restart_call (EmpathyCallWindow *window);
empathy_call_window_volume_changed_cb (GtkScaleButton *button,
gdouble value, EmpathyCallWindow *window);
-static void block_camera_control_signals (EmpathyCallWindow *self);
-static void unblock_camera_control_signals (EmpathyCallWindow *self);
-
static void
-empathy_call_window_setup_toolbar (EmpathyCallWindow *self)
+empathy_call_window_show_hangup_button (EmpathyCallWindow *self,
+ gboolean show)
{
- EmpathyCallWindowPriv *priv = GET_PRIV (self);
- GtkToolItem *tool_item;
- GtkWidget *camera_off_icon;
- GdkPixbuf *pixbuf, *modded_pixbuf;
-
- /* set the icon of the 'camera off' button by greying off the webcam icon */
- pixbuf = empathy_pixbuf_from_icon_name ("camera-web",
- GTK_ICON_SIZE_SMALL_TOOLBAR);
-
- modded_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
- gdk_pixbuf_get_width (pixbuf),
- gdk_pixbuf_get_height (pixbuf));
-
- gdk_pixbuf_saturate_and_pixelate (pixbuf, modded_pixbuf, 1.0, TRUE);
- g_object_unref (pixbuf);
-
- camera_off_icon = gtk_image_new_from_pixbuf (modded_pixbuf);
- g_object_unref (modded_pixbuf);
- gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (
- priv->tool_button_camera_off), camera_off_icon);
-
- /* Add an empty expanded GtkToolItem so the volume button is at the end of
- * the toolbar. */
- tool_item = gtk_tool_item_new ();
- gtk_tool_item_set_expand (tool_item, TRUE);
- gtk_widget_show (GTK_WIDGET (tool_item));
- gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), tool_item, -1);
+ gtk_widget_set_visible (self->priv->hangup_button, show);
+ gtk_widget_set_visible (self->priv->audio_call_button, !show);
+ gtk_widget_set_visible (self->priv->video_call_button, !show);
+}
- priv->volume_button = gtk_volume_button_new ();
- /* FIXME listen to the audiosinks signals and update the button according to
- * that, for now starting out at 1.0 and assuming only the app changes the
- * volume will do */
- gtk_scale_button_set_value (GTK_SCALE_BUTTON (priv->volume_button), 1.0);
- g_signal_connect (G_OBJECT (priv->volume_button), "value-changed",
- G_CALLBACK (empathy_call_window_volume_changed_cb), self);
+static void
+empathy_call_window_audio_call_cb (GtkToggleToolButton *button,
+ EmpathyCallWindow *self)
+{
+ g_object_set (self->priv->handler, "initial-video", FALSE, NULL);
+ empathy_call_window_restart_call (self);
+}
- tool_item = gtk_tool_item_new ();
- gtk_container_add (GTK_CONTAINER (tool_item), priv->volume_button);
- gtk_widget_show_all (GTK_WIDGET (tool_item));
- gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), tool_item, -1);
+static void
+empathy_call_window_video_call_cb (GtkToggleToolButton *button,
+ EmpathyCallWindow *self)
+{
+ empathy_call_window_set_send_video (self, CAMERA_STATE_ON);
+ g_object_set (self->priv->handler, "initial-video", TRUE, NULL);
+ empathy_call_window_restart_call (self);
}
static void
g_object_get (priv->handler, "call-channel", &call, NULL);
- button_quark = g_quark_from_static_string (BUTTON_ID);
+ button_quark = g_quark_from_static_string (EMPATHY_DTMF_BUTTON_ID);
event = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (button),
button_quark));
g_object_unref (call);
}
-static GtkWidget *
-empathy_call_window_create_dtmf (EmpathyCallWindow *self)
-{
- GtkWidget *table;
- int i;
- GQuark button_quark;
- struct {
- const gchar *label;
- TpDTMFEvent event;
- } dtmfbuttons[] = { { "1", TP_DTMF_EVENT_DIGIT_1 },
- { "2", TP_DTMF_EVENT_DIGIT_2 },
- { "3", TP_DTMF_EVENT_DIGIT_3 },
- { "4", TP_DTMF_EVENT_DIGIT_4 },
- { "5", TP_DTMF_EVENT_DIGIT_5 },
- { "6", TP_DTMF_EVENT_DIGIT_6 },
- { "7", TP_DTMF_EVENT_DIGIT_7 },
- { "8", TP_DTMF_EVENT_DIGIT_8 },
- { "9", TP_DTMF_EVENT_DIGIT_9 },
- { "#", TP_DTMF_EVENT_HASH },
- { "0", TP_DTMF_EVENT_DIGIT_0 },
- { "*", TP_DTMF_EVENT_ASTERISK },
- { NULL, } };
-
- button_quark = g_quark_from_static_string (BUTTON_ID);
-
- table = gtk_table_new (4, 3, TRUE);
-
- for (i = 0; dtmfbuttons[i].label != NULL; i++)
- {
- GtkWidget *button = gtk_button_new_with_label (dtmfbuttons[i].label);
- gtk_table_attach (GTK_TABLE (table), button, i % 3, i % 3 + 1,
- i/3, i/3 + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 1, 1);
-
- g_object_set_qdata (G_OBJECT (button), button_quark,
- GUINT_TO_POINTER (dtmfbuttons[i].event));
-
- g_signal_connect (G_OBJECT (button), "pressed",
- G_CALLBACK (dtmf_button_pressed_cb), self);
- g_signal_connect (G_OBJECT (button), "released",
- G_CALLBACK (dtmf_button_released_cb), self);
- }
-
- return table;
-}
-
-static GtkWidget *
-empathy_call_window_create_video_input_add_slider (EmpathyCallWindow *self,
- gchar *label_text, GtkWidget *bin)
-{
- GtkWidget *vbox = gtk_vbox_new (FALSE, 2);
- GtkWidget *scale = gtk_vscale_new_with_range (0, 100, 10);
- GtkWidget *label = gtk_label_new (label_text);
-
- gtk_widget_set_sensitive (scale, FALSE);
-
- gtk_container_add (GTK_CONTAINER (bin), vbox);
-
- gtk_range_set_inverted (GTK_RANGE (scale), TRUE);
- gtk_box_pack_start (GTK_BOX (vbox), scale, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-
- return scale;
-}
-
static void
-empathy_call_window_video_contrast_changed_cb (GtkAdjustment *adj,
- EmpathyCallWindow *self)
-
-{
- EmpathyCallWindowPriv *priv = GET_PRIV (self);
-
- empathy_video_src_set_channel (priv->video_input,
- EMPATHY_GST_VIDEO_SRC_CHANNEL_CONTRAST, gtk_adjustment_get_value (adj));
-}
-
-static void
-empathy_call_window_video_brightness_changed_cb (GtkAdjustment *adj,
- EmpathyCallWindow *self)
-
-{
- EmpathyCallWindowPriv *priv = GET_PRIV (self);
-
- empathy_video_src_set_channel (priv->video_input,
- EMPATHY_GST_VIDEO_SRC_CHANNEL_BRIGHTNESS, gtk_adjustment_get_value (adj));
-}
-
-static void
-empathy_call_window_video_gamma_changed_cb (GtkAdjustment *adj,
- EmpathyCallWindow *self)
-
-{
- EmpathyCallWindowPriv *priv = GET_PRIV (self);
-
- empathy_video_src_set_channel (priv->video_input,
- EMPATHY_GST_VIDEO_SRC_CHANNEL_GAMMA, gtk_adjustment_get_value (adj));
-}
-
-
-static GtkWidget *
-empathy_call_window_create_video_input (EmpathyCallWindow *self)
-{
- EmpathyCallWindowPriv *priv = GET_PRIV (self);
- GtkWidget *hbox;
-
- hbox = gtk_hbox_new (TRUE, 3);
-
- priv->video_contrast = empathy_call_window_create_video_input_add_slider (
- self, _("Contrast"), hbox);
-
- priv->video_brightness = empathy_call_window_create_video_input_add_slider (
- self, _("Brightness"), hbox);
-
- priv->video_gamma = empathy_call_window_create_video_input_add_slider (
- self, _("Gamma"), hbox);
-
- return hbox;
-}
-
-static void
-empathy_call_window_setup_video_input (EmpathyCallWindow *self)
-{
- EmpathyCallWindowPriv *priv = GET_PRIV (self);
- guint supported;
- GtkAdjustment *adj;
-
- supported = empathy_video_src_get_supported_channels (priv->video_input);
-
- if (supported & EMPATHY_GST_VIDEO_SRC_SUPPORTS_CONTRAST)
- {
- adj = gtk_range_get_adjustment (GTK_RANGE (priv->video_contrast));
-
- gtk_adjustment_set_value (adj,
- empathy_video_src_get_channel (priv->video_input,
- EMPATHY_GST_VIDEO_SRC_CHANNEL_CONTRAST));
-
- g_signal_connect (G_OBJECT (adj), "value-changed",
- G_CALLBACK (empathy_call_window_video_contrast_changed_cb), self);
-
- gtk_widget_set_sensitive (priv->video_contrast, TRUE);
- }
-
- if (supported & EMPATHY_GST_VIDEO_SRC_SUPPORTS_BRIGHTNESS)
- {
- adj = gtk_range_get_adjustment (GTK_RANGE (priv->video_brightness));
-
- gtk_adjustment_set_value (adj,
- empathy_video_src_get_channel (priv->video_input,
- EMPATHY_GST_VIDEO_SRC_CHANNEL_BRIGHTNESS));
-
- g_signal_connect (G_OBJECT (adj), "value-changed",
- G_CALLBACK (empathy_call_window_video_brightness_changed_cb), self);
- gtk_widget_set_sensitive (priv->video_brightness, TRUE);
- }
-
- if (supported & EMPATHY_GST_VIDEO_SRC_SUPPORTS_GAMMA)
- {
- adj = gtk_range_get_adjustment (GTK_RANGE (priv->video_gamma));
-
- gtk_adjustment_set_value (adj,
- empathy_video_src_get_channel (priv->video_input,
- EMPATHY_GST_VIDEO_SRC_CHANNEL_GAMMA));
-
- g_signal_connect (G_OBJECT (adj), "value-changed",
- G_CALLBACK (empathy_call_window_video_gamma_changed_cb), self);
- gtk_widget_set_sensitive (priv->video_gamma, TRUE);
- }
-}
-
-static void
-empathy_call_window_mic_volume_changed_cb (GtkAdjustment *adj,
- EmpathyCallWindow *self)
+empathy_call_window_mic_volume_changed (EmpathyCallWindow *self)
{
EmpathyCallWindowPriv *priv = GET_PRIV (self);
gdouble volume;
- volume = gtk_adjustment_get_value (adj)/100.0;
+ volume = g_settings_get_double (priv->settings,
+ EMPATHY_PREFS_CALL_SOUND_VOLUME) / 100.0;
/* Don't store the volume because of muting */
if (volume > 0 || gtk_toggle_tool_button_get_active (
}
static void
-empathy_call_window_audio_input_level_changed_cb (EmpathyGstAudioSrc *src,
- gdouble level, EmpathyCallWindow *window)
+empathy_call_window_prefs_volume_changed_cb (GSettings *settings,
+ gchar *key,
+ EmpathyCallWindow *self)
{
- gdouble value;
- EmpathyCallWindowPriv *priv = GET_PRIV (window);
-
- value = CLAMP (pow (10, level / 20), 0.0, 1.0);
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->volume_progress_bar),
- value);
+ empathy_call_window_mic_volume_changed (self);
}
-static GtkWidget *
-empathy_call_window_create_audio_input (EmpathyCallWindow *self)
+static void
+empathy_call_window_show_video_output (EmpathyCallWindow *self,
+ gboolean show)
{
- EmpathyCallWindowPriv *priv = GET_PRIV (self);
- GtkWidget *hbox, *vbox, *label;
-
- hbox = gtk_hbox_new (TRUE, 3);
-
- vbox = gtk_vbox_new (FALSE, 3);
- gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 3);
-
- priv->volume_scale = gtk_vscale_new_with_range (0, 150, 100);
- gtk_range_set_inverted (GTK_RANGE (priv->volume_scale), TRUE);
- label = gtk_label_new (_("Volume"));
-
- priv->audio_input_adj = gtk_range_get_adjustment (
- GTK_RANGE (priv->volume_scale));
- priv->volume = empathy_audio_src_get_volume (EMPATHY_GST_AUDIO_SRC
- (priv->audio_input));
- gtk_adjustment_set_value (priv->audio_input_adj, priv->volume * 100);
-
- g_signal_connect (G_OBJECT (priv->audio_input_adj), "value-changed",
- G_CALLBACK (empathy_call_window_mic_volume_changed_cb), self);
-
- gtk_box_pack_start (GTK_BOX (vbox), priv->volume_scale, TRUE, TRUE, 3);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 3);
+ if (self->priv->video_output != NULL)
+ g_object_set (self->priv->video_output, "visible", show, NULL);
- priv->volume_progress_bar = gtk_progress_bar_new ();
-
- gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->volume_progress_bar),
- GTK_ORIENTATION_VERTICAL);
-
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->volume_progress_bar),
- 0);
-
- gtk_box_pack_start (GTK_BOX (hbox), priv->volume_progress_bar, FALSE, FALSE,
- 3);
-
- return hbox;
+ gtk_widget_set_visible (self->priv->remote_user_avatar_widget, !show);
}
static void
create_video_output_widget (EmpathyCallWindow *self)
{
EmpathyCallWindowPriv *priv = GET_PRIV (self);
- GstBus *bus;
g_assert (priv->video_output == NULL);
g_assert (priv->pipeline != NULL);
- bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
- priv->video_output = empathy_video_widget_new (bus);
+ priv->video_output = clutter_texture_new ();
- gtk_box_pack_start (GTK_BOX (priv->remote_user_output_hbox),
- priv->video_output, TRUE, TRUE, 0);
+ clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (priv->video_output),
+ TRUE);
- gtk_widget_add_events (priv->video_output,
- GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK);
- g_signal_connect (G_OBJECT (priv->video_output), "button-press-event",
- G_CALLBACK (empathy_call_window_video_button_press_cb), self);
+ priv->video_output_sink = clutter_gst_video_sink_new (
+ CLUTTER_TEXTURE (priv->video_output));
- g_object_unref (bus);
-}
-
-static void
-create_audio_output (EmpathyCallWindow *self)
-{
- EmpathyCallWindowPriv *priv = GET_PRIV (self);
+ clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_box),
+ priv->video_output);
- g_assert (priv->audio_output == NULL);
- priv->audio_output = empathy_audio_sink_new ();
- gst_object_ref (priv->audio_output);
- gst_object_sink (priv->audio_output);
+ gtk_widget_add_events (priv->video_container,
+ GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK);
+ g_signal_connect (G_OBJECT (priv->video_container), "button-press-event",
+ G_CALLBACK (empathy_call_window_video_button_press_cb), self);
}
static void
priv->audio_input = empathy_audio_src_new ();
gst_object_ref (priv->audio_input);
gst_object_sink (priv->audio_input);
-
- tp_g_signal_connect_object (priv->audio_input, "peak-level-changed",
- G_CALLBACK (empathy_call_window_audio_input_level_changed_cb),
- self, 0);
}
static void
g_assert (priv->video_input != NULL);
g_assert (priv->video_tee != NULL);
- preview = empathy_video_widget_get_element (
- EMPATHY_VIDEO_WIDGET (priv->video_preview));
+ preview = priv->video_preview_sink;
if (!gst_bin_add (GST_BIN (priv->pipeline), priv->video_input))
{
return;
}
- if (!gst_bin_add (GST_BIN (priv->pipeline), priv->video_tee))
- {
- g_warning ("Could not add video tee to pipeline");
- return;
- }
-
if (!gst_bin_add (GST_BIN (priv->pipeline), preview))
{
g_warning ("Could not add video preview to pipeline");
}
}
+static void
+empathy_call_window_disable_camera_cb (GtkAction *action,
+ EmpathyCallWindow *self)
+{
+ clutter_actor_destroy (self->priv->preview_hidden_button);
+
+ gtk_toggle_tool_button_set_active (
+ GTK_TOGGLE_TOOL_BUTTON (self->priv->camera_button), FALSE);
+}
+
+static void
+empathy_call_window_minimise_camera_cb (GtkAction *action,
+ EmpathyCallWindow *self)
+{
+ clutter_actor_hide (self->priv->video_preview);
+ clutter_actor_show (self->priv->preview_hidden_button);
+}
+
+static void
+empathy_call_window_maximise_camera_cb (GtkAction *action,
+ EmpathyCallWindow *self)
+{
+ clutter_actor_show (self->priv->video_preview);
+ clutter_actor_hide (self->priv->preview_hidden_button);
+}
+
+static void
+empathy_call_window_preview_button_clicked_cb (GtkButton *button,
+ EmpathyCallWindow *self)
+{
+ GtkWidget *menu;
+
+ menu = gtk_ui_manager_get_widget (self->priv->ui_manager,
+ "/preview-menu");
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
+ 0, gtk_get_current_event_time ());
+ gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
+}
+
+static void
+empathy_call_window_preview_hidden_button_clicked_cb (GtkButton *button,
+ EmpathyCallWindow *self)
+{
+ GtkWidget *menu;
+
+ menu = gtk_ui_manager_get_widget (self->priv->ui_manager,
+ "/preview-hidden-menu");
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
+ 0, gtk_get_current_event_time ());
+ gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
+}
+
static void
create_video_preview (EmpathyCallWindow *self)
{
EmpathyCallWindowPriv *priv = GET_PRIV (self);
- GstBus *bus;
+ ClutterLayoutManager *layout, *layout_center;
+ ClutterActor *preview;
+ ClutterActor *box;
+ ClutterActor *b;
+ GtkWidget *button;
g_assert (priv->video_preview == NULL);
- g_assert (priv->video_tee == NULL);
-
- bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
- priv->video_preview = empathy_video_widget_new_with_size (bus,
+ preview = clutter_texture_new ();
+ clutter_actor_set_size (preview,
+ SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGTH);
+ priv->video_preview_sink = clutter_gst_video_sink_new (
+ CLUTTER_TEXTURE (preview));
+
+ /* Flip the video preview */
+ clutter_actor_set_rotation (preview,
+ CLUTTER_Y_AXIS,
+ 180,
+ SELF_VIDEO_SECTION_WIDTH * 0.5,
+ 0.0,
+ 0.0);
+
+ /* Add a little offset to the video preview */
+ layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_END,
+ CLUTTER_BIN_ALIGNMENT_START);
+ priv->video_preview = clutter_box_new (layout);
+ clutter_actor_set_size (priv->video_preview,
+ SELF_VIDEO_SECTION_WIDTH + 10, SELF_VIDEO_SECTION_HEIGTH + 10);
+
+ layout_center = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
+ CLUTTER_BIN_ALIGNMENT_CENTER);
+ box = clutter_box_new (layout_center);
+ clutter_actor_set_size (box,
SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGTH);
- g_object_set (priv->video_preview, "sync", FALSE, "async", TRUE, NULL);
- gtk_box_pack_start (GTK_BOX (priv->self_user_output_hbox),
- priv->video_preview, TRUE, TRUE, 0);
+ clutter_container_add_actor (CLUTTER_CONTAINER (box), preview);
+ clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_preview), box);
- priv->video_tee = gst_element_factory_make ("tee", NULL);
- gst_object_ref (priv->video_tee);
- gst_object_sink (priv->video_tee);
+ g_object_set (priv->video_preview_sink,
+ "sync", FALSE,
+ "async", TRUE,
+ NULL);
- g_object_unref (bus);
+ /* Translators: this is an "Info" label. It should be as short
+ * as possible. */
+ button = gtk_button_new_with_label (_("i"));
+ b = gtk_clutter_actor_new_with_contents (button);
+
+ clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (layout_center),
+ b,
+ CLUTTER_BIN_ALIGNMENT_END,
+ CLUTTER_BIN_ALIGNMENT_END);
+
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (empathy_call_window_preview_button_clicked_cb),
+ self);
+
+ /* Translators: this is an "Info" label. It should be as short
+ * as possible. */
+ button = gtk_button_new_with_label (_("i"));
+ priv->preview_hidden_button =
+ gtk_clutter_actor_new_with_contents (button);
+
+ clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
+ priv->preview_hidden_button,
+ CLUTTER_BIN_ALIGNMENT_START,
+ CLUTTER_BIN_ALIGNMENT_END);
+
+ clutter_actor_hide (priv->preview_hidden_button);
+
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (empathy_call_window_preview_hidden_button_clicked_cb),
+ self);
+
+ clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
+ priv->video_preview,
+ CLUTTER_BIN_ALIGNMENT_START,
+ CLUTTER_BIN_ALIGNMENT_END);
}
static void
else
state = GST_STATE_NULL;
- preview = empathy_video_widget_get_element (
- EMPATHY_VIDEO_WIDGET (priv->video_preview));
+ preview = priv->video_preview_sink;
gst_element_set_state (preview, state);
gst_element_set_state (priv->video_input, state);
if (display)
{
- /* Display the preview and hide the self avatar */
+ /* Display the video preview */
DEBUG ("Show video preview");
play_camera (self, TRUE);
- gtk_widget_show (priv->video_preview);
- gtk_widget_hide (priv->self_user_avatar_widget);
+ clutter_actor_show (priv->video_preview);
}
else
{
- /* Display the self avatar and hide the preview */
- DEBUG ("Show self avatar");
+ /* Hide the video preview */
+ DEBUG ("Hide video preview");
if (priv->video_preview != NULL)
{
- gtk_widget_hide (priv->video_preview);
+ clutter_actor_hide (priv->video_preview);
play_camera (self, FALSE);
}
- gtk_widget_show (priv->self_user_avatar_widget);
}
}
if (priv->camera_state == CAMERA_STATE_ON)
empathy_call_window_set_send_video (self, CAMERA_STATE_OFF);
- block_camera_control_signals (self);
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (
- priv->tool_button_camera_on), FALSE);
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (
- priv->tool_button_camera_preview), FALSE);
-
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (
- priv->tool_button_camera_off), TRUE);
- gtk_radio_action_set_current_value (GTK_RADIO_ACTION (priv->action_camera_on),
- CAMERA_STATE_OFF);
- unblock_camera_control_signals (self);
-
priv->camera_state = CAMERA_STATE_OFF;
}
-static void
-tool_button_camera_off_toggled_cb (GtkToggleToolButton *toggle,
- EmpathyCallWindow *self)
-{
- EmpathyCallWindowPriv *priv = GET_PRIV (self);
-
- if (!gtk_toggle_tool_button_get_active (toggle))
- {
- if (priv->camera_state == CAMERA_STATE_OFF)
- {
- /* We can't change the state by disabling the button */
- block_camera_control_signals (self);
- gtk_toggle_tool_button_set_active (toggle, TRUE);
- unblock_camera_control_signals (self);
- }
-
- return;
- }
-
- disable_camera (self);
-}
-
-static void
-enable_preview (EmpathyCallWindow *self)
-{
- EmpathyCallWindowPriv *priv = GET_PRIV (self);
-
- if (priv->camera_state == CAMERA_STATE_PREVIEW)
- return;
-
- DEBUG ("Enable preview");
-
- if (priv->camera_state == CAMERA_STATE_ON)
- {
- /* preview is already displayed so we just have to stop sending */
- empathy_call_window_set_send_video (self, CAMERA_STATE_PREVIEW);
- }
- else
- {
- display_video_preview (self, TRUE);
- }
-
- block_camera_control_signals (self);
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (
- priv->tool_button_camera_off), FALSE);
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (
- priv->tool_button_camera_on), FALSE);
-
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (
- priv->tool_button_camera_preview), TRUE);
- gtk_radio_action_set_current_value (GTK_RADIO_ACTION (priv->action_camera_on),
- CAMERA_STATE_PREVIEW);
- unblock_camera_control_signals (self);
-
- priv->camera_state = CAMERA_STATE_PREVIEW;
-}
-
-static void
-tool_button_camera_preview_toggled_cb (GtkToggleToolButton *toggle,
- EmpathyCallWindow *self)
-{
- EmpathyCallWindowPriv *priv = GET_PRIV (self);
-
- if (!gtk_toggle_tool_button_get_active (toggle))
- {
- if (priv->camera_state == CAMERA_STATE_PREVIEW)
- {
- /* We can't change the state by disabling the button */
- block_camera_control_signals (self);
- gtk_toggle_tool_button_set_active (toggle, TRUE);
- unblock_camera_control_signals (self);
- }
-
- return;
- }
-
- enable_preview (self);
-}
-
static void
enable_camera (EmpathyCallWindow *self)
{
return;
}
-
DEBUG ("Enable camera");
empathy_call_window_set_send_video (self, CAMERA_STATE_ON);
- block_camera_control_signals (self);
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (
- priv->tool_button_camera_off), FALSE);
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (
- priv->tool_button_camera_preview), FALSE);
-
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (
- priv->tool_button_camera_on), TRUE);
- gtk_radio_action_set_current_value (GTK_RADIO_ACTION (priv->action_camera_on),
- CAMERA_STATE_ON);
- unblock_camera_control_signals (self);
-
priv->camera_state = CAMERA_STATE_ON;
}
static void
-tool_button_camera_on_toggled_cb (GtkToggleToolButton *toggle,
+empathy_call_window_camera_toggled_cb (GtkToggleToolButton *toggle,
EmpathyCallWindow *self)
{
- EmpathyCallWindowPriv *priv = GET_PRIV (self);
-
- if (!gtk_toggle_tool_button_get_active (toggle))
- {
- if (priv->camera_state == CAMERA_STATE_ON)
- {
- /* We can't change the state by disabling the button */
- block_camera_control_signals (self);
- gtk_toggle_tool_button_set_active (toggle, TRUE);
- unblock_camera_control_signals (self);
- }
-
- return;
- }
-
- enable_camera (self);
-}
-
-static void
-action_camera_change_cb (GtkRadioAction *action,
- GtkRadioAction *current,
- EmpathyCallWindow *self)
-{
- CameraState state;
-
- state = gtk_radio_action_get_current_value (current);
-
- switch (state)
- {
- case CAMERA_STATE_OFF:
- disable_camera (self);
- break;
-
- case CAMERA_STATE_PREVIEW:
- enable_preview (self);
- break;
-
- case CAMERA_STATE_ON:
- enable_camera (self);
- break;
-
- default:
- g_assert_not_reached ();
- }
+ if (gtk_toggle_tool_button_get_active (toggle))
+ enable_camera (self);
+ else
+ disable_camera (self);
}
static void
priv->pipeline = gst_pipeline_new (NULL);
priv->pipeline_playing = FALSE;
+ priv->video_tee = gst_element_factory_make ("tee", NULL);
+ gst_object_ref (priv->video_tee);
+ gst_object_sink (priv->video_tee);
+
+ gst_bin_add (GST_BIN (priv->pipeline), priv->video_tee);
+
bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
priv->bus_message_source_id = gst_bus_add_watch (bus,
empathy_call_window_bus_message, self);
g_object_unref (bus);
}
+static gboolean
+empathy_call_window_configure_event_cb (GtkWidget *widget,
+ GdkEvent *event,
+ EmpathyCallWindow *self)
+{
+ GdkWindow *gdk_window;
+ GdkWindowState window_state;
+
+ gtk_window_get_position (GTK_WINDOW (self), &self->priv->x, &self->priv->y);
+ gtk_window_get_size (GTK_WINDOW (self), &self->priv->w, &self->priv->h);
+
+ gtk_widget_get_preferred_width (self->priv->dtmf_panel,
+ &self->priv->dialpad_width, NULL);
+
+ gdk_window = gtk_widget_get_window (widget);
+ window_state = gdk_window_get_state (gdk_window);
+ self->priv->maximized = (window_state & GDK_WINDOW_STATE_MAXIMIZED);
+
+ return FALSE;
+}
+
+static void
+empathy_call_window_destroyed_cb (GtkWidget *object,
+ EmpathyCallWindow *self)
+{
+ if (gtk_widget_get_visible (self->priv->dtmf_panel))
+ {
+ /* Save the geometry as if the dialpad was hidden. */
+ empathy_geometry_save_values (GTK_WINDOW (self),
+ self->priv->x, self->priv->y,
+ self->priv->w - self->priv->dialpad_width, self->priv->h,
+ self->priv->maximized);
+ }
+}
static void
empathy_call_window_init (EmpathyCallWindow *self)
EmpathyCallWindowPriv *priv;
GtkBuilder *gui;
GtkWidget *top_vbox;
- GtkWidget *h;
- GtkWidget *arrow;
- GtkWidget *page;
gchar *filename;
+ ClutterConstraint *size_constraint;
+ ClutterActor *remote_avatar;
+ GtkStyleContext *context;
+ GdkRGBA rgba;
+ ClutterColor bg;
priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
EMPATHY_TYPE_CALL_WINDOW, EmpathyCallWindowPriv);
"call_window_vbox", &top_vbox,
"errors_vbox", &priv->errors_vbox,
"pane", &priv->pane,
- "statusbar", &priv->statusbar,
- "redial", &priv->redial_button,
+ "remote_user_name_toolbar", &priv->remote_user_name_toolbar,
+ "remote_user_avatar_toolbar", &priv->remote_user_avatar_toolbar,
+ "status_label", &priv->status_label,
+ "audiocall", &priv->audio_call_button,
+ "videocall", &priv->video_call_button,
"microphone", &priv->mic_button,
+ "camera", &priv->camera_button,
+ "hangup", &priv->hangup_button,
+ "dialpad", &priv->dialpad_button,
"toolbar", &priv->toolbar,
- "menuredial", &priv->redial,
+ "bottom_toolbar", &priv->bottom_toolbar,
"ui_manager", &priv->ui_manager,
"menufullscreen", &priv->menu_fullscreen,
- "camera_off", &priv->tool_button_camera_off,
- "camera_preview", &priv->tool_button_camera_preview,
- "camera_on", &priv->tool_button_camera_on,
- "action_camera_on", &priv->action_camera_on,
"details_vbox", &priv->details_vbox,
"vcodec_encoding_label", &priv->vcodec_encoding_label,
"acodec_encoding_label", &priv->acodec_encoding_label,
empathy_builder_connect (gui, self,
"menuhangup", "activate", empathy_call_window_hangup_cb,
"hangup", "clicked", empathy_call_window_hangup_cb,
- "menuredial", "activate", empathy_call_window_redial_cb,
- "redial", "clicked", empathy_call_window_redial_cb,
+ "audiocall", "clicked", empathy_call_window_audio_call_cb,
+ "videocall", "clicked", empathy_call_window_video_call_cb,
+ "volume", "value-changed", empathy_call_window_volume_changed_cb,
"microphone", "toggled", empathy_call_window_mic_toggled_cb,
+ "camera", "toggled", empathy_call_window_camera_toggled_cb,
+ "dialpad", "toggled", empathy_call_window_dialpad_cb,
"menufullscreen", "activate", empathy_call_window_fullscreen_cb,
- "camera_off", "toggled", tool_button_camera_off_toggled_cb,
- "camera_preview", "toggled", tool_button_camera_preview_toggled_cb,
- "camera_on", "toggled", tool_button_camera_on_toggled_cb,
- "action_camera_on", "changed", action_camera_change_cb,
+ "menupreviewdisable", "activate", empathy_call_window_disable_camera_cb,
+ "menupreviewminimise", "activate", empathy_call_window_minimise_camera_cb,
+ "menupreviewmaximise", "activate", empathy_call_window_maximise_camera_cb,
NULL);
gtk_action_set_sensitive (priv->menu_fullscreen, FALSE);
+ priv->camera_monitor = empathy_camera_monitor_dup_singleton ();
+
+ g_object_bind_property (priv->camera_monitor, "available",
+ priv->camera_button, "sensitive",
+ G_BINDING_SYNC_CREATE);
+
priv->lock = g_mutex_new ();
gtk_container_add (GTK_CONTAINER (self), top_vbox);
priv->content_hbox = gtk_hbox_new (FALSE, CONTENT_HBOX_SPACING);
gtk_container_set_border_width (GTK_CONTAINER (priv->content_hbox),
CONTENT_HBOX_BORDER_WIDTH);
- gtk_paned_pack1 (GTK_PANED (priv->pane), priv->content_hbox, TRUE, FALSE);
-
- /* remote user output frame */
- priv->remote_user_output_frame = gtk_frame_new (NULL);
- gtk_widget_set_size_request (priv->remote_user_output_frame,
- EMPATHY_VIDEO_WIDGET_DEFAULT_WIDTH, EMPATHY_VIDEO_WIDGET_DEFAULT_HEIGHT);
- gtk_box_pack_start (GTK_BOX (priv->content_hbox),
- priv->remote_user_output_frame, TRUE, TRUE,
- CONTENT_HBOX_CHILDREN_PACKING_PADDING);
+ gtk_box_pack_start (GTK_BOX (priv->pane), priv->content_hbox,
+ TRUE, TRUE, 0);
+
+ /* avatar/video box */
+ priv->video_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
+ CLUTTER_BIN_ALIGNMENT_CENTER);
+
+ priv->video_box = clutter_box_new (priv->video_layout);
+
+ priv->video_container = gtk_clutter_embed_new ();
+
+ /* Set the background color to that of the rest of the window */
+ context = gtk_widget_get_style_context (priv->content_hbox);
+ gtk_style_context_get_background_color (context,
+ GTK_STATE_FLAG_NORMAL, &rgba);
+ bg.red = CLAMP (rgba.red * 255.0, 0, 255);
+ bg.green = CLAMP (rgba.green * 255.0, 0, 255);
+ bg.blue = CLAMP (rgba.blue * 255.0, 0, 255);
+ bg.alpha = CLAMP (rgba.alpha * 255.0, 0, 255);
+ clutter_stage_set_color (
+ CLUTTER_STAGE (gtk_clutter_embed_get_stage (
+ GTK_CLUTTER_EMBED (priv->video_container))),
+ &bg);
+
+ clutter_container_add (
+ CLUTTER_CONTAINER (gtk_clutter_embed_get_stage (
+ GTK_CLUTTER_EMBED (priv->video_container))),
+ priv->video_box,
+ NULL);
- priv->remote_user_output_hbox = gtk_hbox_new (FALSE, 0);
+ size_constraint = clutter_bind_constraint_new (
+ gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->video_container)),
+ CLUTTER_BIND_SIZE, 0);
+ clutter_actor_add_constraint (priv->video_box, size_constraint);
priv->remote_user_avatar_widget = gtk_image_new ();
+ remote_avatar = gtk_clutter_actor_new_with_contents (
+ priv->remote_user_avatar_widget);
- gtk_box_pack_start (GTK_BOX (priv->remote_user_output_hbox),
- priv->remote_user_avatar_widget, TRUE, TRUE, 0);
-
- gtk_container_add (GTK_CONTAINER (priv->remote_user_output_frame),
- priv->remote_user_output_hbox);
+ clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_box),
+ remote_avatar);
- /* self user output frame */
- priv->self_user_output_frame = gtk_frame_new (NULL);
- gtk_widget_set_size_request (priv->self_user_output_frame,
- SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGTH);
-
- priv->self_user_output_hbox = gtk_hbox_new (FALSE, 0);
-
- priv->self_user_avatar_widget = gtk_image_new ();
- gtk_box_pack_start (GTK_BOX (priv->self_user_output_hbox),
- priv->self_user_avatar_widget, TRUE, TRUE, 0);
-
- gtk_container_add (GTK_CONTAINER (priv->self_user_output_frame),
- priv->self_user_output_hbox);
+ gtk_box_pack_start (GTK_BOX (priv->content_hbox),
+ priv->video_container, TRUE, TRUE,
+ CONTENT_HBOX_CHILDREN_PACKING_PADDING);
create_pipeline (self);
create_video_output_widget (self);
create_audio_input (self);
- create_audio_output (self);
create_video_input (self);
/* The call will be started as soon the pipeline is playing */
priv->start_call_when_playing = TRUE;
- priv->vbox = gtk_vbox_new (FALSE, 3);
- gtk_box_pack_start (GTK_BOX (priv->content_hbox), priv->vbox,
- FALSE, FALSE, CONTENT_HBOX_CHILDREN_PACKING_PADDING);
- gtk_box_pack_start (GTK_BOX (priv->vbox), priv->self_user_output_frame,
- FALSE, FALSE, 0);
-
- empathy_call_window_setup_toolbar (self);
-
- priv->sidebar_button = gtk_toggle_button_new_with_mnemonic (_("_Sidebar"));
- arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
- g_signal_connect (G_OBJECT (priv->sidebar_button), "toggled",
- G_CALLBACK (empathy_call_window_sidebar_toggled_cb), self);
-
- gtk_button_set_image (GTK_BUTTON (priv->sidebar_button), arrow);
-
- h = gtk_hbox_new (FALSE, 3);
- gtk_box_pack_end (GTK_BOX (priv->vbox), h, FALSE, FALSE, 3);
- gtk_box_pack_end (GTK_BOX (h), priv->sidebar_button, FALSE, FALSE, 3);
+ priv->dtmf_panel = empathy_create_dtmf_dialpad (G_OBJECT (self),
+ G_CALLBACK (dtmf_button_pressed_cb),
+ G_CALLBACK (dtmf_button_released_cb));
- priv->sidebar = ev_sidebar_new ();
- g_signal_connect (G_OBJECT (priv->sidebar),
- "hide", G_CALLBACK (empathy_call_window_sidebar_hidden_cb), self);
- g_signal_connect (G_OBJECT (priv->sidebar),
- "show", G_CALLBACK (empathy_call_window_sidebar_shown_cb), self);
- gtk_paned_pack2 (GTK_PANED (priv->pane), priv->sidebar, FALSE, FALSE);
-
- page = empathy_call_window_create_audio_input (self);
- ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "audio-input",
- _("Audio input"), page);
-
- page = empathy_call_window_create_video_input (self);
- ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "video-input",
- _("Video input"), page);
+ gtk_box_pack_start (GTK_BOX (priv->pane), priv->dtmf_panel,
+ FALSE, FALSE, 0);
- priv->dtmf_panel = empathy_call_window_create_dtmf (self);
- ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "dialpad",
- _("Dialpad"), priv->dtmf_panel);
+ gtk_box_pack_start (GTK_BOX (priv->pane), priv->details_vbox,
+ FALSE, FALSE, 0);
gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
- ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "details",
- _("Details"), priv->details_vbox);
-
gtk_widget_show_all (top_vbox);
- gtk_widget_hide (priv->sidebar);
+ gtk_widget_hide (priv->dtmf_panel);
+ gtk_widget_hide (priv->details_vbox);
priv->fullscreen = empathy_call_window_fullscreen_new (self);
+
empathy_call_window_fullscreen_set_video_widget (priv->fullscreen,
- priv->video_output);
+ priv->video_container);
+
g_signal_connect (G_OBJECT (priv->fullscreen->leave_fullscreen_button),
"clicked", G_CALLBACK (empathy_call_window_fullscreen_cb), self);
priv->sound_mgr = empathy_sound_manager_dup_singleton ();
+ empathy_call_window_show_hangup_button (self, TRUE);
+
+ priv->settings = g_settings_new (EMPATHY_PREFS_CALL_SCHEMA);
+ g_signal_connect (priv->settings, "changed::"EMPATHY_PREFS_CALL_SOUND_VOLUME,
+ G_CALLBACK (empathy_call_window_prefs_volume_changed_cb), self);
+
empathy_geometry_bind (GTK_WINDOW (self), "call-window");
+ /* These signals are used to track the window position and save it
+ * when the window is destroyed. We need to do this as we don't want
+ * the window geometry to be saved with the dialpad taken into account. */
+ g_signal_connect (self, "destroy",
+ G_CALLBACK (empathy_call_window_destroyed_cb), self);
+ g_signal_connect (self, "configure-event",
+ G_CALLBACK (empathy_call_window_configure_event_cb), self);
+ g_signal_connect (self, "window-state-event",
+ G_CALLBACK (empathy_call_window_configure_event_cb), self);
}
/* Instead of specifying a width and a height, we specify only one size. That's
}
}
+static void
+set_remote_user_name (EmpathyCallWindow *self,
+ EmpathyContact *contact)
+{
+ const gchar *alias = empathy_contact_get_alias (contact);
+ const gchar *status = empathy_contact_get_status (contact);
+ gchar *label;
+
+ label = g_strdup_printf ("%s\n<small>%s</small>", alias, status);
+ gtk_label_set_markup (GTK_LABEL (self->priv->remote_user_name_toolbar),
+ label);
+ g_free (label);
+}
+
static void
contact_name_changed_cb (EmpathyContact *contact,
- GParamSpec *pspec, EmpathyCallWindow *self)
+ GParamSpec *pspec,
+ EmpathyCallWindow *self)
{
set_window_title (self);
+ set_remote_user_name (self, contact);
+}
+
+static void
+contact_presence_changed_cb (EmpathyContact *contact,
+ GParamSpec *pspec,
+ EmpathyCallWindow *self)
+{
+ set_remote_user_name (self, contact);
}
static void
contact_avatar_changed_cb (EmpathyContact *contact,
- GParamSpec *pspec, GtkWidget *avatar_widget)
+ GParamSpec *pspec,
+ EmpathyCallWindow *self)
{
int size;
GtkAllocation allocation;
+ GtkWidget *avatar_widget;
+
+ avatar_widget = self->priv->remote_user_avatar_widget;
gtk_widget_get_allocation (avatar_widget, &allocation);
size = allocation.height;
}
init_contact_avatar_with_size (contact, avatar_widget, size);
-}
-static void
-empathy_call_window_got_self_contact_cb (TpConnection *connection,
- EmpathyContact *contact, const GError *error, gpointer user_data,
- GObject *weak_object)
-{
- EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
- EmpathyCallWindowPriv *priv = GET_PRIV (self);
+ avatar_widget = self->priv->remote_user_avatar_toolbar;
+
+ gtk_widget_get_allocation (avatar_widget, &allocation);
+ size = allocation.height;
- init_contact_avatar_with_size (contact, priv->self_user_avatar_widget,
- MIN (SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGTH));
+ if (size == 0)
+ {
+ /* the widget is not allocated yet, set a default size */
+ size = SMALL_TOOLBAR_SIZE;
+ }
- g_signal_connect (contact, "notify::avatar",
- G_CALLBACK (contact_avatar_changed_cb), priv->self_user_avatar_widget);
+ init_contact_avatar_with_size (contact, avatar_widget, size);
}
static void
EmpathyCallHandler *handler)
{
EmpathyCallWindowPriv *priv = GET_PRIV (self);
- TpConnection *connection;
-
- g_signal_connect (priv->contact, "notify::name",
- G_CALLBACK (contact_name_changed_cb), self);
- g_signal_connect (priv->contact, "notify::avatar",
- G_CALLBACK (contact_avatar_changed_cb),
- priv->remote_user_avatar_widget);
- /* Retrieving the self avatar */
- connection = empathy_contact_get_connection (priv->contact);
- empathy_tp_contact_factory_get_from_handle (connection,
- tp_connection_get_self_handle (connection),
- empathy_call_window_got_self_contact_cb, self, NULL,
- G_OBJECT (self));
+ tp_g_signal_connect_object (priv->contact, "notify::name",
+ G_CALLBACK (contact_name_changed_cb), self, 0);
+ tp_g_signal_connect_object (priv->contact, "notify::avatar",
+ G_CALLBACK (contact_avatar_changed_cb), self, 0);
+ tp_g_signal_connect_object (priv->contact, "notify::presence",
+ G_CALLBACK (contact_presence_changed_cb), self, 0);
set_window_title (self);
+ set_remote_user_name (self, priv->contact);
init_contact_avatar_with_size (priv->contact,
priv->remote_user_avatar_widget,
MIN (REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH,
REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT));
+ init_contact_avatar_with_size (priv->contact,
+ priv->remote_user_avatar_toolbar,
+ SMALL_TOOLBAR_SIZE);
+
/* The remote avatar is shown by default and will be hidden when we receive
video from the remote side. */
- gtk_widget_hide (priv->video_output);
+ clutter_actor_hide (priv->video_output);
gtk_widget_show (priv->remote_user_avatar_widget);
}
if (!empathy_call_handler_has_initial_video (priv->handler))
{
gtk_toggle_tool_button_set_active (
- GTK_TOGGLE_TOOL_BUTTON (priv->tool_button_camera_off), TRUE);
+ GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), FALSE);
}
/* If call has InitialVideo, the preview will be started once the call has
* been started (start_call()). */
priv->bus_message_source_id = 0;
}
+ if (priv->got_video_src > 0)
+ {
+ g_source_remove (priv->got_video_src);
+ priv->got_video_src = 0;
+ }
+
tp_clear_object (&priv->pipeline);
tp_clear_object (&priv->video_input);
tp_clear_object (&priv->audio_input);
- tp_clear_object (&priv->audio_output);
tp_clear_object (&priv->video_tee);
tp_clear_object (&priv->ui_manager);
tp_clear_object (&priv->fullscreen);
+ tp_clear_object (&priv->camera_monitor);
+ tp_clear_object (&priv->settings);
g_list_free_full (priv->notifiers, g_object_unref);
- if (priv->liveadder != NULL)
- gst_object_unref (priv->liveadder);
- priv->liveadder = NULL;
-
if (priv->timer_id != 0)
g_source_remove (priv->timer_id);
priv->timer_id = 0;
if (priv->video_output_motion_handler_id != 0)
{
- g_signal_handler_disconnect (G_OBJECT (priv->video_output),
+ g_signal_handler_disconnect (G_OBJECT (priv->video_container),
priv->video_output_motion_handler_id);
priv->video_output_motion_handler_id = 0;
}
FsElementAddedNotifier *notifier;
GKeyFile *keyfile;
- g_debug ("Conference added");
+ DEBUG ("Conference added");
/* Add notifier to set the various element properties as needed */
notifier = fs_element_added_notifier_new ();
g_object_unref (priv->pipeline);
priv->pipeline = NULL;
- g_signal_handlers_disconnect_by_func (priv->audio_input_adj,
- empathy_call_window_mic_volume_changed_cb, self);
+ if (priv->audio_output != NULL)
+ g_object_unref (priv->audio_output);
+ priv->audio_output = NULL;
if (priv->video_tee != NULL)
g_object_unref (priv->video_tee);
priv->video_tee = NULL;
if (priv->video_preview != NULL)
- gtk_widget_destroy (priv->video_preview);
+ clutter_actor_destroy (priv->video_preview);
priv->video_preview = NULL;
- priv->liveadder = NULL;
priv->funnel = NULL;
create_pipeline (self);
gtk_window_unfullscreen (GTK_WINDOW (self));
gtk_action_set_sensitive (priv->menu_fullscreen, FALSE);
+ gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
could_reset_pipeline = empathy_call_window_reset_pipeline (self);
empathy_call_window_status_message (self, _("Disconnected"));
- gtk_action_set_sensitive (priv->redial, TRUE);
- gtk_widget_set_sensitive (priv->redial_button, TRUE);
+ empathy_call_window_show_hangup_button (self, FALSE);
/* Unsensitive the camera and mic button */
- gtk_widget_set_sensitive (priv->tool_button_camera_on, FALSE);
- gtk_action_set_sensitive (priv->action_camera_on, FALSE);
+ gtk_widget_set_sensitive (priv->camera_button, FALSE);
gtk_widget_set_sensitive (priv->mic_button, FALSE);
/* Be sure that the mic button is enabled */
GTK_TOGGLE_TOOL_BUTTON (priv->mic_button), TRUE);
if (priv->camera_state == CAMERA_STATE_ON)
- {
- /* Enable the 'preview' button as we are not sending atm. */
- gtk_toggle_tool_button_set_active (
- GTK_TOGGLE_TOOL_BUTTON (priv->tool_button_camera_preview), TRUE);
- }
- else if (priv->camera_state == CAMERA_STATE_PREVIEW)
{
/* Restart the preview with the new pipeline. */
display_video_preview (self, TRUE);
}
- gtk_progress_bar_set_fraction (
- GTK_PROGRESS_BAR (priv->volume_progress_bar), 0);
-
/* destroy the video output; it will be recreated when we'll redial */
disconnect_video_output_motion_handler (self);
- gtk_widget_destroy (priv->video_output);
+ if (priv->video_output != NULL)
+ clutter_actor_destroy (priv->video_output);
priv->video_output = NULL;
+ if (priv->got_video_src > 0)
+ {
+ g_source_remove (priv->got_video_src);
+ priv->got_video_src = 0;
+ }
gtk_widget_show (priv->remote_user_avatar_widget);
{
EmpathyCallWindowPriv *priv = GET_PRIV (self);
- g_print ("window: removing content\n");
+ DEBUG ("removing content");
/*
* This assumes that there is only one video stream per channel...
{
GstElement *output;
- output = empathy_video_widget_get_element (EMPATHY_VIDEO_WIDGET
- (priv->video_output));
+ output = priv->video_output_sink;
gst_element_set_state (output, GST_STATE_NULL);
gst_element_set_state (priv->funnel, GST_STATE_NULL);
}
else if (media_type == FS_MEDIA_TYPE_AUDIO)
{
- if (priv->liveadder != NULL)
+ if (priv->audio_output != NULL)
{
gst_element_set_state (priv->audio_output, GST_STATE_NULL);
- gst_element_set_state (priv->liveadder, GST_STATE_NULL);
gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
- gst_bin_remove (GST_BIN (priv->pipeline), priv->liveadder);
- priv->liveadder = NULL;
+ priv->audio_output = NULL;
return TRUE;
}
}
if (priv->funnel == NULL)
{
- output = empathy_video_widget_get_element (EMPATHY_VIDEO_WIDGET
- (priv->video_output));
+ output = priv->video_output_sink;
priv->funnel = gst_element_factory_make ("fsfunnel", NULL);
{
EmpathyCallWindowPriv *priv = GET_PRIV (self);
GstPad *pad;
- GstElement *filter;
- GError *gerror = NULL;
+ GstPadTemplate *template;
- if (priv->liveadder == NULL)
+ if (priv->audio_output == NULL)
{
- priv->liveadder = gst_element_factory_make ("liveadder", NULL);
+ priv->audio_output = empathy_audio_sink_new ();
+ g_object_ref_sink (priv->audio_output);
- if (!gst_bin_add (GST_BIN (priv->pipeline), priv->liveadder))
- {
- g_warning ("Could not add liveadder to the pipeline");
- goto error_add_liveadder;
- }
if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_output))
{
g_warning ("Could not add audio sink to pipeline");
+ g_object_unref (priv->audio_output);
goto error_add_output;
}
- if (gst_element_set_state (priv->liveadder, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
- {
- g_warning ("Could not start liveadder");
- goto error;
- }
-
if (gst_element_set_state (priv->audio_output, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
{
g_warning ("Could not start audio sink");
goto error;
}
-
- if (GST_PAD_LINK_FAILED (
- gst_element_link (priv->liveadder, priv->audio_output)))
- {
- g_warning ("Could not link liveadder to audio output");
- goto error;
- }
- }
-
- filter = gst_parse_bin_from_description (
- "audioconvert ! audioresample ! audioconvert", TRUE, &gerror);
- if (filter == NULL)
- {
- g_warning ("Could not make audio conversion filter: %s", gerror->message);
- g_clear_error (&gerror);
- goto error;
- }
-
- if (!gst_bin_add (GST_BIN (priv->pipeline), filter))
- {
- g_warning ("Could not add audio conversion filter to pipeline");
- gst_object_unref (filter);
- goto error;
- }
-
- if (gst_element_set_state (filter, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
- {
- g_warning ("Could not start audio conversion filter");
- goto error_filter;
}
- if (!gst_element_link (filter, priv->liveadder))
- {
- g_warning ("Could not link audio conversion filter to liveadder");
- goto error_filter;
- }
+ template = gst_element_class_get_pad_template (
+ GST_ELEMENT_GET_CLASS (priv->audio_output), "sink%d");
- pad = gst_element_get_static_pad (filter, "sink");
+ pad = gst_element_request_pad (priv->audio_output,
+ template, NULL, NULL);
if (pad == NULL)
{
- g_warning ("Could not get sink pad from filter");
- goto error_filter;
+ g_warning ("Could not get sink pad from sink");
+ return NULL;
}
return pad;
- error_filter:
-
- gst_element_set_locked_state (filter, TRUE);
- gst_element_set_state (filter, GST_STATE_NULL);
- gst_bin_remove (GST_BIN (priv->pipeline), filter);
-
- error:
-
- gst_element_set_locked_state (priv->liveadder, TRUE);
+error:
gst_element_set_locked_state (priv->audio_output, TRUE);
-
- gst_element_set_state (priv->liveadder, GST_STATE_NULL);
gst_element_set_state (priv->audio_output, GST_STATE_NULL);
-
gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
+ priv->audio_output = NULL;
- error_add_output:
-
- gst_bin_remove (GST_BIN (priv->pipeline), priv->liveadder);
-
- gst_element_set_locked_state (priv->liveadder, FALSE);
- gst_element_set_locked_state (priv->audio_output, FALSE);
-
- error_add_liveadder:
-
- if (priv->liveadder != NULL)
- {
- gst_object_unref (priv->liveadder);
- priv->liveadder = NULL;
- }
+error_add_output:
return NULL;
}
time_ = g_timer_elapsed (priv->timer, NULL);
- /* Translators: number of minutes:seconds the caller has been connected */
- str = g_strdup_printf (_("Connected — %d:%02dm"), (int) time_ / 60,
- (int) time_ % 60);
+ /* Translators: 'status - minutes:seconds' the caller has been connected */
+ str = g_strdup_printf (_("%s — %d:%02dm"),
+ priv->call_state == HELD ? _("On hold") : _("Connected"),
+ (int) time_ / 60, (int) time_ % 60);
empathy_call_window_status_message (self, str);
g_free (str);
}
#endif
-static gboolean
-empathy_call_window_connected (gpointer user_data)
+static void
+empathy_call_window_state_changed_cb (EmpathyCallHandler *handler,
+ TpyCallState state,
+ EmpathyCallWindow *self)
{
- EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
EmpathyCallWindowPriv *priv = GET_PRIV (self);
TpyCallChannel *call;
gboolean can_send_video;
- empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
+ if (state != TPY_CALL_STATE_ACCEPTED)
+ return;
+
+ if (priv->call_state == CONNECTED)
+ return;
+ g_timer_start (priv->timer);
+ priv->call_state = CONNECTED;
+
+ empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING);
can_send_video = priv->video_input != NULL &&
- empathy_contact_can_voip_video (priv->contact);
+ empathy_contact_can_voip_video (priv->contact) &&
+ empathy_camera_monitor_get_available (priv->camera_monitor);
g_object_get (priv->handler, "call-channel", &call, NULL);
if (priv->video_input == NULL)
empathy_call_window_set_send_video (self, CAMERA_STATE_OFF);
- priv->sending_video = can_send_video &&
- empathy_call_handler_has_initial_video (priv->handler);
-
- gtk_toggle_tool_button_set_active (
- GTK_TOGGLE_TOOL_BUTTON (priv->tool_button_camera_on),
- priv->sending_video && priv->video_input != NULL);
- gtk_widget_set_sensitive (priv->tool_button_camera_on, can_send_video);
- gtk_action_set_sensitive (priv->action_camera_on, can_send_video);
+ gtk_widget_set_sensitive (priv->camera_button, can_send_video);
- gtk_action_set_sensitive (priv->redial, FALSE);
- gtk_widget_set_sensitive (priv->redial_button, FALSE);
+ empathy_call_window_show_hangup_button (self, TRUE);
gtk_widget_set_sensitive (priv->mic_button, TRUE);
- gtk_widget_hide (priv->video_output);
+ clutter_actor_hide (priv->video_output);
gtk_widget_show (priv->remote_user_avatar_widget);
g_object_unref (call);
empathy_call_window_update_timer (self);
gtk_action_set_sensitive (priv->menu_fullscreen, TRUE);
+}
+
+static gboolean
+empathy_call_window_show_video_output_cb (gpointer user_data)
+{
+ EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
+
+ if (self->priv->video_output != NULL)
+ {
+ gtk_widget_hide (self->priv->remote_user_avatar_widget);
+ clutter_actor_show (self->priv->video_output);
+ }
return FALSE;
}
+static gboolean
+empathy_call_window_check_video_cb (gpointer data)
+{
+ EmpathyCallWindow *self = data;
+
+ if (self->priv->got_video)
+ {
+ self->priv->got_video = FALSE;
+ return TRUE;
+ }
+
+ /* No video in the last N seconds, display the remote avatar */
+ empathy_call_window_show_video_output (self, FALSE);
+
+ return TRUE;
+}
+
+/* Called from the streaming thread */
+static gboolean
+empathy_call_window_video_probe_cb (GstPad *pad,
+ GstMiniObject *mini_obj,
+ EmpathyCallWindow *self)
+{
+ /* Ignore events */
+ if (GST_IS_EVENT (mini_obj))
+ return TRUE;
+
+ if (G_UNLIKELY (!self->priv->got_video))
+ {
+ /* show the remote video */
+ g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
+ empathy_call_window_show_video_output_cb,
+ g_object_ref (self), g_object_unref);
+
+ self->priv->got_video = TRUE;
+ }
+
+ return TRUE;
+}
/* Called from the streaming thread */
static gboolean
g_mutex_lock (priv->lock);
- if (priv->call_state != CONNECTED)
- {
- g_timer_start (priv->timer);
- priv->timer_id = g_idle_add (empathy_call_window_connected, self);
- priv->call_state = CONNECTED;
- }
-
switch (media_type)
{
case TP_MEDIA_STREAM_TYPE_AUDIO:
pad = empathy_call_window_get_audio_sink_pad (self);
break;
case TP_MEDIA_STREAM_TYPE_VIDEO:
- gtk_widget_hide (priv->remote_user_avatar_widget);
- gtk_widget_show (priv->video_output);
+ g_idle_add (empathy_call_window_show_video_output_cb, self);
pad = empathy_call_window_get_video_sink_pad (self);
+
+ gst_pad_add_data_probe (src,
+ G_CALLBACK (empathy_call_window_video_probe_cb), self);
+ if (priv->got_video_src > 0)
+ g_source_remove (priv->got_video_src);
+ priv->got_video_src = g_timeout_add_seconds (5,
+ empathy_call_window_check_video_cb, self);
break;
default:
g_assert_not_reached ();
}
else
{
- g_debug ("Could not link real sink, linked fakesink instead");
+ DEBUG ("Could not link real sink, linked fakesink instead");
}
gst_object_unref (sinkpad);
}
retval = TRUE;
break;
case FS_MEDIA_TYPE_VIDEO:
- if (priv->video_input != NULL)
+ if (priv->video_tee != NULL)
{
- if (priv->video_tee != NULL)
+ pad = gst_element_get_request_pad (priv->video_tee, "src%d");
+ if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
{
- pad = gst_element_get_request_pad (priv->video_tee, "src%d");
- if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
- {
- g_warning ("Could not link video source input pipeline");
- break;
- }
- gst_object_unref (pad);
+ g_warning ("Could not link video source input pipeline");
+ break;
}
-
- retval = TRUE;
+ gst_object_unref (pad);
}
+
+ retval = TRUE;
break;
default:
g_assert_not_reached ();
disable_camera (self);
DEBUG ("remove video input");
- preview = empathy_video_widget_get_element (
- EMPATHY_VIDEO_WIDGET (priv->video_preview));
+ preview = priv->video_preview_sink;
gst_element_set_state (priv->video_input, GST_STATE_NULL);
gst_element_set_state (priv->video_tee, GST_STATE_NULL);
gst_element_set_state (preview, GST_STATE_NULL);
gst_bin_remove_many (GST_BIN (priv->pipeline), priv->video_input,
- priv->video_tee, preview, NULL);
+ preview, NULL);
g_object_unref (priv->video_input);
priv->video_input = NULL;
g_object_unref (priv->video_tee);
priv->video_tee = NULL;
- gtk_widget_destroy (priv->video_preview);
+ clutter_actor_destroy (priv->video_preview);
priv->video_preview = NULL;
- gtk_widget_set_sensitive (priv->tool_button_camera_on, FALSE);
- gtk_action_set_sensitive (priv->action_camera_on, FALSE);
- gtk_widget_set_sensitive (priv->tool_button_camera_preview, FALSE);
+ gtk_widget_set_sensitive (priv->camera_button, FALSE);
}
static void
if (empathy_call_handler_has_initial_video (priv->handler))
{
- /* Enable 'send video' buttons and display the preview */
- gtk_toggle_tool_button_set_active (
- GTK_TOGGLE_TOOL_BUTTON (priv->tool_button_camera_on), TRUE);
+ TpyCallChannel *call;
+ TpySendingState s;
+
+ g_object_get (priv->handler, "call-channel", &call, NULL);
+ s = tpy_call_channel_get_video_state (call);
+
+ if (s == TPY_SENDING_STATE_PENDING_SEND ||
+ s == TPY_SENDING_STATE_SENDING)
+ {
+ /* Enable 'send video' buttons and display the preview */
+ gtk_toggle_tool_button_set_active (
+ GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), TRUE);
+ }
+ else
+ {
+ gtk_toggle_tool_button_set_active (
+ GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), FALSE);
+
+ if (priv->video_preview == NULL)
+ {
+ create_video_preview (self);
+ add_video_preview_to_pipeline (self);
+ }
+ }
+
+ g_object_unref (call);
}
}
if (GST_MESSAGE_SRC (message) == GST_OBJECT (priv->video_input))
{
gst_message_parse_state_changed (message, NULL, &newstate, NULL);
- if (newstate == GST_STATE_PAUSED)
- empathy_call_window_setup_video_input (self);
}
if (GST_MESSAGE_SRC (message) == GST_OBJECT (priv->pipeline) &&
!priv->call_started)
return TRUE;
}
+static void
+empathy_call_window_members_changed_cb (TpyCallChannel *call,
+ GHashTable *members,
+ EmpathyCallWindow *self)
+{
+ EmpathyCallWindowPriv *priv = GET_PRIV (self);
+ GHashTableIter iter;
+ gpointer key, value;
+ gboolean held = FALSE;
+
+ g_hash_table_iter_init (&iter, members);
+ while (g_hash_table_iter_next (&iter, &key, &value))
+ {
+ if (GPOINTER_TO_INT (value) & TPY_CALL_MEMBER_FLAG_HELD)
+ {
+ /* This assumes this is a 1-1 call, otherwise one participant
+ * putting the call on hold wouldn't mean the call is on hold
+ * for everyone. */
+ held = TRUE;
+ break;
+ }
+ }
+
+ if (held)
+ priv->call_state = HELD;
+ else if (priv->call_state == HELD)
+ priv->call_state = CONNECTED;
+}
+
static void
call_handler_notify_call_cb (EmpathyCallHandler *handler,
GParamSpec *spec,
tp_g_signal_connect_object (call, "video-stream-error",
G_CALLBACK (empathy_call_window_video_stream_error), self, 0);
*/
+
+ tp_g_signal_connect_object (call, "members-changed",
+ G_CALLBACK (empathy_call_window_members_changed_cb), self, 0);
+
g_object_unref (call);
}
{
EmpathyCallWindowPriv *priv = GET_PRIV (window);
TpyCallChannel *call;
+ gint width;
+
+ /* Make the hangup button twice as wide */
+ width = gtk_widget_get_allocated_width (priv->hangup_button);
+ gtk_widget_set_size_request (priv->hangup_button, width * 2, -1);
+ g_signal_connect (priv->handler, "state-changed",
+ G_CALLBACK (empathy_call_window_state_changed_cb), window);
g_signal_connect (priv->handler, "conference-added",
G_CALLBACK (empathy_call_window_conference_added_cb), window);
g_signal_connect (priv->handler, "conference-removed",
g_object_get (priv->handler, "call-channel", &call, NULL);
if (call != NULL)
{
-/* FIXME: part of the improvements for DRAFT2
- tp_g_signal_connect_object (call, "audio-stream-error",
- G_CALLBACK (empathy_call_window_audio_stream_error), window,
- 0);
- tp_g_signal_connect_object (call, "video-stream-error",
- G_CALLBACK (empathy_call_window_video_stream_error), window,
- 0);
-*/
+ call_handler_notify_call_cb (priv->handler, NULL, window);
g_object_unref (call);
}
else
if (set_fullscreen)
{
- gtk_widget_hide (priv->sidebar);
+ gtk_widget_hide (priv->dtmf_panel);
gtk_widget_hide (menu);
- gtk_widget_hide (priv->vbox);
- gtk_widget_hide (priv->statusbar);
gtk_widget_hide (priv->toolbar);
}
else
{
- if (priv->sidebar_was_visible_before_fs)
- gtk_widget_show (priv->sidebar);
+ if (priv->dialpad_was_visible_before_fs)
+ gtk_widget_show (priv->dtmf_panel);
gtk_widget_show (menu);
- gtk_widget_show (priv->vbox);
- gtk_widget_show (priv->statusbar);
gtk_widget_show (priv->toolbar);
gtk_window_resize (GTK_WINDOW (window), priv->original_width_before_fs,
if (priv->video_output != NULL)
{
+#if 0
gtk_box_set_child_packing (GTK_BOX (priv->content_hbox),
priv->video_output, TRUE, TRUE,
set_fullscreen ? 0 : CONTENT_HBOX_CHILDREN_PACKING_PADDING,
GTK_PACK_START);
+#endif
}
-
- gtk_box_set_child_packing (GTK_BOX (priv->content_hbox),
- priv->vbox, TRUE, TRUE,
- set_fullscreen ? 0 : CONTENT_HBOX_CHILDREN_PACKING_PADDING,
- GTK_PACK_START);
}
static gboolean
if (set_fullscreen)
{
- gboolean sidebar_was_visible;
+ gboolean dialpad_was_visible;
GtkAllocation allocation;
gint original_width, original_height;
original_width = allocation.width;
original_height = allocation.height;
- g_object_get (priv->sidebar, "visible", &sidebar_was_visible, NULL);
+ g_object_get (priv->dtmf_panel,
+ "visible", &dialpad_was_visible,
+ NULL);
- priv->sidebar_was_visible_before_fs = sidebar_was_visible;
+ priv->dialpad_was_visible_before_fs = dialpad_was_visible;
priv->original_width_before_fs = original_width;
priv->original_height_before_fs = original_height;
priv->video_output != NULL)
{
priv->video_output_motion_handler_id = g_signal_connect (
- G_OBJECT (priv->video_output), "motion-notify-event",
+ G_OBJECT (priv->video_container), "motion-notify-event",
G_CALLBACK (empathy_call_window_video_output_motion_notify),
window);
}
}
static void
-empathy_call_window_sidebar_toggled_cb (GtkToggleButton *toggle,
- EmpathyCallWindow *window)
+empathy_call_window_show_dialpad (EmpathyCallWindow *window,
+ gboolean active)
{
EmpathyCallWindowPriv *priv = GET_PRIV (window);
- GtkWidget *arrow;
- int w, h, handle_size;
- GtkAllocation allocation, sidebar_allocation;
+ int w, h, dialpad_width;
+ GtkAllocation allocation;
gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
w = allocation.width;
h = allocation.height;
- gtk_widget_style_get (priv->pane, "handle_size", &handle_size, NULL);
+ gtk_widget_get_preferred_width (priv->dtmf_panel, &dialpad_width, NULL);
- gtk_widget_get_allocation (priv->sidebar, &sidebar_allocation);
- if (gtk_toggle_button_get_active (toggle))
+ if (active)
{
- arrow = gtk_arrow_new (GTK_ARROW_LEFT, GTK_SHADOW_NONE);
- gtk_widget_show (priv->sidebar);
- w += sidebar_allocation.width + handle_size;
+ gtk_widget_show (priv->dtmf_panel);
+ w += dialpad_width;
}
else
{
- arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
- w -= sidebar_allocation.width + handle_size;
- gtk_widget_hide (priv->sidebar);
+ w -= dialpad_width;
+ gtk_widget_hide (priv->dtmf_panel);
}
- gtk_button_set_image (GTK_BUTTON (priv->sidebar_button), arrow);
-
if (w > 0 && h > 0)
gtk_window_resize (GTK_WINDOW (window), w, h);
}
priv->sending_video = (state == CAMERA_STATE_ON);
- if (state == CAMERA_STATE_PREVIEW ||
- state == CAMERA_STATE_ON)
+ if (state == CAMERA_STATE_ON)
{
/* When we start sending video, we want to show the video preview by
default. */
if (active)
{
- empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
- priv->volume);
- gtk_adjustment_set_value (priv->audio_input_adj, priv->volume * 100);
+ g_settings_set_double (priv->settings, EMPATHY_PREFS_CALL_SOUND_VOLUME,
+ priv->volume * 100);
}
else
{
* sides mute at the same time on certain CMs AFAIK. Need to revisit this
* in the future. GNOME #574574
*/
- empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
- 0);
- gtk_adjustment_set_value (priv->audio_input_adj, 0);
+ g_settings_set_double (priv->settings, EMPATHY_PREFS_CALL_SOUND_VOLUME,
+ 0);
}
}
-static void
-empathy_call_window_sidebar_hidden_cb (EvSidebar *sidebar,
- EmpathyCallWindow *window)
-{
- EmpathyCallWindowPriv *priv = GET_PRIV (window);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->sidebar_button),
- FALSE);
-}
-
-static void
-empathy_call_window_sidebar_shown_cb (EvSidebar *sidebar,
- EmpathyCallWindow *window)
-{
- EmpathyCallWindowPriv *priv = GET_PRIV (window);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->sidebar_button),
- TRUE);
-}
-
static void
empathy_call_window_hangup_cb (gpointer object,
EmpathyCallWindow *window)
create_video_output_widget (window);
- g_signal_connect (G_OBJECT (priv->audio_input_adj), "value-changed",
- G_CALLBACK (empathy_call_window_mic_volume_changed_cb), window);
-
/* While the call was disconnected, the input volume might have changed.
* However, since the audio_input source was destroyed, its volume has not
* been updated during that time. That's why we manually update it here */
- empathy_call_window_mic_volume_changed_cb (priv->audio_input_adj, window);
+ empathy_call_window_mic_volume_changed (window);
priv->outgoing = TRUE;
empathy_call_window_set_state_connecting (window);
/* call will be started when the pipeline is ready */
priv->start_call_when_playing = TRUE;
-
empathy_call_window_setup_avatars (window, priv->handler);
- gtk_action_set_sensitive (priv->redial, FALSE);
- gtk_widget_set_sensitive (priv->redial_button, FALSE);
+ empathy_call_window_show_hangup_button (window, TRUE);
}
static void
-empathy_call_window_redial_cb (gpointer object,
+empathy_call_window_dialpad_cb (GtkToggleToolButton *button,
EmpathyCallWindow *window)
{
- EmpathyCallWindowPriv *priv = GET_PRIV (window);
-
- if (priv->call_state == CONNECTED)
- priv->call_state = REDIALING;
+ gboolean active;
- empathy_call_handler_stop_call (priv->handler);
+ active = gtk_toggle_tool_button_get_active (button);
- if (priv->call_state != CONNECTED)
- empathy_call_window_restart_call (window);
+ empathy_call_window_show_dialpad (window, active);
}
static void
}
static gboolean
-empathy_call_window_video_button_press_cb (GtkWidget *video_output,
+empathy_call_window_video_button_press_cb (GtkWidget *video_preview,
GdkEventButton *event, EmpathyCallWindow *window)
{
if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
}
static void
-empathy_call_window_status_message (EmpathyCallWindow *window,
+empathy_call_window_status_message (EmpathyCallWindow *self,
gchar *message)
{
- EmpathyCallWindowPriv *priv = GET_PRIV (window);
-
- if (priv->context_id == 0)
- {
- priv->context_id = gtk_statusbar_get_context_id (
- GTK_STATUSBAR (priv->statusbar), "voip call status messages");
- }
- else
- {
- gtk_statusbar_pop (GTK_STATUSBAR (priv->statusbar), priv->context_id);
- }
-
- gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar), priv->context_id,
- message);
+ gtk_label_set_label (GTK_LABEL (self->priv->status_label), message);
}
static void
empathy_audio_sink_set_volume (EMPATHY_GST_AUDIO_SINK (priv->audio_output),
value);
}
-
-/* block all the signals related to camera control widgets. This is useful
- * when we are manually updating the UI and so don't want to fire the
- * callbacks */
-static void
-block_camera_control_signals (EmpathyCallWindow *self)
-{
- EmpathyCallWindowPriv *priv = GET_PRIV (self);
-
- g_signal_handlers_block_by_func (priv->tool_button_camera_off,
- tool_button_camera_off_toggled_cb, self);
- g_signal_handlers_block_by_func (priv->tool_button_camera_preview,
- tool_button_camera_preview_toggled_cb, self);
- g_signal_handlers_block_by_func (priv->tool_button_camera_on,
- tool_button_camera_on_toggled_cb, self);
- g_signal_handlers_block_by_func (priv->action_camera_on,
- action_camera_change_cb, self);
-}
-
-static void
-unblock_camera_control_signals (EmpathyCallWindow *self)
-{
- EmpathyCallWindowPriv *priv = GET_PRIV (self);
-
- g_signal_handlers_unblock_by_func (priv->tool_button_camera_off,
- tool_button_camera_off_toggled_cb, self);
- g_signal_handlers_unblock_by_func (priv->tool_button_camera_preview,
- tool_button_camera_preview_toggled_cb, self);
- g_signal_handlers_unblock_by_func (priv->tool_button_camera_on,
- tool_button_camera_on_toggled_cb, self);
- g_signal_handlers_unblock_by_func (priv->action_camera_on,
- action_camera_change_cb, self);
-}