/* Copied from telepathy-yell call-channel.c */ void empathy_call_channel_send_video (TpCallChannel *self, gboolean send) { GPtrArray *contents; gboolean found = FALSE; guint i; g_return_if_fail (TP_IS_CALL_CHANNEL (self)); /* Loop over all the contents, if some of them a video set all their * streams to sending, otherwise request a video channel in case we want to * sent */ contents = tp_call_channel_get_contents (self); for (i = 0 ; i < contents->len ; i++) { TpCallContent *content = g_ptr_array_index (contents, i); if (tp_call_content_get_media_type (content) == TP_MEDIA_STREAM_TYPE_VIDEO) { GPtrArray *streams; guint j; found = TRUE; streams = tp_call_content_get_streams (content); for (j = 0; j < streams->len; j++) { TpCallStream *stream = g_ptr_array_index (streams, j); tp_call_stream_set_sending_async (stream, send, NULL, NULL); } } } if (send && !found) { tp_call_channel_add_content_async (self, "video", TP_MEDIA_STREAM_TYPE_VIDEO, TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL, NULL, NULL); } }
static void empathy_call_handler_request_cb (GObject *source, GAsyncResult *result, gpointer user_data) { EmpathyCallHandler *self = EMPATHY_CALL_HANDLER (user_data); EmpathyCallHandlerPriv *priv = GET_PRIV (self); TpChannel *channel; GError *error = NULL; TpAccountChannelRequest *req = TP_ACCOUNT_CHANNEL_REQUEST (source); channel = tp_account_channel_request_create_and_handle_channel_finish (req, result, NULL, &error); if (channel == NULL) { DEBUG ("Failed to create the channel: %s", error->message); g_error_free (error); return; } if (!TP_IS_CALL_CHANNEL (channel)) { DEBUG ("The channel is not a Call channel!"); return; } priv->call = TP_CALL_CHANNEL (channel); tp_g_signal_connect_object (priv->call, "state-changed", G_CALLBACK (on_call_state_changed_cb), self, 0); tp_g_signal_connect_object (priv->call, "invalidated", G_CALLBACK (on_call_invalidated_cb), self, 0); g_object_notify (G_OBJECT (self), "call-channel"); empathy_call_handler_start_tpfs (self); tp_call_channel_accept_async (priv->call, on_call_accepted_cb, NULL); }
/* Copied from telepathy-yell call-channel.c */ TpSendingState empathy_call_channel_get_video_state (TpCallChannel *self) { TpSendingState result = TP_SENDING_STATE_NONE; GPtrArray *contents; guint i; g_return_val_if_fail (TP_IS_CALL_CHANNEL (self), TP_SENDING_STATE_NONE); contents = tp_call_channel_get_contents (self); for (i = 0 ; i < contents->len ; i++) { TpCallContent *content = g_ptr_array_index (contents, i); if (tp_call_content_get_media_type (content) == TP_MEDIA_STREAM_TYPE_VIDEO) { GPtrArray *streams; guint j; streams = tp_call_content_get_streams (content); for (j = 0; j < streams->len; j++) { TpCallStream *stream = g_ptr_array_index (streams, j); TpSendingState state; state = tp_call_stream_get_local_sending_state (stream); if (state != TP_SENDING_STATE_PENDING_STOP_SENDING && state > result) result = state; } } } return result; }