示例#1
0
static void
gst_switch_server_run (GstSwitchServer * srv)
{
  srv->main_loop = g_main_loop_new (NULL, TRUE);

  if (!gst_switch_server_prepare_composite (srv, DEFAULT_COMPOSE_MODE))
    goto error_prepare;

  srv->video_acceptor = g_thread_new ("switch-server-video-acceptor",
      (GThreadFunc) gst_switch_server_video_acceptor, srv);

  srv->audio_acceptor = g_thread_new ("switch-server-audio-acceptor",
      (GThreadFunc) gst_switch_server_audio_acceptor, srv);

  srv->controller_thread = g_thread_new ("switch-server-controller",
      (GThreadFunc) gst_switch_server_controller, srv);

  gst_switch_server_prepare_bus_controller (srv);

  g_main_loop_run (srv->main_loop);

  g_thread_join (srv->video_acceptor);
  g_thread_join (srv->audio_acceptor);
  g_thread_join (srv->controller_thread);
  return;

  /* Errors Handling */
 error_prepare:
  {
    ERROR ("error preparing server");
    return;
  }
}
示例#2
0
/**
 * gst_switch_server_run:
 *
 * Running the GstSwitchServer instance.
 */
static void
gst_switch_server_run (GstSwitchServer * srv)
{
  GST_SWITCH_SERVER_LOCK_MAIN_LOOP (srv);
  srv->main_loop = g_main_loop_new (NULL, TRUE);
  GST_SWITCH_SERVER_UNLOCK_MAIN_LOOP (srv);

  //g_timeout_add_seconds (15, &timeout, srv);

  if (!gst_switch_server_prepare_composite (srv, DEFAULT_COMPOSE_MODE))
    goto error_prepare_composite;

  if (!gst_switch_server_create_output (srv))
    goto error_prepare_output;

  if (!gst_switch_server_create_recorder (srv))
    goto error_prepare_recorder;

  srv->video_acceptor = g_thread_new ("switch-server-video-acceptor",
      (GThreadFunc)
      gst_switch_server_video_acceptor, srv);

  srv->audio_acceptor = g_thread_new ("switch-server-audio-acceptor",
      (GThreadFunc)
      gst_switch_server_audio_acceptor, srv);

  srv->controller_thread = g_thread_new ("switch-server-controller",
      (GThreadFunc)
      gst_switch_server_controller, srv);

  // TODO: quit the server if controller is not ready
  gst_switch_server_prepare_bus_controller (srv);

  g_main_loop_run (srv->main_loop);

  GST_SWITCH_SERVER_LOCK_MAIN_LOOP (srv);
  srv->main_loop = NULL;
  GST_SWITCH_SERVER_UNLOCK_MAIN_LOOP (srv);

/*
  g_thread_join (srv->video_acceptor);
  g_thread_join (srv->audio_acceptor);
  g_thread_join (srv->controller_thread);
*/
  return;

  /* Errors Handling */
error_prepare_composite:
  {
    ERROR ("error preparing server");
    return;
  }
error_prepare_output:
  {
    ERROR ("error preparing server");
    return;
  }
error_prepare_recorder:
  {
    ERROR ("error preparing server");
    return;
  }
}