コード例 #1
0
ファイル: testegl.c プロジェクト: ryumiel/gst-omx
static void
update_image (APP_STATE_T * state, GstBuffer * buffer)
{
    GstVideoGLTextureUploadMeta *meta = NULL;

    if (state->current_buffer) {
        gst_buffer_unref (state->current_buffer);
    } else {
        /* Setup the model world */
        init_model_proj (state);
        TRACE_VC_MEMORY ("after init_model_proj");

        /* initialize the OGLES texture(s) */
        init_textures (state, buffer);
        TRACE_VC_MEMORY ("after init_textures");
    }
    state->current_buffer = gst_buffer_ref (buffer);

    TRACE_VC_MEMORY_ONCE_FOR_ID ("before GstVideoGLTextureUploadMeta", gid0);

    if (state->can_avoid_upload) {
        GstMemory *mem = gst_buffer_peek_memory (state->current_buffer, 0);
        g_assert (gst_is_gl_memory (mem));
        state->tex = ((GstGLMemory *) mem)->tex_id;
    } else if ((meta = gst_buffer_get_video_gl_texture_upload_meta (buffer))) {
        if (meta->n_textures == 1) {
            guint ids[4] = { state->tex, 0, 0, 0 };
            if (!gst_video_gl_texture_upload_meta_upload (meta, ids)) {
                GST_WARNING ("failed to upload to texture");
            }
        }
    }

    TRACE_VC_MEMORY_ONCE_FOR_ID ("after GstVideoGLTextureUploadMeta", gid1);
}
コード例 #2
0
ファイル: testegl.c プロジェクト: 01org/gst-omx
static void
open_ogl (void)
{
  TRACE_VC_MEMORY ("state 0");

#if defined (USE_OMX_TARGET_RPI) && defined (HAVE_GST_EGL)
  bcm_host_init ();
  TRACE_VC_MEMORY ("after bcm_host_init");
#endif

  /* Start OpenGLES */
  init_ogl (state);
  TRACE_VC_MEMORY ("after init_ogl");

  /* Wrap the EGL display */
  state->gst_display = gst_egl_display_new (state->display, NULL);

  /* Setup the model world */
  init_model_proj (state);
  TRACE_VC_MEMORY ("after init_model_proj");

  /* initialize the OGLES texture(s) */
  init_textures (state);
  TRACE_VC_MEMORY ("after init_textures");
}
コード例 #3
0
ファイル: testegl.c プロジェクト: ryumiel/gst-omx
static void
open_ogl (void)
{
    TRACE_VC_MEMORY ("state 0");

#if defined (USE_OMX_TARGET_RPI)
    bcm_host_init ();
    TRACE_VC_MEMORY ("after bcm_host_init");
#endif

    /* Create surface and gl context */
    init_ogl (state);
    TRACE_VC_MEMORY ("after init_ogl");

    /* Wrap the EGLDisplay to GstGLDisplayEGL */
    state->gst_display = gst_gl_display_egl_new_with_egl_display (state->display);
}
コード例 #4
0
ファイル: testegl.c プロジェクト: 01org/gst-omx
int
main (int argc, char **argv)
{
  GstBus *bus;
  GOptionContext *ctx;
  GIOChannel *io_stdin;
  GError *err = NULL;
  gboolean res;
  GOptionEntry options[] = {
    {NULL}
  };
  GThread *rthread;

  /* Clear application state */
  memset (state, 0, sizeof (*state));
  state->animate = TRUE;

  /* must initialise the threading system before using any other GLib funtion */
  if (!g_thread_supported ())
    g_thread_init (NULL);

  ctx = g_option_context_new ("[ADDITIONAL ARGUMENTS]");
  g_option_context_add_main_entries (ctx, options, NULL);
  g_option_context_add_group (ctx, gst_init_get_option_group ());
  if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
    g_print ("Error initializing: %s\n", GST_STR_NULL (err->message));
    exit (1);
  }
  g_option_context_free (ctx);

  if (argc != 2) {
    g_print ("Usage: %s <URI> or <PIPELINE-DESCRIPTION>\n", argv[0]);
    exit (1);
  }

  /* Initialize GStreamer */
  gst_init (&argc, &argv);

  /* initialize inter thread comunnication */
  init_intercom (state);

  TRACE_VC_MEMORY ("state 0");

  if (!(rthread = g_thread_new ("render", (GThreadFunc) render_func, NULL))) {
    g_print ("Render thread create failed\n");
    exit (1);
  }

  /* Initialize player */
  if (gst_uri_is_valid (argv[1])) {
    res = init_playbin_player (state, argv[1]);
  } else {
    res = init_parse_launch_player (state, argv[1]);
  }

  if (!res)
    goto done;

  /* Create a GLib Main Loop and set it to run */
  state->main_loop = g_main_loop_new (NULL, FALSE);

  /* Add a keyboard watch so we get notified of keystrokes */
  io_stdin = g_io_channel_unix_new (fileno (stdin));
  g_io_add_watch (io_stdin, G_IO_IN, (GIOFunc) handle_keyboard, state);
  g_io_channel_unref (io_stdin);

  /* *INDENT-OFF* */
  g_print ("Available commands: \n"
      "  a - Toggle animation \n"
      "  p - Pause playback \n"
      "  r - Resume playback \n"
      "  l - Query position/duration\n"
      "  f - Seek 30 seconds forward \n"
      "  b - Seek 30 seconds backward \n"
      "  q - Quit \n");
  /* *INDENT-ON* */

  /* Connect the bus handlers */
  bus = gst_element_get_bus (state->pipeline);

  gst_bus_set_sync_handler (bus, (GstBusSyncHandler) bus_sync_handler, state,
      NULL);

  gst_bus_add_signal_watch_full (bus, G_PRIORITY_HIGH);
  gst_bus_enable_sync_message_emission (bus);

  g_signal_connect (G_OBJECT (bus), "message::error", (GCallback) error_cb,
      state);
  g_signal_connect (G_OBJECT (bus), "message::buffering",
      (GCallback) buffering_cb, state);
  g_signal_connect (G_OBJECT (bus), "message::eos", (GCallback) eos_cb, state);
  g_signal_connect (G_OBJECT (bus), "message::qos", (GCallback) qos_cb, state);
  g_signal_connect (G_OBJECT (bus), "message::state-changed",
      (GCallback) state_changed_cb, state);
  gst_object_unref (bus);

  /* Make player start playing */
  gst_element_set_state (state->pipeline, GST_STATE_PLAYING);

  /* Start the mainloop */
  state->main_loop = g_main_loop_new (NULL, FALSE);
  g_main_loop_run (state->main_loop);

done:
  /* Release pipeline */
  if (state->pipeline) {
    gst_element_set_state (state->pipeline, GST_STATE_NULL);
    if (state->vsink) {
      gst_object_unref (state->vsink);
      state->vsink = NULL;
    }

    gst_object_unref (state->pipeline);
  }

  /* Unref the mainloop */
  if (state->main_loop) {
    g_main_loop_unref (state->main_loop);
  }

  /* Stop rendering thread */
  state->running = FALSE;
  g_thread_join (rthread);

  terminate_intercom (state);

  TRACE_VC_MEMORY ("at exit");
  return 0;
}