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>
25 #include <telepathy-glib/proxy-subclass.h>
26 #include <telepathy-glib/dbus.h>
27 #include <telepathy-glib/interfaces.h>
28 #include <telepathy-glib/util.h>
30 #include "empathy-tp-streamed-media.h"
31 #include "empathy-tp-contact-factory.h"
32 #include "empathy-utils.h"
34 #define DEBUG_FLAG EMPATHY_DEBUG_VOIP
35 #include "empathy-debug.h"
37 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyTpStreamedMedia)
40 gboolean dispose_has_run;
43 EmpathyContact *contact;
47 EmpathyTpStreamedMediaStream *audio;
48 EmpathyTpStreamedMediaStream *video;
49 } EmpathyTpStreamedMediaPriv;
58 static guint signals[LAST_SIGNAL] = {0};
71 G_DEFINE_TYPE (EmpathyTpStreamedMedia, empathy_tp_streamed_media, G_TYPE_OBJECT)
74 tp_streamed_media_add_stream (EmpathyTpStreamedMedia *call,
79 guint stream_direction)
81 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
85 case TP_MEDIA_STREAM_TYPE_AUDIO:
86 DEBUG ("Audio stream - id: %d, state: %d, direction: %d",
87 stream_id, stream_state, stream_direction);
88 priv->audio->exists = TRUE;
89 priv->audio->id = stream_id;
90 priv->audio->state = stream_state;
91 priv->audio->direction = stream_direction;
92 g_object_notify (G_OBJECT (call), "audio-stream");
94 case TP_MEDIA_STREAM_TYPE_VIDEO:
95 DEBUG ("Video stream - id: %d, state: %d, direction: %d",
96 stream_id, stream_state, stream_direction);
97 priv->video->exists = TRUE;
98 priv->video->id = stream_id;
99 priv->video->state = stream_state;
100 priv->video->direction = stream_direction;
101 g_object_notify (G_OBJECT (call), "video-stream");
104 DEBUG ("Unknown stream type: %d", stream_type);
109 tp_streamed_media_stream_added_cb (TpChannel *channel,
111 guint contact_handle,
116 DEBUG ("Stream added - stream id: %d, contact handle: %d, stream type: %d",
117 stream_id, contact_handle, stream_type);
119 tp_streamed_media_add_stream (EMPATHY_TP_STREAMED_MEDIA (call), stream_id, contact_handle,
120 stream_type, TP_MEDIA_STREAM_STATE_DISCONNECTED,
121 TP_MEDIA_STREAM_DIRECTION_NONE);
125 tp_streamed_media_stream_removed_cb (TpChannel *channel,
130 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
132 DEBUG ("Stream removed - stream id: %d", stream_id);
134 if (stream_id == priv->audio->id)
136 priv->audio->exists = FALSE;
137 g_object_notify (call, "audio-stream");
139 else if (stream_id == priv->video->id)
141 priv->video->exists = FALSE;
142 g_object_notify (call, "video-stream");
147 tp_streamed_media_stream_state_changed_cb (TpChannel *proxy,
153 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
155 DEBUG ("Stream state changed - stream id: %d, state state: %d",
156 stream_id, stream_state);
158 if (stream_id == priv->audio->id)
160 priv->audio->state = stream_state;
161 g_object_notify (call, "audio-stream");
163 else if (stream_id == priv->video->id)
165 priv->video->state = stream_state;
166 g_object_notify (call, "video-stream");
171 tp_streamed_media_stream_direction_changed_cb (TpChannel *channel,
173 guint stream_direction,
178 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
180 DEBUG ("Stream direction changed - stream: %d, direction: %d",
181 stream_id, stream_direction);
183 if (stream_id == priv->audio->id)
185 priv->audio->direction = stream_direction;
186 g_object_notify (call, "audio-stream");
188 else if (stream_id == priv->video->id)
190 priv->video->direction = stream_direction;
191 g_object_notify (call, "video-stream");
196 tp_streamed_media_request_streams_cb (TpChannel *channel,
197 const GPtrArray *streams,
206 DEBUG ("Error requesting streams: %s", error->message);
210 for (i = 0; i < streams->len; i++)
214 guint contact_handle;
217 guint stream_direction;
219 values = g_ptr_array_index (streams, i);
220 stream_id = g_value_get_uint (g_value_array_get_nth (values, 0));
221 contact_handle = g_value_get_uint (g_value_array_get_nth (values, 1));
222 stream_type = g_value_get_uint (g_value_array_get_nth (values, 2));
223 stream_state = g_value_get_uint (g_value_array_get_nth (values, 3));
224 stream_direction = g_value_get_uint (g_value_array_get_nth (values, 4));
226 tp_streamed_media_add_stream (EMPATHY_TP_STREAMED_MEDIA (call), stream_id, contact_handle,
227 stream_type, stream_state, stream_direction);
232 tp_streamed_media_request_streams_for_capabilities (EmpathyTpStreamedMedia *call,
233 EmpathyCapabilities capabilities)
235 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
236 GArray *stream_types;
240 if (capabilities == EMPATHY_CAPABILITIES_UNKNOWN)
241 capabilities = EMPATHY_CAPABILITIES_AUDIO | EMPATHY_CAPABILITIES_VIDEO;
243 DEBUG ("Requesting new stream for capabilities %d",
246 stream_types = g_array_new (FALSE, FALSE, sizeof (guint));
247 handle = empathy_contact_get_handle (priv->contact);
249 if (capabilities & EMPATHY_CAPABILITIES_AUDIO)
251 stream_type = TP_MEDIA_STREAM_TYPE_AUDIO;
252 g_array_append_val (stream_types, stream_type);
254 if (capabilities & EMPATHY_CAPABILITIES_VIDEO)
256 stream_type = TP_MEDIA_STREAM_TYPE_VIDEO;
257 g_array_append_val (stream_types, stream_type);
260 tp_cli_channel_type_streamed_media_call_request_streams (priv->channel, -1,
261 handle, stream_types, tp_streamed_media_request_streams_cb, NULL, NULL,
264 g_array_unref (stream_types);
268 tp_streamed_media_got_contact_cb (TpConnection *connection,
269 EmpathyContact *contact,
274 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
278 DEBUG ("Error: %s", error->message);
282 priv->contact = g_object_ref (contact);
284 if (priv->status < EMPATHY_TP_STREAMED_MEDIA_STATUS_PENDING)
286 priv->status = EMPATHY_TP_STREAMED_MEDIA_STATUS_PENDING;
287 g_object_notify (G_OBJECT (call), "status");
290 g_object_notify (G_OBJECT (call), "contact");
294 tp_streamed_media_update_status (EmpathyTpStreamedMedia *call)
296 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
297 TpHandle self_handle;
303 self_handle = tp_channel_group_get_self_handle (priv->channel);
304 set = tp_channel_group_get_members (priv->channel);
305 tp_intset_iter_init (&iter, set);
306 while (tp_intset_iter_next (&iter))
308 if (priv->status == EMPATHY_TP_STREAMED_MEDIA_STATUS_PENDING &&
309 ((priv->is_incoming && iter.element == self_handle) ||
310 (!priv->is_incoming && iter.element != self_handle)))
312 priv->status = EMPATHY_TP_STREAMED_MEDIA_STATUS_ACCEPTED;
313 g_object_notify (G_OBJECT (call), "status");
317 g_object_unref (call);
321 tp_streamed_media_channel_invalidated_cb (TpChannel *channel,
325 EmpathyTpStreamedMedia *call)
327 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
329 DEBUG ("Channel invalidated: %s", message);
330 priv->status = EMPATHY_TP_STREAMED_MEDIA_STATUS_CLOSED;
331 g_object_notify (G_OBJECT (call), "status");
335 tp_streamed_media_async_cb (TpProxy *proxy,
341 DEBUG ("Error %s: %s", (gchar *) user_data, error->message);
345 tp_streamed_media_stream_error_cb (TpChannel *channel,
352 EmpathyTpStreamedMedia *self = EMPATHY_TP_STREAMED_MEDIA (call);
353 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (self);
355 DEBUG ("Stream error on stream %u: %s (code: %u)", stream_id, msg,
358 if (priv->audio->id == stream_id)
360 g_signal_emit (call, signals[AUDIO_STREAM_ERROR], 0, error_code, msg);
362 else if (priv->video->id == stream_id)
364 g_signal_emit (call, signals[VIDEO_STREAM_ERROR], 0, error_code, msg);
368 DEBUG ("Unknown stream id: %u", stream_id);
373 tp_streamed_media_constructor (GType type,
374 guint n_construct_params,
375 GObjectConstructParam *construct_params)
378 EmpathyTpStreamedMedia *call;
379 EmpathyTpStreamedMediaPriv *priv;
381 object = G_OBJECT_CLASS (empathy_tp_streamed_media_parent_class)->constructor (type,
382 n_construct_params, construct_params);
384 call = EMPATHY_TP_STREAMED_MEDIA (object);
385 priv = GET_PRIV (call);
387 /* Setup streamed media channel */
388 g_signal_connect (priv->channel, "invalidated",
389 G_CALLBACK (tp_streamed_media_channel_invalidated_cb), call);
390 tp_cli_channel_type_streamed_media_connect_to_stream_added (priv->channel,
391 tp_streamed_media_stream_added_cb, NULL, NULL, G_OBJECT (call), NULL);
392 tp_cli_channel_type_streamed_media_connect_to_stream_removed (priv->channel,
393 tp_streamed_media_stream_removed_cb, NULL, NULL, G_OBJECT (call), NULL);
394 tp_cli_channel_type_streamed_media_connect_to_stream_state_changed (priv->channel,
395 tp_streamed_media_stream_state_changed_cb, NULL, NULL, G_OBJECT (call), NULL);
396 tp_cli_channel_type_streamed_media_connect_to_stream_direction_changed (priv->channel,
397 tp_streamed_media_stream_direction_changed_cb, NULL, NULL, G_OBJECT (call), NULL);
398 tp_cli_channel_type_streamed_media_connect_to_stream_error (priv->channel,
399 tp_streamed_media_stream_error_cb, NULL, NULL, G_OBJECT (call), NULL);
400 tp_cli_channel_type_streamed_media_call_list_streams (priv->channel, -1,
401 tp_streamed_media_request_streams_cb, NULL, NULL, G_OBJECT (call));
403 /* Is the call incoming? */
404 priv->is_incoming = !tp_channel_get_requested (priv->channel);
406 /* Get the remote contact */
407 empathy_tp_contact_factory_get_from_handle (
408 tp_channel_borrow_connection (priv->channel),
409 tp_channel_get_handle (priv->channel, NULL), tp_streamed_media_got_contact_cb,
412 /* Update status when members changes */
413 tp_streamed_media_update_status (call);
414 tp_g_signal_connect_object (priv->channel, "group-members-changed",
415 G_CALLBACK (tp_streamed_media_update_status), call, G_CONNECT_SWAPPED);
420 tp_streamed_media_dispose (GObject *object)
422 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (object);
424 DEBUG ("Disposing: %p, %d", object, priv->dispose_has_run);
426 if (priv->dispose_has_run)
429 priv->dispose_has_run = TRUE;
431 if (priv->channel != NULL)
433 g_signal_handlers_disconnect_by_func (priv->channel,
434 tp_streamed_media_channel_invalidated_cb, object);
436 g_object_unref (priv->channel);
437 priv->channel = NULL;
440 if (priv->contact != NULL)
441 g_object_unref (priv->contact);
443 tp_clear_object (&priv->account);
445 if (G_OBJECT_CLASS (empathy_tp_streamed_media_parent_class)->dispose)
446 G_OBJECT_CLASS (empathy_tp_streamed_media_parent_class)->dispose (object);
450 tp_streamed_media_finalize (GObject *object)
452 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (object);
454 DEBUG ("Finalizing: %p", object);
456 g_slice_free (EmpathyTpStreamedMediaStream, priv->audio);
457 g_slice_free (EmpathyTpStreamedMediaStream, priv->video);
459 (G_OBJECT_CLASS (empathy_tp_streamed_media_parent_class)->finalize) (object);
463 tp_streamed_media_set_property (GObject *object,
468 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (object);
473 priv->account = g_value_dup_object (value);
476 priv->channel = g_value_dup_object (value);
479 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
485 tp_streamed_media_get_property (GObject *object,
490 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (object);
495 g_value_set_object (value, priv->channel);
498 g_value_set_object (value, priv->channel);
501 g_value_set_object (value, priv->contact);
504 g_value_set_uint (value, priv->status);
506 case PROP_AUDIO_STREAM:
507 g_value_set_pointer (value, priv->audio);
509 case PROP_VIDEO_STREAM:
510 g_value_set_pointer (value, priv->video);
513 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
519 empathy_tp_streamed_media_class_init (EmpathyTpStreamedMediaClass *klass)
521 GObjectClass *object_class = G_OBJECT_CLASS (klass);
523 object_class->constructor = tp_streamed_media_constructor;
524 object_class->dispose = tp_streamed_media_dispose;
525 object_class->finalize = tp_streamed_media_finalize;
526 object_class->set_property = tp_streamed_media_set_property;
527 object_class->get_property = tp_streamed_media_get_property;
529 g_type_class_add_private (klass, sizeof (EmpathyTpStreamedMediaPriv));
531 g_object_class_install_property (object_class, PROP_ACCOUNT,
532 g_param_spec_object ("account", "TpAccount", "TpAccount",
534 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
535 G_PARAM_STATIC_STRINGS));
537 g_object_class_install_property (object_class, PROP_CHANNEL,
538 g_param_spec_object ("channel", "channel", "channel",
540 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
541 G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
543 g_object_class_install_property (object_class, PROP_CONTACT,
544 g_param_spec_object ("contact", "Call contact", "Call contact",
545 EMPATHY_TYPE_CONTACT,
546 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
548 g_object_class_install_property (object_class, PROP_STATUS,
549 g_param_spec_uint ("status", "Call status",
550 "Call status", 0, 255, 0, G_PARAM_READABLE | G_PARAM_STATIC_NICK |
551 G_PARAM_STATIC_BLURB));
553 g_object_class_install_property (object_class, PROP_AUDIO_STREAM,
554 g_param_spec_pointer ("audio-stream", "Audio stream data",
556 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
558 g_object_class_install_property (object_class, PROP_VIDEO_STREAM,
559 g_param_spec_pointer ("video-stream", "Video stream data",
561 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
563 signals[AUDIO_STREAM_ERROR] =
564 g_signal_new ("audio-stream-error",
565 G_TYPE_FROM_CLASS (klass),
566 G_SIGNAL_RUN_LAST, 0,
568 g_cclosure_marshal_generic,
570 2, G_TYPE_UINT, G_TYPE_STRING);
572 signals[VIDEO_STREAM_ERROR] =
573 g_signal_new ("video-stream-error",
574 G_TYPE_FROM_CLASS (klass),
575 G_SIGNAL_RUN_LAST, 0,
577 g_cclosure_marshal_generic,
579 2, G_TYPE_UINT, G_TYPE_STRING);
583 empathy_tp_streamed_media_init (EmpathyTpStreamedMedia *call)
585 EmpathyTpStreamedMediaPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (call,
586 EMPATHY_TYPE_TP_STREAMED_MEDIA, EmpathyTpStreamedMediaPriv);
589 priv->status = EMPATHY_TP_STREAMED_MEDIA_STATUS_READYING;
590 priv->contact = NULL;
591 priv->audio = g_slice_new0 (EmpathyTpStreamedMediaStream);
592 priv->video = g_slice_new0 (EmpathyTpStreamedMediaStream);
593 priv->audio->exists = FALSE;
594 priv->video->exists = FALSE;
597 EmpathyTpStreamedMedia *
598 empathy_tp_streamed_media_new (TpAccount *account,
601 g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL);
602 g_return_val_if_fail (TP_IS_CHANNEL (channel), NULL);
604 return g_object_new (EMPATHY_TYPE_TP_STREAMED_MEDIA,
611 empathy_tp_streamed_media_accept_incoming_call (EmpathyTpStreamedMedia *call)
613 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
614 TpHandle self_handle;
615 GArray handles = {(gchar *) &self_handle, 1};
617 g_return_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call));
618 g_return_if_fail (priv->status == EMPATHY_TP_STREAMED_MEDIA_STATUS_PENDING);
620 if (!priv->is_incoming)
623 DEBUG ("Accepting incoming call");
625 self_handle = tp_channel_group_get_self_handle (priv->channel);
626 tp_cli_channel_interface_group_call_add_members (priv->channel, -1,
627 &handles, NULL, NULL, NULL, NULL, NULL);
631 empathy_tp_streamed_media_close (EmpathyTpStreamedMedia *call)
633 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
635 g_return_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call));
637 if (priv->status == EMPATHY_TP_STREAMED_MEDIA_STATUS_CLOSED)
640 DEBUG ("Closing channel");
642 tp_cli_channel_call_close (priv->channel, -1,
643 NULL, NULL, NULL, NULL);
645 priv->status = EMPATHY_TP_STREAMED_MEDIA_STATUS_CLOSED;
646 g_object_notify (G_OBJECT (call), "status");
650 empathy_tp_streamed_media_request_video_stream_direction (EmpathyTpStreamedMedia *call,
653 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
656 g_return_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call));
657 g_return_if_fail (priv->status == EMPATHY_TP_STREAMED_MEDIA_STATUS_ACCEPTED);
659 DEBUG ("Requesting video stream direction - is_sending: %d", is_sending);
661 if (!priv->video->exists)
664 tp_streamed_media_request_streams_for_capabilities (call,
665 EMPATHY_CAPABILITIES_VIDEO);
670 new_direction = priv->video->direction | TP_MEDIA_STREAM_DIRECTION_SEND;
672 new_direction = priv->video->direction & ~TP_MEDIA_STREAM_DIRECTION_SEND;
674 tp_cli_channel_type_streamed_media_call_request_stream_direction (priv->channel,
675 -1, priv->video->id, new_direction,
676 (tp_cli_channel_type_streamed_media_callback_for_request_stream_direction)
677 tp_streamed_media_async_cb, NULL, NULL, G_OBJECT (call));
681 empathy_tp_streamed_media_start_tone (EmpathyTpStreamedMedia *call, TpDTMFEvent event)
683 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
685 g_return_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call));
686 g_return_if_fail (priv->status == EMPATHY_TP_STREAMED_MEDIA_STATUS_ACCEPTED);
688 if (!priv->audio->exists)
691 tp_cli_channel_interface_dtmf_call_start_tone (priv->channel, -1,
692 priv->audio->id, event,
693 (tp_cli_channel_interface_dtmf_callback_for_start_tone) tp_streamed_media_async_cb,
694 "starting tone", NULL, G_OBJECT (call));
698 empathy_tp_streamed_media_stop_tone (EmpathyTpStreamedMedia *call)
700 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
702 g_return_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call));
703 g_return_if_fail (priv->status == EMPATHY_TP_STREAMED_MEDIA_STATUS_ACCEPTED);
705 if (!priv->audio->exists)
708 tp_cli_channel_interface_dtmf_call_stop_tone (priv->channel, -1,
710 (tp_cli_channel_interface_dtmf_callback_for_stop_tone) tp_streamed_media_async_cb,
711 "stoping tone", NULL, G_OBJECT (call));
715 empathy_tp_streamed_media_has_dtmf (EmpathyTpStreamedMedia *call)
717 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
719 g_return_val_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call), FALSE);
721 return tp_proxy_has_interface_by_id (priv->channel,
722 TP_IFACE_QUARK_CHANNEL_INTERFACE_DTMF);
726 * empathy_tp_streamed_media_is_receiving_video:
729 * Indicates if the call is receiving video or not.
731 * Returns: %TRUE if the call is currently receiving video, %FALSE otherwise.
734 empathy_tp_streamed_media_is_receiving_video (EmpathyTpStreamedMedia *call)
736 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
738 g_return_val_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call), FALSE);
740 if (!priv->video->exists)
743 return priv->video->direction & TP_MEDIA_STREAM_DIRECTION_RECEIVE ?
748 * empathy_tp_streamed_media_is_sending_video:
751 * Indicates if the call is sending video or not.
753 * Returns: %TRUE if the call is currently sending video, %FALSE otherwise.
756 empathy_tp_streamed_media_is_sending_video (EmpathyTpStreamedMedia *call)
758 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
760 g_return_val_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call), FALSE);
762 if (!priv->video->exists)
765 return priv->video->direction & TP_MEDIA_STREAM_DIRECTION_SEND ?
770 empathy_tp_streamed_media_get_connection_manager (EmpathyTpStreamedMedia *self)
772 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (self);
774 return tp_account_get_connection_manager (priv->account);
778 empathy_tp_streamed_media_has_initial_video (EmpathyTpStreamedMedia *self)
780 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (self);
782 gboolean initial_video;
785 if (priv->channel == NULL)
788 g_object_get (priv->channel, "channel-properties", &props, NULL);
790 initial_video = tp_asv_get_boolean (props,
791 TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA ".InitialVideo", &valid);
793 initial_video = FALSE;
795 g_hash_table_unref (props);
796 return initial_video;
800 leave_remove_members_cb (TpChannel *proxy,
803 GObject *weak_object)
805 EmpathyTpStreamedMedia *self = user_data;
810 DEBUG ("RemoveMembers failed (%s); closing the channel", error->message);
811 empathy_tp_streamed_media_close (self);
815 empathy_tp_streamed_media_leave (EmpathyTpStreamedMedia *self)
817 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (self);
818 TpHandle self_handle;
819 GArray array = { (gchar *) &self_handle, 1 };
821 if (!tp_proxy_has_interface_by_id (priv->channel,
822 TP_IFACE_QUARK_CHANNEL_INTERFACE_GROUP))
824 empathy_tp_streamed_media_close (self);
828 self_handle = tp_channel_group_get_self_handle (priv->channel);
829 if (self_handle == 0)
831 /* we are not member of the channel */
832 empathy_tp_streamed_media_close (self);
836 tp_cli_channel_interface_group_call_remove_members (priv->channel, -1, &array,
837 "", leave_remove_members_cb, self, NULL, G_OBJECT (self));
840 EmpathyTpStreamedMediaStatus
841 empathy_tp_streamed_media_get_status (EmpathyTpStreamedMedia *self)
843 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (self);
849 empathy_tp_streamed_media_get_account (EmpathyTpStreamedMedia *self)
851 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (self);
853 return priv->account;