]> git.0d.be Git - empathy.git/blobdiff - libempathy/empathy-tp-call.c
Merge branch 'sasl'
[empathy.git] / libempathy / empathy-tp-call.c
index 7703aeffb5c96718d44f6ddd16f4fd8c3abdefb2..1a53de65d51299d1638edaf1c7719bbfe0830fba 100644 (file)
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
  * Copyright (C) 2007 Elliot Fairweather
  * Copyright (C) 2007-2008 Collabora Ltd.
 #include <telepathy-glib/proxy-subclass.h>
 #include <telepathy-glib/dbus.h>
 #include <telepathy-glib/interfaces.h>
-
-#include <extensions/extensions.h>
+#include <telepathy-glib/util.h>
 
 #include "empathy-tp-call.h"
-#include "empathy-contact-factory.h"
-#include "empathy-tp-group.h"
+#include "empathy-tp-contact-factory.h"
 #include "empathy-utils.h"
+#include "empathy-marshal.h"
 
-#define DEBUG_FLAG EMPATHY_DEBUG_TP
+#define DEBUG_FLAG EMPATHY_DEBUG_VOIP
 #include "empathy-debug.h"
 
-#define STREAM_ENGINE_BUS_NAME "org.freedesktop.Telepathy.StreamEngine"
-#define STREAM_ENGINE_OBJECT_PATH "/org/freedesktop/Telepathy/StreamEngine"
-
 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyTpCall)
 typedef struct
 {
+  gboolean dispose_has_run;
+  TpAccount *account;
   TpChannel *channel;
-  TpProxy *stream_engine;
-  TpDBusDaemon *dbus_daemon;
-  EmpathyTpGroup *group;
   EmpathyContact *contact;
   gboolean is_incoming;
   guint status;
-  gboolean stream_engine_running;
 
   EmpathyTpCallStream *audio;
   EmpathyTpCallStream *video;
 } EmpathyTpCallPriv;
 
+/* signal enum */
+enum {
+  AUDIO_STREAM_ERROR,
+  VIDEO_STREAM_ERROR,
+  LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = {0};
+
 enum
 {
   PROP_0,
+  PROP_ACCOUNT,
   PROP_CHANNEL,
   PROP_CONTACT,
-  PROP_IS_INCOMING,
   PROP_STATUS,
   PROP_AUDIO_STREAM,
   PROP_VIDEO_STREAM
@@ -264,58 +266,55 @@ tp_call_request_streams_for_capabilities (EmpathyTpCall *call,
 }
 
 static void
-tp_call_member_added_cb (EmpathyTpGroup *group,
-                         EmpathyContact *contact,
-                         EmpathyContact *actor,
-                         guint reason,
-                         const gchar *message,
-                         EmpathyTpCall *call)
+tp_call_got_contact_cb (TpConnection            *connection,
+                        EmpathyContact          *contact,
+                        const GError            *error,
+                        gpointer                 user_data,
+                        GObject                 *call)
 {
   EmpathyTpCallPriv *priv = GET_PRIV (call);
 
-  g_object_ref (call);
-  if (!priv->contact && !empathy_contact_is_user (contact))
+  if (error)
     {
-      priv->contact = g_object_ref (contact);
-      priv->is_incoming = TRUE;
-      priv->status = EMPATHY_TP_CALL_STATUS_PENDING;
-      g_object_notify (G_OBJECT (call), "is-incoming");
-      g_object_notify (G_OBJECT (call), "contact");
-      g_object_notify (G_OBJECT (call), "status");
+      DEBUG ("Error: %s", error->message);
+      return;
     }
 
-  if (priv->status == EMPATHY_TP_CALL_STATUS_PENDING &&
-      ((priv->is_incoming && contact != priv->contact) ||
-       (!priv->is_incoming && contact == priv->contact)))
+  priv->contact = g_object_ref (contact);
+
+  if (priv->status < EMPATHY_TP_CALL_STATUS_PENDING)
     {
-      priv->status = EMPATHY_TP_CALL_STATUS_ACCEPTED;
+      priv->status = EMPATHY_TP_CALL_STATUS_PENDING;
       g_object_notify (G_OBJECT (call), "status");
     }
-  g_object_unref (call);
+
+  g_object_notify (G_OBJECT (call), "contact");
 }
 
 static void
-tp_call_remote_pending_cb (EmpathyTpGroup *group,
-                           EmpathyContact *contact,
-                           EmpathyContact *actor,
-                           guint reason,
-                           const gchar *message,
-                           EmpathyTpCall *call)
+tp_call_update_status (EmpathyTpCall *call)
 {
   EmpathyTpCallPriv *priv = GET_PRIV (call);
+  TpHandle self_handle;
+  const TpIntSet *set;
+  TpIntSetIter iter;
 
   g_object_ref (call);
-  if (!priv->contact && !empathy_contact_is_user (contact))
+
+  self_handle = tp_channel_group_get_self_handle (priv->channel);
+  set = tp_channel_group_get_members (priv->channel);
+  tp_intset_iter_init (&iter, set);
+  while (tp_intset_iter_next (&iter))
     {
-      priv->contact = g_object_ref (contact);
-      priv->is_incoming = FALSE;
-      priv->status = EMPATHY_TP_CALL_STATUS_PENDING;
-      g_object_notify (G_OBJECT (call), "is-incoming");
-      g_object_notify (G_OBJECT (call), "contact"); 
-      g_object_notify (G_OBJECT (call), "status");     
-      tp_call_request_streams_for_capabilities (call,
-          EMPATHY_CAPABILITIES_AUDIO);
+      if (priv->status == EMPATHY_TP_CALL_STATUS_PENDING &&
+          ((priv->is_incoming && iter.element == self_handle) ||
+           (!priv->is_incoming && iter.element != self_handle)))
+        {
+          priv->status = EMPATHY_TP_CALL_STATUS_ACCEPTED;
+          g_object_notify (G_OBJECT (call), "status");
+        }
     }
+
   g_object_unref (call);
 }
 
@@ -340,111 +339,35 @@ tp_call_async_cb (TpProxy *proxy,
                   GObject *call)
 {
   if (error)
-      DEBUG ("Error %s: %s", (gchar*) user_data, error->message);
+      DEBUG ("Error %s: %s", (gchar *) user_data, error->message);
 }
 
 static void
-tp_call_close_channel (EmpathyTpCall *call)
+tp_call_stream_error_cb (TpChannel *channel,
+    guint stream_id,
+    guint error_code,
+    const gchar *msg,
+    gpointer user_data,
+    GObject *call)
 {
-  EmpathyTpCallPriv *priv = GET_PRIV (call);
+  EmpathyTpCall *self = EMPATHY_TP_CALL (call);
+  EmpathyTpCallPriv *priv = GET_PRIV (self);
 
-  if (priv->status == EMPATHY_TP_CALL_STATUS_CLOSED)
-      return;
+  DEBUG ("Stream error on stream %u: %s (code: %u)", stream_id, msg,
+      error_code);
 
-  DEBUG ("Closing channel");
-
-  tp_cli_channel_call_close (priv->channel, -1,
-      NULL, NULL, NULL, NULL);
-
-  priv->status = EMPATHY_TP_CALL_STATUS_CLOSED;
-  g_object_notify (G_OBJECT (call), "status");
-}
-
-static void
-tp_call_stream_engine_invalidated_cb (TpProxy       *stream_engine,
-                                     GQuark         domain,
-                                     gint           code,
-                                     gchar         *message,
-                                     EmpathyTpCall *call)
-{
-  DEBUG ("Stream engine proxy invalidated: %s", message);
-  tp_call_close_channel (call);
-}
-
-static void
-tp_call_stream_engine_watch_name_owner_cb (TpDBusDaemon *daemon,
-                                          const gchar *name,
-                                          const gchar *new_owner,
-                                          gpointer call)
-{
-  EmpathyTpCallPriv *priv = GET_PRIV (call);
-
-  /* G_STR_EMPTY(new_owner) means either stream-engine has not started yet or
-   * has crashed. We want to close the channel if stream-engine has crashed.
-   * */
-  DEBUG ("Watch SE: name='%s' SE running='%s' new_owner='%s'",
-      name, priv->stream_engine_running ? "yes" : "no",
-      new_owner ? new_owner : "none");
-  if (priv->stream_engine_running && G_STR_EMPTY (new_owner))
+  if (priv->audio->id == stream_id)
     {
-      DEBUG ("Stream engine falled off the bus");
-      tp_call_close_channel (call);
-      return;
+      g_signal_emit (call, signals[AUDIO_STREAM_ERROR], 0, error_code, msg);
+    }
+  else if (priv->video->id == stream_id)
+    {
+      g_signal_emit (call, signals[VIDEO_STREAM_ERROR], 0, error_code, msg);
+    }
+  else
+    {
+      DEBUG ("Unknown stream id: %u", stream_id);
     }
-
-  priv->stream_engine_running = !G_STR_EMPTY (new_owner);
-}
-
-static void
-tp_call_stream_engine_handle_channel (EmpathyTpCall *call)
-{
-  EmpathyTpCallPriv *priv = GET_PRIV (call);
-  gchar *channel_type;
-  gchar *object_path;
-  guint handle_type;
-  guint handle;
-  TpProxy *connection;
-
-  DEBUG ("Revving up the stream engine");
-
-  priv->stream_engine = g_object_new (TP_TYPE_PROXY,
-      "bus-name", STREAM_ENGINE_BUS_NAME,
-      "dbus-connection", tp_get_bus (),
-      "object-path", STREAM_ENGINE_OBJECT_PATH,
-       NULL);
-  tp_proxy_add_interface_by_id (priv->stream_engine,
-      EMP_IFACE_QUARK_STREAM_ENGINE);
-  tp_proxy_add_interface_by_id (priv->stream_engine,
-      EMP_IFACE_QUARK_CHANNEL_HANDLER);
-
-  g_signal_connect (priv->stream_engine, "invalidated",
-      G_CALLBACK (tp_call_stream_engine_invalidated_cb),
-      call);
-  
-  /* FIXME: dbus daemon should be unique */
-  priv->dbus_daemon = tp_dbus_daemon_new (tp_get_bus ());
-  tp_dbus_daemon_watch_name_owner (priv->dbus_daemon, STREAM_ENGINE_BUS_NAME,
-      tp_call_stream_engine_watch_name_owner_cb,
-      call, NULL);
-
-  g_object_get (priv->channel,
-      "connection", &connection,
-      "channel-type", &channel_type,
-      "object-path", &object_path,
-      "handle_type", &handle_type,
-      "handle", &handle,
-      NULL);
-
-  emp_cli_channel_handler_call_handle_channel (priv->stream_engine, -1,
-        connection->bus_name,
-        connection->object_path,
-        channel_type, object_path, handle_type, handle,
-        tp_call_async_cb, "calling handle channel", NULL,
-        G_OBJECT (call));
-
-  g_object_unref (connection);
-  g_free (channel_type);
-  g_free (object_path);
 }
 
 static GObject *
@@ -473,65 +396,71 @@ tp_call_constructor (GType type,
       tp_call_stream_state_changed_cb, NULL, NULL, G_OBJECT (call), NULL);
   tp_cli_channel_type_streamed_media_connect_to_stream_direction_changed (priv->channel,
       tp_call_stream_direction_changed_cb, NULL, NULL, G_OBJECT (call), NULL);
+  tp_cli_channel_type_streamed_media_connect_to_stream_error (priv->channel,
+      tp_call_stream_error_cb, NULL, NULL, G_OBJECT (call), NULL);
   tp_cli_channel_type_streamed_media_call_list_streams (priv->channel, -1,
       tp_call_request_streams_cb, NULL, NULL, G_OBJECT (call));
 
-  /* Setup group interface */
-  priv->group = empathy_tp_group_new (priv->channel);
+  /* Is the call incoming? */
+  priv->is_incoming = !tp_channel_get_requested (priv->channel);
 
-  g_signal_connect (priv->group, "member-added",
-      G_CALLBACK (tp_call_member_added_cb), call);
-  g_signal_connect (priv->group, "remote-pending",
-      G_CALLBACK (tp_call_remote_pending_cb), call);
+  /* Get the remote contact */
+  empathy_tp_contact_factory_get_from_handle (
+      tp_channel_borrow_connection (priv->channel),
+      tp_channel_get_handle (priv->channel, NULL), tp_call_got_contact_cb,
+      NULL, NULL, object);
 
-  /* Start stream engine */
-  tp_call_stream_engine_handle_channel (call);
+  /* Update status when members changes */
+  tp_call_update_status (call);
+  tp_g_signal_connect_object (priv->channel, "group-members-changed",
+      G_CALLBACK (tp_call_update_status), call, G_CONNECT_SWAPPED);
 
   return object;
 }
-
-static void 
-tp_call_finalize (GObject *object)
+static void
+tp_call_dispose (GObject *object)
 {
   EmpathyTpCallPriv *priv = GET_PRIV (object);
 
-  DEBUG ("Finalizing: %p", object);
+  DEBUG ("Disposing: %p, %d", object, priv->dispose_has_run);
 
-  g_slice_free (EmpathyTpCallStream, priv->audio);
-  g_slice_free (EmpathyTpCallStream, priv->video);
-  g_object_unref (priv->group);
+  if (priv->dispose_has_run)
+    return;
+
+  priv->dispose_has_run = TRUE;
 
   if (priv->channel != NULL)
     {
       g_signal_handlers_disconnect_by_func (priv->channel,
-          tp_call_channel_invalidated_cb, object);
-      tp_call_close_channel (EMPATHY_TP_CALL (object));
-      g_object_unref (priv->channel);
-    }
+        tp_call_channel_invalidated_cb, object);
 
-  if (priv->stream_engine != NULL)
-    {
-      g_signal_handlers_disconnect_by_func (priv->stream_engine,
-          tp_call_stream_engine_invalidated_cb, object);
-      g_object_unref (priv->stream_engine);
+      g_object_unref (priv->channel);
+      priv->channel = NULL;
     }
 
   if (priv->contact != NULL)
       g_object_unref (priv->contact);
 
-  if (priv->dbus_daemon != NULL)
-    {
-      tp_dbus_daemon_cancel_name_owner_watch (priv->dbus_daemon,
-          STREAM_ENGINE_BUS_NAME,
-          tp_call_stream_engine_watch_name_owner_cb,
-          object);
-      g_object_unref (priv->dbus_daemon);
-    }
+  tp_clear_object (&priv->account);
+
+  if (G_OBJECT_CLASS (empathy_tp_call_parent_class)->dispose)
+    G_OBJECT_CLASS (empathy_tp_call_parent_class)->dispose (object);
+}
+
+static void
+tp_call_finalize (GObject *object)
+{
+  EmpathyTpCallPriv *priv = GET_PRIV (object);
+
+  DEBUG ("Finalizing: %p", object);
+
+  g_slice_free (EmpathyTpCallStream, priv->audio);
+  g_slice_free (EmpathyTpCallStream, priv->video);
 
   (G_OBJECT_CLASS (empathy_tp_call_parent_class)->finalize) (object);
 }
 
-static void 
+static void
 tp_call_set_property (GObject *object,
                       guint prop_id,
                       const GValue *value,
@@ -541,6 +470,9 @@ tp_call_set_property (GObject *object,
 
   switch (prop_id)
     {
+    case PROP_ACCOUNT:
+      priv->account = g_value_dup_object (value);
+      break;
     case PROP_CHANNEL:
       priv->channel = g_value_dup_object (value);
       break;
@@ -560,15 +492,15 @@ tp_call_get_property (GObject *object,
 
   switch (prop_id)
     {
+    case PROP_ACCOUNT:
+      g_value_set_object (value, priv->channel);
+      break;
     case PROP_CHANNEL:
       g_value_set_object (value, priv->channel);
       break;
     case PROP_CONTACT:
       g_value_set_object (value, priv->contact);
       break;
-    case PROP_IS_INCOMING:
-      g_value_set_boolean (value, priv->is_incoming);
-      break;
     case PROP_STATUS:
       g_value_set_uint (value, priv->status);
       break;
@@ -590,49 +522,73 @@ empathy_tp_call_class_init (EmpathyTpCallClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
   object_class->constructor = tp_call_constructor;
+  object_class->dispose = tp_call_dispose;
   object_class->finalize = tp_call_finalize;
   object_class->set_property = tp_call_set_property;
   object_class->get_property = tp_call_get_property;
 
   g_type_class_add_private (klass, sizeof (EmpathyTpCallPriv));
 
+  g_object_class_install_property (object_class, PROP_ACCOUNT,
+      g_param_spec_object ("account", "TpAccount", "TpAccount",
+      TP_TYPE_ACCOUNT,
+      G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
+      G_PARAM_STATIC_STRINGS));
+
   g_object_class_install_property (object_class, PROP_CHANNEL,
       g_param_spec_object ("channel", "channel", "channel",
       TP_TYPE_CHANNEL,
       G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
       G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
   g_object_class_install_property (object_class, PROP_CONTACT,
       g_param_spec_object ("contact", "Call contact", "Call contact",
       EMPATHY_TYPE_CONTACT,
       G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
-  g_object_class_install_property (object_class, PROP_IS_INCOMING,
-      g_param_spec_boolean ("is-incoming", "Is media stream incoming",
-      "Is media stream incoming", FALSE, G_PARAM_READABLE |
-      G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
   g_object_class_install_property (object_class, PROP_STATUS,
       g_param_spec_uint ("status", "Call status",
       "Call status", 0, 255, 0, G_PARAM_READABLE | G_PARAM_STATIC_NICK |
       G_PARAM_STATIC_BLURB));
+
   g_object_class_install_property (object_class, PROP_AUDIO_STREAM,
       g_param_spec_pointer ("audio-stream", "Audio stream data",
       "Audio stream data",
       G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
   g_object_class_install_property (object_class, PROP_VIDEO_STREAM,
       g_param_spec_pointer ("video-stream", "Video stream data",
       "Video stream data",
       G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
+  signals[AUDIO_STREAM_ERROR] =
+    g_signal_new ("audio-stream-error",
+      G_TYPE_FROM_CLASS (klass),
+      G_SIGNAL_RUN_LAST, 0,
+      NULL, NULL,
+      _empathy_marshal_VOID__UINT_STRING,
+      G_TYPE_NONE,
+      2, G_TYPE_UINT, G_TYPE_STRING);
+
+  signals[VIDEO_STREAM_ERROR] =
+    g_signal_new ("video-stream-error",
+      G_TYPE_FROM_CLASS (klass),
+      G_SIGNAL_RUN_LAST, 0,
+      NULL, NULL,
+      _empathy_marshal_VOID__UINT_STRING,
+      G_TYPE_NONE,
+      2, G_TYPE_UINT, G_TYPE_STRING);
 }
 
 static void
 empathy_tp_call_init (EmpathyTpCall *call)
 {
   EmpathyTpCallPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (call,
-               EMPATHY_TYPE_TP_CALL, EmpathyTpCallPriv);
+    EMPATHY_TYPE_TP_CALL, EmpathyTpCallPriv);
 
   call->priv = priv;
   priv->status = EMPATHY_TP_CALL_STATUS_READYING;
   priv->contact = NULL;
-  priv->stream_engine_running = FALSE;
   priv->audio = g_slice_new0 (EmpathyTpCallStream);
   priv->video = g_slice_new0 (EmpathyTpCallStream);
   priv->audio->exists = FALSE;
@@ -640,11 +596,14 @@ empathy_tp_call_init (EmpathyTpCall *call)
 }
 
 EmpathyTpCall *
-empathy_tp_call_new (TpChannel *channel)
+empathy_tp_call_new (TpAccount *account,
+    TpChannel *channel)
 {
+  g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL);
   g_return_val_if_fail (TP_IS_CHANNEL (channel), NULL);
 
   return g_object_new (EMPATHY_TYPE_TP_CALL,
+      "account", account,
       "channel", channel,
       NULL);
 }
@@ -653,16 +612,39 @@ void
 empathy_tp_call_accept_incoming_call (EmpathyTpCall *call)
 {
   EmpathyTpCallPriv *priv = GET_PRIV (call);
-  EmpathyContact *self_contact;
+  TpHandle self_handle;
+  GArray handles = {(gchar *) &self_handle, 1};
 
   g_return_if_fail (EMPATHY_IS_TP_CALL (call));
   g_return_if_fail (priv->status == EMPATHY_TP_CALL_STATUS_PENDING);
 
+  if (!priv->is_incoming)
+    return;
+
   DEBUG ("Accepting incoming call");
 
-  self_contact = empathy_tp_group_get_self_contact (priv->group);
-  empathy_tp_group_add_member (priv->group, self_contact, NULL);
-  g_object_unref (self_contact);
+  self_handle = tp_channel_group_get_self_handle (priv->channel);
+  tp_cli_channel_interface_group_call_add_members (priv->channel, -1,
+      &handles, NULL, NULL, NULL, NULL, NULL);
+}
+
+void
+empathy_tp_call_close (EmpathyTpCall *call)
+{
+  EmpathyTpCallPriv *priv = GET_PRIV (call);
+
+  g_return_if_fail (EMPATHY_IS_TP_CALL (call));
+
+  if (priv->status == EMPATHY_TP_CALL_STATUS_CLOSED)
+      return;
+
+  DEBUG ("Closing channel");
+
+  tp_cli_channel_call_close (priv->channel, -1,
+      NULL, NULL, NULL, NULL);
+
+  priv->status = EMPATHY_TP_CALL_STATUS_CLOSED;
+  g_object_notify (G_OBJECT (call), "status");
 }
 
 void
@@ -697,154 +679,177 @@ empathy_tp_call_request_video_stream_direction (EmpathyTpCall *call,
 }
 
 void
-empathy_tp_call_add_preview_video (EmpathyTpCall *call,
-                                   guint preview_video_socket_id)
+empathy_tp_call_start_tone (EmpathyTpCall *call, TpDTMFEvent event)
 {
   EmpathyTpCallPriv *priv = GET_PRIV (call);
 
   g_return_if_fail (EMPATHY_IS_TP_CALL (call));
+  g_return_if_fail (priv->status == EMPATHY_TP_CALL_STATUS_ACCEPTED);
 
-  DEBUG ("Adding preview video");
+  if (!priv->audio->exists)
+      return;
 
-  emp_cli_stream_engine_call_add_preview_window (priv->stream_engine, -1,
-      preview_video_socket_id,
-      tp_call_async_cb,
-      "adding preview window", NULL,
-      G_OBJECT (call));
+  tp_cli_channel_interface_dtmf_call_start_tone (priv->channel, -1,
+      priv->audio->id, event,
+      (tp_cli_channel_interface_dtmf_callback_for_start_tone) tp_call_async_cb,
+      "starting tone", NULL, G_OBJECT (call));
 }
 
 void
-empathy_tp_call_remove_preview_video (EmpathyTpCall *call,
-                                      guint preview_video_socket_id)
+empathy_tp_call_stop_tone (EmpathyTpCall *call)
 {
   EmpathyTpCallPriv *priv = GET_PRIV (call);
 
   g_return_if_fail (EMPATHY_IS_TP_CALL (call));
+  g_return_if_fail (priv->status == EMPATHY_TP_CALL_STATUS_ACCEPTED);
 
-  DEBUG ("Removing preview video");
+  if (!priv->audio->exists)
+      return;
 
-  emp_cli_stream_engine_call_remove_preview_window (priv->stream_engine, -1,
-      preview_video_socket_id,
-      tp_call_async_cb,
-      "removing preview window", NULL,
-      G_OBJECT (call));
+  tp_cli_channel_interface_dtmf_call_stop_tone (priv->channel, -1,
+      priv->audio->id,
+      (tp_cli_channel_interface_dtmf_callback_for_stop_tone) tp_call_async_cb,
+      "stoping tone", NULL, G_OBJECT (call));
 }
 
-void
-empathy_tp_call_add_output_video (EmpathyTpCall *call,
-                                  guint output_video_socket_id)
+gboolean
+empathy_tp_call_has_dtmf (EmpathyTpCall *call)
 {
   EmpathyTpCallPriv *priv = GET_PRIV (call);
 
-  g_return_if_fail (EMPATHY_IS_TP_CALL (call));
-
-  DEBUG ("Adding output video - socket: %d", output_video_socket_id);
+  g_return_val_if_fail (EMPATHY_IS_TP_CALL (call), FALSE);
 
-  emp_cli_stream_engine_call_set_output_window (priv->stream_engine, -1,
-      TP_PROXY (priv->channel)->object_path,
-      priv->video->id, output_video_socket_id,
-      tp_call_async_cb,
-      "setting output window", NULL,
-      G_OBJECT (call));
+  return tp_proxy_has_interface_by_id (priv->channel,
+      TP_IFACE_QUARK_CHANNEL_INTERFACE_DTMF);
 }
 
-void
-empathy_tp_call_set_output_volume (EmpathyTpCall *call,
-                                   guint volume)
+/**
+ * empathy_tp_call_is_receiving_video:
+ * @call: the call
+ *
+ * Indicates if the call is receiving video or not.
+ *
+ * Returns: %TRUE if the call is currently receiving video, %FALSE otherwise.
+ */
+gboolean
+empathy_tp_call_is_receiving_video (EmpathyTpCall *call)
 {
   EmpathyTpCallPriv *priv = GET_PRIV (call);
 
-  g_return_if_fail (EMPATHY_IS_TP_CALL (call));
-  g_return_if_fail (priv->status != EMPATHY_TP_CALL_STATUS_CLOSED);
+  g_return_val_if_fail (EMPATHY_IS_TP_CALL (call), FALSE);
 
-  DEBUG ("Setting output volume: %d", volume);
+  if (!priv->video->exists)
+    return FALSE;
 
-  emp_cli_stream_engine_call_set_output_volume (priv->stream_engine, -1,
-      TP_PROXY (priv->channel)->object_path,
-      priv->audio->id, volume,
-      tp_call_async_cb,
-      "setting output volume", NULL,
-      G_OBJECT (call));
+  return priv->video->direction & TP_MEDIA_STREAM_DIRECTION_RECEIVE ?
+      TRUE : FALSE;
 }
 
-void
-empathy_tp_call_mute_output (EmpathyTpCall *call,
-                             gboolean is_muted)
+/**
+ * empathy_tp_call_is_sending_video:
+ * @call: the call
+ *
+ * Indicates if the call is sending video or not.
+ *
+ * Returns: %TRUE if the call is currently sending video, %FALSE otherwise.
+ */
+gboolean
+empathy_tp_call_is_sending_video (EmpathyTpCall *call)
 {
   EmpathyTpCallPriv *priv = GET_PRIV (call);
 
-  g_return_if_fail (EMPATHY_IS_TP_CALL (call));
+  g_return_val_if_fail (EMPATHY_IS_TP_CALL (call), FALSE);
 
-  DEBUG ("Setting output mute: %d", is_muted);
+  if (!priv->video->exists)
+    return FALSE;
 
-  emp_cli_stream_engine_call_mute_output (priv->stream_engine, -1,
-      TP_PROXY (priv->channel)->object_path,
-      priv->audio->id, is_muted,
-      tp_call_async_cb,
-      "muting output", NULL,
-      G_OBJECT (call));
+  return priv->video->direction & TP_MEDIA_STREAM_DIRECTION_SEND ?
+      TRUE : FALSE;
 }
 
-void
-empathy_tp_call_mute_input (EmpathyTpCall *call,
-                            gboolean is_muted)
+const gchar *
+empathy_tp_call_get_connection_manager (EmpathyTpCall *self)
 {
-  EmpathyTpCallPriv *priv = GET_PRIV (call);
+  EmpathyTpCallPriv *priv = GET_PRIV (self);
 
-  g_return_if_fail (EMPATHY_IS_TP_CALL (call));
+  return tp_account_get_connection_manager (priv->account);
+}
 
-  DEBUG ("Setting input mute: %d", is_muted);
+gboolean
+empathy_tp_call_has_initial_video (EmpathyTpCall *self)
+{
+  EmpathyTpCallPriv *priv = GET_PRIV (self);
+  GHashTable *props;
+  gboolean initial_video;
+  gboolean valid;
 
-  emp_cli_stream_engine_call_mute_input (priv->stream_engine, -1,
-      TP_PROXY (priv->channel)->object_path,
-      priv->audio->id, is_muted,
-      tp_call_async_cb,
-      "muting input", NULL,
-      G_OBJECT (call));
+  if (priv->channel == NULL)
+    return FALSE;
+
+  g_object_get (priv->channel, "channel-properties", &props, NULL);
+
+  initial_video = tp_asv_get_boolean (props,
+    TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA ".InitialVideo", &valid);
+  if (!valid)
+    initial_video = FALSE;
+
+  g_hash_table_unref (props);
+  return initial_video;
 }
 
-void
-empathy_tp_call_start_tone (EmpathyTpCall *call, TpDTMFEvent event)
+static void
+leave_remove_members_cb (TpChannel *proxy,
+    const GError *error,
+    gpointer user_data,
+    GObject *weak_object)
 {
-  EmpathyTpCallPriv *priv = GET_PRIV (call);
-
-  g_return_if_fail (EMPATHY_IS_TP_CALL (call));
-  g_return_if_fail (priv->status == EMPATHY_TP_CALL_STATUS_ACCEPTED);
+  EmpathyTpCall *self = user_data;
 
-  if (!priv->audio->exists)
-      return;
+  if (error == NULL)
+    return;
 
-  tp_cli_channel_interface_dtmf_call_start_tone (priv->channel, -1,
-      priv->audio->id, event,
-      (tp_cli_channel_interface_dtmf_callback_for_start_tone) tp_call_async_cb,
-      "starting tone", NULL, G_OBJECT (call));
+  DEBUG ("RemoveMembers failed (%s); closing the channel", error->message);
+  empathy_tp_call_close (self);
 }
 
 void
-empathy_tp_call_stop_tone (EmpathyTpCall *call)
+empathy_tp_call_leave (EmpathyTpCall *self)
 {
-  EmpathyTpCallPriv *priv = GET_PRIV (call);
+  EmpathyTpCallPriv *priv = GET_PRIV (self);
+  TpHandle self_handle;
+  GArray array = { (gchar *) &self_handle, 1 };
 
-  g_return_if_fail (EMPATHY_IS_TP_CALL (call));
-  g_return_if_fail (priv->status == EMPATHY_TP_CALL_STATUS_ACCEPTED);
+  if (!tp_proxy_has_interface_by_id (priv->channel,
+        TP_IFACE_QUARK_CHANNEL_INTERFACE_GROUP))
+    {
+      empathy_tp_call_close (self);
+      return;
+    }
 
-  if (!priv->audio->exists)
+  self_handle = tp_channel_group_get_self_handle (priv->channel);
+  if (self_handle == 0)
+    {
+      /* we are not member of the channel */
+      empathy_tp_call_close (self);
       return;
+    }
 
-  tp_cli_channel_interface_dtmf_call_stop_tone (priv->channel, -1,
-      priv->audio->id,
-      (tp_cli_channel_interface_dtmf_callback_for_stop_tone) tp_call_async_cb,
-      "stoping tone", NULL, G_OBJECT (call));
+  tp_cli_channel_interface_group_call_remove_members (priv->channel, -1, &array,
+      "", leave_remove_members_cb, self, NULL, G_OBJECT (self));
 }
 
-gboolean
-empathy_tp_call_has_dtmf (EmpathyTpCall *call)
+EmpathyTpCallStatus
+empathy_tp_call_get_status (EmpathyTpCall *self)
 {
-  EmpathyTpCallPriv *priv = GET_PRIV (call);
-
-  g_return_val_if_fail (EMPATHY_IS_TP_CALL (call), FALSE);
+  EmpathyTpCallPriv *priv = GET_PRIV (self);
 
-  return tp_proxy_has_interface_by_id (priv->channel,
-      TP_IFACE_QUARK_CHANNEL_INTERFACE_DTMF);
+  return priv->status;
 }
 
+TpAccount *
+empathy_tp_call_get_account (EmpathyTpCall *self)
+{
+  EmpathyTpCallPriv *priv = GET_PRIV (self);
+
+  return priv->account;
+}