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);
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 (EmpathyTpCall *call)
330 EmpathyTpCallPriv *priv = GET_PRIV (call);
331 EmpathyCapabilities capabilities;
332 DBusGProxy *capabilities_iface;
334 empathy_debug (DEBUG_DOMAIN,
335 "Requesting appropriate audio/video streams from contact");
337 capabilities = empathy_contact_get_capabilities (priv->contact);
339 /* FIXME: SIP don't have capabilities interface but we know it supports
340 * only audio and not video. */
341 capabilities_iface = tp_conn_get_interface (priv->connection,
342 TP_IFACE_QUARK_CONNECTION_INTERFACE_CAPABILITIES);
343 if (!capabilities_iface)
345 capabilities = EMPATHY_CAPABILITIES_AUDIO;
348 tp_call_request_streams_for_capabilities (call, capabilities);
352 tp_call_is_ready (EmpathyTpCall *call)
354 EmpathyTpCallPriv *priv = GET_PRIV (call);
355 EmpathyContact *self_contact;
357 GList *local_pendings;
358 GList *remote_pendings;
360 if (priv->status > EMPATHY_TP_CALL_STATUS_READYING)
363 members = empathy_tp_group_get_members (priv->group);
367 self_contact = empathy_tp_group_get_self_contact (priv->group);
368 local_pendings = empathy_tp_group_get_local_pendings (priv->group);
369 remote_pendings = empathy_tp_group_get_remote_pendings (priv->group);
371 if (local_pendings &&
372 empathy_contact_equal (EMPATHY_CONTACT (((EmpathyPendingInfo *)
373 local_pendings->data)->member), self_contact))
375 empathy_debug (DEBUG_DOMAIN,
376 "Incoming call is ready - %p",
377 ((EmpathyPendingInfo *) local_pendings->data)->member);
378 priv->is_incoming = TRUE;
379 priv->contact = g_object_ref (members->data);
381 else if (remote_pendings &&
382 empathy_contact_equal (EMPATHY_CONTACT (members->data), self_contact))
384 empathy_debug (DEBUG_DOMAIN,
385 "Outgoing call is ready - %p", remote_pendings->data);
386 priv->is_incoming = FALSE;
387 priv->contact = g_object_ref (remote_pendings->data);
388 tp_call_request_streams (call);
391 g_object_unref (self_contact);
392 g_list_foreach (members, (GFunc) g_object_unref, NULL);
393 g_list_free (members);
394 g_list_foreach (local_pendings, (GFunc) empathy_pending_info_free, NULL);
395 g_list_free (local_pendings);
396 g_list_foreach (remote_pendings, (GFunc) g_object_unref, NULL);
397 g_list_free (remote_pendings);
401 priv->status = EMPATHY_TP_CALL_STATUS_PENDING;
402 g_signal_emit (call, signals[STATUS_CHANGED_SIGNAL], 0);
407 tp_call_member_added_cb (EmpathyTpGroup *group,
408 EmpathyContact *contact,
409 EmpathyContact *actor,
411 const gchar *message,
414 EmpathyTpCallPriv *priv = GET_PRIV (call);
416 empathy_debug (DEBUG_DOMAIN, "New member added callback %p", contact);
417 tp_call_is_ready (call);
419 if (priv->status == EMPATHY_TP_CALL_STATUS_PENDING)
421 if ((priv->is_incoming &&
422 !empathy_contact_equal (contact, priv->contact))
423 || (!priv->is_incoming &&
424 empathy_contact_equal (contact, priv->contact)))
426 priv->status = EMPATHY_TP_CALL_STATUS_ACCEPTED;
427 g_signal_emit (call, signals[STATUS_CHANGED_SIGNAL], 0);
433 tp_call_local_pending_cb (EmpathyTpGroup *group,
434 EmpathyContact *contact,
435 EmpathyContact *actor,
437 const gchar *message,
440 empathy_debug (DEBUG_DOMAIN, "New local pending added callback %p", contact);
441 tp_call_is_ready (call);
445 tp_call_remote_pending_cb (EmpathyTpGroup *group,
446 EmpathyContact *contact,
447 EmpathyContact *actor,
449 const gchar *message,
452 empathy_debug (DEBUG_DOMAIN, "New remote pending added callback %p", contact);
453 tp_call_is_ready (call);
457 tp_call_start_stream_engine (EmpathyTpCall *call)
459 EmpathyTpCallPriv *priv = GET_PRIV (call);
460 DBusGProxy *ch_proxy;
461 GError *error = NULL;
463 empathy_debug (DEBUG_DOMAIN, "Revving up the stream engine");
465 ch_proxy = dbus_g_proxy_new_for_name (tp_get_bus (), STREAM_ENGINE_BUS_NAME,
466 STREAM_ENGINE_OBJECT_PATH, CHANNEL_HANDLER_INTERFACE);
468 if (!org_freedesktop_Telepathy_ChannelHandler_handle_channel (ch_proxy,
469 dbus_g_proxy_get_bus_name (DBUS_G_PROXY (priv->connection)),
470 dbus_g_proxy_get_path (DBUS_G_PROXY (priv->connection)),
472 dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel)),
473 priv->channel->handle_type, priv->channel->handle, &error))
475 empathy_debug (DEBUG_DOMAIN, "Couldn't start stream engine: %s",
477 g_clear_error (&error);
482 tp_call_constructor (GType type,
483 guint n_construct_params,
484 GObjectConstructParam *construct_params)
488 EmpathyTpCallPriv *priv;
489 DBusGProxy *streamed_iface;
493 object = G_OBJECT_CLASS (empathy_tp_call_parent_class)->constructor (type,
494 n_construct_params, construct_params);
496 call = EMPATHY_TP_CALL (object);
497 priv = GET_PRIV (call);
499 dbus_g_proxy_connect_signal (DBUS_G_PROXY (priv->channel), "Closed",
500 G_CALLBACK (tp_call_channel_closed_cb), (gpointer) call, NULL);
502 streamed_iface = tp_chan_get_interface (priv->channel,
503 TELEPATHY_CHAN_IFACE_STREAMED_QUARK);
504 dbus_g_proxy_connect_signal (streamed_iface, "StreamStateChanged",
505 G_CALLBACK (tp_call_stream_state_changed_cb),
506 (gpointer) call, NULL);
507 dbus_g_proxy_connect_signal (streamed_iface, "StreamDirectionChanged",
508 G_CALLBACK (tp_call_stream_direction_changed_cb),
509 (gpointer) call, NULL);
510 dbus_g_proxy_connect_signal (streamed_iface, "StreamAdded",
511 G_CALLBACK (tp_call_stream_added_cb), (gpointer) call, NULL);
512 dbus_g_proxy_connect_signal (streamed_iface, "StreamRemoved",
513 G_CALLBACK (tp_call_stream_removed_cb), (gpointer) call, NULL);
515 mc = empathy_mission_control_new ();
516 account = mission_control_get_account_for_connection (mc, priv->connection,
518 priv->group = empathy_tp_group_new (account, priv->channel);
520 g_signal_connect (G_OBJECT (priv->group), "member-added",
521 G_CALLBACK (tp_call_member_added_cb), (gpointer) call);
522 g_signal_connect (G_OBJECT (priv->group), "local-pending",
523 G_CALLBACK (tp_call_local_pending_cb), (gpointer) call);
524 g_signal_connect (G_OBJECT (priv->group), "remote-pending",
525 G_CALLBACK (tp_call_remote_pending_cb), (gpointer) call);
527 tp_call_start_stream_engine (call);
528 /* FIXME: unnecessary for outgoing? */
529 tp_call_identify_streams (call);
535 tp_call_finalize (GObject *object)
537 EmpathyTpCallPriv *priv = GET_PRIV (object);
539 empathy_debug (DEBUG_DOMAIN, "Finalizing: %p", object);
541 g_slice_free (EmpathyTpCallStream, priv->audio);
542 g_slice_free (EmpathyTpCallStream, priv->video);
543 g_object_unref (priv->group);
546 g_object_unref (priv->contact);
549 (G_OBJECT_CLASS (empathy_tp_call_parent_class)->finalize) (object);
553 tp_call_set_property (GObject *object,
558 EmpathyTpCallPriv *priv = GET_PRIV (object);
562 case PROP_CONNECTION:
563 priv->connection = g_value_get_object (value);
566 priv->channel = g_value_get_object (value);
569 priv->contact = g_value_get_object (value);
571 case PROP_IS_INCOMING:
572 priv->is_incoming = g_value_get_boolean (value);
575 priv->status = g_value_get_uint (value);
577 case PROP_AUDIO_STREAM:
578 priv->audio = g_value_get_pointer (value);
580 case PROP_VIDEO_STREAM:
581 priv->video = g_value_get_pointer (value);
584 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
591 tp_call_get_property (GObject *object,
596 EmpathyTpCallPriv *priv = GET_PRIV (object);
600 case PROP_CONNECTION:
601 g_value_set_object (value, priv->connection);
604 g_value_set_object (value, priv->channel);
607 g_value_set_object (value, priv->contact);
609 case PROP_IS_INCOMING:
610 g_value_set_boolean (value, priv->is_incoming);
613 g_value_set_uint (value, priv->status);
615 case PROP_AUDIO_STREAM:
616 g_value_set_pointer (value, priv->audio);
618 case PROP_VIDEO_STREAM:
619 g_value_set_pointer (value, priv->video);
622 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
628 empathy_tp_call_class_init (EmpathyTpCallClass *klass)
630 GObjectClass *object_class = G_OBJECT_CLASS (klass);
632 object_class->constructor = tp_call_constructor;
633 object_class->finalize = tp_call_finalize;
634 object_class->set_property = tp_call_set_property;
635 object_class->get_property = tp_call_get_property;
637 g_type_class_add_private (klass, sizeof (EmpathyTpCallPriv));
639 signals[STATUS_CHANGED_SIGNAL] =
640 g_signal_new ("status-changed", G_TYPE_FROM_CLASS (klass),
641 G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
643 signals[RECEIVING_VIDEO_SIGNAL] =
644 g_signal_new ("receiving-video", G_TYPE_FROM_CLASS (klass),
645 G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
646 G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
647 signals[SENDING_VIDEO_SIGNAL] =
648 g_signal_new ("sending-video", G_TYPE_FROM_CLASS (klass),
649 G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
650 G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
652 g_object_class_install_property (object_class, PROP_CONNECTION,
653 g_param_spec_object ("connection", "connection", "connection",
655 G_PARAM_CONSTRUCT | G_PARAM_READWRITE |
656 G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
657 g_object_class_install_property (object_class, PROP_CHANNEL,
658 g_param_spec_object ("channel", "channel", "channel",
660 G_PARAM_CONSTRUCT | G_PARAM_READWRITE |
661 G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
662 g_object_class_install_property (object_class, PROP_CONTACT,
663 g_param_spec_object ("contact", "Call contact", "Call contact",
664 EMPATHY_TYPE_CONTACT,
665 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
666 g_object_class_install_property (object_class, PROP_IS_INCOMING,
667 g_param_spec_boolean ("is-incoming", "Is media stream incoming",
668 "Is media stream incoming", FALSE, G_PARAM_READABLE |
669 G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
670 g_object_class_install_property (object_class, PROP_STATUS,
671 g_param_spec_uint ("status", "Call status",
672 "Call status", 0, 255, 0, G_PARAM_READABLE | G_PARAM_STATIC_NICK |
673 G_PARAM_STATIC_BLURB));
674 g_object_class_install_property (object_class, PROP_AUDIO_STREAM,
675 g_param_spec_pointer ("audio-stream", "Audio stream data",
677 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
678 g_object_class_install_property (object_class, PROP_VIDEO_STREAM,
679 g_param_spec_pointer ("video-stream", "Video stream data",
681 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
685 empathy_tp_call_init (EmpathyTpCall *call)
687 EmpathyTpCallPriv *priv = GET_PRIV (call);
689 priv->status = EMPATHY_TP_CALL_STATUS_READYING;
690 priv->contact = NULL;
691 priv->audio = g_slice_new0 (EmpathyTpCallStream);
692 priv->video = g_slice_new0 (EmpathyTpCallStream);
693 priv->audio->exists = FALSE;
694 priv->video->exists = FALSE;
698 empathy_tp_call_new (TpConn *connection, TpChan *channel)
700 return g_object_new (EMPATHY_TYPE_TP_CALL,
701 "connection", connection,
707 empathy_tp_call_accept_incoming_call (EmpathyTpCall *call)
709 EmpathyTpCallPriv *priv = GET_PRIV (call);
710 GList *local_pendings;
712 empathy_debug (DEBUG_DOMAIN, "Accepting incoming call");
714 local_pendings = empathy_tp_group_get_local_pendings (priv->group);
716 empathy_tp_group_add_member (priv->group, EMPATHY_CONTACT
717 (((EmpathyPendingInfo *) local_pendings->data)->member), NULL);
719 g_list_foreach (local_pendings, (GFunc) empathy_pending_info_free, NULL);
720 g_list_free (local_pendings);
724 empathy_tp_call_request_video_stream_direction (EmpathyTpCall *call,
727 EmpathyTpCallPriv *priv = GET_PRIV (call);
728 DBusGProxy *streamed_iface;
730 GError *error = NULL;
732 empathy_debug (DEBUG_DOMAIN,
733 "Requesting video stream direction - is_sending: %d", is_sending);
735 if (!priv->video->exists)
737 tp_call_request_streams_for_capabilities (call, EMPATHY_CAPABILITIES_VIDEO);
741 streamed_iface = tp_chan_get_interface (priv->channel,
742 TELEPATHY_CHAN_IFACE_STREAMED_QUARK);
746 new_direction = priv->video->direction | TP_MEDIA_STREAM_DIRECTION_SEND;
750 new_direction = priv->video->direction & ~TP_MEDIA_STREAM_DIRECTION_SEND;
753 if (!tp_chan_type_streamed_media_request_stream_direction (streamed_iface,
754 priv->video->id, new_direction, &error))
756 empathy_debug (DEBUG_DOMAIN,
757 "Couldn't request video stream direction: %s", error->message);
758 g_clear_error (&error);
763 empathy_tp_call_close_channel (EmpathyTpCall *call)
765 EmpathyTpCallPriv *priv = GET_PRIV (call);
766 GError *error = NULL;
768 empathy_debug (DEBUG_DOMAIN, "Closing channel");
770 if (!tp_chan_close (DBUS_G_PROXY (priv->channel), &error))
772 empathy_debug (DEBUG_DOMAIN, "Error closing channel: %s",
773 error ? error->message : "No error given");
774 g_clear_error (&error);
779 empathy_tp_call_add_preview_video (guint preview_video_socket_id)
781 GError *error = NULL;
782 DBusGProxy *ch_proxy;
784 empathy_debug (DEBUG_DOMAIN, "Adding preview video");
786 ch_proxy = dbus_g_proxy_new_for_name (tp_get_bus (), STREAM_ENGINE_BUS_NAME,
787 STREAM_ENGINE_OBJECT_PATH, STREAM_ENGINE_INTERFACE);
789 if (!org_freedesktop_Telepathy_StreamEngine_add_preview_window (ch_proxy,
790 preview_video_socket_id, &error))
792 empathy_debug (DEBUG_DOMAIN, "Couldn't set video preview: %s",
794 g_clear_error (&error);
799 empathy_tp_call_remove_preview_video (guint preview_video_socket_id)
801 GError *error = NULL;
802 DBusGProxy *ch_proxy;
804 empathy_debug (DEBUG_DOMAIN, "Removing preview video");
806 ch_proxy = dbus_g_proxy_new_for_name (tp_get_bus (), STREAM_ENGINE_BUS_NAME,
807 STREAM_ENGINE_OBJECT_PATH, STREAM_ENGINE_INTERFACE);
809 if (!org_freedesktop_Telepathy_StreamEngine_remove_preview_window (ch_proxy,
810 preview_video_socket_id, &error))
812 empathy_debug (DEBUG_DOMAIN, "Couldn't set video preview: %s",
814 g_clear_error (&error);
819 empathy_tp_call_add_output_video (EmpathyTpCall *call,
820 guint output_video_socket_id)
822 EmpathyTpCallPriv *priv = GET_PRIV (call);
823 const gchar *object_path;
824 DBusGProxy *ch_proxy;
825 GError *error = NULL;
827 empathy_debug (DEBUG_DOMAIN, "Adding output video - socket: %d",
828 output_video_socket_id);
830 object_path = dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel));
831 ch_proxy = dbus_g_proxy_new_for_name (tp_get_bus (), STREAM_ENGINE_BUS_NAME,
832 STREAM_ENGINE_OBJECT_PATH, STREAM_ENGINE_INTERFACE);
834 if (!org_freedesktop_Telepathy_StreamEngine_set_output_window (ch_proxy,
835 object_path, priv->video->id, output_video_socket_id, &error))
837 empathy_debug (DEBUG_DOMAIN, "Couldn't set video output: %s",
839 g_clear_error (&error);
844 empathy_tp_call_set_output_volume (EmpathyTpCall *call,
847 EmpathyTpCallPriv *priv = GET_PRIV (call);
848 const gchar *object_path;
849 DBusGProxy *ch_proxy;
850 GError *error = NULL;
852 if (priv->status == EMPATHY_TP_CALL_STATUS_CLOSED)
855 empathy_debug (DEBUG_DOMAIN, "Setting output volume: %d", volume);
857 object_path = dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel));
858 ch_proxy = dbus_g_proxy_new_for_name (tp_get_bus (), STREAM_ENGINE_BUS_NAME,
859 STREAM_ENGINE_OBJECT_PATH, STREAM_ENGINE_INTERFACE);
861 if (!org_freedesktop_Telepathy_StreamEngine_set_output_volume (ch_proxy,
862 object_path, priv->audio->id, volume, &error))
864 empathy_debug (DEBUG_DOMAIN, "Couldn't set volume: %s", error->message);
865 g_clear_error (&error);
871 empathy_tp_call_mute_output (EmpathyTpCall *call,
874 EmpathyTpCallPriv *priv = GET_PRIV (call);
875 const gchar *object_path;
876 DBusGProxy *ch_proxy;
877 GError *error = NULL;
879 if (priv->status == EMPATHY_TP_CALL_STATUS_CLOSED)
882 empathy_debug (DEBUG_DOMAIN, "Setting output mute: %d", is_muted);
884 object_path = dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel));
885 ch_proxy = dbus_g_proxy_new_for_name (tp_get_bus (), STREAM_ENGINE_BUS_NAME,
886 STREAM_ENGINE_OBJECT_PATH, STREAM_ENGINE_INTERFACE);
888 if (!org_freedesktop_Telepathy_StreamEngine_mute_output (ch_proxy,
889 object_path, priv->audio->id, is_muted, &error))
891 empathy_debug (DEBUG_DOMAIN, "Couldn't mute output: %s", error->message);
892 g_clear_error (&error);
897 empathy_tp_call_mute_input (EmpathyTpCall *call,
900 EmpathyTpCallPriv *priv = GET_PRIV (call);
901 const gchar *object_path;
902 DBusGProxy *ch_proxy;
903 GError *error = NULL;
905 if (priv->status == EMPATHY_TP_CALL_STATUS_CLOSED)
908 empathy_debug (DEBUG_DOMAIN, "Setting input mute: %d", is_muted);
910 object_path = dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel));
911 ch_proxy = dbus_g_proxy_new_for_name (tp_get_bus (), STREAM_ENGINE_BUS_NAME,
912 STREAM_ENGINE_OBJECT_PATH, STREAM_ENGINE_INTERFACE);
914 if (!org_freedesktop_Telepathy_StreamEngine_mute_input (ch_proxy,
915 object_path, priv->audio->id, is_muted, &error))
917 empathy_debug (DEBUG_DOMAIN, "Couldn't mute input: %s", error->message);
918 g_clear_error (&error);