]> git.0d.be Git - empathy.git/blob - libempathy/empathy-tp-call.c
Request only audio in the initial request
[empathy.git] / libempathy / empathy-tp-call.c
1 /*
2  * Copyright (C) 2007 Elliot Fairweather
3  * Copyright (C) 2007-2008 Collabora Ltd.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18  *
19  * Authors: Elliot Fairweather <elliot.fairweather@collabora.co.uk>
20  *          Xavier Claessens <xclaesse@gmail.com>
21  */
22
23 #include <string.h>
24
25 #include <telepathy-glib/proxy-subclass.h>
26 #include <telepathy-glib/dbus.h>
27 #include <telepathy-glib/interfaces.h>
28
29 #include "empathy-tp-call.h"
30 #include "empathy-contact-factory.h"
31 #include "empathy-utils.h"
32
33 #define DEBUG_FLAG EMPATHY_DEBUG_TP
34 #include "empathy-debug.h"
35
36 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyTpCall)
37 typedef struct
38 {
39   gboolean dispose_has_run;
40   TpChannel *channel;
41   EmpathyContact *contact;
42   gboolean is_incoming;
43   guint status;
44
45   EmpathyTpCallStream *audio;
46   EmpathyTpCallStream *video;
47 } EmpathyTpCallPriv;
48
49 enum
50 {
51   PROP_0,
52   PROP_CHANNEL,
53   PROP_CONTACT,
54   PROP_IS_INCOMING,
55   PROP_STATUS,
56   PROP_AUDIO_STREAM,
57   PROP_VIDEO_STREAM
58 };
59
60 G_DEFINE_TYPE (EmpathyTpCall, empathy_tp_call, G_TYPE_OBJECT)
61
62 static void
63 tp_call_add_stream (EmpathyTpCall *call,
64                     guint stream_id,
65                     guint contact_handle,
66                     guint stream_type,
67                     guint stream_state,
68                     guint stream_direction)
69 {
70   EmpathyTpCallPriv *priv = GET_PRIV (call);
71
72   switch (stream_type)
73     {
74       case TP_MEDIA_STREAM_TYPE_AUDIO:
75         DEBUG ("Audio stream - id: %d, state: %d, direction: %d",
76             stream_id, stream_state, stream_direction);
77         priv->audio->exists = TRUE;
78         priv->audio->id = stream_id;
79         priv->audio->state = stream_state;
80         priv->audio->direction = stream_direction;
81         g_object_notify (G_OBJECT (call), "audio-stream");
82         break;
83       case TP_MEDIA_STREAM_TYPE_VIDEO:
84         DEBUG ("Video stream - id: %d, state: %d, direction: %d",
85             stream_id, stream_state, stream_direction);
86         priv->video->exists = TRUE;
87         priv->video->id = stream_id;
88         priv->video->state = stream_state;
89         priv->video->direction = stream_direction;
90         g_object_notify (G_OBJECT (call), "video-stream");
91         break;
92       default:
93         DEBUG ("Unknown stream type: %d", stream_type);
94     }
95 }
96
97 static void
98 tp_call_stream_added_cb (TpChannel *channel,
99                          guint stream_id,
100                          guint contact_handle,
101                          guint stream_type,
102                          gpointer user_data,
103                          GObject *call)
104 {
105   DEBUG ("Stream added - stream id: %d, contact handle: %d, stream type: %d",
106       stream_id, contact_handle, stream_type);
107
108   tp_call_add_stream (EMPATHY_TP_CALL (call), stream_id, contact_handle,
109       stream_type, TP_MEDIA_STREAM_STATE_DISCONNECTED,
110       TP_MEDIA_STREAM_DIRECTION_NONE);
111 }
112
113 static void
114 tp_call_stream_removed_cb (TpChannel *channel,
115                            guint stream_id,
116                            gpointer user_data,
117                            GObject *call)
118 {
119   EmpathyTpCallPriv *priv = GET_PRIV (call);
120
121   DEBUG ("Stream removed - stream id: %d", stream_id);
122
123   if (stream_id == priv->audio->id)
124     {
125       priv->audio->exists = FALSE;
126       g_object_notify (call, "audio-stream");
127     }
128   else if (stream_id == priv->video->id)
129     {
130       priv->video->exists = FALSE;
131       g_object_notify (call, "video-stream");
132     }
133 }
134
135 static void
136 tp_call_stream_state_changed_cb (TpChannel *proxy,
137                                  guint stream_id,
138                                  guint stream_state,
139                                  gpointer user_data,
140                                  GObject *call)
141 {
142   EmpathyTpCallPriv *priv = GET_PRIV (call);
143
144   DEBUG ("Stream state changed - stream id: %d, state state: %d",
145       stream_id, stream_state);
146
147   if (stream_id == priv->audio->id)
148     {
149       priv->audio->state = stream_state;
150       g_object_notify (call, "audio-stream");
151     }
152   else if (stream_id == priv->video->id)
153     {
154       priv->video->state = stream_state;
155       g_object_notify (call, "video-stream");
156     }
157 }
158
159 static void
160 tp_call_stream_direction_changed_cb (TpChannel *channel,
161                                      guint stream_id,
162                                      guint stream_direction,
163                                      guint pending_flags,
164                                      gpointer user_data,
165                                      GObject *call)
166 {
167   EmpathyTpCallPriv *priv = GET_PRIV (call);
168
169   DEBUG ("Stream direction changed - stream: %d, direction: %d",
170       stream_id, stream_direction);
171
172   if (stream_id == priv->audio->id)
173     {
174       priv->audio->direction = stream_direction;
175       g_object_notify (call, "audio-stream");
176     }
177   else if (stream_id == priv->video->id)
178     {
179       priv->video->direction = stream_direction;
180       g_object_notify (call, "video-stream");
181     }
182 }
183
184 static void
185 tp_call_request_streams_cb (TpChannel *channel,
186                             const GPtrArray *streams,
187                             const GError *error,
188                             gpointer user_data,
189                             GObject *call)
190 {
191   guint i;
192
193   if (error)
194     {
195       DEBUG ("Error requesting streams: %s", error->message);
196       return;
197     }
198
199   for (i = 0; i < streams->len; i++)
200     {
201       GValueArray *values;
202       guint stream_id;
203       guint contact_handle;
204       guint stream_type;
205       guint stream_state;
206       guint stream_direction;
207
208       values = g_ptr_array_index (streams, i);
209       stream_id = g_value_get_uint (g_value_array_get_nth (values, 0));
210       contact_handle = g_value_get_uint (g_value_array_get_nth (values, 1));
211       stream_type = g_value_get_uint (g_value_array_get_nth (values, 2));
212       stream_state = g_value_get_uint (g_value_array_get_nth (values, 3));
213       stream_direction = g_value_get_uint (g_value_array_get_nth (values, 4));
214
215       tp_call_add_stream (EMPATHY_TP_CALL (call), stream_id, contact_handle,
216           stream_type, stream_state, stream_direction);
217   }
218 }
219
220 static void
221 tp_call_request_streams_for_capabilities (EmpathyTpCall *call,
222                                           EmpathyCapabilities capabilities)
223 {
224   EmpathyTpCallPriv *priv = GET_PRIV (call);
225   GArray *stream_types;
226   guint handle;
227   guint stream_type;
228
229   if (capabilities == EMPATHY_CAPABILITIES_UNKNOWN)
230       capabilities = EMPATHY_CAPABILITIES_AUDIO | EMPATHY_CAPABILITIES_VIDEO;
231
232   DEBUG ("Requesting new stream for capabilities %d",
233       capabilities);
234
235   stream_types = g_array_new (FALSE, FALSE, sizeof (guint));
236   handle = empathy_contact_get_handle (priv->contact);
237
238   if (capabilities & EMPATHY_CAPABILITIES_AUDIO)
239     {
240       stream_type = TP_MEDIA_STREAM_TYPE_AUDIO;
241       g_array_append_val (stream_types, stream_type);
242     }
243   if (capabilities & EMPATHY_CAPABILITIES_VIDEO)
244     {
245       stream_type = TP_MEDIA_STREAM_TYPE_VIDEO;
246       g_array_append_val (stream_types, stream_type);
247     }
248
249   tp_cli_channel_type_streamed_media_call_request_streams (priv->channel, -1,
250       handle, stream_types, tp_call_request_streams_cb, NULL, NULL,
251       G_OBJECT (call));
252
253   g_array_free (stream_types, TRUE);
254 }
255
256 static EmpathyContact *
257 tp_call_dup_contact_from_handle (EmpathyTpCall *call, TpHandle handle)
258 {
259   EmpathyTpCallPriv *priv = GET_PRIV (call);
260   EmpathyContactFactory *factory;
261   McAccount *account;
262   EmpathyContact *contact;
263
264   factory = empathy_contact_factory_dup_singleton ();
265   account = empathy_channel_get_account (priv->channel);
266   contact = empathy_contact_factory_get_from_handle (factory, account, handle);
267
268   g_object_unref (factory);
269   g_object_unref (account);
270
271   return contact;
272 }
273
274 static void
275 tp_call_update_status (EmpathyTpCall *call)
276 {
277   EmpathyTpCallPriv *priv = GET_PRIV (call);
278   TpHandle self_handle;
279   const TpIntSet *set;
280   TpIntSetIter iter;
281
282   g_object_ref (call);
283
284   self_handle = tp_channel_group_get_self_handle (priv->channel);
285   set = tp_channel_group_get_members (priv->channel);
286   tp_intset_iter_init (&iter, set);
287   while (tp_intset_iter_next (&iter))
288     {
289       if (priv->contact == NULL && iter.element != self_handle)
290         {
291           /* We found the remote contact */
292           priv->contact = tp_call_dup_contact_from_handle (call, iter.element);
293           priv->is_incoming = TRUE;
294           priv->status = EMPATHY_TP_CALL_STATUS_PENDING;
295           g_object_notify (G_OBJECT (call), "is-incoming");
296           g_object_notify (G_OBJECT (call), "contact");
297           g_object_notify (G_OBJECT (call), "status");
298         }
299
300       if (priv->status == EMPATHY_TP_CALL_STATUS_PENDING &&
301           ((priv->is_incoming && iter.element == self_handle) ||
302            (!priv->is_incoming && iter.element != self_handle)))
303         {
304           priv->status = EMPATHY_TP_CALL_STATUS_ACCEPTED;
305           g_object_notify (G_OBJECT (call), "status");
306         }
307     }
308
309   g_object_unref (call);
310 }
311
312 static void
313 tp_call_members_changed_cb (TpChannel *channel,
314                             gchar *message,
315                             GArray *added,
316                             GArray *removed,
317                             GArray *local_pending,
318                             GArray *remote_pending,
319                             guint actor,
320                             guint reason,
321                             EmpathyTpCall *call)
322 {
323   tp_call_update_status (call);
324 }
325
326 void
327 empathy_tp_call_to (EmpathyTpCall *call, EmpathyContact *contact)
328 {
329   EmpathyTpCallPriv *priv = GET_PRIV (call);
330
331   priv->contact = g_object_ref (contact);
332   priv->is_incoming = FALSE;
333   priv->status = EMPATHY_TP_CALL_STATUS_PENDING;
334   g_object_notify (G_OBJECT (call), "is-incoming");
335   g_object_notify (G_OBJECT (call), "contact");
336   g_object_notify (G_OBJECT (call), "status");
337   tp_call_request_streams_for_capabilities (call, EMPATHY_CAPABILITIES_AUDIO);
338 }
339
340 static void
341 tp_call_channel_invalidated_cb (TpChannel     *channel,
342                                 GQuark         domain,
343                                 gint           code,
344                                 gchar         *message,
345                                 EmpathyTpCall *call)
346 {
347   EmpathyTpCallPriv *priv = GET_PRIV (call);
348
349   DEBUG ("Channel invalidated: %s", message);
350   priv->status = EMPATHY_TP_CALL_STATUS_CLOSED;
351   g_object_notify (G_OBJECT (call), "status");
352 }
353
354 static void
355 tp_call_async_cb (TpProxy *proxy,
356                   const GError *error,
357                   gpointer user_data,
358                   GObject *call)
359 {
360   if (error)
361       DEBUG ("Error %s: %s", (gchar*) user_data, error->message);
362 }
363
364 static void
365 tp_call_close_channel (EmpathyTpCall *call)
366 {
367   EmpathyTpCallPriv *priv = GET_PRIV (call);
368
369   if (priv->status == EMPATHY_TP_CALL_STATUS_CLOSED)
370       return;
371
372   DEBUG ("Closing channel");
373
374   tp_cli_channel_call_close (priv->channel, -1,
375       NULL, NULL, NULL, NULL);
376
377   priv->status = EMPATHY_TP_CALL_STATUS_CLOSED;
378   g_object_notify (G_OBJECT (call), "status");
379 }
380
381 static GObject *
382 tp_call_constructor (GType type,
383                      guint n_construct_params,
384                      GObjectConstructParam *construct_params)
385 {
386   GObject *object;
387   EmpathyTpCall *call;
388   EmpathyTpCallPriv *priv;
389
390   object = G_OBJECT_CLASS (empathy_tp_call_parent_class)->constructor (type,
391       n_construct_params, construct_params);
392
393   call = EMPATHY_TP_CALL (object);
394   priv = GET_PRIV (call);
395
396   /* Setup streamed media channel */
397   g_signal_connect (priv->channel, "invalidated",
398       G_CALLBACK (tp_call_channel_invalidated_cb), call);
399   tp_cli_channel_type_streamed_media_connect_to_stream_added (priv->channel,
400       tp_call_stream_added_cb, NULL, NULL, G_OBJECT (call), NULL);
401   tp_cli_channel_type_streamed_media_connect_to_stream_removed (priv->channel,
402       tp_call_stream_removed_cb, NULL, NULL, G_OBJECT (call), NULL);
403   tp_cli_channel_type_streamed_media_connect_to_stream_state_changed (priv->channel,
404       tp_call_stream_state_changed_cb, NULL, NULL, G_OBJECT (call), NULL);
405   tp_cli_channel_type_streamed_media_connect_to_stream_direction_changed (priv->channel,
406       tp_call_stream_direction_changed_cb, NULL, NULL, G_OBJECT (call), NULL);
407   tp_cli_channel_type_streamed_media_call_list_streams (priv->channel, -1,
408       tp_call_request_streams_cb, NULL, NULL, G_OBJECT (call));
409
410   /* Update status when members changes */
411   tp_call_update_status (call);
412   g_signal_connect (priv->channel, "group-members-changed",
413       G_CALLBACK (tp_call_members_changed_cb), call);
414
415   return object;
416 }
417 static void
418 tp_call_dispose (GObject *object)
419 {
420   EmpathyTpCallPriv *priv = GET_PRIV (object);
421
422   DEBUG ("Disposing: %p, %d", object, priv->dispose_has_run);
423
424   if (priv->dispose_has_run)
425     return;
426
427   priv->dispose_has_run = TRUE;
428
429   if (priv->channel != NULL)
430     {
431       g_signal_handlers_disconnect_by_func (priv->channel,
432         tp_call_channel_invalidated_cb, object);
433
434       g_object_unref (priv->channel);
435       priv->channel = NULL;
436     }
437
438   if (priv->contact != NULL)
439       g_object_unref (priv->contact);
440
441   if (G_OBJECT_CLASS (empathy_tp_call_parent_class)->dispose)
442     G_OBJECT_CLASS (empathy_tp_call_parent_class)->dispose (object);
443 }
444
445 static void
446 tp_call_finalize (GObject *object)
447 {
448   EmpathyTpCallPriv *priv = GET_PRIV (object);
449
450   DEBUG ("Finalizing: %p", object);
451
452   g_slice_free (EmpathyTpCallStream, priv->audio);
453   g_slice_free (EmpathyTpCallStream, priv->video);
454
455   (G_OBJECT_CLASS (empathy_tp_call_parent_class)->finalize) (object);
456 }
457
458 static void
459 tp_call_set_property (GObject *object,
460                       guint prop_id,
461                       const GValue *value,
462                       GParamSpec *pspec)
463 {
464   EmpathyTpCallPriv *priv = GET_PRIV (object);
465
466   switch (prop_id)
467     {
468     case PROP_CHANNEL:
469       priv->channel = g_value_dup_object (value);
470       break;
471     default:
472       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
473       break;
474   }
475 }
476
477 static void
478 tp_call_get_property (GObject *object,
479                       guint prop_id,
480                       GValue *value,
481                       GParamSpec *pspec)
482 {
483   EmpathyTpCallPriv *priv = GET_PRIV (object);
484
485   switch (prop_id)
486     {
487     case PROP_CHANNEL:
488       g_value_set_object (value, priv->channel);
489       break;
490     case PROP_CONTACT:
491       g_value_set_object (value, priv->contact);
492       break;
493     case PROP_IS_INCOMING:
494       g_value_set_boolean (value, priv->is_incoming);
495       break;
496     case PROP_STATUS:
497       g_value_set_uint (value, priv->status);
498       break;
499     case PROP_AUDIO_STREAM:
500       g_value_set_pointer (value, priv->audio);
501       break;
502     case PROP_VIDEO_STREAM:
503       g_value_set_pointer (value, priv->video);
504       break;
505     default:
506       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
507       break;
508   }
509 }
510
511 static void
512 empathy_tp_call_class_init (EmpathyTpCallClass *klass)
513 {
514   GObjectClass *object_class = G_OBJECT_CLASS (klass);
515
516   object_class->constructor = tp_call_constructor;
517   object_class->dispose = tp_call_dispose;
518   object_class->finalize = tp_call_finalize;
519   object_class->set_property = tp_call_set_property;
520   object_class->get_property = tp_call_get_property;
521
522   g_type_class_add_private (klass, sizeof (EmpathyTpCallPriv));
523
524   g_object_class_install_property (object_class, PROP_CHANNEL,
525       g_param_spec_object ("channel", "channel", "channel",
526       TP_TYPE_CHANNEL,
527       G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
528       G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
529   g_object_class_install_property (object_class, PROP_CONTACT,
530       g_param_spec_object ("contact", "Call contact", "Call contact",
531       EMPATHY_TYPE_CONTACT,
532       G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
533   g_object_class_install_property (object_class, PROP_IS_INCOMING,
534       g_param_spec_boolean ("is-incoming", "Is media stream incoming",
535       "Is media stream incoming", FALSE, G_PARAM_READABLE |
536       G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
537   g_object_class_install_property (object_class, PROP_STATUS,
538       g_param_spec_uint ("status", "Call status",
539       "Call status", 0, 255, 0, G_PARAM_READABLE | G_PARAM_STATIC_NICK |
540       G_PARAM_STATIC_BLURB));
541   g_object_class_install_property (object_class, PROP_AUDIO_STREAM,
542       g_param_spec_pointer ("audio-stream", "Audio stream data",
543       "Audio stream data",
544       G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
545   g_object_class_install_property (object_class, PROP_VIDEO_STREAM,
546       g_param_spec_pointer ("video-stream", "Video stream data",
547       "Video stream data",
548       G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
549 }
550
551 static void
552 empathy_tp_call_init (EmpathyTpCall *call)
553 {
554   EmpathyTpCallPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (call,
555     EMPATHY_TYPE_TP_CALL, EmpathyTpCallPriv);
556
557   call->priv = priv;
558   priv->status = EMPATHY_TP_CALL_STATUS_READYING;
559   priv->contact = NULL;
560   priv->audio = g_slice_new0 (EmpathyTpCallStream);
561   priv->video = g_slice_new0 (EmpathyTpCallStream);
562   priv->audio->exists = FALSE;
563   priv->video->exists = FALSE;
564 }
565
566 EmpathyTpCall *
567 empathy_tp_call_new (TpChannel *channel)
568 {
569   g_return_val_if_fail (TP_IS_CHANNEL (channel), NULL);
570
571   return g_object_new (EMPATHY_TYPE_TP_CALL,
572       "channel", channel,
573       NULL);
574 }
575
576 void
577 empathy_tp_call_accept_incoming_call (EmpathyTpCall *call)
578 {
579   EmpathyTpCallPriv *priv = GET_PRIV (call);
580   TpHandle self_handle;
581   GArray handles = {(gchar *) &self_handle, 1};
582
583   g_return_if_fail (EMPATHY_IS_TP_CALL (call));
584   g_return_if_fail (priv->status == EMPATHY_TP_CALL_STATUS_PENDING);
585   g_return_if_fail (priv->is_incoming);
586
587   DEBUG ("Accepting incoming call");
588
589   self_handle = tp_channel_group_get_self_handle (priv->channel);
590   tp_cli_channel_interface_group_call_add_members (priv->channel, -1,
591       &handles, NULL, NULL, NULL, NULL, NULL);
592 }
593
594 void
595 empathy_tp_call_close (EmpathyTpCall *call)
596 {
597   EmpathyTpCallPriv *priv = GET_PRIV (call);
598
599   g_return_if_fail (EMPATHY_IS_TP_CALL (call));
600
601   if (priv->status == EMPATHY_TP_CALL_STATUS_CLOSED)
602       return;
603
604   DEBUG ("Closing channel");
605
606   tp_cli_channel_call_close (priv->channel, -1,
607       NULL, NULL, NULL, NULL);
608
609   priv->status = EMPATHY_TP_CALL_STATUS_CLOSED;
610   g_object_notify (G_OBJECT (call), "status");
611 }
612
613 void
614 empathy_tp_call_request_video_stream_direction (EmpathyTpCall *call,
615                                                 gboolean is_sending)
616 {
617   EmpathyTpCallPriv *priv = GET_PRIV (call);
618   guint new_direction;
619
620   g_return_if_fail (EMPATHY_IS_TP_CALL (call));
621   g_return_if_fail (priv->status == EMPATHY_TP_CALL_STATUS_ACCEPTED);
622
623   DEBUG ("Requesting video stream direction - is_sending: %d", is_sending);
624
625   if (!priv->video->exists)
626     {
627       if (is_sending)
628           tp_call_request_streams_for_capabilities (call,
629               EMPATHY_CAPABILITIES_VIDEO);
630       return;
631     }
632
633   if (is_sending)
634       new_direction = priv->video->direction | TP_MEDIA_STREAM_DIRECTION_SEND;
635   else
636       new_direction = priv->video->direction & ~TP_MEDIA_STREAM_DIRECTION_SEND;
637
638   tp_cli_channel_type_streamed_media_call_request_stream_direction (priv->channel,
639       -1, priv->video->id, new_direction,
640       (tp_cli_channel_type_streamed_media_callback_for_request_stream_direction)
641       tp_call_async_cb, NULL, NULL, G_OBJECT (call));
642 }
643
644 void
645 empathy_tp_call_add_preview_video (EmpathyTpCall *call,
646                                    guint preview_video_socket_id)
647 {
648   //EmpathyTpCallPriv *priv = GET_PRIV (call);
649
650   g_return_if_fail (EMPATHY_IS_TP_CALL (call));
651
652   DEBUG ("Adding preview video");
653
654   /* FIXME add the preview window */
655 }
656
657 void
658 empathy_tp_call_remove_preview_video (EmpathyTpCall *call,
659                                       guint preview_video_socket_id)
660 {
661   //EmpathyTpCallPriv *priv = GET_PRIV (call);
662
663   g_return_if_fail (EMPATHY_IS_TP_CALL (call));
664
665   DEBUG ("Removing preview video");
666
667   /* FIXME remove the preview window */
668 }
669
670 void
671 empathy_tp_call_add_output_video (EmpathyTpCall *call,
672                                   guint output_video_socket_id)
673 {
674   //EmpathyTpCallPriv *priv = GET_PRIV (call);
675
676   g_return_if_fail (EMPATHY_IS_TP_CALL (call));
677
678   DEBUG ("Adding output video - socket: %d", output_video_socket_id);
679
680   /* FIXME add output window */
681 }
682
683 void
684 empathy_tp_call_set_output_volume (EmpathyTpCall *call,
685                                    guint volume)
686 {
687   EmpathyTpCallPriv *priv = GET_PRIV (call);
688
689   g_return_if_fail (EMPATHY_IS_TP_CALL (call));
690   g_return_if_fail (priv->status != EMPATHY_TP_CALL_STATUS_CLOSED);
691
692   DEBUG ("Setting output volume: %d", volume);
693
694   /* FIXME set volume */
695 }
696
697 void
698 empathy_tp_call_mute_output (EmpathyTpCall *call,
699                              gboolean is_muted)
700 {
701   //EmpathyTpCallPriv *priv = GET_PRIV (call);
702
703   g_return_if_fail (EMPATHY_IS_TP_CALL (call));
704
705   DEBUG ("Setting output mute: %d", is_muted);
706   /* FIXME mute output */
707 }
708
709 void
710 empathy_tp_call_mute_input (EmpathyTpCall *call,
711                             gboolean is_muted)
712 {
713   //EmpathyTpCallPriv *priv = GET_PRIV (call);
714
715   g_return_if_fail (EMPATHY_IS_TP_CALL (call));
716
717   DEBUG ("Setting input mute: %d", is_muted);
718
719   /* FIXME mute input */
720 }
721
722 void
723 empathy_tp_call_start_tone (EmpathyTpCall *call, TpDTMFEvent event)
724 {
725   EmpathyTpCallPriv *priv = GET_PRIV (call);
726
727   g_return_if_fail (EMPATHY_IS_TP_CALL (call));
728   g_return_if_fail (priv->status == EMPATHY_TP_CALL_STATUS_ACCEPTED);
729
730   if (!priv->audio->exists)
731       return;
732
733   tp_cli_channel_interface_dtmf_call_start_tone (priv->channel, -1,
734       priv->audio->id, event,
735       (tp_cli_channel_interface_dtmf_callback_for_start_tone) tp_call_async_cb,
736       "starting tone", NULL, G_OBJECT (call));
737 }
738
739 void
740 empathy_tp_call_stop_tone (EmpathyTpCall *call)
741 {
742   EmpathyTpCallPriv *priv = GET_PRIV (call);
743
744   g_return_if_fail (EMPATHY_IS_TP_CALL (call));
745   g_return_if_fail (priv->status == EMPATHY_TP_CALL_STATUS_ACCEPTED);
746
747   if (!priv->audio->exists)
748       return;
749
750   tp_cli_channel_interface_dtmf_call_stop_tone (priv->channel, -1,
751       priv->audio->id,
752       (tp_cli_channel_interface_dtmf_callback_for_stop_tone) tp_call_async_cb,
753       "stoping tone", NULL, G_OBJECT (call));
754 }
755
756 gboolean
757 empathy_tp_call_has_dtmf (EmpathyTpCall *call)
758 {
759   EmpathyTpCallPriv *priv = GET_PRIV (call);
760
761   g_return_val_if_fail (EMPATHY_IS_TP_CALL (call), FALSE);
762
763   return tp_proxy_has_interface_by_id (priv->channel,
764       TP_IFACE_QUARK_CHANNEL_INTERFACE_DTMF);
765 }
766