static void
channel_prepared (GObject *proxy, GAsyncResult *prepare_res, gpointer user_data)
{
  GSimpleAsyncResult *res = user_data;
  TfCallChannel *self =
      TF_CALL_CHANNEL (g_async_result_get_source_object (G_ASYNC_RESULT (res)));
  GError *error = NULL;
  GPtrArray *contents;
  guint i;

  if (!tp_proxy_prepare_finish (proxy, prepare_res, &error))
    {
      g_warning ("Preparing the channel: %s",
          error->message);
      g_simple_async_result_take_error (res, error);
      goto out;
    }

  if (tp_call_channel_has_hardware_streaming (TP_CALL_CHANNEL (proxy)))
    {
      g_warning ("Hardware streaming property is TRUE, ignoring");

      g_simple_async_result_set_error (res, TP_ERROR, TP_ERROR_NOT_CAPABLE,
          "This channel does hardware streaming, not handled here");
      goto out;
    }

  contents = tp_call_channel_get_contents (TP_CALL_CHANNEL (proxy));

  self->contents = g_ptr_array_new_with_free_func (free_content);

  for (i = 0; i < contents->len; i++)
    if (!add_content (self, g_ptr_array_index (contents, i)))
      break;

  g_simple_async_result_set_op_res_gboolean (res, TRUE);

out:
  g_simple_async_result_complete (res);
  g_object_unref (res);
  g_object_unref (self);
}
Ejemplo n.º 2
0
/* 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);
    }
}
Ejemplo n.º 3
0
/* 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;
}