2 * empathy-call-handler.c - Source for EmpathyCallHandler
3 * Copyright (C) 2008-2009 Collabora Ltd.
4 * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include <telepathy-glib/account-channel-request.h>
26 #include <telepathy-glib/util.h>
27 #include <telepathy-glib/interfaces.h>
29 #include <telepathy-yell/telepathy-yell.h>
31 #include <telepathy-farstream/telepathy-farstream.h>
33 #include <libempathy/empathy-utils.h>
34 #include <libempathy/empathy-tp-contact-factory.h>
36 #include "empathy-call-handler.h"
37 #include "empathy-call-factory.h"
38 #include "src-marshal.h"
40 #define DEBUG_FLAG EMPATHY_DEBUG_VOIP
41 #include <libempathy/empathy-debug.h>
43 G_DEFINE_TYPE(EmpathyCallHandler, empathy_call_handler, G_TYPE_OBJECT)
57 static guint signals[LAST_SIGNAL] = {0};
60 PROP_CALL_CHANNEL = 1,
65 PROP_SEND_AUDIO_CODEC,
66 PROP_SEND_VIDEO_CODEC,
67 PROP_RECV_AUDIO_CODECS,
68 PROP_RECV_VIDEO_CODECS,
69 PROP_AUDIO_REMOTE_CANDIDATE,
70 PROP_VIDEO_REMOTE_CANDIDATE,
71 PROP_AUDIO_LOCAL_CANDIDATE,
72 PROP_VIDEO_LOCAL_CANDIDATE,
75 /* private structure */
80 /* GArray of TpContacts */
83 gboolean initial_audio;
84 gboolean initial_video;
86 FsCodec *send_audio_codec;
87 FsCodec *send_video_codec;
88 GList *recv_audio_codecs;
89 GList *recv_video_codecs;
90 FsCandidate *audio_remote_candidate;
91 FsCandidate *video_remote_candidate;
92 FsCandidate *audio_local_candidate;
93 FsCandidate *video_local_candidate;
94 } EmpathyCallHandlerPriv;
96 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyCallHandler)
99 empathy_call_handler_dispose (GObject *object)
101 EmpathyCallHandlerPriv *priv = GET_PRIV (object);
103 tp_clear_object (&priv->tfchannel);
104 tp_clear_object (&priv->call);
106 tp_clear_pointer (&priv->members, g_array_unref);
108 G_OBJECT_CLASS (empathy_call_handler_parent_class)->dispose (object);
112 empathy_call_handler_finalize (GObject *object)
114 EmpathyCallHandlerPriv *priv = GET_PRIV (object);
116 fs_codec_destroy (priv->send_audio_codec);
117 fs_codec_destroy (priv->send_video_codec);
118 fs_codec_list_destroy (priv->recv_audio_codecs);
119 fs_codec_list_destroy (priv->recv_video_codecs);
120 fs_candidate_destroy (priv->audio_remote_candidate);
121 fs_candidate_destroy (priv->video_remote_candidate);
122 fs_candidate_destroy (priv->audio_local_candidate);
123 fs_candidate_destroy (priv->video_local_candidate);
125 G_OBJECT_CLASS (empathy_call_handler_parent_class)->finalize (object);
129 empathy_call_handler_init (EmpathyCallHandler *obj)
131 EmpathyCallHandlerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (obj,
132 EMPATHY_TYPE_CALL_HANDLER, EmpathyCallHandlerPriv);
138 on_get_contacts_cb (TpConnection *connection,
140 EmpathyContact * const * contacts,
142 const TpHandle *failed,
145 GObject *weak_object)
147 EmpathyCallHandler *self = EMPATHY_CALL_HANDLER (weak_object);
148 EmpathyCallHandlerPriv *priv = GET_PRIV (self);
151 g_print ("\nGot %d EmpathyContacts\n\n", n_contacts);
154 g_warning ("Failed to get %d EmpathyContacts: %s",
155 n_failed, error->message);
157 priv->members = g_array_sized_new (FALSE, TRUE,
158 sizeof (EmpathyContact *), n_contacts);
160 for (i = 0; i < n_contacts; i++)
161 g_object_ref (contacts[i]);
163 g_array_append_vals (priv->members, contacts, n_contacts);
165 g_object_notify (G_OBJECT (self), "members");
169 on_members_changed_cb (TpyCallChannel *call,
171 EmpathyCallHandler *self)
173 EmpathyCallHandlerPriv *priv = GET_PRIV (self);
180 g_print ("\non_members_changed!\n\n");
184 g_print ("\nmembers is null!\n\n");
188 n_handles = g_hash_table_size (members);
189 g_print ("\nn_handles: %d\n\n", n_handles);
193 handles = g_new0 (TpHandle, n_handles);
195 g_hash_table_iter_init (&iter, members);
196 while (g_hash_table_iter_next (&iter, &key, &value))
197 handles[i++] = GPOINTER_TO_UINT (key);
199 empathy_tp_contact_factory_get_from_handles (
200 tp_channel_borrow_connection (TP_CHANNEL (priv->call)),
203 NULL, NULL, G_OBJECT (self));
209 empathy_call_handler_constructed (GObject *object)
211 EmpathyCallHandler *self = EMPATHY_CALL_HANDLER (object);
212 EmpathyCallHandlerPriv *priv = GET_PRIV (self);
213 // GHashTable *members;
215 g_signal_connect (priv->call, "members-changed",
216 G_CALLBACK (on_members_changed_cb), object);
219 g_object_get (priv->call, "members", &members, NULL);
222 on_members_changed_cb (priv->call, members, self);
227 empathy_call_handler_set_property (GObject *object,
228 guint property_id, const GValue *value, GParamSpec *pspec)
230 EmpathyCallHandlerPriv *priv = GET_PRIV (object);
235 priv->members = g_value_get_boxed (value);
237 case PROP_CALL_CHANNEL:
238 priv->call = g_value_dup_object (value);
240 case PROP_INITIAL_AUDIO:
241 priv->initial_audio = g_value_get_boolean (value);
243 case PROP_INITIAL_VIDEO:
244 priv->initial_video = g_value_get_boolean (value);
247 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
252 empathy_call_handler_get_property (GObject *object,
253 guint property_id, GValue *value, GParamSpec *pspec)
255 EmpathyCallHandlerPriv *priv = GET_PRIV (object);
260 g_value_set_boxed (value, priv->members);
262 case PROP_CALL_CHANNEL:
263 g_value_set_object (value, priv->call);
265 case PROP_INITIAL_AUDIO:
266 g_value_set_boolean (value, priv->initial_audio);
268 case PROP_INITIAL_VIDEO:
269 g_value_set_boolean (value, priv->initial_video);
271 case PROP_SEND_AUDIO_CODEC:
272 g_value_set_boxed (value, priv->send_audio_codec);
274 case PROP_SEND_VIDEO_CODEC:
275 g_value_set_boxed (value, priv->send_video_codec);
277 case PROP_RECV_AUDIO_CODECS:
278 g_value_set_boxed (value, priv->recv_audio_codecs);
280 case PROP_RECV_VIDEO_CODECS:
281 g_value_set_boxed (value, priv->recv_video_codecs);
283 case PROP_AUDIO_REMOTE_CANDIDATE:
284 g_value_set_boxed (value, priv->audio_remote_candidate);
286 case PROP_VIDEO_REMOTE_CANDIDATE:
287 g_value_set_boxed (value, priv->video_remote_candidate);
289 case PROP_AUDIO_LOCAL_CANDIDATE:
290 g_value_set_boxed (value, priv->audio_local_candidate);
292 case PROP_VIDEO_LOCAL_CANDIDATE:
293 g_value_set_boxed (value, priv->video_local_candidate);
296 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
302 empathy_call_handler_class_init (EmpathyCallHandlerClass *klass)
304 GObjectClass *object_class = G_OBJECT_CLASS (klass);
305 GParamSpec *param_spec;
307 g_type_class_add_private (klass, sizeof (EmpathyCallHandlerPriv));
309 object_class->constructed = empathy_call_handler_constructed;
310 object_class->set_property = empathy_call_handler_set_property;
311 object_class->get_property = empathy_call_handler_get_property;
312 object_class->dispose = empathy_call_handler_dispose;
313 object_class->finalize = empathy_call_handler_finalize;
315 param_spec = g_param_spec_boxed ("members",
316 "call members", "The call participants",
318 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
319 g_object_class_install_property (object_class, PROP_MEMBERS, param_spec);
321 param_spec = g_param_spec_object ("call-channel",
322 "call channel", "The call channel",
323 TPY_TYPE_CALL_CHANNEL,
324 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
325 g_object_class_install_property (object_class, PROP_CALL_CHANNEL, param_spec);
327 param_spec = g_param_spec_boolean ("initial-audio",
328 "initial-audio", "Whether the call should start with audio",
330 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
331 g_object_class_install_property (object_class, PROP_INITIAL_AUDIO,
334 param_spec = g_param_spec_boolean ("initial-video",
335 "initial-video", "Whether the call should start with video",
337 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
338 g_object_class_install_property (object_class, PROP_INITIAL_VIDEO,
341 param_spec = g_param_spec_boxed ("send-audio-codec",
342 "send audio codec", "Codec used to encode the outgoing video stream",
344 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
345 g_object_class_install_property (object_class, PROP_SEND_AUDIO_CODEC,
348 param_spec = g_param_spec_boxed ("send-video-codec",
349 "send video codec", "Codec used to encode the outgoing video stream",
351 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
352 g_object_class_install_property (object_class, PROP_SEND_VIDEO_CODEC,
355 param_spec = g_param_spec_boxed ("recv-audio-codecs",
356 "recvs audio codec", "Codecs used to decode the incoming audio stream",
358 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
359 g_object_class_install_property (object_class, PROP_RECV_AUDIO_CODECS,
362 param_spec = g_param_spec_boxed ("recv-video-codecs",
363 "recvs video codec", "Codecs used to decode the incoming video stream",
365 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
366 g_object_class_install_property (object_class, PROP_RECV_VIDEO_CODECS,
369 param_spec = g_param_spec_boxed ("audio-remote-candidate",
370 "audio remote candidate",
371 "Remote candidate used for the audio stream",
373 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
374 g_object_class_install_property (object_class,
375 PROP_AUDIO_REMOTE_CANDIDATE, param_spec);
377 param_spec = g_param_spec_boxed ("video-remote-candidate",
378 "video remote candidate",
379 "Remote candidate used for the video stream",
381 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
382 g_object_class_install_property (object_class,
383 PROP_VIDEO_REMOTE_CANDIDATE, param_spec);
385 param_spec = g_param_spec_boxed ("audio-local-candidate",
386 "audio local candidate",
387 "Local candidate used for the audio stream",
389 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
390 g_object_class_install_property (object_class,
391 PROP_AUDIO_REMOTE_CANDIDATE, param_spec);
393 param_spec = g_param_spec_boxed ("video-local-candidate",
394 "video local candidate",
395 "Local candidate used for the video stream",
397 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
398 g_object_class_install_property (object_class,
399 PROP_VIDEO_REMOTE_CANDIDATE, param_spec);
401 signals[CONFERENCE_ADDED] =
402 g_signal_new ("conference-added", G_TYPE_FROM_CLASS (klass),
403 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
404 g_cclosure_marshal_VOID__OBJECT,
406 1, FS_TYPE_CONFERENCE);
408 signals[CONFERENCE_REMOVED] =
409 g_signal_new ("conference-removed", G_TYPE_FROM_CLASS (klass),
410 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
411 g_cclosure_marshal_VOID__OBJECT,
413 1, FS_TYPE_CONFERENCE);
415 signals[SRC_PAD_ADDED] =
416 g_signal_new ("src-pad-added", G_TYPE_FROM_CLASS (klass),
417 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
418 _src_marshal_BOOLEAN__OBJECT_UINT,
420 2, GST_TYPE_PAD, G_TYPE_UINT);
422 signals[SINK_PAD_ADDED] =
423 g_signal_new ("sink-pad-added", G_TYPE_FROM_CLASS (klass),
424 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
425 _src_marshal_BOOLEAN__OBJECT_UINT,
427 2, GST_TYPE_PAD, G_TYPE_UINT);
429 signals[SINK_PAD_REMOVED] =
430 g_signal_new ("sink-pad-removed", G_TYPE_FROM_CLASS (klass),
431 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
432 _src_marshal_BOOLEAN__OBJECT_UINT,
434 2, GST_TYPE_PAD, G_TYPE_UINT);
437 g_signal_new ("closed", G_TYPE_FROM_CLASS (klass),
438 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
439 g_cclosure_marshal_VOID__VOID,
443 signals[CANDIDATES_CHANGED] =
444 g_signal_new ("candidates-changed", G_TYPE_FROM_CLASS (klass),
445 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
446 g_cclosure_marshal_VOID__UINT,
447 G_TYPE_NONE, 1, G_TYPE_UINT);
451 empathy_call_handler_new_for_channel (TpyCallChannel *call)
453 return EMPATHY_CALL_HANDLER (g_object_new (EMPATHY_TYPE_CALL_HANDLER,
454 "call-channel", call,
455 "initial-video", tpy_call_channel_has_initial_video (call),
460 update_sending_codec (EmpathyCallHandler *self,
464 EmpathyCallHandlerPriv *priv = GET_PRIV (self);
467 if (codec == NULL || session == NULL)
470 g_object_get (session, "media-type", &type, NULL);
472 if (type == FS_MEDIA_TYPE_AUDIO)
474 priv->send_audio_codec = fs_codec_copy (codec);
475 g_object_notify (G_OBJECT (self), "send-audio-codec");
477 else if (type == FS_MEDIA_TYPE_VIDEO)
479 priv->send_video_codec = fs_codec_copy (codec);
480 g_object_notify (G_OBJECT (self), "send-video-codec");
485 update_receiving_codec (EmpathyCallHandler *self,
489 EmpathyCallHandlerPriv *priv = GET_PRIV (self);
493 if (codecs == NULL || stream == NULL)
496 g_object_get (stream, "session", &session, NULL);
500 g_object_get (session, "media-type", &type, NULL);
502 if (type == FS_MEDIA_TYPE_AUDIO)
504 priv->recv_audio_codecs = fs_codec_list_copy (codecs);
505 g_object_notify (G_OBJECT (self), "recv-audio-codecs");
507 else if (type == FS_MEDIA_TYPE_VIDEO)
509 priv->recv_video_codecs = fs_codec_list_copy (codecs);
510 g_object_notify (G_OBJECT (self), "recv-video-codecs");
513 g_object_unref (session);
517 update_candidates (EmpathyCallHandler *self,
518 FsCandidate *remote_candidate,
519 FsCandidate *local_candidate,
522 EmpathyCallHandlerPriv *priv = GET_PRIV (self);
529 g_object_get (stream, "session", &session, NULL);
533 g_object_get (session, "media-type", &type, NULL);
535 if (type == FS_MEDIA_TYPE_AUDIO)
537 if (remote_candidate != NULL)
539 fs_candidate_destroy (priv->audio_remote_candidate);
540 priv->audio_remote_candidate = fs_candidate_copy (remote_candidate);
541 g_object_notify (G_OBJECT (self), "audio-remote-candidate");
544 if (local_candidate != NULL)
546 fs_candidate_destroy (priv->audio_local_candidate);
547 priv->audio_local_candidate = fs_candidate_copy (local_candidate);
548 g_object_notify (G_OBJECT (self), "audio-local-candidate");
551 g_signal_emit (G_OBJECT (self), signals[CANDIDATES_CHANGED], 0,
552 FS_MEDIA_TYPE_AUDIO);
554 else if (type == FS_MEDIA_TYPE_VIDEO)
556 if (remote_candidate != NULL)
558 fs_candidate_destroy (priv->video_remote_candidate);
559 priv->video_remote_candidate = fs_candidate_copy (remote_candidate);
560 g_object_notify (G_OBJECT (self), "video-remote-candidate");
563 if (local_candidate != NULL)
565 fs_candidate_destroy (priv->video_local_candidate);
566 priv->video_local_candidate = fs_candidate_copy (local_candidate);
567 g_object_notify (G_OBJECT (self), "video-local-candidate");
570 g_signal_emit (G_OBJECT (self), signals[CANDIDATES_CHANGED], 0,
571 FS_MEDIA_TYPE_VIDEO);
574 g_object_unref (session);
578 empathy_call_handler_bus_message (EmpathyCallHandler *handler,
579 GstBus *bus, GstMessage *message)
581 EmpathyCallHandlerPriv *priv = GET_PRIV (handler);
582 const GstStructure *s = gst_message_get_structure (message);
584 if (priv->tfchannel == NULL)
588 gst_structure_has_name (s, "farsight-send-codec-changed"))
594 g_print ("empathy_call_handler_bus_message: farsight-send-codec-changed\n");
596 val = gst_structure_get_value (s, "codec");
597 codec = g_value_get_boxed (val);
599 val = gst_structure_get_value (s, "session");
600 session = g_value_get_object (val);
602 update_sending_codec (handler, codec, session);
604 else if (s != NULL &&
605 gst_structure_has_name (s, "farsight-recv-codecs-changed"))
611 g_print ("empathy_call_handler_bus_message: farsight-recv-codecs-changed\n");
613 val = gst_structure_get_value (s, "codecs");
614 codecs = g_value_get_boxed (val);
616 val = gst_structure_get_value (s, "stream");
617 stream = g_value_get_object (val);
619 update_receiving_codec (handler, codecs, stream);
621 else if (s != NULL &&
622 gst_structure_has_name (s, "farsight-new-active-candidate-pair"))
625 FsCandidate *remote_candidate, *local_candidate;
628 g_print ("empathy_call_handler_bus_message: farsight-new-active-candidate-pair\n");
630 val = gst_structure_get_value (s, "remote-candidate");
631 remote_candidate = g_value_get_boxed (val);
633 val = gst_structure_get_value (s, "local-candidate");
634 local_candidate = g_value_get_boxed (val);
636 val = gst_structure_get_value (s, "stream");
637 stream = g_value_get_object (val);
639 update_candidates (handler, remote_candidate, local_candidate, stream);
642 tf_channel_bus_message (priv->tfchannel, message);
646 on_tf_channel_conference_added_cb (TfChannel *tfchannel,
647 GstElement *conference,
648 EmpathyCallHandler *self)
650 g_signal_emit (G_OBJECT (self), signals[CONFERENCE_ADDED], 0,
655 on_tf_channel_conference_removed_cb (TfChannel *tfchannel,
656 FsConference *conference,
657 EmpathyCallHandler *self)
659 g_signal_emit (G_OBJECT (self), signals[CONFERENCE_REMOVED], 0,
660 GST_ELEMENT (conference));
664 src_pad_added_error_idle (gpointer data)
666 TfContent *content = data;
668 tf_content_error (content, 0 /* FIXME */,
669 "Could not link sink", NULL);
670 g_object_unref (content);
676 on_tf_content_src_pad_added_cb (TfContent *content,
681 EmpathyCallHandler *handler)
686 g_object_get (content, "media-type", &media_type, NULL);
688 g_signal_emit (G_OBJECT (handler), signals[SRC_PAD_ADDED], 0,
689 pad, media_type, &retval);
692 g_idle_add (src_pad_added_error_idle, g_object_ref (content));
696 on_tf_channel_content_added_cb (TfChannel *tfchannel,
698 EmpathyCallHandler *handler)
703 // FsStream *fs_stream;
708 g_signal_connect (content, "src-pad-added",
709 G_CALLBACK (on_tf_content_src_pad_added_cb), handler);
711 g_signal_connect (content, "start-sending",
712 G_CALLBACK (on_tf_content_start_sending_cb), handler);
713 g_signal_connect (content, "stop-sending",
714 G_CALLBACK (on_tf_content_stop_sending_cb), handler);
717 g_object_get (content, "media-type", &mtype,
718 "sink-pad", &spad, NULL);
720 g_signal_emit (G_OBJECT (handler), signals[SINK_PAD_ADDED], 0,
721 spad, mtype, &retval);
724 tf_content_error (content, 0 /* FIXME */,
725 "Could not link source", NULL);
727 /* Get sending codec */
728 g_object_get (content, "fs-session", &session, NULL);
729 g_object_get (session, "current-send-codec", &codec, NULL);
731 update_sending_codec (handler, codec, session);
733 tp_clear_object (&session);
734 tp_clear_object (&codec);
736 /* Get receiving codec */
738 g_object_get (content, "fs-stream", &fs_stream, NULL);
739 g_object_get (fs_stream, "current-recv-codecs", &codecs, NULL);
741 update_receiving_codec (handler, codecs, fs_stream);
743 fs_codec_list_destroy (codecs);
744 tp_clear_object (&fs_stream);
747 gst_object_unref (spad);
751 on_tf_channel_content_removed_cb (TfChannel *tfchannel,
753 EmpathyCallHandler *handler)
759 g_print ("removing content\n");
761 g_object_get (content, "media-type", &mtype,
762 "sink-pad", &spad, NULL);
764 g_signal_emit (G_OBJECT (handler), signals[SINK_PAD_REMOVED], 0,
765 spad, mtype, &retval);
769 g_warning ("Could not remove content!");
771 tf_content_error (content, 0 /* FIXME */,
772 "Could not link source", NULL);
777 on_tf_channel_closed_cb (TfChannel *tfchannel,
778 EmpathyCallHandler *handler)
780 g_signal_emit (G_OBJECT (handler), signals[CLOSED], 0);
784 on_tf_channel_ready (GObject *source,
785 GAsyncResult *result,
788 EmpathyCallHandler *self = EMPATHY_CALL_HANDLER (user_data);
789 EmpathyCallHandlerPriv *priv = GET_PRIV (self);
790 GError *error = NULL;
792 priv->tfchannel = TF_CHANNEL (g_async_initable_new_finish (
793 G_ASYNC_INITABLE (source), result, NULL));
795 if (priv->tfchannel == NULL)
797 g_warning ("Failed to create Farstream channel: %s", error->message);
798 g_error_free (error);
802 /* Set up the telepathy farstream channel */
803 g_signal_connect (priv->tfchannel, "closed",
804 G_CALLBACK (on_tf_channel_closed_cb), self);
805 g_signal_connect (priv->tfchannel, "fs-conference-added",
806 G_CALLBACK (on_tf_channel_conference_added_cb), self);
807 g_signal_connect (priv->tfchannel, "fs-conference-removed",
808 G_CALLBACK (on_tf_channel_conference_removed_cb), self);
809 g_signal_connect (priv->tfchannel, "content-added",
810 G_CALLBACK (on_tf_channel_content_added_cb), self);
811 g_signal_connect (priv->tfchannel, "content-removed",
812 G_CALLBACK (on_tf_channel_content_removed_cb), self);
816 empathy_call_handler_start_tpfs (EmpathyCallHandler *self)
818 EmpathyCallHandlerPriv *priv = GET_PRIV (self);
820 tf_channel_new_async (TP_CHANNEL (priv->call),
821 on_tf_channel_ready, self);
826 empathy_call_handler_request_cb (GObject *source,
827 GAsyncResult *result,
830 EmpathyCallHandler *self = EMPATHY_CALL_HANDLER (user_data);
831 EmpathyCallHandlerPriv *priv = GET_PRIV (self);
833 GError *error = NULL;
834 TpAccountChannelRequest *req = TP_ACCOUNT_CHANNEL_REQUEST (source);
836 channel = tp_account_channel_request_create_and_handle_channel_finish (req,
837 result, NULL, &error);
840 DEBUG ("Failed to create the channel: %s", error->message);
841 g_error_free (error);
845 if (!TPY_IS_CALL_CHANNEL (channel))
847 DEBUG ("The channel is not a Call channel!");
851 priv->call = TPY_CALL_CHANNEL (channel);
853 g_object_notify (G_OBJECT (self), "call-channel");
855 empathy_call_handler_start_tpfs (self);
860 on_call_accepted_cb (GObject *source_object,
864 TpyCallChannel *call = TPY_CALL_CHANNEL (source_object);
865 GError *error = NULL;
867 if (!tpy_call_channel_accept_finish (call, res, &error))
869 g_warning ("could not accept Call: %s", error->message);
870 g_error_free (error);
875 empathy_call_handler_start_call (EmpathyCallHandler *handler,
878 EmpathyCallHandlerPriv *priv = GET_PRIV (handler);
879 /*TpAccountChannelRequest *req;
881 GHashTable *request;*/
883 if (priv->call != NULL)
885 empathy_call_handler_start_tpfs (handler);
886 tpy_call_channel_accept_async (priv->call, on_call_accepted_cb, NULL);
891 g_warning ("No Call channel!");
895 /* No TpyCallChannel (we are redialing). Request a new call channel */
896 g_assert (priv->contact != NULL);
898 account = empathy_contact_get_account (priv->contact);
899 request = empathy_call_create_call_request (priv->contact,
900 priv->initial_audio, priv->initial_video);
902 req = tp_account_channel_request_new (account, request, timestamp);
904 tp_account_channel_request_create_and_handle_channel_async (req, NULL,
905 empathy_call_handler_request_cb, handler);
907 g_object_unref (req);
908 g_hash_table_unref (request);
913 * empathy_call_handler_stop_call:
914 * @handler: an #EmpathyCallHandler
916 * Closes the #EmpathyCallHandler's call and frees its resources.
919 empathy_call_handler_stop_call (EmpathyCallHandler *handler)
921 EmpathyCallHandlerPriv *priv = GET_PRIV (handler);
923 if (priv->call != NULL)
925 tpy_call_channel_hangup_async (priv->call,
926 TPY_CALL_STATE_CHANGE_REASON_USER_REQUESTED,
928 tp_clear_object (&priv->call);
933 * empathy_call_handler_has_initial_video:
934 * @handler: an #EmpathyCallHandler
936 * Return %TRUE if the call managed by this #EmpathyCallHandler was
937 * created with video enabled
939 * Return value: %TRUE if the call was created as a video conversation.
942 empathy_call_handler_has_initial_video (EmpathyCallHandler *handler)
944 EmpathyCallHandlerPriv *priv = GET_PRIV (handler);
946 return priv->initial_video;
950 empathy_call_handler_get_send_audio_codec (EmpathyCallHandler *self)
952 EmpathyCallHandlerPriv *priv = GET_PRIV (self);
954 return priv->send_audio_codec;
958 empathy_call_handler_get_send_video_codec (EmpathyCallHandler *self)
960 EmpathyCallHandlerPriv *priv = GET_PRIV (self);
962 return priv->send_video_codec;
966 empathy_call_handler_get_recv_audio_codecs (EmpathyCallHandler *self)
968 EmpathyCallHandlerPriv *priv = GET_PRIV (self);
970 return priv->recv_audio_codecs;
974 empathy_call_handler_get_recv_video_codecs (EmpathyCallHandler *self)
976 EmpathyCallHandlerPriv *priv = GET_PRIV (self);
978 return priv->recv_video_codecs;
982 empathy_call_handler_get_audio_remote_candidate (
983 EmpathyCallHandler *self)
985 EmpathyCallHandlerPriv *priv = GET_PRIV (self);
987 return priv->audio_remote_candidate;
991 empathy_call_handler_get_audio_local_candidate (
992 EmpathyCallHandler *self)
994 EmpathyCallHandlerPriv *priv = GET_PRIV (self);
996 return priv->audio_local_candidate;
1000 empathy_call_handler_get_video_remote_candidate (
1001 EmpathyCallHandler *self)
1003 EmpathyCallHandlerPriv *priv = GET_PRIV (self);
1005 return priv->video_remote_candidate;
1009 empathy_call_handler_get_video_local_candidate (
1010 EmpathyCallHandler *self)
1012 EmpathyCallHandlerPriv *priv = GET_PRIV (self);
1014 return priv->video_local_candidate;