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"
33 #include "empathy-marshal.h"
35 #define DEBUG_FLAG EMPATHY_DEBUG_VOIP
36 #include "empathy-debug.h"
38 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyTpStreamedMedia)
41 gboolean dispose_has_run;
44 EmpathyContact *contact;
48 EmpathyTpStreamedMediaStream *audio;
49 EmpathyTpStreamedMediaStream *video;
50 } EmpathyTpStreamedMediaPriv;
59 static guint signals[LAST_SIGNAL] = {0};
72 G_DEFINE_TYPE (EmpathyTpStreamedMedia, empathy_tp_streamed_media, G_TYPE_OBJECT)
75 tp_streamed_media_add_stream (EmpathyTpStreamedMedia *call,
80 guint stream_direction)
82 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
86 case TP_MEDIA_STREAM_TYPE_AUDIO:
87 DEBUG ("Audio stream - id: %d, state: %d, direction: %d",
88 stream_id, stream_state, stream_direction);
89 priv->audio->exists = TRUE;
90 priv->audio->id = stream_id;
91 priv->audio->state = stream_state;
92 priv->audio->direction = stream_direction;
93 g_object_notify (G_OBJECT (call), "audio-stream");
95 case TP_MEDIA_STREAM_TYPE_VIDEO:
96 DEBUG ("Video stream - id: %d, state: %d, direction: %d",
97 stream_id, stream_state, stream_direction);
98 priv->video->exists = TRUE;
99 priv->video->id = stream_id;
100 priv->video->state = stream_state;
101 priv->video->direction = stream_direction;
102 g_object_notify (G_OBJECT (call), "video-stream");
105 DEBUG ("Unknown stream type: %d", stream_type);
110 tp_streamed_media_stream_added_cb (TpChannel *channel,
112 guint contact_handle,
117 DEBUG ("Stream added - stream id: %d, contact handle: %d, stream type: %d",
118 stream_id, contact_handle, stream_type);
120 tp_streamed_media_add_stream (EMPATHY_TP_STREAMED_MEDIA (call), stream_id, contact_handle,
121 stream_type, TP_MEDIA_STREAM_STATE_DISCONNECTED,
122 TP_MEDIA_STREAM_DIRECTION_NONE);
126 tp_streamed_media_stream_removed_cb (TpChannel *channel,
131 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
133 DEBUG ("Stream removed - stream id: %d", stream_id);
135 if (stream_id == priv->audio->id)
137 priv->audio->exists = FALSE;
138 g_object_notify (call, "audio-stream");
140 else if (stream_id == priv->video->id)
142 priv->video->exists = FALSE;
143 g_object_notify (call, "video-stream");
148 tp_streamed_media_stream_state_changed_cb (TpChannel *proxy,
154 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
156 DEBUG ("Stream state changed - stream id: %d, state state: %d",
157 stream_id, stream_state);
159 if (stream_id == priv->audio->id)
161 priv->audio->state = stream_state;
162 g_object_notify (call, "audio-stream");
164 else if (stream_id == priv->video->id)
166 priv->video->state = stream_state;
167 g_object_notify (call, "video-stream");
172 tp_streamed_media_stream_direction_changed_cb (TpChannel *channel,
174 guint stream_direction,
179 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
181 DEBUG ("Stream direction changed - stream: %d, direction: %d",
182 stream_id, stream_direction);
184 if (stream_id == priv->audio->id)
186 priv->audio->direction = stream_direction;
187 g_object_notify (call, "audio-stream");
189 else if (stream_id == priv->video->id)
191 priv->video->direction = stream_direction;
192 g_object_notify (call, "video-stream");
197 tp_streamed_media_request_streams_cb (TpChannel *channel,
198 const GPtrArray *streams,
207 DEBUG ("Error requesting streams: %s", error->message);
211 for (i = 0; i < streams->len; i++)
215 guint contact_handle;
218 guint stream_direction;
220 values = g_ptr_array_index (streams, i);
221 stream_id = g_value_get_uint (g_value_array_get_nth (values, 0));
222 contact_handle = g_value_get_uint (g_value_array_get_nth (values, 1));
223 stream_type = g_value_get_uint (g_value_array_get_nth (values, 2));
224 stream_state = g_value_get_uint (g_value_array_get_nth (values, 3));
225 stream_direction = g_value_get_uint (g_value_array_get_nth (values, 4));
227 tp_streamed_media_add_stream (EMPATHY_TP_STREAMED_MEDIA (call), stream_id, contact_handle,
228 stream_type, stream_state, stream_direction);
233 tp_streamed_media_request_streams_for_capabilities (EmpathyTpStreamedMedia *call,
234 EmpathyCapabilities capabilities)
236 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
237 GArray *stream_types;
241 if (capabilities == EMPATHY_CAPABILITIES_UNKNOWN)
242 capabilities = EMPATHY_CAPABILITIES_AUDIO | EMPATHY_CAPABILITIES_VIDEO;
244 DEBUG ("Requesting new stream for capabilities %d",
247 stream_types = g_array_new (FALSE, FALSE, sizeof (guint));
248 handle = empathy_contact_get_handle (priv->contact);
250 if (capabilities & EMPATHY_CAPABILITIES_AUDIO)
252 stream_type = TP_MEDIA_STREAM_TYPE_AUDIO;
253 g_array_append_val (stream_types, stream_type);
255 if (capabilities & EMPATHY_CAPABILITIES_VIDEO)
257 stream_type = TP_MEDIA_STREAM_TYPE_VIDEO;
258 g_array_append_val (stream_types, stream_type);
261 tp_cli_channel_type_streamed_media_call_request_streams (priv->channel, -1,
262 handle, stream_types, tp_streamed_media_request_streams_cb, NULL, NULL,
265 g_array_free (stream_types, TRUE);
269 tp_streamed_media_got_contact_cb (TpConnection *connection,
270 EmpathyContact *contact,
275 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
279 DEBUG ("Error: %s", error->message);
283 priv->contact = g_object_ref (contact);
285 if (priv->status < EMPATHY_TP_STREAMED_MEDIA_STATUS_PENDING)
287 priv->status = EMPATHY_TP_STREAMED_MEDIA_STATUS_PENDING;
288 g_object_notify (G_OBJECT (call), "status");
291 g_object_notify (G_OBJECT (call), "contact");
295 tp_streamed_media_update_status (EmpathyTpStreamedMedia *call)
297 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
298 TpHandle self_handle;
304 self_handle = tp_channel_group_get_self_handle (priv->channel);
305 set = tp_channel_group_get_members (priv->channel);
306 tp_intset_iter_init (&iter, set);
307 while (tp_intset_iter_next (&iter))
309 if (priv->status == EMPATHY_TP_STREAMED_MEDIA_STATUS_PENDING &&
310 ((priv->is_incoming && iter.element == self_handle) ||
311 (!priv->is_incoming && iter.element != self_handle)))
313 priv->status = EMPATHY_TP_STREAMED_MEDIA_STATUS_ACCEPTED;
314 g_object_notify (G_OBJECT (call), "status");
318 g_object_unref (call);
322 tp_streamed_media_channel_invalidated_cb (TpChannel *channel,
326 EmpathyTpStreamedMedia *call)
328 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
330 DEBUG ("Channel invalidated: %s", message);
331 priv->status = EMPATHY_TP_STREAMED_MEDIA_STATUS_CLOSED;
332 g_object_notify (G_OBJECT (call), "status");
336 tp_streamed_media_async_cb (TpProxy *proxy,
342 DEBUG ("Error %s: %s", (gchar *) user_data, error->message);
346 tp_streamed_media_stream_error_cb (TpChannel *channel,
353 EmpathyTpStreamedMedia *self = EMPATHY_TP_STREAMED_MEDIA (call);
354 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (self);
356 DEBUG ("Stream error on stream %u: %s (code: %u)", stream_id, msg,
359 if (priv->audio->id == stream_id)
361 g_signal_emit (call, signals[AUDIO_STREAM_ERROR], 0, error_code, msg);
363 else if (priv->video->id == stream_id)
365 g_signal_emit (call, signals[VIDEO_STREAM_ERROR], 0, error_code, msg);
369 DEBUG ("Unknown stream id: %u", stream_id);
374 tp_streamed_media_constructor (GType type,
375 guint n_construct_params,
376 GObjectConstructParam *construct_params)
379 EmpathyTpStreamedMedia *call;
380 EmpathyTpStreamedMediaPriv *priv;
382 object = G_OBJECT_CLASS (empathy_tp_streamed_media_parent_class)->constructor (type,
383 n_construct_params, construct_params);
385 call = EMPATHY_TP_STREAMED_MEDIA (object);
386 priv = GET_PRIV (call);
388 /* Setup streamed media channel */
389 g_signal_connect (priv->channel, "invalidated",
390 G_CALLBACK (tp_streamed_media_channel_invalidated_cb), call);
391 tp_cli_channel_type_streamed_media_connect_to_stream_added (priv->channel,
392 tp_streamed_media_stream_added_cb, NULL, NULL, G_OBJECT (call), NULL);
393 tp_cli_channel_type_streamed_media_connect_to_stream_removed (priv->channel,
394 tp_streamed_media_stream_removed_cb, NULL, NULL, G_OBJECT (call), NULL);
395 tp_cli_channel_type_streamed_media_connect_to_stream_state_changed (priv->channel,
396 tp_streamed_media_stream_state_changed_cb, NULL, NULL, G_OBJECT (call), NULL);
397 tp_cli_channel_type_streamed_media_connect_to_stream_direction_changed (priv->channel,
398 tp_streamed_media_stream_direction_changed_cb, NULL, NULL, G_OBJECT (call), NULL);
399 tp_cli_channel_type_streamed_media_connect_to_stream_error (priv->channel,
400 tp_streamed_media_stream_error_cb, NULL, NULL, G_OBJECT (call), NULL);
401 tp_cli_channel_type_streamed_media_call_list_streams (priv->channel, -1,
402 tp_streamed_media_request_streams_cb, NULL, NULL, G_OBJECT (call));
404 /* Is the call incoming? */
405 priv->is_incoming = !tp_channel_get_requested (priv->channel);
407 /* Get the remote contact */
408 empathy_tp_contact_factory_get_from_handle (
409 tp_channel_borrow_connection (priv->channel),
410 tp_channel_get_handle (priv->channel, NULL), tp_streamed_media_got_contact_cb,
413 /* Update status when members changes */
414 tp_streamed_media_update_status (call);
415 tp_g_signal_connect_object (priv->channel, "group-members-changed",
416 G_CALLBACK (tp_streamed_media_update_status), call, G_CONNECT_SWAPPED);
421 tp_streamed_media_dispose (GObject *object)
423 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (object);
425 DEBUG ("Disposing: %p, %d", object, priv->dispose_has_run);
427 if (priv->dispose_has_run)
430 priv->dispose_has_run = TRUE;
432 if (priv->channel != NULL)
434 g_signal_handlers_disconnect_by_func (priv->channel,
435 tp_streamed_media_channel_invalidated_cb, object);
437 g_object_unref (priv->channel);
438 priv->channel = NULL;
441 if (priv->contact != NULL)
442 g_object_unref (priv->contact);
444 tp_clear_object (&priv->account);
446 if (G_OBJECT_CLASS (empathy_tp_streamed_media_parent_class)->dispose)
447 G_OBJECT_CLASS (empathy_tp_streamed_media_parent_class)->dispose (object);
451 tp_streamed_media_finalize (GObject *object)
453 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (object);
455 DEBUG ("Finalizing: %p", object);
457 g_slice_free (EmpathyTpStreamedMediaStream, priv->audio);
458 g_slice_free (EmpathyTpStreamedMediaStream, priv->video);
460 (G_OBJECT_CLASS (empathy_tp_streamed_media_parent_class)->finalize) (object);
464 tp_streamed_media_set_property (GObject *object,
469 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (object);
474 priv->account = g_value_dup_object (value);
477 priv->channel = g_value_dup_object (value);
480 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
486 tp_streamed_media_get_property (GObject *object,
491 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (object);
496 g_value_set_object (value, priv->channel);
499 g_value_set_object (value, priv->channel);
502 g_value_set_object (value, priv->contact);
505 g_value_set_uint (value, priv->status);
507 case PROP_AUDIO_STREAM:
508 g_value_set_pointer (value, priv->audio);
510 case PROP_VIDEO_STREAM:
511 g_value_set_pointer (value, priv->video);
514 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
520 empathy_tp_streamed_media_class_init (EmpathyTpStreamedMediaClass *klass)
522 GObjectClass *object_class = G_OBJECT_CLASS (klass);
524 object_class->constructor = tp_streamed_media_constructor;
525 object_class->dispose = tp_streamed_media_dispose;
526 object_class->finalize = tp_streamed_media_finalize;
527 object_class->set_property = tp_streamed_media_set_property;
528 object_class->get_property = tp_streamed_media_get_property;
530 g_type_class_add_private (klass, sizeof (EmpathyTpStreamedMediaPriv));
532 g_object_class_install_property (object_class, PROP_ACCOUNT,
533 g_param_spec_object ("account", "TpAccount", "TpAccount",
535 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
536 G_PARAM_STATIC_STRINGS));
538 g_object_class_install_property (object_class, PROP_CHANNEL,
539 g_param_spec_object ("channel", "channel", "channel",
541 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
542 G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
544 g_object_class_install_property (object_class, PROP_CONTACT,
545 g_param_spec_object ("contact", "Call contact", "Call contact",
546 EMPATHY_TYPE_CONTACT,
547 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
549 g_object_class_install_property (object_class, PROP_STATUS,
550 g_param_spec_uint ("status", "Call status",
551 "Call status", 0, 255, 0, G_PARAM_READABLE | G_PARAM_STATIC_NICK |
552 G_PARAM_STATIC_BLURB));
554 g_object_class_install_property (object_class, PROP_AUDIO_STREAM,
555 g_param_spec_pointer ("audio-stream", "Audio stream data",
557 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
559 g_object_class_install_property (object_class, PROP_VIDEO_STREAM,
560 g_param_spec_pointer ("video-stream", "Video stream data",
562 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
564 signals[AUDIO_STREAM_ERROR] =
565 g_signal_new ("audio-stream-error",
566 G_TYPE_FROM_CLASS (klass),
567 G_SIGNAL_RUN_LAST, 0,
569 _empathy_marshal_VOID__UINT_STRING,
571 2, G_TYPE_UINT, G_TYPE_STRING);
573 signals[VIDEO_STREAM_ERROR] =
574 g_signal_new ("video-stream-error",
575 G_TYPE_FROM_CLASS (klass),
576 G_SIGNAL_RUN_LAST, 0,
578 _empathy_marshal_VOID__UINT_STRING,
580 2, G_TYPE_UINT, G_TYPE_STRING);
584 empathy_tp_streamed_media_init (EmpathyTpStreamedMedia *call)
586 EmpathyTpStreamedMediaPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (call,
587 EMPATHY_TYPE_TP_STREAMED_MEDIA, EmpathyTpStreamedMediaPriv);
590 priv->status = EMPATHY_TP_STREAMED_MEDIA_STATUS_READYING;
591 priv->contact = NULL;
592 priv->audio = g_slice_new0 (EmpathyTpStreamedMediaStream);
593 priv->video = g_slice_new0 (EmpathyTpStreamedMediaStream);
594 priv->audio->exists = FALSE;
595 priv->video->exists = FALSE;
598 EmpathyTpStreamedMedia *
599 empathy_tp_streamed_media_new (TpAccount *account,
602 g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL);
603 g_return_val_if_fail (TP_IS_CHANNEL (channel), NULL);
605 return g_object_new (EMPATHY_TYPE_TP_STREAMED_MEDIA,
612 empathy_tp_streamed_media_accept_incoming_call (EmpathyTpStreamedMedia *call)
614 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
615 TpHandle self_handle;
616 GArray handles = {(gchar *) &self_handle, 1};
618 g_return_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call));
619 g_return_if_fail (priv->status == EMPATHY_TP_STREAMED_MEDIA_STATUS_PENDING);
621 if (!priv->is_incoming)
624 DEBUG ("Accepting incoming call");
626 self_handle = tp_channel_group_get_self_handle (priv->channel);
627 tp_cli_channel_interface_group_call_add_members (priv->channel, -1,
628 &handles, NULL, NULL, NULL, NULL, NULL);
632 empathy_tp_streamed_media_close (EmpathyTpStreamedMedia *call)
634 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
636 g_return_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call));
638 if (priv->status == EMPATHY_TP_STREAMED_MEDIA_STATUS_CLOSED)
641 DEBUG ("Closing channel");
643 tp_cli_channel_call_close (priv->channel, -1,
644 NULL, NULL, NULL, NULL);
646 priv->status = EMPATHY_TP_STREAMED_MEDIA_STATUS_CLOSED;
647 g_object_notify (G_OBJECT (call), "status");
651 empathy_tp_streamed_media_request_video_stream_direction (EmpathyTpStreamedMedia *call,
654 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
657 g_return_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call));
658 g_return_if_fail (priv->status == EMPATHY_TP_STREAMED_MEDIA_STATUS_ACCEPTED);
660 DEBUG ("Requesting video stream direction - is_sending: %d", is_sending);
662 if (!priv->video->exists)
665 tp_streamed_media_request_streams_for_capabilities (call,
666 EMPATHY_CAPABILITIES_VIDEO);
671 new_direction = priv->video->direction | TP_MEDIA_STREAM_DIRECTION_SEND;
673 new_direction = priv->video->direction & ~TP_MEDIA_STREAM_DIRECTION_SEND;
675 tp_cli_channel_type_streamed_media_call_request_stream_direction (priv->channel,
676 -1, priv->video->id, new_direction,
677 (tp_cli_channel_type_streamed_media_callback_for_request_stream_direction)
678 tp_streamed_media_async_cb, NULL, NULL, G_OBJECT (call));
682 empathy_tp_streamed_media_start_tone (EmpathyTpStreamedMedia *call, TpDTMFEvent event)
684 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
686 g_return_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call));
687 g_return_if_fail (priv->status == EMPATHY_TP_STREAMED_MEDIA_STATUS_ACCEPTED);
689 if (!priv->audio->exists)
692 tp_cli_channel_interface_dtmf_call_start_tone (priv->channel, -1,
693 priv->audio->id, event,
694 (tp_cli_channel_interface_dtmf_callback_for_start_tone) tp_streamed_media_async_cb,
695 "starting tone", NULL, G_OBJECT (call));
699 empathy_tp_streamed_media_stop_tone (EmpathyTpStreamedMedia *call)
701 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
703 g_return_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call));
704 g_return_if_fail (priv->status == EMPATHY_TP_STREAMED_MEDIA_STATUS_ACCEPTED);
706 if (!priv->audio->exists)
709 tp_cli_channel_interface_dtmf_call_stop_tone (priv->channel, -1,
711 (tp_cli_channel_interface_dtmf_callback_for_stop_tone) tp_streamed_media_async_cb,
712 "stoping tone", NULL, G_OBJECT (call));
716 empathy_tp_streamed_media_has_dtmf (EmpathyTpStreamedMedia *call)
718 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
720 g_return_val_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call), FALSE);
722 return tp_proxy_has_interface_by_id (priv->channel,
723 TP_IFACE_QUARK_CHANNEL_INTERFACE_DTMF);
727 * empathy_tp_streamed_media_is_receiving_video:
730 * Indicates if the call is receiving video or not.
732 * Returns: %TRUE if the call is currently receiving video, %FALSE otherwise.
735 empathy_tp_streamed_media_is_receiving_video (EmpathyTpStreamedMedia *call)
737 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
739 g_return_val_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call), FALSE);
741 if (!priv->video->exists)
744 return priv->video->direction & TP_MEDIA_STREAM_DIRECTION_RECEIVE ?
749 * empathy_tp_streamed_media_is_sending_video:
752 * Indicates if the call is sending video or not.
754 * Returns: %TRUE if the call is currently sending video, %FALSE otherwise.
757 empathy_tp_streamed_media_is_sending_video (EmpathyTpStreamedMedia *call)
759 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (call);
761 g_return_val_if_fail (EMPATHY_IS_TP_STREAMED_MEDIA (call), FALSE);
763 if (!priv->video->exists)
766 return priv->video->direction & TP_MEDIA_STREAM_DIRECTION_SEND ?
771 empathy_tp_streamed_media_get_connection_manager (EmpathyTpStreamedMedia *self)
773 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (self);
775 return tp_account_get_connection_manager (priv->account);
779 empathy_tp_streamed_media_has_initial_video (EmpathyTpStreamedMedia *self)
781 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (self);
783 gboolean initial_video;
786 if (priv->channel == NULL)
789 g_object_get (priv->channel, "channel-properties", &props, NULL);
791 initial_video = tp_asv_get_boolean (props,
792 TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA ".InitialVideo", &valid);
794 initial_video = FALSE;
796 g_hash_table_unref (props);
797 return initial_video;
801 leave_remove_members_cb (TpChannel *proxy,
804 GObject *weak_object)
806 EmpathyTpStreamedMedia *self = user_data;
811 DEBUG ("RemoveMembers failed (%s); closing the channel", error->message);
812 empathy_tp_streamed_media_close (self);
816 empathy_tp_streamed_media_leave (EmpathyTpStreamedMedia *self)
818 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (self);
819 TpHandle self_handle;
820 GArray array = { (gchar *) &self_handle, 1 };
822 if (!tp_proxy_has_interface_by_id (priv->channel,
823 TP_IFACE_QUARK_CHANNEL_INTERFACE_GROUP))
825 empathy_tp_streamed_media_close (self);
829 self_handle = tp_channel_group_get_self_handle (priv->channel);
830 if (self_handle == 0)
832 /* we are not member of the channel */
833 empathy_tp_streamed_media_close (self);
837 tp_cli_channel_interface_group_call_remove_members (priv->channel, -1, &array,
838 "", leave_remove_members_cb, self, NULL, G_OBJECT (self));
841 EmpathyTpStreamedMediaStatus
842 empathy_tp_streamed_media_get_status (EmpathyTpStreamedMedia *self)
844 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (self);
850 empathy_tp_streamed_media_get_account (EmpathyTpStreamedMedia *self)
852 EmpathyTpStreamedMediaPriv *priv = GET_PRIV (self);
854 return priv->account;