]> 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 5603ddf6e1cf9178eaf99c301b09bd6e534c0efb..1802b01a8e46a0162ce0b3b215b62368f6b130a0 100644 (file)
@@ -53,6 +53,7 @@
 #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>
@@ -167,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;
@@ -193,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;
@@ -229,6 +229,7 @@ struct _EmpathyCallWindowPriv
   GstElement *video_output_sink;
   GstElement *audio_input;
   GstElement *audio_output;
+  gboolean audio_output_added;
   GstElement *pipeline;
   GstElement *video_tee;
 
@@ -287,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);
 
@@ -323,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)
@@ -410,39 +404,6 @@ dtmf_start_tone_cb (EmpathyDialpadWidget *dialpad,
   empathy_call_window_maybe_emit_tones (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)
 {
@@ -502,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)
 {
@@ -511,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
@@ -1165,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
@@ -1280,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
@@ -1344,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;
 }
@@ -1554,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;
@@ -1598,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)
 {
@@ -1647,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,
@@ -1675,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,
@@ -1707,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,
@@ -1721,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,
@@ -1873,13 +1873,6 @@ empathy_call_window_init (EmpathyCallWindow *self)
 
   empathy_call_window_show_hangup_button (self, TRUE);
 
-  /* 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
@@ -2255,14 +2248,14 @@ empathy_call_window_constructed (GObject *object)
 {
   EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
-  TpyCallChannel *call;
-  TpyCallState state;
+  TpCallChannel *call;
+  TpCallState state;
 
   g_assert (priv->handler != NULL);
 
   g_object_get (priv->handler, "call-channel", &call, NULL);
-  state = tpy_call_channel_get_state (call, NULL, NULL);
-  priv->outgoing = (state == TPY_CALL_STATE_PENDING_INITIATOR);
+  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);
@@ -2543,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);
@@ -2694,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...
    */
@@ -2721,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)
@@ -2730,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 */
@@ -2821,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");
@@ -2960,7 +3004,7 @@ display_error (EmpathyCallWindow *self,
   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 */
@@ -2968,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 */
@@ -3012,7 +3056,7 @@ display_error (EmpathyCallWindow *self,
 #if 0
 static gchar *
 media_stream_error_to_txt (EmpathyCallWindow *self,
-    TpyCallChannel *call,
+    TpCallChannel *call,
     gboolean audio,
     TpMediaStreamError error)
 {
@@ -3084,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,
@@ -3108,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)
@@ -3118,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)
@@ -3177,22 +3221,22 @@ show_balance_error (EmpathyCallWindow *self)
 
 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_ENDED &&
+  if (state == TP_CALL_STATE_ENDED &&
       !tp_strdiff (reason, TP_ERROR_STR_INSUFFICIENT_BALANCE))
     {
       show_balance_error (self);
       return;
     }
 
-  if (state != TPY_CALL_STATE_ACCEPTED)
+  if (state != TP_CALL_STATE_ACCEPTED)
     return;
 
   if (priv->call_state == CONNECTED)
@@ -3209,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)
@@ -3296,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);
@@ -3319,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:
@@ -3374,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");
@@ -3415,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:
@@ -3435,6 +3555,7 @@ empathy_call_window_sink_added_cb (EmpathyCallHandler *handler,
         g_assert_not_reached ();
     }
 
+  gst_object_unref (sink);
   return retval;
 }
 
@@ -3477,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 (
@@ -3502,7 +3629,8 @@ start_call (EmpathyCallWindow *self)
             }
         }
 
-      g_object_unref (call);
+      if (call != NULL)
+        g_object_unref (call);
     }
 }
 
@@ -3599,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);
@@ -3608,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
@@ -3633,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)
@@ -3660,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);
@@ -3672,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
@@ -3683,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)
     {
@@ -3868,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);
 
@@ -3888,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)
@@ -3945,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);
 
@@ -4062,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)
 {
@@ -4096,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);
+}