static void
gst_cacasink_set_property (GObject * object, guint prop_id,
    const GValue * value, GParamSpec * pspec)
{
  GstCACASink *cacasink;

  g_return_if_fail (GST_IS_CACASINK (object));

  cacasink = GST_CACASINK (object);

  switch (prop_id) {
    case PROP_DITHER:{
      cacasink->dither = g_value_get_enum (value);
      caca_set_dithering (cacasink->dither + CACA_DITHERING_NONE);
      break;
    }
    case PROP_ANTIALIASING:{
      cacasink->antialiasing = g_value_get_boolean (value);
      if (cacasink->antialiasing) {
        caca_set_feature (CACA_ANTIALIASING_MAX);
      } else {
        caca_set_feature (CACA_ANTIALIASING_MIN);
      }
      break;
    }
    default:
      break;
  }
}
static gboolean
gst_cacasink_open (GstCACASink * cacasink)
{
  cacasink->bitmap = NULL;

  if (caca_init () < 0)
    goto init_failed;

  cacasink->screen_width = caca_get_width ();
  cacasink->screen_height = caca_get_height ();
  cacasink->antialiasing = TRUE;
  caca_set_feature (CACA_ANTIALIASING_MAX);
  cacasink->dither = 0;
  caca_set_dithering (CACA_DITHERING_NONE);

  return TRUE;

  /* ERRORS */
init_failed:
  {
    GST_ELEMENT_ERROR (cacasink, RESOURCE, OPEN_WRITE, (NULL),
        ("caca_init() failed"));
    return FALSE;
  }
}
Exemple #3
0
static int preinit(const char *arg)
{
    if (arg)
    {
	mp_msg(MSGT_VO, MSGL_ERR, "vo_caca: Unknown subdevice: %s\n", arg);
	return ENOSYS;
    }

    if (caca_init())
    {
	mp_msg(MSGT_VO, MSGL_ERR, "vo_caca: failed to initialize\n");
	return ENOSYS;
    }

    caca_set_window_title("MPlayer");

    /* Default libcaca features */
    caca_set_feature(CACA_ANTIALIASING_PREFILTER);
    caca_set_feature(CACA_DITHERING_RANDOM);

    return 0;
}
Exemple #4
0
int main(void)
{
	int event;
	int ch;
	struct caca_sprite *carita=NULL;

	if (caca_init()) 
		return 1;
	caca_set_feature(CACA_ANTIALIASING_PREFILTER);
	caca_set_delay(40000);
	caca_set_color(CACA_COLOR_YELLOW, CACA_COLOR_RED);
	caca_draw_thin_box(0,0,10,2);
	caca_refresh();
	carita=caca_load_sprite("carita.txt");
	while(1) {
		while((event = caca_get_event(CACA_EVENT_ANY))) {
			caca_set_color(CACA_COLOR_BLACK, CACA_COLOR_WHITE);
			caca_printf(1,1, "%x\n", event);
			if(event & CACA_EVENT_KEY_PRESS)
			{
				ch=event & 0xffff;
				switch(ch)
				{
					case 'q':
					case 'Q':
						goto fin;
					case '0'...'9':  /* extension gcc */
						caca_set_color(caca_rand(2,14), CACA_COLOR_BLACK);
						caca_draw_thin_line(0,3,caca_get_width(),3+(ch-'0')*10);
					default:
						if (carita)
							caca_draw_sprite(caca_rand(4,caca_get_width()), caca_rand(4,caca_get_height()), carita, 0);
				}
			}
			caca_refresh();
		}
	}
Exemple #5
0
static void check_events (void)
{
    unsigned int cev;

    if ((cev = caca_get_event(CACA_EVENT_ANY)))
    {
	if (cev & CACA_EVENT_RESIZE)
	{
	    caca_refresh();
	    resize();
	} else if (cev & CACA_EVENT_KEY_RELEASE)
	{
	    int key = (cev & 0x00ffffff);
	    enum caca_feature cf;

	    switch (key) {
	    case 'd':
	    case 'D':
	      /* Toggle dithering method */
	      cf = 1 + caca_get_feature(CACA_DITHERING);
	      if (cf > CACA_DITHERING_MAX)
		  cf = CACA_DITHERING_MIN;
	      caca_set_feature(cf);
	      osdmessage(MESSAGE_DURATION, "Using %s", caca_get_feature_name(cf));
	      break;

	    case 'a':
	    case 'A':
	      /* Toggle antialiasing method */
	      cf = 1 + caca_get_feature(CACA_ANTIALIASING);
	      if (cf > CACA_ANTIALIASING_MAX)
		  cf = CACA_ANTIALIASING_MIN;
	      caca_set_feature(cf);
	      osdmessage(MESSAGE_DURATION, "Using %s", caca_get_feature_name(cf));
	      break;

	    case 'b':
	    case 'B':
	      /* Toggle background method */
	      cf = 1 + caca_get_feature(CACA_BACKGROUND);
	      if (cf > CACA_BACKGROUND_MAX)
		  cf = CACA_BACKGROUND_MIN;
	      caca_set_feature(cf);
	      osdmessage(MESSAGE_DURATION, "Using %s", caca_get_feature_name(cf));
	      break;

	    case CACA_KEY_UP:
	      mplayer_put_key(KEY_UP);
	      break;
	    case CACA_KEY_DOWN:
	      mplayer_put_key(KEY_DOWN);
	      break;
	    case CACA_KEY_LEFT:
	      mplayer_put_key(KEY_LEFT);
	      break;
	    case CACA_KEY_RIGHT:
	      mplayer_put_key(KEY_RIGHT);
	      break;
	    case CACA_KEY_ESCAPE:
	      mplayer_put_key(KEY_ESC);
	      break;
	    case CACA_KEY_PAGEUP:
	      mplayer_put_key(KEY_PAGE_UP);
	      break;
	    case CACA_KEY_PAGEDOWN:
	      mplayer_put_key(KEY_PAGE_DOWN);
	      break;
	    case CACA_KEY_RETURN:
	      mplayer_put_key(KEY_ENTER);
	      break;
	    case CACA_KEY_HOME:
	      mplayer_put_key(KEY_HOME);
	      break;
	    case CACA_KEY_END:
	      mplayer_put_key(KEY_END);
	      break;
	    default:
	      if (key <= 255)
		  mplayer_put_key (key);
	      break;
	    }
	}
    }
}