]> git.0d.be Git - empathy.git/blobdiff - src/empathy-call-window.c
Merge branch 'gnome-3-4'
[empathy.git] / src / empathy-call-window.c
index 7577abd1179ec7fcd02327b1eca1bb377f7c625f..d9641fdf95e8a7aa062116039976b66a7ebf7a69 100644 (file)
@@ -43,7 +43,6 @@
 
 #include <libempathy/empathy-camera-monitor.h>
 #include <libempathy/empathy-gsettings.h>
-#include <libempathy/empathy-tp-contact-factory.h>
 #include <libempathy/empathy-request-util.h>
 #include <libempathy/empathy-utils.h>
 
@@ -61,7 +60,6 @@
 #include "empathy-call-window.h"
 #include "empathy-call-window-fullscreen.h"
 #include "empathy-call-factory.h"
-#include "empathy-video-widget.h"
 #include "empathy-about-dialog.h"
 #include "empathy-audio-src.h"
 #include "empathy-audio-sink.h"
@@ -77,6 +75,9 @@
 #define CONTENT_HBOX_CHILDREN_PACKING_PADDING 0
 #define OVERLAY_MARGIN 6
 
+#define REMOTE_VIDEO_DEFAULT_WIDTH 320
+#define REMOTE_VIDEO_DEFAULT_HEIGHT 240
+
 #define SELF_VIDEO_SECTION_WIDTH 120
 #define SELF_VIDEO_SECTION_HEIGHT 90
 #define SELF_VIDEO_SECTION_MARGIN 2
@@ -87,9 +88,8 @@
 
 /* The avatar's default width and height are set to the same value because we
    want a square icon. */
-#define REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH EMPATHY_VIDEO_WIDGET_DEFAULT_HEIGHT
-#define REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT \
-  EMPATHY_VIDEO_WIDGET_DEFAULT_HEIGHT
+#define REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT REMOTE_VIDEO_DEFAULT_HEIGHT
+#define REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH REMOTE_VIDEO_DEFAULT_HEIGHT
 
 #define SMALL_TOOLBAR_SIZE 36
 
@@ -183,9 +183,9 @@ struct _EmpathyCallWindowPriv
   ClutterActor *video_box;
   ClutterLayoutManager *video_layout;
 
-  /* A Box layout manager containing a bin for previews
+  /* A bin layout manager containing a bin for previews
    * and the floating toolbar */
-  ClutterActor *overlay_box;
+  ClutterActor *overlay_bin;
   ClutterLayoutManager *overlay_layout;
 
   /* Bin layout for the previews */
@@ -243,7 +243,7 @@ struct _EmpathyCallWindowPriv
   GTimer *timer;
   guint timer_id;
 
-  GMutex *lock;
+  GMutex lock;
   gboolean call_started;
   gboolean sending_video;
   CameraState camera_state;
@@ -275,6 +275,8 @@ struct _EmpathyCallWindowPriv
   GSettings *settings;
   EmpathyMicMenu *mic_menu;
   EmpathyCameraMenu *camera_menu;
+
+  gboolean muted;
 };
 
 #define GET_PRIV(o) (EMPATHY_CALL_WINDOW (o)->priv)
@@ -324,6 +326,8 @@ static void empathy_call_window_status_message (EmpathyCallWindow *window,
 static gboolean empathy_call_window_bus_message (GstBus *bus,
   GstMessage *message, gpointer user_data);
 
+static gboolean empathy_call_window_update_timer (gpointer user_data);
+
 static void
 make_background_transparent (GtkClutterActor *actor)
 {
@@ -386,7 +390,7 @@ empathy_call_window_show_video_output (EmpathyCallWindow *self,
 
   gtk_widget_set_visible (self->priv->remote_user_avatar_widget, !show);
 
-  clutter_actor_raise_top (self->priv->overlay_box);
+  clutter_actor_raise_top (self->priv->overlay_bin);
 }
 
 static void
@@ -461,6 +465,20 @@ element_volume_to_audio_control (GBinding *binding,
   return TRUE;
 }
 
+static void
+audio_input_mute_notify_cb (GObject *obj, GParamSpec *spec,
+  EmpathyCallWindow *self)
+{
+  gboolean muted;
+  g_object_get (obj, "mute", &muted, NULL);
+
+  self->priv->muted = muted;
+  if (muted && self->priv->transitions)
+    clutter_state_set_state (self->priv->transitions, "fade-in");
+
+  empathy_call_window_update_timer (self);
+}
+
 static void
 create_audio_input (EmpathyCallWindow *self)
 {
@@ -470,10 +488,14 @@ create_audio_input (EmpathyCallWindow *self)
   priv->audio_input = empathy_audio_src_new ();
   gst_object_ref_sink (priv->audio_input);
 
+  g_signal_connect (priv->audio_input, "notify::mute",
+    G_CALLBACK (audio_input_mute_notify_cb), self);
+
   g_object_bind_property (priv->mic_button, "active",
     priv->audio_input, "mute",
     G_BINDING_BIDIRECTIONAL |
       G_BINDING_INVERT_BOOLEAN | G_BINDING_SYNC_CREATE);
+
 }
 
 static void
@@ -654,9 +676,9 @@ empathy_call_window_create_preview_rectangles (EmpathyCallWindow *self)
       CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER);
   self->priv->preview_box = box = clutter_box_new (self->priv->preview_layout);
 
-  clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (self->priv->overlay_layout),
-      box, TRUE, TRUE, TRUE,
-      CLUTTER_BOX_ALIGNMENT_CENTER, CLUTTER_BOX_ALIGNMENT_START);
+  clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (self->priv->overlay_layout),
+      box,
+      CLUTTER_BIN_ALIGNMENT_FILL, CLUTTER_BIN_ALIGNMENT_FILL);
 
   self->priv->preview_rectangle1 =
       empathy_call_window_create_preview_rectangle (self,
@@ -844,51 +866,28 @@ empathy_call_window_move_video_preview (EmpathyCallWindow *self,
   g_settings_set_enum (self->priv->settings, "camera-position", pos);
 }
 
-static void
-_clutter_color_from_rgba (ClutterColor *color,
-                          const GdkRGBA *rgba)
-{
-  color->red = (guint8) floor (rgba->red * 255);
-  color->green = (guint8) floor (rgba->green * 255);
-  color->blue = (guint8) floor (rgba->blue * 255);
-  color->alpha = (guint8) floor (rgba->alpha * 255);
-}
-
 static void
 empathy_call_window_highlight_preview_rectangle (EmpathyCallWindow *self,
     PreviewPosition pos)
 {
   ClutterActor *rectangle;
-  GtkStyleContext *context;
-  GdkRGBA rgba;
-  ClutterColor color, highlight;
+  ClutterColor white = { 0xff, 0xff, 0xff, 0xff};
 
   rectangle = empathy_call_window_get_preview_rectangle (self, pos);
-  context = gtk_widget_get_style_context (GTK_WIDGET (self));
-  gtk_style_context_get_color (context, 0, &rgba);
-
-  _clutter_color_from_rgba (&color, &rgba);
-  clutter_color_shade (&color, 1.4, &highlight);
 
   empathy_rounded_rectangle_set_border_width (
       EMPATHY_ROUNDED_RECTANGLE (rectangle), 2 * SELF_VIDEO_SECTION_MARGIN);
   empathy_rounded_rectangle_set_border_color (
-      EMPATHY_ROUNDED_RECTANGLE (rectangle), &highlight);
+      EMPATHY_ROUNDED_RECTANGLE (rectangle), &white);
 }
 
 static void
 empathy_call_window_darken_preview_rectangle (EmpathyCallWindow *self,
     ClutterActor *rectangle)
 {
-  GtkStyleContext *context;
-  GdkRGBA rgba;
-  ClutterColor color, darker;
+  ClutterColor white = { 0xff, 0xff, 0xff, 0xff}, darker;
 
-  context = gtk_widget_get_style_context (GTK_WIDGET (self));
-  gtk_style_context_get_background_color (context, 0, &rgba);
-
-  _clutter_color_from_rgba (&color, &rgba);
-  clutter_color_shade (&color, 0.55, &darker);
+  clutter_color_shade (&white, 0.55, &darker);
 
   empathy_rounded_rectangle_set_border_width (
       EMPATHY_ROUNDED_RECTANGLE (rectangle), 1);
@@ -1382,9 +1381,11 @@ empathy_call_window_toolbar_timeout (gpointer data)
   EmpathyCallWindow *self = data;
 
   /* We don't want to hide the toolbar if we're not in a call, as
-   * to show the call status all the time. */
+   * to show the call status all the time. Also don't hide if we're muted
+   * to prevent the awkward, talking when muted situation */
   if (self->priv->call_state != CONNECTING &&
-      self->priv->call_state != DISCONNECTED)
+      self->priv->call_state != DISCONNECTED &&
+      !self->priv->muted)
     clutter_state_set_state (self->priv->transitions, "fade-out");
 
   return TRUE;
@@ -1558,6 +1559,7 @@ empathy_call_window_init (EmpathyCallWindow *self)
     EMPATHY_TYPE_CALL_WINDOW, EmpathyCallWindowPriv);
 
   priv->settings = g_settings_new (EMPATHY_PREFS_CALL_SCHEMA);
+  priv->timer = g_timer_new ();
 
   filename = empathy_file_lookup ("empathy-call-window.ui", "src");
   gui = empathy_builder_get_file (filename,
@@ -1637,7 +1639,7 @@ empathy_call_window_init (EmpathyCallWindow *self)
   g_signal_connect (priv->camera_monitor, "removed",
       G_CALLBACK (empathy_call_window_camera_removed_cb), self);
 
-  priv->lock = g_mutex_new ();
+  g_mutex_init (&priv->lock);
 
   gtk_container_add (GTK_CONTAINER (self), top_vbox);
 
@@ -1647,15 +1649,15 @@ empathy_call_window_init (EmpathyCallWindow *self)
       TRUE, TRUE, 0);
 
   /* main contents remote avatar/video box */
-  priv->video_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
-      CLUTTER_BIN_ALIGNMENT_CENTER);
+  priv->video_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_FILL,
+      CLUTTER_BIN_ALIGNMENT_FILL);
 
   priv->video_box = clutter_box_new (priv->video_layout);
 
   priv->video_container = gtk_clutter_embed_new ();
 
   gtk_widget_set_size_request (priv->video_container,
-      EMPATHY_VIDEO_WIDGET_DEFAULT_WIDTH, EMPATHY_VIDEO_WIDGET_DEFAULT_HEIGHT);
+      REMOTE_VIDEO_DEFAULT_WIDTH, REMOTE_VIDEO_DEFAULT_HEIGHT);
 
   /* Set the background black */
   clutter_stage_set_color (
@@ -1682,17 +1684,16 @@ empathy_call_window_init (EmpathyCallWindow *self)
   clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_box),
       remote_avatar);
 
-  /* create the overlay box */
-  priv->overlay_layout = clutter_box_layout_new ();
-  clutter_box_layout_set_vertical (
-      CLUTTER_BOX_LAYOUT (priv->overlay_layout), TRUE);
-  priv->overlay_box = clutter_actor_new ();
-  clutter_actor_set_layout_manager (priv->overlay_box, priv->overlay_layout);
+  /* create the overlay bin */
+  priv->overlay_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
+    CLUTTER_BIN_ALIGNMENT_CENTER);
+  priv->overlay_bin = clutter_actor_new ();
+  clutter_actor_set_layout_manager (priv->overlay_bin, priv->overlay_layout);
 
-  clutter_actor_set_margin (priv->overlay_box, &overlay_margin);
+  clutter_actor_set_margin (priv->overlay_bin, &overlay_margin);
 
   clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
-      priv->overlay_box,
+      priv->overlay_bin,
       CLUTTER_BIN_ALIGNMENT_FILL, CLUTTER_BIN_ALIGNMENT_FILL);
 
   empathy_call_window_create_preview_rectangles (self);
@@ -1713,9 +1714,9 @@ empathy_call_window_init (EmpathyCallWindow *self)
   gtk_widget_reparent (priv->bottom_toolbar,
       gtk_clutter_actor_get_widget (GTK_CLUTTER_ACTOR (priv->floating_toolbar)));
 
-  clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (priv->overlay_layout),
-      priv->floating_toolbar, FALSE, FALSE, FALSE,
-      CLUTTER_BOX_ALIGNMENT_CENTER, CLUTTER_BOX_ALIGNMENT_END);
+  clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->overlay_layout),
+      priv->floating_toolbar,
+      CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_END);
 
   clutter_actor_set_opacity (priv->floating_toolbar, FLOATING_TOOLBAR_OPACITY);
 
@@ -1790,8 +1791,6 @@ empathy_call_window_init (EmpathyCallWindow *self)
   g_signal_connect (self, "motion-notify-event",
       G_CALLBACK (empathy_call_window_motion_notify_cb), self);
 
-  priv->timer = g_timer_new ();
-
   g_object_ref (priv->ui_manager);
   g_object_unref (gui);
 
@@ -2374,7 +2373,7 @@ empathy_call_window_finalize (GObject *object)
   disconnect_video_output_motion_handler (self);
 
   /* free any data held directly by the object here */
-  g_mutex_free (priv->lock);
+  g_mutex_clear (&priv->lock);
 
   g_timer_destroy (priv->timer);
 
@@ -2547,7 +2546,7 @@ empathy_call_window_disconnected (EmpathyCallWindow *self,
 
   if (could_reset_pipeline)
     {
-      g_mutex_lock (priv->lock);
+      g_mutex_lock (&priv->lock);
 
       g_timer_stop (priv->timer);
 
@@ -2555,7 +2554,7 @@ empathy_call_window_disconnected (EmpathyCallWindow *self,
         g_source_remove (priv->timer_id);
       priv->timer_id = 0;
 
-      g_mutex_unlock (priv->lock);
+      g_mutex_unlock (&priv->lock);
 
       if (!restart)
         /* We are about to destroy the window, no need to update it or create
@@ -3205,12 +3204,12 @@ empathy_call_window_state_changed_cb (EmpathyCallHandler *handler,
 
   g_object_unref (call);
 
-  g_mutex_lock (priv->lock);
+  g_mutex_lock (&priv->lock);
 
   priv->timer_id = g_timeout_add_seconds (1,
     empathy_call_window_update_timer, self);
 
-  g_mutex_unlock (priv->lock);
+  g_mutex_unlock (&priv->lock);
 
   empathy_call_window_update_timer (self);
 
@@ -3226,7 +3225,7 @@ empathy_call_window_show_video_output_cb (gpointer user_data)
     {
       gtk_widget_hide (self->priv->remote_user_avatar_widget);
       clutter_actor_show (self->priv->video_output);
-      clutter_actor_raise_top (self->priv->overlay_box);
+      clutter_actor_raise_top (self->priv->overlay_bin);
     }
 
   return FALSE;
@@ -3284,7 +3283,7 @@ empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
 
   GstPad *pad;
 
-  g_mutex_lock (priv->lock);
+  g_mutex_lock (&priv->lock);
 
   g_object_get (content, "media-type", &media_type, NULL);
 
@@ -3351,7 +3350,7 @@ empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
     }
 
 
-  g_mutex_unlock (priv->lock);
+  g_mutex_unlock (&priv->lock);
 
   return TRUE;
 }