/*****************************************************************************
* caca.c: Color ASCII Art video output plugin using libcaca
*****************************************************************************
- * Copyright (C) 2003 VideoLAN
- * $Id: caca.c,v 1.2 2003/11/22 15:53:18 sam Exp $
+ * Copyright (C) 2003, 2004 the VideoLAN team
+ * $Id$
*
* Authors: Sam Hocevar <sam@zoy.org>
*
/*****************************************************************************
* Module descriptor
*****************************************************************************/
-#define MODE_TEXT N_("dithering mode")
-#define MODE_LONGTEXT N_("Choose the libcaca dithering mode")
-
-static char *mode_list[] = { "none", "ordered", "random" };
-static char *mode_list_text[] = { N_("No dithering"), N_("Ordered dithering"),
- N_("Random dithering") };
-
vlc_module_begin();
- add_category_hint( N_("Dithering"), NULL, VLC_FALSE );
- add_string( "caca-dithering", "ordered", NULL, MODE_TEXT,
- MODE_LONGTEXT, VLC_FALSE );
- change_string_list( mode_list, mode_list_text, 0 );
- set_description( _("colour ASCII art video output") );
+ set_shortname( "Caca" );
+ set_category( CAT_VIDEO );
+ set_subcategory( SUBCAT_VIDEO_VOUT );
+ set_description( _("Color ASCII art video output") );
set_capability( "video output", 12 );
set_callbacks( Create, Destroy );
vlc_module_end();
static int Create( vlc_object_t *p_this )
{
vout_thread_t *p_vout = (vout_thread_t *)p_this;
- enum caca_dithering dither = CACA_DITHER_ORDERED;
- vlc_value_t val;
+
+#if defined( WIN32 ) && !defined( UNDER_CE )
+ if( AllocConsole() )
+ {
+ CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
+ SMALL_RECT rect;
+ COORD coord;
+
+ HANDLE hstdout =
+ CreateConsoleScreenBuffer( GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL, CONSOLE_TEXTMODE_BUFFER, NULL );
+ if( !hstdout || hstdout == INVALID_HANDLE_VALUE )
+ {
+ msg_Err( p_vout, "cannot create screen buffer" );
+ FreeConsole();
+ return VLC_EGENERIC;
+ }
+
+ if( !SetConsoleActiveScreenBuffer( hstdout) )
+ {
+ msg_Err( p_vout, "cannot set active screen buffer" );
+ FreeConsole();
+ return VLC_EGENERIC;
+ }
+
+ coord = GetLargestConsoleWindowSize( hstdout );
+ msg_Dbg( p_vout, "SetConsoleWindowInfo: %ix%i", coord.X, coord.Y );
+
+ /* Force size for now */
+ coord.X = 100;
+ coord.Y = 40;
+
+ if( !SetConsoleScreenBufferSize( hstdout, coord ) )
+ msg_Warn( p_vout, "SetConsoleScreenBufferSize %i %i",
+ coord.X, coord.Y );
+
+ /* Get the current screen buffer size and window position. */
+ if( GetConsoleScreenBufferInfo( hstdout, &csbiInfo ) )
+ {
+ rect.Top = 0; rect.Left = 0;
+ rect.Right = csbiInfo.dwMaximumWindowSize.X - 1;
+ rect.Bottom = csbiInfo.dwMaximumWindowSize.Y - 1;
+ if( !SetConsoleWindowInfo( hstdout, TRUE, &rect ) )
+ msg_Dbg( p_vout, "SetConsoleWindowInfo failed: %ix%i",
+ rect.Right, rect.Bottom );
+ }
+ }
+ else
+ {
+ msg_Err( p_vout, "cannot create console" );
+ return VLC_EGENERIC;
+ }
+
+#endif
/* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
return VLC_EGENERIC;
}
- var_Create( p_vout, "caca-dithering", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
- var_Get( p_vout, "caca-dithering", &val );
- if( val.psz_string )
- {
- if( !strcmp( val.psz_string, "none" ) )
- {
- dither = CACA_DITHER_NONE;
- }
- else if( !strcmp( val.psz_string, "random" ) )
- {
- dither = CACA_DITHER_RANDOM;
- }
- free( val.psz_string );
- }
- caca_set_dithering( dither );
+ caca_set_window_title( VOUT_TITLE " - Colour AsCii Art (caca)" );
p_vout->pf_init = Init;
p_vout->pf_end = End;
4 * ((p_vout->output.i_width + 15) & ~15),
p_vout->output.i_rmask,
p_vout->output.i_gmask,
- p_vout->output.i_bmask );
+ p_vout->output.i_bmask,
+ 0x00000000 );
if( !p_vout->p_sys->p_bitmap )
{
msg_Err( p_vout, "could not create libcaca bitmap" );
/* Allocate the picture */
p_pic->p->i_lines = p_vout->output.i_height;
+ p_pic->p->i_visible_lines = p_vout->output.i_height;
p_pic->p->i_pitch = 4 * ((p_vout->output.i_width + 15) & ~15);
p_pic->p->i_pixel_pitch = 4;
p_pic->p->i_visible_pitch = 4 * p_vout->output.i_width;
vout_thread_t *p_vout = (vout_thread_t *)p_this;
caca_end();
+
+#if defined( WIN32 ) && !defined( UNDER_CE )
+ FreeConsole();
+#endif
+
free( p_vout->p_sys );
}
int event;
vlc_value_t val;
- while(( event = caca_get_event() ))
+ while(( event = caca_get_event(CACA_EVENT_KEY_PRESS | CACA_EVENT_RESIZE) ))
{
- if( event & CACA_EVENT_KEY_PRESS )
+ if( event == CACA_EVENT_RESIZE )
+ {
+ /* Acknowledge the resize */
+ caca_refresh();
+ continue;
+ }
+
+ switch( event & 0x00ffffff )
{
- switch( event & 0xffff )
- {
- case 'q':
- val.i_int = KEY_MODIFIER_CTRL | 'q';
- break;
- case ' ':
- val.i_int = KEY_SPACE;
- break;
- default:
- continue;
- }
+ case 'q':
+ val.i_int = KEY_MODIFIER_CTRL | 'q';
+ break;
+ case ' ':
+ val.i_int = KEY_SPACE;
+ break;
+ default:
+ continue;
}
var_Set( p_vout->p_vlc, "key-pressed", val );
static void Render( vout_thread_t *p_vout, picture_t *p_pic )
{
caca_clear();
- caca_blit( 0, 0, caca_get_width() - 1, caca_get_height() - 1,
- p_vout->p_sys->p_bitmap, p_pic->p->p_pixels );
+ caca_draw_bitmap( 0, 0, caca_get_width() - 1, caca_get_height() - 1,
+ p_vout->p_sys->p_bitmap, p_pic->p->p_pixels );
}
/*****************************************************************************