2 * Copyright (C) 2007 Elliot Fairweather
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 * Authors: Elliot Fairweather <elliot.fairweather@collabora.co.uk>
22 #include <dbus/dbus-glib.h>
24 #include <libtelepathy/tp-chan-type-streamed-media-gen.h>
25 #include <libtelepathy/tp-connmgr.h>
26 #include <libtelepathy/tp-helpers.h>
27 #include <telepathy-glib/proxy-subclass.h>
29 #include <libmissioncontrol/mc-account.h>
31 #include <extensions/extensions.h>
32 #include <libempathy/empathy-contact-factory.h>
33 #include <libempathy/empathy-debug.h>
34 #include <libempathy/empathy-tp-group.h>
35 #include <libempathy/empathy-utils.h>
37 #include "empathy-tp-call.h"
39 #define DEBUG_DOMAIN "TpCall"
41 #define GET_PRIV(object) (G_TYPE_INSTANCE_GET_PRIVATE \
42 ((object), EMPATHY_TYPE_TP_CALL, EmpathyTpCallPriv))
44 #define STREAM_ENGINE_BUS_NAME "org.freedesktop.Telepathy.StreamEngine"
45 #define STREAM_ENGINE_OBJECT_PATH "/org/freedesktop/Telepathy/StreamEngine"
47 typedef struct _EmpathyTpCallPriv EmpathyTpCallPriv;
49 struct _EmpathyTpCallPriv
53 TpProxy *stream_engine;
54 EmpathyTpGroup *group;
55 EmpathyContact *contact;
59 EmpathyTpCallStream *audio;
60 EmpathyTpCallStream *video;
65 STATUS_CHANGED_SIGNAL,
66 RECEIVING_VIDEO_SIGNAL,
83 static guint signals[LAST_SIGNAL];
85 G_DEFINE_TYPE (EmpathyTpCall, empathy_tp_call, G_TYPE_OBJECT)
88 tp_call_stream_state_changed_cb (DBusGProxy *channel,
93 EmpathyTpCallPriv *priv = GET_PRIV (call);
95 empathy_debug (DEBUG_DOMAIN,
96 "Stream state changed - stream id: %d, state state: %d",
97 stream_id, stream_state);
99 if (stream_id == priv->audio->id)
101 priv->audio->state = stream_state;
103 else if (stream_id == priv->video->id)
105 priv->video->state = stream_state;
108 g_signal_emit_by_name (call, "status-changed");
112 tp_call_identify_streams (EmpathyTpCall *call)
114 EmpathyTpCallPriv *priv = GET_PRIV (call);
115 GPtrArray *stream_infos;
116 DBusGProxy *streamed_iface;
117 GError *error = NULL;
120 empathy_debug (DEBUG_DOMAIN, "Identifying audio/video streams");
122 streamed_iface = tp_chan_get_interface (priv->channel,
123 TELEPATHY_CHAN_IFACE_STREAMED_QUARK);
125 if (!tp_chan_type_streamed_media_list_streams (streamed_iface, &stream_infos,
128 empathy_debug (DEBUG_DOMAIN, "Couldn't list audio/video streams: %s",
130 g_clear_error (&error);
134 for (i = 0; i < stream_infos->len; i++)
141 guint stream_direction;
143 values = g_ptr_array_index (stream_infos, i);
144 stream_id = g_value_get_uint (g_value_array_get_nth (values, 0));
145 stream_handle = g_value_get_uint (g_value_array_get_nth (values, 1));
146 stream_type = g_value_get_uint (g_value_array_get_nth (values, 2));
147 stream_state = g_value_get_uint (g_value_array_get_nth (values, 3));
148 stream_direction = g_value_get_uint (g_value_array_get_nth (values, 4));
152 case TP_MEDIA_STREAM_TYPE_AUDIO:
153 empathy_debug (DEBUG_DOMAIN,
154 "Audio stream - id: %d, state: %d, direction: %d",
155 stream_id, stream_state, stream_direction);
156 priv->audio->exists = TRUE;
157 priv->audio->id = stream_id;
158 priv->audio->state = stream_state;
159 priv->audio->direction = stream_direction;
161 case TP_MEDIA_STREAM_TYPE_VIDEO:
162 empathy_debug (DEBUG_DOMAIN,
163 "Video stream - id: %d, state: %d, direction: %d",
164 stream_id, stream_state, stream_direction);
165 priv->video->exists = TRUE;
166 priv->video->id = stream_id;
167 priv->video->state = stream_state;
168 priv->video->direction = stream_direction;
171 empathy_debug (DEBUG_DOMAIN, "Unknown stream type: %d",
175 g_value_array_free (values);
180 tp_call_stream_added_cb (DBusGProxy *channel,
182 guint contact_handle,
186 empathy_debug (DEBUG_DOMAIN,
187 "Stream added - stream id: %d, contact handle: %d, stream type: %d",
188 stream_id, contact_handle, stream_type);
190 tp_call_identify_streams (call);
195 tp_call_stream_removed_cb (DBusGProxy *channel,
199 EmpathyTpCallPriv *priv = GET_PRIV (call);
201 empathy_debug (DEBUG_DOMAIN, "Stream removed - stream id: %d", stream_id);
203 if (stream_id == priv->audio->id)
205 priv->audio->exists = FALSE;
207 else if (stream_id == priv->video->id)
209 priv->video->exists = FALSE;
214 tp_call_channel_closed_cb (TpChan *channel,
217 EmpathyTpCallPriv *priv = GET_PRIV (call);
218 DBusGProxy *streamed_iface;
219 DBusGProxy *group_iface;
221 empathy_debug (DEBUG_DOMAIN, "Channel closed");
223 priv->status = EMPATHY_TP_CALL_STATUS_CLOSED;
224 g_signal_emit_by_name (call, "status-changed");
226 streamed_iface = tp_chan_get_interface (priv->channel,
227 TELEPATHY_CHAN_IFACE_STREAMED_QUARK);
228 group_iface = tp_chan_get_interface (priv->channel,
229 TELEPATHY_CHAN_IFACE_GROUP_QUARK);
231 dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (priv->channel), "Closed",
232 G_CALLBACK (tp_call_channel_closed_cb), (gpointer) call);
233 dbus_g_proxy_disconnect_signal (streamed_iface, "StreamStateChanged",
234 G_CALLBACK (tp_call_stream_state_changed_cb), (gpointer) call);
235 dbus_g_proxy_disconnect_signal (streamed_iface, "StreamAdded",
236 G_CALLBACK (tp_call_stream_added_cb), (gpointer) call);
237 dbus_g_proxy_disconnect_signal (streamed_iface, "StreamRemoved",
238 G_CALLBACK (tp_call_stream_removed_cb), (gpointer) call);
242 tp_call_stream_direction_changed_cb (DBusGProxy *channel,
244 guint stream_direction,
248 EmpathyTpCallPriv *priv = GET_PRIV (call);
250 empathy_debug (DEBUG_DOMAIN,
251 "Stream direction changed - stream: %d, direction: %d",
252 stream_id, stream_direction);
254 if (stream_id == priv->audio->id)
256 priv->audio->direction = stream_direction;
258 else if (stream_id == priv->video->id)
260 priv->video->direction = stream_direction;
262 if (stream_direction & TP_MEDIA_STREAM_DIRECTION_RECEIVE)
264 empathy_debug (DEBUG_DOMAIN, "RECEIVING");
265 g_signal_emit_by_name (call, "receiving-video", TRUE);
269 empathy_debug (DEBUG_DOMAIN, "NOT RECEIVING");
270 g_signal_emit_by_name (call, "receiving-video", FALSE);
273 if (stream_direction & TP_MEDIA_STREAM_DIRECTION_SEND)
275 empathy_debug (DEBUG_DOMAIN, "SENDING");
276 g_signal_emit_by_name (call, "sending-video", TRUE);
280 empathy_debug (DEBUG_DOMAIN, "NOT SENDING");
281 g_signal_emit_by_name (call, "sending-video", FALSE);
287 tp_call_request_streams_for_capabilities (EmpathyTpCall *call,
288 EmpathyCapabilities capabilities)
290 EmpathyTpCallPriv *priv = GET_PRIV (call);
291 DBusGProxy *streamed_iface;
292 GArray *stream_types;
295 GError *error = NULL;
297 empathy_debug (DEBUG_DOMAIN, "Requesting new stream for capabilities %d",
300 streamed_iface = tp_chan_get_interface (priv->channel,
301 TELEPATHY_CHAN_IFACE_STREAMED_QUARK);
302 stream_types = g_array_new (FALSE, FALSE, sizeof (guint));
303 handle = empathy_contact_get_handle (priv->contact);
305 if (capabilities & EMPATHY_CAPABILITIES_AUDIO)
307 stream_type = TP_MEDIA_STREAM_TYPE_AUDIO;
308 g_array_append_val (stream_types, stream_type);
310 if (capabilities & EMPATHY_CAPABILITIES_VIDEO)
312 stream_type = TP_MEDIA_STREAM_TYPE_VIDEO;
313 g_array_append_val (stream_types, stream_type);
316 if (!tp_chan_type_streamed_media_request_streams (streamed_iface, handle,
317 stream_types, NULL, &error))
319 empathy_debug (DEBUG_DOMAIN, "Couldn't request new stream: %s",
321 g_clear_error (&error);
324 g_array_free (stream_types, TRUE);
328 tp_call_request_streams_capabilities_cb (EmpathyContact *contact,
329 GParamSpec *property,
332 EmpathyTpCall *call = EMPATHY_TP_CALL (user_data);
334 g_signal_handlers_disconnect_by_func (contact,
335 tp_call_request_streams_capabilities_cb,
338 tp_call_request_streams_for_capabilities (call,
339 empathy_contact_get_capabilities (contact));
343 tp_call_request_streams (EmpathyTpCall *call)
345 EmpathyTpCallPriv *priv = GET_PRIV (call);
346 EmpathyCapabilities capabilities;
347 DBusGProxy *capabilities_iface;
349 empathy_debug (DEBUG_DOMAIN,
350 "Requesting appropriate audio/video streams from contact");
353 /* FIXME: SIP don't have capabilities interface but we know it supports
354 * only audio and not video. */
355 capabilities_iface = tp_conn_get_interface (priv->connection,
356 TP_IFACE_QUARK_CONNECTION_INTERFACE_CAPABILITIES);
357 if (!capabilities_iface)
359 capabilities = EMPATHY_CAPABILITIES_AUDIO;
363 capabilities = empathy_contact_get_capabilities (priv->contact);
364 if (capabilities == EMPATHY_CAPABILITIES_UNKNOWN)
366 g_signal_connect (priv->contact, "notify::capabilities",
367 G_CALLBACK (tp_call_request_streams_capabilities_cb), call);
372 tp_call_request_streams_for_capabilities (call, capabilities);
376 tp_call_is_ready (EmpathyTpCall *call)
378 EmpathyTpCallPriv *priv = GET_PRIV (call);
379 EmpathyContact *self_contact;
381 GList *local_pendings;
382 GList *remote_pendings;
384 if (priv->status > EMPATHY_TP_CALL_STATUS_READYING)
387 members = empathy_tp_group_get_members (priv->group);
391 self_contact = empathy_tp_group_get_self_contact (priv->group);
392 local_pendings = empathy_tp_group_get_local_pendings (priv->group);
393 remote_pendings = empathy_tp_group_get_remote_pendings (priv->group);
395 if (local_pendings &&
396 empathy_contact_equal (EMPATHY_CONTACT (((EmpathyPendingInfo *)
397 local_pendings->data)->member), self_contact))
399 empathy_debug (DEBUG_DOMAIN,
400 "Incoming call is ready - %p",
401 ((EmpathyPendingInfo *) local_pendings->data)->member);
402 priv->is_incoming = TRUE;
403 priv->contact = g_object_ref (members->data);
405 else if (remote_pendings &&
406 empathy_contact_equal (EMPATHY_CONTACT (members->data), self_contact))
408 empathy_debug (DEBUG_DOMAIN,
409 "Outgoing call is ready - %p", remote_pendings->data);
410 priv->is_incoming = FALSE;
411 priv->contact = g_object_ref (remote_pendings->data);
412 tp_call_request_streams (call);
415 g_object_unref (self_contact);
416 g_list_foreach (members, (GFunc) g_object_unref, NULL);
417 g_list_free (members);
418 g_list_foreach (local_pendings, (GFunc) empathy_pending_info_free, NULL);
419 g_list_free (local_pendings);
420 g_list_foreach (remote_pendings, (GFunc) g_object_unref, NULL);
421 g_list_free (remote_pendings);
425 priv->status = EMPATHY_TP_CALL_STATUS_PENDING;
426 g_signal_emit (call, signals[STATUS_CHANGED_SIGNAL], 0);
431 tp_call_member_added_cb (EmpathyTpGroup *group,
432 EmpathyContact *contact,
433 EmpathyContact *actor,
435 const gchar *message,
438 EmpathyTpCallPriv *priv = GET_PRIV (call);
440 empathy_debug (DEBUG_DOMAIN, "New member added callback %p", contact);
441 tp_call_is_ready (call);
443 if (priv->status == EMPATHY_TP_CALL_STATUS_PENDING)
445 if ((priv->is_incoming &&
446 !empathy_contact_equal (contact, priv->contact))
447 || (!priv->is_incoming &&
448 empathy_contact_equal (contact, priv->contact)))
450 priv->status = EMPATHY_TP_CALL_STATUS_ACCEPTED;
451 g_signal_emit (call, signals[STATUS_CHANGED_SIGNAL], 0);
457 tp_call_local_pending_cb (EmpathyTpGroup *group,
458 EmpathyContact *contact,
459 EmpathyContact *actor,
461 const gchar *message,
464 empathy_debug (DEBUG_DOMAIN, "New local pending added callback %p", contact);
465 tp_call_is_ready (call);
469 tp_call_remote_pending_cb (EmpathyTpGroup *group,
470 EmpathyContact *contact,
471 EmpathyContact *actor,
473 const gchar *message,
476 empathy_debug (DEBUG_DOMAIN, "New remote pending added callback %p", contact);
477 tp_call_is_ready (call);
481 tp_call_async_cb (TpProxy *proxy,
484 GObject *weak_object)
488 empathy_debug (DEBUG_DOMAIN, "Error %s: %s",
489 user_data, error->message);
494 tp_call_start_stream_engine (EmpathyTpCall *call)
496 EmpathyTpCallPriv *priv = GET_PRIV (call);
498 empathy_debug (DEBUG_DOMAIN, "Revving up the stream engine");
500 priv->stream_engine = g_object_new (TP_TYPE_PROXY,
501 "bus-name", STREAM_ENGINE_BUS_NAME,
502 "dbus-connection", tp_get_bus (),
503 "object-path", STREAM_ENGINE_OBJECT_PATH);
504 tp_proxy_add_interface_by_id (priv->stream_engine,
505 EMP_IFACE_QUARK_STREAM_ENGINE);
506 tp_proxy_add_interface_by_id (priv->stream_engine,
507 EMP_IFACE_QUARK_CHANNEL_HANDLER);
509 emp_cli_channel_handler_call_handle_channel (priv->stream_engine, -1,
510 dbus_g_proxy_get_bus_name (DBUS_G_PROXY (priv->connection)),
511 dbus_g_proxy_get_path (DBUS_G_PROXY (priv->connection)),
513 dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel)),
514 priv->channel->handle_type, priv->channel->handle,
516 "calling handle channel", NULL,
521 tp_call_constructor (GType type,
522 guint n_construct_params,
523 GObjectConstructParam *construct_params)
527 EmpathyTpCallPriv *priv;
528 DBusGProxy *streamed_iface;
532 object = G_OBJECT_CLASS (empathy_tp_call_parent_class)->constructor (type,
533 n_construct_params, construct_params);
535 call = EMPATHY_TP_CALL (object);
536 priv = GET_PRIV (call);
538 dbus_g_proxy_connect_signal (DBUS_G_PROXY (priv->channel), "Closed",
539 G_CALLBACK (tp_call_channel_closed_cb), (gpointer) call, NULL);
541 streamed_iface = tp_chan_get_interface (priv->channel,
542 TELEPATHY_CHAN_IFACE_STREAMED_QUARK);
543 dbus_g_proxy_connect_signal (streamed_iface, "StreamStateChanged",
544 G_CALLBACK (tp_call_stream_state_changed_cb),
545 (gpointer) call, NULL);
546 dbus_g_proxy_connect_signal (streamed_iface, "StreamDirectionChanged",
547 G_CALLBACK (tp_call_stream_direction_changed_cb),
548 (gpointer) call, NULL);
549 dbus_g_proxy_connect_signal (streamed_iface, "StreamAdded",
550 G_CALLBACK (tp_call_stream_added_cb), (gpointer) call, NULL);
551 dbus_g_proxy_connect_signal (streamed_iface, "StreamRemoved",
552 G_CALLBACK (tp_call_stream_removed_cb), (gpointer) call, NULL);
554 mc = empathy_mission_control_new ();
555 account = mission_control_get_account_for_connection (mc, priv->connection,
557 priv->group = empathy_tp_group_new (account, priv->channel);
560 g_signal_connect (G_OBJECT (priv->group), "member-added",
561 G_CALLBACK (tp_call_member_added_cb), (gpointer) call);
562 g_signal_connect (G_OBJECT (priv->group), "local-pending",
563 G_CALLBACK (tp_call_local_pending_cb), (gpointer) call);
564 g_signal_connect (G_OBJECT (priv->group), "remote-pending",
565 G_CALLBACK (tp_call_remote_pending_cb), (gpointer) call);
567 tp_call_start_stream_engine (call);
568 /* FIXME: unnecessary for outgoing? */
569 tp_call_identify_streams (call);
575 tp_call_finalize (GObject *object)
577 EmpathyTpCallPriv *priv = GET_PRIV (object);
579 empathy_debug (DEBUG_DOMAIN, "Finalizing: %p", object);
581 g_slice_free (EmpathyTpCallStream, priv->audio);
582 g_slice_free (EmpathyTpCallStream, priv->video);
583 g_object_unref (priv->group);
585 if (priv->connection != NULL)
586 g_object_unref (priv->connection);
588 if (priv->channel != NULL)
589 g_object_unref (priv->channel);
593 g_object_unref (priv->contact);
596 (G_OBJECT_CLASS (empathy_tp_call_parent_class)->finalize) (object);
600 tp_call_set_property (GObject *object,
605 EmpathyTpCallPriv *priv = GET_PRIV (object);
609 case PROP_CONNECTION:
610 priv->connection = g_value_dup_object (value);
613 priv->channel = g_value_dup_object (value);
616 /* FIXME should this one be writable in the first place ? */
617 g_assert (priv->contact == NULL);
618 priv->contact = g_value_dup_object (value);
620 case PROP_IS_INCOMING:
621 priv->is_incoming = g_value_get_boolean (value);
624 priv->status = g_value_get_uint (value);
626 case PROP_AUDIO_STREAM:
627 priv->audio = g_value_get_pointer (value);
629 case PROP_VIDEO_STREAM:
630 priv->video = g_value_get_pointer (value);
633 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
640 tp_call_get_property (GObject *object,
645 EmpathyTpCallPriv *priv = GET_PRIV (object);
649 case PROP_CONNECTION:
650 g_value_set_object (value, priv->connection);
653 g_value_set_object (value, priv->channel);
656 g_value_set_object (value, priv->contact);
658 case PROP_IS_INCOMING:
659 g_value_set_boolean (value, priv->is_incoming);
662 g_value_set_uint (value, priv->status);
664 case PROP_AUDIO_STREAM:
665 g_value_set_pointer (value, priv->audio);
667 case PROP_VIDEO_STREAM:
668 g_value_set_pointer (value, priv->video);
671 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
677 empathy_tp_call_class_init (EmpathyTpCallClass *klass)
679 GObjectClass *object_class = G_OBJECT_CLASS (klass);
683 object_class->constructor = tp_call_constructor;
684 object_class->finalize = tp_call_finalize;
685 object_class->set_property = tp_call_set_property;
686 object_class->get_property = tp_call_get_property;
688 g_type_class_add_private (klass, sizeof (EmpathyTpCallPriv));
690 signals[STATUS_CHANGED_SIGNAL] =
691 g_signal_new ("status-changed", G_TYPE_FROM_CLASS (klass),
692 G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
694 signals[RECEIVING_VIDEO_SIGNAL] =
695 g_signal_new ("receiving-video", G_TYPE_FROM_CLASS (klass),
696 G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
697 G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
698 signals[SENDING_VIDEO_SIGNAL] =
699 g_signal_new ("sending-video", G_TYPE_FROM_CLASS (klass),
700 G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
701 G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
703 g_object_class_install_property (object_class, PROP_CONNECTION,
704 g_param_spec_object ("connection", "connection", "connection",
706 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
707 G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
708 g_object_class_install_property (object_class, PROP_CHANNEL,
709 g_param_spec_object ("channel", "channel", "channel",
711 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
712 G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
713 g_object_class_install_property (object_class, PROP_CONTACT,
714 g_param_spec_object ("contact", "Call contact", "Call contact",
715 EMPATHY_TYPE_CONTACT,
716 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
717 g_object_class_install_property (object_class, PROP_IS_INCOMING,
718 g_param_spec_boolean ("is-incoming", "Is media stream incoming",
719 "Is media stream incoming", FALSE, G_PARAM_READABLE |
720 G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
721 g_object_class_install_property (object_class, PROP_STATUS,
722 g_param_spec_uint ("status", "Call status",
723 "Call status", 0, 255, 0, G_PARAM_READABLE | G_PARAM_STATIC_NICK |
724 G_PARAM_STATIC_BLURB));
725 g_object_class_install_property (object_class, PROP_AUDIO_STREAM,
726 g_param_spec_pointer ("audio-stream", "Audio stream data",
728 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
729 g_object_class_install_property (object_class, PROP_VIDEO_STREAM,
730 g_param_spec_pointer ("video-stream", "Video stream data",
732 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
736 empathy_tp_call_init (EmpathyTpCall *call)
738 EmpathyTpCallPriv *priv = GET_PRIV (call);
740 priv->status = EMPATHY_TP_CALL_STATUS_READYING;
741 priv->contact = NULL;
742 priv->audio = g_slice_new0 (EmpathyTpCallStream);
743 priv->video = g_slice_new0 (EmpathyTpCallStream);
744 priv->audio->exists = FALSE;
745 priv->video->exists = FALSE;
749 empathy_tp_call_new (TpConn *connection, TpChan *channel)
751 return g_object_new (EMPATHY_TYPE_TP_CALL,
752 "connection", connection,
758 empathy_tp_call_accept_incoming_call (EmpathyTpCall *call)
760 EmpathyTpCallPriv *priv = GET_PRIV (call);
761 GList *local_pendings;
763 empathy_debug (DEBUG_DOMAIN, "Accepting incoming call");
765 local_pendings = empathy_tp_group_get_local_pendings (priv->group);
767 empathy_tp_group_add_member (priv->group, EMPATHY_CONTACT
768 (((EmpathyPendingInfo *) local_pendings->data)->member), NULL);
770 g_list_foreach (local_pendings, (GFunc) empathy_pending_info_free, NULL);
771 g_list_free (local_pendings);
775 empathy_tp_call_request_video_stream_direction (EmpathyTpCall *call,
778 EmpathyTpCallPriv *priv = GET_PRIV (call);
779 DBusGProxy *streamed_iface;
781 GError *error = NULL;
783 empathy_debug (DEBUG_DOMAIN,
784 "Requesting video stream direction - is_sending: %d", is_sending);
786 if (!priv->video->exists)
788 tp_call_request_streams_for_capabilities (call, EMPATHY_CAPABILITIES_VIDEO);
792 streamed_iface = tp_chan_get_interface (priv->channel,
793 TELEPATHY_CHAN_IFACE_STREAMED_QUARK);
797 new_direction = priv->video->direction | TP_MEDIA_STREAM_DIRECTION_SEND;
801 new_direction = priv->video->direction & ~TP_MEDIA_STREAM_DIRECTION_SEND;
804 if (!tp_chan_type_streamed_media_request_stream_direction (streamed_iface,
805 priv->video->id, new_direction, &error))
807 empathy_debug (DEBUG_DOMAIN,
808 "Couldn't request video stream direction: %s", error->message);
809 g_clear_error (&error);
814 empathy_tp_call_close_channel (EmpathyTpCall *call)
816 EmpathyTpCallPriv *priv = GET_PRIV (call);
817 GError *error = NULL;
819 empathy_debug (DEBUG_DOMAIN, "Closing channel");
821 if (!tp_chan_close (DBUS_G_PROXY (priv->channel), &error))
823 empathy_debug (DEBUG_DOMAIN, "Error closing channel: %s",
824 error ? error->message : "No error given");
825 g_clear_error (&error);
830 empathy_tp_call_add_preview_video (EmpathyTpCall *call,
831 guint preview_video_socket_id)
833 EmpathyTpCallPriv *priv = GET_PRIV (call);
835 empathy_debug (DEBUG_DOMAIN, "Adding preview video");
837 emp_cli_stream_engine_call_add_preview_window (priv->stream_engine, -1,
838 preview_video_socket_id,
840 "adding preview window", NULL,
845 empathy_tp_call_remove_preview_video (EmpathyTpCall *call,
846 guint preview_video_socket_id)
848 EmpathyTpCallPriv *priv = GET_PRIV (call);
850 empathy_debug (DEBUG_DOMAIN, "Removing preview video");
852 emp_cli_stream_engine_call_remove_preview_window (priv->stream_engine, -1,
853 preview_video_socket_id,
855 "removing preview window", NULL,
860 empathy_tp_call_add_output_video (EmpathyTpCall *call,
861 guint output_video_socket_id)
863 EmpathyTpCallPriv *priv = GET_PRIV (call);
865 empathy_debug (DEBUG_DOMAIN, "Adding output video - socket: %d",
866 output_video_socket_id);
868 emp_cli_stream_engine_call_set_output_window (priv->stream_engine, -1,
869 dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel)),
870 priv->video->id, output_video_socket_id,
872 "setting output window", NULL,
877 empathy_tp_call_set_output_volume (EmpathyTpCall *call,
880 EmpathyTpCallPriv *priv = GET_PRIV (call);
882 if (priv->status == EMPATHY_TP_CALL_STATUS_CLOSED)
885 empathy_debug (DEBUG_DOMAIN, "Setting output volume: %d", volume);
887 emp_cli_stream_engine_call_set_output_volume (priv->stream_engine, -1,
888 dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel)),
889 priv->audio->id, volume,
891 "setting output volume", NULL,
896 empathy_tp_call_mute_output (EmpathyTpCall *call,
899 EmpathyTpCallPriv *priv = GET_PRIV (call);
901 if (priv->status == EMPATHY_TP_CALL_STATUS_CLOSED)
904 empathy_debug (DEBUG_DOMAIN, "Setting output mute: %d", is_muted);
906 emp_cli_stream_engine_call_mute_output (priv->stream_engine, -1,
907 dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel)),
908 priv->audio->id, is_muted,
910 "muting output", NULL,
915 empathy_tp_call_mute_input (EmpathyTpCall *call,
918 EmpathyTpCallPriv *priv = GET_PRIV (call);
920 if (priv->status == EMPATHY_TP_CALL_STATUS_CLOSED)
923 empathy_debug (DEBUG_DOMAIN, "Setting input mute: %d", is_muted);
925 emp_cli_stream_engine_call_mute_input (priv->stream_engine, -1,
926 dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel)),
927 priv->audio->id, is_muted,
929 "muting input", NULL,