static void krad_wcap_player_play (char *filename) {

  krad_wcap_player_t *krad_wcap_player;

  krad_wcap_player = calloc (1, sizeof (krad_wcap_player_t));

  krad_wcap_player->decoder = wcap_decoder_create (filename, 1);

  if (krad_wcap_player->decoder == NULL) {
    fprintf (stderr, "Couldn't open file: %s\n", filename);
    free (krad_wcap_player);
    exit (1);
  }

  krad_wcap_player->width = krad_wcap_player->decoder->width;
  krad_wcap_player->height = krad_wcap_player->decoder->height;

  krad_wcap_player->krad_wayland = krad_wayland_create ();

  krad_wayland_prepare_window (krad_wcap_player->krad_wayland, krad_wcap_player->width, krad_wcap_player->height, &krad_wcap_player->buffer);
  wcap_decoder_set_external_buffer (krad_wcap_player->decoder, krad_wcap_player->buffer);

  krad_wcap_player->krad_gui = kradgui_create_with_external_surface (krad_wcap_player->width,
                                     krad_wcap_player->height,
                            (unsigned char *)krad_wcap_player->buffer);



  wcap_decoder_get_frame (krad_wcap_player->decoder);

  krad_wcap_player->start_time = krad_wcap_player->decoder->msecs;

  printf ("Krad WCAP Player \n");
  printf ("Playing: %s\n", filename);
  printf ("Size: %dx%d\n", krad_wcap_player->width, krad_wcap_player->height);



  krad_wcap_player->krad_gui->clear = 0;
  //kradgui_go_live (krad_wcap_player->krad_gui);

  krad_wayland_set_frame_callback (krad_wcap_player->krad_wayland, krad_wcap_player_render_callback, krad_wcap_player);

  krad_wayland_open_window (krad_wcap_player->krad_wayland);

  while (krad_wcap_player->krad_wayland->running == 1) {
    usleep (100000);
  }
  
  usleep (100000);
  
  krad_wayland_destroy (krad_wcap_player->krad_wayland);

  kradgui_destroy (krad_wcap_player->krad_gui);

  wcap_decoder_destroy (krad_wcap_player->decoder);

  free (krad_wcap_player);

}
static void show_cpu_meter_window (int width, int height) {

	cpu_meter_t *cpu_meter;

	cpu_meter = calloc (1, sizeof (cpu_meter_t));

	cpu_meter->displayed_cpu_usage = -1;

	cpu_meter->width = width;
	cpu_meter->height = height;


	cpu_meter->x = cpu_meter->width / 2;
	cpu_meter->y = cpu_meter->height - (cpu_meter->height / 3);
	cpu_meter->size = cpu_meter->width / 4;

	cpu_meter->cpu_usage = krad_system_get_cpu_usage ();


	cpu_meter->krad_wayland = krad_wayland_create ();

	krad_wayland_prepare_window (cpu_meter->krad_wayland, cpu_meter->width, cpu_meter->height, &cpu_meter->buffer);

	cpu_meter->krad_gui = kradgui_create_with_external_surface (cpu_meter->width, cpu_meter->height, cpu_meter->buffer);

	cpu_meter->krad_gui->update_drawtime = 0;
	cpu_meter->krad_gui->print_drawtime = 0;

	//krad_gui->render_wheel = 1;
	//krad_gui->render_ftest = 1;
	//krad_gui->render_tearbar = 1;
	//kradgui_test_screen (krad_gui, "Gtk test");


	krad_wayland_set_frame_callback (cpu_meter->krad_wayland, cpu_meter_render_callback, cpu_meter);
	krad_wayland_open_window (cpu_meter->krad_wayland);

	while (cpu_meter->krad_wayland->running == 1) {
		usleep (300000);

	}

	krad_wayland_destroy (cpu_meter->krad_wayland);

	kradgui_destroy (cpu_meter->krad_gui);

	free (cpu_meter);

}