From 2104fdf4bd3b020e2dca0d397ce445423f463704 Mon Sep 17 00:00:00 2001 From: Emilio Pozuelo Monfort Date: Wed, 9 Feb 2011 16:48:34 +0000 Subject: Move a couple of call-related functions to empathy-utils.h Since the rest of the call stuff will only be compiled for empathy-av so we don't link every binary against farsight. --- libempathy/empathy-utils.c | 62 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) (limited to 'libempathy/empathy-utils.c') diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c index d089c6fd5..b23071a29 100644 --- a/libempathy/empathy-utils.c +++ b/libempathy/empathy-utils.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2003-2007 Imendio AB - * Copyright (C) 2007-2008 Collabora Ltd. + * Copyright (C) 2007-2011 Collabora Ltd. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -237,6 +237,66 @@ empathy_xml_node_find_child_prop_value (xmlNodePtr node, return found; } +GHashTable * +empathy_call_create_streamed_media_request (EmpathyContact *contact, + gboolean initial_audio, + gboolean initial_video) +{ + return tp_asv_new ( + TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, + TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA, + TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, + TP_HANDLE_TYPE_CONTACT, + TP_PROP_CHANNEL_TARGET_HANDLE, G_TYPE_UINT, + empathy_contact_get_handle (contact), + TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_AUDIO, G_TYPE_BOOLEAN, + initial_audio, + TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_VIDEO, G_TYPE_BOOLEAN, + initial_video, + NULL); +} + +static void +create_media_channel_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + GError *error = NULL; + + if (!tp_account_channel_request_create_channel_finish (TP_ACCOUNT_CHANNEL_REQUEST (source), + result, + &error)) { + DEBUG ("Failed to create StreamedMedia channel: %s", error->message); + g_error_free (error); + } +} + +void +empathy_call_new_with_streams (EmpathyContact *contact, + gboolean initial_audio, + gboolean initial_video, + gint64 timestamp) +{ + GHashTable *request; + TpAccount *account; + TpAccountChannelRequest *req; + + request = empathy_call_create_streamed_media_request (contact, + initial_audio, + initial_video); + + account = empathy_contact_get_account (contact); + + req = tp_account_channel_request_new (account, request, timestamp); + + tp_account_channel_request_create_channel_async (req, NULL, NULL, + create_media_channel_cb, + NULL); + + g_hash_table_unref (request); + g_object_unref (req); +} + const gchar * empathy_presence_get_default_message (TpConnectionPresenceType presence) { -- cgit v1.2.3