Ejemplo n.º 1
0
struct SimpleTestStream *
simple_conference_add_stream (
    struct SimpleTestConference *dat,
    struct SimpleTestConference *target,
    const gchar *transmitter,
    guint st_param_count,
    GParameter *st_params)
{
  struct SimpleTestStream *st = g_new0 (struct SimpleTestStream, 1);
  GError *error = NULL;

  st->dat = dat;
  st->target = target;

  st->participant = fs_conference_new_participant (
      FS_CONFERENCE (dat->conference), NULL, &error);
  if (error)
    fail ("Error while creating new participant (%d): %s",
        error->code, error->message);
  fail_if (st->participant == NULL, "Could not make participant, but no GError!");

  st->stream = fs_session_new_stream (dat->session, st->participant,
      FS_DIRECTION_BOTH, transmitter, st_param_count, st_params, &error);
  if (error)
    fail ("Error while creating new stream (%d): %s",
        error->code, error->message);
  fail_if (st->stream == NULL, "Could not make stream, but no GError!");

  g_object_set_data (G_OBJECT (st->stream), "SimpleTestStream", st);

  dat->streams = g_list_append (dat->streams, st);

  return st;
}
FsParticipant *
_tf_call_channel_get_participant (TfCallChannel *channel,
    FsConference *fsconference,
    guint contact_handle,
    GError **error)
{
  guint i;
  struct CallParticipant *cp;
  FsParticipant *p;

  for (i = 0; i < channel->participants->len; i++)
    {
      cp = g_ptr_array_index (channel->participants, i);

      if (cp->fsconference == fsconference &&
          cp->handle == contact_handle)
        {
          cp->use_count++;
          return g_object_ref (cp->fsparticipant);
        }
    }

  p = fs_conference_new_participant (fsconference, error);
  if (!p)
    return NULL;

  cp = g_slice_new (struct CallParticipant);
  cp->use_count = 1;
  cp->handle = contact_handle;
  cp->fsconference = gst_object_ref (fsconference);
  cp->fsparticipant = p;
  g_ptr_array_add (channel->participants, cp);

  return p;
}
Ejemplo n.º 3
0
int main (int argc, char **argv)
{
  GMainLoop *loop = NULL;
  GstElement *pipeline = NULL;
  GstBus *bus = NULL;
  GstElement *conf = NULL;
  FsParticipant *part = NULL;
  GError *error = NULL;
  GInputStream *istream = NULL;
  gchar *send_socket, *recv_socket;
  TestSession *ses;

  gst_init (&argc, &argv);

  if (argc != 3)
  {
    g_print ("Usage: %s <send socket> <recv_socket>\n", argv[0]);
    return 1;
  }

  send_socket = argv[1];
  recv_socket = argv[2];

  if (unlink (send_socket) < 0 && errno != ENOENT)
  {
    g_print ("Could not delete send or recv sockets");
    return 2;
  }

  g_print ("Press ENTER when the other side is ready\n");

  loop = g_main_loop_new (NULL, FALSE);

  pipeline = gst_pipeline_new (NULL);

  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_watch (bus, async_bus_cb, pipeline);
  gst_object_unref (bus);

  conf = gst_element_factory_make ("fsrtpconference", NULL);
  g_assert (conf);

  part = fs_conference_new_participant (FS_CONFERENCE (conf), &error);
  print_error (error);
  g_assert (part);

  g_assert (gst_bin_add (GST_BIN (pipeline), conf));

  istream = g_unix_input_stream_new (0, FALSE);

  ses = add_audio_session (pipeline, FS_CONFERENCE (conf), 1, part, send_socket,
      recv_socket);

  g_input_stream_skip_async (istream, 1, G_PRIORITY_DEFAULT, NULL, skipped_cb,
      ses);

  g_assert (gst_element_set_state (pipeline, GST_STATE_PLAYING) !=
      GST_STATE_CHANGE_FAILURE);
  g_main_loop_run (loop);

  g_assert (gst_element_set_state (pipeline, GST_STATE_NULL) !=
      GST_STATE_CHANGE_FAILURE);

  g_object_unref (part);
  g_object_unref (istream);

  free_session (ses);

  gst_object_unref (pipeline);
  g_main_loop_unref (loop);

  return 0;
}
Ejemplo n.º 4
0
static void
one_way (GCallback havedata_handler, gpointer data)
{
  FsParticipant *participant = NULL;
  GError *error = NULL;
  gint port = 0;
  GstElement *recv_pipeline;
  GList *candidates = NULL;
  GstBus *bus = NULL;

  dtmf_id = 105;
  digit = 0;
  sending = FALSE;
  received = FALSE;
  ready_to_send = FALSE;

  loop = g_main_loop_new (NULL, FALSE);

  dat = setup_simple_conference (1, "fsrtpconference", "tester@123445");

  bus = gst_element_get_bus (dat->pipeline);
  gst_bus_add_watch (bus, _bus_callback, dat);
  gst_object_unref (bus);

  g_idle_add (_start_pipeline, dat);

  participant = fs_conference_new_participant (
      FS_CONFERENCE (dat->conference), "*****@*****.**", &error);
  if (error)
    ts_fail ("Error while creating new participant (%d): %s",
        error->code, error->message);
  ts_fail_if (dat->session == NULL,
      "Could not make participant, but no GError!");

  stream = fs_session_new_stream (dat->session, participant,
      FS_DIRECTION_SEND, "rawudp", 0, NULL, &error);
  if (error)
    ts_fail ("Error while creating new stream (%d): %s",
        error->code, error->message);
  ts_fail_if (stream == NULL, "Could not make stream, but no GError!");

  recv_pipeline = build_recv_pipeline (havedata_handler, NULL, &port);

  GST_DEBUG ("port is %d", port);

  candidates = g_list_prepend (NULL,
      fs_candidate_new ("1", FS_COMPONENT_RTP, FS_CANDIDATE_TYPE_HOST,
          FS_NETWORK_PROTOCOL_UDP, "127.0.0.1", port));
  ts_fail_unless (fs_stream_set_remote_candidates (stream, candidates, &error),
      "Could not set remote candidate");
  fs_candidate_list_destroy (candidates);

  set_codecs (dat, stream);

  setup_fakesrc (dat);

  g_main_loop_run (loop);

  gst_element_set_state (dat->pipeline, GST_STATE_NULL);
  gst_element_set_state (recv_pipeline, GST_STATE_NULL);

  cleanup_simple_conference (dat);
  gst_object_unref (recv_pipeline);

  g_main_loop_unref (loop);
}
Ejemplo n.º 5
0
int main (int argc, char **argv)
{
  GMainLoop *loop = NULL;
  GstElement *pipeline = NULL;
  GstBus *bus = NULL;
  const gchar *remoteip;
  guint localport = 0;
  guint remoteport = 0;
  GstElement *conf = NULL;
  FsParticipant *part = NULL;
  GError *error = NULL;

  gst_init (&argc, &argv);

  if (argc != 4)
  {
    g_print ("Usage: %s <local port> <remoteip> <remoteport>\n",
        argv[0]);
    return 1;
  }

  localport = atoi (argv[1]);
  remoteip = argv[2];
  remoteport = atoi (argv[3]);

  if (!localport || !remoteip || !remoteport)
  {
    g_print ("Usage: %s <local port> <remoteip> <remoteport>\n",
        argv[0]);
    return 2;
  }

  loop = g_main_loop_new (NULL, FALSE);

  pipeline = gst_pipeline_new (NULL);

  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_watch (bus, async_bus_cb, pipeline);
  gst_object_unref (bus);

  conf = gst_element_factory_make ("fsrtpconference", NULL);
  g_assert (conf);

  part = fs_conference_new_participant (FS_CONFERENCE (conf), "test@ignore",
      &error);
  print_error (error);
  g_assert (part);

  g_assert (gst_bin_add (GST_BIN (pipeline), conf));


  add_audio_session (pipeline, FS_CONFERENCE (conf), 1, part, localport,
      remoteip, remoteport);


  g_assert (gst_element_set_state (pipeline, GST_STATE_PLAYING) !=
      GST_STATE_CHANGE_FAILURE);

  g_main_loop_run (loop);

  g_assert (gst_element_set_state (pipeline, GST_STATE_NULL) !=
      GST_STATE_CHANGE_FAILURE);

  g_object_unref (part);

  gst_object_unref (pipeline);
  g_main_loop_unref (loop);

  return 0;
}
Ejemplo n.º 6
0
struct SimpleMsnConference *
setup_conference (FsStreamDirection dir, struct SimpleMsnConference *target)
{
  struct SimpleMsnConference *dat = g_new0 (struct SimpleMsnConference, 1);
  GError *error = NULL;
  GstBus *bus;
  GParameter param = {NULL, {0}};
  gint n_params = 0;
  guint tos;

  dat->target = target;
  dat->direction = dir;

  dat->pipeline = gst_pipeline_new (NULL);

  bus = gst_element_get_bus (dat->pipeline);
  gst_bus_add_watch (bus, bus_watch, dat);
  gst_object_unref (bus);

  if (dir == FS_DIRECTION_SEND)
    dat->conf = FS_CONFERENCE (
        gst_element_factory_make ("fsmsncamsendconference", NULL));
  else
    dat->conf = FS_CONFERENCE (
        gst_element_factory_make ("fsmsncamrecvconference", NULL));
  ts_fail_unless (dat->conf != NULL);

  ts_fail_unless (gst_bin_add (GST_BIN (dat->pipeline),
          GST_ELEMENT (dat->conf)));

  dat->part = fs_conference_new_participant (dat->conf, &error);
  ts_fail_unless (error == NULL, "Error: %s", error ? error->message: "");
  ts_fail_unless (dat->part != NULL);

  dat->session = fs_conference_new_session (dat->conf, FS_MEDIA_TYPE_VIDEO,
      &error);
  ts_fail_unless (dat->session != NULL, "Session create error: %s:",
      error ? error->message : "No GError");
  ts_fail_unless (error == NULL);

  g_object_set (dat->session, "tos", 2, NULL);
  g_object_get (dat->session, "tos", &tos, NULL);
  ts_fail_unless (tos == 2);

  if (dir == FS_DIRECTION_SEND)
  {
    GstPad *sinkpad, *srcpad;
    GstElement *src;
    src = gst_element_factory_make ("videotestsrc", NULL);
    ts_fail_unless (src != NULL);
    g_object_set (src, "is-live", TRUE, NULL);
    ts_fail_unless (gst_bin_add (GST_BIN (dat->pipeline),
            GST_ELEMENT (src)));

    g_object_get (dat->session, "sink-pad", &sinkpad, NULL);
    ts_fail_if (sinkpad == NULL);
    srcpad = gst_element_get_static_pad (src, "src");
    ts_fail_if (srcpad == NULL);

    ts_fail_if (GST_PAD_LINK_FAILED (gst_pad_link ( srcpad, sinkpad)));
    gst_object_unref (srcpad);
    gst_object_unref (sinkpad);
  }

  if (target)
  {
    guint session_id = 0;
    n_params = 1;
    g_object_get (target->stream, "session-id", &session_id, NULL);
    ts_fail_unless (session_id >= 9000 && session_id < 10000);
    param.name = "session-id";
    g_value_init (&param.value, G_TYPE_UINT);
    g_value_set_uint (&param.value, session_id);
  }

  dat->stream = fs_session_new_stream (dat->session, dat->part, dir, &error);
  ts_fail_unless (dat->stream != NULL);
  ts_fail_unless (error == NULL);

  fail_unless (fs_stream_set_transmitter (dat->stream, NULL, &param, n_params,
          &error));
  fail_unless (error == NULL);

  g_signal_connect (dat->stream, "src-pad-added",
      G_CALLBACK (stream_src_pad_added), dat);

  ts_fail_if (gst_element_set_state (dat->pipeline, GST_STATE_PLAYING) ==
      GST_STATE_CHANGE_FAILURE);

  return dat;
}