2 * Copyright (C) 2007 Elliot Fairweather
3 * Copyright (C) 2007-2008 Collabora Ltd.
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.
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.
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
19 * Authors: Elliot Fairweather <elliot.fairweather@collabora.co.uk>
20 * Xavier Claessens <xclaesse@gmail.com>
27 #include <telepathy-glib/proxy-subclass.h>
28 #include <telepathy-glib/dbus.h>
29 #include <telepathy-glib/interfaces.h>
30 #include <telepathy-glib/util.h>
32 #include "empathy-tp-streamed-media.h"
33 #include "empathy-tp-contact-factory.h"
34 #include "empathy-utils.h"
36 #define DEBUG_FLAG EMPATHY_DEBUG_VOIP
37 #include "empathy-debug.h"
39 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyTpStreamedMedia)
42 gboolean dispose_has_run;
45 EmpathyContact *contact;
49 EmpathyTpStreamedMediaStream *audio;
50 EmpathyTpStreamedMediaStream *video;
51 } EmpathyTpStreamedMediaPriv;
60 static guint signals[LAST_SIGNAL] = {0};
73 G_DEFINE_TYPE (EmpathyTpStreamedMedia, empathy_tp_streamed_media, G_TYPE_OBJECT)
76 tp_streamed_media_add_stream (EmpathyTpStreamedMedia *call,
81 guint stream_direction)
83 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
87 case TP_MEDIA_STREAM_TYPE_AUDIO:
88 DEBUG ("Audio stream - id: %d, state: %d, direction: %d",
89 stream_id, stream_state, stream_direction);
90 priv->audio->exists = TRUE;
91 priv->audio->id = stream_id;
92 priv->audio->state = stream_state;
93 priv->audio->direction = stream_direction;
94 g_object_notify (G_OBJECT (call), "audio-stream");
96 case TP_MEDIA_STREAM_TYPE_VIDEO:
97 DEBUG ("Video stream - id: %d, state: %d, direction: %d",
98 stream_id, stream_state, stream_direction);
99 priv->video->exists = TRUE;
100 priv->video->id = stream_id;
101 priv->video->state = stream_state;
102 priv->video->direction = stream_direction;
103 g_object_notify (G_OBJECT (call), "video-stream");
106 DEBUG ("Unknown stream type: %d", stream_type);
111 tp_streamed_media_stream_added_cb (TpChannel *channel,
113 guint contact_handle,
118 DEBUG ("Stream added - stream id: %d, contact handle: %d, stream type: %d",
119 stream_id, contact_handle, stream_type);
121 tp_streamed_media_add_stream (EMPATHY_TP_STREAMED_MEDIA (call), stream_id, contact_handle,
122 stream_type, TP_MEDIA_STREAM_STATE_DISCONNECTED,
123 TP_MEDIA_STREAM_DIRECTION_NONE);
127 tp_streamed_media_stream_removed_cb (TpChannel *channel,
132 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
134 DEBUG ("Stream removed - stream id: %d", stream_id);
136 if (stream_id == priv->audio->id)
138 priv->audio->exists = FALSE;
139 g_object_notify (call, "audio-stream");
141 else if (stream_id == priv->video->id)
143 priv->video->exists = FALSE;
144 g_object_notify (call, "video-stream");
149 tp_streamed_media_stream_state_changed_cb (TpChannel *proxy,
155 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
157 DEBUG ("Stream state changed - stream id: %d, state state: %d",
158 stream_id, stream_state);
160 if (stream_id == priv->audio->id)
162 priv->audio->state = stream_state;
163 g_object_notify (call, "audio-stream");
165 else if (stream_id == priv->video->id)
167 priv->video->state = stream_state;
168 g_object_notify (call, "video-stream");
173 tp_streamed_media_stream_direction_changed_cb (TpChannel *channel,
175 guint stream_direction,
180 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
182 DEBUG ("Stream direction changed - stream: %d, direction: %d",
183 stream_id, stream_direction);
185 if (stream_id == priv->audio->id)
187 priv->audio->direction = stream_direction;
188 g_object_notify (call, "audio-stream");
190 else if (stream_id == priv->video->id)
192 priv->video->direction = stream_direction;
193 g_object_notify (call, "video-stream");
198 tp_streamed_media_request_streams_cb (TpChannel *channel,
199 const GPtrArray *streams,
208 DEBUG ("Error requesting streams: %s", error->message);
212 for (i = 0; i < streams->len; i++)
216 guint contact_handle;
219 guint stream_direction;
221 values = g_ptr_array_index (streams, i);
222 stream_id = g_value_get_uint (g_value_array_get_nth (values, 0));
223 contact_handle = g_value_get_uint (g_value_array_get_nth (values, 1));
224 stream_type = g_value_get_uint (g_value_array_get_nth (values, 2));
225 stream_state = g_value_get_uint (g_value_array_get_nth (values, 3));
226 stream_direction = g_value_get_uint (g_value_array_get_nth (values, 4));
228 tp_streamed_media_add_stream (EMPATHY_TP_STREAMED_MEDIA (call), stream_id, contact_handle,
229 stream_type, stream_state, stream_direction);
234 tp_streamed_media_request_streams_for_capabilities (EmpathyTpStreamedMedia *call,
235 EmpathyCapabilities capabilities)
237 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
238 GArray *stream_types;
242 if (capabilities == EMPATHY_CAPABILITIES_UNKNOWN)
243 capabilities = EMPATHY_CAPABILITIES_AUDIO | EMPATHY_CAPABILITIES_VIDEO;
245 DEBUG ("Requesting new stream for capabilities %d",
248 stream_types = g_array_new (FALSE, FALSE, sizeof (guint));
249 handle = empathy_contact_get_handle (priv->contact);
251 if (capabilities & EMPATHY_CAPABILITIES_AUDIO)
253 stream_type = TP_MEDIA_STREAM_TYPE_AUDIO;
254 g_array_append_val (stream_types, stream_type);
256 if (capabilities & EMPATHY_CAPABILITIES_VIDEO)
258 stream_type = TP_MEDIA_STREAM_TYPE_VIDEO;
259 g_array_append_val (stream_types, stream_type);
262 tp_cli_channel_type_streamed_media_call_request_streams (priv->channel, -1,
263 handle, stream_types, tp_streamed_media_request_streams_cb, NULL, NULL,
266 g_array_unref (stream_types);
270 tp_streamed_media_got_contact_cb (TpConnection *connection,
271 EmpathyContact *contact,
276 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
280 DEBUG ("Error: %s", error->message);
284 priv->contact = g_object_ref (contact);
286 if (priv->status < EMPATHY_TP_STREAMED_MEDIA_STATUS_PENDING)
288 priv->status = EMPATHY_TP_STREAMED_MEDIA_STATUS_PENDING;
289 g_object_notify (G_OBJECT (call), "status");
292 g_object_notify (G_OBJECT (call), "contact");
296 tp_streamed_media_update_status (EmpathyTpStreamedMedia *call)
298 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
299 TpHandle self_handle;
305 self_handle = tp_channel_group_get_self_handle (priv->channel);
306 set = tp_channel_group_get_members (priv->channel);
307 tp_intset_iter_init (&iter, set);
308 while (tp_intset_iter_next (&iter))
310 if (priv->status == EMPATHY_TP_STREAMED_MEDIA_STATUS_PENDING &&
311 ((priv->is_incoming && iter.element == self_handle) ||
312 (!priv->is_incoming && iter.element != self_handle)))
314 priv->status = EMPATHY_TP_STREAMED_MEDIA_STATUS_ACCEPTED;
315 g_object_notify (G_OBJECT (call), "status");
319 g_object_unref (call);
323 tp_streamed_media_channel_invalidated_cb (TpChannel *channel,
327 EmpathyTpStreamedMedia *call)
329 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
331 DEBUG ("Channel invalidated: %s", message);
332 priv->status = EMPATHY_TP_STREAMED_MEDIA_STATUS_CLOSED;
333 g_object_notify (G_OBJECT (call), "status");
337 tp_streamed_media_async_cb (TpProxy *proxy,
343 DEBUG ("Error %s: %s", (gchar *) user_data, error->message);
347 tp_streamed_media_stream_error_cb (TpChannel *channel,
354 EmpathyTpStreamedMedia *self = EMPATHY_TP_STREAMED_MEDIA (call);
355 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (self);
357 DEBUG ("Stream error on stream %u: %s (code: %u)", stream_id, msg,
360 if (priv->audio->id == stream_id)
362 g_signal_emit (call, signals[AUDIO_STREAM_ERROR], 0, error_code, msg);
364 else if (priv->video->id == stream_id)
366 g_signal_emit (call, signals[VIDEO_STREAM_ERROR], 0, error_code, msg);
370 DEBUG ("Unknown stream id: %u", stream_id);
375 tp_streamed_media_constructor (GType type,
376 guint n_construct_params,
377 GObjectConstructParam *construct_params)
380 EmpathyTpStreamedMedia *call;
381 EmpathyTpStreamedMediaPriv *priv;
383 object = G_OBJECT_CLASS (empathy_tp_streamed_media_parent_class)->constructor (type,
384 n_construct_params, construct_params);
386 call = EMPATHY_TP_STREAMED_MEDIA (object);
387 priv = GET_PRIV (call);
389 /* Setup streamed media channel */
390 g_signal_connect (priv->channel, "invalidated",
391 G_CALLBACK (tp_streamed_media_channel_invalidated_cb), call);
392 tp_cli_channel_type_streamed_media_connect_to_stream_added (priv->channel,
393 tp_streamed_media_stream_added_cb, NULL, NULL, G_OBJECT (call), NULL);
394 tp_cli_channel_type_streamed_media_connect_to_stream_removed (priv->channel,
395 tp_streamed_media_stream_removed_cb, NULL, NULL, G_OBJECT (call), NULL);
396 tp_cli_channel_type_streamed_media_connect_to_stream_state_changed (priv->channel,
397 tp_streamed_media_stream_state_changed_cb, NULL, NULL, G_OBJECT (call), NULL);
398 tp_cli_channel_type_streamed_media_connect_to_stream_direction_changed (priv->channel,
399 tp_streamed_media_stream_direction_changed_cb, NULL, NULL, G_OBJECT (call), NULL);
400 tp_cli_channel_type_streamed_media_connect_to_stream_error (priv->channel,
401 tp_streamed_media_stream_error_cb, NULL, NULL, G_OBJECT (call), NULL);
402 tp_cli_channel_type_streamed_media_call_list_streams (priv->channel, -1,
403 tp_streamed_media_request_streams_cb, NULL, NULL, G_OBJECT (call));
405 /* Is the call incoming? */
406 priv->is_incoming = !tp_channel_get_requested (priv->channel);
408 /* Get the remote contact */
409 empathy_tp_contact_factory_get_from_handle (
410 tp_channel_borrow_connection (priv->channel),
411 tp_channel_get_handle (priv->channel, NULL), tp_streamed_media_got_contact_cb,
414 /* Update status when members changes */
415 tp_streamed_media_update_status (call);
416 tp_g_signal_connect_object (priv->channel, "group-members-changed",
417 G_CALLBACK (tp_streamed_media_update_status), call, G_CONNECT_SWAPPED);
422 tp_streamed_media_dispose (GObject *object)
424 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (object);
426 DEBUG ("Disposing: %p, %d", object, priv->dispose_has_run);
428 if (priv->dispose_has_run)
431 priv->dispose_has_run = TRUE;
433 if (priv->channel != NULL)
435 g_signal_handlers_disconnect_by_func (priv->channel,
436 tp_streamed_media_channel_invalidated_cb, object);
438 g_object_unref (priv->channel);
439 priv->channel = NULL;
442 if (priv->contact != NULL)
443 g_object_unref (priv->contact);
445 tp_clear_object (&priv->account);
447 if (G_OBJECT_CLASS (empathy_tp_streamed_media_parent_class)->dispose)
448 G_OBJECT_CLASS (empathy_tp_streamed_media_parent_class)->dispose (object);
452 tp_streamed_media_finalize (GObject *object)
454 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (object);
456 DEBUG ("Finalizing: %p", object);
458 g_slice_free (EmpathyTpStreamedMediaStream, priv->audio);
459 g_slice_free (EmpathyTpStreamedMediaStream, priv->video);
461 (G_OBJECT_CLASS (empathy_tp_streamed_media_parent_class)->finalize) (object);
465 tp_streamed_media_set_property (GObject *object,
470 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (object);
475 priv->account = g_value_dup_object (value);
478 priv->channel = g_value_dup_object (value);
481 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
487 tp_streamed_media_get_property (GObject *object,
492 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (object);
497 g_value_set_object (value, priv->channel);
500 g_value_set_object (value, priv->channel);
503 g_value_set_object (value, priv->contact);
506 g_value_set_uint (value, priv->status);
508 case PROP_AUDIO_STREAM:
509 g_value_set_pointer (value, priv->audio);
511 case PROP_VIDEO_STREAM:
512 g_value_set_pointer (value, priv->video);
515 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
521 empathy_tp_streamed_media_class_init (EmpathyTpStreamedMediaClass *klass)
523 GObjectClass *object_class = G_OBJECT_CLASS (klass);
525 object_class->constructor = tp_streamed_media_constructor;
526 object_class->dispose = tp_streamed_media_dispose;
527 object_class->finalize = tp_streamed_media_finalize;
528 object_class->set_property = tp_streamed_media_set_property;
529 object_class->get_property = tp_streamed_media_get_property;
531 g_type_class_add_private (klass, sizeof (EmpathyTpStreamedMediaPriv));
533 g_object_class_install_property (object_class, PROP_ACCOUNT,
534 g_param_spec_object ("account", "TpAccount", "TpAccount",
536 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
537 G_PARAM_STATIC_STRINGS));
539 g_object_class_install_property (object_class, PROP_CHANNEL,
540 g_param_spec_object ("channel", "channel", "channel",
542 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
543 G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
545 g_object_class_install_property (object_class, PROP_CONTACT,
546 g_param_spec_object ("contact", "Call contact", "Call contact",
547 EMPATHY_TYPE_CONTACT,
548 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
550 g_object_class_install_property (object_class, PROP_STATUS,
551 g_param_spec_uint ("status", "Call status",
552 "Call status", 0, 255, 0, G_PARAM_READABLE | G_PARAM_STATIC_NICK |
553 G_PARAM_STATIC_BLURB));
555 g_object_class_install_property (object_class, PROP_AUDIO_STREAM,
556 g_param_spec_pointer ("audio-stream", "Audio stream data",
558 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
560 g_object_class_install_property (object_class, PROP_VIDEO_STREAM,
561 g_param_spec_pointer ("video-stream", "Video stream data",
563 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
565 signals[AUDIO_STREAM_ERROR] =
566 g_signal_new ("audio-stream-error",
567 G_TYPE_FROM_CLASS (klass),
568 G_SIGNAL_RUN_LAST, 0,
570 g_cclosure_marshal_generic,
572 2, G_TYPE_UINT, G_TYPE_STRING);
574 signals[VIDEO_STREAM_ERROR] =
575 g_signal_new ("video-stream-error",
576 G_TYPE_FROM_CLASS (klass),
577 G_SIGNAL_RUN_LAST, 0,
579 g_cclosure_marshal_generic,
581 2, G_TYPE_UINT, G_TYPE_STRING);
585 empathy_tp_streamed_media_init (EmpathyTpStreamedMedia *call)
587 EmpathyTpStreamedMediaPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (call,
588 EMPATHY_TYPE_TP_STREAMED_MEDIA, EmpathyTpStreamedMediaPriv);
591 priv->status = EMPATHY_TP_STREAMED_MEDIA_STATUS_READYING;
592 priv->contact = NULL;
593 priv->audio = g_slice_new0 (EmpathyTpStreamedMediaStream);
594 priv->video = g_slice_new0 (EmpathyTpStreamedMediaStream);
595 priv->audio->exists = FALSE;
596 priv->video->exists = FALSE;
599 EmpathyTpStreamedMedia *
600 empathy_tp_streamed_media_new (TpAccount *account,
603 g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL);
604 g_return_val_if_fail (TP_IS_CHANNEL (channel), NULL);
606 return g_object_new (EMPATHY_TYPE_TP_STREAMED_MEDIA,
613 empathy_tp_streamed_media_accept_incoming_call (EmpathyTpStreamedMedia *call)
615 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
616 TpHandle self_handle;
617 GArray handles = {(gchar *) &self_handle, 1};
619 g_return_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call));
620 g_return_if_fail (priv->status == EMPATHY_TP_STREAMED_MEDIA_STATUS_PENDING);
622 if (!priv->is_incoming)
625 DEBUG ("Accepting incoming call");
627 self_handle = tp_channel_group_get_self_handle (priv->channel);
628 tp_cli_channel_interface_group_call_add_members (priv->channel, -1,
629 &handles, NULL, NULL, NULL, NULL, NULL);
633 empathy_tp_streamed_media_close (EmpathyTpStreamedMedia *call)
635 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
637 g_return_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call));
639 if (priv->status == EMPATHY_TP_STREAMED_MEDIA_STATUS_CLOSED)
642 DEBUG ("Closing channel");
644 tp_cli_channel_call_close (priv->channel, -1,
645 NULL, NULL, NULL, NULL);
647 priv->status = EMPATHY_TP_STREAMED_MEDIA_STATUS_CLOSED;
648 g_object_notify (G_OBJECT (call), "status");
652 empathy_tp_streamed_media_request_video_stream_direction (EmpathyTpStreamedMedia *call,
655 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
658 g_return_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call));
659 g_return_if_fail (priv->status == EMPATHY_TP_STREAMED_MEDIA_STATUS_ACCEPTED);
661 DEBUG ("Requesting video stream direction - is_sending: %d", is_sending);
663 if (!priv->video->exists)
666 tp_streamed_media_request_streams_for_capabilities (call,
667 EMPATHY_CAPABILITIES_VIDEO);
672 new_direction = priv->video->direction | TP_MEDIA_STREAM_DIRECTION_SEND;
674 new_direction = priv->video->direction & ~TP_MEDIA_STREAM_DIRECTION_SEND;
676 tp_cli_channel_type_streamed_media_call_request_stream_direction (priv->channel,
677 -1, priv->video->id, new_direction,
678 (tp_cli_channel_type_streamed_media_callback_for_request_stream_direction)
679 tp_streamed_media_async_cb, NULL, NULL, G_OBJECT (call));
683 empathy_tp_streamed_media_start_tone (EmpathyTpStreamedMedia *call, TpDTMFEvent event)
685 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
687 g_return_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call));
688 g_return_if_fail (priv->status == EMPATHY_TP_STREAMED_MEDIA_STATUS_ACCEPTED);
690 if (!priv->audio->exists)
693 tp_cli_channel_interface_dtmf_call_start_tone (priv->channel, -1,
694 priv->audio->id, event,
695 (tp_cli_channel_interface_dtmf_callback_for_start_tone) tp_streamed_media_async_cb,
696 "starting tone", NULL, G_OBJECT (call));
700 empathy_tp_streamed_media_stop_tone (EmpathyTpStreamedMedia *call)
702 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
704 g_return_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call));
705 g_return_if_fail (priv->status == EMPATHY_TP_STREAMED_MEDIA_STATUS_ACCEPTED);
707 if (!priv->audio->exists)
710 tp_cli_channel_interface_dtmf_call_stop_tone (priv->channel, -1,
712 (tp_cli_channel_interface_dtmf_callback_for_stop_tone) tp_streamed_media_async_cb,
713 "stoping tone", NULL, G_OBJECT (call));
717 empathy_tp_streamed_media_has_dtmf (EmpathyTpStreamedMedia *call)
719 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
721 g_return_val_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call), FALSE);
723 return tp_proxy_has_interface_by_id (priv->channel,
724 TP_IFACE_QUARK_CHANNEL_INTERFACE_DTMF);
728 * empathy_tp_streamed_media_is_receiving_video:
731 * Indicates if the call is receiving video or not.
733 * Returns: %TRUE if the call is currently receiving video, %FALSE otherwise.
736 empathy_tp_streamed_media_is_receiving_video (EmpathyTpStreamedMedia *call)
738 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
740 g_return_val_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call), FALSE);
742 if (!priv->video->exists)
745 return priv->video->direction & TP_MEDIA_STREAM_DIRECTION_RECEIVE ?
750 * empathy_tp_streamed_media_is_sending_video:
753 * Indicates if the call is sending video or not.
755 * Returns: %TRUE if the call is currently sending video, %FALSE otherwise.
758 empathy_tp_streamed_media_is_sending_video (EmpathyTpStreamedMedia *call)
760 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
762 g_return_val_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call), FALSE);
764 if (!priv->video->exists)
767 return priv->video->direction & TP_MEDIA_STREAM_DIRECTION_SEND ?
772 empathy_tp_streamed_media_get_connection_manager (EmpathyTpStreamedMedia *self)
774 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (self);
776 return tp_account_get_connection_manager (priv->account);
780 empathy_tp_streamed_media_has_initial_video (EmpathyTpStreamedMedia *self)
782 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (self);
784 gboolean initial_video;
787 if (priv->channel == NULL)
790 g_object_get (priv->channel, "channel-properties", &props, NULL);
792 initial_video = tp_asv_get_boolean (props,
793 TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA ".InitialVideo", &valid);
795 initial_video = FALSE;
797 g_hash_table_unref (props);
798 return initial_video;
802 leave_remove_members_cb (TpChannel *proxy,
805 GObject *weak_object)
807 EmpathyTpStreamedMedia *self = user_data;
812 DEBUG ("RemoveMembers failed (%s); closing the channel", error->message);
813 empathy_tp_streamed_media_close (self);
817 empathy_tp_streamed_media_leave (EmpathyTpStreamedMedia *self)
819 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (self);
820 TpHandle self_handle;
821 GArray array = { (gchar *) &self_handle, 1 };
823 if (!tp_proxy_has_interface_by_id (priv->channel,
824 TP_IFACE_QUARK_CHANNEL_INTERFACE_GROUP))
826 empathy_tp_streamed_media_close (self);
830 self_handle = tp_channel_group_get_self_handle (priv->channel);
831 if (self_handle == 0)
833 /* we are not member of the channel */
834 empathy_tp_streamed_media_close (self);
838 tp_cli_channel_interface_group_call_remove_members (priv->channel, -1, &array,
839 "", leave_remove_members_cb, self, NULL, G_OBJECT (self));
842 EmpathyTpStreamedMediaStatus
843 empathy_tp_streamed_media_get_status (EmpathyTpStreamedMedia *self)
845 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (self);
851 empathy_tp_streamed_media_get_account (EmpathyTpStreamedMedia *self)
853 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (self);
855 return priv->account;