]> git.0d.be Git - empathy.git/blobdiff - src/empathy-call-window.c
Remove tp-yell and use TpCallChannel
[empathy.git] / src / empathy-call-window.c
index bf546c1a0d901c89e4e294644e1ef3aa3164eeaf..1802b01a8e46a0162ce0b3b215b62368f6b130a0 100644 (file)
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include "config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <libempathy/empathy-utils.h>
 
 #include <libempathy-gtk/empathy-avatar-image.h>
+#include <libempathy-gtk/empathy-dialpad-widget.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>
+#include <libempathy-gtk/empathy-call-utils.h>
 
 #define DEBUG_FLAG EMPATHY_DEBUG_VOIP
 #include <libempathy/empathy-debug.h>
@@ -165,6 +168,7 @@ struct _EmpathyCallWindowPriv
   GtkWidget *audio_call_button;
   GtkWidget *video_call_button;
   GtkWidget *mic_button;
+  GtkWidget *volume_button;
   GtkWidget *camera_button;
   GtkWidget *dialpad_button;
   GtkWidget *toolbar;
@@ -191,15 +195,13 @@ struct _EmpathyCallWindowPriv
   /* These are used to accept or reject an incoming call when the status
      is RINGING. */
   GtkWidget *incoming_call_dialog;
-  TpyCallChannel *pending_channel;
+  TpCallChannel *pending_channel;
   TpChannelDispatchOperation *pending_cdo;
   TpAddDispatchOperationContext *pending_context;
 
   gulong video_output_motion_handler_id;
   guint bus_message_source_id;
 
-  gdouble volume;
-
   /* String that contains the queued tones to send after the current ones
      are sent */
   GString *tones;
@@ -227,6 +229,7 @@ struct _EmpathyCallWindowPriv
   GstElement *video_output_sink;
   GstElement *audio_input;
   GstElement *audio_output;
+  gboolean audio_output_added;
   GstElement *pipeline;
   GstElement *video_tee;
 
@@ -285,9 +288,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);
 
@@ -321,10 +321,6 @@ static void empathy_call_window_status_message (EmpathyCallWindow *window,
 static gboolean empathy_call_window_bus_message (GstBus *bus,
   GstMessage *message, gpointer user_data);
 
-static void
-empathy_call_window_volume_changed_cb (GtkScaleButton *button,
-  gdouble value, EmpathyCallWindow *window);
-
 static void
 empathy_call_window_show_hangup_button (EmpathyCallWindow *self,
     gboolean show)
@@ -397,62 +393,17 @@ empathy_call_window_tones_stopped_cb (TpChannel *proxy,
 }
 
 static void
-dtmf_button_pressed_cb (GtkButton *button,
+dtmf_start_tone_cb (EmpathyDialpadWidget *dialpad,
+    TpDTMFEvent event,
     EmpathyCallWindow *self)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
-  GQuark button_quark;
-  TpDTMFEvent event;
-
-  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_string_append_c (priv->tones, tp_dtmf_event_to_char (event));
 
   empathy_call_window_maybe_emit_tones (self);
 }
 
-/* empathy_create_dtmf_dialpad() requires a callback, even if empty */
-static void
-dtmf_button_released_cb (GtkButton *button,
-    EmpathyCallWindow *self)
-{
-}
-
-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_raise_actors (EmpathyCallWindow *self)
 {
@@ -512,6 +463,40 @@ create_video_input (EmpathyCallWindow *self)
   gst_object_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
 create_audio_input (EmpathyCallWindow *self)
 {
@@ -521,6 +506,11 @@ create_audio_input (EmpathyCallWindow *self)
   priv->audio_input = empathy_audio_src_new ();
   gst_object_ref (priv->audio_input);
   gst_object_sink (priv->audio_input);
+
+  g_object_bind_property (priv->mic_button, "active",
+    priv->audio_input, "mute",
+    G_BINDING_BIDIRECTIONAL |
+      G_BINDING_INVERT_BOOLEAN | G_BINDING_SYNC_CREATE);
 }
 
 static void
@@ -754,6 +744,55 @@ empathy_call_window_show_preview_rectangles (EmpathyCallWindow *self,
   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->video_box))
+    goto out;
+
+  clutter_actor_get_geometry (self->priv->video_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
+            - FLOATING_TOOLBAR_HEIGHT - FLOATING_TOOLBAR_SPACING;
+        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 - FLOATING_TOOLBAR_HEIGHT
+            - FLOATING_TOOLBAR_SPACING;
+        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,
@@ -953,6 +992,13 @@ empathy_call_window_preview_on_drag_begin_cb (ClutterDragAction *action,
   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,
@@ -962,18 +1008,30 @@ empathy_call_window_preview_on_drag_end_cb (ClutterDragAction *action,
     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);
 
-  /* Destroy the video preview copy that we were dragging */
-  clutter_actor_destroy (self->priv->drag_preview);
-  self->priv->drag_preview = NULL;
+  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);
 
-  clutter_actor_set_opacity (actor, 255);
-  clutter_actor_show (self->priv->preview_shown_button);
+  self->priv->drag_preview = NULL;
 
   if (pos != PREVIEW_POS_NONE)
     empathy_call_window_move_video_preview (self, pos);
@@ -1107,7 +1165,7 @@ create_video_preview (EmpathyCallWindow *self)
 
   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
@@ -1222,8 +1280,8 @@ empathy_call_window_play_camera (EmpathyCallWindow *self,
   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
@@ -1232,6 +1290,12 @@ 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 */
@@ -1280,10 +1344,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;
 }
@@ -1490,7 +1551,7 @@ empathy_call_window_set_state_ringing (EmpathyCallWindow *self)
 
   g_assert (self->priv->call_state != CONNECTED);
 
-  video = tpy_call_channel_has_initial_video (self->priv->pending_channel);
+  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;
@@ -1534,7 +1595,7 @@ empathy_call_window_cdo_invalidated_cb (TpProxy *channel,
 
 void
 empathy_call_window_start_ringing (EmpathyCallWindow *self,
-    TpyCallChannel *channel,
+    TpCallChannel *channel,
     TpChannelDispatchOperation *dispatch_operation,
     TpAddDispatchOperationContext *context)
 {
@@ -1570,6 +1631,8 @@ empathy_call_window_init (EmpathyCallWindow *self)
   priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
     EMPATHY_TYPE_CALL_WINDOW, EmpathyCallWindowPriv);
 
+  priv->settings = g_settings_new (EMPATHY_PREFS_CALL_SCHEMA);
+
   filename = empathy_file_lookup ("empathy-call-window.ui", "src");
   gui = empathy_builder_get_file (filename,
     "call_window_vbox", &top_vbox,
@@ -1581,6 +1644,7 @@ empathy_call_window_init (EmpathyCallWindow *self)
     "audiocall", &priv->audio_call_button,
     "videocall", &priv->video_call_button,
     "microphone", &priv->mic_button,
+    "volume", &priv->volume_button,
     "camera", &priv->camera_button,
     "hangup", &priv->hangup_button,
     "dialpad", &priv->dialpad_button,
@@ -1609,8 +1673,6 @@ 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,
@@ -1641,7 +1703,8 @@ empathy_call_window_init (EmpathyCallWindow *self)
 
   gtk_container_add (GTK_CONTAINER (self), top_vbox);
 
-  priv->content_hbox = gtk_hbox_new (FALSE, CONTENT_HBOX_SPACING);
+  priv->content_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,
+      CONTENT_HBOX_SPACING);
   gtk_container_set_border_width (GTK_CONTAINER (priv->content_hbox),
                                   CONTENT_HBOX_BORDER_WIDTH);
   gtk_box_pack_start (GTK_BOX (priv->pane), priv->content_hbox,
@@ -1655,6 +1718,9 @@ empathy_call_window_init (EmpathyCallWindow *self)
 
   priv->video_container = gtk_clutter_embed_new ();
 
+  gtk_widget_set_size_request (priv->video_container,
+      EMPATHY_VIDEO_WIDGET_DEFAULT_WIDTH, EMPATHY_VIDEO_WIDGET_DEFAULT_HEIGHT);
+
   /* 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,
@@ -1749,9 +1815,9 @@ empathy_call_window_init (EmpathyCallWindow *self)
   /* 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);
 
   priv->tones = g_string_new ("");
 
@@ -1807,15 +1873,6 @@ empathy_call_window_init (EmpathyCallWindow *self)
 
   empathy_call_window_show_hangup_button (self, TRUE);
 
-  priv->settings = g_settings_new (EMPATHY_PREFS_CALL_SCHEMA);
-
-  /* Retrieve initial volume */
-  priv->volume = g_settings_get_double (priv->settings,
-      EMPATHY_PREFS_CALL_SOUND_VOLUME) / 100.0;
-
-  g_signal_connect (priv->settings, "changed::"EMPATHY_PREFS_CALL_SOUND_VOLUME,
-      G_CALLBACK (empathy_call_window_prefs_volume_changed_cb), self);
-
   empathy_geometry_bind (GTK_WINDOW (self), "call-window");
   /* These signals are used to track the window position and save it
    * when the window is destroyed. We need to do this as we don't want
@@ -2191,14 +2248,15 @@ 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);
   g_assert (priv->contact != NULL);
@@ -2478,6 +2536,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);
@@ -2629,15 +2688,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...
    */
@@ -2656,7 +2734,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)
@@ -2665,13 +2742,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 */
@@ -2756,17 +2867,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");
@@ -2835,14 +2944,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;
@@ -2854,15 +2986,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 */
@@ -2870,7 +3012,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 */
@@ -2904,16 +3046,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)
 {
@@ -2985,7 +3128,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,
@@ -3009,7 +3152,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)
@@ -3019,7 +3162,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)
@@ -3029,16 +3172,71 @@ 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_borrow_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 &&
+      !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)
@@ -3055,7 +3253,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)
@@ -3142,20 +3340,23 @@ empathy_call_window_video_probe_cb (GstPad *pad,
 /* 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_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);
@@ -3165,7 +3366,7 @@ empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
             G_CALLBACK (empathy_call_window_video_probe_cb), self);
         if (priv->got_video_src > 0)
           g_source_remove (priv->got_video_src);
-        priv->got_video_src = g_timeout_add_seconds (5,
+        priv->got_video_src = g_timeout_add_seconds (1,
             empathy_call_window_check_video_cb, self);
         break;
       default:
@@ -3220,18 +3421,88 @@ empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
   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");
@@ -3261,6 +3532,9 @@ 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:
@@ -3281,6 +3555,7 @@ empathy_call_window_sink_added_cb (EmpathyCallHandler *handler,
         g_assert_not_reached ();
     }
 
+  gst_object_unref (sink);
   return retval;
 }
 
@@ -3323,14 +3598,20 @@ start_call (EmpathyCallWindow *self)
 
   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 (
@@ -3348,7 +3629,8 @@ start_call (EmpathyCallWindow *self)
             }
         }
 
-      g_object_unref (call);
+      if (call != NULL)
+        g_object_unref (call);
     }
 }
 
@@ -3445,8 +3727,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);
@@ -3454,10 +3738,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
@@ -3479,7 +3763,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)
@@ -3506,7 +3790,7 @@ static void
 empathy_call_window_connect_handler (EmpathyCallWindow *self)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
-  TpyCallChannel *call;
+  TpCallChannel *call;
 
   g_signal_connect (priv->handler, "state-changed",
     G_CALLBACK (empathy_call_window_state_changed_cb), self);
@@ -3518,10 +3802,10 @@ empathy_call_window_connect_handler (EmpathyCallWindow *self)
     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), self);
-  g_signal_connect (priv->handler, "sink-pad-added",
-    G_CALLBACK (empathy_call_window_sink_added_cb), self);
-  g_signal_connect (priv->handler, "sink-pad-removed",
-    G_CALLBACK (empathy_call_window_sink_removed_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
@@ -3529,6 +3813,11 @@ empathy_call_window_connect_handler (EmpathyCallWindow *self)
   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)
     {
@@ -3714,7 +4003,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);
 
@@ -3734,44 +4023,10 @@ 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 *self)
-{
-  EmpathyCallWindowPriv *priv = GET_PRIV (self);
-  gboolean active;
-
-  active = (gtk_toggle_tool_button_get_active (toggle));
-
-  /* We don't want the settings callback to react to this change to avoid
-   * a loop. */
-  g_signal_handlers_block_by_func (priv->settings,
-      empathy_call_window_prefs_volume_changed_cb, self);
-
-  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);
-    }
-
-    g_signal_handlers_unblock_by_func (priv->settings,
-      empathy_call_window_prefs_volume_changed_cb, self);
-}
-
 static void
 empathy_call_window_hangup_cb (gpointer object,
     EmpathyCallWindow *self)
@@ -3791,12 +4046,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);
 
@@ -3908,19 +4157,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)
 {
@@ -3942,3 +4178,23 @@ 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);
+}