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>
28 #include <libmissioncontrol/mc-account.h>
30 #include <libempathy/empathy-contact-factory.h>
31 #include <libempathy/empathy-debug.h>
32 #include <libempathy/empathy-tp-group.h>
33 #include <libempathy/empathy-utils.h>
35 #include "tp-stream-engine-gen.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"
46 #define STREAM_ENGINE_INTERFACE "org.freedesktop.Telepathy.StreamEngine"
47 #define CHANNEL_HANDLER_INTERFACE "org.freedesktop.Telepathy.ChannelHandler"
49 typedef struct _EmpathyTpCallPriv EmpathyTpCallPriv;
51 struct _EmpathyTpCallPriv
55 EmpathyTpGroup *group;
56 EmpathyContact *contact;
60 EmpathyTpCallStream *audio;
61 EmpathyTpCallStream *video;
66 STATUS_CHANGED_SIGNAL,
67 RECEIVING_VIDEO_SIGNAL,
84 static guint signals[LAST_SIGNAL];
86 G_DEFINE_TYPE (EmpathyTpCall, empathy_tp_call, G_TYPE_OBJECT)
89 tp_call_stream_state_changed_cb (DBusGProxy *channel,
94 EmpathyTpCallPriv *priv = GET_PRIV (call);
96 empathy_debug (DEBUG_DOMAIN,
97 "Stream state changed - stream id: %d, state state: %d",
98 stream_id, stream_state);
100 if (stream_id == priv->audio->id)
102 priv->audio->state = stream_state;
104 else if (stream_id == priv->video->id)
106 priv->video->state = stream_state;
109 g_signal_emit_by_name (call, "status-changed");
113 tp_call_identify_streams (EmpathyTpCall *call)
115 EmpathyTpCallPriv *priv = GET_PRIV (call);
116 GPtrArray *stream_infos;
117 DBusGProxy *streamed_iface;
118 GError *error = NULL;
121 empathy_debug (DEBUG_DOMAIN, "Identifying audio/video streams");
123 streamed_iface = tp_chan_get_interface (priv->channel,
124 TELEPATHY_CHAN_IFACE_STREAMED_QUARK);
126 if (!tp_chan_type_streamed_media_list_streams (streamed_iface, &stream_infos,
129 empathy_debug (DEBUG_DOMAIN, "Couldn't list audio/video streams: %s",
131 g_clear_error (&error);
135 for (i = 0; i < stream_infos->len; i++)
142 guint stream_direction;
144 values = g_ptr_array_index (stream_infos, i);
145 stream_id = g_value_get_uint (g_value_array_get_nth (values, 0));
146 stream_handle = g_value_get_uint (g_value_array_get_nth (values, 1));
147 stream_type = g_value_get_uint (g_value_array_get_nth (values, 2));
148 stream_state = g_value_get_uint (g_value_array_get_nth (values, 3));
149 stream_direction = g_value_get_uint (g_value_array_get_nth (values, 4));
153 case TP_MEDIA_STREAM_TYPE_AUDIO:
154 empathy_debug (DEBUG_DOMAIN,
155 "Audio stream - id: %d, state: %d, direction: %d",
156 stream_id, stream_state, stream_direction);
157 priv->audio->exists = TRUE;
158 priv->audio->id = stream_id;
159 priv->audio->state = stream_state;
160 priv->audio->direction = stream_direction;
162 case TP_MEDIA_STREAM_TYPE_VIDEO:
163 empathy_debug (DEBUG_DOMAIN,
164 "Video stream - id: %d, state: %d, direction: %d",
165 stream_id, stream_state, stream_direction);
166 priv->video->exists = TRUE;
167 priv->video->id = stream_id;
168 priv->video->state = stream_state;
169 priv->video->direction = stream_direction;
172 empathy_debug (DEBUG_DOMAIN, "Unknown stream type: %d",
176 g_value_array_free (values);
181 tp_call_stream_added_cb (DBusGProxy *channel,
183 guint contact_handle,
187 empathy_debug (DEBUG_DOMAIN,
188 "Stream added - stream id: %d, contact handle: %d, stream type: %d",
189 stream_id, contact_handle, stream_type);
191 tp_call_identify_streams (call);
196 tp_call_stream_removed_cb (DBusGProxy *channel,
200 EmpathyTpCallPriv *priv = GET_PRIV (call);
202 empathy_debug (DEBUG_DOMAIN, "Stream removed - stream id: %d", stream_id);
204 if (stream_id == priv->audio->id)
206 priv->audio->exists = FALSE;
208 else if (stream_id == priv->video->id)
210 priv->video->exists = FALSE;
215 tp_call_channel_closed_cb (TpChan *channel,
218 EmpathyTpCallPriv *priv = GET_PRIV (call);
219 DBusGProxy *streamed_iface;
220 DBusGProxy *group_iface;
222 empathy_debug (DEBUG_DOMAIN, "Channel closed");
224 priv->status = EMPATHY_TP_CALL_STATUS_CLOSED;
225 g_signal_emit_by_name (call, "status-changed");
227 streamed_iface = tp_chan_get_interface (priv->channel,
228 TELEPATHY_CHAN_IFACE_STREAMED_QUARK);
229 group_iface = tp_chan_get_interface (priv->channel,
230 TELEPATHY_CHAN_IFACE_GROUP_QUARK);
232 dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (priv->channel), "Closed",
233 G_CALLBACK (tp_call_channel_closed_cb), (gpointer) call);
234 dbus_g_proxy_disconnect_signal (streamed_iface, "StreamStateChanged",
235 G_CALLBACK (tp_call_stream_state_changed_cb), (gpointer) call);
236 dbus_g_proxy_disconnect_signal (streamed_iface, "StreamAdded",
237 G_CALLBACK (tp_call_stream_added_cb), (gpointer) call);
238 dbus_g_proxy_disconnect_signal (streamed_iface, "StreamRemoved",
239 G_CALLBACK (tp_call_stream_removed_cb), (gpointer) call);
243 tp_call_stream_direction_changed_cb (DBusGProxy *channel,
245 guint stream_direction,
249 EmpathyTpCallPriv *priv = GET_PRIV (call);
251 empathy_debug (DEBUG_DOMAIN,
252 "Stream direction changed - stream: %d, direction: %d",
253 stream_id, stream_direction);
255 if (stream_id == priv->audio->id)
257 priv->audio->direction = stream_direction;
259 else if (stream_id == priv->video->id)
261 priv->video->direction = stream_direction;
263 if (stream_direction & TP_MEDIA_STREAM_DIRECTION_RECEIVE)
265 empathy_debug (DEBUG_DOMAIN, "RECEIVING");
266 g_signal_emit_by_name (call, "receiving-video", TRUE);
270 empathy_debug (DEBUG_DOMAIN, "NOT RECEIVING");
271 g_signal_emit_by_name (call, "receiving-video", FALSE);
274 if (stream_direction & TP_MEDIA_STREAM_DIRECTION_SEND)
276 empathy_debug (DEBUG_DOMAIN, "SENDING");
277 g_signal_emit_by_name (call, "sending-video", TRUE);
281 empathy_debug (DEBUG_DOMAIN, "NOT SENDING");
282 g_signal_emit_by_name (call, "sending-video", FALSE);
288 tp_call_request_streams_for_capabilities (EmpathyTpCall *call,
289 EmpathyCapabilities capabilities)
291 EmpathyTpCallPriv *priv = GET_PRIV (call);
292 DBusGProxy *streamed_iface;
293 GArray *stream_types;
296 GError *error = NULL;
298 empathy_debug (DEBUG_DOMAIN, "Requesting new stream for capabilities %d",
301 streamed_iface = tp_chan_get_interface (priv->channel,
302 TELEPATHY_CHAN_IFACE_STREAMED_QUARK);
303 stream_types = g_array_new (FALSE, FALSE, sizeof (guint));
304 handle = empathy_contact_get_handle (priv->contact);
306 if (capabilities & EMPATHY_CAPABILITIES_AUDIO)
308 stream_type = TP_MEDIA_STREAM_TYPE_AUDIO;
309 g_array_append_val (stream_types, stream_type);
311 if (capabilities & EMPATHY_CAPABILITIES_VIDEO)
313 stream_type = TP_MEDIA_STREAM_TYPE_VIDEO;
314 g_array_append_val (stream_types, stream_type);
317 if (!tp_chan_type_streamed_media_request_streams (streamed_iface, handle,
318 stream_types, NULL, &error))
320 empathy_debug (DEBUG_DOMAIN, "Couldn't request new stream: %s",
322 g_clear_error (&error);
325 g_array_free (stream_types, TRUE);
329 tp_call_request_streams_capabilities_cb (EmpathyContact *contact,
330 GParamSpec *property, gpointer user_data)
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) {
365 g_signal_connect (G_OBJECT (priv->contact), "notify::capabilities",
366 G_CALLBACK (tp_call_request_streams_capabilities_cb), call);
371 tp_call_request_streams_for_capabilities (call, capabilities);
375 tp_call_is_ready (EmpathyTpCall *call)
377 EmpathyTpCallPriv *priv = GET_PRIV (call);
378 EmpathyContact *self_contact;
380 GList *local_pendings;
381 GList *remote_pendings;
383 if (priv->status > EMPATHY_TP_CALL_STATUS_READYING)
386 members = empathy_tp_group_get_members (priv->group);
390 self_contact = empathy_tp_group_get_self_contact (priv->group);
391 local_pendings = empathy_tp_group_get_local_pendings (priv->group);
392 remote_pendings = empathy_tp_group_get_remote_pendings (priv->group);
394 if (local_pendings &&
395 empathy_contact_equal (EMPATHY_CONTACT (((EmpathyPendingInfo *)
396 local_pendings->data)->member), self_contact))
398 empathy_debug (DEBUG_DOMAIN,
399 "Incoming call is ready - %p",
400 ((EmpathyPendingInfo *) local_pendings->data)->member);
401 priv->is_incoming = TRUE;
402 priv->contact = g_object_ref (members->data);
404 else if (remote_pendings &&
405 empathy_contact_equal (EMPATHY_CONTACT (members->data), self_contact))
407 empathy_debug (DEBUG_DOMAIN,
408 "Outgoing call is ready - %p", remote_pendings->data);
409 priv->is_incoming = FALSE;
410 priv->contact = g_object_ref (remote_pendings->data);
411 tp_call_request_streams (call);
414 g_object_unref (self_contact);
415 g_list_foreach (members, (GFunc) g_object_unref, NULL);
416 g_list_free (members);
417 g_list_foreach (local_pendings, (GFunc) empathy_pending_info_free, NULL);
418 g_list_free (local_pendings);
419 g_list_foreach (remote_pendings, (GFunc) g_object_unref, NULL);
420 g_list_free (remote_pendings);
424 priv->status = EMPATHY_TP_CALL_STATUS_PENDING;
425 g_signal_emit (call, signals[STATUS_CHANGED_SIGNAL], 0);
430 tp_call_member_added_cb (EmpathyTpGroup *group,
431 EmpathyContact *contact,
432 EmpathyContact *actor,
434 const gchar *message,
437 EmpathyTpCallPriv *priv = GET_PRIV (call);
439 empathy_debug (DEBUG_DOMAIN, "New member added callback %p", contact);
440 tp_call_is_ready (call);
442 if (priv->status == EMPATHY_TP_CALL_STATUS_PENDING)
444 if ((priv->is_incoming &&
445 !empathy_contact_equal (contact, priv->contact))
446 || (!priv->is_incoming &&
447 empathy_contact_equal (contact, priv->contact)))
449 priv->status = EMPATHY_TP_CALL_STATUS_ACCEPTED;
450 g_signal_emit (call, signals[STATUS_CHANGED_SIGNAL], 0);
456 tp_call_local_pending_cb (EmpathyTpGroup *group,
457 EmpathyContact *contact,
458 EmpathyContact *actor,
460 const gchar *message,
463 empathy_debug (DEBUG_DOMAIN, "New local pending added callback %p", contact);
464 tp_call_is_ready (call);
468 tp_call_remote_pending_cb (EmpathyTpGroup *group,
469 EmpathyContact *contact,
470 EmpathyContact *actor,
472 const gchar *message,
475 empathy_debug (DEBUG_DOMAIN, "New remote pending added callback %p", contact);
476 tp_call_is_ready (call);
480 tp_call_start_stream_engine (EmpathyTpCall *call)
482 EmpathyTpCallPriv *priv = GET_PRIV (call);
483 DBusGProxy *ch_proxy;
484 GError *error = NULL;
486 empathy_debug (DEBUG_DOMAIN, "Revving up the stream engine");
488 ch_proxy = dbus_g_proxy_new_for_name (tp_get_bus (), STREAM_ENGINE_BUS_NAME,
489 STREAM_ENGINE_OBJECT_PATH, CHANNEL_HANDLER_INTERFACE);
491 if (!org_freedesktop_Telepathy_ChannelHandler_handle_channel (ch_proxy,
492 dbus_g_proxy_get_bus_name (DBUS_G_PROXY (priv->connection)),
493 dbus_g_proxy_get_path (DBUS_G_PROXY (priv->connection)),
495 dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel)),
496 priv->channel->handle_type, priv->channel->handle, &error))
498 empathy_debug (DEBUG_DOMAIN, "Couldn't start stream engine: %s",
500 g_clear_error (&error);
505 tp_call_constructor (GType type,
506 guint n_construct_params,
507 GObjectConstructParam *construct_params)
511 EmpathyTpCallPriv *priv;
512 DBusGProxy *streamed_iface;
516 object = G_OBJECT_CLASS (empathy_tp_call_parent_class)->constructor (type,
517 n_construct_params, construct_params);
519 call = EMPATHY_TP_CALL (object);
520 priv = GET_PRIV (call);
522 dbus_g_proxy_connect_signal (DBUS_G_PROXY (priv->channel), "Closed",
523 G_CALLBACK (tp_call_channel_closed_cb), (gpointer) call, NULL);
525 streamed_iface = tp_chan_get_interface (priv->channel,
526 TELEPATHY_CHAN_IFACE_STREAMED_QUARK);
527 dbus_g_proxy_connect_signal (streamed_iface, "StreamStateChanged",
528 G_CALLBACK (tp_call_stream_state_changed_cb),
529 (gpointer) call, NULL);
530 dbus_g_proxy_connect_signal (streamed_iface, "StreamDirectionChanged",
531 G_CALLBACK (tp_call_stream_direction_changed_cb),
532 (gpointer) call, NULL);
533 dbus_g_proxy_connect_signal (streamed_iface, "StreamAdded",
534 G_CALLBACK (tp_call_stream_added_cb), (gpointer) call, NULL);
535 dbus_g_proxy_connect_signal (streamed_iface, "StreamRemoved",
536 G_CALLBACK (tp_call_stream_removed_cb), (gpointer) call, NULL);
538 mc = empathy_mission_control_new ();
539 account = mission_control_get_account_for_connection (mc, priv->connection,
541 priv->group = empathy_tp_group_new (account, priv->channel);
543 g_signal_connect (G_OBJECT (priv->group), "member-added",
544 G_CALLBACK (tp_call_member_added_cb), (gpointer) call);
545 g_signal_connect (G_OBJECT (priv->group), "local-pending",
546 G_CALLBACK (tp_call_local_pending_cb), (gpointer) call);
547 g_signal_connect (G_OBJECT (priv->group), "remote-pending",
548 G_CALLBACK (tp_call_remote_pending_cb), (gpointer) call);
550 tp_call_start_stream_engine (call);
551 /* FIXME: unnecessary for outgoing? */
552 tp_call_identify_streams (call);
558 tp_call_finalize (GObject *object)
560 EmpathyTpCallPriv *priv = GET_PRIV (object);
562 empathy_debug (DEBUG_DOMAIN, "Finalizing: %p", object);
564 g_slice_free (EmpathyTpCallStream, priv->audio);
565 g_slice_free (EmpathyTpCallStream, priv->video);
566 g_object_unref (priv->group);
568 if (priv->connection != NULL)
569 g_object_unref (priv->connection);
571 if (priv->channel != NULL)
572 g_object_unref (priv->channel);
576 g_object_unref (priv->contact);
579 (G_OBJECT_CLASS (empathy_tp_call_parent_class)->finalize) (object);
583 tp_call_set_property (GObject *object,
588 EmpathyTpCallPriv *priv = GET_PRIV (object);
592 case PROP_CONNECTION:
593 priv->connection = g_value_dup_object (value);
596 priv->channel = g_value_dup_object (value);
599 /* FIXME should this one be writable in the first place ? */
600 g_assert (priv->contact == NULL);
601 priv->contact = g_value_dup_object (value);
603 case PROP_IS_INCOMING:
604 priv->is_incoming = g_value_get_boolean (value);
607 priv->status = g_value_get_uint (value);
609 case PROP_AUDIO_STREAM:
610 priv->audio = g_value_get_pointer (value);
612 case PROP_VIDEO_STREAM:
613 priv->video = g_value_get_pointer (value);
616 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
623 tp_call_get_property (GObject *object,
628 EmpathyTpCallPriv *priv = GET_PRIV (object);
632 case PROP_CONNECTION:
633 g_value_set_object (value, priv->connection);
636 g_value_set_object (value, priv->channel);
639 g_value_set_object (value, priv->contact);
641 case PROP_IS_INCOMING:
642 g_value_set_boolean (value, priv->is_incoming);
645 g_value_set_uint (value, priv->status);
647 case PROP_AUDIO_STREAM:
648 g_value_set_pointer (value, priv->audio);
650 case PROP_VIDEO_STREAM:
651 g_value_set_pointer (value, priv->video);
654 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
660 empathy_tp_call_class_init (EmpathyTpCallClass *klass)
662 GObjectClass *object_class = G_OBJECT_CLASS (klass);
664 object_class->constructor = tp_call_constructor;
665 object_class->finalize = tp_call_finalize;
666 object_class->set_property = tp_call_set_property;
667 object_class->get_property = tp_call_get_property;
669 g_type_class_add_private (klass, sizeof (EmpathyTpCallPriv));
671 signals[STATUS_CHANGED_SIGNAL] =
672 g_signal_new ("status-changed", G_TYPE_FROM_CLASS (klass),
673 G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
675 signals[RECEIVING_VIDEO_SIGNAL] =
676 g_signal_new ("receiving-video", G_TYPE_FROM_CLASS (klass),
677 G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
678 G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
679 signals[SENDING_VIDEO_SIGNAL] =
680 g_signal_new ("sending-video", G_TYPE_FROM_CLASS (klass),
681 G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
682 G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
684 g_object_class_install_property (object_class, PROP_CONNECTION,
685 g_param_spec_object ("connection", "connection", "connection",
687 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
688 G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
689 g_object_class_install_property (object_class, PROP_CHANNEL,
690 g_param_spec_object ("channel", "channel", "channel",
692 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
693 G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
694 g_object_class_install_property (object_class, PROP_CONTACT,
695 g_param_spec_object ("contact", "Call contact", "Call contact",
696 EMPATHY_TYPE_CONTACT,
697 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
698 g_object_class_install_property (object_class, PROP_IS_INCOMING,
699 g_param_spec_boolean ("is-incoming", "Is media stream incoming",
700 "Is media stream incoming", FALSE, G_PARAM_READABLE |
701 G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
702 g_object_class_install_property (object_class, PROP_STATUS,
703 g_param_spec_uint ("status", "Call status",
704 "Call status", 0, 255, 0, G_PARAM_READABLE | G_PARAM_STATIC_NICK |
705 G_PARAM_STATIC_BLURB));
706 g_object_class_install_property (object_class, PROP_AUDIO_STREAM,
707 g_param_spec_pointer ("audio-stream", "Audio stream data",
709 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
710 g_object_class_install_property (object_class, PROP_VIDEO_STREAM,
711 g_param_spec_pointer ("video-stream", "Video stream data",
713 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
717 empathy_tp_call_init (EmpathyTpCall *call)
719 EmpathyTpCallPriv *priv = GET_PRIV (call);
721 priv->status = EMPATHY_TP_CALL_STATUS_READYING;
722 priv->contact = NULL;
723 priv->audio = g_slice_new0 (EmpathyTpCallStream);
724 priv->video = g_slice_new0 (EmpathyTpCallStream);
725 priv->audio->exists = FALSE;
726 priv->video->exists = FALSE;
730 empathy_tp_call_new (TpConn *connection, TpChan *channel)
732 return g_object_new (EMPATHY_TYPE_TP_CALL,
733 "connection", connection,
739 empathy_tp_call_accept_incoming_call (EmpathyTpCall *call)
741 EmpathyTpCallPriv *priv = GET_PRIV (call);
742 GList *local_pendings;
744 empathy_debug (DEBUG_DOMAIN, "Accepting incoming call");
746 local_pendings = empathy_tp_group_get_local_pendings (priv->group);
748 empathy_tp_group_add_member (priv->group, EMPATHY_CONTACT
749 (((EmpathyPendingInfo *) local_pendings->data)->member), NULL);
751 g_list_foreach (local_pendings, (GFunc) empathy_pending_info_free, NULL);
752 g_list_free (local_pendings);
756 empathy_tp_call_request_video_stream_direction (EmpathyTpCall *call,
759 EmpathyTpCallPriv *priv = GET_PRIV (call);
760 DBusGProxy *streamed_iface;
762 GError *error = NULL;
764 empathy_debug (DEBUG_DOMAIN,
765 "Requesting video stream direction - is_sending: %d", is_sending);
767 if (!priv->video->exists)
769 tp_call_request_streams_for_capabilities (call, EMPATHY_CAPABILITIES_VIDEO);
773 streamed_iface = tp_chan_get_interface (priv->channel,
774 TELEPATHY_CHAN_IFACE_STREAMED_QUARK);
778 new_direction = priv->video->direction | TP_MEDIA_STREAM_DIRECTION_SEND;
782 new_direction = priv->video->direction & ~TP_MEDIA_STREAM_DIRECTION_SEND;
785 if (!tp_chan_type_streamed_media_request_stream_direction (streamed_iface,
786 priv->video->id, new_direction, &error))
788 empathy_debug (DEBUG_DOMAIN,
789 "Couldn't request video stream direction: %s", error->message);
790 g_clear_error (&error);
795 empathy_tp_call_close_channel (EmpathyTpCall *call)
797 EmpathyTpCallPriv *priv = GET_PRIV (call);
798 GError *error = NULL;
800 empathy_debug (DEBUG_DOMAIN, "Closing channel");
802 if (!tp_chan_close (DBUS_G_PROXY (priv->channel), &error))
804 empathy_debug (DEBUG_DOMAIN, "Error closing channel: %s",
805 error ? error->message : "No error given");
806 g_clear_error (&error);
811 empathy_tp_call_add_preview_video (guint preview_video_socket_id)
813 GError *error = NULL;
814 DBusGProxy *ch_proxy;
816 empathy_debug (DEBUG_DOMAIN, "Adding preview video");
818 ch_proxy = dbus_g_proxy_new_for_name (tp_get_bus (), STREAM_ENGINE_BUS_NAME,
819 STREAM_ENGINE_OBJECT_PATH, STREAM_ENGINE_INTERFACE);
821 if (!org_freedesktop_Telepathy_StreamEngine_add_preview_window (ch_proxy,
822 preview_video_socket_id, &error))
824 empathy_debug (DEBUG_DOMAIN, "Couldn't set video preview: %s",
826 g_clear_error (&error);
831 empathy_tp_call_remove_preview_video (guint preview_video_socket_id)
833 GError *error = NULL;
834 DBusGProxy *ch_proxy;
836 empathy_debug (DEBUG_DOMAIN, "Removing preview video");
838 ch_proxy = dbus_g_proxy_new_for_name (tp_get_bus (), STREAM_ENGINE_BUS_NAME,
839 STREAM_ENGINE_OBJECT_PATH, STREAM_ENGINE_INTERFACE);
841 if (!org_freedesktop_Telepathy_StreamEngine_remove_preview_window (ch_proxy,
842 preview_video_socket_id, &error))
844 empathy_debug (DEBUG_DOMAIN, "Couldn't set video preview: %s",
846 g_clear_error (&error);
851 empathy_tp_call_add_output_video (EmpathyTpCall *call,
852 guint output_video_socket_id)
854 EmpathyTpCallPriv *priv = GET_PRIV (call);
855 const gchar *object_path;
856 DBusGProxy *ch_proxy;
857 GError *error = NULL;
859 empathy_debug (DEBUG_DOMAIN, "Adding output video - socket: %d",
860 output_video_socket_id);
862 object_path = dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel));
863 ch_proxy = dbus_g_proxy_new_for_name (tp_get_bus (), STREAM_ENGINE_BUS_NAME,
864 STREAM_ENGINE_OBJECT_PATH, STREAM_ENGINE_INTERFACE);
866 if (!org_freedesktop_Telepathy_StreamEngine_set_output_window (ch_proxy,
867 object_path, priv->video->id, output_video_socket_id, &error))
869 empathy_debug (DEBUG_DOMAIN, "Couldn't set video output: %s",
871 g_clear_error (&error);
876 empathy_tp_call_set_output_volume (EmpathyTpCall *call,
879 EmpathyTpCallPriv *priv = GET_PRIV (call);
880 const gchar *object_path;
881 DBusGProxy *ch_proxy;
882 GError *error = NULL;
884 if (priv->status == EMPATHY_TP_CALL_STATUS_CLOSED)
887 empathy_debug (DEBUG_DOMAIN, "Setting output volume: %d", volume);
889 object_path = dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel));
890 ch_proxy = dbus_g_proxy_new_for_name (tp_get_bus (), STREAM_ENGINE_BUS_NAME,
891 STREAM_ENGINE_OBJECT_PATH, STREAM_ENGINE_INTERFACE);
893 if (!org_freedesktop_Telepathy_StreamEngine_set_output_volume (ch_proxy,
894 object_path, priv->audio->id, volume, &error))
896 empathy_debug (DEBUG_DOMAIN, "Couldn't set volume: %s", error->message);
897 g_clear_error (&error);
903 empathy_tp_call_mute_output (EmpathyTpCall *call,
906 EmpathyTpCallPriv *priv = GET_PRIV (call);
907 const gchar *object_path;
908 DBusGProxy *ch_proxy;
909 GError *error = NULL;
911 if (priv->status == EMPATHY_TP_CALL_STATUS_CLOSED)
914 empathy_debug (DEBUG_DOMAIN, "Setting output mute: %d", is_muted);
916 object_path = dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel));
917 ch_proxy = dbus_g_proxy_new_for_name (tp_get_bus (), STREAM_ENGINE_BUS_NAME,
918 STREAM_ENGINE_OBJECT_PATH, STREAM_ENGINE_INTERFACE);
920 if (!org_freedesktop_Telepathy_StreamEngine_mute_output (ch_proxy,
921 object_path, priv->audio->id, is_muted, &error))
923 empathy_debug (DEBUG_DOMAIN, "Couldn't mute output: %s", error->message);
924 g_clear_error (&error);
929 empathy_tp_call_mute_input (EmpathyTpCall *call,
932 EmpathyTpCallPriv *priv = GET_PRIV (call);
933 const gchar *object_path;
934 DBusGProxy *ch_proxy;
935 GError *error = NULL;
937 if (priv->status == EMPATHY_TP_CALL_STATUS_CLOSED)
940 empathy_debug (DEBUG_DOMAIN, "Setting input mute: %d", is_muted);
942 object_path = dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel));
943 ch_proxy = dbus_g_proxy_new_for_name (tp_get_bus (), STREAM_ENGINE_BUS_NAME,
944 STREAM_ENGINE_OBJECT_PATH, STREAM_ENGINE_INTERFACE);
946 if (!org_freedesktop_Telepathy_StreamEngine_mute_input (ch_proxy,
947 object_path, priv->audio->id, is_muted, &error))
949 empathy_debug (DEBUG_DOMAIN, "Couldn't mute input: %s", error->message);
950 g_clear_error (&error);