Commit 421866e2 authored by Cyril Deguet's avatar Cyril Deguet

* all: skeleton of a coming-soon OpenGL visualization plugin, compatible

   with MilkDrop for winamp.
parent ce1924e3
......@@ -2,7 +2,8 @@
FEATURES="
SKINS skins
SKINS2 skins2
SKINS skins2
FAMILIAR familiar
WXWINDOWS wxwindows
OPIE opie
MACOSX macosx
......@@ -80,6 +81,7 @@ RELEASE release
SOUT sout
WITHFFMPEGMP3LAME ffmpeg-mp3lame
WITHFFMPEGFAAC ffmpeg-faac
GALAKTOS galaktos
"
PATHS="
WITHXML2CONFIGPATH xml2-config-path
......@@ -136,25 +138,17 @@ do
eval x="\$CONFIG_$1"
if [ "$x" == "y" ]
then
if [ "$1" == "WITHFFMPEGMP3LAME" ]
then
echo -n "--with-$2 " >> .cmd
else if [ "$1" == "WITHFFMPEGFAAC" ]
if [ "$1" == "WITHFFMPEGMP3LAME" ] || [ "$1" == "WITHFFMPEGFAAC" ]
then
echo -n "--with-$2 " >> .cmd
else
echo -n "--enable-$2 " >> .cmd
fi fi
fi
else
if [ "$1" == "WITHFFMPEGMP3LAME" ]
if [ "$1" != "WITHFFMPEGMP3LAME" ] && [ "$1" != "WITHFFMPEGFAAC" ]
then
echo -n "--without-$2 " >> .cmd
else if [ "$1" == "WITHFFMPEGFAAC" ]
then
echo -n "--without-$2 " >> .cmd
else
echo -n "--disable-$2 " >> .cmd
fi fi
fi
fi
shift; shift
done
......
......@@ -16,6 +16,7 @@ bool 'Skins2 module' CONFIG_SKINS2
if [ "$CONFIG_SKINS2" = "y" ]; then
string 'xml2-config path' CONFIG_WITHXML2CONFIGPATH ""
fi
bool 'Familiar GTK+ support' CONFIG_FAMILIAR
# TODO: --enable-pda
bool 'wxWindows support' CONFIG_WXWINDOWS
if [ "$CONFIG_WXWINDOWS" = "y" ]; then
......@@ -36,6 +37,7 @@ bool 'Goom visualization plugin' CONFIG_GOOM
if [ "$CONFIG_GOOM" = "y" ]; then
string 'goom tree for static linking' CONFIG_WITHGOOMTREE ""
fi
bool 'GaLaktos visualization plugin' CONFIG_GALAKTOS
bool 'SLP service discovery support' CONFIG_SLP
if [ "$CONFIG_SLP" = "y" ]; then
string 'libslp headers and libraries' CONFIG_WITHSLP ""
......
......@@ -3346,6 +3346,17 @@ then
VLC_ADD_PLUGINS([visual])
fi
dnl
dnl OpenGL visualisation plugin
dnl
AC_ARG_ENABLE(galaktos,
[ --enable-galaktos OpenGL visualisation plugin (default disabled)])
if test "${enable_galaktos}" = "yes"
then
VLC_ADD_PLUGINS([galaktos])
VLC_ADD_LDFLAGS([galaktos],[-lGL -lGLU])
fi
dnl
dnl goom visualization plugin
dnl
......@@ -3855,6 +3866,7 @@ AC_CONFIG_FILES([
modules/video_output/x11/Makefile
modules/visualization/Makefile
modules/visualization/visual/Makefile
modules/visualization/galaktos/Makefile
])
AC_CONFIG_FILES([vlc-config], [chmod 0755 vlc-config])
......
SOURCES_galaktos = plugin.c \
plugin.h \
glx.c \
glx.h
/*****************************************************************************
* glx.c:
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id$
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#include "glx.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <GL/glx.h>
/* Local prototypes */
static int CreateWindow( galaktos_thread_t *p_thread, int i_width,
int i_height );
typedef struct
{
Display *p_display;
GLXFBConfig fbconf;
Window wnd;
GLXWindow gwnd;
}
glx_data_t;
#define OS_DATA ((glx_data_t*)(p_thread->p_os_data))
int galaktos_glx_init( galaktos_thread_t *p_thread, int i_width, int i_height )
{
Display *p_display;
int i_opcode, i_evt, i_err;
int i_maj, i_min;
int i_nbelem;
GLXFBConfig *p_fbconfs, fbconf;
static const int p_attr[] = { GLX_RED_SIZE, 5, GLX_GREEN_SIZE, 5,
GLX_BLUE_SIZE, 5, GLX_DOUBLEBUFFER, True,
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, 0 };
/* Initialize OS data */
p_thread->p_os_data = malloc( sizeof( glx_data_t ) );
/* Open the display */
OS_DATA->p_display = p_display = XOpenDisplay( NULL );
if( !p_display )
{
msg_Err( p_thread, "Cannot open display" );
return -1;
}
/* Check for GLX extension */
if( !XQueryExtension( p_display, "GLX", &i_opcode, &i_evt, &i_err ) )
{
msg_Err( p_thread, "GLX extension not supported" );
return -1;
}
if( !glXQueryExtension( p_display, &i_err, &i_evt ) )
{
msg_Err( p_thread, "glXQueryExtension failed" );
return -1;
}
/* Check GLX version */
if (!glXQueryVersion( p_display, &i_maj, &i_min ) )
{
msg_Err( p_thread, "glXQueryVersion failed" );
return -1;
}
if( i_maj <= 0 || ((i_maj == 1) && (i_min < 3)) )
{
msg_Err( p_thread, "GLX 1.3 is needed" );
return -1;
}
/* Get the FB configuration */
p_fbconfs = glXChooseFBConfig( p_display, 0, p_attr, &i_nbelem );
if( (i_nbelem <= 0) || !p_fbconfs )
{
msg_Err( p_thread, "Cannot get FB configurations");
if( p_fbconfs )
{
XFree( p_fbconfs );
}
return -1;
}
OS_DATA->fbconf = fbconf = p_fbconfs[0];
if( CreateWindow( p_thread, i_width, i_height ) == -1 )
{
XFree( p_fbconfs );
return -1;
}
msg_Err( p_thread, "NOT IMPLEMENTED YET ;)" );
return 0;
}
int CreateWindow( galaktos_thread_t *p_thread, int i_width, int i_height )
{
Display *p_display;
XVisualInfo *p_vi;
XSetWindowAttributes xattr;
Window wnd;
p_display = OS_DATA->p_display;
/* Get the X11 visual */
p_vi = glXGetVisualFromFBConfig( p_display, OS_DATA->fbconf );
if( !p_vi )
{
msg_Err( p_thread, "Cannot get X11 visual" );
return -1;
}
/* Create the window */
xattr.background_pixel = BlackPixel( p_display, DefaultScreen(p_display) );
xattr.border_pixel = 0;
OS_DATA->wnd = wnd = XCreateWindow( p_display, DefaultRootWindow(p_display),
0, 0, i_width, i_height, 0, p_vi->depth, InputOutput, p_vi->visual,
CWBackPixel | CWBorderPixel, &xattr);
XFree( p_vi );
/* Create the GLX window */
OS_DATA->gwnd = glXCreateWindow( p_display, OS_DATA->fbconf, wnd, NULL );
if( OS_DATA->gwnd == None )
{
msg_Err( p_thread, "Cannot create GLX window" );
return -1;
}
return 0;
}
/*****************************************************************************
* plugin.h:
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id$
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#ifndef _GALAKTOS_GLX_H_
#define _GALAKTOS_GLX_H_
#include "plugin.h"
int galaktos_glx_init( galaktos_thread_t *p_thread, int i_width, int i_height );
#endif
/*****************************************************************************
* plugin.c:
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id$
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include "plugin.h"
#include "glx.h"
#include <vlc/input.h>
#include <vlc/vout.h>
#include "aout_internal.h"
/*****************************************************************************
* Module descriptor
*****************************************************************************/
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
vlc_module_begin();
set_description( _("GaLaktos visualization plugin") );
set_capability( "audio filter", 0 );
set_callbacks( Open, Close );
add_shortcut( "galaktos" );
vlc_module_end();
/*****************************************************************************
* Local prototypes
*****************************************************************************/
typedef struct aout_filter_sys_t
{
galaktos_thread_t *p_thread;
} aout_filter_sys_t;
static void DoWork ( aout_instance_t *, aout_filter_t *, aout_buffer_t *,
aout_buffer_t * );
static void Thread ( vlc_object_t * );
static char *TitleGet( vlc_object_t * );
/*****************************************************************************
* Open: open a scope effect plugin
*****************************************************************************/
static int Open( vlc_object_t *p_this )
{
aout_filter_t *p_filter = (aout_filter_t *)p_this;
aout_filter_sys_t *p_sys;
galaktos_thread_t *p_thread;
vlc_value_t width, height;
if ( p_filter->input.i_format != VLC_FOURCC('f','l','3','2' )
|| p_filter->output.i_format != VLC_FOURCC('f','l','3','2') )
{
msg_Warn( p_filter, "Bad input or output format" );
return VLC_EGENERIC;
}
if ( !AOUT_FMTS_SIMILAR( &p_filter->input, &p_filter->output ) )
{
msg_Warn( p_filter, "input and output formats are not similar" );
return VLC_EGENERIC;
}
p_filter->pf_do_work = DoWork;
p_filter->b_in_place = 1;
/* Allocate structure */
p_sys = p_filter->p_sys = malloc( sizeof( aout_filter_sys_t ) );
/* Create galaktos thread */
p_sys->p_thread = p_thread =
vlc_object_create( p_filter, sizeof( galaktos_thread_t ) );
vlc_object_attach( p_thread, p_this );
galaktos_glx_init( p_thread, 512, 512 );
/*
var_Create( p_thread, "galaktos-width", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
var_Get( p_thread, "galaktos-width", &width );
var_Create( p_thread, "galaktos-height", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
var_Get( p_thread, "galaktos-height", &height );
*/
vlc_mutex_init( p_filter, &p_thread->lock );
vlc_cond_init( p_filter, &p_thread->wait );
p_thread->i_blocks = 0;
aout_DateInit( &p_thread->date, p_filter->output.i_rate );
aout_DateSet( &p_thread->date, 0 );
p_thread->i_channels = aout_FormatNbChannels( &p_filter->input );
p_thread->psz_title = TitleGet( VLC_OBJECT( p_filter ) );
if( vlc_thread_create( p_thread, "galaktos update thread", Thread,
VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
{
msg_Err( p_filter, "cannot lauch galaktos thread" );
vout_Destroy( p_thread->p_vout );
vlc_mutex_destroy( &p_thread->lock );
vlc_cond_destroy( &p_thread->wait );
if( p_thread->psz_title ) free( p_thread->psz_title );
vlc_object_detach( p_thread );
vlc_object_destroy( p_thread );
free( p_sys );
return VLC_EGENERIC;
}
return VLC_SUCCESS;
}
/*****************************************************************************
* DoWork: process samples buffer
*****************************************************************************
* This function queues the audio buffer to be processed by the galaktos thread
*****************************************************************************/
static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
aout_buffer_t * p_in_buf, aout_buffer_t * p_out_buf )
{
aout_filter_sys_t *p_sys = p_filter->p_sys;
block_t *p_block;
p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes;
/* Queue sample */
vlc_mutex_lock( &p_sys->p_thread->lock );
if( p_sys->p_thread->i_blocks == MAX_BLOCKS )
{
vlc_mutex_unlock( &p_sys->p_thread->lock );
return;
}
p_block = block_New( p_sys->p_thread, p_in_buf->i_nb_bytes );
if( !p_block ) return;
memcpy( p_block->p_buffer, p_in_buf->p_buffer, p_in_buf->i_nb_bytes );
p_block->i_pts = p_in_buf->start_date;
p_sys->p_thread->pp_blocks[p_sys->p_thread->i_blocks++] = p_block;
vlc_cond_signal( &p_sys->p_thread->wait );
vlc_mutex_unlock( &p_sys->p_thread->lock );
}
/*****************************************************************************
* float to s16 conversion
*****************************************************************************/
static inline int16_t FloatToInt16( float f )
{
if( f >= 1.0 )
return 32767;
else if( f < -1.0 )
return -32768;
else
return (int16_t)( f * 32768.0 );
}
/*****************************************************************************
* Fill buffer
*****************************************************************************/
static int FillBuffer( int16_t *p_data, int *pi_data,
audio_date_t *pi_date, audio_date_t *pi_date_end,
galaktos_thread_t *p_this )
{
int i_samples = 0;
block_t *p_block;
while( *pi_data < 512 )
{
if( !p_this->i_blocks ) return VLC_EGENERIC;
p_block = p_this->pp_blocks[0];
i_samples = __MIN( 512 - *pi_data, p_block->i_buffer /
sizeof(float) / p_this->i_channels );
/* Date management */
if( p_block->i_pts > 0 &&
p_block->i_pts != aout_DateGet( pi_date_end ) )
{
aout_DateSet( pi_date_end, p_block->i_pts );
}
p_block->i_pts = 0;
aout_DateIncrement( pi_date_end, i_samples );
while( i_samples > 0 )
{
float *p_float = (float *)p_block->p_buffer;
p_data[*pi_data] = FloatToInt16( p_float[0] );
if( p_this->i_channels > 1 )
p_data[512 + *pi_data] = FloatToInt16( p_float[1] );
(*pi_data)++;
p_block->p_buffer += (sizeof(float) * p_this->i_channels);
p_block->i_buffer -= (sizeof(float) * p_this->i_channels);
i_samples--;
}
if( !p_block->i_buffer )
{
block_Release( p_block );
p_this->i_blocks--;
if( p_this->i_blocks )
memmove( p_this->pp_blocks, p_this->pp_blocks + 1,
p_this->i_blocks * sizeof(block_t *) );
}
}
*pi_date = *pi_date_end;
*pi_data = 0;
return VLC_SUCCESS;
}
/*****************************************************************************
* Thread:
*****************************************************************************/
static void Thread( vlc_object_t *p_this )
{
galaktos_thread_t *p_thread = (galaktos_thread_t*)p_this;
vlc_value_t width, height, speed;
audio_date_t i_pts;
int16_t p_data[2][512];
int i_data = 0, i_count = 0;
while( !p_thread->b_die )
{
msleep( VOUT_OUTMEM_SLEEP );
}
}
/*****************************************************************************
* Close: close the plugin
*****************************************************************************/
static void Close( vlc_object_t *p_this )
{
aout_filter_t *p_filter = (aout_filter_t *)p_this;
aout_filter_sys_t *p_sys = p_filter->p_sys;
/* Stop galaktos Thread */
p_sys->p_thread->b_die = VLC_TRUE;
vlc_mutex_lock( &p_sys->p_thread->lock );
vlc_cond_signal( &p_sys->p_thread->wait );
vlc_mutex_unlock( &p_sys->p_thread->lock );
vlc_thread_join( p_sys->p_thread );
/* Free data */
vout_Request( p_filter, p_sys->p_thread->p_vout, 0, 0, 0, 0 );
vlc_mutex_destroy( &p_sys->p_thread->lock );
vlc_cond_destroy( &p_sys->p_thread->wait );
vlc_object_detach( p_sys->p_thread );
while( p_sys->p_thread->i_blocks-- )
{
block_Release( p_sys->p_thread->pp_blocks[p_sys->p_thread->i_blocks] );
}
vlc_object_destroy( p_sys->p_thread );
free( p_sys );
}
static char *TitleGet( vlc_object_t *p_this )
{
char *psz_title = NULL;
input_thread_t *p_input =
vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_ANYWHERE );
if( p_input )
{
char *psz = strrchr( p_input->input.p_item->psz_uri, '/' );
if( psz )
{
psz++;
}
else
{
psz = p_input->input.p_item->psz_uri;
}
if( psz && *psz )
{
psz_title = strdup( psz );
}
vlc_object_release( p_input );
}
return psz_title;
}
/*****************************************************************************
* plugin.h:
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id$
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#ifndef _GALAKTOS_PLUGIN_H_
#define _GALAKTOS_PLUGIN_H_
#include <vlc/vlc.h>
#include <vlc/aout.h>
#define MAX_BLOCKS 10
typedef struct
{
VLC_COMMON_MEMBERS
vout_thread_t *p_vout;
char *psz_title;
vlc_mutex_t lock;
vlc_cond_t wait;
/* Audio properties */
int i_channels;
/* Audio samples queue */
block_t *pp_blocks[MAX_BLOCKS];
int i_blocks;
audio_date_t date;
/* OS specific data */
void *p_os_data;
} galaktos_thread_t;
#endif
......@@ -122,6 +122,14 @@ int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input )
var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
}
/* Look for galaktos plugin */
p_module = config_FindModule( VLC_OBJECT(p_aout), "galaktos" );
if( p_module )
{
val.psz_string = "galaktos"; text.psz_string = _("GaLaktos");
var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
}
if( var_Get( p_aout, "effect-list", &val ) == VLC_SUCCESS )
{
var_Set( p_aout, "visual", val );
......@@ -563,6 +571,7 @@ static int VisualizationCallback( vlc_object_t *p_this, char const *psz_cmd,
{
ChangeFiltersString( p_aout, "goom", VLC_FALSE );
ChangeFiltersString( p_aout, "visual", VLC_FALSE );
ChangeFiltersString( p_aout, "galaktos", VLC_FALSE );
}
else
{
......@@ -570,6 +579,13 @@ static int VisualizationCallback( vlc_object_t *p_this, char const *psz_cmd,
{
ChangeFiltersString( p_aout, "visual", VLC_FALSE );
ChangeFiltersString( p_aout, "goom", VLC_TRUE );
ChangeFiltersString( p_aout, "galaktos", VLC_FALSE );
}
else if( !strcmp( "galaktos", psz_mode ) )
{
ChangeFiltersString( p_aout, "visual", VLC_FALSE );
ChangeFiltersString( p_aout, "goom", VLC_FALSE );
ChangeFiltersString( p_aout, "galaktos", VLC_TRUE );
}
else
{
......@@ -579,6 +595,7 @@ static int VisualizationCallback( vlc_object_t *p_this, char const *psz_cmd,
ChangeFiltersString( p_aout, "goom", VLC_FALSE );
ChangeFiltersString( p_aout, "visual", VLC_TRUE );
ChangeFiltersString( p_aout, "galaktos", VLC_FALSE );
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment