]> git.0d.be Git - empathy.git/blobdiff - src/empathy-call-window.c
GNOME Goal: Update icon names
[empathy.git] / src / empathy-call-window.c
index cdfc90fc6cd19bd3a9b1011f7b9d84566d5e83eb..eb39855babb9632c1257b1a78a441b33f76c7ead 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include "config.h"
+#include "empathy-call-window.h"
 
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <math.h>
-
-#include <gdk/gdkkeysyms.h>
-#include <gst/gst.h>
-#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 <farstream/fs-element-added-notifier.h>
+#include <farstream/fs-utils.h>
 
-#include <libempathy-gtk/empathy-avatar-image.h>
-#include <libempathy-gtk/empathy-ui-utils.h>
-#include <libempathy-gtk/empathy-sound-manager.h>
-#include <libempathy-gtk/empathy-geometry.h>
-#include <libempathy-gtk/empathy-images.h>
-
-#define DEBUG_FLAG EMPATHY_DEBUG_VOIP
-#include <libempathy/empathy-debug.h>
-
-#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"
-#include "empathy-video-src.h"
+#include "empathy-call-utils.h"
+#include "empathy-call-window-fullscreen.h"
+#include "empathy-camera-menu.h"
+#include "empathy-camera-monitor.h"
+#include "empathy-dialpad-widget.h"
+#include "empathy-geometry.h"
+#include "empathy-gsettings.h"
+#include "empathy-images.h"
 #include "empathy-mic-menu.h"
+#include "empathy-preferences.h"
+#include "empathy-request-util.h"
+#include "empathy-rounded-actor.h"
+#include "empathy-rounded-rectangle.h"
+#include "empathy-rounded-texture.h"
+#include "empathy-sound-manager.h"
+#include "empathy-ui-utils.h"
+#include "empathy-utils.h"
+
+#define DEBUG_FLAG EMPATHY_DEBUG_VOIP
+#include "empathy-debug.h"
 
-#define CONTENT_HBOX_BORDER_WIDTH 6
 #define CONTENT_HBOX_SPACING 3
-#define CONTENT_HBOX_CHILDREN_PACKING_PADDING 3
+#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_HEIGTH 90
+#define SELF_VIDEO_SECTION_HEIGHT 90
+#define SELF_VIDEO_SECTION_MARGIN 2
+#define SELF_VIDEO_SECTION_BORDER SELF_VIDEO_SECTION_MARGIN*2
 
 /* 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
 
 /* The time interval in milliseconds between 2 outgoing rings */
 #define MS_BETWEEN_RING 500
 
+/* The roundedness of preview box and placeholders */
+#define PREVIEW_ROUND_FACTOR 16
+
+#define PREVIEW_BUTTON_OPACITY 180
+
 G_DEFINE_TYPE(EmpathyCallWindow, empathy_call_window, GTK_TYPE_WINDOW)
 
 enum {
   PROP_CALL_HANDLER = 1,
 };
 
+enum {
+  SIG_INHIBIT,
+  LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+
 typedef enum {
-  CONNECTING,
-  CONNECTED,
-  HELD,
-  DISCONNECTED,
-  REDIALING
+  RINGING,       /* Incoming call */
+  CONNECTING,    /* Outgoing call */
+  CONNECTED,     /* Connected */
+  HELD,          /* Connected, but on hold */
+  DISCONNECTED,  /* Disconnected */
+  REDIALING      /* Redialing (special case of CONNECTING) */
 } CallState;
 
 typedef enum {
@@ -104,6 +106,14 @@ typedef enum {
   CAMERA_STATE_ON,
 } CameraState;
 
+typedef enum {
+  PREVIEW_POS_NONE,
+  PREVIEW_POS_TOP_LEFT,
+  PREVIEW_POS_TOP_RIGHT,
+  PREVIEW_POS_BOTTOM_LEFT,
+  PREVIEW_POS_BOTTOM_RIGHT,
+} PreviewPosition;
+
 struct _EmpathyCallWindowPriv
 {
   gboolean dispose_has_run;
@@ -113,7 +123,7 @@ struct _EmpathyCallWindowPriv
 
   EmpathyCameraMonitor *camera_monitor;
 
-  guint call_state;
+  CallState call_state;
   gboolean outgoing;
 
   GtkUIManager *ui_manager;
@@ -122,37 +132,68 @@ struct _EmpathyCallWindowPriv
    * alive only during call. */
   ClutterActor *video_output;
   ClutterActor *video_preview;
+  ClutterActor *drag_preview;
+  ClutterActor *preview_shown_button;
   ClutterActor *preview_hidden_button;
+  ClutterActor *preview_rectangle1;
+  ClutterActor *preview_rectangle2;
+  ClutterActor *preview_rectangle3;
+  ClutterActor *preview_rectangle4;
+  ClutterActor *preview_spinner_actor;
+  GtkWidget *preview_spinner_widget;
   GtkWidget *video_container;
   GtkWidget *remote_user_avatar_widget;
   GtkWidget *remote_user_avatar_toolbar;
   GtkWidget *remote_user_name_toolbar;
+  GtkWidget *remote_user_status_toolbar;
   GtkWidget *status_label;
   GtkWidget *hangup_button;
   GtkWidget *audio_call_button;
   GtkWidget *video_call_button;
   GtkWidget *mic_button;
+  GtkWidget *microphone_icon;
+  GtkWidget *volume_button;
   GtkWidget *camera_button;
   GtkWidget *dialpad_button;
   GtkWidget *toolbar;
   GtkWidget *bottom_toolbar;
+  ClutterActor *floating_toolbar;
   GtkWidget *pane;
   GtkAction *menu_fullscreen;
+  GtkAction *menu_swap_camera;
+
+  ClutterState *transitions;
 
-  /* The box that contains self and remote avatar and video
-     input/output. When we redial, we destroy and re-create the box */
+  /* The main box covering all the stage, contaning remote avatar/video */
   ClutterActor *video_box;
   ClutterLayoutManager *video_layout;
 
+  /* A bin layout manager containing a bin for previews
+   * and the floating toolbar */
+  ClutterActor *overlay_bin;
+  ClutterLayoutManager *overlay_layout;
+
+  /* Bin layout for the previews */
+  ClutterActor *preview_box;
+  ClutterLayoutManager *preview_layout;
+
+  /* Coordinates of the preview drag event's start. */
+  PreviewPosition preview_pos;
+
   /* We keep a reference on the hbox which contains the main content so we can
      easilly repack everything when toggling fullscreen */
   GtkWidget *content_hbox;
 
+  /* These are used to accept or reject an incoming call when the status
+     is RINGING. */
+  GtkWidget *incoming_call_dialog;
+  TpCallChannel *pending_channel;
+  TpChannelDispatchOperation *pending_cdo;
+  TpAddDispatchOperationContext *pending_context;
+
   gulong video_output_motion_handler_id;
   guint bus_message_source_id;
 
-  gdouble volume;
-
   GtkWidget *dtmf_panel;
 
   /* Details vbox */
@@ -176,6 +217,7 @@ struct _EmpathyCallWindowPriv
   GstElement *video_output_sink;
   GstElement *audio_input;
   GstElement *audio_output;
+  gboolean audio_output_added;
   GstElement *pipeline;
   GstElement *video_tee;
 
@@ -186,7 +228,7 @@ struct _EmpathyCallWindowPriv
   GTimer *timer;
   guint timer_id;
 
-  GMutex *lock;
+  GMutex lock;
   gboolean call_started;
   gboolean sending_video;
   CameraState camera_state;
@@ -197,6 +239,8 @@ struct _EmpathyCallWindowPriv
   gboolean got_video;
   guint got_video_src;
 
+  guint inactivity_src;
+
   /* Those fields represent the state of the window before it actually was in
      fullscreen mode. */
   gboolean dialpad_was_visible_before_fs;
@@ -215,6 +259,9 @@ struct _EmpathyCallWindowPriv
 
   GSettings *settings;
   EmpathyMicMenu *mic_menu;
+  EmpathyCameraMenu *camera_menu;
+
+  gboolean muted;
 };
 
 #define GET_PRIV(o) (EMPATHY_CALL_WINDOW (o)->priv)
@@ -231,9 +278,6 @@ static gboolean empathy_call_window_state_event_cb (GtkWidget *widget,
 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_hangup_cb (gpointer object,
   EmpathyCallWindow *window);
 
@@ -254,6 +298,8 @@ static gboolean empathy_call_window_video_output_motion_notify (
 static void empathy_call_window_video_menu_popup (EmpathyCallWindow *window,
   guint button);
 
+static void empathy_call_window_connect_handler (EmpathyCallWindow *self);
+
 static void empathy_call_window_dialpad_cb (GtkToggleToolButton *button,
   EmpathyCallWindow *window);
 
@@ -265,9 +311,17 @@ 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
-empathy_call_window_volume_changed_cb (GtkScaleButton *button,
-  gdouble value, EmpathyCallWindow *window);
+make_background_transparent (GtkClutterActor *actor)
+{
+  GdkRGBA transparent = { 0., 0., 0., 0. };
+  GtkWidget *widget;
+
+  widget = gtk_clutter_actor_get_widget (actor);
+  gtk_widget_override_background_color (widget, GTK_STATE_FLAG_NORMAL, &transparent);
+}
 
 static void
 empathy_call_window_show_hangup_button (EmpathyCallWindow *self,
@@ -296,70 +350,22 @@ empathy_call_window_video_call_cb (GtkToggleToolButton *button,
 }
 
 static void
-dtmf_button_pressed_cb (GtkButton *button, EmpathyCallWindow *window)
+dtmf_start_tone_cb (EmpathyDialpadWidget *dialpad,
+    TpDTMFEvent event,
+    EmpathyCallWindow *self)
 {
-  EmpathyCallWindowPriv *priv = GET_PRIV (window);
-  TpyCallChannel *call;
-  GQuark button_quark;
-  TpDTMFEvent event;
-
-  g_object_get (priv->handler, "call-channel", &call, NULL);
+  TpCallChannel *call;
+  gchar tones[2];
 
-  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_get (self->priv->handler, "call-channel", &call, NULL);
 
-  tpy_call_channel_dtmf_start_tone (call, event);
+  tones[0] = tp_dtmf_event_to_char (event);
+  tones[1] = '\0';
+  tp_call_channel_send_tones_async (call, tones, NULL, NULL, NULL);
 
   g_object_unref (call);
 }
 
-static void
-dtmf_button_released_cb (GtkButton *button, EmpathyCallWindow *window)
-{
-  EmpathyCallWindowPriv *priv = GET_PRIV (window);
-  TpyCallChannel *call;
-
-  g_object_get (priv->handler, "call-channel", &call, NULL);
-
-  tpy_call_channel_dtmf_stop_tone (call);
-
-  g_object_unref (call);
-}
-
-static void
-empathy_call_window_mic_volume_changed (EmpathyCallWindow *self)
-{
-  EmpathyCallWindowPriv *priv = GET_PRIV (self);
-  gdouble volume;
-
-  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 (
-        GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
-    priv->volume = volume;
-
-  /* Ensure that the toggle button is active if the volume is > 0 and inactive
-   * if it's smaller than 0 */
-  if ((volume > 0) != gtk_toggle_tool_button_get_active (
-        GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
-    gtk_toggle_tool_button_set_active (
-      GTK_TOGGLE_TOOL_BUTTON (priv->mic_button), volume > 0);
-
-  empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
-    volume);
-}
-
-static void
-empathy_call_window_prefs_volume_changed_cb (GSettings *settings,
-    gchar *key,
-    EmpathyCallWindow *self)
-{
-  empathy_call_window_mic_volume_changed (self);
-}
-
 static void
 empathy_call_window_show_video_output (EmpathyCallWindow *self,
     gboolean show)
@@ -368,6 +374,8 @@ empathy_call_window_show_video_output (EmpathyCallWindow *self,
     g_object_set (self->priv->video_output, "visible", show, NULL);
 
   gtk_widget_set_visible (self->priv->remote_user_avatar_widget, !show);
+
+  clutter_actor_raise_top (self->priv->overlay_bin);
 }
 
 static void
@@ -383,8 +391,11 @@ create_video_output_widget (EmpathyCallWindow *self)
   clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (priv->video_output),
       TRUE);
 
-  priv->video_output_sink = clutter_gst_video_sink_new (
-      CLUTTER_TEXTURE (priv->video_output));
+  priv->video_output_sink = gst_element_factory_make ("cluttersink", NULL);
+  if (priv->video_output_sink == NULL)
+    g_error ("Missing cluttersink");
+  else
+    g_object_set (priv->video_output_sink, "texture", priv->video_output, NULL);
 
   clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_box),
       priv->video_output);
@@ -402,8 +413,66 @@ create_video_input (EmpathyCallWindow *self)
 
   g_assert (priv->video_input == NULL);
   priv->video_input = empathy_video_src_new ();
-  gst_object_ref (priv->video_input);
-  gst_object_sink (priv->video_input);
+  gst_object_ref_sink (priv->video_input);
+}
+
+static gboolean
+audio_control_volume_to_element (GBinding *binding,
+  const GValue *source_value,
+  GValue *target_value,
+  gpointer user_data)
+{
+  /* AudioControl volume is 0-255, with -1 for unknown */
+  gint hv;
+
+  hv = g_value_get_int (source_value);
+  if (hv < 0)
+    return FALSE;
+
+  hv = MIN (hv, 255);
+  g_value_set_double (target_value, hv/255.0);
+
+  return TRUE;
+}
+
+static gboolean
+element_volume_to_audio_control (GBinding *binding,
+  const GValue *source_value,
+  GValue *target_value,
+  gpointer user_data)
+{
+  gdouble ev;
+
+  ev = g_value_get_double (source_value);
+  ev = CLAMP (ev, 0.0, 1.0);
+
+  g_value_set_int (target_value, ev * 255);
+  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");
+
+  if (muted)
+    {
+      gtk_image_set_from_icon_name (GTK_IMAGE (self->priv->microphone_icon),
+          EMPATHY_IMAGE_MIC_MUTED, GTK_ICON_SIZE_MENU);
+    }
+  else
+    {
+      gtk_image_set_from_icon_name (GTK_IMAGE (self->priv->microphone_icon),
+          EMPATHY_IMAGE_MIC, GTK_ICON_SIZE_MENU);
+    }
+
+  empathy_call_window_update_timer (self);
 }
 
 static void
@@ -413,8 +482,10 @@ create_audio_input (EmpathyCallWindow *self)
 
   g_assert (priv->audio_input == NULL);
   priv->audio_input = empathy_audio_src_new ();
-  gst_object_ref (priv->audio_input);
-  gst_object_sink (priv->audio_input);
+  gst_object_ref_sink (priv->audio_input);
+
+  g_signal_connect (priv->audio_input, "notify::mute",
+    G_CALLBACK (audio_input_mute_notify_cb), self);
 }
 
 static void
@@ -461,8 +532,8 @@ empathy_call_window_disable_camera_cb (GtkAction *action,
 {
   clutter_actor_destroy (self->priv->preview_hidden_button);
 
-  gtk_toggle_tool_button_set_active (
-      GTK_TOGGLE_TOOL_BUTTON (self->priv->camera_button), FALSE);
+  gtk_toggle_button_set_active (
+      GTK_TOGGLE_BUTTON (self->priv->camera_button), FALSE);
 }
 
 static void
@@ -482,7 +553,69 @@ empathy_call_window_maximise_camera_cb (GtkAction *action,
 }
 
 static void
-empathy_call_window_preview_button_clicked_cb (GtkButton *button,
+empathy_call_window_swap_camera_cb (GtkAction *action,
+    EmpathyCallWindow *self)
+{
+  const GList *cameras, *l;
+  gchar *current_cam;
+
+  DEBUG ("Swapping the camera");
+
+  cameras = empathy_camera_monitor_get_cameras (self->priv->camera_monitor);
+  current_cam = empathy_video_src_dup_device (
+      EMPATHY_GST_VIDEO_SRC (self->priv->video_input));
+
+  for (l = cameras; l != NULL; l = l->next)
+    {
+      EmpathyCamera *camera = l->data;
+
+      if (!tp_strdiff (camera->device, current_cam))
+        {
+          EmpathyCamera *next;
+
+          if (l->next != NULL)
+            next = l->next->data;
+          else
+            next = cameras->data;
+
+          /* EmpathyCameraMenu will update itself and do the actual change
+           * for us */
+          g_settings_set_string (self->priv->settings,
+              EMPATHY_PREFS_CALL_CAMERA_DEVICE,
+              next->device);
+
+          break;
+        }
+    }
+
+  g_free (current_cam);
+}
+
+static void
+empathy_call_window_camera_added_cb (EmpathyCameraMonitor *monitor,
+    EmpathyCamera *camera,
+    EmpathyCallWindow *self)
+{
+  const GList *cameras = empathy_camera_monitor_get_cameras (monitor);
+
+  gtk_action_set_visible (self->priv->menu_swap_camera,
+      g_list_length ((GList *) cameras) >= 2);
+}
+
+static void
+empathy_call_window_camera_removed_cb (EmpathyCameraMonitor *monitor,
+    EmpathyCamera *camera,
+    EmpathyCallWindow *self)
+{
+  const GList *cameras = empathy_camera_monitor_get_cameras (monitor);
+
+  gtk_action_set_visible (self->priv->menu_swap_camera,
+      g_list_length ((GList *) cameras) >= 2);
+}
+
+static void
+empathy_call_window_preview_button_clicked_cb (ClutterClickAction *action,
+    ClutterActor *actor,
     EmpathyCallWindow *self)
 {
   GtkWidget *menu;
@@ -495,7 +628,9 @@ empathy_call_window_preview_button_clicked_cb (GtkButton *button,
 }
 
 static void
-empathy_call_window_preview_hidden_button_clicked_cb (GtkButton *button,
+empathy_call_window_preview_hidden_button_clicked_cb (
+    ClutterClickAction *action,
+    ClutterActor *actor,
     EmpathyCallWindow *self)
 {
   GtkWidget *menu;
@@ -507,114 +642,578 @@ empathy_call_window_preview_hidden_button_clicked_cb (GtkButton *button,
   gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
 }
 
+static ClutterActor *
+empathy_call_window_create_preview_rectangle (EmpathyCallWindow *self,
+    ClutterBinAlignment x,
+    ClutterBinAlignment y)
+{
+  ClutterActor *rectangle;
+
+  rectangle = CLUTTER_ACTOR (empathy_rounded_rectangle_new (
+      SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGHT,
+      PREVIEW_ROUND_FACTOR));
+
+  clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (self->priv->preview_layout),
+      rectangle, x, y);
+  clutter_actor_hide (rectangle);
+
+  return rectangle;
+}
+
+static void
+empathy_call_window_create_preview_rectangles (EmpathyCallWindow *self)
+{
+  ClutterActor *box;
+
+  self->priv->preview_layout = clutter_bin_layout_new (
+      CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER);
+  self->priv->preview_box = box = clutter_box_new (self->priv->preview_layout);
+
+  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,
+          CLUTTER_BIN_ALIGNMENT_START, CLUTTER_BIN_ALIGNMENT_START);
+  self->priv->preview_rectangle2 =
+      empathy_call_window_create_preview_rectangle (self,
+          CLUTTER_BIN_ALIGNMENT_START, CLUTTER_BIN_ALIGNMENT_END);
+  self->priv->preview_rectangle3 =
+      empathy_call_window_create_preview_rectangle (self,
+          CLUTTER_BIN_ALIGNMENT_END, CLUTTER_BIN_ALIGNMENT_START);
+  self->priv->preview_rectangle4 =
+      empathy_call_window_create_preview_rectangle (self,
+          CLUTTER_BIN_ALIGNMENT_END, CLUTTER_BIN_ALIGNMENT_END);
+}
+
+static void
+empathy_call_window_show_preview_rectangles (EmpathyCallWindow *self,
+    gboolean show)
+{
+  g_object_set (self->priv->preview_rectangle1, "visible", show, NULL);
+  g_object_set (self->priv->preview_rectangle2, "visible", show, NULL);
+  g_object_set (self->priv->preview_rectangle3, "visible", show, NULL);
+  g_object_set (self->priv->preview_rectangle4, "visible", show, NULL);
+}
+
+static void
+empathy_call_window_get_preview_coordinates (EmpathyCallWindow *self,
+    PreviewPosition pos,
+    guint *x,
+    guint *y)
+{
+  guint ret_x = 0, ret_y = 0;
+  ClutterGeometry box;
+
+  if (!clutter_actor_has_allocation (self->priv->preview_box))
+    goto out;
+
+  clutter_actor_get_geometry (self->priv->preview_box, &box);
+
+  switch (pos)
+    {
+      case PREVIEW_POS_TOP_LEFT:
+        ret_x = ret_y = SELF_VIDEO_SECTION_MARGIN;
+        break;
+      case PREVIEW_POS_TOP_RIGHT:
+        ret_x = box.width - SELF_VIDEO_SECTION_MARGIN
+            - SELF_VIDEO_SECTION_WIDTH;
+        ret_y = SELF_VIDEO_SECTION_MARGIN;
+        break;
+      case PREVIEW_POS_BOTTOM_LEFT:
+        ret_x = SELF_VIDEO_SECTION_MARGIN;
+        ret_y = box.height - SELF_VIDEO_SECTION_MARGIN
+            - SELF_VIDEO_SECTION_HEIGHT;
+        break;
+      case PREVIEW_POS_BOTTOM_RIGHT:
+        ret_x = box.width - SELF_VIDEO_SECTION_MARGIN
+            - SELF_VIDEO_SECTION_WIDTH;
+        ret_y = box.height - SELF_VIDEO_SECTION_MARGIN
+            - SELF_VIDEO_SECTION_HEIGHT;
+        break;
+      default:
+        g_warn_if_reached ();
+    }
+
+out:
+  if (x != NULL)
+    *x = ret_x;
+
+  if (y != NULL)
+    *y = ret_y;
+}
+
+static PreviewPosition
+empathy_call_window_get_preview_position (EmpathyCallWindow *self,
+    gfloat event_x,
+    gfloat event_y)
+{
+  ClutterGeometry box;
+  PreviewPosition pos = PREVIEW_POS_NONE;
+
+  if (!clutter_actor_has_allocation (self->priv->preview_box))
+    return pos;
+
+  clutter_actor_get_geometry (self->priv->preview_box, &box);
+
+  if (0 + SELF_VIDEO_SECTION_MARGIN <= event_x &&
+      event_x <= (0 + SELF_VIDEO_SECTION_MARGIN + (gint) SELF_VIDEO_SECTION_WIDTH) &&
+      0 + SELF_VIDEO_SECTION_MARGIN <= event_y &&
+      event_y <= (0 + SELF_VIDEO_SECTION_MARGIN + (gint) SELF_VIDEO_SECTION_HEIGHT))
+    {
+      pos = PREVIEW_POS_TOP_LEFT;
+    }
+  else if (box.width - SELF_VIDEO_SECTION_MARGIN >= event_x &&
+      event_x >= (box.width - SELF_VIDEO_SECTION_MARGIN - (gint) SELF_VIDEO_SECTION_WIDTH) &&
+      0 + SELF_VIDEO_SECTION_MARGIN <= event_y &&
+      event_y <= (0 + SELF_VIDEO_SECTION_MARGIN + (gint) SELF_VIDEO_SECTION_HEIGHT))
+    {
+      pos = PREVIEW_POS_TOP_RIGHT;
+    }
+  else if (0 + SELF_VIDEO_SECTION_MARGIN <= event_x &&
+      event_x <= (0 + SELF_VIDEO_SECTION_MARGIN + (gint) SELF_VIDEO_SECTION_WIDTH) &&
+      box.height - SELF_VIDEO_SECTION_MARGIN >= event_y &&
+      event_y >= (box.height - SELF_VIDEO_SECTION_MARGIN - (gint) SELF_VIDEO_SECTION_HEIGHT))
+    {
+      pos = PREVIEW_POS_BOTTOM_LEFT;
+    }
+  else if (box.width - SELF_VIDEO_SECTION_MARGIN >= event_x &&
+      event_x >= (box.width - SELF_VIDEO_SECTION_MARGIN - (gint) SELF_VIDEO_SECTION_WIDTH) &&
+      box.height - 2 * SELF_VIDEO_SECTION_MARGIN >= event_y &&
+      event_y >= (box.height - SELF_VIDEO_SECTION_MARGIN - (gint) SELF_VIDEO_SECTION_HEIGHT))
+    {
+      pos = PREVIEW_POS_BOTTOM_RIGHT;
+    }
+
+  return pos;
+}
+
+static ClutterActor *
+empathy_call_window_get_preview_rectangle (EmpathyCallWindow *self,
+    PreviewPosition pos)
+{
+  ClutterActor *rectangle;
+
+  switch (pos)
+    {
+      case PREVIEW_POS_TOP_LEFT:
+        rectangle = self->priv->preview_rectangle1;
+        break;
+      case PREVIEW_POS_TOP_RIGHT:
+        rectangle = self->priv->preview_rectangle3;
+        break;
+      case PREVIEW_POS_BOTTOM_LEFT:
+        rectangle = self->priv->preview_rectangle2;
+        break;
+      case PREVIEW_POS_BOTTOM_RIGHT:
+        rectangle = self->priv->preview_rectangle4;
+        break;
+      default:
+        rectangle = NULL;
+    }
+
+  return rectangle;
+}
+
+static void
+empathy_call_window_move_video_preview (EmpathyCallWindow *self,
+    PreviewPosition pos)
+{
+  ClutterBinLayout *layout = CLUTTER_BIN_LAYOUT (self->priv->preview_layout);
+
+  DEBUG ("moving the video preview to %d", pos);
+
+  self->priv->preview_pos = pos;
+
+  switch (pos)
+    {
+      case PREVIEW_POS_TOP_LEFT:
+        clutter_bin_layout_set_alignment (layout,
+            self->priv->video_preview,
+            CLUTTER_BIN_ALIGNMENT_START,
+            CLUTTER_BIN_ALIGNMENT_START);
+        break;
+      case PREVIEW_POS_TOP_RIGHT:
+        clutter_bin_layout_set_alignment (layout,
+            self->priv->video_preview,
+            CLUTTER_BIN_ALIGNMENT_END,
+            CLUTTER_BIN_ALIGNMENT_START);
+        break;
+      case PREVIEW_POS_BOTTOM_LEFT:
+        clutter_bin_layout_set_alignment (layout,
+            self->priv->video_preview,
+            CLUTTER_BIN_ALIGNMENT_START,
+            CLUTTER_BIN_ALIGNMENT_END);
+        break;
+      case PREVIEW_POS_BOTTOM_RIGHT:
+        clutter_bin_layout_set_alignment (layout,
+            self->priv->video_preview,
+            CLUTTER_BIN_ALIGNMENT_END,
+            CLUTTER_BIN_ALIGNMENT_END);
+        break;
+      default:
+        g_warn_if_reached ();
+    }
+
+  g_settings_set_enum (self->priv->settings, "camera-position", pos);
+}
+
+static void
+empathy_call_window_highlight_preview_rectangle (EmpathyCallWindow *self,
+    PreviewPosition pos)
+{
+  ClutterActor *rectangle;
+  ClutterColor white = { 0xff, 0xff, 0xff, 0xff};
+
+  rectangle = empathy_call_window_get_preview_rectangle (self, pos);
+
+  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), &white);
+}
+
+static void
+empathy_call_window_darken_preview_rectangle (EmpathyCallWindow *self,
+    ClutterActor *rectangle)
+{
+  ClutterColor white = { 0xff, 0xff, 0xff, 0xff}, darker;
+
+  clutter_color_shade (&white, 0.55, &darker);
+
+  empathy_rounded_rectangle_set_border_width (
+      EMPATHY_ROUNDED_RECTANGLE (rectangle), 1);
+  empathy_rounded_rectangle_set_border_color (
+      EMPATHY_ROUNDED_RECTANGLE (rectangle), &darker);
+}
+
+static void
+empathy_call_window_darken_preview_rectangles (EmpathyCallWindow *self)
+{
+  ClutterActor *rectangle;
+
+  rectangle = empathy_call_window_get_preview_rectangle (self,
+      self->priv->preview_pos);
+
+  /* We don't want to darken the rectangle where the preview
+   * currently is. */
+
+  if (self->priv->preview_rectangle1 != rectangle)
+    empathy_call_window_darken_preview_rectangle (self,
+        self->priv->preview_rectangle1);
+
+  if (self->priv->preview_rectangle2 != rectangle)
+    empathy_call_window_darken_preview_rectangle (self,
+        self->priv->preview_rectangle2);
+
+  if (self->priv->preview_rectangle3 != rectangle)
+    empathy_call_window_darken_preview_rectangle (self,
+        self->priv->preview_rectangle3);
+
+  if (self->priv->preview_rectangle4 != rectangle)
+    empathy_call_window_darken_preview_rectangle (self,
+        self->priv->preview_rectangle4);
+}
+
+static void
+empathy_call_window_preview_on_drag_begin_cb (ClutterDragAction *action,
+    ClutterActor *actor,
+    gfloat event_x,
+    gfloat event_y,
+    ClutterModifierType modifiers,
+    EmpathyCallWindow *self)
+{
+  ClutterActor *stage = clutter_actor_get_stage (actor);
+  gfloat rel_x, rel_y;
+
+  self->priv->drag_preview = clutter_clone_new (actor);
+
+  clutter_container_add_actor (CLUTTER_CONTAINER (stage),
+      self->priv->drag_preview);
+
+  clutter_actor_transform_stage_point (actor, event_x, event_y,
+      &rel_x, &rel_y);
+
+  clutter_actor_set_position (self->priv->drag_preview,
+      event_x - rel_x, event_y - rel_y);
+
+  clutter_drag_action_set_drag_handle (action,
+      self->priv->drag_preview);
+
+  clutter_actor_set_opacity (actor, 0);
+  clutter_actor_hide (self->priv->preview_shown_button);
+
+  empathy_call_window_show_preview_rectangles (self, TRUE);
+  empathy_call_window_darken_preview_rectangles (self);
+}
+
+static void
+empathy_call_window_on_animation_completed_cb (ClutterAnimation *animation,
+    ClutterActor *actor)
+{
+  clutter_actor_set_opacity (actor, 255);
+}
+
+static void
+empathy_call_window_preview_on_drag_end_cb (ClutterDragAction *action,
+    ClutterActor *actor,
+    gfloat event_x,
+    gfloat event_y,
+    ClutterModifierType modifiers,
+    EmpathyCallWindow *self)
+{
+  PreviewPosition pos;
+  guint x, y;
+
+  /* Get the position before destroying the drag actor, otherwise the
+   * preview_box allocation won't be valid and we won't be able to
+   * calculate the position. */
+  pos = empathy_call_window_get_preview_position (self, event_x, event_y);
+
+  empathy_call_window_get_preview_coordinates (self,
+      pos != PREVIEW_POS_NONE ? pos : self->priv->preview_pos,
+      &x, &y);
+
+  /* Move the preview to the destination and destroy it afterwards */
+  clutter_actor_animate (self->priv->drag_preview, CLUTTER_LINEAR, 500,
+      "x", (gfloat) x,
+      "y", (gfloat) y,
+      "signal-swapped-after::completed",
+        clutter_actor_destroy, self->priv->drag_preview,
+      "signal-swapped-after::completed",
+        clutter_actor_show, self->priv->preview_shown_button,
+      "signal::completed",
+        empathy_call_window_on_animation_completed_cb, actor,
+      NULL);
+
+  self->priv->drag_preview = NULL;
+
+  if (pos != PREVIEW_POS_NONE)
+    empathy_call_window_move_video_preview (self, pos);
+
+  empathy_call_window_show_preview_rectangles (self, FALSE);
+}
+
+static void
+empathy_call_window_preview_on_drag_motion_cb (ClutterDragAction *action,
+    ClutterActor *actor,
+    gfloat delta_x,
+    gfloat delta_y,
+    EmpathyCallWindow *self)
+{
+  PreviewPosition pos;
+  gfloat event_x, event_y;
+
+  clutter_drag_action_get_motion_coords (action, &event_x, &event_y);
+
+  pos = empathy_call_window_get_preview_position (self, event_x, event_y);
+
+  if (pos != PREVIEW_POS_NONE)
+    empathy_call_window_highlight_preview_rectangle (self, pos);
+  else
+    empathy_call_window_darken_preview_rectangles (self);
+}
+
+static gboolean
+empathy_call_window_preview_enter_event_cb (ClutterActor *actor,
+    ClutterCrossingEvent *event,
+    EmpathyCallWindow *self)
+{
+  ClutterActor *rectangle;
+
+  rectangle = empathy_call_window_get_preview_rectangle (self,
+      self->priv->preview_pos);
+
+  empathy_call_window_highlight_preview_rectangle (self,
+      self->priv->preview_pos);
+
+  clutter_actor_show (rectangle);
+
+  return FALSE;
+}
+
+static gboolean
+empathy_call_window_preview_leave_event_cb (ClutterActor *actor,
+    ClutterCrossingEvent *event,
+    EmpathyCallWindow *self)
+{
+  ClutterActor *rectangle;
+
+  rectangle = empathy_call_window_get_preview_rectangle (self,
+      self->priv->preview_pos);
+
+  empathy_call_window_darken_preview_rectangle (self, rectangle);
+
+  clutter_actor_hide (rectangle);
+
+  return FALSE;
+}
+
 static void
 create_video_preview (EmpathyCallWindow *self)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
-  ClutterLayoutManager *layout, *layout_center;
+  ClutterLayoutManager *layout;
   ClutterActor *preview;
-  ClutterActor *box;
   ClutterActor *b;
-  GtkWidget *button;
+  ClutterAction *action;
+  PreviewPosition pos;
 
   g_assert (priv->video_preview == NULL);
 
-  preview = clutter_texture_new ();
+  pos = g_settings_get_enum (priv->settings, "camera-position");
+
+  preview = empathy_rounded_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);
+      SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGHT);
+
+  priv->video_preview_sink = gst_element_factory_make ("cluttersink", NULL);
+  if (priv->video_preview_sink == NULL)
+      g_error ("Missing cluttersink, check your clutter-gst installation");
+  g_object_set (priv->video_preview_sink, "texture", preview, NULL);
+  g_object_add_weak_pointer (G_OBJECT (priv->video_preview_sink), (gpointer) &priv->video_preview_sink);
 
   /* Add a little offset to the video preview */
-  layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_END,
-      CLUTTER_BIN_ALIGNMENT_START);
+  layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
+      CLUTTER_BIN_ALIGNMENT_CENTER);
   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);
-
-  clutter_container_add_actor (CLUTTER_CONTAINER (box), preview);
-  clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_preview), box);
+      SELF_VIDEO_SECTION_WIDTH + 2 * SELF_VIDEO_SECTION_MARGIN,
+      SELF_VIDEO_SECTION_HEIGHT + 2 * SELF_VIDEO_SECTION_MARGIN);
+
+  /* Spinner for when changing the camera device */
+  priv->preview_spinner_widget = gtk_spinner_new ();
+  priv->preview_spinner_actor = empathy_rounded_actor_new (PREVIEW_ROUND_FACTOR);
+
+  g_object_set (priv->preview_spinner_widget, "expand", TRUE, NULL);
+  make_background_transparent (GTK_CLUTTER_ACTOR (priv->preview_spinner_actor));
+  gtk_widget_show (priv->preview_spinner_widget);
+
+  gtk_container_add (
+      GTK_CONTAINER (gtk_clutter_actor_get_widget (
+          GTK_CLUTTER_ACTOR (priv->preview_spinner_actor))),
+      priv->preview_spinner_widget);
+  clutter_actor_set_size (priv->preview_spinner_actor,
+      SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGHT);
+  clutter_actor_set_opacity (priv->preview_spinner_actor, 128);
+  clutter_actor_hide (priv->preview_spinner_actor);
+
+  clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_preview),
+      preview);
+  clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_preview),
+      priv->preview_spinner_actor);
 
   g_object_set (priv->video_preview_sink,
       "sync", FALSE,
-      "async", TRUE,
+      "async", FALSE,
       NULL);
 
-  /* 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),
+  /* Preview show */
+  priv->preview_shown_button = b = gtk_clutter_actor_new_with_contents (
+      gtk_image_new_from_icon_name ("emblem-system-symbolic",
+        GTK_ICON_SIZE_MENU));
+  clutter_actor_set_margin_right (b, 4);
+  clutter_actor_set_margin_bottom (b, 2);
+  clutter_actor_set_opacity (b, PREVIEW_BUTTON_OPACITY);
+  make_background_transparent (GTK_CLUTTER_ACTOR (b));
+
+  clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (layout), b,
+      CLUTTER_BIN_ALIGNMENT_END, CLUTTER_BIN_ALIGNMENT_END);
+
+  action = clutter_click_action_new ();
+  clutter_actor_add_action (b, action);
+  g_signal_connect (action, "clicked",
+      G_CALLBACK (empathy_call_window_preview_button_clicked_cb), self);
+
+  /* Preview hidden */
+  priv->preview_hidden_button = b = gtk_clutter_actor_new_with_contents (
+      gtk_image_new_from_icon_name ("emblem-system-symbolic",
+        GTK_ICON_SIZE_MENU));
+  make_background_transparent (GTK_CLUTTER_ACTOR (b));
+
+  clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->preview_layout),
       priv->preview_hidden_button,
       CLUTTER_BIN_ALIGNMENT_START,
       CLUTTER_BIN_ALIGNMENT_END);
 
+  self->priv->preview_pos = PREVIEW_POS_BOTTOM_LEFT;
+
   clutter_actor_hide (priv->preview_hidden_button);
 
-  g_signal_connect (button, "clicked",
-      G_CALLBACK (empathy_call_window_preview_hidden_button_clicked_cb),
-      self);
+  action = clutter_click_action_new ();
+  clutter_actor_add_action (b, action);
+  g_signal_connect (action, "clicked",
+      G_CALLBACK (empathy_call_window_preview_hidden_button_clicked_cb), self);
 
-  clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
+  clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->preview_layout),
       priv->video_preview,
       CLUTTER_BIN_ALIGNMENT_START,
       CLUTTER_BIN_ALIGNMENT_END);
+
+  empathy_call_window_move_video_preview (self, pos);
+
+  action = clutter_drag_action_new ();
+  g_signal_connect (action, "drag-begin",
+      G_CALLBACK (empathy_call_window_preview_on_drag_begin_cb), self);
+  g_signal_connect (action, "drag-end",
+      G_CALLBACK (empathy_call_window_preview_on_drag_end_cb), self);
+  g_signal_connect (action, "drag-motion",
+      G_CALLBACK (empathy_call_window_preview_on_drag_motion_cb), self);
+
+  g_signal_connect (preview, "enter-event",
+      G_CALLBACK (empathy_call_window_preview_enter_event_cb), self);
+  g_signal_connect (preview, "leave-event",
+      G_CALLBACK (empathy_call_window_preview_leave_event_cb), self);
+
+  clutter_actor_add_action (preview, action);
+  clutter_actor_set_reactive (preview, TRUE);
+  clutter_actor_set_reactive (priv->preview_shown_button, TRUE);
+}
+
+static void
+empathy_call_window_start_camera_spinning (EmpathyCallWindow *self)
+{
+  clutter_actor_show (self->priv->preview_spinner_actor);
+  gtk_spinner_start (GTK_SPINNER (self->priv->preview_spinner_widget));
 }
 
 static void
-play_camera (EmpathyCallWindow *window,
+empathy_call_window_stop_camera_spinning (EmpathyCallWindow *self)
+{
+  clutter_actor_hide (self->priv->preview_spinner_actor);
+  gtk_spinner_stop (GTK_SPINNER (self->priv->preview_spinner_widget));
+}
+
+void
+empathy_call_window_play_camera (EmpathyCallWindow *self,
     gboolean play)
 {
-  EmpathyCallWindowPriv *priv = GET_PRIV (window);
+  EmpathyCallWindowPriv *priv = GET_PRIV (self);
   GstElement *preview;
   GstState state;
 
   if (priv->video_preview == NULL)
     {
-      create_video_preview (window);
-      add_video_preview_to_pipeline (window);
+      create_video_preview (self);
+      add_video_preview_to_pipeline (self);
     }
 
   if (play)
-    state = GST_STATE_PLAYING;
+    {
+      state = GST_STATE_PLAYING;
+    }
   else
-    state = GST_STATE_NULL;
+    {
+      empathy_call_window_start_camera_spinning (self);
+      state = GST_STATE_NULL;
+    }
 
   preview = priv->video_preview_sink;
 
   gst_element_set_state (preview, state);
-  gst_element_set_state (priv->video_input, state);
   gst_element_set_state (priv->video_tee, state);
+  gst_element_set_state (priv->video_input, state);
 }
 
 static void
@@ -623,13 +1222,20 @@ display_video_preview (EmpathyCallWindow *self,
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
 
+  if (priv->video_preview == NULL)
+    {
+      create_video_preview (self);
+      add_video_preview_to_pipeline (self);
+    }
+
   if (display)
     {
       /* Display the video preview */
       DEBUG ("Show video preview");
 
-      play_camera (self, TRUE);
+      empathy_call_window_play_camera (self, TRUE);
       clutter_actor_show (priv->video_preview);
+      clutter_actor_raise_top (priv->floating_toolbar);
     }
   else
     {
@@ -639,7 +1245,7 @@ display_video_preview (EmpathyCallWindow *self,
       if (priv->video_preview != NULL)
         {
           clutter_actor_hide (priv->video_preview);
-          play_camera (self, FALSE);
+          empathy_call_window_play_camera (self, FALSE);
         }
     }
 }
@@ -652,6 +1258,9 @@ empathy_call_window_set_state_connecting (EmpathyCallWindow *window)
   empathy_call_window_status_message (window, _("Connecting…"));
   priv->call_state = CONNECTING;
 
+  /* Show the toolbar */
+  clutter_state_set_state (priv->transitions, "fade-in");
+
   if (priv->outgoing)
     empathy_sound_manager_start_playing (priv->sound_mgr, GTK_WIDGET (window),
         EMPATHY_SOUND_PHONE_OUTGOING, MS_BETWEEN_RING);
@@ -667,10 +1276,7 @@ disable_camera (EmpathyCallWindow *self)
 
   DEBUG ("Disable camera");
 
-  display_video_preview (self, FALSE);
-
-  if (priv->camera_state == CAMERA_STATE_ON)
-    empathy_call_window_set_send_video (self, CAMERA_STATE_OFF);
+  empathy_call_window_set_send_video (self, CAMERA_STATE_OFF);
 
   priv->camera_state = CAMERA_STATE_OFF;
 }
@@ -697,10 +1303,10 @@ enable_camera (EmpathyCallWindow *self)
 }
 
 static void
-empathy_call_window_camera_toggled_cb (GtkToggleToolButton *toggle,
+empathy_call_window_camera_toggled_cb (GtkToggleButton *toggle,
   EmpathyCallWindow *self)
 {
-  if (gtk_toggle_tool_button_get_active (toggle))
+  if (gtk_toggle_button_get_active (toggle))
     enable_camera (self);
   else
     disable_camera (self);
@@ -718,8 +1324,7 @@ create_pipeline (EmpathyCallWindow *self)
   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_object_ref_sink (priv->video_tee);
 
   gst_bin_add (GST_BIN (priv->pipeline), priv->video_tee);
 
@@ -734,18 +1339,81 @@ static void
 empathy_call_window_settings_cb (GtkAction *action,
     EmpathyCallWindow *self)
 {
-  empathy_launch_program (BIN_DIR, "empathy", "-p");
+  gchar *args = g_strdup_printf ("-p %s",
+      empathy_preferences_tab_to_string (EMPATHY_PREFERENCES_TAB_CALLS));
+
+  empathy_launch_program (BIN_DIR, "empathy", args);
+
+  g_free (args);
 }
 
 static void
 empathy_call_window_contents_cb (GtkAction *action,
     EmpathyCallWindow *self)
 {
-  empathy_url_show (GTK_WIDGET (self), "ghelp:empathy?audio-video");
+  empathy_url_show (GTK_WIDGET (self), "help:empathy/audio-video");
 }
 
 static void
-empathy_call_window_debug_cb (GtkAction *action,
+show_png (GPid pid, gint status, gpointer user_data)
+{
+  gtk_show_uri (NULL, (gchar *) user_data, GDK_CURRENT_TIME, NULL);
+  g_spawn_close_pid (pid);
+  g_free (user_data);
+}
+
+static void
+empathy_call_window_debug_gst_cb (GtkAction *action,
+    EmpathyCallWindow *self)
+{
+  EmpathyCallWindowPriv *priv = GET_PRIV (self);
+  GDateTime *date_time;
+  GPid dot_pid;
+  const gchar *dot_dir;
+  const gchar *prgname;
+  gchar *dot_cmd;
+  gchar *filename;
+  gchar **argv;
+  gint argc;
+
+  if (priv->pipeline == NULL)
+    DEBUG ("No pipeline");
+
+  date_time = g_date_time_new_now_utc ();
+  prgname = g_get_prgname ();
+  filename = g_strdup_printf ("%s-%" G_GINT64_FORMAT, prgname,
+      g_date_time_to_unix (date_time));
+
+  GST_DEBUG_BIN_TO_DOT_FILE (GST_BIN (priv->pipeline),
+      GST_DEBUG_GRAPH_SHOW_ALL, filename);
+
+  dot_dir = g_getenv ("GST_DEBUG_DUMP_DOT_DIR");
+  dot_cmd = g_strdup_printf ("dot -Tpng -o %s.png %s.dot",
+      filename,
+      filename);
+  g_shell_parse_argv (dot_cmd, &argc, &argv, NULL);
+
+  if (g_spawn_async (dot_dir,
+          argv,
+          NULL,
+          G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,
+          NULL,
+          NULL,
+          &dot_pid,
+          NULL))
+    {
+      gchar *uri = g_strdup_printf ("file://%s/%s.png", dot_dir, filename);
+      g_child_watch_add (dot_pid, show_png, uri);
+    }
+
+  g_strfreev (argv);
+  g_free (dot_cmd);
+  g_free (filename);
+  g_date_time_unref (date_time);
+}
+
+static void
+empathy_call_window_debug_tp_cb (GtkAction *action,
     EmpathyCallWindow *self)
 {
   empathy_launch_program (BIN_DIR, "empathy-debugger", "-s Empathy.Call");
@@ -758,6 +1426,38 @@ empathy_call_window_about_cb (GtkAction *action,
   empathy_about_dialog_new (GTK_WINDOW (self));
 }
 
+static gboolean
+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. 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->muted)
+    clutter_state_set_state (self->priv->transitions, "fade-out");
+
+  return TRUE;
+}
+
+static gboolean
+empathy_call_window_motion_notify_cb (GtkWidget *widget,
+    GdkEvent *event,
+    EmpathyCallWindow *self)
+{
+  clutter_state_set_state (self->priv->transitions, "fade-in");
+
+  if (self->priv->inactivity_src > 0)
+    g_source_remove (self->priv->inactivity_src);
+
+  self->priv->inactivity_src = g_timeout_add_seconds (3,
+      empathy_call_window_toolbar_timeout, self);
+
+  return FALSE;
+}
+
 static gboolean
 empathy_call_window_configure_event_cb (GtkWidget *widget,
     GdkEvent  *event,
@@ -793,6 +1493,115 @@ empathy_call_window_destroyed_cb (GtkWidget *object,
     }
 }
 
+static void
+empathy_call_window_incoming_call_response_cb (GtkDialog *dialog,
+    gint response_id,
+    EmpathyCallWindow *self)
+{
+  switch (response_id)
+    {
+      case GTK_RESPONSE_ACCEPT:
+        tp_channel_dispatch_operation_handle_with_async (
+            self->priv->pending_cdo, EMPATHY_CALL_BUS_NAME, NULL, NULL);
+
+        tp_clear_object (&self->priv->pending_cdo);
+        tp_clear_object (&self->priv->pending_channel);
+        tp_clear_object (&self->priv->pending_context);
+
+        break;
+      case GTK_RESPONSE_CANCEL:
+        tp_channel_dispatch_operation_close_channels_async (
+            self->priv->pending_cdo, NULL, NULL);
+
+        empathy_call_window_status_message (self, _("Disconnected"));
+        self->priv->call_state = DISCONNECTED;
+        break;
+      default:
+        g_warn_if_reached ();
+    }
+}
+
+static void
+empathy_call_window_set_state_ringing (EmpathyCallWindow *self)
+{
+  gboolean video;
+
+  g_assert (self->priv->call_state != CONNECTED);
+
+  video = tp_call_channel_has_initial_video (self->priv->pending_channel, NULL);
+
+  empathy_call_window_status_message (self, _("Incoming call"));
+  self->priv->call_state = RINGING;
+
+  self->priv->incoming_call_dialog = gtk_message_dialog_new (
+      GTK_WINDOW (self), GTK_DIALOG_MODAL,
+      GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
+      video ? _("Incoming video call from %s") : _("Incoming call from %s"),
+      empathy_contact_get_alias (self->priv->contact));
+
+  gtk_dialog_add_buttons (GTK_DIALOG (self->priv->incoming_call_dialog),
+      _("Reject"), GTK_RESPONSE_CANCEL,
+      _("Answer"), GTK_RESPONSE_ACCEPT,
+      NULL);
+
+  g_signal_connect (self->priv->incoming_call_dialog, "response",
+      G_CALLBACK (empathy_call_window_incoming_call_response_cb), self);
+  gtk_widget_show (self->priv->incoming_call_dialog);
+}
+
+static void
+empathy_call_window_cdo_invalidated_cb (TpProxy *channel,
+    guint domain,
+    gint code,
+    gchar *message,
+    EmpathyCallWindow *self)
+{
+  tp_clear_object (&self->priv->pending_cdo);
+  tp_clear_object (&self->priv->pending_channel);
+  tp_clear_object (&self->priv->pending_context);
+
+  /* We don't know if the incoming call has been accepted or not, so we
+   * assume it hasn't and if it has, we'll set the proper status when
+   * we get the new handler. */
+  empathy_call_window_status_message (self, _("Disconnected"));
+  self->priv->call_state = DISCONNECTED;
+
+  gtk_widget_destroy (self->priv->incoming_call_dialog);
+  self->priv->incoming_call_dialog = NULL;
+}
+
+void
+empathy_call_window_start_ringing (EmpathyCallWindow *self,
+    TpCallChannel *channel,
+    TpChannelDispatchOperation *dispatch_operation,
+    TpAddDispatchOperationContext *context)
+{
+  g_assert (self->priv->pending_channel == NULL);
+  g_assert (self->priv->pending_context == NULL);
+  g_assert (self->priv->pending_cdo == NULL);
+
+  /* Start ringing and delay until the user answers or hangs. */
+  self->priv->pending_channel = g_object_ref (channel);
+  self->priv->pending_context = g_object_ref (context);
+  self->priv->pending_cdo = g_object_ref (dispatch_operation);
+
+  g_signal_connect (self->priv->pending_cdo, "invalidated",
+      G_CALLBACK (empathy_call_window_cdo_invalidated_cb), self);
+
+  empathy_call_window_set_state_ringing (self);
+  tp_add_dispatch_operation_context_accept (context);
+}
+
+static void
+mic_button_clicked (GtkWidget *button,
+    EmpathyCallWindow *self)
+{
+  /* Toggle the muted state. We rely on audio_input_mute_notify_cb to update
+   * the icon. */
+  empathy_audio_src_set_mute (EMPATHY_GST_AUDIO_SRC (self->priv->audio_input),
+      !self->priv->muted);
+}
+
 static void
 empathy_call_window_init (EmpathyCallWindow *self)
 {
@@ -800,26 +1609,32 @@ empathy_call_window_init (EmpathyCallWindow *self)
   GtkBuilder *gui;
   GtkWidget *top_vbox;
   gchar *filename;
-  ClutterConstraint *size_constraint;
+  ClutterConstraint *constraint;
   ClutterActor *remote_avatar;
-  GtkStyleContext *context;
-  GdkRGBA rgba;
-  ClutterColor bg;
+  ClutterColor black = { 0, 0, 0, 0 };
+  ClutterMargin overlay_margin = { OVERLAY_MARGIN, OVERLAY_MARGIN,
+    OVERLAY_MARGIN, OVERLAY_MARGIN };
 
   priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (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,
     "call_window_vbox", &top_vbox,
     "errors_vbox", &priv->errors_vbox,
     "pane", &priv->pane,
     "remote_user_name_toolbar", &priv->remote_user_name_toolbar,
+    "remote_user_status_toolbar", &priv->remote_user_status_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,
+    "microphone_icon", &priv->microphone_icon,
+    "volume", &priv->volume_button,
     "camera", &priv->camera_button,
     "hangup", &priv->hangup_button,
     "dialpad", &priv->dialpad_button,
@@ -827,6 +1642,7 @@ empathy_call_window_init (EmpathyCallWindow *self)
     "bottom_toolbar", &priv->bottom_toolbar,
     "ui_manager", &priv->ui_manager,
     "menufullscreen", &priv->menu_fullscreen,
+    "menupreviewswap", &priv->menu_swap_camera,
     "details_vbox",  &priv->details_vbox,
     "vcodec_encoding_label", &priv->vcodec_encoding_label,
     "acodec_encoding_label", &priv->acodec_encoding_label,
@@ -847,20 +1663,21 @@ empathy_call_window_init (EmpathyCallWindow *self)
     "hangup", "clicked", empathy_call_window_hangup_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,
     "menusettings", "activate", empathy_call_window_settings_cb,
     "menucontents", "activate", empathy_call_window_contents_cb,
-    "menudebug", "activate", empathy_call_window_debug_cb,
+    "menudebuggst", "activate", empathy_call_window_debug_gst_cb,
+    "menudebugtp", "activate", empathy_call_window_debug_tp_cb,
     "menuabout", "activate", empathy_call_window_about_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,
+    "menupreviewswap", "activate", empathy_call_window_swap_camera_cb,
     NULL);
 
+  empathy_set_css_provider (GTK_WIDGET (self));
   gtk_action_set_sensitive (priv->menu_fullscreen, FALSE);
 
   priv->camera_monitor = empathy_camera_monitor_dup_singleton ();
@@ -869,36 +1686,39 @@ empathy_call_window_init (EmpathyCallWindow *self)
       priv->camera_button, "sensitive",
       G_BINDING_SYNC_CREATE);
 
-  priv->lock = g_mutex_new ();
+  g_signal_connect (priv->camera_monitor, "added",
+      G_CALLBACK (empathy_call_window_camera_added_cb), self);
+  g_signal_connect (priv->camera_monitor, "removed",
+      G_CALLBACK (empathy_call_window_camera_removed_cb), self);
+
+  g_signal_connect (priv->mic_button, "clicked",
+      G_CALLBACK (mic_button_clicked), self);
+
+  g_mutex_init (&priv->lock);
 
   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);
+  priv->content_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,
+      CONTENT_HBOX_SPACING);
   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);
+  /* main contents remote avatar/video box */
+  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 ();
 
-  /* 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);
+  gtk_widget_set_size_request (priv->video_container,
+      REMOTE_VIDEO_DEFAULT_WIDTH, REMOTE_VIDEO_DEFAULT_HEIGHT);
+
+  /* Set the background black */
   clutter_stage_set_color (
       CLUTTER_STAGE (gtk_clutter_embed_get_stage (
           GTK_CLUTTER_EMBED (priv->video_container))),
-      &bg);
+      &black);
 
   clutter_container_add (
       CLUTTER_CONTAINER (gtk_clutter_embed_get_stage (
@@ -906,18 +1726,33 @@ empathy_call_window_init (EmpathyCallWindow *self)
       priv->video_box,
       NULL);
 
-  size_constraint = clutter_bind_constraint_new (
+  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);
+  clutter_actor_add_constraint (priv->video_box, constraint);
 
   priv->remote_user_avatar_widget = gtk_image_new ();
   remote_avatar = gtk_clutter_actor_new_with_contents (
       priv->remote_user_avatar_widget);
+  make_background_transparent (GTK_CLUTTER_ACTOR (remote_avatar));
 
   clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_box),
       remote_avatar);
 
+  /* 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_bin, &overlay_margin);
+
+  clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
+      priv->overlay_bin,
+      CLUTTER_BIN_ALIGNMENT_FILL, CLUTTER_BIN_ALIGNMENT_FILL);
+
+  empathy_call_window_create_preview_rectangles (self);
+
   gtk_box_pack_start (GTK_BOX (priv->content_hbox),
       priv->video_container, TRUE, TRUE,
       CONTENT_HBOX_CHILDREN_PACKING_PADDING);
@@ -927,15 +1762,52 @@ empathy_call_window_init (EmpathyCallWindow *self)
   create_audio_input (self);
   create_video_input (self);
 
+  priv->floating_toolbar = gtk_clutter_actor_new ();
+  clutter_actor_set_reactive (priv->floating_toolbar, TRUE);
+  make_background_transparent (GTK_CLUTTER_ACTOR (priv->floating_toolbar));
+
+  gtk_style_context_add_class (
+      gtk_widget_get_style_context (GTK_WIDGET (priv->bottom_toolbar)),
+      GTK_STYLE_CLASS_OSD);
+  gtk_widget_reparent (priv->bottom_toolbar,
+      gtk_clutter_actor_get_widget (GTK_CLUTTER_ACTOR (priv->floating_toolbar)));
+
+  clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->overlay_layout),
+      priv->floating_toolbar,
+      CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_END);
+
+  clutter_actor_raise_top (priv->floating_toolbar);
+
+  /* Transitions for the floating toolbar */
+  priv->transitions = clutter_state_new ();
+
+  /* all transitions last for 2s */
+  clutter_state_set_duration (priv->transitions, NULL, NULL, 2000);
+
+  /* transition from any state to "fade-out" state */
+  clutter_state_set (priv->transitions, NULL, "fade-out",
+      priv->floating_toolbar,
+      "opacity", CLUTTER_EASE_OUT_QUAD, 0,
+      NULL);
+
+  /* transition from any state to "fade-in" state */
+  clutter_state_set (priv->transitions, NULL, "fade-in",
+      priv->floating_toolbar,
+      "opacity", CLUTTER_EASE_OUT_QUAD, 255,
+      NULL);
+
+  /* put the actor into the "fade-in" state with no animation */
+  clutter_state_warp_to_state (priv->transitions, "fade-in");
+
   /* The call will be started as soon the pipeline is playing */
   priv->start_call_when_playing = TRUE;
 
-  priv->dtmf_panel = empathy_create_dtmf_dialpad (G_OBJECT (self),
-      G_CALLBACK (dtmf_button_pressed_cb),
-      G_CALLBACK (dtmf_button_released_cb));
+  priv->dtmf_panel = empathy_dialpad_widget_new ();
+  g_signal_connect (priv->dtmf_panel, "start-tone",
+      G_CALLBACK (dtmf_start_tone_cb), self);
 
   gtk_box_pack_start (GTK_BOX (priv->pane), priv->dtmf_panel,
-      FALSE, FALSE, 0);
+      FALSE, FALSE, 6);
 
   gtk_box_pack_start (GTK_BOX (priv->pane), priv->details_vbox,
       FALSE, FALSE, 0);
@@ -952,6 +1824,11 @@ empathy_call_window_init (EmpathyCallWindow *self)
   empathy_call_window_fullscreen_set_video_widget (priv->fullscreen,
       priv->video_container);
 
+  /* We hide the bottom toolbar after 3s of inactivity and show it
+   * again on mouse movement */
+  priv->inactivity_src = g_timeout_add_seconds (3,
+      empathy_call_window_toolbar_timeout, self);
+
   g_signal_connect (G_OBJECT (priv->fullscreen->leave_fullscreen_button),
       "clicked", G_CALLBACK (empathy_call_window_fullscreen_cb), self);
 
@@ -967,19 +1844,19 @@ empathy_call_window_init (EmpathyCallWindow *self)
   g_signal_connect (G_OBJECT (self), "key-press-event",
       G_CALLBACK (empathy_call_window_key_press_cb), self);
 
-  priv->timer = g_timer_new ();
+  g_signal_connect (self, "motion-notify-event",
+      G_CALLBACK (empathy_call_window_motion_notify_cb), self);
 
   g_object_ref (priv->ui_manager);
   g_object_unref (gui);
 
   priv->sound_mgr = empathy_sound_manager_dup_singleton ();
   priv->mic_menu = empathy_mic_menu_new (self);
+  priv->camera_menu = empathy_camera_menu_new (self);
 
   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);
+  gtk_window_set_default_size (GTK_WINDOW (self), 580, 480);
 
   empathy_geometry_bind (GTK_WINDOW (self), "call-window");
   /* These signals are used to track the window position and save it
@@ -994,7 +1871,6 @@ empathy_call_window_init (EmpathyCallWindow *self)
 
   /* Don't display labels in both toolbars */
   gtk_toolbar_set_style (GTK_TOOLBAR (priv->toolbar), GTK_TOOLBAR_ICONS);
-  gtk_toolbar_set_style (GTK_TOOLBAR (priv->bottom_toolbar), GTK_TOOLBAR_ICONS);
 }
 
 /* Instead of specifying a width and a height, we specify only one size. That's
@@ -1041,7 +1917,7 @@ set_window_title (EmpathyCallWindow *self)
     }
   else
     {
-      gtk_window_set_title (GTK_WINDOW (self), _("Call with %d participants"));
+      g_warning ("Unknown remote contact!");
     }
 }
 
@@ -1051,12 +1927,20 @@ set_remote_user_name (EmpathyCallWindow *self,
 {
   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);
+  gtk_label_set_text (GTK_LABEL (self->priv->remote_user_name_toolbar), alias);
+
+  if (status != NULL) {
+    gchar *markup;
+
+    markup = g_markup_printf_escaped ("<small>%s</small>", status);
+    gtk_label_set_markup (GTK_LABEL (self->priv->remote_user_status_toolbar),
+      markup);
+    g_free (markup);
+  } else {
+    gtk_label_set_markup (GTK_LABEL (self->priv->remote_user_status_toolbar),
+      "");
+  }
 }
 
 static void
@@ -1357,25 +2241,33 @@ empathy_call_window_constructed (GObject *object)
 {
   EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
-  TpyCallChannel *call;
+  TpCallChannel *call;
+  TpCallState state;
 
   g_assert (priv->handler != NULL);
 
   g_object_get (priv->handler, "call-channel", &call, NULL);
-  priv->outgoing = (call == NULL);
-  if (call != NULL)
-    g_object_unref (call);
+  state = tp_call_channel_get_state (call, NULL, NULL, NULL);
+  priv->outgoing = (state == TP_CALL_STATE_PENDING_INITIATOR);
+  tp_clear_object (&call);
 
-  g_object_get (priv->handler, "target-contact", &priv->contact, NULL);
+  priv->contact = empathy_call_handler_get_contact (priv->handler);
   g_assert (priv->contact != NULL);
+  g_object_ref (priv->contact);
+
+  if (!empathy_contact_can_voip_video (priv->contact))
+    {
+      gtk_widget_set_sensitive (priv->video_call_button, FALSE);
+      gtk_widget_set_sensitive (priv->camera_button, FALSE);
+    }
 
   empathy_call_window_setup_avatars (self, priv->handler);
   empathy_call_window_set_state_connecting (self);
 
   if (!empathy_call_handler_has_initial_video (priv->handler))
     {
-      gtk_toggle_tool_button_set_active (
-          GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), FALSE);
+      gtk_toggle_button_set_active (
+          GTK_TOGGLE_BUTTON (priv->camera_button), FALSE);
     }
   /* If call has InitialVideo, the preview will be started once the call has
    * been started (start_call()). */
@@ -1456,6 +2348,13 @@ empathy_call_window_class_init (
     G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
   g_object_class_install_property (object_class,
     PROP_CALL_HANDLER, param_spec);
+
+  signals[SIG_INHIBIT] = g_signal_new ("inhibit",
+      G_OBJECT_CLASS_TYPE (empathy_call_window_class),
+      G_SIGNAL_RUN_LAST,
+      0, NULL, NULL, NULL,
+      G_TYPE_NONE,
+      1, G_TYPE_BOOLEAN);
 }
 
 void
@@ -1487,6 +2386,12 @@ empathy_call_window_dispose (GObject *object)
       priv->got_video_src = 0;
     }
 
+  if (priv->inactivity_src > 0)
+    {
+      g_source_remove (priv->inactivity_src);
+      priv->inactivity_src = 0;
+    }
+
   tp_clear_object (&priv->pipeline);
   tp_clear_object (&priv->video_input);
   tp_clear_object (&priv->audio_input);
@@ -1495,6 +2400,10 @@ empathy_call_window_dispose (GObject *object)
   tp_clear_object (&priv->fullscreen);
   tp_clear_object (&priv->camera_monitor);
   tp_clear_object (&priv->settings);
+  tp_clear_object (&priv->sound_mgr);
+  tp_clear_object (&priv->mic_menu);
+  tp_clear_object (&priv->camera_menu);
+  tp_clear_object (&priv->transitions);
 
   g_list_free_full (priv->notifiers, g_object_unref);
 
@@ -1502,17 +2411,7 @@ empathy_call_window_dispose (GObject *object)
     g_source_remove (priv->timer_id);
   priv->timer_id = 0;
 
-  if (priv->contact != NULL)
-    {
-      g_signal_handlers_disconnect_by_func (priv->contact,
-          contact_name_changed_cb, self);
-      priv->contact = NULL;
-    }
-
-
-  tp_clear_object (&priv->sound_mgr);
-
-  tp_clear_object (&priv->mic_menu);
+  tp_clear_object (&priv->contact);
 
   G_OBJECT_CLASS (empathy_call_window_parent_class)->dispose (object);
 }
@@ -1539,7 +2438,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);
 
@@ -1554,6 +2453,25 @@ empathy_call_window_new (EmpathyCallHandler *handler)
     g_object_new (EMPATHY_TYPE_CALL_WINDOW, "handler", handler, NULL));
 }
 
+void
+empathy_call_window_present (EmpathyCallWindow *self,
+    EmpathyCallHandler *handler)
+{
+  g_return_if_fail (EMPATHY_IS_CALL_HANDLER (handler));
+
+  empathy_window_present (GTK_WINDOW (self));
+
+  if (self->priv->call_state == DISCONNECTED)
+    {
+      /* start a new call if one is not already in progress */
+      tp_clear_object (&self->priv->handler);
+      self->priv->handler = g_object_ref (handler);
+      empathy_call_window_connect_handler (self);
+
+      empathy_call_window_restart_call (self);
+    }
+}
+
 static void
 empathy_call_window_conference_added_cb (EmpathyCallHandler *handler,
   GstElement *conference, gpointer user_data)
@@ -1587,6 +2505,9 @@ empathy_call_window_conference_removed_cb (EmpathyCallHandler *handler,
   EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
 
+  g_list_free_full (priv->notifiers, g_object_unref);
+  priv->notifiers = NULL;
+
   gst_bin_remove (GST_BIN (priv->pipeline), conference);
   gst_element_set_state (conference, GST_STATE_NULL);
 }
@@ -1618,6 +2539,7 @@ empathy_call_window_reset_pipeline (EmpathyCallWindow *self)
       if (priv->audio_output != NULL)
         g_object_unref (priv->audio_output);
       priv->audio_output = NULL;
+      priv->audio_output_added = FALSE;
 
       if (priv->video_tee != NULL)
         g_object_unref (priv->video_tee);
@@ -1627,6 +2549,15 @@ empathy_call_window_reset_pipeline (EmpathyCallWindow *self)
         clutter_actor_destroy (priv->video_preview);
       priv->video_preview = NULL;
 
+      /* If we destroy the preview while it's being dragged, we won't
+       * get the ::drag-end signal, so manually destroy the clone */
+      if (priv->drag_preview != NULL)
+        {
+          clutter_actor_destroy (priv->drag_preview);
+          empathy_call_window_show_preview_rectangles (self, FALSE);
+          priv->drag_preview = NULL;
+        }
+
       priv->funnel = NULL;
 
       create_pipeline (self);
@@ -1667,9 +2598,18 @@ empathy_call_window_disconnected (EmpathyCallWindow *self,
   /* Leave full screen mode if needed */
   gtk_window_unfullscreen (GTK_WINDOW (self));
 
+  g_signal_emit (self, signals[SIG_INHIBIT], 0, FALSE);
+
   gtk_action_set_sensitive (priv->menu_fullscreen, FALSE);
   gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
 
+  /* Create the video input and then turn on the camera
+   * menu, so that the active camera gets marked as such.
+   */
+  if (priv->video_input == NULL)
+    create_video_input (self);
+  empathy_camera_menu_set_sensitive (priv->camera_menu, TRUE);
+
   could_reset_pipeline = empathy_call_window_reset_pipeline (self);
 
   if (priv->call_state == CONNECTING)
@@ -1678,9 +2618,12 @@ empathy_call_window_disconnected (EmpathyCallWindow *self,
   if (priv->call_state != REDIALING)
     priv->call_state = DISCONNECTED;
 
+  /* Show the toolbar */
+  clutter_state_set_state (priv->transitions, "fade-in");
+
   if (could_reset_pipeline)
     {
-      g_mutex_lock (priv->lock);
+      g_mutex_lock (&priv->lock);
 
       g_timer_stop (priv->timer);
 
@@ -1688,7 +2631,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
@@ -1704,8 +2647,8 @@ empathy_call_window_disconnected (EmpathyCallWindow *self,
       gtk_widget_set_sensitive (priv->mic_button, FALSE);
 
       /* Be sure that the mic button is enabled */
-      gtk_toggle_tool_button_set_active (
-          GTK_TOGGLE_TOOL_BUTTON (priv->mic_button), TRUE);
+      empathy_audio_src_set_mute (
+          EMPATHY_GST_AUDIO_SRC (self->priv->audio_input), FALSE);
 
       if (priv->camera_state == CAMERA_STATE_ON)
         {
@@ -1754,15 +2697,34 @@ empathy_call_window_channel_closed_cb (EmpathyCallHandler *handler,
 }
 
 static gboolean
-empathy_call_window_sink_removed_cb (EmpathyCallHandler *handler,
-    GstPad *sink,
-    FsMediaType media_type,
+empathy_call_window_content_is_raw (TfContent *content)
+{
+  FsConference *conference;
+  gboolean israw;
+
+  g_object_get (content, "fs-conference", &conference, NULL);
+  g_assert (conference != NULL);
+
+  /* FIXME: Ugly hack, update when moving a packetization property into
+   * farstream */
+  israw = g_str_has_prefix (GST_OBJECT_NAME (conference), "fsrawconf");
+  gst_object_unref (conference);
+
+  return israw;
+}
+
+static gboolean
+empathy_call_window_content_removed_cb (EmpathyCallHandler *handler,
+    TfContent *content,
     EmpathyCallWindow *self)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
+  FsMediaType media_type;
 
   DEBUG ("removing content");
 
+  g_object_get (content, "media-type", &media_type, NULL);
+
   /*
    * This assumes that there is only one video stream per channel...
    */
@@ -1781,7 +2743,6 @@ empathy_call_window_sink_removed_cb (EmpathyCallHandler *handler,
           gst_bin_remove (GST_BIN (priv->pipeline), output);
           gst_bin_remove (GST_BIN (priv->pipeline), priv->funnel);
           priv->funnel = NULL;
-          return TRUE;
         }
     }
   else if (media_type == FS_MEDIA_TYPE_AUDIO)
@@ -1790,13 +2751,47 @@ empathy_call_window_sink_removed_cb (EmpathyCallHandler *handler,
         {
           gst_element_set_state (priv->audio_output, GST_STATE_NULL);
 
-          gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
+          if (priv->audio_output_added)
+            gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
           priv->audio_output = NULL;
-          return TRUE;
+          priv->audio_output_added = FALSE;
         }
     }
+  else
+    {
+      g_assert_not_reached ();
+    }
 
-  return FALSE;
+  return TRUE;
+}
+
+static void
+empathy_call_window_framerate_changed_cb (EmpathyCallHandler *handler,
+    guint framerate,
+    EmpathyCallWindow *self)
+{
+  EmpathyCallWindowPriv *priv = GET_PRIV (self);
+
+  DEBUG ("Framerate changed to %u", framerate);
+
+  if (priv->video_input != NULL)
+    empathy_video_src_set_framerate (priv->video_input, framerate);
+}
+
+static void
+empathy_call_window_resolution_changed_cb (EmpathyCallHandler *handler,
+    guint width,
+    guint height,
+    EmpathyCallWindow *self)
+{
+  EmpathyCallWindowPriv *priv = GET_PRIV (self);
+
+  DEBUG ("Resolution changed to %ux%u", width, height);
+
+  if (priv->video_input != NULL)
+    {
+      empathy_video_src_set_resolution (priv->video_input, width, height);
+    }
 }
 
 /* Called with global lock held */
@@ -1810,12 +2805,15 @@ empathy_call_window_get_video_sink_pad (EmpathyCallWindow *self)
   if (priv->funnel == NULL)
     {
       output = priv->video_output_sink;
-
+#ifdef HAVE_GST1
+      priv->funnel = gst_element_factory_make ("funnel", NULL);
+#else
       priv->funnel = gst_element_factory_make ("fsfunnel", NULL);
+#endif
 
       if (!priv->funnel)
         {
-          g_warning ("Could not create fsfunnel");
+          g_warning ("Could not create video funnel");
           return NULL;
         }
 
@@ -1851,8 +2849,11 @@ empathy_call_window_get_video_sink_pad (EmpathyCallWindow *self)
           goto error_output_added;
         }
     }
-
+#ifdef HAVE_GST1
+  pad = gst_element_get_request_pad (priv->funnel, "sink_%u");
+#else
   pad = gst_element_get_request_pad (priv->funnel, "sink%d");
+#endif
 
   if (!pad)
     g_warning ("Could not get request pad from funnel");
@@ -1881,17 +2882,15 @@ empathy_call_window_get_video_sink_pad (EmpathyCallWindow *self)
 
 /* Called with global lock held */
 static GstPad *
-empathy_call_window_get_audio_sink_pad (EmpathyCallWindow *self)
+empathy_call_window_get_audio_sink_pad (EmpathyCallWindow *self,
+  TfContent *content)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
   GstPad *pad;
   GstPadTemplate *template;
 
-  if (priv->audio_output == NULL)
+  if (!priv->audio_output_added)
     {
-      priv->audio_output = empathy_audio_sink_new ();
-      g_object_ref_sink (priv->audio_output);
-
       if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_output))
         {
           g_warning ("Could not add audio sink to pipeline");
@@ -1904,6 +2903,7 @@ empathy_call_window_get_audio_sink_pad (EmpathyCallWindow *self)
           g_warning ("Could not start audio sink");
           goto error;
         }
+      priv->audio_output_added = TRUE;
     }
 
   template = gst_element_class_get_pad_template (
@@ -1944,8 +2944,9 @@ empathy_call_window_update_timer (gpointer user_data)
 
   if (priv->call_state == HELD)
     status = _("On hold");
-  else if (!gtk_toggle_tool_button_get_active (
-      GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
+  else if (priv->call_state == DISCONNECTED)
+    status = _("Disconnected");
+  else if (priv->muted)
     status = _("Mute");
   else
     status = _("Duration");
@@ -1960,14 +2961,37 @@ empathy_call_window_update_timer (gpointer user_data)
   return TRUE;
 }
 
-#if 0
+enum
+{
+  EMP_RESPONSE_BALANCE
+};
+
+static void
+on_error_infobar_response_cb (GtkInfoBar *info_bar,
+    gint response_id,
+    gpointer user_data)
+{
+  switch (response_id)
+    {
+      case GTK_RESPONSE_CLOSE:
+        gtk_widget_destroy (GTK_WIDGET (info_bar));
+        break;
+      case EMP_RESPONSE_BALANCE:
+        empathy_url_show (GTK_WIDGET (info_bar),
+            g_object_get_data (G_OBJECT (info_bar), "uri"));
+        break;
+    }
+}
+
 static void
 display_error (EmpathyCallWindow *self,
-    TpyCallChannel *call,
     const gchar *img,
     const gchar *title,
     const gchar *desc,
-    const gchar *details)
+    const gchar *details,
+    const gchar *button_text,
+    const gchar *uri,
+    gint button_response)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
   GtkWidget *info_bar;
@@ -1979,15 +3003,25 @@ display_error (EmpathyCallWindow *self,
   gchar *txt;
 
   /* Create info bar */
-  info_bar = gtk_info_bar_new_with_buttons (GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
-      NULL);
+  info_bar = gtk_info_bar_new ();
+
+  if (button_text != NULL)
+    {
+      gtk_info_bar_add_button (GTK_INFO_BAR (info_bar),
+          button_text, button_response);
+      g_object_set_data_full (G_OBJECT (info_bar),
+          "uri", g_strdup (uri), g_free);
+    }
+
+  gtk_info_bar_add_button (GTK_INFO_BAR (info_bar),
+      GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
 
   gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_WARNING);
 
   content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar));
 
   /* hbox containing the image and the messages vbox */
-  hbox = gtk_hbox_new (FALSE, 3);
+  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
   gtk_container_add (GTK_CONTAINER (content_area), hbox);
 
   /* Add image */
@@ -1995,7 +3029,7 @@ display_error (EmpathyCallWindow *self,
   gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
 
   /* vbox containing the main message and the details expander */
-  vbox = gtk_vbox_new (FALSE, 3);
+  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
   gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
 
   /* Add text */
@@ -2029,16 +3063,17 @@ display_error (EmpathyCallWindow *self,
     }
 
   g_signal_connect (info_bar, "response",
-      G_CALLBACK (gtk_widget_destroy), NULL);
+      G_CALLBACK (on_error_infobar_response_cb), NULL);
 
   gtk_box_pack_start (GTK_BOX (priv->errors_vbox), info_bar,
       FALSE, FALSE, CONTENT_HBOX_CHILDREN_PACKING_PADDING);
   gtk_widget_show_all (info_bar);
 }
 
+#if 0
 static gchar *
 media_stream_error_to_txt (EmpathyCallWindow *self,
-    TpyCallChannel *call,
+    TpCallChannel *call,
     gboolean audio,
     TpMediaStreamError error)
 {
@@ -2081,7 +3116,7 @@ media_stream_error_to_txt (EmpathyCallWindow *self,
 
       case TP_MEDIA_STREAM_ERROR_INVALID_CM_BEHAVIOR:
         tp_connection_parse_object_path (
-            tp_channel_borrow_connection (TP_CHANNEL (call)),
+            tp_channel_get_connection (TP_CHANNEL (call)),
             NULL, &cm);
 
         url = g_strdup_printf ("http://bugs.freedesktop.org/enter_bug.cgi?"
@@ -2110,7 +3145,7 @@ media_stream_error_to_txt (EmpathyCallWindow *self,
 
 static void
 empathy_call_window_stream_error (EmpathyCallWindow *self,
-    TpyCallChannel *call,
+    TpCallChannel *call,
     gboolean audio,
     guint code,
     const gchar *msg,
@@ -2134,7 +3169,7 @@ empathy_call_window_stream_error (EmpathyCallWindow *self,
 }
 
 static void
-empathy_call_window_audio_stream_error (TpyCallChannel *call,
+empathy_call_window_audio_stream_error (TpCallChannel *call,
     guint code,
     const gchar *msg,
     EmpathyCallWindow *self)
@@ -2144,7 +3179,7 @@ empathy_call_window_audio_stream_error (TpyCallChannel *call,
 }
 
 static void
-empathy_call_window_video_stream_error (TpyCallChannel *call,
+empathy_call_window_video_stream_error (TpCallChannel *call,
     guint code,
     const gchar *msg,
     EmpathyCallWindow *self)
@@ -2154,16 +3189,73 @@ empathy_call_window_video_stream_error (TpyCallChannel *call,
 }
 #endif
 
+static void
+show_balance_error (EmpathyCallWindow *self)
+{
+  TpChannel *call;
+  TpConnection *conn;
+  gchar *balance, *tmp;
+  const gchar *uri, *currency;
+  gint amount;
+  guint scale;
+
+  g_object_get (self->priv->handler,
+      "call-channel", &call,
+      NULL);
+
+  conn = tp_channel_get_connection (call);
+  g_object_unref (call);
+
+  uri = tp_connection_get_balance_uri (conn);
+
+  if (!tp_connection_get_balance (conn, &amount, &scale, &currency))
+    {
+      /* unknown balance */
+      balance = g_strdup ("(--)");
+    }
+  else
+    {
+      char *money = empathy_format_currency (amount, scale, currency);
+
+      balance = g_strdup_printf ("%s %s",
+          currency, money);
+      g_free (money);
+    }
+
+  tmp = g_strdup_printf (_("Your current balance is %s."), balance),
+
+  display_error (self,
+      NULL,
+      _("Sorry, you don’t have enough credit for that call."),
+      tmp, NULL,
+      _("Top Up"),
+      uri,
+      EMP_RESPONSE_BALANCE);
+
+  g_free (tmp);
+  g_free (balance);
+}
+
 static void
 empathy_call_window_state_changed_cb (EmpathyCallHandler *handler,
-    TpyCallState state,
+    TpCallState state,
+    gchar *reason,
     EmpathyCallWindow *self)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
-  TpyCallChannel *call;
+  TpCallChannel *call;
   gboolean can_send_video;
 
-  if (state != TPY_CALL_STATE_ACCEPTED)
+  if (state == TP_CALL_STATE_ENDED)
+    {
+      DEBUG ("Call ended: %s", (reason != NULL && reason[0] != '\0') ? reason : "unspecified reason");
+      empathy_call_window_disconnected (self, TRUE);
+      if (!tp_strdiff (reason, TP_ERROR_STR_INSUFFICIENT_BALANCE))
+          show_balance_error (self);
+      return;
+    }
+
+  if (state != TP_CALL_STATE_ACCEPTED)
     return;
 
   if (priv->call_state == CONNECTED)
@@ -2180,7 +3272,7 @@ empathy_call_window_state_changed_cb (EmpathyCallHandler *handler,
 
   g_object_get (priv->handler, "call-channel", &call, NULL);
 
-  if (tpy_call_channel_has_dtmf (call))
+  if (tp_call_channel_has_dtmf (call))
     gtk_widget_set_sensitive (priv->dtmf_panel, TRUE);
 
   if (priv->video_input == NULL)
@@ -2197,12 +3289,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);
 
@@ -2218,6 +3310,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_bin);
     }
 
   return FALSE;
@@ -2241,6 +3334,27 @@ empathy_call_window_check_video_cb (gpointer data)
 }
 
 /* Called from the streaming thread */
+#ifdef HAVE_GST1
+static GstPadProbeReturn
+empathy_call_window_video_probe_cb (GstPad *pad,
+    GstPadProbeInfo *info,
+    gpointer user_data)
+{
+    EmpathyCallWindow *self = user_data;
+
+  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 GST_PAD_PROBE_OK;
+}
+#else
 static gboolean
 empathy_call_window_video_probe_cb (GstPad *pad,
     GstMiniObject *mini_obj,
@@ -2262,34 +3376,44 @@ empathy_call_window_video_probe_cb (GstPad *pad,
 
   return TRUE;
 }
+#endif
 
 /* Called from the streaming thread */
 static gboolean
 empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
-  GstPad *src, guint media_type, gpointer user_data)
+  TfContent *content, GstPad *src, gpointer user_data)
 {
   EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
   gboolean retval = FALSE;
+  guint media_type;
 
   GstPad *pad;
 
-  g_mutex_lock (priv->lock);
+  g_mutex_lock (&priv->lock);
+
+  g_object_get (content, "media-type", &media_type, NULL);
 
   switch (media_type)
     {
       case TP_MEDIA_STREAM_TYPE_AUDIO:
-        pad = empathy_call_window_get_audio_sink_pad (self);
+        pad = empathy_call_window_get_audio_sink_pad (self, content);
         break;
       case TP_MEDIA_STREAM_TYPE_VIDEO:
         g_idle_add (empathy_call_window_show_video_output_cb, self);
         pad = empathy_call_window_get_video_sink_pad (self);
 
+#ifdef HAVE_GST1
+        gst_pad_add_probe (src,
+            GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST,
+            empathy_call_window_video_probe_cb, self, NULL);
+#else
         gst_pad_add_data_probe (src,
             G_CALLBACK (empathy_call_window_video_probe_cb), self);
+#endif
         if (priv->got_video_src > 0)
           g_source_remove (priv->got_video_src);
-        priv->got_video_src = g_timeout_add_seconds (5,
+        priv->got_video_src = g_timeout_add_seconds (1,
             empathy_call_window_check_video_cb, self);
         break;
       default:
@@ -2339,23 +3463,93 @@ empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
     }
 
 
-  g_mutex_unlock (priv->lock);
+  g_mutex_unlock (&priv->lock);
 
   return TRUE;
 }
 
+static void
+empathy_call_window_prepare_audio_output (EmpathyCallWindow *self,
+  TfContent *content)
+{
+  EmpathyCallWindowPriv *priv = self->priv;
+
+  g_assert (priv->audio_output_added == FALSE);
+  g_assert (priv->audio_output == FALSE);
+
+  priv->audio_output = empathy_audio_sink_new ();
+  g_object_ref_sink (priv->audio_output);
+
+  /* volume button to output volume linking */
+  g_object_bind_property (priv->audio_output, "volume",
+    priv->volume_button, "value",
+    G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+
+  g_object_bind_property_full (content, "requested-output-volume",
+    priv->audio_output, "volume",
+    G_BINDING_DEFAULT,
+    audio_control_volume_to_element,
+    element_volume_to_audio_control,
+    NULL, NULL);
+
+  /* Link volumes together, sync the current audio input volume property
+    * back to farstream first */
+  g_object_bind_property_full (priv->audio_output, "volume",
+    content, "reported-output-volume",
+    G_BINDING_SYNC_CREATE,
+    element_volume_to_audio_control,
+    audio_control_volume_to_element,
+    NULL, NULL);
+
+  /* For raw audio conferences assume that the producer of the raw data
+   * has already processed it, so turn off any echo cancellation and any
+   * other audio improvements that come with it */
+  empathy_audio_sink_set_echo_cancel (
+    EMPATHY_GST_AUDIO_SINK (priv->audio_output),
+    !empathy_call_window_content_is_raw (content));
+}
+
+
 static gboolean
-empathy_call_window_sink_added_cb (EmpathyCallHandler *handler,
-  GstPad *sink, FsMediaType media_type, gpointer user_data)
+empathy_call_window_content_added_cb (EmpathyCallHandler *handler,
+  TfContent *content, gpointer user_data)
 {
   EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
-  GstPad *pad;
+  GstPad *sink, *pad;
+  FsMediaType media_type;
   gboolean retval = FALSE;
 
+  g_object_get (content, "media-type", &media_type, "sink-pad", &sink, NULL);
+  g_assert (sink != NULL);
+
   switch (media_type)
     {
       case FS_MEDIA_TYPE_AUDIO:
+
+        /* For raw audio conferences assume that the receiver of the raw data
+         * wants it unprocessed, so turn off any echo cancellation and any
+         * other audio improvements that come with it */
+        empathy_audio_src_set_echo_cancel (
+          EMPATHY_GST_AUDIO_SRC (priv->audio_input),
+          !empathy_call_window_content_is_raw (content));
+
+        /* Link volumes together, sync the current audio input volume property
+         * back to farstream first */
+        g_object_bind_property_full (content, "requested-input-volume",
+          priv->audio_input, "volume",
+          G_BINDING_DEFAULT,
+          audio_control_volume_to_element,
+          element_volume_to_audio_control,
+          NULL, NULL);
+
+        g_object_bind_property_full (priv->audio_input, "volume",
+          content, "reported-input-volume",
+          G_BINDING_SYNC_CREATE,
+          element_volume_to_audio_control,
+          audio_control_volume_to_element,
+          NULL, NULL);
+
         if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_input))
           {
             g_warning ("Could not add audio source to pipeline");
@@ -2373,9 +3567,11 @@ empathy_call_window_sink_added_cb (EmpathyCallHandler *handler,
         if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
           {
             gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_input);
+            gst_object_unref (pad);
             g_warning ("Could not link audio source to farsight");
             break;
           }
+        gst_object_unref (pad);
 
         if (gst_element_set_state (priv->audio_input, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
           {
@@ -2385,12 +3581,19 @@ empathy_call_window_sink_added_cb (EmpathyCallHandler *handler,
             break;
           }
 
+        /* Prepare our audio output, not added yet though */
+        empathy_call_window_prepare_audio_output (self, content);
+
         retval = TRUE;
         break;
       case FS_MEDIA_TYPE_VIDEO:
         if (priv->video_tee != NULL)
           {
+#ifdef HAVE_GST1
+            pad = gst_element_get_request_pad (priv->video_tee, "src_%u");
+#else
             pad = gst_element_get_request_pad (priv->video_tee, "src%d");
+#endif
             if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sink)))
               {
                 g_warning ("Could not link video source input pipeline");
@@ -2405,6 +3608,7 @@ empathy_call_window_sink_added_cb (EmpathyCallHandler *handler,
         g_assert_not_reached ();
     }
 
+  gst_object_unref (sink);
   return retval;
 }
 
@@ -2434,6 +3638,7 @@ empathy_call_window_remove_video_input (EmpathyCallWindow *self)
   priv->video_preview = NULL;
 
   gtk_widget_set_sensitive (priv->camera_button, FALSE);
+  empathy_camera_menu_set_sensitive (priv->camera_menu, FALSE);
 }
 
 static void
@@ -2441,29 +3646,37 @@ start_call (EmpathyCallWindow *self)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
 
+  g_signal_emit (self, signals[SIG_INHIBIT], 0, TRUE);
+
   priv->call_started = TRUE;
   empathy_call_handler_start_call (priv->handler,
       gtk_get_current_event_time ());
 
   if (empathy_call_handler_has_initial_video (priv->handler))
     {
-      TpyCallChannel *call;
-      TpySendingState s;
+      TpCallChannel *call;
+      TpSendingState s;
 
       g_object_get (priv->handler, "call-channel", &call, NULL);
-      s = tpy_call_channel_get_video_state (call);
+      /* If the call channel isn't set yet we're requesting it, if we're
+       * requesting it with initial video it should be PENDING_SEND when we get
+       * it */
+      if (call == NULL)
+        s = TP_SENDING_STATE_PENDING_SEND;
+      else
+        s = empathy_call_channel_get_video_state (call);
 
-      if (s == TPY_SENDING_STATE_PENDING_SEND ||
-          s == TPY_SENDING_STATE_SENDING)
+      if (s == TP_SENDING_STATE_PENDING_SEND ||
+          s == TP_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);
+          gtk_toggle_button_set_active (
+            GTK_TOGGLE_BUTTON (priv->camera_button), TRUE);
         }
       else
         {
-          gtk_toggle_tool_button_set_active (
-            GTK_TOGGLE_TOOL_BUTTON (priv->camera_button), FALSE);
+          gtk_toggle_button_set_active (
+            GTK_TOGGLE_BUTTON (priv->camera_button), FALSE);
 
           if (priv->video_preview == NULL)
             {
@@ -2472,7 +3685,8 @@ start_call (EmpathyCallWindow *self)
             }
         }
 
-      g_object_unref (call);
+      if (call != NULL)
+        g_object_unref (call);
     }
 }
 
@@ -2482,7 +3696,7 @@ empathy_call_window_bus_message (GstBus *bus, GstMessage *message,
 {
   EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
-  GstState newstate;
+  GstState newstate, pending;
 
   empathy_call_handler_bus_message (priv->handler, bus, message);
 
@@ -2506,20 +3720,31 @@ empathy_call_window_bus_message (GstBus *bus, GstMessage *message,
                   start_call (self);
               }
           }
+        if (priv->video_preview_sink != NULL &&
+            GST_MESSAGE_SRC (message) == GST_OBJECT (priv->video_preview_sink))
+          {
+            gst_message_parse_state_changed (message, NULL, &newstate,
+                &pending);
+
+            if (newstate == GST_STATE_PLAYING &&
+                pending == GST_STATE_VOID_PENDING)
+              empathy_call_window_stop_camera_spinning (self);
+          }
         break;
       case GST_MESSAGE_ERROR:
         {
           GError *error = NULL;
           GstElement *gst_error;
           gchar *debug;
+          gchar *name;
 
           gst_message_parse_error (message, &error, &debug);
           gst_error = GST_ELEMENT (GST_MESSAGE_SRC (message));
 
           g_message ("Element error: %s -- %s\n", error->message, debug);
 
-          if (g_str_has_prefix (gst_element_get_name (gst_error),
-                VIDEO_INPUT_ERROR_PREFIX))
+          name = gst_element_get_name (gst_error);
+          if (g_str_has_prefix (name, VIDEO_INPUT_ERROR_PREFIX))
             {
               /* Remove the video input and continue */
               if (priv->video_input != NULL)
@@ -2530,6 +3755,7 @@ empathy_call_window_bus_message (GstBus *bus, GstMessage *message,
             {
               empathy_call_window_disconnected (self, TRUE);
             }
+          g_free (name);
           g_error_free (error);
           g_free (debug);
         }
@@ -2560,8 +3786,10 @@ empathy_call_window_bus_message (GstBus *bus, GstMessage *message,
 }
 
 static void
-empathy_call_window_members_changed_cb (TpyCallChannel *call,
-    GHashTable *members,
+empathy_call_window_members_changed_cb (TpCallChannel *call,
+    GHashTable *updates,
+    GPtrArray *removed,
+    TpCallStateReason *reason,
     EmpathyCallWindow *self)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
@@ -2569,10 +3797,10 @@ empathy_call_window_members_changed_cb (TpyCallChannel *call,
   gpointer key, value;
   gboolean held = FALSE;
 
-  g_hash_table_iter_init (&iter, members);
+  g_hash_table_iter_init (&iter, updates);
   while (g_hash_table_iter_next (&iter, &key, &value))
     {
-      if (GPOINTER_TO_INT (value) & TPY_CALL_MEMBER_FLAG_HELD)
+      if (GPOINTER_TO_INT (value) & TP_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
@@ -2594,7 +3822,7 @@ call_handler_notify_call_cb (EmpathyCallHandler *handler,
     EmpathyCallWindow *self)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
-  TpyCallChannel *call;
+  TpCallChannel *call;
 
   g_object_get (priv->handler, "call-channel", &call, NULL);
   if (call == NULL)
@@ -2614,46 +3842,60 @@ call_handler_notify_call_cb (EmpathyCallHandler *handler,
 }
 
 static void
-empathy_call_window_realized_cb (GtkWidget *widget, EmpathyCallWindow *window)
+empathy_call_window_connect_handler (EmpathyCallWindow *self)
 {
-  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);
+  EmpathyCallWindowPriv *priv = GET_PRIV (self);
+  TpCallChannel *call;
 
   g_signal_connect (priv->handler, "state-changed",
-    G_CALLBACK (empathy_call_window_state_changed_cb), window);
+    G_CALLBACK (empathy_call_window_state_changed_cb), self);
   g_signal_connect (priv->handler, "conference-added",
-    G_CALLBACK (empathy_call_window_conference_added_cb), window);
+    G_CALLBACK (empathy_call_window_conference_added_cb), self);
   g_signal_connect (priv->handler, "conference-removed",
-    G_CALLBACK (empathy_call_window_conference_removed_cb), window);
+    G_CALLBACK (empathy_call_window_conference_removed_cb), self);
   g_signal_connect (priv->handler, "closed",
-    G_CALLBACK (empathy_call_window_channel_closed_cb), window);
+    G_CALLBACK (empathy_call_window_channel_closed_cb), self);
   g_signal_connect (priv->handler, "src-pad-added",
-    G_CALLBACK (empathy_call_window_src_added_cb), window);
-  g_signal_connect (priv->handler, "sink-pad-added",
-    G_CALLBACK (empathy_call_window_sink_added_cb), window);
-  g_signal_connect (priv->handler, "sink-pad-removed",
-    G_CALLBACK (empathy_call_window_sink_removed_cb), window);
+    G_CALLBACK (empathy_call_window_src_added_cb), self);
+  g_signal_connect (priv->handler, "content-added",
+    G_CALLBACK (empathy_call_window_content_added_cb), self);
+  g_signal_connect (priv->handler, "content-removed",
+    G_CALLBACK (empathy_call_window_content_removed_cb), self);
+
+  /* We connect to ::call-channel unconditionally since we'll
+   * get new channels if we hangup and redial or if we reuse the
+   * call window. */
+  g_signal_connect (priv->handler, "notify::call-channel",
+    G_CALLBACK (call_handler_notify_call_cb), self);
+
+  g_signal_connect (priv->handler, "framerate-changed",
+    G_CALLBACK (empathy_call_window_framerate_changed_cb), self);
+  g_signal_connect (priv->handler, "resolution-changed",
+    G_CALLBACK (empathy_call_window_resolution_changed_cb), self);
 
   g_object_get (priv->handler, "call-channel", &call, NULL);
   if (call != NULL)
     {
-      call_handler_notify_call_cb (priv->handler, NULL, window);
+      /* We won't get notify::call-channel for this channel, so
+       * directly call the callback. */
+      call_handler_notify_call_cb (priv->handler, NULL, self);
       g_object_unref (call);
     }
-  else
-    {
-      /* call-channel doesn't exist yet, we'll connect signals once it has been
-       * set */
-      g_signal_connect (priv->handler, "notify::call-channel",
-        G_CALLBACK (call_handler_notify_call_cb), window);
-    }
+}
+
+static void
+empathy_call_window_realized_cb (GtkWidget *widget,
+    EmpathyCallWindow *self)
+{
+  gint width;
+
+  /* Make the hangup button twice as wide */
+  width = gtk_widget_get_allocated_width (self->priv->hangup_button);
+  gtk_widget_set_size_request (self->priv->hangup_button, width * 2, -1);
 
-  gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
+  empathy_call_window_connect_handler (self);
+
+  gst_element_set_state (self->priv->pipeline, GST_STATE_PAUSED);
 }
 
 static gboolean
@@ -2712,8 +3954,6 @@ show_borders (EmpathyCallWindow *window, gboolean set_fullscreen)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (window);
 
-  gtk_container_set_border_width (GTK_CONTAINER (priv->content_hbox),
-      set_fullscreen ? 0 : CONTENT_HBOX_BORDER_WIDTH);
   gtk_box_set_spacing (GTK_BOX (priv->content_hbox),
       set_fullscreen ? 0 : CONTENT_HBOX_SPACING);
 
@@ -2775,7 +4015,7 @@ empathy_call_window_state_event_cb (GtkWidget *widget,
       show_controls (window, set_fullscreen);
       show_borders (window, set_fullscreen);
       gtk_action_set_stock_id (priv->menu_fullscreen,
-          (set_fullscreen ? "gtk-leave-fullscreen" : "gtk-fullscreen"));
+          (set_fullscreen ? "view-restore" : "view-fullscreen"));
       priv->is_fullscreen = set_fullscreen;
   }
 
@@ -2816,7 +4056,7 @@ empathy_call_window_set_send_video (EmpathyCallWindow *window,
   CameraState state)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (window);
-  TpyCallChannel *call;
+  TpCallChannel *call;
 
   priv->sending_video = (state == CAMERA_STATE_ON);
 
@@ -2836,43 +4076,18 @@ empathy_call_window_set_send_video (EmpathyCallWindow *window,
 
   g_object_get (priv->handler, "call-channel", &call, NULL);
   DEBUG ("%s sending video", priv->sending_video ? "start": "stop");
-  tpy_call_channel_send_video (call, priv->sending_video);
+  empathy_call_channel_send_video (call, priv->sending_video);
   g_object_unref (call);
 }
 
-static void
-empathy_call_window_mic_toggled_cb (GtkToggleToolButton *toggle,
-  EmpathyCallWindow *window)
-{
-  EmpathyCallWindowPriv *priv = GET_PRIV (window);
-  gboolean active;
-
-  active = (gtk_toggle_tool_button_get_active (toggle));
-
-  if (active)
-    {
-      g_settings_set_double (priv->settings, EMPATHY_PREFS_CALL_SOUND_VOLUME,
-          priv->volume * 100);
-    }
-  else
-    {
-      /* TODO, Instead of setting the input volume to 0 we should probably
-       * stop sending but this would cause the audio call to drop if both
-       * sides mute at the same time on certain CMs AFAIK. Need to revisit this
-       * in the future. GNOME #574574
-       */
-      g_settings_set_double (priv->settings, EMPATHY_PREFS_CALL_SOUND_VOLUME,
-          0);
-    }
-}
-
 static void
 empathy_call_window_hangup_cb (gpointer object,
     EmpathyCallWindow *self)
 {
+  /* stopping the call will put it the ENDED state and
+   * from state_changed_cb we'll reconfigure the window
+   */
   empathy_call_handler_stop_call (self->priv->handler);
-
-  empathy_call_window_disconnected (self, TRUE);
 }
 
 static void
@@ -2885,12 +4100,6 @@ empathy_call_window_restart_call (EmpathyCallWindow *window)
       (GtkCallback) gtk_widget_destroy, NULL);
 
   create_video_output_widget (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 (window);
-
   priv->outgoing = TRUE;
   empathy_call_window_set_state_connecting (window);
 
@@ -2952,6 +4161,7 @@ empathy_call_window_key_press_cb (GtkWidget *video_output,
   GdkEventKey *event, EmpathyCallWindow *window)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (window);
+  gchar key;
 
   if (priv->is_fullscreen && event->keyval == GDK_KEY_Escape)
     {
@@ -2961,7 +4171,34 @@ empathy_call_window_key_press_cb (GtkWidget *video_output,
       return TRUE;
     }
 
-  return FALSE;
+  key = gdk_keyval_to_unicode (event->keyval);
+  switch (key)
+    {
+      case '0':
+      case '1':
+      case '2':
+      case '3':
+      case '4':
+      case '5':
+      case '6':
+      case '7':
+      case '8':
+      case '9':
+      case '*':
+      case '#':
+        break;
+      default:
+        return TRUE;
+        break;
+    }
+
+  gtk_toggle_tool_button_set_active (
+      GTK_TOGGLE_TOOL_BUTTON (priv->dialpad_button), TRUE);
+
+  empathy_dialpad_widget_press_key (
+      EMPATHY_DIALPAD_WIDGET (priv->dtmf_panel), key);
+
+  return TRUE;
 }
 
 static gboolean
@@ -2973,6 +4210,9 @@ empathy_call_window_video_output_motion_notify (GtkWidget *widget,
   if (priv->is_fullscreen)
     {
       empathy_call_window_fullscreen_show_popup (priv->fullscreen);
+
+      /* Show the bottom toolbar */
+      empathy_call_window_motion_notify_cb (NULL, NULL, window);
       return TRUE;
     }
   return FALSE;
@@ -2999,19 +4239,6 @@ empathy_call_window_status_message (EmpathyCallWindow *self,
   gtk_label_set_label (GTK_LABEL (self->priv->status_label), message);
 }
 
-static void
-empathy_call_window_volume_changed_cb (GtkScaleButton *button,
-  gdouble value, EmpathyCallWindow *window)
-{
-  EmpathyCallWindowPriv *priv = GET_PRIV (window);
-
-  if (priv->audio_output == NULL)
-    return;
-
-  empathy_audio_sink_set_volume (EMPATHY_GST_AUDIO_SINK (priv->audio_output),
-    value);
-}
-
 GtkUIManager *
 empathy_call_window_get_ui_manager (EmpathyCallWindow *window)
 {
@@ -3027,3 +4254,29 @@ empathy_call_window_get_audio_src (EmpathyCallWindow *window)
 
   return (EmpathyGstAudioSrc *) priv->audio_input;
 }
+
+EmpathyGstVideoSrc *
+empathy_call_window_get_video_src (EmpathyCallWindow *self)
+{
+  return EMPATHY_GST_VIDEO_SRC (self->priv->video_input);
+}
+
+void
+empathy_call_window_change_webcam (EmpathyCallWindow *self,
+    const gchar *device)
+{
+  EmpathyGstVideoSrc *video;
+  gboolean running;
+
+  /* Restart the camera only if it's already running */
+  running = (self->priv->video_preview != NULL);
+  video = empathy_call_window_get_video_src (self);
+
+  if (running)
+    empathy_call_window_play_camera (self, FALSE);
+
+  empathy_video_src_change_device (video, device);
+
+  if (running)
+    empathy_call_window_play_camera (self, TRUE);
+}