From 9ad76c67d91ba596dc33477dfb4c3a7d038e727c Mon Sep 17 00:00:00 2001 From: Niels Elburg Date: Sat, 2 Sep 2006 19:43:38 +0000 Subject: [PATCH] Bye sayVIMS, hello sayOSC, OSC dynamic namespaces, revamped event handlers, bugfixes in livido host implementation, bugfixes in vevosample, some memory leaks fixed git-svn-id: svn://code.dyne.org/veejay/trunk@593 eb8d1916-c9e9-0310-b8de-cf0c9472ead5 --- veejay-ng/libplugger/defs.h | 1 - veejay-ng/libplugger/freeframe-loader.c | 15 +- veejay-ng/libplugger/frei0r-loader.c | 10 +- veejay-ng/libplugger/livido-loader.c | 280 ++- veejay-ng/libplugger/livido-loader.h | 9 + veejay-ng/libplugger/plugload.c | 131 +- veejay-ng/libplugger/plugload.h | 4 +- veejay-ng/libvevo/libvevo.h | 12 +- veejay-ng/libvevo/vevo.c | 287 +++- veejay-ng/libyuv/subsample.c | 2 +- veejay-ng/tools/Makefile.am | 16 +- veejay-ng/tools/sayVIMS.c | 251 --- veejay-ng/tools/veejay-talk.c | 71 + veejay-ng/veejay/Makefile.am | 3 +- veejay-ng/veejay/liblavplayvj.c | 166 +- veejay-ng/veejay/oscevents.c | 673 ++++++++ veejay-ng/veejay/oscservit.c | 555 ++++-- veejay-ng/veejay/oscservit.h | 39 + veejay-ng/veejay/performer.c | 26 +- veejay-ng/veejay/veejay.c | 4 +- veejay-ng/veejay/veejay.h | 12 +- veejay-ng/veejay/vims.h | 154 +- veejay-ng/veejay/vj-event.c | 2060 ----------------------- veejay-ng/veejay/vj-event.h | 98 -- veejay-ng/veejay/vj-eventman.c | 1056 ------------ veejay-ng/vevosample/vevosample.c | 719 +++++++- veejay-ng/vevosample/vevosample.h | 31 +- veejay-ng/vevosample/vj-unicap.c | 13 +- 28 files changed, 2781 insertions(+), 3917 deletions(-) delete mode 100644 veejay-ng/tools/sayVIMS.c create mode 100644 veejay-ng/tools/veejay-talk.c create mode 100644 veejay-ng/veejay/oscevents.c delete mode 100644 veejay-ng/veejay/vj-event.c delete mode 100644 veejay-ng/veejay/vj-event.h delete mode 100644 veejay-ng/veejay/vj-eventman.c diff --git a/veejay-ng/libplugger/defs.h b/veejay-ng/libplugger/defs.h index 19d7dd4a..b6fd4f46 100644 --- a/veejay-ng/libplugger/defs.h +++ b/veejay-ng/libplugger/defs.h @@ -16,7 +16,6 @@ typedef void (*generic_push_parameter_f)(void *instance, int seq_num, void *va typedef void (*generic_clone_parameter_f)(void *instance, int seq_num, void *fx_values ); typedef void (*generic_reverse_clone_parameter_f)(void *instance, int seq_num, void *fxvalues ); typedef void (*generic_reverse_clone_out_parameter_f)(void *instance, void *fxvalues ); - typedef void (*generic_deinit_f)(void *instance); typedef void (*generic_init_f)(void *instance, int w, int h ); diff --git a/veejay-ng/libplugger/freeframe-loader.c b/veejay-ng/libplugger/freeframe-loader.c index 739d5fae..ebbfe32b 100644 --- a/veejay-ng/libplugger/freeframe-loader.c +++ b/veejay-ng/libplugger/freeframe-loader.c @@ -47,7 +47,11 @@ static int freeframe_signature_ = VEVO_PLUG_FF; void* deal_with_ff( void *handle, char *name ) { +#ifdef STRICT_CHECKING + void *port = vevo_port_new( VEVO_FF_PORT , __FUNCTION__, __LINE__ ); +#else void *port = vevo_port_new( VEVO_FF_PORT ); +#endif char *plugin_name = NULL; plugMainType *q = (plugMainType*) dlsym( handle, "plugMain" ); @@ -135,9 +139,11 @@ void* deal_with_ff( void *handle, char *name ) if(kind) continue; - +#ifdef STRICT_CHECKING + void *parameter = vevo_port_new( VEVO_FF_PARAM_PORT, __FUNCTION__,__LINE__ ); +#else void *parameter = vevo_port_new( VEVO_FF_PARAM_PORT ); - +#endif double ivalue = (double)q( FF_GETPARAMETERDEFAULT, (LPVOID) p, 0).fvalue; vevo_property_set( parameter, "default", VEVO_ATOM_TYPE_DOUBLE,1 ,&ivalue ); @@ -332,8 +338,11 @@ int freeframe_plug_init( void *plugin, int w, int h ) int num_channels = 0; int i; vevo_property_get( plugin, "num_inputs", 0, &num_channels ); - +#ifdef STRICT_CHECKING + void *buf = vevo_port_new( VEVO_ANONYMOUS_PORT, __FUNCTION__, __LINE__ ); +#else void *buf = vevo_port_new( VEVO_ANONYMOUS_PORT ); +#endif error = vevo_property_set( instance, "HOST_buffers", VEVO_ATOM_TYPE_PORTPTR,1,&buf); #ifdef STRICT_CHECKING diff --git a/veejay-ng/libplugger/frei0r-loader.c b/veejay-ng/libplugger/frei0r-loader.c index ea19b8d3..20b42fc1 100644 --- a/veejay-ng/libplugger/frei0r-loader.c +++ b/veejay-ng/libplugger/frei0r-loader.c @@ -14,7 +14,7 @@ #include #include #include -#ifdef HAVE_STRICT +#ifdef STRICT_CHECKING #include #endif /** \defgroup freior Freior Host @@ -44,7 +44,11 @@ typedef void (*f0r_set_param_value_f)(f0r_instance_t *instance, f0r_param_t *par static int init_param_fr( void *port, int p, int hint) { +#ifdef STRICT_CHECKING + void *parameter = vevo_port_new( VEVO_FR_PARAM_PORT, __FUNCTION__,__LINE__ ); +#else void *parameter = vevo_port_new( VEVO_FR_PARAM_PORT ); +#endif int min = 0; int max = 100; int dv = 50; @@ -94,7 +98,11 @@ static int init_param_fr( void *port, int p, int hint) } void* deal_with_fr( void *handle, char *name) { +#ifdef STRICT_CHECKING + void *port = vevo_port_new( VEVO_FR_PORT, __FUNCTION__,__LINE__ ); +#else void *port = vevo_port_new( VEVO_FR_PORT ); +#endif char *plugin_name = NULL; f0r_init_f f0r_init = dlsym( handle, "f0r_init" ); if( f0r_init == NULL ) diff --git a/veejay-ng/libplugger/livido-loader.c b/veejay-ng/libplugger/livido-loader.c index bb38d12a..ba362a58 100644 --- a/veejay-ng/libplugger/livido-loader.c +++ b/veejay-ng/libplugger/livido-loader.c @@ -41,7 +41,7 @@ #include #include #include - +#include #include #include @@ -170,17 +170,17 @@ void livido_plug_parameter_set_text( void *parameter, void *value ) } void livido_plug_parameter_set_number( void *parameter, void *value ) { - veejay_msg(0,"%s: value = '%d'", __FUNCTION__, *((double*) value )); + veejay_msg(0,"%s: value = '%g'", __FUNCTION__, (double) *((double*) value )); vevo_property_set( parameter, "value", LIVIDO_ATOM_TYPE_DOUBLE, 1, value ); } void livido_plug_parameter_set_index( void *parameter, void *value) { - veejay_msg(0,"%s: value = '%s'", __FUNCTION__, *((int*) value )); + veejay_msg(0,"%s: value = '%d'", __FUNCTION__, *((int*) value )); vevo_property_set( parameter, "value", VEVO_ATOM_TYPE_INT, 1, value ); } void livido_plug_parameter_set_bool( void *parameter, void *value ) { - veejay_msg(0,"%s: value = '%s'", __FUNCTION__, *((int*) value )); + veejay_msg(0,"%s: value = '%d'", __FUNCTION__, *((int*) value )); vevo_property_set( parameter, "value", VEVO_ATOM_TYPE_BOOL, 1, value ); } void livido_plug_parameter_set_color( void *parameter,void *value ) @@ -244,11 +244,13 @@ static int livido_scan_out_parameters( void *plugin , void *plugger_port) ikind = livido_pname_to_host_kind(kind); - veejay_msg(0, "Parameter %d, kind '%s', type '%d'",n,kind,ikind ); vevo_property_set( param, "HOST_kind", VEVO_ATOM_TYPE_INT,1,&ikind ); +#ifdef STRICT_CHECKING + void *vje_port = vevo_port_new( VEVO_VJE_PORT, __FUNCTION__, __LINE__ ); +#else void *vje_port = vevo_port_new( VEVO_VJE_PORT ); - +#endif vevo_property_set( plugger_port, key, LIVIDO_ATOM_TYPE_PORTPTR,1, &vje_port ); @@ -285,11 +287,18 @@ static int livido_scan_parameters( void *plugin, void *plugger_port ) #ifdef STRICT_CHECKING assert( kind != NULL ); #endif +#ifdef STRICT_CHECKING + void *vje_port = vevo_port_new( VEVO_VJE_PORT,__FUNCTION__,__LINE__ ); +#else void *vje_port = vevo_port_new( VEVO_VJE_PORT ); +#endif int tmp[4]; double dtmp[4]; - vevo_property_set( plugger_port, key, LIVIDO_ATOM_TYPE_PORTPTR,1, &vje_port ); + error = vevo_property_set( plugger_port, key, LIVIDO_ATOM_TYPE_PORTPTR,1, &vje_port ); +#ifdef STRICT_CHECKING + assert( error == LIVIDO_NO_ERROR ); +#endif if(strcasecmp(kind, "NUMBER") == 0 ) { ikind = HOST_PARAM_NUMBER; vj_np ++; @@ -515,7 +524,11 @@ static int init_ports_from_template( livido_port_t *filter_instance, livido_port #ifdef STRICT_CHECKING assert( error == LIVIDO_NO_ERROR ); #endif +#ifdef STRICT_CHECKING + in_channels[i] = livido_port_new( id, __FUNCTION__, i ); +#else in_channels[i] = livido_port_new( id ); //@ is this ever freed?! +#endif livido_property_set( in_channels[i], "parent_template",LIVIDO_ATOM_TYPE_PORTPTR,1, &ptr); livido_property_soft_reference( in_channels[i], "parent_template" ); ; @@ -546,11 +559,163 @@ static int init_ports_from_template( livido_port_t *filter_instance, livido_port livido_property_set( filter_instance, iname, LIVIDO_ATOM_TYPE_PORTPTR,num, in_channels ); - livido_property_soft_reference( filter_instance, name ); + +// veejay_msg(0, "%s --> %s",__FUNCTION__, name); +// livido_property_soft_reference( filter_instance, name ); return num; } +char *livido_describe_parameter_format_osc( void *instance, int p ) +{ + void *param = NULL; + void *param_templ = NULL; + int error = vevo_property_get( instance, "in_parameters", p, ¶m ); + if(error != VEVO_NO_ERROR ) + { + veejay_msg(0, "Input parameter %d does not exist ", p ); + return NULL; + } + error = vevo_property_get( param, "parent_template",0,¶m_templ); +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif + + int kind = 0; + error = vevo_property_get( param_templ, "HOST_kind",0,&kind ); +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif + + int n_elems = vevo_property_num_elements( param_templ, "default" ); + +#ifdef STRICT_CHECKING + assert( n_elems > 0 ); +#endif + + char fmt[5]; + + bzero(fmt,5); + + switch(kind) + { + case HOST_PARAM_INDEX: + fmt[0] = 'i'; + break; + case HOST_PARAM_NUMBER: + fmt[0] = 'd'; + break; + case HOST_PARAM_SWITCH: + fmt[0] = 'i'; + break; + case HOST_PARAM_COORD: + fmt[0] = 'd'; + fmt[1] = 'd'; + break; + case HOST_PARAM_COLOR: + fmt[0] = 'd'; + fmt[1] = 'd'; + fmt[2] = 'd'; + break; + case HOST_PARAM_TEXT: + fmt[0] = 's'; + break; + default: +#ifdef STRICT_CHECKING + assert(0); +#endif + break; + } + + char *res = strdup( fmt ); + return res; +} + +void livido_plug_free_namespace( void *fx_instance , void *data ) +{ + void *osc_namespace = NULL; + int error = vevo_property_get( fx_instance, "HOST_osc",0,&osc_namespace); +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif + veejay_osc_del_methods( data,osc_namespace,fx_instance, fx_instance ); +} + +int livido_plug_build_namespace( void *plugin_template , int entry_id, void *fx_instance , void *data, int sample_id) +{ + void *plug_info = NULL; + void *filter_templ = NULL; + int flags =0; + int error = vevo_property_get( plugin_template, "instance", 0, &plug_info); + +#ifdef STRICT_CHECKING + assert( error == LIVIDO_NO_ERROR ); +#endif + error = vevo_property_get( plug_info, "filters",0,&filter_templ); +#ifdef STRICT_CHECKING + assert( error == LIVIDO_NO_ERROR ); +#endif + + int n_in = vevo_property_num_elements( filter_templ, "in_parameter_templates" ); + int i; + if( n_in <= 0) + { + return 0; // no namespace needed yet + } + + char *plug_name = get_str_vevo( filter_templ, "name" ); + + char base[256]; +#ifdef STRICT_CHECKING + void *osc_namespace = vevo_port_new(VEVO_ANONYMOUS_PORT, __FUNCTION__, __LINE__ ); +#else + void *osc_namespace = vevo_port_new(VEVO_ANONYMOUS_PORT); +#endif + + for( i = 0; i < n_in ; i ++ ) + { + void *param_templ = NULL; + error = vevo_property_get( filter_templ, "in_parameter_templates", i, ¶m_templ ); +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif + char *param_name = get_str_vevo( param_templ, "name" ); + char *descrip = get_str_vevo( param_templ, "description" ); + + sprintf(base, "/sample_%d/fx_%d/%s", + sample_id, + entry_id, + plug_name ); + + char *format = livido_describe_parameter_format_osc( fx_instance ,i); + + + plugin_new_event( + data, osc_namespace, fx_instance, base, param_name, format, NULL, descrip, NULL, entry_id ); + + free(param_name); + free(format); + free(descrip); + + } + + error = vevo_property_set( fx_instance, "HOST_osc", LIVIDO_ATOM_TYPE_PORTPTR,1,&osc_namespace); + + free(plug_name); + + veejay_msg(0, "End of OSC namespace"); + return n_in; +} + +void *livido_get_name_space( void *instance ) +{ + void *space = NULL; + int error = vevo_property_get( instance, "HOST_osc", 0, &space ); + if( error != VEVO_NO_ERROR ) + return NULL; + return space; +} + /* initialize a plugin */ void *livido_plug_init(void *plugin,int w, int h ) { @@ -566,8 +731,11 @@ void *livido_plug_init(void *plugin,int w, int h ) #ifdef STRICT_CHECKING assert( error == LIVIDO_NO_ERROR ); #endif +#ifdef STRICT_CHECKING + void *filter_instance = livido_port_new( LIVIDO_PORT_TYPE_FILTER_INSTANCE, __FUNCTION__,__LINE__ ); +#else void *filter_instance = livido_port_new( LIVIDO_PORT_TYPE_FILTER_INSTANCE ); - +#endif int num_in_channels = init_ports_from_template( filter_instance, filter_templ, LIVIDO_PORT_TYPE_CHANNEL, @@ -763,7 +931,7 @@ void livido_plug_deinit( void *instance ) } } - + void *channel = NULL; int hsampling = 0; error = vevo_property_get( instance, "out_channels", 0, &channel ); @@ -781,9 +949,9 @@ void livido_plug_deinit( void *instance ) subsample_free(sampler); } - livido_port_recursive_free( instance ); +// livido_port_recursive_free( instance ); - instance = NULL; +// instance = NULL; } //get plugin defaults void livido_plug_retrieve_values( void *instance, void *fx_values ) @@ -833,6 +1001,61 @@ void livido_plug_read_output_parameters( void *instance, void *fx_values ) } } +char *livido_describe_parameter_format( void *instance, int p ) +{ + void *param = NULL; + void *param_templ = NULL; + int error = vevo_property_get( instance, "in_parameters", p, ¶m ); + if(error != VEVO_NO_ERROR ) + return 0; + error = vevo_property_get( param, "parent_template",0,¶m_templ); +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif + int kind = 0; + error = vevo_property_get( param_templ, "HOST_kind",0,&kind ); +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif + + int n_elems = vevo_property_num_elements( param, "value" ); + +#ifdef STRICT_CHECKING + assert( n_elems > 0 ); +#endif + + char fmt[5]; + + bzero(fmt,5); + + switch(kind) + { + case HOST_PARAM_INDEX: + fmt[0] = 'd'; + break; + case HOST_PARAM_NUMBER: + fmt[0] = 'g'; + break; + case HOST_PARAM_SWITCH: + fmt[0] = 'd'; + break; + case HOST_PARAM_COORD: + fmt[0] = 'g'; + fmt[1] = 'g'; + break; + case HOST_PARAM_COLOR: + fmt[0] = 'g'; + fmt[1] = 'g'; + fmt[2] = 'g'; + break; + case HOST_PARAM_TEXT: + fmt[0] = 's'; + break; + } + + char *res = strdup( fmt ); + return res; +} int livido_set_parameter_from_string( void *instance, int p, const char *str, void *fx_values ) @@ -932,15 +1155,27 @@ void livido_set_parameter( void *instance, int seq, void *value ) } } +#ifdef STRICT_CHECKING +void *livido_plugin_port_new( int id ) +{ + return vevo_port_new(id, "Allocated by plugin" ,rand()); +} +#endif + void* deal_with_livido( void *handle, const char *name ) { +#ifdef STRICT_CHECKING + void *port = vevo_port_new( VEVO_LIVIDO_PORT, __FUNCTION__, __LINE__ ); +#else void *port = vevo_port_new( VEVO_LIVIDO_PORT ); +#endif char *plugin_name = NULL; int lvd = 1; int type = VEVO_LIVIDO_PORT; livido_setup_f livido_setup = dlsym( handle, "livido_setup" ); +#ifndef STRICT_CHECKING livido_setup_t setup[] = { { (void(*)()) vj_malloc }, { (void(*)()) free }, @@ -955,6 +1190,24 @@ void* deal_with_livido( void *handle, const char *name ) { (void(*)())vevo_property_element_size }, { (void(*)())vevo_list_properties } }; +#else + livido_setup_t setup[] = { + { (void(*)()) vj_malloc }, + { (void(*)()) free }, + { (void(*)())memset }, + { (void(*)())memcpy }, + { (void(*)())livido_plugin_port_new }, + { (void(*)())vevo_port_free }, + { (void(*)())vevo_property_set }, + { (void(*)())vevo_property_get }, + { (void(*)())vevo_property_num_elements }, + { (void(*)())vevo_property_atom_type }, + { (void(*)())vevo_property_element_size }, + { (void(*)())vevo_list_properties } + }; + + +#endif void *livido_plugin = livido_setup( setup, 100 ); #ifdef STRICT_CHECKING @@ -991,7 +1244,6 @@ void* deal_with_livido( void *handle, const char *name ) #endif char *clone_name = (char*) malloc( strlen(plugin_name) + 4); sprintf(clone_name, "LVD%s", plugin_name ); - veejay_msg(0, "Livido plugin '%s'", plugin_name ); vevo_property_set( port, "num_params", VEVO_ATOM_TYPE_INT, 1, &n_params ); vevo_property_set( port, "num_out_params", VEVO_ATOM_TYPE_INT,1,&n_oparams ); @@ -1003,8 +1255,6 @@ void* deal_with_livido( void *handle, const char *name ) free(clone_name); free(plugin_name); - veejay_msg(0, "Input:%d, Output; %d", n_params, n_oparams ); - return port; } diff --git a/veejay-ng/libplugger/livido-loader.h b/veejay-ng/libplugger/livido-loader.h index a5ac9a2f..b1d1c039 100644 --- a/veejay-ng/libplugger/livido-loader.h +++ b/veejay-ng/libplugger/livido-loader.h @@ -36,4 +36,13 @@ void livido_exit( void ); void livido_plug_read_output_parameters( void *instance, void *fx_values ); +char *livido_describe_parameter_format( void *instance, int p ); + +int livido_plug_build_namespace( void *plugin_template , int entry_id, void *fx_instance , void *data, int sam); + +char *livido_describe_parameter_format_osc( void *instance, int p ); + +void livido_plug_free_namespace( void *fx_instance , void *data ); + +void *livido_get_name_space( void *instance ); #endif diff --git a/veejay-ng/libplugger/plugload.c b/veejay-ng/libplugger/plugload.c index e4d8ad9b..756f3ab8 100644 --- a/veejay-ng/libplugger/plugload.c +++ b/veejay-ng/libplugger/plugload.c @@ -79,6 +79,12 @@ int plug_set_param_from_str( void *plugin , int p, const char *str, void *value return livido_set_parameter_from_string( plugin, p, str, values ); } +char *plug_describe_param( void *plugin, int p ) +{ + return livido_describe_parameter_format( plugin,p ); +} + + static void *instantiate_plugin( void *plugin, int w , int h ) { int type = 0; @@ -182,7 +188,7 @@ static void add_to_plugin_list( const char *path ) continue; } - veejay_msg(0, "\tOpened plugin '%s' in '%s'", name,path ); + // veejay_msg(0, "\tOpened plugin '%s' in '%s'", name,path ); if(dlsym( handle, "plugMain" )) { @@ -195,10 +201,7 @@ static void add_to_plugin_list( const char *path ) } else dlclose( handle ); - } - - if(dlsym( handle, "f0r_construct" )) - { + } else if(dlsym( handle, "f0r_construct" )) { void *plugin = deal_with_fr( handle, name ); if( plugin ) { @@ -208,26 +211,18 @@ static void add_to_plugin_list( const char *path ) } else dlclose( handle ); - } - - if(dlsym( handle, "livido_setup" )) - { + } else if(dlsym( handle, "livido_setup" )) { void *plugin = deal_with_livido( handle , name ); if( plugin ) { - veejay_msg(VEEJAY_MSG_INFO, "Load livido plugin '%s' to slot %d",name, index_); - index_map_[index_] = plugin; index_ ++; n_lvd_ ++; } else - { - veejay_msg(VEEJAY_MSG_ERROR, "Failed to load '%s'",name ); dlclose(handle); - } - - } + } else + dlclose(handle); } @@ -242,27 +237,17 @@ static void free_plugin(void *plugin) #ifdef STRICT_CHECKING assert( plugin != NULL ); #endif - - int type = 0; - int error = vevo_property_get( plugin, "HOST_plugin_type", 0, &type); -#ifdef STRICT_CHECKING - assert( error == 0 ); -#endif - - char *name = get_str_vevo( plugin, "name" ); - - veejay_msg(0, "%s: Free plugin '%s' %p, Type %x", - __FUNCTION__,name,plugin,type ); - free(name); - void *handle = NULL; - error = vevo_property_get( plugin, "handle", 0 , &handle ); + int error = vevo_property_get( plugin, "handle", 0 , &handle ); #ifdef STRICT_CHECKING assert( error == 0 ); #endif - if( handle ) dlclose( handle ); + vevo_port_recursive_free( plugin ); + if( handle ) dlclose( handle ); + + plugin = NULL; } char *list_plugins() @@ -301,12 +286,14 @@ char *list_plugins() static void free_plugins() { int i; - vevo_port_recursive_free( illegal_plugins_ ); - for( i = 0; i < index_ ; i ++ ) free_plugin( index_map_[i]); + + vevo_port_recursive_free( illegal_plugins_ ); + free( index_map_ ); index_ = 0; + index_map_ = NULL; } #define CONFIG_FILE_LEN 65535 @@ -337,7 +324,6 @@ static int scan_plugins() char *pch = strtok( data, "\n" ); while( pch != NULL ) { - veejay_msg(0, "Add '%s'",pch ); add_to_plugin_list( pch ); pch = strtok( NULL, "\n"); } @@ -393,8 +379,11 @@ void plug_sys_init( int fmt, int w, int h ) int plug_sys_detect_plugins(void) { index_map_ = (vevo_port_t**) malloc(sizeof(vevo_port_t*) * 256 ); - +#ifdef STRICT_CHECKING + illegal_plugins_ = vevo_port_new( VEVO_ILLEGAL, __FUNCTION__, __LINE__ ); +#else illegal_plugins_ = vevo_port_new( VEVO_ILLEGAL ); +#endif #ifdef STRICT_CHECKING assert( illegal_plugins_ != NULL ); #endif @@ -427,7 +416,8 @@ int plug_sys_detect_plugins(void) n_lvd_, n_lvd_ == 1 ? "plugin" :"plugins" ); veejay_msg(VEEJAY_MSG_INFO, "-------------------------------------------------------------------------------------------"); - + plug_print_all(); + return index_; } @@ -683,6 +673,58 @@ void *plug_activate( int fx_id ) return instantiate_plugin( index_map_[fx_id], base_width_,base_height_); } +void plug_clear_namespace( void *fx_instance, void *data ) +{ + livido_plug_free_namespace( fx_instance , data ); +} + +void plug_build_name_space( int fx_id, void *fx_instance, void *data, int entry_id , int sample_id) +{ + void *plugin = index_map_[fx_id]; + int type = 0; +#ifdef STRICT_CHECKING + assert( plugin != NULL ); +#endif + int error = vevo_property_get( plugin, "HOST_plugin_type", 0, &type); +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif + switch( type ) + { + case VEVO_PLUG_LIVIDO: + livido_plug_build_namespace( plugin, entry_id, fx_instance, data, sample_id ); + break; + case VEVO_PLUG_FF: + break; + case VEVO_PLUG_FR: + break; + default: +#ifdef STRICT_CHECKING + assert(0); +#endif + break; + } + + + +} + + +void plug_print_all() +{ + int n; + for(n = 0; n < index_ ; n ++ ) + { + char *fx_name = plug_get_name(n); + if(fx_name) + { + veejay_msg(VEEJAY_MSG_INFO, "\t'FX %s loaded", fx_name ); + free(fx_name); + } + } + +} + char *plug_get_name( int fx_id ) { if(!index_map_[fx_id] ) @@ -691,6 +733,18 @@ char *plug_get_name( int fx_id ) return name; } +char *plug_get_osc_format(void *fx_instance, int seq_num) +{ +/* void *param_templ = NULL; + int error = vevo_property_get( fx_instance, "parent_template",0,¶m_templ); +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif*/ + + char *required_format = livido_describe_parameter_format_osc( fx_instance,seq_num ); + return required_format; +} + int plug_get_fx_id_by_name( const char *name ) { int n = 0; @@ -773,3 +827,8 @@ void plug_process( void *instance ) (*gpf)( instance,0.0 ); } + +void *plug_get_name_space( void *instance ) +{ + return livido_get_name_space(instance); +} diff --git a/veejay-ng/libplugger/plugload.h b/veejay-ng/libplugger/plugload.h index 5011e094..8e7ffb91 100644 --- a/veejay-ng/libplugger/plugload.h +++ b/veejay-ng/libplugger/plugload.h @@ -39,5 +39,7 @@ void plug_process( void *instance ); void plug_get_defaults( void *instance, void *fx_values ); void plug_set_parameter( void *instance, int seq_num, int n_elements,void *value ); void plug_clone_from_output_parameters( void *instance, void *fx_values ); - +char *plug_get_osc_format(void *fx_instance, int p); +void plug_build_name_space( int fx_id, void *fx_instance, void *data, int entry_id, int sample_id ); +void plug_clear_namespace( void *fx_instance, void *data ); #endif diff --git a/veejay-ng/libvevo/libvevo.h b/veejay-ng/libvevo/libvevo.h index 94a5a306..f4696c03 100644 --- a/veejay-ng/libvevo/libvevo.h +++ b/veejay-ng/libvevo/libvevo.h @@ -46,8 +46,11 @@ int vevo_property_atom_type( vevo_port_t *p, const char *key); size_t vevo_property_element_size( vevo_port_t * p, const char *key, const int idx); +#ifdef STRICT_CHECKING +vevo_port_t *vevo_port_new( int port_type, const char *func, int line_no ); +#else vevo_port_t *vevo_port_new(int port_type); - +#endif int vevo_property_soft_reference(vevo_port_t * p, const char *key); void vevo_strict_init(); @@ -86,6 +89,7 @@ int vevo_property_from_string( vevo_port_t *port, const char *s, const char *key #define VEVO_ATOM_TYPE_STRING 4 #define VEVO_ATOM_TYPE_BOOL 3 #define VEVO_ATOM_TYPE_PORTPTR 66 +#define VEVO_ATOM_TYPE_HIDDEN 50 #define VEVO_ATOM_TYPE_UINT64 5 #define VEVO_NO_ERROR 0 @@ -98,10 +102,12 @@ int vevo_property_from_string( vevo_port_t *port, const char *s, const char *key #define VEVO_ERROR_HARDWARE 7 #define VEVO_ERROR_PROPERTY_EMPTY 8 + #define VEVO_PORT_POOL 1041 #define VEVO_ANONYMOUS_PORT -1 -#define VEVO_PROPERTY_READONLY (1<<0) -#define VEVO_PROPERTY_SOFTREF (2<<0) +#define VEVO_PROPERTY_READONLY (1<<1) +#define VEVO_PROPERTY_SOFTREF (1<<2) +#define VEVO_PROPERTY_PROTECTED (1<<10) #endif diff --git a/veejay-ng/libvevo/vevo.c b/veejay-ng/libvevo/vevo.c index d48c3a47..19b76ff2 100644 --- a/veejay-ng/libvevo/vevo.c +++ b/veejay-ng/libvevo/vevo.c @@ -130,6 +130,7 @@ typedef struct { } elements; int num_elements; /*!< number of atoms */ int flags; /*!< special flags */ + int softlink; /*! < protected, use to indicate soft link */ } vevo_storage_t; //! \typedef vevo_property_t @@ -169,6 +170,7 @@ typedef struct { void *pool; /*!< pointer to pool_t object caching */ } __vevo_port_t; + //! \var port_ref_ Book keeping of allocated and freed ports static vevo_port_t *port_ref_ = NULL; static size_t atom_sizes_[100]; @@ -403,24 +405,24 @@ int vevo_property_soft_reference(vevo_port_t * p, const char *key) if (!port->table) { vevo_property_t *node = NULL; if ((node = prop_node_get(port, hash_key)) != NULL) { - node->st->flags |= VEVO_PROPERTY_SOFTREF; + node->st->softlink = 1; return VEVO_NO_ERROR; } } else { hnode_t *node = NULL; if ((node = property_exists(port, hash_key)) != NULL) { vevo_storage_t *stor = (vevo_storage_t *) hnode_get(node); - stor->flags |= VEVO_PROPERTY_SOFTREF; - hnode_t *new_node = hnode_create((void *) stor); - hnode_put(new_node, (void *) hash_key); - hnode_destroy(new_node); + stor->softlink = 1; + hnode_put( node, (void*) hash_key ); return VEVO_NO_ERROR; } } + return VEVO_NO_ERROR; } + //! Flag a property as read-only. Use to avoid overriding the value /*! \param p port @@ -926,10 +928,11 @@ vevo_property_element_size(vevo_port_t * p, const char *key, assert(key != NULL); assert(idx >= 0); #endif - if(!p) return -1; __vevo_port_t *port = (__vevo_port_t *) p; uint32_t hash_key = hash_key_code(key); - +#ifdef STRICT_CHECKING + assert( port ); +#endif if (!port->table) { vevo_property_t *node; if ((node = prop_node_get(port, hash_key)) != NULL) { @@ -970,7 +973,26 @@ vevo_property_element_size(vevo_port_t * p, const char *key, \param port_type Type of Port to Create. Port types <= 1024 are typed, > 1024 are anonymous ports. \return A New Port */ +#ifndef STRICT_CHECKING vevo_port_t *vevo_port_new(int port_type) +{ + __vevo_port_t *port = (__vevo_port_t *) malloc(sizeof(__vevo_port_t)); + + port->index = NULL; + port->list = NULL; + port->table = NULL; + port->pool = vevo_pool_init( sizeof(vevo_property_t),sizeof( vevo_storage_t ), sizeof( atom_t ) , sizeof( port_index_t ) ); +/* If the port type is a Livido port this or that */ + if ( (port_type >= 1 && port_type <= 50) || port_type < 0) + port->list = NULL; + else + port->table = hash_create(HASHCOUNT_T_MAX, key_compare, int_hash); + + vevo_port_finalize (port, port_type ); + return (vevo_port_t *) port; +} +#else +vevo_port_t *vevo_port_new(int port_type, const char *func, int line_num) { __vevo_port_t *port = (__vevo_port_t *) malloc(sizeof(__vevo_port_t)); @@ -988,13 +1010,24 @@ vevo_port_t *vevo_port_new(int port_type) port->table = hash_create(HASHCOUNT_T_MAX, key_compare, int_hash); vevo_port_finalize (port, port_type ); + +/* char har[1024]; + sprintf(har,"%s::%d", func,line_num ); + vevo_property_set( port, har, VEVO_ATOM_TYPE_HIDDEN,0,NULL); + */ return (vevo_port_t *) port; } +#endif + //! Initialize VeVo. Set up bookkeeping information to track Port construction and destruction void vevo_strict_init() { +#ifdef STRICT_CHECKING + port_ref_ = vevo_port_new( VEVO_PORT_REFERENCES, __FUNCTION__,__LINE__ ); +#else port_ref_ = vevo_port_new( VEVO_PORT_REFERENCES ); +#endif memset( atom_sizes_,0,sizeof(atom_sizes_) ); atom_sizes_[1] = sizeof(int32_t); atom_sizes_[2] = sizeof(double); @@ -1128,7 +1161,7 @@ void vevo_port_free( vevo_port_t *port ) if( dec_ref) { error = vevo_property_get( port_ref_, pkey, 0, &ref_count ); - if( error != 0 ) + if( error != VEVO_NO_ERROR ) { veejay_msg(0, "%s: Port '%s' not allocated by vevo_port_new()", __FUNCTION__, pkey ); #ifdef STRICT_CHECKING @@ -1144,7 +1177,7 @@ void vevo_port_free( vevo_port_t *port ) #endif return; } - if( ref_count != 1 ) + if( ref_count > 1 ) { veejay_msg(0, "%s: Port '%s' has a reference count of %d", __FUNCTION__,pkey,ref_count); #ifdef STRICT_CHECKING @@ -1156,7 +1189,7 @@ void vevo_port_free( vevo_port_t *port ) #ifdef STRICT_CHECKING assert( ref_count == 0 ); #endif - vevo_property_set( port_ref_, pkey, VEVO_ATOM_TYPE_INT,0,0 ); + vevo_property_set( port_ref_, pkey, VEVO_ATOM_TYPE_INT,1,&ref_count ); vevo_port_free_( port ); } @@ -1184,16 +1217,14 @@ vevo_property_is_soft_referenced(vevo_port_t * p, if (!port->table) { vevo_property_t *pnode = NULL; if ((pnode = prop_node_get(port, hash_key)) != NULL) { - if (pnode->st->flags & VEVO_PROPERTY_SOFTREF) - return 1; + return pnode->st->softlink; } } else { hnode_t *old_node = NULL; if ((old_node = property_exists(port, hash_key)) != NULL) { vevo_storage_t *oldstor = (vevo_storage_t *) hnode_get(old_node); - if (oldstor->flags & VEVO_PROPERTY_SOFTREF) - return 1; + return oldstor->softlink; } } return 0; @@ -1219,6 +1250,8 @@ vevo_property_set(vevo_port_t * p, assert( src != p ); if( num_elements > 0 ) assert( src != NULL ); assert( key != NULL ); + if( atom_type != VEVO_ATOM_TYPE_HIDDEN ) + assert( vevo_atom_size(atom_type) > 0 ); #endif __vevo_port_t *port = (__vevo_port_t *) p; uint32_t hash_key = hash_key_code(key); @@ -1234,7 +1267,9 @@ vevo_property_set(vevo_port_t * p, if (pnode->st->atom_type != atom_type) return VEVO_ERROR_WRONG_ATOM_TYPE; if (pnode->st->flags & VEVO_PROPERTY_READONLY) + { return VEVO_ERROR_PROPERTY_READONLY; + } #endif vevo_free_storage(port,pnode->st); //prop_node_free(pnode); @@ -1392,19 +1427,27 @@ char **vevo_list_properties(vevo_port_t * p) l = (port_index_t *) port->index; i = 0; while (l != NULL) { - list[i] = (char *) strdup(l->key); +#ifdef STRICT_CHECKING + if( vevo_property_atom_type( p, l->key ) != VEVO_ATOM_TYPE_HIDDEN ) + { +#endif + list[i] = (char *) strdup(l->key); #ifdef STRICT_CHECING assert(list[i] != NULL); #endif - l = l->next; i++; +#ifdef STRICT_CHECKING + } +#endif + + l = l->next; + //i++; } list[i] = NULL; return list; } - int vevo_num_properties(vevo_port_t * p) { __vevo_port_t *port = (__vevo_port_t *) p; @@ -1486,7 +1529,7 @@ static vevo_storage_t **vevo_list_nodes_(vevo_port_t * p, int atype) vevo_storage_t **list = (vevo_storage_t**)malloc(sizeof(vevo_storage_t*) * n ); memset(list,0,sizeof(vevo_storage_t*) * n ); - if( port->table) + if( port->table) { hnode_t *node; hscan_t scan; @@ -1495,46 +1538,51 @@ static vevo_storage_t **vevo_list_nodes_(vevo_port_t * p, int atype) while((node=hash_scan_next(&scan)) != NULL) { s = hnode_get(node); - if( s->atom_type == atype ) + if( s->atom_type == atype || atype == 0) { int type = 0; - atom_get_value(s, 0, &type); - if( type != PORT_TYPE_FILTER_CLASS || + int ec = atom_get_value(s, 0, &type); + /* if( type != PORT_TYPE_FILTER_CLASS || type != PORT_TYPE_CHANNEL_TEMPLATE || type != PORT_TYPE_PARAMETER_TEMPLATE || type != PORT_TYPE_PLUGIN_INFO || - !(s->flags & VEVO_PROPERTY_SOFTREF) ) + !(s->flags & VEVO_PROPERTY_SOFTREF) )*/ + + if( ec == VEVO_NO_ERROR && !s->softlink ) list[i++] = s; } } } - else + else + { + vevo_property_t *l = port->list; + vevo_property_t *n; + vevo_storage_t *s; + while( l != NULL ) { - vevo_property_t *l = port->list; - vevo_property_t *n; - vevo_storage_t *s; - while( l != NULL ) + n = l->next; + s = l->st; + + if( s->atom_type == atype || atype == 0 ) { - n = l->next; - s = l->st; - - if( s->atom_type == atype ) - { - int type = 0; - int ec = atom_get_value(l->st, 0, &type); - if( (type != PORT_TYPE_FILTER_CLASS || - type != PORT_TYPE_CHANNEL_TEMPLATE || - type != PORT_TYPE_PARAMETER_TEMPLATE || - type != PORT_TYPE_PLUGIN_INFO ) && - ec != VEVO_ERROR_PROPERTY_EMPTY && + int type = 0; + int ec = atom_get_value(l->st, 0, &type); + /* if( (type != PORT_TYPE_FILTER_CLASS || + type != PORT_TYPE_CHANNEL_TEMPLATE || + type != PORT_TYPE_PARAMETER_TEMPLATE || + type != PORT_TYPE_PLUGIN_INFO ) && + ec != VEVO_ERROR_PROPERTY_EMPTY && !(s->flags & VEVO_PROPERTY_SOFTREF)) - + */ + if( ec == VEVO_NO_ERROR && !s->softlink ) list[i++] = s; - } - l = n; } + l = n; } - + } +#ifdef STRICT_CHECKING + assert( i < 256 ); +#endif return list; } @@ -1569,8 +1617,13 @@ void *vevo_port_register( vevo_port_t *in, vevo_port_t *ref ) { void *port = in; const void *store = ref; +#ifndef STRICT_CHECKING if(!port) port = vevo_port_new( VEVO_PORT_POOL ); +#else + if(!port) + port = vevo_port_new( VEVO_PORT_POOL, __FUNCTION__, __LINE__ ); +#endif char pkey[32]; #ifdef STRICT_CHECKING @@ -1695,33 +1748,154 @@ void vevo_port_recursive_free( vevo_port_t *port ) assert( sor != NULL ); #endif int i; - //char **item = vevo_list_properties( sor ); vevo_storage_t **item = vevo_list_nodes_( sor, VEVO_ATOM_TYPE_PORTPTR ); if(!item) { - veejay_msg(0, "Port %p empty ?!", port ); vevo_port_free(sor); #ifdef STRICT_CHECKING - assert( 0 ); + assert( 0 ); #endif return; } #ifdef STRICT_CHECKING assert( item != NULL ); + int n_freed = 0; #endif for( i = 0; item[i] != NULL ; i ++ ) { - void *port = NULL; - atom_get_value( item[i],0,&port ); + void *sub_port = NULL; + + int ec = atom_get_value( item[i],0,&sub_port ); + if( ec == VEVO_NO_ERROR ) + { #ifdef STRICT_CHECKING - assert(port != NULL); + assert(sub_port != NULL); + n_freed++; #endif - vevo_port_free( port ); + vevo_port_free( sub_port ); + } } free(item); vevo_port_free( sor ); } + +char **vevo_port_deepen_namespace( void *port, char *path) +{ + char **top_level = vevo_list_properties(port); + int k; + int error; + int num = 0; + if(!top_level) + { + return 0; + } + num = vevo_num_properties(port ); + + if( num == 0 ) + { + return NULL; + } + char **res = (char**) malloc( sizeof(char*) * (num+1)); + memset(res,0,sizeof(char*) * (num+1)); + int n = 0; + + for( k = 0; top_level[k] != NULL ; k ++ ) + { + int atom_type = vevo_property_atom_type( port, top_level[k] ); + if( atom_type != VEVO_ATOM_TYPE_VOIDPTR && atom_type != VEVO_ATOM_TYPE_PORTPTR ) + { + int len = strlen(path) + 2; + len += strlen( top_level[k] ); + res[n] = (char*) malloc(sizeof(char) * len ); + snprintf(res[n],len,"%s/%s",path,top_level[k]); + n++; + } + free(top_level[k]); + } + free(top_level); + res[n] = NULL; + return res; +} + +char **vevo_port_recurse_namespace( vevo_port_t *port, const char *base ) + +{ + + char **top_level = vevo_list_properties(port); + if(!top_level) + return NULL; + int k; + int num = 0; + for( k = 0; top_level[k] != NULL ; k ++ ) + { + int atom_type = vevo_property_atom_type( port, top_level[k] ); + if( atom_type != VEVO_ATOM_TYPE_VOIDPTR ) + { + if( atom_type == VEVO_ATOM_TYPE_PORTPTR ) + { + void *p = NULL; + int error = vevo_property_get( port, top_level[k],0,&p ); + if( error == VEVO_NO_ERROR ) + num += vevo_num_properties(p); + } + num++; + } + } + +#ifdef STRICT_CHECKING + assert( num > 0 ); +#endif + + char **namespace = (char**) malloc(sizeof(char*) * (num+1) ); + memset(namespace, 0,sizeof(char*) * (num+1)); + int methods = 0; + int error; + for( k = 0; top_level[k] != NULL ; k ++ ) + { + int atom_type = vevo_property_atom_type( port, top_level[k] ); + char path[256]; + + sprintf(path, "%s", base); + + if( atom_type == VEVO_ATOM_TYPE_PORTPTR ) + { + void *exp = NULL; + error = vevo_property_get( port, top_level[k],0,&exp ); +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif + int depth = 0; + strcat( path, "/" ); + strcat( path, top_level[k] ); + + char **ns = vevo_port_deepen_namespace( exp, path ); + if( ns ) + { + int j; + for( j = 0; ns[j] != NULL ; j ++ ) + { + namespace[methods] = strdup( ns[j]); + methods++; + free(ns[j]); + } + free(ns); + } + } + else if( atom_type != VEVO_ATOM_TYPE_VOIDPTR ) + { + strcat( path, "/" ); + strcat( path, top_level[k] ); + } + + namespace[ methods ] = strdup( path ); + methods ++; + + free(top_level[k]); + } + free(top_level); + return namespace; +} //! Flatten all ports and return list of ports to be destroyed /*! \param sorted_port Reference Port @@ -1735,7 +1909,7 @@ static void vevo_port_recurse_free( vevo_port_t *sorted_port, vevo_port_t *p ) vevo_storage_t **item = vevo_list_nodes_( p, VEVO_ATOM_TYPE_PORTPTR ); if(!item) { - veejay_msg(1, "%s: port %p empty", p ); + free(item); return; } @@ -1809,6 +1983,15 @@ static int vevo_port_ref_verify( vevo_port_t *p) if( ref_count != 0 ) { +#ifdef STRICT_CHECKING + void *which_port = NULL; + error = vevo_property_get( port_ref_, item[i],0, &which_port ); + if( error ) + veejay_msg(0, "Port '%s' retrieval returns error %d", item[i],error ); + else + veejay_msg(0, "Reference to Port %s exists, but may be invalid", item[i]); +#endif + veejay_msg(0, "Port '%s' reference count is %d",item[i], ref_count); err++; } @@ -1943,7 +2126,7 @@ char *vevo_format_kind( vevo_port_t *port, const char *key ) break; case VEVO_ATOM_TYPE_PORTPTR: token[0] = 'p'; - break; + break; default: token[0] = 'g'; break; diff --git a/veejay-ng/libyuv/subsample.c b/veejay-ng/libyuv/subsample.c index 0080cd1d..537a854b 100644 --- a/veejay-ng/libyuv/subsample.c +++ b/veejay-ng/libyuv/subsample.c @@ -128,13 +128,13 @@ void subsample_free(void *data) free(sampler->YUV_to_YCbCr[0]); if(sampler->YUV_to_YCbCr[1]) free(sampler->YUV_to_YCbCr[1]); - free(sampler); if(sampler->planes[0]) free(sampler->planes[0]); if(sampler->planes[1]) free(sampler->planes[1]); if(sampler->planes[2]) free(sampler->planes[2]); + free(sampler); } sampler = NULL; } diff --git a/veejay-ng/tools/Makefile.am b/veejay-ng/tools/Makefile.am index 3c8009ad..473d6979 100644 --- a/veejay-ng/tools/Makefile.am +++ b/veejay-ng/tools/Makefile.am @@ -2,20 +2,12 @@ MAINTAINERCLEANFILES = Makefile.in INCLUDES = -I$(top_srcdir) \ -I$(includedir) \ - -I$(top_scrdir)/libvjmem \ - -I$(top_srcdir)/libvjmsg \ - -I$(top_srcdir)/libvjnet \ - $(MJPEGTOOLS_CFLAGS) $(GLIB_CFLAGS) + -I${LIBLO_CFLAGS} -VJLIBS = $(top_builddir)/libvjnet/libvjnet.la \ - $(top_builddir)/libvjmsg/libvjmsg.la \ - $(top_builddir)/libvjmem/libvjmem.la +sayOSC_SOURCES = veejay-talk.c +sayOSC_LDADD = ${LIBLO_LIBS} -sayVIMS_SOURCES = sayVIMS.c -sayVIMS_LDFLAGS = $(LAV_ALL_LIB_OPTS) -sayVIMS_LDADD = $(VJLIBS) @LIBGETOPT_LIB@ - -YUV2RAWDV_BIN = sayVIMS +YUV2RAWDV_BIN = sayOSC bin_PROGRAMS = \ $(YUV2RAWDV_BIN) diff --git a/veejay-ng/tools/sayVIMS.c b/veejay-ng/tools/sayVIMS.c deleted file mode 100644 index b1af26da..00000000 --- a/veejay-ng/tools/sayVIMS.c +++ /dev/null @@ -1,251 +0,0 @@ -/* sendVIMS - very simple client for VeeJay - * (C) 2002-2004 Niels Elburg - * - * - * 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -static int port_num = 3490; -static char *filename = NULL; -static char *group_name = NULL; -static char *host_name = NULL; -static vj_client *sayvims = NULL; -static int colors = 0; -static int fd_in = 0; // stdin -static int single_msg = 0; -static int dump = 0; - -/* count played frames (delay) */ -static void vj_flush(int frames) { - int n = 0; - char status[100]; - bzero(status,100); - - while(frames>0) { - if( vj_client_poll(sayvims, V_STATUS )) - { - char sta_len[6]; - bzero(sta_len, 6 ); - int nb = vj_client_read( sayvims, V_STATUS, sta_len, 5 ); - if(sta_len[0] == 'V' ) - { - int bytes = 0; - sscanf( sta_len + 1, "%03d", &bytes ); - if(bytes > 0 ) - { - bzero(status, 100); - int n = vj_client_read(sayvims,V_STATUS,status,bytes); - if( n ) - { - if(dump) fprintf(stdout , "%s\n", status ); - frames -- ; - } - if(n == -1) - { - - exit(0); - } - } - } - } - } -} - -static void Usage(char *progname) -{ - veejay_msg(VEEJAY_MSG_INFO, "Usage: %s [options] [messages]",progname); - veejay_msg(VEEJAY_MSG_INFO, "where options are:"); - veejay_msg(VEEJAY_MSG_INFO, " -p\t\tVeejay port (3490)"); - veejay_msg(VEEJAY_MSG_INFO, " -g\t\tVeejay groupname (224.0.0.31)"); - veejay_msg(VEEJAY_MSG_INFO, " -h\t\tVeejay hostname (localhost)"); - veejay_msg(VEEJAY_MSG_INFO, " -m\t\tSend single message"); - veejay_msg(VEEJAY_MSG_INFO, " -c\t\tColored output"); - veejay_msg(VEEJAY_MSG_INFO, " -d\t\tDump status to stdout"); - veejay_msg(VEEJAY_MSG_INFO, "Messages to send to veejay must be wrapped in quotes"); - veejay_msg(VEEJAY_MSG_INFO, "You can send multiple messages by seperating them with a whitespace"); - veejay_msg(VEEJAY_MSG_INFO, "Example: %s \"600:;\"",progname); - veejay_msg(VEEJAY_MSG_INFO, " (quit veejay)"); - veejay_msg(VEEJAY_MSG_INFO, "Example: echo \"%03d:;\" | %s ", VIMS_QUIT, progname); - - exit(-1); -} - -static int set_option(const char *name, char *value) -{ - int err = 0; - if(strcmp(name, "h") == 0 ) - { - host_name = strdup(optarg); - if(group_name) err ++; - } - else if(strcmp(name, "g") == 0) - { - if(host_name) err ++; - group_name = strdup( optarg ); - } - else if (strcmp(name, "p") == 0) - { - port_num = atoi(optarg); - } - else if (strcmp(name, "c") == 0) - { - colors = 1; - } - else if (strcmp(name, "m") == 0 ) - { - single_msg = 1; - } - else if(strcmp(name, "d") == 0) - { - dump = 1; - } - else err++; - - return err; -} - -static char buf[65535]; - -vj_client *sayvims_connect(void) -{ - vj_client *client = vj_client_alloc( 0,0,0 ); - if(host_name == NULL) - host_name = strdup( "localhost" ); - - if(!vj_client_connect( client, host_name,group_name, port_num )) - { - return NULL; - } - return client; -} - -int main(int argc, char *argv[]) -{ - int i; - int n = 0; - int x = 0; - int k =0; - char msg[20]; - char option[2]; - char ibuf[1024]; - int err = 0; - FILE *infile; - // parse commandline parameters - while( ( n = getopt(argc,argv, "h:g:p:micd")) != EOF) - { - sprintf(option,"%c",n); - err += set_option( option,optarg); - } - - veejay_set_colors(colors); - - if( optind > argc ) - err ++; - if ( err ) - Usage(argv[0]); - - bzero( buf, 65535 ); - - // make connection with veejay - sayvims = sayvims_connect(); - if(!sayvims) - { - veejay_msg(VEEJAY_MSG_ERROR, "Cannot connect to %s", host_name); - exit(1); - } - veejay_msg(VEEJAY_MSG_INFO, - "Connected to %s", host_name ); - - if(single_msg || (optind == 1 && err == 0 && argc > 1 )) - { - char **msg = argv + optind; - int nmsg = argc - optind; - i=0; - while( i < nmsg ) - { - if(msg[i][0] == '+') - { - int delay = 1; - char *tmp = msg[i]; - if(sscanf(tmp + 1, "%d",&delay) == 1 ) - { - vj_flush(delay); - } - else - { - veejay_msg(VEEJAY_MSG_ERROR, "Fatal: error parsing %s", tmp ); - exit(-1); - } - } - else - { - int n = vj_client_send( sayvims,V_CMD, msg[i] ); -// vj_flush(1); - } - i++; - } - } - else - { - /* read from stdin*/ - int not_done = 1; - infile = fdopen( fd_in, "r" ); - if(!infile) - { - veejay_msg(VEEJAY_MSG_ERROR, "Cannot read from STDIN"); - return 0; - } - veejay_msg(VEEJAY_MSG_ERROR, "Reading from STDIN"); - while( fgets(buf, 100, infile) ) - { - if( buf[0] == '+' ) - { - int wait_ = 1; - - if(sscanf( buf+1, "%d", &wait_ ) ) - { - vj_flush( wait_ ); - } - else - { - veejay_msg(VEEJAY_MSG_ERROR, "Delay not valid: '%s'", wait_ ); - } - } - else - { - vj_client_send( sayvims, V_CMD, buf ); - } - } - } - veejay_msg(VEEJAY_MSG_INFO, "%s done ", argv[0]); - vj_client_close(sayvims); - vj_client_free(sayvims); - return 0; -} diff --git a/veejay-ng/tools/veejay-talk.c b/veejay-ng/tools/veejay-talk.c new file mode 100644 index 00000000..eef79d64 --- /dev/null +++ b/veejay-ng/tools/veejay-talk.c @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2004 Steve Harris, Uwe Koloska + * + * 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. + * + * $Id: example_client.c,v 1.1.1.1 2004/08/07 22:21:02 theno23 Exp $ + */ +#include +#include + +#include +#include +#include + +#include "lo/lo.h" + +static void Usage(const char *progname) +{ + fprintf(stderr, "Usage: %s [address] [port] [format] [path] {arguments}\n",progname ); + exit(0); +} + +int main(int argc, char *argv[]) +{ + const char *addr = argv[1]; + if(!addr || argc < 5) + Usage(argv[0]); + const char *port = argv[2]; + const char *format = argv[3]; + + lo_address t = lo_address_new(addr, port); + if(!t) + { + fprintf(stderr, "Failed to communicate with %s:%s\n",addr,port); + Usage(argv[0]); + } + const char *path = argv[4]; + lo_message msg = lo_message_new(); + int i; + int n = 5; + + while (*format ) + { + if( *format == 'i' ) { + lo_message_add_int32( msg, atoi( argv[n] )); n ++ ; + } else if( *format == 'd' ) { + lo_message_add_double( msg, atof( argv[n] )); n ++ ; + } else if ( *format == 's' ) { + lo_message_add_string( msg, (char*) argv[n] ); n ++ ; + } else if ( *format == 'h' ) { + lo_message_add_string( msg, (int64_t) atoll( argv[n]) ); n++ ; + } else { + // fprintf(stderr, "Unknown format identifier %c", *format ); + // return 0; + } + *format++; + } + + lo_send_message( t,path, msg ); + + return 0; +} + diff --git a/veejay-ng/veejay/Makefile.am b/veejay-ng/veejay/Makefile.am index c8366bbf..1b3d6d7f 100644 --- a/veejay-ng/veejay/Makefile.am +++ b/veejay-ng/veejay/Makefile.am @@ -33,10 +33,9 @@ VEEJAY_ALL_LIB_OPTS = \ libveejay_la_SOURCES = vj-misc.c \ vj-pjack.c performer.c \ gl.c vj-sdl.c \ - vj-eventman.c \ - vj-event.c \ oscsend.c \ oscservit.c \ + oscevents.c \ liblavplayvj.c libveejay_la_LDFLAGS = $(VEEJAY_ALL_LIB_OPTS ) diff --git a/veejay-ng/veejay/liblavplayvj.c b/veejay-ng/veejay/liblavplayvj.c index d3aea678..0923b141 100644 --- a/veejay-ng/veejay/liblavplayvj.c +++ b/veejay-ng/veejay/liblavplayvj.c @@ -73,7 +73,7 @@ #include #include #include -#include +//#include #include #include #include @@ -103,6 +103,60 @@ int veejay_get_state(veejay_t *info) { video_playback_setup *settings = (video_playback_setup*)info->settings; return settings->state; } + +sample_video_info_t *veejay_get_ps(void *data) +{ + veejay_t *v = (veejay_t*) data; + return v->video_info; +} +int veejay_osc_verify_format( void *vevo_port, char const *types ) +{ + char *format = get_str_vevo( vevo_port, "format" ); + int n = strlen(types); + if(!format) + { + if( (n ==0 || types == NULL) && format == NULL ) + return 1; + return 0; + } + if( strcasecmp( types,format ) == 0 ) + { + free(format); + return 1; + } + free(format); + return 0; +} + +int veejay_osc_property_calls_event( void *instance, const char *path, char *types, void **argv[] ) +{ + veejay_t *v = (veejay_t*) instance; + void *vevo_port = v->osc_namespace; + + int atom_type = vevo_property_atom_type( vevo_port, path ); + if( atom_type == VEVO_ATOM_TYPE_PORTPTR ) + { + void *port = NULL; + int error = vevo_property_get( vevo_port, path,0,&port ); + + if(error == VEVO_NO_ERROR ) + { + vevo_event_f f; + if( veejay_osc_verify_format( port, types ) ) + { + error = vevo_property_get( port, "func",0,&f ); + if( error == VEVO_NO_ERROR ) + { + (*f)( instance,path, types, argv ); + return 1; + } + } + } + } + + return 0; +} + //! Change Veejay state /**! \param info Veejay Object @@ -541,7 +595,7 @@ int veejay_open(veejay_t * info) memset( &(settings->lastframe_completion), 0, sizeof(struct timeval)); pthread_mutex_init(&(settings->valid_mutex), NULL); pthread_mutex_init(&(settings->syncinfo_mutex), NULL); - pthread_mutex_init( &(info->display_mutex), 0 ); + pthread_mutex_init( &(info->vevo_mutex), 0 ); /* Invalidate all buffers, and initialize the conditions */ settings->valid[0] = 0; @@ -689,12 +743,20 @@ int veejay_close(veejay_t * info) void veejay_deinit(veejay_t *info) { - vj_server_shutdown(info->status_socket); - vj_server_shutdown(info->command_socket); - vj_server_shutdown(info->frame_socket); - veejay_free_osc_server(info->osc_server ); - vj_event_stop(); + //vj_event_stop(); samplebank_free(); + + veejay_osc_del_methods( info,info->osc_namespace,info ,info); + + vevo_port_recursive_free( info->osc_namespace ); + + + +// vj_server_shutdown(info->status_socket); +// vj_server_shutdown(info->command_socket); +// vj_server_shutdown(info->frame_socket); + veejay_free_osc_server(info->osc_server ); + plug_sys_free(); performer_destroy(info); vj_el_deinit(); @@ -734,7 +796,8 @@ int veejay_load_devices( veejay_t *info ) } else { - samplebank_add_sample( sample ); + int id = samplebank_add_sample( sample ); + sample_set_user_data( sample,info, id ); } } @@ -752,7 +815,10 @@ int veejay_load_samples( veejay_t *info, const char **argv, int n_arg ) void *sample = sample_new( VJ_TAG_TYPE_COLOR ); if( sample_open(sample, NULL, 0, vid_info ) <= 0 ) return 0; + //sample_set_user_data(sample,info); id = samplebank_add_sample( sample ); + sample_set_user_data(sample,info, id); + veejay_load_video_settings(info, id ); return 1; } @@ -769,6 +835,8 @@ int veejay_load_samples( veejay_t *info, const char **argv, int n_arg ) else { id = samplebank_add_sample( sample ); + sample_set_user_data(sample,info,id); + veejay_msg(0, "Loaded '%s' to sample %d", argv[n], id ); } } @@ -801,7 +869,7 @@ int veejay_init(veejay_t * info) veejay_msg(VEEJAY_MSG_INFO, "\tPlugin(s) loaded: %d", n); // veejay_msg(VEEJAY_MSG_INFO,"Loaded %d Plugins",n); - vj_event_init(); +/* vj_event_init(); if(!vj_server_setup(info)) { @@ -812,7 +880,7 @@ int veejay_init(veejay_t * info) { veejay_msg(VEEJAY_MSG_INFO, "TCP/UDP service (port range %d-%d)", info->port_offset, info->port_offset+5); - } + }*/ vj_el_set_itu601_preference( info->itu601 ); @@ -906,7 +974,7 @@ int veejay_init(veejay_t * info) void veejay_playback_status( veejay_t *info ) { - char status_message[300]; +/* char status_message[300]; int len = strlen( info->message ); @@ -929,7 +997,7 @@ void veejay_playback_status( veejay_t *info ) _vj_server_del_client( info->command_socket,info->current_link ); _vj_server_del_client( info->frame_socket, info->current_link ); } - //sample_sprintf_port( info->current_sample); + //sample_sprintf_port( info->current_sample);*/ } @@ -992,7 +1060,7 @@ static void veejay_playback_cycle(veejay_t * info) veejay_mjpeg_queue_buf(info, 0, 1); stats.nqueue = 1; - int last_id = sample_get_key_ptr( info->current_sample); + int last_id = sample_get_key_ptr( info->current_sample); while (settings->state != VEEJAY_STATE_STOP) { first_free = stats.nsync; @@ -1026,7 +1094,7 @@ static void veejay_playback_cycle(veejay_t * info) stats.tdiff = time_now.tv_sec - bs.timestamp.tv_sec + (time_now.tv_usec - bs.timestamp.tv_usec)*1.e-6; - vj_event_update_remote( info ); + //vj_event_update_remote( info ); } while (stats.tdiff > settings->spvf && (stats.nsync - first_free) < (1 - 1)); @@ -1165,7 +1233,7 @@ int vj_server_setup(veejay_t * info) { int port = info->port_offset; - info->command_socket = vj_server_alloc(port, NULL, V_CMD); + /*info->command_socket = vj_server_alloc(port, NULL, V_CMD); if(!info->command_socket) return 0; @@ -1177,17 +1245,65 @@ int vj_server_setup(veejay_t * info) info->frame_socket = vj_server_alloc(port, NULL, V_MSG ); if(!info->frame_socket) return 0; - +*/ const char port_str[50]; sprintf(port_str, "%d",port ); info->osc_server = veejay_new_osc_server( (void*)info, port_str ); - +#ifdef STRICT_CHECKING + info->osc_namespace = vevo_port_new( VEVO_ANONYMOUS_PORT, __FUNCTION__, __LINE__ ); +#else + info->osc_namespace = vevo_port_new( VEVO_ANONYMOUS_PORT ); +#endif + veejay_osc_namespace_events( (void*) info, "/veejay"); + // info->mcast_socket = // vj_server_alloc(port, info->settings->vims_group_name, V_CMD ); // GoMultiCast( info->settings->group_name ); return 1; } +#define VALID_RESOLUTION(w,h,x,y) (( (w >=64 && w<=2048) && (h >= 64 && h <= 2048) && (x >= 0 && x <2048) && (y>=0 && y <2048)) ? 1: 0 ) + + +void veejay_resize_screen( void *info, int x, int y, int w, int h ) +{ + veejay_t *v = (veejay_t*) info; + if(!VALID_RESOLUTION(w,h,x,y)) + { + veejay_msg(VEEJAY_MSG_ERROR,"Invalid dimensions for video window. Width and Height must be >= 64 and <= 2048"); + return; + + } + if( v->use_display == 2) + { + veejay_msg(VEEJAY_MSG_INFO, "OpenGL video window is %gx%g+%gx%g", + w,h,x,y ); + x_display_resize( w,h,x,y ); + } + if( v->use_display == 1 ) + { + if(vj_sdl_resize_window(v->display,w,h,x,y)) + veejay_msg(VEEJAY_MSG_INFO, "SDL video window is %dx%d+%dx%d", + w,h,x,y); + } +} + +void veejay_fullscreen(void *info, int value) +{ + veejay_t *v = (veejay_t*) info; + if( v->use_display == 2 ) + { + if(x_display_set_fullscreen( v->display, value )) + veejay_msg(VEEJAY_MSG_INFO,"OpenGL display window Fullscreen %s", + value == 0 ? "disabled" : "enabled"); + } + if( v->use_display == 1 ) + { + if(vj_sdl_set_fullscreen( v->display, value )) + veejay_msg(VEEJAY_MSG_INFO,"SDL display window fullsceen %s", + value == 0 ? "disabled" : "enabled"); + } +} /****************************************************** * veejay_malloc() @@ -1219,10 +1335,24 @@ veejay_t *veejay_malloc() info->settings->currently_processed_entry = -1; info->settings->first_frame = 1; info->settings->state = VEEJAY_STATE_STOP; - info->port_offset = VJ_PORT; + info->port_offset = 3490;// VJ_PORT; samplebank_init(); available_diskspace(); + + //vj_event_init(); + + if(!vj_server_setup(info)) + { + veejay_msg(0, "Cannot setup service"); + return -1; + } + else + { + veejay_msg(VEEJAY_MSG_INFO, "TCP/UDP service (port range %d-%d)", + info->port_offset, info->port_offset+5); + } + return info; } diff --git a/veejay-ng/veejay/oscevents.c b/veejay-ng/veejay/oscevents.c new file mode 100644 index 00000000..1c071a78 --- /dev/null +++ b/veejay-ng/veejay/oscevents.c @@ -0,0 +1,673 @@ +/* veejay - Linux VeeJay + * (C) 2002-2006 Niels Elburg + * + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef STRICT_CHECKING +#include +#endif + +void osc_sample_edl_paste_at( void *ptr,const char *path, const char *types, void **dargv ) +{ + lo_arg **argv = (lo_arg**) dargv; + + if(sample_edl_paste_from_buffer( ptr, (uint64_t) argv[0]->h )) + veejay_msg( VEEJAY_MSG_INFO, "Pasted frames from buffer to position %lld", + argv[0]->h ); + else + veejay_msg(VEEJAY_MSG_INFO, "Unable to paste frames at position %lld", + argv[0]->h ); +} +void osc_sample_edl_cut( void *sample,const char *path, const char *types, void **dargv ) +{ + lo_arg **argv = (lo_arg**) dargv; + + if(sample_edl_cut_to_buffer( sample, (uint64_t) argv[0]->h, (uint64_t) argv[1]->h )) + veejay_msg(VEEJAY_MSG_INFO, "Cut frames %lld - %lld to buffer",argv[0]->h,argv[1]->h); + else + veejay_msg(VEEJAY_MSG_ERROR, "Unable to cut frames %lld - %lld",argv[0]->h,argv[1]->h); +} + +void osc_sample_edl_copy(void *sample,const char *path, const char *types, void **dargv ) +{ + lo_arg **argv = (lo_arg**) dargv; + + if( sample_edl_copy( sample, (uint64_t) argv[0]->h,(uint64_t) argv[1]->h )) + veejay_msg(VEEJAY_MSG_INFO, "Copied frames %lld - %lld to buffer",argv[0]->h,argv[1]->h); + + else + veejay_msg(VEEJAY_MSG_INFO, "Unable to copy frames %lld - %lld",argv[0]->h,argv[1]->h); +} +void osc_sample_edl_del(void *sample,const char *path, const char *types, void **dargv ) +{ + lo_arg **argv = (lo_arg**) dargv; + + if( sample_edl_delete( sample, (uint64_t) argv[0]->h,(uint64_t) argv[1]->h )) + veejay_msg(VEEJAY_MSG_INFO, "Deleted frames %lld - %lld to buffer",argv[0]->h,argv[1]->h); + + else + veejay_msg(VEEJAY_MSG_INFO, "Unable to delete frames %lld - %lld",argv[0]->h,argv[1]->h); +} +void osc_sample_play_forward(void *sample,const char *path, const char *types, void **dargv ) +{ + lo_arg **argv = (lo_arg**) dargv; + int speed = sample_get_speed( sample ); + if(speed <= 0) + { + if(speed == 0) + speed = -1; + speed *= -1; + + sample_set_property_ptr( sample, "speed", VEVO_ATOM_TYPE_INT,&speed); + } +} +void osc_sample_play_reverse(void *sample,const char *path, const char *types, void **dargv ) +{ + lo_arg **argv = (lo_arg**) dargv; + int speed = sample_get_speed( sample ); + if(speed >= 0) + { + if(speed == 0) + speed = -1; + speed *= -1; + + sample_set_property_ptr( sample, "speed", VEVO_ATOM_TYPE_INT,&speed); + } +} +void osc_sample_play_pause(void *sample,const char *path, const char *types, void **dargv ) +{ + lo_arg **argv = (lo_arg**) dargv; + int speed = sample_get_speed( sample ); + if(speed != 0) + { + speed = 0; + sample_set_property_ptr( sample, "speed", VEVO_ATOM_TYPE_INT,&speed); + } +} + +void osc_sample_set_frame(void *sample,const char *path, const char *types, void **dargv ) +{ + lo_arg **argv = (lo_arg**) dargv; + uint64_t pos = sample_get_current_pos( sample ); + uint64_t user_pos = argv[0]->h; + if(pos != user_pos) + { + if( sample_valid_pos( sample, user_pos )) + { + sample_set_property_ptr(sample, "current_pos", + VEVO_ATOM_TYPE_UINT64, &user_pos ); + veejay_msg(VEEJAY_MSG_INFO, "Position changed to %lld",user_pos); + } + else + { + veejay_msg(VEEJAY_MSG_ERROR, "Position %lld outside sample",user_pos); + } + } +} +void osc_sample_set_next_frame(void *sample,const char *path, const char *types, void **dargv ) +{ + lo_arg **argv = (lo_arg**) dargv; + uint64_t pos = sample_get_current_pos( sample ); + uint64_t user_pos = pos + 1; + if(pos != user_pos) + { + if( sample_valid_pos( sample, user_pos )) + { + sample_set_property_ptr(sample, "current_pos", + VEVO_ATOM_TYPE_UINT64, &user_pos ); + veejay_msg(VEEJAY_MSG_INFO, "Position changed to %lld",user_pos); + } + else + { + veejay_msg(VEEJAY_MSG_ERROR, "Position %lld outside sample",user_pos); + } + } +} + +void osc_sample_set_prev_frame(void *sample,const char *path, const char *types, void **dargv ) +{ + lo_arg **argv = (lo_arg**) dargv; + uint64_t pos = sample_get_current_pos( sample ); + uint64_t user_pos = pos - 1; + if(pos != user_pos) + { + if( sample_valid_pos( sample, user_pos )) + { + sample_set_property_ptr(sample, "current_pos", + VEVO_ATOM_TYPE_UINT64, &user_pos ); + veejay_msg(VEEJAY_MSG_INFO, "Position changed to %lld",user_pos); + } + else + { + veejay_msg(VEEJAY_MSG_ERROR, "Position %lld outside sample",user_pos); + } + } +} + +void osc_sample_goto_start(void *sample, const char *path, const char *types, void **dargv ) +{ + uint64_t pos = sample_get_start_pos( sample ); + sample_set_property_ptr( sample, "current_pos", + VEVO_ATOM_TYPE_UINT64, &pos ); + veejay_msg(VEEJAY_MSG_INFO, "Position changed to %lld", pos); +} +void osc_sample_goto_end(void *sample, const char *path, const char *types, void **dargv ) +{ + uint64_t pos = sample_get_end_pos( sample ); + sample_set_property_ptr( sample, "current_pos", + VEVO_ATOM_TYPE_UINT64, &pos ); + veejay_msg(VEEJAY_MSG_INFO, "Position changed to %lld", pos); +} +void osc_sample_reset_fx(void *sample,const char *path, const char *types, void **dargv ) +{ + sample_fx_chain_reset( sample ); +} + +void osc_sample_reset_fx_entry( void *sample,const char *path, const char *types, void **dargv) +{ + int fx_id = sample_extract_fx_entry_from_path(sample, path ); + if( fx_id < 0 ) + { + veejay_msg(VEEJAY_MSG_ERROR, "Outside chain boundary"); + return; + } + if(sample_fx_chain_entry_clear( sample, fx_id ) ) + veejay_msg(VEEJAY_MSG_INFO, "Cleared FX slot %d",fx_id ); +} +void osc_sample_alpha_fx_entry( void *sample,const char *path, const char *types, void **dargv) +{ + lo_arg **argv = (lo_arg**) dargv; + + int fx_id = sample_extract_fx_entry_from_path(sample, path ); + if( fx_id < 0 ) + { + veejay_msg(VEEJAY_MSG_ERROR, "Outside chain boundary"); + return; + } + + double alpha = argv[0]->d; + sample_set_fx_alpha( sample, fx_id, alpha ); +} + +void osc_sample_channel_fx_entry( void *sample,const char *path, const char *types, void **dargv) +{ + lo_arg **argv = (lo_arg**) dargv; + + int fx_id = sample_extract_fx_entry_from_path(sample, path ); + if( fx_id < 0 ) + { + veejay_msg(VEEJAY_MSG_ERROR, "Outside chain boundary"); + return; + } + + int seq = argv[0]->i; + int id = argv[1]->i; + + if( find_sample(id) ) + { + int n = sample_fx_set_in_channel( sample, fx_id, seq,id ); + if(n) + veejay_msg(VEEJAY_MSG_ERROR, "Input channel %d set to sample %d", seq, id ); + } +} +void osc_sample_set_fx_entry( void *sample,const char *path, const char *types, void **dargv) +{ + lo_arg **argv = (lo_arg**) dargv; + + int fx_id = sample_extract_fx_entry_from_path(sample, path ); + if( fx_id < 0 ) + { + veejay_msg(VEEJAY_MSG_ERROR, "Outside chain boundary"); + return; + } + + char *s = (char*) &(argv[0]->s); + int fx = plug_get_fx_id_by_name( s ); + if( fx < 0 ) + veejay_msg(VEEJAY_MSG_ERROR, "FX '%s' not found", s ); + else + { + if( sample_fx_set( sample, fx_id,fx ) ) + veejay_msg(VEEJAY_MSG_INFO, + "Added '%s' to fx_%d", + s,fx_id); + } +} +void osc_sample_bind_fx_entry( void *sample, const char *path, const char *types, void **dargv) +{ + lo_arg **argv = (lo_arg**) dargv; + + int fx_id = sample_extract_fx_entry_from_path(sample, path ); + if( fx_id < 0 ) + { + veejay_msg(VEEJAY_MSG_ERROR, "Outside chain boundary"); + return; + } + void *src_entry = sample_get_fx_port_ptr( sample,fx_id ); + if(src_entry == NULL ) + { + veejay_msg(0,"Invalid fx entry"); + return; + } + + int error = sample_new_bind( sample, src_entry, argv[0]->i, argv[1]->i, argv[2]->i ); + if( error == VEVO_NO_ERROR ) + { + veejay_msg(0, "Pushing out parameters on entry %d parameter %d -> Entry %d parameter %d", + fx_id,argv[0]->i,argv[1]->i,argv[2]->i); + } +} +void osc_sample_release_fx_entry( void *sample, const char *path, const char *types, void **dargv) +{ + lo_arg **argv = (lo_arg**) dargv; + + int fx_id = sample_extract_fx_entry_from_path(sample, path ); + if( fx_id < 0 ) + { + veejay_msg(VEEJAY_MSG_ERROR, "Outside chain boundary"); + return; + } + void *src_entry = sample_get_fx_port_ptr( sample,fx_id ); + if(src_entry == NULL ) + { + veejay_msg(0,"Invalid fx entry"); + return; + } + int error = sample_del_bind( sample, src_entry, argv[0]->i ); + if( error == VEVO_NO_ERROR ) + { + veejay_msg(0, "Detached output parameter %d on entry %d", argv[0]->i,fx_id ); + } +} +void osc_sample_bind_osc_fx_entry( void *sample, const char *path, const char *types, void **dargv) +{ + lo_arg **argv = (lo_arg**) dargv; + + int fx_id = sample_extract_fx_entry_from_path(sample, path ); + if( fx_id < 0 ) + { + veejay_msg(VEEJAY_MSG_ERROR, "Outside chain boundary"); + return; + } + sample_add_osc_path( sample, (char*) &(argv[0]->s), fx_id ); +} +void osc_sample_release_osc_fx_entry( void *sample, const char *path, const char *types, void **dargv) +{ + lo_arg **argv = (lo_arg**) dargv; + + int fx_id = sample_extract_fx_entry_from_path(sample, path ); + if( fx_id < 0 ) + { + veejay_msg(VEEJAY_MSG_ERROR, "Outside chain boundary"); + return; + } + sample_del_osc_path( sample, fx_id ); +} + + +void osc_sample_parameter_sender_start( void *sample,const char *path, const char *types, void **dargv) +{ + lo_arg **argv = (lo_arg**) dargv; + sample_new_osc_sender( sample, (char*)&(argv[0]->s), (char*) &(argv[1]->s) ); +} + +void osc_sample_parameter_sender_stop( void *sample,const char *path, const char *types, void **dargv) +{ + sample_close_osc_sender( sample ); +} + +void osc_sample_config_record(void *sample,const char *path, const char *types, void **dargv) +{ + lo_arg **argv = (lo_arg**) dargv; + + int error = sample_configure_recorder( sample, + argv[0]->i, (char*) &(argv[2]->s), argv[1]->i ); + if( error ) + veejay_msg(0, "Unable to configure the recorder"); +} +void osc_sample_record_start(void *sample,const char *path, const char *types, void **dargv) +{ + lo_arg **argv = (lo_arg**) dargv; + + int error = sample_start_recorder( sample ); + if( error ) + veejay_msg(0, "Unable to start the sample recorder"); +} +void osc_sample_record_stop(void *sample,const char *path, const char *types, void **dargv) +{ + lo_arg **argv = (lo_arg**) dargv; + + int error = sample_stop_recorder( sample ); + if( error ) + veejay_msg(0, "Unable to stop the sample recorder"); +} + +void osc_veejay_quit(void *info,const char *path, const char *types, void **dargv) +{ + lo_arg **argv = (lo_arg**) dargv; + veejay_change_state( info, VEEJAY_STATE_STOP ); +} +void osc_veejay_resize(void *info,const char *path, const char *types, void **dargv) +{ + lo_arg **argv = (lo_arg**) dargv; + veejay_resize_screen( info, argv[0]->i,argv[1]->i,argv[2]->i,argv[3]->i); +} +void osc_veejay_fullscreen(void *info,const char *path, const char *types, void **dargv) +{ + lo_arg **argv = (lo_arg**) dargv; + veejay_fullscreen( info, argv[0]->i ); +} +void osc_veejay_select( void *info,const char *path, const char *types, void **dargv) +{ + lo_arg **argv = (lo_arg**) dargv; + int id = argv[0]->i; + veejay_t *v = (veejay_t*) info; + void *sample = v->current_sample; + void *res = sample; + + if( id > 0 ) + { + res = find_sample( id ); + } + else if( id == -1 ) + res = sample_last(); + + if(sample == res) + { + uint64_t pos = sample_get_start_pos( v->current_sample ); + sample_set_property_ptr( + v->current_sample, "current_pos", VEVO_ATOM_TYPE_UINT64, &pos ); + } + else + { + sample_save_cache_data( v->current_sample ); + v->current_sample = res; + } +} +void osc_veejay_new_sample(void *info,const char *path, const char *types, void **dargv) +{ + lo_arg **argv = (lo_arg**) dargv; + int type = argv[0]->i; + int token = argv[1]->i; + char *str = &(argv[2]->s); + veejay_t *v = (veejay_t*) info; + void *sample = sample_new( type ); + if(!sample) + { + veejay_msg(0, "Invalid type"); + return; + } + if(sample_open( sample, str,token, v->video_info)) + { + int new_id = samplebank_add_sample( sample ); + const char *type_str = sample_describe_type( type ); + + sample_set_user_data( sample,info,new_id ); + veejay_msg(VEEJAY_MSG_INFO,"Created new %s from %s as Sample %d", + type_str, str, new_id ); + } + else + { + veejay_msg(VEEJAY_MSG_ERROR,"Could not create sample from %s",token); + } +} + +void osc_veejay_del_sample(void *info,const char *path, const char *types, void **dargv) +{ + lo_arg **argv = (lo_arg**) dargv; + int id = argv[0]->i; + veejay_t *v = (veejay_t*) info; + void *sample = find_sample(id); + if(sample == v->current_sample) + veejay_msg(0, "Cannot delete current playing sample"); + else + if(sample_delete( id ) ) + veejay_msg(0, "Deleted sample %d", id ); +} + +void osc_sample_print( void *sample,const char *path, const char *types, void **dargv) +{ + sample_osc_namespace( sample ); +} + + +static struct +{ + const char *name; + const char *format; + const char *args[4]; + const char *descr; + vevo_event_f func; +} fx_events_[] = { + { "clear", NULL, {NULL,NULL,NULL,NULL }, "Delete plugin" , osc_sample_reset_fx_entry }, + { "alpha", "d", {"Alpha value 0.0 - 1.0",NULL,NULL,NULL }, "Opacity", osc_sample_alpha_fx_entry }, + { "input_channel","ii", {"Input Channel", "Sample ID", NULL,NULL}, "Set a plugin's input channel", + osc_sample_channel_fx_entry }, + { "set", "s", {"FX plugin name", NULL,NULL,NULL }, "Initialize a plugin", + osc_sample_set_fx_entry }, + { "bind", "iii",{"Output parameter ID", + "Bind to FX entry", + "Input Parameter ID", + NULL }, "Bind output parameter to some input parameter", + osc_sample_bind_fx_entry }, + { "release", NULL, { NULL,NULL,NULL }, "Release bind between output and input parameter", + osc_sample_release_fx_entry }, + { "bind_osc", "s", { "OSC message", NULL,NULL,NULL }, "Bind an OSC Path to an output parameter", + osc_sample_bind_osc_fx_entry }, + { "release_osc", NULL, { NULL,NULL,NULL,NULL}, "Release OSC Path", + osc_sample_release_osc_fx_entry }, + { NULL, NULL, { NULL,NULL,NULL,NULL}, NULL, NULL } +}; + +static struct +{ + const char *name; + const char *format; + const char *args[4]; + const char *descr; + vevo_event_f func; +} sample_generic_events_[] = +{ + { "reset_fx", NULL, { NULL,NULL,NULL,NULL }, "Delete all plugins", osc_sample_reset_fx }, + { "register_param_sender","ss", { "Address" , "Port Number",NULL,NULL }, + "Initialize a new OSC sender", + osc_sample_parameter_sender_start }, + { "unregister_param_sender", NULL, { NULL, NULL,NULL,NULL },"Close OSC sender", + osc_sample_parameter_sender_stop }, + { "rec/config", "iis", { "Format", "Frames", "Filename" , NULL },"Configure sample recorder", + osc_sample_config_record }, + { "rec/start", NULL, { NULL,NULL,NULL,NULL },"Start recording from sample", + osc_sample_record_start }, + { "rec/stop", NULL, { NULL,NULL,NULL,NULL },"Stop recording from sample", + osc_sample_record_stop }, + { "print", NULL, { NULL,NULL,NULL,NULL },"Print OSC namespace", osc_sample_print }, + { NULL, NULL, { NULL,NULL,NULL,NULL },NULL, NULL }, + +}; + +static struct +{ + const char *name; + const char *format; + const char *args[4]; + const char *descr; + vevo_event_f func; +} sample_nonstream_events_[] = +{ + { "video/play", NULL, { NULL,NULL,NULL,NULL },"Play video forward", osc_sample_play_forward }, + { "video/reverse",NULL, { NULL,NULL,NULL,NULL },"Play video backward", osc_sample_play_reverse }, + { "video/pause", NULL, { NULL,NULL,NULL,NULL },"Pause video", osc_sample_play_pause }, + { "video/frame", "h", { "Frame number",NULL,NULL,NULL }, "Set a frame", osc_sample_set_frame }, + { "video/next_frame",NULL, { NULL,NULL,NULL,NULL },"Goto next frame", osc_sample_set_next_frame }, + { "video/prev_frame",NULL, { NULL,NULL,NULL,NULL },"Goto previous frame", osc_sample_set_prev_frame }, + { "video/goto_start", NULL, { NULL,NULL,NULL,NULL },"Goto starting position", osc_sample_goto_start }, + { "video/goto_end", NULL, { NULL,NULL,NULL,NULL },"Goto ending position", osc_sample_goto_end }, + { "edl/paste_at", "h", { "Destination frame number", NULL,NULL,NULL },"Paste from buffer at position", osc_sample_edl_paste_at }, + { "edl/cut", "hh", { "Selection start","Selection end",NULL,NULL },"Cut to buffer from selection", osc_sample_edl_cut }, + { "edl/copy", "hh", { "Selection start","Selection end",NULL,NULL },"Copy to buffer from selection",osc_sample_edl_copy }, + { "edl/del", "hh", { "Selection start","Selection end",NULL,NULL },"Delete without using buffer", osc_sample_edl_del }, + { NULL, NULL, { NULL,NULL,NULL,NULL }, NULL }, + +}; + + +static struct +{ + const char *name; + const char *format; + const char *args[4]; + const char *descr; + vevo_event_f func; +} veejay_events_[] = +{ + { "quit", NULL, { NULL,NULL,NULL,NULL },"Quit Veejay-NG", osc_veejay_quit }, + { "resize", "iiii", { "X offset", "Y offset", "Width", "Height" },"Resize video window", osc_veejay_resize }, + { "fullscreen","i", { "On=1, Off=0",NULL,NULL,NULL },"Fullscreen video window", osc_veejay_fullscreen }, + { "select", "i", { "Sample ID", NULL,NULL,NULL },"Select a sample", osc_veejay_select }, + { "new" , "iis", { "Sample Type", "Numeric value", "Filename" , NULL }, "Create a new sample", osc_veejay_new_sample }, + { "del" , "i", { "Sample ID", NULL, NULL, NULL },"Delete sample", osc_veejay_del_sample }, + { NULL, NULL, { NULL,NULL,NULL,NULL }, NULL }, + +}; + + +static void osc_fx_generic_event( + lo_server_thread *st, + void *user_data, + void *osc_port, + void *vevo_port, + const char *base, + const char *key, + const char *format, + const char **args, + const char *descr, + vevo_event_f *func ) +{ + vevosample_new_event( + user_data, + osc_port, + vevo_port, // Instance! + base, + key, + format, + args, + descr, + func, + 0 + ); +} +void osc_add_sample_generic_events( lo_server_thread *st, void *user_data, void *osc_port, void *vevo_port, const char *base, int chain_len ) +{ + int i; + for( i = 0; sample_generic_events_[i].name != NULL ; i ++ ) + { + vevosample_new_event( + user_data, + osc_port, + vevo_port, + base, + sample_generic_events_[i].name, + sample_generic_events_[i].format, + sample_generic_events_[i].args, + sample_generic_events_[i].descr, + sample_generic_events_[i].func, + 0 ); + } + + for( i =0; i < chain_len ; i ++ ) + { + char name[20]; + sprintf(name, "%s/fx_%d", base, i ); + + int k; + for( k = 0; fx_events_[k].name != NULL ; k ++ ) + { + vevosample_new_event( + user_data, + osc_port, + vevo_port, + name, + fx_events_[k].name, + fx_events_[k].format, + fx_events_[k].args, + fx_events_[k].descr, + fx_events_[k].func, + 0 + ); + } + } +} + + +void osc_add_sample_nonstream_events( lo_server_thread *st, void *user_data, void *osc_port, void *vevo_port, const char *base ) +{ + int i; + for( i =0 ; sample_nonstream_events_[i].name != NULL ; i ++ ) + { + vevosample_new_event( + user_data, + osc_port, + vevo_port, + base, + sample_nonstream_events_[i].name, + sample_nonstream_events_[i].format, + sample_nonstream_events_[i].args, + sample_nonstream_events_[i].descr, + sample_nonstream_events_[i].func, + 0 + ); + } +} + +void osc_add_veejay_events( lo_server_thread *st, void *user_data, void *osc_port, const char *base ) +{ + int i; + for( i = 0; veejay_events_[i].name != NULL ; i ++ ) + { + veejay_new_event( + user_data, + osc_port, + user_data, + base, + veejay_events_[i].name, + veejay_events_[i].format, + veejay_events_[i].args, + veejay_events_[i].descr, + veejay_events_[i].func, + 0 + ); + } +} + + diff --git a/veejay-ng/veejay/oscservit.c b/veejay-ng/veejay/oscservit.c index 93db6c3b..1ae00192 100644 --- a/veejay-ng/veejay/oscservit.c +++ b/veejay-ng/veejay/oscservit.c @@ -31,91 +31,46 @@ #include #include #include - - +#include +#include //@ client side implementation #ifdef STRICT_CHECKING #include #endif #include - +typedef struct { + int seq; + void *caller; + void *instance; +} plugin_data_t; typedef struct { lo_server_thread st; - void *events; +// void *events; } osc_recv_t; -static struct -{ - const char *path; - int id; -} osc_paths_[] = { - { "/sample/new", VIMS_SAMPLE_NEW }, - { "/sample/select", VIMS_SAMPLE_SELECT }, - { "/sample/del", VIMS_SAMPLE_DEL }, - { "/sample/set/properties", VIMS_SAMPLE_SET_PROPERTIES }, - { "/load/samplelist", VIMS_SAMPLE_LOAD }, - { "/save/samplelist", VIMS_SAMPLE_SAVE }, - { "/sample/rec/start", VIMS_SAMPLE_START_RECORDER }, - { "/sample/rec/stop", VIMS_SAMPLE_STOP_RECORDER }, - { "/sample/rec/configure", VIMS_SAMPLE_CONFIGURE_RECORDER }, - { "/sample/set/volume", VIMS_SAMPLE_SET_VOLUME }, - { "/sample/fxc/active", VIMS_SAMPLE_CHAIN_ACTIVE }, - { "/sample/edl/paste_at", VIMS_SAMPLE_EDL_PASTE_AT }, - { "/sample/edl/copy", VIMS_SAMPLE_EDL_COPY }, - { "/sample/edl/del", VIMS_SAMPLE_EDL_DEL }, - { "/sample/edl/crop", VIMS_SAMPLE_EDL_CROP }, - { "/sample/edl/cut", VIMS_SAMPLE_EDL_CUT }, - { "/sample/edl/append", VIMS_SAMPLE_EDL_ADD }, - { "/sample/edl/export", VIMS_SAMPLE_EDL_EXPORT }, - { "/sample/edl/load", VIMS_SAMPLE_EDL_LOAD }, - { "/sample/edl/save", VIMS_SAMPLE_EDL_SAVE }, - { "/sample/chain/clear", VIMS_SAMPLE_CHAIN_CLEAR }, - { "/sample/chain/entry/select", VIMS_SAMPLE_CHAIN_SET_ENTRY }, - { "/sample/chain/entry/set", VIMS_SAMPLE_CHAIN_ENTRY_SET_FX }, - { "/sample/chain/entry/preset", VIMS_SAMPLE_CHAIN_ENTRY_SET_PRESET }, - { "/sample/chain/entry/active", VIMS_SAMPLE_CHAIN_ENTRY_SET_ACTIVE }, - { "/sample/chain/entry/value", VIMS_SAMPLE_CHAIN_ENTRY_SET_VALUE }, - { "/sample/chain/entry/channel", VIMS_SAMPLE_CHAIN_ENTRY_SET_INPUT }, - { "/sample/chain/entry/alpha", VIMS_SAMPLE_CHAIN_ENTRY_SET_ALPHA }, - { "/sample/chain/entry/clear", VIMS_SAMPLE_CHAIN_ENTRY_CLEAR }, - { "/sample/chain/entry/state", VIMS_SAMPLE_CHAIN_ENTRY_SET_STATE }, - { "/sample/chain/entry/bind", VIMS_SAMPLE_ATTACH_OUT_PARAMETER }, - { "/sample/chain/entry/release", VIMS_SAMPLE_DETACH_OUT_PARAMETER }, - { "/sample/chain/entry/register_osc_path", VIMS_SAMPLE_BIND_OUTP_OSC }, - { "/sample/chain/entry/unregister_osc_path",VIMS_SAMPLE_RELEASE_OUTP_OSC }, - { "/sample/register_osc_client", VIMS_SAMPLE_OSC_START }, - { "/sample/unregister_osc_client", VIMS_SAMPLE_OSC_STOP }, - { "/samplebank/add", VIMS_SAMPLEBANK_ADD }, - { "/samplebank/del", VIMS_SAMPLEBANK_DEL }, - { "/play", VIMS_SAMPLE_PLAY_FORWARD }, - { "/reverse", VIMS_SAMPLE_PLAY_BACKWARD }, - { "/pause", VIMS_SAMPLE_PLAY_STOP }, - { "/skip", VIMS_SAMPLE_SKIP_FRAME }, - { "/prev", VIMS_SAMPLE_PREV_FRAME }, - { "/up", VIMS_SAMPLE_SKIP_SECOND }, - { "/down", VIMS_SAMPLE_PREV_SECOND }, - { "/start", VIMS_SAMPLE_GOTO_START }, - { "/end", VIMS_SAMPLE_GOTO_END }, - { "/frame", VIMS_SAMPLE_SET_FRAME }, - { "/speed", VIMS_SAMPLE_SET_SPEED }, - { "/slow", VIMS_SAMPLE_SET_SLOW }, - - { "/fullscreen", VIMS_FULLSCREEN }, - { "/audio", VIMS_AUDIO_SET_ACTIVE }, - { "/resize", VIMS_RESIZE_SCREEN }, - - { NULL, 0 } - -}; - void error_handler( int num, const char *msg, const char *path ) { veejay_msg(0,"Liblo server error %d in path %s: %s",num,path,msg ); } +static char *osc_create_path( const char *base, const char *path ) +{ + int n = strlen(base) + strlen(path) + 2; + char *res = (char*) malloc(n); + bzero(res,n); + sprintf(res,"%s/%s", base,path); + return res; +} -typedef void (*osc_event)(void *ptr, const char format[], va_list ap); +static char *osc_fx_pair_str( const char *base, const char *key ) +{ + int n = strlen(base) + strlen(key) + 2; + char *res = (char*) malloc(n); + bzero(res,n); + snprintf( res,n, "%s/%s", base,key); + return res; +} static char *vevo_str_to_liblo( const char *format ) @@ -136,119 +91,417 @@ static char *vevo_str_to_liblo( const char *format ) return res; } -int generic_handler( const char *path, const char *types, +static char make_valid_char_( const char c ) +{ + const char *invalid = " #*,?[]{}"; + int k = 0; + char o = '_'; + char r = c; + for( k = 0; k < 8 ; k ++ ) + { + if ( c == invalid[k] || isspace((unsigned char)c)) + return o; + char l = tolower(c); + if(l) + r = l; + } + return r; +} + +char *veejay_valid_osc_name( const char *in ) +{ + int n = strlen( in ); + int k; + char *res = strdup( in ); + for( k = 0; k < n ; k ++ ) + { + res[k] = make_valid_char_( in[k] ); + } + return res; +} + +void veejay_osc_del_methods( void *user_data, void *osc_space,void *vevo_port, void *fx_instance ) +{ + veejay_t *info = (veejay_t*) user_data; + osc_recv_t *s = (osc_recv_t*) info->osc_server; + + char **keys = vevo_list_properties( osc_space ); + int i; + int error; + for( i = 0; keys[i] != NULL ; i ++ ) + { + void *event_port = NULL; + error = vevo_property_get( osc_space, keys[i],0,&event_port ); +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif + + void *ptr = NULL; + error = vevo_property_get( event_port, "userdata",0, &ptr ); + +#ifdef STRICT_CHECKING + assert(error == VEVO_NO_ERROR ); + assert( ptr != NULL ); +#endif + + char *types = get_str_vevo( event_port, "format" ); + + lo_server_thread_del_method( s->st, keys[i], types ); + + free(keys[i]); + if(types) + free(types); + free(ptr); + } + free(keys); + +} + + + +//@ plugin handler! +int osc_plugin_handler( const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data ) { - int vims_id = 0; - int args[16]; - double gargs[16]; - char *str[16]; - int i; - int n = 0; - int s = 0; - int g = 0; - veejay_t *info = (veejay_t*) user_data; - osc_recv_t *st = (osc_recv_t*) info->osc_server; + plugin_data_t *pd = (plugin_data_t*) user_data; + veejay_t *info = pd->caller; - int error = vevo_property_get( st->events, path,0, &vims_id ); - - memset(str, 0, sizeof(str)); - - if( vims_id == 0 || error != VEVO_NO_ERROR) + pthread_mutex_lock( &(info->vevo_mutex) ); + char *required_format = plug_get_osc_format( pd->instance, pd->seq ); + if( strcmp( required_format , types ) != 0 ) { - veejay_msg(0, "OSC path '%s' does not exist", path ); + veejay_msg(0, "Plugin Path %s wrong format '%s' , need '%s'", + path,types, required_format ); + pthread_mutex_unlock( &(info->vevo_mutex) ); + + return 1; + } + + int n_elem = strlen(required_format); +#ifdef STRICT_CHECKING + assert( n_elem == argc ); +#endif + int k; + if( types[0] == 'i' ) + { + int32_t *elements = (int32_t*) malloc(sizeof(int32_t) * n_elem ); + for( k = 0; k < n_elem; k ++ ) + elements[k] = argv[k]->i32; + plug_set_parameter( pd->instance, pd->seq, n_elem, (void*)elements ); + free(elements); + } + else if( types[0] == 'd' ) + { + double *elements = (double*) malloc(sizeof(double) * n_elem ); + for( k = 0; k < n_elem; k ++ ) + elements[k] = argv[k]->d; + plug_set_parameter( pd->instance, pd->seq, n_elem, (void*) elements ); + free(elements); + } + else if( types[0] == 's' ) + { + char *strs = malloc(sizeof(char*) * n_elem ); + for( k = 0; k < n_elem; k ++ ) + strs[k] = strdup( (char*) &argv[k]->s ); + plug_set_parameter( pd->instance,pd->seq, n_elem, (void*) strs ); + } + + pthread_mutex_unlock( &(info->vevo_mutex)); + + return 0; +} +int osc_veejay_handler( const char *path, const char *types, + lo_arg **argv, int argc, void *data, void *user_data ) +{ + plugin_data_t *pd = (plugin_data_t*) user_data; + veejay_t *info = pd->caller; + pthread_mutex_lock( &(info->vevo_mutex) ); + // format of KEY in path!! + + if( veejay_osc_property_calls_event( pd->instance, + path, + types, + argv )) + { + pthread_mutex_unlock( &(info->vevo_mutex)); return 0; } + + pthread_mutex_unlock( &(info->vevo_mutex)); + return 1; +} + +int osc_sample_handler( const char *path, const char *types, + lo_arg **argv, int argc, void *data, void *user_data ) +{ + plugin_data_t *pd = (plugin_data_t*) user_data; + veejay_t *info = pd->caller; + pthread_mutex_lock( &(info->vevo_mutex) ); + if( sample_osc_property_calls_event( pd->instance, + path, + types, + argv )) + { + pthread_mutex_unlock( &(info->vevo_mutex) ); + + return 0; + } + + char *required_format = sample_property_format_osc( pd->instance, path ); + if(required_format == NULL ) + { + veejay_msg(0, "Invalid path '%s'", path); + pthread_mutex_unlock( &(info->vevo_mutex) ); + + return 1; + } + if( strcmp( required_format , types ) != 0 ) + { + veejay_msg(0, "Sample Path %s wrong format '%s' , need '%s'", + path,types, required_format ); + pthread_mutex_unlock( &(info->vevo_mutex) ); - int vims_args = vj_event_vevo_get_num_args( vims_id ); - - char *format = vj_event_vevo_get_event_format( vims_id ); - - for( i = 0; i < argc ; i ++ ) - { - switch(types[i]) - { - case 'i': - args[n++] = argv[i]->i32; - break; - - case 's': - str[s++] = strdup( (char*) &argv[i]->s ); - break; - - case 'd': - gargs[g++] = argv[i]->d; - break; - - default: - veejay_msg(0, "Skipping unknown argument type '%c' ", - types[i]); - break; - - } + return 1; } - if( vims_args != (n + s) ) + int n_elem = strlen(required_format); +#ifdef STRICT_CHECKING + assert( n_elem == argc ); +#endif + int k; + if( types[0] == 'i' ) { - char *name = vj_event_vevo_get_event_name( vims_id ); - char *loarg = vevo_str_to_liblo(format); - veejay_msg(0, "Wrong number of arguments for VIMS %d (%s)", vims_id, name); - veejay_msg(0, "FORMAT is '%s' but I received '%s'", loarg, types ); - free(name); - if(loarg) free(loarg); + int32_t *elements = (int32_t*) malloc(sizeof(int32_t) * n_elem ); + for( k = 0; k < n_elem; k ++ ) + elements[k] = argv[k]->i32; + sample_set_property_from_path( pd->instance, path, (void*)elements ); + free(elements); } - else + else if( types[0] == 'd' ) { - vj_event_fire_net_event( info, - vims_id, - str[0], - args, - n + s, - 0, - gargs, - g ); + double *elements = (double*) malloc(sizeof(double) * n_elem ); + for( k = 0; k < n_elem; k ++ ) + elements[k] = argv[k]->d; + sample_set_property_from_path( pd->instance, path, (void*)elements ); + + free(elements); } - if(format) - free(format); + else if( types[0] == 's' ) + { + char **strs = malloc(sizeof(char*) * n_elem ); + for( k = 0; k < n_elem; k ++ ) + strs[k] = strdup( (char*) &argv[k]->s ); + sample_set_property_from_path( pd->instance, path, (void*)strs ); + } + else if( types[0] == 'h' ) + { + uint64_t *elements = malloc(sizeof(uint64_t) * n_elem ); + for( k = 0; k < n_elem; k ++ ) + elements[k] = argv[k]->h; + sample_set_property_from_path( pd->instance, path, (void*) elements ); + } + + free(required_format); - for( i = 0; i < 16 ; i ++ ) - if( str[i] ) - free(str[i]); + pthread_mutex_unlock( &(info->vevo_mutex)); return 0; } +void veejay_osc_add_sample_generic_events(void *user_data, void *osc_port, void *vevo_port, const char *base, int fx) +{ + veejay_t *info = (veejay_t*) user_data; + osc_recv_t *s = (osc_recv_t*) info->osc_server; + osc_add_sample_generic_events( s->st, user_data,osc_port,vevo_port,base,fx ); +} + +void veejay_osc_add_sample_nonstream_events(void *user_data, void *osc_port, void *vevo_port, const char *base) +{ + veejay_t *info = (veejay_t*) user_data; + osc_recv_t *s = (osc_recv_t*) info->osc_server; + osc_add_sample_nonstream_events( s->st, user_data,osc_port,vevo_port,base ); +} + +void veejay_osc_namespace_events(void *user_data, const char *base) +{ + veejay_t *info = (veejay_t*) user_data; + osc_recv_t *s = (osc_recv_t*) info->osc_server; + osc_add_veejay_events( s->st, user_data, info->osc_namespace,base ); +} void *veejay_new_osc_server( void *data, const char *port ) { osc_recv_t *s = (osc_recv_t*) vj_malloc(sizeof( osc_recv_t)); s->st = lo_server_thread_new( port, error_handler ); - - s->events = vevo_port_new( VEVO_ANONYMOUS_PORT ); - - int i; - for( i =0; osc_paths_[i].path != NULL ; i ++ ) - { - int error = - vevo_property_set( s->events, osc_paths_[i].path, VEVO_ATOM_TYPE_INT,1, - &(osc_paths_[i].id) ); - lo_server_thread_add_method( - s->st, - NULL, - NULL, - generic_handler, - data ); - veejay_msg(0, "Added '%s", osc_paths_[i].path ); - } lo_server_thread_start( s->st ); + veejay_msg( 0, "OSC server ready at UDP port %d", lo_server_thread_get_port(s->st) ); return (void*) s; } + +static int servit_new_event( + void *userdata, + void *osc_space, + void *instance, + const char *base, + const char *key, + const char *fmt, + const char **args, + const char *descr, + vevo_event_f *func, + int extra_token, + lo_method_handler method ) +{ + veejay_t *info = (veejay_t*) userdata; + osc_recv_t *s = (osc_recv_t*) info->osc_server; +#ifdef STRICT_CHECKING + void *p = (void*) vevo_port_new( VEVO_ANONYMOUS_PORT,__FUNCTION__,__LINE__ ); +#else + void *p = (void*) vevo_port_new( VEVO_ANONYMOUS_PORT ); +#endif + int error; + + if( func ) + { + error = vevo_property_set( p, "func", VEVO_ATOM_TYPE_VOIDPTR,1,&func ); +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif + } + + if( fmt == NULL ) + error = vevo_property_set( p, "format", VEVO_ATOM_TYPE_STRING,0,NULL ); + else + error = vevo_property_set( p, "format", VEVO_ATOM_TYPE_STRING,1, &fmt ); +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif + + if( descr == NULL ) + error = vevo_property_set(p, "description",VEVO_ATOM_TYPE_STRING,0, NULL ); + else + error = vevo_property_set(p, "description", VEVO_ATOM_TYPE_STRING,1, &descr ); + +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif + + if( args ) + { + int i; + for( i = 0;i < 4; i ++ ) + { + if(args[i]) + { + char index[10]; + sprintf(index,"help_%d",i); + error = vevo_property_set( p, index, VEVO_ATOM_TYPE_STRING,1,&(args[i]) ); +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif + } + } + } + + plugin_data_t *pd = (plugin_data_t*) malloc(sizeof(plugin_data_t)); + pd->seq = extra_token; + pd->caller = userdata; + pd->instance = instance; + error = vevo_property_set( p, + "userdata", + VEVO_ATOM_TYPE_VOIDPTR, + 1, + &pd ); + +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif + + char *tmp_path = NULL; + if( base) + tmp_path = osc_create_path( base, key ); + else + tmp_path = strdup(key); + + char *my_path = veejay_valid_osc_name( tmp_path ); + + error = vevo_property_set( osc_space, + my_path, + VEVO_ATOM_TYPE_PORTPTR, + 1, + &p ); + +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif + + lo_server_thread_add_method( + s->st, + my_path, + fmt, + method, + (void*) pd ); + + free(my_path); + free(tmp_path); + + return VEVO_NO_ERROR; +} + +int vevosample_new_event( + void *userdata, + void *osc_space, + void *instance, + const char *base, + const char *key, + const char *fmt, + const char **args, + const char *descr, + vevo_event_f *func, + int extra_token) +{ + return servit_new_event( userdata,osc_space,instance,base,key,fmt,args,descr,func,extra_token, + osc_sample_handler ); +} + +int veejay_new_event( + void *userdata, + void *osc_space, + void *instance, + const char *base, + const char *key, + const char *fmt, + const char **args, + const char *descr, + vevo_event_f *func, + int extra_token) +{ + return servit_new_event( userdata,osc_space,instance,base,key,fmt,args,descr,func,extra_token, + osc_veejay_handler ); +} + +int plugin_new_event( + void *userdata, + void *osc_space, + void *instance, + const char *base, + const char *key, + const char *fmt, + const char **args, + const char *descr, + vevo_event_f *func, + int extra_token) +{ + return servit_new_event( userdata,osc_space,instance,base,key,fmt,args,descr,func,extra_token, + osc_plugin_handler ); +} + void veejay_free_osc_server( void *dosc ) { osc_recv_t *s = (osc_recv_t*) dosc; lo_server_thread_stop( s->st ); - vevo_port_free( s->events ); + lo_server_thread_free( s->st ); +// vevo_port_free( s->events ); free(s); s = NULL; } diff --git a/veejay-ng/veejay/oscservit.h b/veejay-ng/veejay/oscservit.h index ecb6bfb5..54fe5395 100644 --- a/veejay-ng/veejay/oscservit.h +++ b/veejay-ng/veejay/oscservit.h @@ -20,4 +20,43 @@ */ void *veejay_new_osc_server( void *data, const char *port ); void veejay_free_osc_server( void *dosc ); + +void veejay_osc_del_methods( void *user_data, void *osc_space,void *vevo_port, void *fx_instance ); + +int plugin_new_event( + void *userdata, + void *osc_space, + void *instance, + const char *base, + const char *key, + const char *fmt, + const char **args, + const char *descr, + void *func, + int extra_token); + +int veejay_new_event( + void *userdata, + void *osc_space, + void *instance, + const char *base, + const char *key, + const char *fmt, + const char **args, + const char *descr, + void *func, + int extra_token); + + +int vevosample_new_event( + void *userdata, + void *osc_space, + void *instance, + const char *base, + const char *key, + const char *fmt, + const char **args, + const char *descr, + void *func, + int extra_token); #endif diff --git a/veejay-ng/veejay/performer.c b/veejay-ng/veejay/performer.c index 6f3824de..11a1198d 100644 --- a/veejay-ng/veejay/performer.c +++ b/veejay-ng/veejay/performer.c @@ -654,6 +654,8 @@ static int performer_fetch_frames( veejay_t *info, void *samples_needed) void *value = NULL; int error = vevo_property_get( samples_needed,fetch_list[k],0, &Sk); #ifdef STRICT_CHECKING + if( error != VEVO_NO_ERROR ) + veejay_msg(0, "Error fetching '%s' , error code %d", fetch_list[k], error ); assert( error == VEVO_NO_ERROR ); #endif value = (void*) p->ref_buffer[ n_fetched ]; @@ -860,7 +862,6 @@ static int performer_push_in_frames( void *sample, performer_t *p, int i ) return tmp1; } - static int performer_render_entry( veejay_t *info, void *sample, performer_t *p, int i) { int opacity = sample_get_fx_alpha( sample, i ); @@ -950,11 +951,20 @@ int performer_queue_frame( veejay_t *info, int skip_incr ) #ifdef STRICT_CHECKING assert( info->current_sample != NULL ); #endif + +#ifdef STRICT_CHECKING + void *queue_list = vevo_port_new( VEVO_ANONYMOUS_PORT, __FUNCTION__ , __LINE__ ); + assert( queue_list != NULL ); +#else void *queue_list = vevo_port_new( VEVO_ANONYMOUS_PORT );//ll - +#endif int i; int error = 0; + + + pthread_mutex_lock( &(info->vevo_mutex)); + if(!skip_incr) { char key[64]; @@ -965,7 +975,8 @@ int performer_queue_frame( veejay_t *info, int skip_incr ) assert( error == VEVO_NO_ERROR ); #endif } - + + //@ lock for( i = 0; i < SAMPLE_CHAIN_LEN; i ++ ) { if( sample_process_entry( info->current_sample, i )) @@ -977,13 +988,20 @@ int performer_queue_frame( veejay_t *info, int skip_incr ) #endif } } +#ifdef STRICT_CHECKING + p->in_frames = vevo_port_new( VEVO_ANONYMOUS_PORT, __FUNCTION__ , __LINE__ ); +#else /* Build reference list */ p->in_frames = vevo_port_new( VEVO_ANONYMOUS_PORT ); - +#endif performer_fetch_frames( info, queue_list ); performer_render_frame(info, p); + pthread_mutex_unlock( &(info->vevo_mutex)); + + //@ unlock + vevo_port_free( queue_list ); vevo_port_free( p->in_frames ); p->in_frames = NULL; diff --git a/veejay-ng/veejay/veejay.c b/veejay-ng/veejay/veejay.c index 718034d1..4d4f8c1e 100644 --- a/veejay-ng/veejay/veejay.c +++ b/veejay-ng/veejay/veejay.c @@ -345,8 +345,8 @@ int main(int argc, char **argv) if( dump_ ) { - vj_init_vevo_events(); - vj_event_vevo_dump(); + // vj_init_vevo_events(); + // vj_event_vevo_dump(); return 0; } diff --git a/veejay-ng/veejay/veejay.h b/veejay-ng/veejay/veejay.h index e85a2e06..b28b242e 100644 --- a/veejay-ng/veejay/veejay.h +++ b/veejay-ng/veejay/veejay.h @@ -115,17 +115,17 @@ typedef struct int audio; void *display; - void *status_socket; - void *command_socket; - void *frame_socket; - void *mcast_socket; +// void *status_socket; +// void *command_socket; +// void *frame_socket; +// void *mcast_socket; void *osc_server; - + void *osc_namespace; int current_link; int port_offset; int use_display; void *sdl_display; - pthread_mutex_t display_mutex; + pthread_mutex_t vevo_mutex; int itu601; char message[256]; diff --git a/veejay-ng/veejay/vims.h b/veejay-ng/veejay/vims.h index 9a28a98a..148d1259 100644 --- a/veejay-ng/veejay/vims.h +++ b/veejay-ng/veejay/vims.h @@ -26,113 +26,79 @@ */ enum { - VIMS_BUNDLE_START = 500, - VIMS_BUNDLE_END = 599, - VIMS_MAX = 702, + VIMS_MAX = 650, }; enum { -/* query information */ - VIMS_EFFECT_LIST = 401, - VIMS_EDITLIST_LIST = 402, - VIMS_BUNDLE_LIST = 403, - VIMS_STREAM_DEVICES = 406, - VIMS_SAMPLE_LIST = 408, - VIMS_CHAIN_GET_ENTRY = 410, - VIMS_VIMS_LIST = 411, - VIMS_LOG = 412, - VIMS_SAMPLE_INFO = 413, /* general controls */ - VIMS_FULLSCREEN = 301, + VIMS_FULLSCREEN = 40, VIMS_QUIT = 600, - VIMS_RECORD_DATAFORMAT = 302, - VIMS_AUDIO_SET_ACTIVE = 306, - VIMS_REC_AUTO_START = 320, - VIMS_REC_STOP = 321, - VIMS_REC_START = 322, - VIMS_BEZERK = 324, - VIMS_DEBUG_LEVEL = 325, - VIMS_RESIZE_SCREEN = 326, - VIMS_SCREENSHOT = 330, - VIMS_RGB24_IMAGE = 333, - -/* video controls */ - VIMS_SAMPLE_PLAY_FORWARD = 10, - VIMS_SAMPLE_PLAY_BACKWARD = 11, - VIMS_SAMPLE_PLAY_STOP = 12, - VIMS_SAMPLE_SKIP_FRAME = 13, - VIMS_SAMPLE_PREV_FRAME = 14, - VIMS_SAMPLE_SKIP_SECOND = 15, - VIMS_SAMPLE_PREV_SECOND = 16, - VIMS_SAMPLE_GOTO_START = 17, - VIMS_SAMPLE_GOTO_END = 18, - VIMS_SAMPLE_SET_FRAME = 19, - VIMS_SAMPLE_SET_SPEED = 20, - VIMS_SAMPLE_SET_SLOW = 21, -/* editlist commands */ - + VIMS_BEZERK = 11, + VIMS_DEBUG_LEVEL = 12, + VIMS_RESIZE_SCREEN = 41, + VIMS_SCREENSHOT = 13, VIMS_SAMPLE_NEW = 100, VIMS_SAMPLE_SELECT = 101, - VIMS_SAMPLE_DEL = 120, - VIMS_SAMPLE_SET_PROPERTIES = 103, - VIMS_SAMPLE_LOAD = 125, - VIMS_SAMPLE_SAVE = 126, - VIMS_SAMPLE_DEL_ALL = 121, - VIMS_SAMPLE_COPY = 127, - VIMS_SAMPLE_REC_START = 130, - VIMS_SAMPLE_REC_STOP = 131, - VIMS_SAMPLE_CHAIN_ACTIVE = 112, - VIMS_SAMPLE_SET_VOLUME = 132, - VIMS_SAMPLE_EDL_PASTE_AT = 50, - VIMS_SAMPLE_EDL_COPY = 51, - VIMS_SAMPLE_EDL_DEL = 52, - VIMS_SAMPLE_EDL_CROP = 53, - VIMS_SAMPLE_EDL_CUT = 54, - VIMS_SAMPLE_EDL_ADD = 55, - VIMS_SAMPLE_EDL_SAVE = 58, - VIMS_SAMPLE_EDL_LOAD = 59, - VIMS_SAMPLE_EDL_EXPORT = 56, + VIMS_SAMPLE_DEL = 102, + VIMS_SAMPLE_COPY = 103, + VIMS_SAMPLE_LOAD = 104, + VIMS_SAMPLE_SAVE = 105, + + VIMS_SAMPLE_PLAY_FORWARD = 110, + VIMS_SAMPLE_PLAY_BACKWARD = 111, + VIMS_SAMPLE_PLAY_STOP = 112, + VIMS_SAMPLE_SKIP_FRAME = 113, + VIMS_SAMPLE_PREV_FRAME = 114, + VIMS_SAMPLE_SKIP_SECOND = 115, + VIMS_SAMPLE_PREV_SECOND = 116, + VIMS_SAMPLE_GOTO_START = 117, + VIMS_SAMPLE_GOTO_END = 118, + VIMS_SAMPLE_SET_FRAME = 119, + VIMS_SAMPLE_SET_SPEED = 120, + VIMS_SAMPLE_SET_SLOW = 121, + VIMS_SAMPLE_SET_PROPERTIES = 123, + VIMS_SAMPLE_EDL_PASTE_AT = 150, + VIMS_SAMPLE_EDL_COPY = 151, + VIMS_SAMPLE_EDL_DEL = 152, + VIMS_SAMPLE_EDL_CROP = 153, + VIMS_SAMPLE_EDL_CUT = 154, + VIMS_SAMPLE_EDL_ADD = 155, + VIMS_SAMPLE_EDL_SAVE = 158, + VIMS_SAMPLE_EDL_LOAD = 159, + VIMS_SAMPLE_EDL_EXPORT = 156, + VIMS_SAMPLE_CHAIN_SET_ACTIVE = 130, + VIMS_SAMPLE_CHAIN_CLEAR = 131, + VIMS_SAMPLE_CHAIN_LIST = 132, + VIMS_SAMPLE_CHAIN_SET_ENTRY = 133, + VIMS_SAMPLE_CHAIN_ENTRY_SET_FX = 134, + VIMS_SAMPLE_CHAIN_ENTRY_SET_PRESET = 135, + VIMS_SAMPLE_CHAIN_ENTRY_SET_ACTIVE = 136, + VIMS_SAMPLE_CHAIN_ENTRY_SET_VALUE = 137, + VIMS_SAMPLE_CHAIN_ENTRY_SET_INPUT = 138, + VIMS_SAMPLE_CHAIN_ENTRY_CLEAR = 139, + VIMS_SAMPLE_ATTACH_OUT_PARAMETER = 180, + VIMS_SAMPLE_DETACH_OUT_PARAMETER = 181, - VIMS_SAMPLE_CHAIN_SET_ACTIVE = 353, - VIMS_SAMPLE_CHAIN_CLEAR = 355, - VIMS_SAMPLE_CHAIN_LIST = 358, - VIMS_SAMPLE_CHAIN_SET_ENTRY = 359, - VIMS_SAMPLE_CHAIN_ENTRY_SET_FX = 360, - VIMS_SAMPLE_CHAIN_ENTRY_SET_PRESET = 361, - VIMS_SAMPLE_CHAIN_ENTRY_SET_ACTIVE = 363, - VIMS_SAMPLE_CHAIN_ENTRY_SET_VALUE = 366, - VIMS_SAMPLE_CHAIN_ENTRY_SET_INPUT = 367, - VIMS_SAMPLE_CHAIN_ENTRY_CLEAR = 369, - VIMS_SAMPLE_CHAIN_ENTRY_SET_ALPHA = 370, - - VIMS_SAMPLE_CHAIN_ENTRY_SET_STATE = 377, - VIMS_SAMPLE_ATTACH_OUT_PARAMETER = 378, - VIMS_SAMPLE_DETACH_OUT_PARAMETER = 379, + VIMS_SAMPLE_BIND_OUTP_OSC = 190, + VIMS_SAMPLE_RELEASE_OUTP_OSC = 191, + VIMS_SAMPLE_OSC_START = 192, + VIMS_SAMPLE_OSC_STOP = 193, - VIMS_SAMPLE_BIND_OUTP_OSC = 380, - VIMS_SAMPLE_RELEASE_OUTP_OSC = 381, - VIMS_SAMPLE_OSC_START = 382, - VIMS_SAMPLE_OSC_STOP = 383, - - VIMS_SAMPLE_CONFIGURE_RECORDER = 390, - VIMS_SAMPLE_START_RECORDER = 391, - VIMS_SAMPLE_STOP_RECORDER = 392, + VIMS_SAMPLE_CONFIGURE_RECORDER = 124, + VIMS_SAMPLE_START_RECORDER = 125, + VIMS_SAMPLE_STOP_RECORDER = 126, - VIMS_PERFORMER_SETUP_PREVIEW = 400, - VIMS_PERFORMER_GET_PREVIEW = 401, + VIMS_PERFORMER_SETUP_PREVIEW = 20, + VIMS_PERFORMER_GET_PREVIEW = 21, - VIMS_SAMPLEBANK_LIST = 402, - VIMS_SAMPLEBANK_ADD = 403, - VIMS_SAMPLEBANK_DEL = 404, - VIMS_FX_LIST = 405, - VIMS_FX_DETAILS = 406, - VIMS_FX_CURRENT_DETAILS = 407, - VIMS_FX_CHAIN = 408, + VIMS_SAMPLEBANK_LIST = 1, + VIMS_SAMPLEBANK_ADD = 2, + VIMS_SAMPLEBANK_DEL = 3, - VIMS_GET_FRAME = 42, + VIMS_GET_FRAME = 5, - VIMS_SET_PORT = 650, - VIMS_GET_PORT = 649, + VIMS_SET_PORT = 99, + VIMS_GET_PORT = 97, }; #endif diff --git a/veejay-ng/veejay/vj-event.c b/veejay-ng/veejay/vj-event.c deleted file mode 100644 index 0380b182..00000000 --- a/veejay-ng/veejay/vj-event.c +++ /dev/null @@ -1,2060 +0,0 @@ -/* - * Linux VeeJay - * - * Copyright(C)2002-2004 Niels Elburg - * - * 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 - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef STRICT_CHECKING -#include -#endif - -#define SEND_BUF 125000 -#define MSG_MIN_LEN 4 -#define MESSAGE_SIZE 300 - -static int _last_known_num_args = 0; - -/* define the function pointer to any event */ -typedef void (*vj_event)(void *ptr, const char format[], va_list ap); - -/* struct for runtime initialization of event handlers */ -typedef struct { - int list_id; // VIMS id - vj_event act; // function pointer -} vj_events; - -static vj_events net_list[VIMS_MAX]; - -static char _print_buf[SEND_BUF]; -static char _s_print_buf[SEND_BUF]; - -enum { - VJ_ERROR_NONE=0, - VJ_ERROR_MODE=1, - VJ_ERROR_EXISTS=2, - VJ_ERROR_VIMS=3, - VJ_ERROR_DIMEN=4, - VJ_ERROR_MEM=5, - VJ_ERROR_INVALID_MODE = 6, -}; - -#define VIMS_REQUIRE_ALL_PARAMS (1<<0) /* all params needed */ -#define VIMS_DONT_PARSE_PARAMS (1<<1) /* dont parse arguments */ -#define VIMS_LONG_PARAMS (1<<3) /* long string arguments (bundle, plugin) */ -#define VIMS_ALLOW_ANY (1<<4) /* use defaults when optional arguments are not given */ - -#define FORMAT_MSG(dst,str) sprintf(dst,"%03d%s",strlen(str),str) -#define APPEND_MSG(dst,str) strncat(dst,str,strlen(str)) -#define SEND_MSG_DEBUG(v,str) \ -{\ -char *__buf = str;\ -int __len = strlen(str);\ -int __done = 0;\ -veejay_msg(VEEJAY_MSG_INFO, "--------------------------------------------------------");\ -for(__done = 0; __len > (__done + 80); __done += 80)\ -{\ - char *__tmp = strndup( str+__done, 80 );\ -veejay_msg(VEEJAY_MSG_INFO, "[%d][%s]",strlen(str),__tmp);\ - if(__tmp) free(__tmp);\ -}\ -veejay_msg(VEEJAY_MSG_INFO, "[%s]", str + __done );\ -vj_server_send(v->command_socket, v->current_link, __buf, strlen(__buf));\ -veejay_msg(VEEJAY_MSG_INFO, "--------------------------------------------------------");\ -} - -#define SEND_MSG(v,str)\ -{\ -vj_server_send(v->command_socket, v->current_link, str, strlen(str));\ -} -#define RAW_SEND_MSG(v,str,len)\ -{\ -vj_server_send(v->command_socket,v->current_link, str, len );\ -} - -#define SEND_LOG_MSG(v,str)\ -{\ -vj_server_send(v->frame_socket, v->current_link,str,strlen(str));\ -} - -/* some macros for commonly used checks */ -#define P_Ag(a,b,c,d,g)\ -{\ -int __z = 0;\ -int __y = 0;\ -unsigned char *__tmpstr = NULL;\ -if(a!=NULL){\ -unsigned int __rp;\ -unsigned int __rplen = (sizeof(a) / sizeof(int) );\ -for(__rp = 0; __rp < __rplen; __rp++) { a[__rp] = 0; g[__rp] = 0; }\ -}\ -while(*c) { \ -if( (__z+__y) > _last_known_num_args ) break; \ -switch(*c++) {\ - case 's':\ -__tmpstr = (char*)va_arg(d,char*);\ -if(__tmpstr != NULL) {\ - sprintf( b,"%s",__tmpstr);\ - }\ -__z++ ;\ - break;\ - case 'd': a[__z] = *( va_arg(d, int*)); __z++ ;\ - break; }\ - case 'g': g[__y] = *( va_arg(d, double*)); __y++;\ - break; }\ - }\ -} - -#define P_A(a,b,c,d)\ -{\ -int __z = 0;\ -unsigned char *__tmpstr = NULL;\ -if(a!=NULL){\ -unsigned int __rp;\ -unsigned int __rplen = (sizeof(a) / sizeof(int) );\ -for(__rp = 0; __rp < __rplen; __rp++) a[__rp] = 0;\ -}\ -while(*c) { \ -if(__z > _last_known_num_args ) break; \ -switch(*c++) {\ - case 's':\ -__tmpstr = (char*)va_arg(d,char*);\ -if(__tmpstr != NULL) {\ - sprintf( b,"%s",__tmpstr);\ - }\ -__z++ ;\ - break;\ - case 'd': a[__z] = *( va_arg(d, int*)); __z++ ;\ - break; }\ - }\ -} - -/* P_A16: Parse 16 integer arguments. This macro is used in 1 function */ -#define P_A16(a,c,d)\ -{\ -int __z = 0;\ -while(*c) { \ -if(__z > 15 ) break; \ -switch(*c++) { case 'd': a[__z] = va_arg(d, int); __z++ ; break; }\ -}}\ - - -#define DUMP_ARG(a)\ -if(sizeof(a)>0){\ -int __l = sizeof(a)/sizeof(int);\ -int __i; for(__i=0; __i < __l; __i++) veejay_msg(VEEJAY_MSG_DEBUG,"[%02d]=[%06d], ",__i,a[__i]);}\ -else { veejay_msg(VEEJAY_MSG_DEBUG,"arg has size of 0x0");} - - -#define CLAMPVAL(a) { if(a<0)a=0; else if(a >255) a =255; } -#define IS_BOOLEAN(a) ( (a == 0 || a==1) ? 1 : 0 ) -#define BOOLEAN_ERROR(i) { veejay_msg(VEEJAY_MSG_ERROR, "Argument %d must be 0 or 1",i); } - -#define VALID_RESOLUTION(w,h,x,y) (( (w >=64 && w<=2048) && (h >= 64 && h <= 2048) && (x >= 0 && x <2048) && (y>=0 && y <2048)) ? 1: 0 ) - -static inline hash_val_t int_bundle_hash(const void *key) -{ - return (hash_val_t) key; -} - -static inline int int_bundle_compare(const void *key1,const void *key2) -{ - return ((int)key1 < (int) key2 ? -1 : - ((int) key1 > (int) key2 ? +1 : 0)); -} - -static inline void* which_sample( veejay_t *info, int *args ) -{ - if(args[0] == 0 ) - return info->current_sample; - if(args[0] == -1) - return sample_last(); - void *res = find_sample( args[0] ); - if(!res) - veejay_msg(VEEJAY_MSG_ERROR, "Sample '%d' does not exist", args[0]); - return res; -} - -typedef struct { - int event_id; - int accelerator; - int modifier; - char *bundle; -} vj_msg_bundle; - - -/* forward declarations (former console sample/tag print info) */ -void vj_event_print_sample_info(veejay_t *v, int id); -//int vj_event_bundle_update( vj_msg_bundle *bundle, int bundle_id ); -//vj_msg_bundle *vj_event_bundle_get(int event_id); -//int vj_event_bundle_exists(int event_id); -//int vj_event_suggest_bundle_id(void); -//int vj_event_load_bundles(char *bundle_file); -//int vj_event_bundle_store( vj_msg_bundle *m ); -//int vj_event_bundle_del( int event_id ); -//vj_msg_bundle *vj_event_bundle_new(char *bundle_msg, int event_id); -void vj_event_trigger_function(void *ptr, vj_event f, int max_args, const char format[], ...); -//void vj_event_parse_bundle(veejay_t *v, char *msg ); -void vj_event_fire_net_event(veejay_t *v, int net_id, char *str_arg, int *args, int arglen, int type, double *gargs, int ng); -void vj_event_commit_bundle( veejay_t *v, int key_num, int key_mod); - -#ifdef HAVE_XML2 -void vj_event_format_xml_event( xmlNodePtr node, int event_id ); -void vj_event_format_xml_stream( xmlNodePtr node, int stream_id ); -#endif - -void vj_event_init(void); -/* -int vj_event_bundle_update( vj_msg_bundle *bundle, int bundle_id ) -{ - if(bundle) { - hnode_t *n = hnode_create(bundle); - if(!n) return 0; - hnode_put( n, (void*) bundle_id); - hnode_destroy(n); - return 1; - } - return 0; -} - -vj_msg_bundle *vj_event_bundle_get(int event_id) -{ - vj_msg_bundle *m; - hnode_t *n = hash_lookup(BundleHash, (void*) event_id); - if(n) - { - m = (vj_msg_bundle*) hnode_get(n); - if(m) - { - return m; - } - } - return NULL; -}*/ -/* -int vj_event_bundle_exists(int event_id) -{ - hnode_t *n = hash_lookup( BundleHash, (void*) event_id ); - if(!n) - return 0; - return ( vj_event_bundle_get(event_id) == NULL ? 0 : 1); -} - -int vj_event_suggest_bundle_id(void) -{ - int i; - for(i=VIMS_BUNDLE_START ; i < VIMS_BUNDLE_END; i++) - { - if ( vj_event_bundle_exists(i ) == 0 ) return i; - } - - return -1; -} - -int vj_event_bundle_store( vj_msg_bundle *m ) -{ - hnode_t *n; - if(!m) return 0; - n = hnode_create(m); - if(!n) return 0; - if(!vj_event_bundle_exists(m->event_id)) - { - hash_insert( BundleHash, n, (void*) m->event_id); - } - else - { - hnode_put( n, (void*) m->event_id); - hnode_destroy( n ); - } - - // add bundle to VIMS list - veejay_msg(VEEJAY_MSG_DEBUG, - "Added Bundle VIMS %d to net_list", m->event_id ); - - net_list[ m->event_id ].list_id = m->event_id; - net_list[ m->event_id ].act = vj_event_none; - - - return 1; -} -int vj_event_bundle_del( int event_id ) -{ - hnode_t *n; - vj_msg_bundle *m = vj_event_bundle_get( event_id ); - if(!m) return -1; - - n = hash_lookup( BundleHash, (void*) event_id ); - if(!n) - return -1; - - net_list[ m->event_id ].list_id = 0; - net_list[ m->event_id ].act = vj_event_none; - -#ifdef USE_DISPLAY - vj_event_unregister_keyb_event( m->accelerator, m->modifier ); -#endif - - if( m->bundle ) - free(m->bundle); - if(m) - free(m); - m = NULL; - - hash_delete( BundleHash, n ); - - - return 0; -} - -vj_msg_bundle *vj_event_bundle_new(char *bundle_msg, int event_id) -{ - vj_msg_bundle *m; - int len = 0; - if(!bundle_msg || strlen(bundle_msg) < 1) - { - veejay_msg(VEEJAY_MSG_ERROR, "Doesnt make sense to store empty bundles in memory"); - return NULL; - } - - len = strlen(bundle_msg); - m = (vj_msg_bundle*) malloc(sizeof(vj_msg_bundle)); - if(!m) - { - veejay_msg(VEEJAY_MSG_ERROR, "Error allocating memory for bundled message"); - return NULL; - } - memset(m, 0, sizeof(m) ); - m->bundle = (char*) malloc(sizeof(char) * len+1); - bzero(m->bundle, len+1); - m->accelerator = 0; - m->modifier = 0; - if(!m->bundle) - { - veejay_msg(VEEJAY_MSG_ERROR, "Error allocating memory for bundled message context"); - return NULL; - } - strncpy(m->bundle, bundle_msg, len); - - m->event_id = event_id; - - veejay_msg(VEEJAY_MSG_DEBUG, - "New VIMS Bundle %d [%s]", - event_id, m->bundle ); - - return m; -} -*/ - -void vj_event_trigger_function(void *ptr, vj_event f, int max_args, const char *format, ...) -{ - va_list ap; - va_start(ap,format); - f(ptr, format, ap); - va_end(ap); -} - - -int vj_event_parse_msg(veejay_t *v, char *msg); - -/* parse a message received from network */ -void vj_event_parse_bundle(veejay_t *v, char *msg ) -{ - - int num_msg = 0; - int offset = 3; - int i = 0; - - - if ( msg[offset] == ':' ) - { - int j = 0; - offset += 1; /* skip ':' */ - if( sscanf(msg+offset, "%03d", &num_msg )<= 0 ) - { - veejay_msg(VEEJAY_MSG_ERROR,"(VIMS) Invalid number of messages. Skipping message [%s] ",msg); - } - if ( num_msg <= 0 ) - { - veejay_msg(VEEJAY_MSG_ERROR,"(VIMS) Invalid number of message given to execute. Skipping message [%s]",msg); - return; - } - - offset += 3; - - if ( msg[offset] != '{' ) - { - veejay_msg(VEEJAY_MSG_ERROR, "(VIMS) 'al' expected. Skipping message [%s]",msg); - return; - } - - offset+=1; /* skip # */ - - for( i = 1; i <= num_msg ; i ++ ) /* iterate through message bundle and invoke parse_msg */ - { - char atomic_msg[256]; - int found_end_of_msg = 0; - int total_msg_len = strlen(msg); - bzero(atomic_msg,256); - while( (offset+j) < total_msg_len) - { - if(msg[offset+j] == '}') - { - return; /* dont care about semicolon here */ - } - else - if(msg[offset+j] == ';') - { - found_end_of_msg = offset+j+1; - strncpy(atomic_msg, msg+offset, (found_end_of_msg-offset)); - atomic_msg[ (found_end_of_msg-offset) ] ='\0'; - offset += j + 1; - j = 0; - vj_event_parse_msg( v, atomic_msg ); - } - j++; - } - } - } -} - -void vj_event_dump() -{ - vj_event_vevo_dump(); - -} - -typedef struct { - void *value; -} vims_arg_t; - -static void dump_arguments_(int net_id,int arglen, int np, int prefixed, char *fmt) -{ - int i; - char *name = vj_event_vevo_get_event_name( net_id ); - veejay_msg(VEEJAY_MSG_ERROR, "VIMS '%03d' : '%s'", net_id, name ); - veejay_msg(VEEJAY_MSG_ERROR, "Invalid number of arguments given: %d out of %d", - arglen,np); - veejay_msg(VEEJAY_MSG_ERROR, "Format is '%s'", fmt ); - - for( i = prefixed; i < np; i ++ ) - { - char *help = vj_event_vevo_help_vims( net_id, i ); - veejay_msg(VEEJAY_MSG_ERROR,"\tArgument %d : %s", - i,help ); - if(help) free(help); - } -} - -static void dump_argument_( int net_id , int i ) -{ - char *help = vj_event_vevo_help_vims( net_id, i ); - veejay_msg(VEEJAY_MSG_ERROR,"\tArgument %d : %s", - i,help ); - if(help) free(help); -} - -static int vj_event_verify_args( int *fx, int net_id , int arglen, int np, int prefixed, char *fmt ) -{ - return 1; -} - -void vj_event_fire_net_event(veejay_t *v, int net_id, char *str_arg, int *args, int iarglen, int prefixed, double *gargs, int garglen) -{ - int np = vj_event_vevo_get_num_args(net_id); - char *fmt = vj_event_vevo_get_event_format( net_id ); - int flags = vj_event_vevo_get_flags( net_id ); - int fmt_offset = 1; - vims_arg_t vims_arguments[16]; - memset( vims_arguments, 0, sizeof(vims_arguments) ); - - if( np == 0 ) - { - vj_event_vevo_inline_fire( (void*) v, net_id,NULL,NULL ); - return; - } - - int i=0; - int arglen = iarglen + garglen; - while( i < arglen ) - { - if( fmt[fmt_offset] == 'd' ) - { - vims_arguments[i].value = (void*) &(args[i]); - } - if( fmt[fmt_offset] == 'g' ) - { - vims_arguments[i].value = (void*) &(gargs[i]); - } - if( fmt[fmt_offset] == 's' ) - { - if(str_arg == NULL ) - { - veejay_msg(VEEJAY_MSG_ERROR, "Argument %d must be a string!", i ); - if(fmt) free(fmt); - return; - } - vims_arguments[i].value = (void*) strdup( str_arg ); - if(flags & VIMS_REQUIRE_ALL_PARAMS ) - { - if( strlen((char*)vims_arguments[i].value) <= 0 ) - { - veejay_msg(VEEJAY_MSG_ERROR, "Argument %d is not a string!",i ); - if(fmt)free(fmt); - return; - } - } - } - fmt_offset += 3; - i++; - } - _last_known_num_args = arglen; - - while( i < np ) - { - int dv = vj_event_vevo_get_default_value( net_id, i); - if( fmt[fmt_offset] == 'd' ) - { - vims_arguments[i].value = (void*) &(dv); - } - i++; - } - - vj_event_vevo_inline_fire( (void*) v, net_id, - fmt, - vims_arguments[0].value, - vims_arguments[1].value, - vims_arguments[2].value, - vims_arguments[3].value, - vims_arguments[4].value, - vims_arguments[5].value, - vims_arguments[6].value, - vims_arguments[7].value, - vims_arguments[8].value, - vims_arguments[9].value, - vims_arguments[10].value, - vims_arguments[11].value, - vims_arguments[12].value, - vims_arguments[13].value, - vims_arguments[14].value, - vims_arguments[15].value); - fmt_offset = 1; - for ( i = 0; i < np ; i ++ ) - { - if( vims_arguments[i].value && - fmt[fmt_offset] == 's' ) - if( vims_arguments[i].value) - { - free( vims_arguments[i].value ); - vims_arguments[i].value = NULL; - } - fmt_offset += 3; - } - if(fmt) - free(fmt); - -} - -static int inline_str_to_dbl(const char *msg, double *val) -{ - char longest_num[16]; - int str_len = 0; - if( sscanf( msg , "%g", val ) <= 0 ) - return 0; - bzero( longest_num, 16 ); - sprintf(longest_num, "%d", *val ); - - str_len = strlen( longest_num ); - return str_len; -} -static int inline_str_to_int(const char *msg, int *val) -{ - char longest_num[16]; - int str_len = 0; - if( sscanf( msg , "%d", val ) <= 0 ) - return 0; - bzero( longest_num, 16 ); - sprintf(longest_num, "%d", *val ); - - str_len = strlen( longest_num ); - return str_len; -} - -static char *inline_str_to_str(int flags, char *msg) -{ - char *res = NULL; - int len = strlen(msg); - if( len <= 0 ) - return res; - - if( (flags & VIMS_LONG_PARAMS) ) /* copy rest of message */ - { - res = (char*) malloc(sizeof(char) * len ); - memset(res, 0, len ); - if( msg[len-1] == ';' ) - strncpy( res, msg, len- 1 ); - } - else - { - char str[255]; - bzero(str, 255 ); - if(sscanf( msg, "%s", str ) <= 0 ) - return res; - res = strndup( str, 255 ); - } - return res; -} - -static char *vj_event_get_port_name(char *in , char *buf) -{ - char *c = in; - int n = 0; - while( *c ) - { - if( *c == '#' ) - { - *c++; - n++; - strncpy(buf,in,n); - return c; - } - *c++; - n++; - } - return NULL; -} - -static void vj_event_parse_port( veejay_t *v, char *msg ) -{ - char port_name[128]; - - char *port_str = vj_event_get_port_name( msg, port_name ); - - if(!port_str) - { - veejay_msg(0, "Invalid property set"); - return; - } - - int len = strlen(port_str); - if( port_str[len-1] == ';' ) - port_str[len-1] = '\0'; - - if( strncasecmp(port_name, "sample#",5 ) == 0 ) - { - sample_sscanf_port( v->current_sample, port_str ); - } - //@ setting fx on fx chain !! FIXME - //if( strncasecmp(port_name, "fx", 2 ) == 0 ) - //{ - // sample_fx_sscanf_port( v->current_sample, port_str, port_name); - //} -} - -int vj_event_parse_msg( veejay_t * v, char *msg ) -{ - char *head = NULL; - int net_id = 0; - int np = 0; - if( msg == NULL ) - { - veejay_msg(VEEJAY_MSG_ERROR, "Empty VIMS, dropped!"); - return 0; - } - veejay_msg(VEEJAY_MSG_INFO, "Parse: '%s'",msg); - int msg_len = strlen( msg ); - - veejay_chomp_str( msg, &msg_len ); - msg_len --; - - if( msg_len < MSG_MIN_LEN ) - { - veejay_msg(VEEJAY_MSG_ERROR, "VIMS Message too small, dropped!"); - return 0; - } - - head = strndup( msg, 3 ); - - if( strncasecmp( head, "bun", 3 ) == 0 ) - { - vj_event_parse_bundle( v, msg ); - return 1; - } - - /* try to scan VIMS id */ - if ( sscanf( head, "%03d", &net_id ) != 1 ) - { - veejay_msg(VEEJAY_MSG_ERROR, "Error parsing VIMS selector"); - return 0; - } - if( head ) free(head ); - - if( net_id <= 0 || net_id >= VIMS_MAX || !vj_event_exists(net_id) ) - { - veejay_msg(VEEJAY_MSG_ERROR, "VIMS Selector %d invalid", net_id ); - return 0; - } - - /* verify format */ - if( msg[3] != 0x3a || msg[msg_len] != ';' ) - { - veejay_msg(VEEJAY_MSG_ERROR, "Syntax error in VIMS message"); - if( msg[3] != 0x3a ) - { - veejay_msg(VEEJAY_MSG_ERROR, "\tExpected ':' after VIMS selector"); - return 0; - } - if( msg[msg_len] != ';' ) - { - veejay_msg(VEEJAY_MSG_ERROR, "\tExpected ';' to terminate VIMS message"); - return 0; - } - } - - //@ also for FX setting / removing etc etc - if( net_id == VIMS_SET_PORT ) - { - char *port_str = msg + 4; - vj_event_parse_port( v, port_str ); - return 1; - } - //@ we can drop ALL VIMS Get stuff -> extract properties with vevo_printf - -// if( net_id >= 400 && net_id < 499 ) -// vj_server_client_promote( v->command_socket , v->current_link ); - - np = vj_event_vevo_get_num_args( net_id ); - - if ( msg_len <= MSG_MIN_LEN ) - { - int i_args[16]; - int i = 0; - while( i < np ) - { - i_args[i] = vj_event_vevo_get_default_value( net_id, i ); - i++; - } - vj_event_fire_net_event( v, net_id, NULL, i_args, np, 0, NULL,0 ); - } - else - { - char *arguments = NULL; - char *fmt = vj_event_vevo_get_event_format( net_id ); - int flags = vj_event_vevo_get_flags( net_id ); - int i = 0; - int ng = 0; - int ni = 0; - int ns = 0; - int i_args[16]; - double g_args[16]; - char *str = NULL; - int fmt_offset = 1; - char *arg_str = NULL; - memset( i_args, 0, sizeof(i_args) ); - - arg_str = arguments = strndup( msg + 4 , msg_len - 3 ); - - if( arguments == NULL ) - { - dump_arguments_( net_id, 0, np, 0, fmt ); - if(fmt) free(fmt ); - return 0; - } - if( np <= 0 ) - { - veejay_msg(VEEJAY_MSG_ERROR, "VIMS %d accepts no arguments", net_id ); - if(fmt) free(fmt); - return 0; - } - - while( i < np ) - { - if( fmt[fmt_offset] == 'd' ) - i_args[i] = vj_event_vevo_get_default_value(net_id, i); - i++; - } - - for( i = 0; i < np; i ++ ) - { - int failed_arg = 1; - - if( fmt[fmt_offset] == 'd' ) - { - int il = inline_str_to_int( arguments, &i_args[ni] ); - if( il > 0 ) - { - failed_arg = 0; - arguments += il; - } - ni ++; - } - if( fmt[fmt_offset] == 's' && str == NULL) - { - str = inline_str_to_str( flags,arguments ); - if(str != NULL ) - { - failed_arg = 0; - arguments += strlen(str); - } - ns ++; - } - if( fmt[fmt_offset] == 'g' ) - { - int il = inline_str_to_dbl( arguments, &g_args[ng]); - if( il > 0 ) - { - failed_arg = 0; - arguments += il; - } - ng ++; - } - if( failed_arg ) - { - char *name = vj_event_vevo_get_event_name( net_id ); - veejay_msg(VEEJAY_MSG_ERROR, "Invalid argument %d for VIMS '%03d' : '%s' ", - i, net_id, name ); - if(name) free(name); - dump_argument_( net_id, i ); - if(fmt) free(fmt); - return 0; - } - - if( *arguments == ';' || *arguments == 0 ) - break; - fmt_offset += 3; - - if( *arguments == 0x20 ) - *arguments ++; - } - - i ++; - - if( flags & VIMS_ALLOW_ANY ) - i = np; - - vj_event_fire_net_event( v, net_id, str, i_args, ni + ns, 0, g_args,ng ); - - - if(fmt) free(fmt); - if(arg_str) free(arg_str); - if(str) free(str); - - return 1; - - } - - return 0; -} - -/* - update connections - */ -void vj_event_update_remote(void *ptr) -{ - veejay_t *v = (veejay_t*)ptr; - int cmd_poll = 0; // command port - int sta_poll = 0; // status port - int new_link = -1; - int sta_link = -1; - int msg_link = -1; - int msg_poll = 0; - int i; - cmd_poll = vj_server_poll(v->command_socket); - sta_poll = vj_server_poll(v->status_socket); - msg_poll = vj_server_poll(v->frame_socket); - // accept connection command socket - - if( cmd_poll > 0) - { - new_link = vj_server_new_connection ( v->command_socket ); - } - // accept connection on status socket - if( sta_poll > 0) - { - sta_link = vj_server_new_connection ( v->status_socket ); - } - if( msg_poll > 0) - { - msg_link = vj_server_new_connection( v->frame_socket ); - } - - // see if there is any link interested in status information - - for( i = 0; i < VJ_MAX_CONNECTIONS; i ++ ) - if( vj_server_link_used( v->status_socket, i )) - veejay_playback_status( v, i ); -/* - if( v->settings->use_vims_mcast ) - { - int res = vj_server_update(v->vjs[2],0 ); - if(res > 0) - { - v->current_link = 0; - char buf[MESSAGE_SIZE]; - bzero(buf, MESSAGE_SIZE); - while( vj_server_retrieve_msg( v->vjs[2], 0, buf ) ) - { - vj_event_parse_msg( v, buf ); - bzero( buf, MESSAGE_SIZE ); - } - } - - }*/ - - for( i = 0; i < VJ_MAX_CONNECTIONS; i ++ ) - { - if( vj_server_link_used( v->command_socket, i ) ) - { - int res = 1; - while( res != 0 ) - { - res = vj_server_update( v->command_socket, i ); - if(res>0) - { - v->current_link = i; - char buf[MESSAGE_SIZE]; - bzero(buf, MESSAGE_SIZE); - int n = 0; - while( vj_server_retrieve_msg(v->command_socket,i,buf) != 0 ) - { - vj_event_parse_msg( v, buf ); - bzero( buf, MESSAGE_SIZE ); - n++; - } - } - if( res == -1 ) - { - veejay_msg(VEEJAY_MSG_DEBUG, - "Lost connection with link %d",i); - _vj_server_del_client( v->command_socket, i ); - _vj_server_del_client( v->status_socket, i ); - _vj_server_del_client( v->frame_socket, i ); - break; - } - - } - } - } - -} - - -void vj_event_lvd_parse_set_entry( veejay_t *v, const char *format[], va_list ap) -{ - //@ format is constructed dynamicly, based on whatever entry in sample - //@ -> atom types of fx_values and fx_chain -} - -//@ FIXME -void vj_event_none(void *ptr, const char format[], va_list ap) -{ - veejay_msg(VEEJAY_MSG_INFO, "No event attached on this key"); -} - -void vj_event_init_network_events() -{ - int i; - int net_id = 0; - for( i = 0; i <= 600; i ++ ) - { - net_list[ net_id ].act = - (vj_event) vj_event_vevo_get_event_function( i ); - - if( net_list[ net_id ].act ) - { - net_list[net_id].list_id = i; - net_id ++; - } - } - veejay_msg(VEEJAY_MSG_INFO, "\tVIMS selectors: %d", net_id ); -} - -void vj_event_init() -{ - int i; - vj_init_vevo_events(); - for(i=0; i < VIMS_MAX; i++) - { - net_list[i].act = vj_event_none; - net_list[i].list_id = 0; - } - -/* if( !(BundleHash = hash_create(HASHCOUNT_T_MAX, int_bundle_compare, int_bundle_hash))) - { - veejay_msg(VEEJAY_MSG_ERROR, "Cannot initialize hashtable for message bundles"); - return; - }*/ - veejay_msg(VEEJAY_MSG_INFO,"Initializing Event system"); - vj_event_init_network_events(); -} - -void vj_event_stop() -{ - veejay_msg(VEEJAY_MSG_INFO, "Shutting down event system"); - // destroy bundlehash, destroy keyboard_events - vj_event_vevo_free(); -} -void vj_event_linkclose(void *ptr, const char format[], va_list ap) -{ - veejay_t *v = (veejay_t*)ptr; - veejay_msg(VEEJAY_MSG_INFO, "Remote requested session-end, quitting Client"); - int i = v->current_link; - _vj_server_del_client( v->command_socket, i ); - _vj_server_del_client( v->status_socket, i ); - _vj_server_del_client( v->frame_socket, i ); -} - -void vj_event_quit(void *ptr, const char format[], va_list ap) -{ - veejay_t *v = (veejay_t*)ptr; - veejay_msg(VEEJAY_MSG_INFO, "Remote requested Quit."); - veejay_change_state(v, VEEJAY_STATE_STOP); -} - -void vj_event_bezerk(void *ptr, const char format[], va_list ap) -{ - veejay_t *v = (veejay_t*) ptr; - if(v->no_bezerk) v->no_bezerk = 0; else v->no_bezerk = 1; - if(v->no_bezerk==1) - veejay_msg(VEEJAY_MSG_INFO,"Bezerk On :No sample-restart when changing input channels"); - else - veejay_msg(VEEJAY_MSG_INFO,"Bezerk Off :Sample-restart when changing input channels"); -} - -void vj_event_debug_level(void *ptr, const char format[], va_list ap) -{ - veejay_t *v = (veejay_t*) ptr; - if(v->verbose) v->verbose = 0; else v->verbose = 1; - veejay_set_debug_level( v->verbose ); - if(v->verbose) - veejay_msg(VEEJAY_MSG_INFO, "Displaying debug information" ); - else - veejay_msg(VEEJAY_MSG_INFO, "Not displaying debug information"); -} - -void vj_event_sample_select(void *ptr, const char format[], va_list ap) -{ - veejay_t *v = (veejay_t*) ptr; - int args[1]; - char *s = NULL; - P_A( args, s , format, ap); - - void *sample = which_sample( v,args ); - if(sample) - { - if(sample == v->current_sample) - { - uint64_t pos = sample_get_start_pos( v->current_sample ); - sample_set_property_ptr( - v->current_sample, "current_pos", VEVO_ATOM_TYPE_UINT64, &pos ); - } - else - { - sample_save_cache_data( v->current_sample ); - v->current_sample = sample; - } - } -} - - -void vj_event_set_volume(void *ptr, const char format[], va_list ap) -{ - int args[2]; - char *s = NULL; - veejay_t *v = (veejay_t*) ptr; - P_A(args,s,format,ap) - - void *sample = which_sample( v,args ); - if(sample) - { -#ifdef HAVE_JACK - if(vj_jack_set_volume(args[1])) //@ TODO: audio - { - veejay_msg(VEEJAY_MSG_INFO, "Volume set to %d", args[1]); - sample_set_property_ptr( v->current_sample, "volume", VEVO_ATOM_TYPE_INT, &(args[1])); - } -#else - veejay_msg(VEEJAY_MSG_ERROR, "Audio support not compiled in. Cannot change audio volume."); -#endif - } -} - -void vj_event_sample_new(void *ptr, const char format[], va_list ap) -{ - int new_id = 0; - veejay_t *v = (veejay_t*) ptr; - int args[2]; - char *token[1024]; - bzero(token,1024); - P_A(args,token,format, ap); - - const char *type_str = sample_describe_type( args[0] ); - if(type_str==NULL) - { - veejay_msg(0,"Invalid sample type: %d",args[0]); - } - else - { - void *sample = sample_new( args[0] ); - if(sample_open( sample, token,args[1], v->video_info)) - { - new_id = samplebank_add_sample( sample ); - veejay_msg(VEEJAY_MSG_INFO,"Created new %s from %s as Sample %d", - type_str, token, new_id ); - } - else - { - veejay_msg(VEEJAY_MSG_ERROR,"Could not create sample from %s",token); - } - } -} - -void vj_event_fullscreen(void *ptr, const char format[], va_list ap ) -{ -#ifdef USE_DISPLAY - veejay_t *v = (veejay_t*) ptr; - int args[2]; - char *s = NULL; - P_A(args,s,format,ap); - - if(!IS_BOOLEAN(args[0])) - { - BOOLEAN_ERROR(0); - return; - } - - if( v->use_display == 2 ) - { - if(x_display_set_fullscreen( v->display, args[0] )) - veejay_msg(VEEJAY_MSG_INFO,"OpenGL display window Fullscreen %s", - args[0] == 0 ? "disabled" : "enabled"); - } - if( v->use_display == 1 ) - { - if(vj_sdl_set_fullscreen( v->display, args[0] )) - veejay_msg(VEEJAY_MSG_INFO,"SDL display window fullsceen %s", - args[0] == 0 ? "disabled" : "enabled"); - } -#endif -} -void vj_event_set_screen_size(void *ptr, const char format[], va_list ap) -{ -#ifdef USE_DISPLAY - int args[5]; - veejay_t *v = (veejay_t*) ptr; - char *s = NULL; - P_A(args,s,format,ap); - - int w = args[0]; - int h = args[1]; - int x = args[2]; - int y = args[3]; - - if( !VALID_RESOLUTION(w,h,x,y)) - { - veejay_msg(VEEJAY_MSG_ERROR,"Invalid dimensions for video window. Width and Height must be >= 64 and <= 2048"); - return; - } - - if( v->use_display == 2) - { - veejay_msg(VEEJAY_MSG_INFO, "OpenGL video window is %gx%g+%gx%g", - w,h,x,y ); - x_display_resize( v->display ); - } - if( v->use_display == 1 ) - { - if(vj_sdl_resize_window(v->display,w,h,x,y)) - veejay_msg(VEEJAY_MSG_INFO, "SDL video window is %dx%d+%dx%d", - w,h,x,y); - } -#endif -} - -void vj_event_play_stop(void *ptr, const char format[], va_list ap) -{ - veejay_t *v = (veejay_t*) ptr; - int args[2]; - char *s = NULL; - P_A(args,s,format,ap) - - void *sample = which_sample( v,args ); - if(sample) - { - int speed = sample_get_speed( sample ); - if(speed != 0) - { - speed = 0; - sample_set_property_ptr( - v->current_sample, "speed", VEVO_ATOM_TYPE_INT, &speed ); - } - - } -} - - -void vj_event_play_reverse(void *ptr,const char format[],va_list ap) -{ - veejay_t *v = (veejay_t*) ptr; - - int args[2]; - char *s = NULL; - P_A(args,s,format,ap) - - void *sample = which_sample( v,args ); - if(sample) - { - int speed = sample_get_speed( v->current_sample ); - if(speed >= 0) - { - if(speed == 0) - speed = 1; - speed *= -1; - sample_set_property_ptr( - v->current_sample, "speed", VEVO_ATOM_TYPE_INT, &speed ); - } - } -} - -void vj_event_play_forward(void *ptr, const char format[],va_list ap) -{ - veejay_t *v = (veejay_t*) ptr; - - int args[2]; - char *s = NULL; - P_A(args,s,format,ap) - void *sample = which_sample( v,args ); - if(sample) - { - int speed = sample_get_speed( v->current_sample ); - if(speed <= 0) - { - if(speed == 0) - speed = -1; - speed *= -1; - sample_set_property_ptr( - v->current_sample, "speed", VEVO_ATOM_TYPE_INT, &speed ); - } - } -} - -void vj_event_play_speed(void *ptr, const char format[], va_list ap) -{ - veejay_t *v = (veejay_t*) ptr; - - int args[2]; - char *s = NULL; - P_A(args,s,format,ap) - void *sample = which_sample( v,args ); - if(sample) - { - if( sample_valid_speed( v->current_sample, args[1] )) - { - sample_set_property_ptr( - v->current_sample, "speed", VEVO_ATOM_TYPE_INT, &(args[1]) ); - int frame_repeat = (args[1] == 1 || args[1] == -1 ? 0 : - sample_get_repeat( v->current_sample ) ); - sample_set_property_ptr( - v->current_sample, "repeat", VEVO_ATOM_TYPE_INT,&frame_repeat ); - veejay_msg(VEEJAY_MSG_INFO, "Playback speed changed to %d (repeat is %d)", args[1], - frame_repeat); - } - else - { - veejay_msg(VEEJAY_MSG_ERROR, "Playback speed %d bounces beyond sample boundaries", args[1]); - } - } -} - -void vj_event_play_repeat(void *ptr, const char format[], va_list ap) -{ - int args[5]; - veejay_t *v = (veejay_t*) ptr; - char *s = NULL; - P_A(args,s,format,ap); - - void *sample = which_sample(v,args); - - if(sample) - { - int speed = (sample_get_speed(v->current_sample) < 0 ? -1 : 1 ); - - sample_set_property_ptr( v->current_sample, - "speed", VEVO_ATOM_TYPE_INT, &speed); - sample_set_property_ptr( v->current_sample, - "repeat", VEVO_ATOM_TYPE_INT, &(args[1]) ); - veejay_msg(VEEJAY_MSG_ERROR, "Playback repeat set to %d", args[1]); - } -} - - - -void vj_event_set_frame(void *ptr, const char format[], va_list ap) -{ - int args[2]; - veejay_t *v = (veejay_t*) ptr; - char *s = NULL; - P_A(args,s,format,ap); - - void *sample = which_sample(v,args); - - if(sample) - { - uint64_t pos = sample_get_current_pos( v->current_sample ); - if(pos != args[1]) - { - if( sample_valid_pos( v->current_sample, args[1] )) - { - uint64_t new_pos = (uint64_t) args[1]; - sample_set_property_ptr( - v->current_sample, "current_pos", VEVO_ATOM_TYPE_UINT64, &new_pos ); - veejay_msg(VEEJAY_MSG_INFO, "Position changed to %d", args[1]); - } - else - { - veejay_msg(VEEJAY_MSG_ERROR, "Position %d outside sample boundaries", args[1]); - } - } - } - -} - -void vj_event_inc_frame(void *ptr, const char format[], va_list ap) -{ - int args[2]; - veejay_t *v = (veejay_t*) ptr; - char *s = NULL; - P_A(args,s,format,ap); - - void *sample = which_sample(v,args); - - if(sample) - { - uint64_t pos = sample_get_current_pos( v->current_sample ); - pos += args[1]; - if( sample_valid_pos( v->current_sample, pos )) - { - sample_set_property_ptr( - v->current_sample, "current_pos", VEVO_ATOM_TYPE_UINT64, &pos ); - veejay_msg(VEEJAY_MSG_INFO, "Position changed to %lld",pos); - } - } -} - -void vj_event_dec_frame(void *ptr, const char format[], va_list ap) -{ - int args[2]; - veejay_t *v = (veejay_t*) ptr; - char *s = NULL; - P_A(args,s,format,ap); - - void *sample = which_sample(v,args); - - if(sample) - { - uint64_t pos = sample_get_current_pos( v->current_sample ); - pos -= args[1]; - if( sample_valid_pos( v->current_sample, pos )) - { - sample_set_property_ptr( - v->current_sample, "current_pos", VEVO_ATOM_TYPE_UINT64, &pos ); - veejay_msg(VEEJAY_MSG_INFO, "Position changed to %lld", pos); - } - } -} - -void vj_event_prev_second(void *ptr, const char format[], va_list ap) -{ - int args[2]; - veejay_t *v = (veejay_t*) ptr; - char *s = NULL; - P_A(args,s,format,ap); - - void *sample = which_sample(v,args); - - if(sample) - { - sample_video_info_t *svit = (sample_video_info_t*) v->video_info; - uint64_t pos = sample_get_current_pos( v->current_sample ); - - pos += (args[1] * svit->fps); - if( sample_valid_pos( v->current_sample, pos )) - { - sample_set_property_ptr( - v->current_sample, "current_pos", VEVO_ATOM_TYPE_UINT64, &pos ); - veejay_msg(VEEJAY_MSG_INFO, "Position changed to %lld", pos); - } - } - -} - -void vj_event_next_second(void *ptr, const char format[], va_list ap) -{ - int args[2]; - veejay_t *v = (veejay_t*) ptr; - char *s = NULL; - P_A(args,s,format,ap); - - void *sample = which_sample(v,args); - - if(sample) - { - sample_video_info_t *svit = (sample_video_info_t*) v->video_info; - uint64_t pos = sample_get_current_pos( v->current_sample ); - - pos -= (args[1] * svit->fps); - if( sample_valid_pos( v->current_sample, pos )) - { - sample_set_property_ptr( - v->current_sample, "current_pos", VEVO_ATOM_TYPE_UINT64, &pos ); - veejay_msg(VEEJAY_MSG_INFO, "Position changed to %lld", pos); - } - } -} - -void vj_event_goto_end(void *ptr, const char format[], va_list ap) -{ - int args[2]; - veejay_t *v = (veejay_t*) ptr; - char *s = NULL; - P_A(args,s,format,ap); - - void *sample = which_sample(v,args); - if(sample) - { - uint64_t pos = sample_get_end_pos( v->current_sample ); - sample_set_property_ptr( - v->current_sample, "current_pos", VEVO_ATOM_TYPE_UINT64, &pos ); - veejay_msg(VEEJAY_MSG_INFO, "Position changed to %lld", pos); - } -} - -void vj_event_goto_start(void *ptr, const char format[], va_list ap) -{ - int args[2]; - veejay_t *v = (veejay_t*) ptr; - char *s = NULL; - P_A(args,s,format,ap); - - void *sample = which_sample(v,args); - if(sample) - { - uint64_t pos = sample_get_start_pos( v->current_sample ); - sample_set_property_ptr( - v->current_sample, "current_pos", VEVO_ATOM_TYPE_UINT64, &pos ); - veejay_msg(VEEJAY_MSG_INFO, "Position changed to %lld", pos); - } -} - -void vj_event_set_property(void *ptr, const char format[], va_list ap) -{ - int args[2]; - veejay_t *v = (veejay_t*) ptr; - - // arbitrary parsing of arguments. - -} - -void vj_event_get_property_value(void *ptr, const char format[], va_list ap) -{ - int args[2]; - veejay_t *v = (veejay_t*) ptr; - char *s = NULL; - P_A(args, s, format, ap); - -} - -void vj_event_sample_del(void *ptr, const char format[], va_list ap) -{ - int args[2]; - veejay_t *v = (veejay_t*) ptr; - char *s = NULL; - P_A(args, s, format, ap); - - void *sample = which_sample(v,args[0]); - if( sample == v->current_sample) - veejay_msg(VEEJAY_MSG_ERROR, "Cannot delete current playing sample"); - else - { - if( sample_delete( args[0] ) ) - veejay_msg(VEEJAY_MSG_ERROR,"Sample %d is deleted", args[0]); - } -} - -void vj_event_sample_copy(void *ptr, const char format[] , va_list ap) -{ -} - -void vj_event_chain_clear(void *ptr, const char format[], va_list ap) -{ - int args[2]; - veejay_t *v = (veejay_t*) ptr; - char *s = NULL; - P_A(args, s, format, ap); - - void *sample = which_sample(v,args[0]); - if(sample) - { - sample_fx_chain_reset( sample ); - veejay_msg(VEEJAY_MSG_INFO, "Wiped contents of FX Chain in sample %d", - args[0]); - } -} - -void vj_event_chain_entry_clear(void *ptr, const char format[], va_list ap) -{ - int args[2]; - veejay_t *v = (veejay_t*) ptr; - char *s = NULL; - P_A(args, s, format, ap); - - void *sample = which_sample(v,args); - if(sample) - { - if(sample_fx_chain_entry_clear( sample, args[1] ) ) - veejay_msg(VEEJAY_MSG_INFO, "Cleared FX slot %d in sample %d", - args[1], args[0]); - } - -} - -void vj_event_chain_entry_set_defaults(void *ptr, const char format[], va_list ap) -{ - -} - -void vj_event_chain_entry_set_alpha( void *ptr, const char format[], va_list ap) -{ - int args[4]; - veejay_t *v = (veejay_t*) ptr; - char *s = NULL; - P_A(args, s, format, ap); - void *sample = which_sample( v, args ); - if( sample ) - { - int idx = args[1]; - if( idx < 0 || idx >= SAMPLE_CHAIN_LEN ) - { - veejay_msg(VEEJAY_MSG_ERROR, - "Invalid entry '%d'", idx ); - return; - } - sample_set_fx_alpha( sample, idx, args[2] ); - } -} - -void vj_event_chain_entry_set_input( void *ptr, const char format[], va_list ap ) -{ - int args[4]; - veejay_t *v = (veejay_t*) ptr; - char *s = NULL; - P_A(args, s, format, ap); - - void *sample = which_sample( v, args ); - if( sample ) - { - int idx = args[1]; - if( idx < 0 || idx >= SAMPLE_CHAIN_LEN ) - { - veejay_msg(VEEJAY_MSG_ERROR, - "Invalid entry '%d'", idx ); - return; - } - - int n = sample_fx_set_in_channel( sample, idx, args[2], args[3] ); - if(n) - veejay_msg(VEEJAY_MSG_ERROR, "Input channel %d set to sample %d",args[2],args[3]); - else - veejay_msg(VEEJAY_MSG_ERROR, "Error setting input channel"); - } -} - - -void vj_event_chain_entry_set_parameter_value( void *ptr, const char format[], va_list ap ) -{ - int args[4]; - veejay_t *v = (veejay_t*) ptr; - char s[1024]; - P_A(args, s, format, ap); - - void *sample = which_sample( v, args ); - if( sample ) - { - int idx = args[1]; - if( idx < 0 || idx >= SAMPLE_CHAIN_LEN ) - { - veejay_msg(VEEJAY_MSG_ERROR, - "Invalid entry '%d'", idx ); - return; - } - - int n = sample_set_param_from_str( sample,idx,args[2],s ); - if(n) - veejay_msg(VEEJAY_MSG_INFO, "Parameter %d value '%s'", - args[2],s); - else - veejay_msg(VEEJAY_MSG_ERROR, "Error parsing parameter value"); - } -} - -void vj_event_chain_entry_set_active( void *ptr, const char format[], va_list ap ) -{ - int args[4]; - veejay_t *v = (veejay_t*) ptr; - char *s = NULL; - P_A(args, s, format, ap); - - void *sample = which_sample( v, args ); - if( sample ) - { - int idx = args[1]; - if( idx < 0 || idx >= SAMPLE_CHAIN_LEN ) - { - veejay_msg(VEEJAY_MSG_ERROR, - "Invalid entry '%d'", idx ); - return; - } - if(!IS_BOOLEAN(args[2])) - { - BOOLEAN_ERROR(2); - return; - } - sample_toggle_process_entry( sample, idx, args[2] ); - veejay_msg(VEEJAY_MSG_INFO, "Entry %d is %s", idx,args[2] ? "Enabled" : "Disabled" ); - } -} - -void vj_event_chain_entry_set(void *ptr, const char format[], va_list ap) -{ - // NET_ID:11 0 LVDNegation - int args[2]; - veejay_t *v = (veejay_t*) ptr; - char s[256]; - P_A(args, s, format, ap); - - void *sample = which_sample( v, args ); - if( sample ) - { - int idx = args[1]; - if( idx < 0 || idx >= SAMPLE_CHAIN_LEN ) - { - veejay_msg(VEEJAY_MSG_ERROR, - "Invalid entry '%d'", idx ); - return; - } - int fx_id = plug_get_fx_id_by_name( s ); - if( fx_id < 0 ) - veejay_msg(VEEJAY_MSG_ERROR, "FX '%s' not found", s ); - else - { - if( sample_fx_set( sample, idx,fx_id ) ) - veejay_msg(VEEJAY_MSG_INFO, - "Added '%s' to entry %d of sample %d", - s,idx,args[0]); - else - veejay_msg(VEEJAY_MSG_ERROR, - "Unable to add '%s' to entry %d of sample %d", - s,idx,args[0]); - } - } - - -} - -void vj_event_chain_entry_preset(void *ptr,const char format[], va_list ap) -{ - //@ arbitrary format, all fx_values and fx_channels -} - - -void vj_event_el_cut(void *ptr, const char format[], va_list ap) -{ - int args[2]; - veejay_t *v = (veejay_t*) ptr; - char s[256]; - P_A(args, s, format, ap); - - void *sample = which_sample( v, args ); - if( sample ) - { - if(sample_edl_cut_to_buffer( sample, (uint64_t) args[1], (uint64_t) args[2] )) - veejay_msg(VEEJAY_MSG_INFO, "Cut frames %d - %d to buffer",args[1],args[2]); - else - veejay_msg(VEEJAY_MSG_ERROR, "Unable to cut frames %d - %d",args[1],args[2]); - } -} - -void vj_event_el_copy(void *ptr, const char format[], va_list ap) -{ - int args[2]; - veejay_t *v = (veejay_t*) ptr; - char s[256]; - P_A(args, s, format, ap); - - void *sample = which_sample( v, args ); - if(sample) - { - if( sample_edl_copy( sample, (uint64_t) args[1],(uint64_t)args[2] )) - veejay_msg(VEEJAY_MSG_INFO, "Copied frames %d - %d to buffer", args[1],args[2]); - else - veejay_msg(VEEJAY_MSG_INFO, "Unable to copy frames %d - %d",args[1],args[2]); - } -} - -void vj_event_el_del(void *ptr, const char format[], va_list ap) -{ - int args[2]; - veejay_t *v = (veejay_t*) ptr; - char s[256]; - P_A(args, s, format, ap); - - void *sample = which_sample( v, args ); - if(sample) - { - if( sample_edl_delete( sample, (uint64_t) args[1],(uint64_t)args[2] )) - veejay_msg(VEEJAY_MSG_INFO, "Copied frames %d - %d to buffer", args[1],args[2]); - else - veejay_msg(VEEJAY_MSG_INFO, "Unable to copy frames %d - %d",args[1],args[2]); - } - -} - -void vj_event_sample_detach_out_parameter( void *ptr, const char format[] , va_list ap ) -{ - int args[5]; - veejay_t *v = (veejay_t*) ptr; - char *s = NULL; - P_A(args, s, format, ap); - - void *sample = which_sample( v, args ); - - if(sample) - { - void *src_entry = sample_get_fx_port_ptr( sample,args[1] ); - if(src_entry == NULL ) - { - veejay_msg(0,"Invalid fx entry"); - return; - } - - int error = sample_del_bind( sample, src_entry, args[2] ); - if( error == VEVO_NO_ERROR ) - { - veejay_msg(0, "Detached output parameter %d on entry %d", args[2],args[1] ); - } - } - -} - -void vj_event_sample_attach_out_parameter( void *ptr, const char format[], - va_list ap) -{ - int args[5]; - veejay_t *v = (veejay_t*) ptr; - char *s = NULL; - P_A(args, s, format, ap); - - void *sample = which_sample( v, args ); - if(sample) - { - void *src_entry = sample_get_fx_port_ptr( sample,args[1] ); - if(src_entry == NULL ) - { - veejay_msg(0,"Invalid fx entry"); - return; - } - - int error = sample_new_bind( sample, src_entry, args[2], - args[3],args[4] ); - if( error == VEVO_NO_ERROR ) - { - veejay_msg(0, "Pushing out parameters on entry %d parameter %d -> Entry %d parameter %d", - args[1],args[3],args[2],args[4]); - } - } - -} - -void vj_event_el_paste_at(void *ptr, const char format[], va_list ap) -{ - int args[2]; - veejay_t *v = (veejay_t*) ptr; - char s[256]; - P_A(args, s, format, ap); - - void *sample = which_sample( v, args ); - if(sample) - { - if( sample_edl_paste_from_buffer( sample, (uint64_t) args[1] ) ) - veejay_msg( VEEJAY_MSG_INFO, "Pasted frames from buffer to position %d", args[1] ); - else - veejay_msg(VEEJAY_MSG_INFO, "Unable to paste frames at position %d", args[1]); - - } -} - - -void vj_event_el_add_video(void *ptr, const char format[], va_list ap) -{ -} - -void vj_event_performer_configure_preview( void *ptr, const char format[], va_list ap ) -{ - int args[3]; - char *s = NULL; - veejay_t *v = (veejay_t*) ptr; - P_A(args, s, format, ap); - - int n = performer_setup_preview( v, - v->performer, - args[0], - args[1]); - if( n ) - { - veejay_msg(VEEJAY_MSG_INFO, "Preview image configured"); - } -} - -void vj_event_performer_get_preview_image( void *ptr, const char format[], va_list ap ) -{ - //write preview image to socket -} - -void vj_event_samplebank_list( void *ptr, const char format[], va_list ap ) -{ - /* sample id, sample type */ - char *data = samplebank_sprint_list(); - veejay_msg(0,"list: '%s'", data ); - free(data); -} -void vj_event_samplebank_add ( void *ptr, const char format[], va_list ap ) -{ - int args[3]; - char s[1024]; - veejay_t *v = (veejay_t*) ptr; - P_A(args, s, format, ap); - - void *sample = sample_new( args[0] ); - if( sample_open( sample, s, args[1], v->video_info ) <= 0 ) - { - veejay_msg(0, "Unable to open '%s' as new sample", s); - } - else - { - int id = samplebank_add_sample(sample); - veejay_msg(0, "Added '%s' as new sample %d", s, id ); - } -} -void vj_event_samplebank_del ( void *ptr, const char format[], va_list ap ) -{ - int args[3]; - char *s = NULL; - veejay_t *v = (veejay_t*) ptr; - P_A(args, s, format, ap); - - int current_playing = sample_get_key_ptr( v->current_sample ); - - if( args[0] == current_playing || args[0] == 0) - { - veejay_msg(0, "Cannot delete current playing sample"); - return; - } - - if( sample_delete( args[0] ) ) - { - veejay_msg(VEEJAY_MSG_INFO, "Deleted sample %d", args[0] ); - } - else - { - veejay_msg(VEEJAY_MSG_INFO, "Sample %d does not exist",args[0]); - } -} - -void vj_event_fx_list ( void *ptr, const char format[], va_list ap ) -{ - char *data = list_plugins(); - veejay_msg(0,"list: '%s'", data ); - free(data); - -} -void vj_event_fx_info ( void *ptr, const char format[], va_list ap ) -{ - - int args[3]; - char plug_name[1024]; - veejay_t *v = (veejay_t*) ptr; - P_A(args, plug_name, format, ap); - int i; - int fx_id = - plug_get_fx_id_by_name( plug_name ); - - if( fx_id < 0 ) - { - veejay_msg(0, "Plugin '%s' not loaded", plug_name); - return; - } - - char *str = plug_describe( fx_id ); - - printf( "\n\n%s\n\n", str ); - - free(str); - -} -void vj_event_sample_fx_details(void *ptr, const char format[], va_list ap) -{ -} -void vj_event_sample_fx_chain( void *ptr, const char format[], va_list ap ) -{ -} - - - -void vj_event_sample_configure_recorder( void *ptr, const char format[], va_list ap ) -{ - int args[4]; - veejay_t *v = (veejay_t*) ptr; - char s[256]; - P_A(args, s, format, ap); - - void *sample = which_sample( v, args ); - if(sample) - { - int error = sample_configure_recorder( sample, args[1], s, args[2], - v->video_info ); - if( error ) - veejay_msg(0, "Unable to configure the recorder"); - } - -} - -void vj_event_sample_start_recorder( void *ptr, const char format[], va_list ap ) -{ - int args[2]; - veejay_t *v = (veejay_t*) ptr; - char *s = NULL; - P_A(args, s, format, ap); - - void *sample = which_sample( v, args ); - if(sample) - { - int error = sample_start_recorder( sample,v->video_info ); - if( error ) - veejay_msg(0, "Unable to start sample recorder"); - else - veejay_msg(2, "Started sample recorder"); - } -} - -void vj_event_sample_stop_recorder( void *ptr, const char format[], va_list ap ) -{ - int args[2]; - veejay_t *v = (veejay_t*) ptr; - char *s = NULL; - P_A(args, s, format, ap); - - void *sample = which_sample( v, args ); - if(sample) - { - int error = sample_stop_recorder( sample ); - if ( error ) - veejay_msg(0, "Unable to stop sample recorder"); - else - veejay_msg(2, "Stopped sample recorder. File is written"); - } -} - -void vj_event_sample_bind_outp_osc( void *ptr, const char format[], va_list ap ) -{ - int args[2]; - veejay_t *v = (veejay_t*) ptr; - char s[1024]; - P_A(args, s, format, ap); - - void *sample = which_sample( v, args ); - if(sample) - { - sample_add_osc_path( sample, s, args[1] ); - } - -} - -void vj_event_sample_release_outp_osc( void *ptr, const char format[], va_list ap) -{ - int args[2]; - veejay_t *v = (veejay_t*) ptr; - char *s = NULL; - P_A(args, s, format, ap); - - void *sample = which_sample( v, args ); - if(sample) - { - sample_del_osc_path( sample, args[1] ); - } -} - -void vj_event_sample_start_osc_sender( void *ptr, const char format[], va_list ap ) -{ - int args[2]; - veejay_t *v = (veejay_t*) ptr; - char s[1024]; - char port[50]; - - P_A(args, s, format, ap); - sprintf(port,"%d", args[1]); - - void *sample = which_sample( v, args ); - if(sample) - { - sample_new_osc_sender( sample, s, port ); - } -} - -void vj_event_sample_stop_osc_sender( void *ptr, const char format[], va_list ap ) -{ - int args[2]; - veejay_t *v = (veejay_t*) ptr; - char *s = NULL; - P_A(args, s, format, ap); - - void *sample = which_sample( v, args ); - if(sample) - { - sample_close_osc_sender( sample ); - } -} - diff --git a/veejay-ng/veejay/vj-event.h b/veejay-ng/veejay/vj-event.h deleted file mode 100644 index bd424167..00000000 --- a/veejay-ng/veejay/vj-event.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Linux VeeJay - * - * Copyright(C)2002-2004 Niels Elburg - * - * 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 - */ - -#ifndef VJ_EVENT_H -#define VJ_EVENT_H -#include -#ifdef HAVE_XML2 -#include -#include -#endif - -void vj_event_fmt_arg ( int *args, char *str, const char format[], va_list ap); -void vj_event_init (); -void vj_event_print_range ( int n1, int n2); -#ifdef HAVE_SDL -#ifdef HAVE_XML2 -void vj_event_xml_new_keyb_event ( void *v, xmlDocPtr doc, xmlNodePtr cur ); -#endif -#endif -void vj_event_update_remote(void *ptr); -void vj_event_dump(void); -void vj_event_chain_clear ( void *ptr, const char format[], va_list ap ); -void vj_event_el_copy ( void *ptr, const char format[], va_list ap ); -void vj_event_el_crop ( void *ptr, const char format[], va_list ap ); -void vj_event_el_cut ( void *ptr, const char format[], va_list ap ); -void vj_event_el_del ( void *ptr, const char format[], va_list ap ); -void vj_event_el_paste_at ( void *ptr, const char format[], va_list ap ); -void vj_event_el_load_editlist ( void *ptr, const char format[], va_list ap ); -void vj_event_el_save_editlist ( void *ptr, const char format[], va_list ap ); -void vj_event_el_add_video ( void *ptr, const char format[], va_list ap ); -void vj_event_goto_end ( void *ptr, const char format[], va_list ap ); -void vj_event_goto_start ( void *ptr, const char format[], va_list ap ); -void vj_event_inc_frame ( void *ptr, const char format[], va_list ap ); -void vj_event_dec_frame ( void *ptr, const char format[], va_list ap ); -void vj_event_next_second ( void *ptr, const char format[], va_list ap ); -void vj_event_none ( void *ptr, const char format[], va_list ap ); -void vj_event_play_forward ( void *ptr, const char format[], va_list ap ); -void vj_event_play_reverse ( void *ptr, const char format[], va_list ap ); -void vj_event_play_speed ( void *ptr, const char format[], va_list ap ); -void vj_event_play_repeat(void *ptr, const char format[], va_list ap); -void vj_event_play_stop ( void *ptr, const char format[], va_list ap ); -void vj_event_prev_second ( void *ptr, const char format[], va_list ap ); -void vj_event_sample_copy ( void *ptr, const char format[], va_list ap ); -void vj_event_sample_del ( void *ptr, const char format[], va_list ap ); -void vj_event_sample_select ( void *ptr, const char format[], va_list ap ); -void vj_event_set_property ( void *ptr, const char format[], va_list ap ); -void vj_event_get_property ( void *ptr, const char format[], va_list ap ); -void vj_event_set_frame ( void *ptr, const char format[], va_list ap ); -#ifdef USE_DISPLAY -void vj_event_set_screen_size ( void *ptr, const char format[], va_list ap ); -#endif -void vj_event_sample_new ( void *ptr, const char format[], va_list ap ); -void vj_event_quit ( void *ptr, const char format[], va_list ap ); -void vj_event_set_volume ( void *ptr, const char format[], va_list ap ); -void vj_event_debug_level ( void *ptr, const char format[], va_list ap ); -void vj_event_bezerk ( void *ptr, const char format[], va_list ap ); -void vj_event_fullscreen ( void *ptr, const char format[], va_list ap ); -void vj_event_chain_entry_set_active ( void *ptr, const char format[], va_list ap ); -void vj_event_chain_entry_set ( void *ptr, const char format[], va_list ap ); -void vj_event_chain_entry_clear ( void *ptr, const char format[], va_list ap ); -void vj_event_chain_entry_set_parameter_value( void *ptr, const char format[], va_list ap ); -void vj_event_chain_entry_set_input ( void *ptr, const char format[], va_list ap ); -void vj_event_chain_entry_set_alpha ( void *ptr, const char format[], va_list ap ); -void vj_event_sample_attach_out_parameter ( void *ptr, const char format[], va_list ap ); -void vj_event_sample_detach_out_parameter ( void *ptr, const char format[], va_list ap ); -void vj_event_sample_configure_recorder ( void *ptr, const char format[], va_list ap ); -void vj_event_sample_start_recorder ( void *ptr, const char format[], va_list ap ); -void vj_event_sample_stop_recorder ( void *ptr, const char format[], va_list ap ); -void vj_event_performer_configure_preview ( void *ptr, const char format[], va_list ap ); -void vj_event_performer_get_preview_image ( void *ptr, const char format[], va_list ap ); -void vj_event_samplebank_list ( void *ptr, const char format[], va_list ap ); -void vj_event_samplebank_add ( void *ptr, const char format[], va_list ap ); -void vj_event_samplebank_del ( void *ptr, const char format[], va_list ap ); -void vj_event_fx_list ( void *ptr, const char format[], va_list ap ); -void vj_event_fx_info ( void *ptr, const char format[], va_list ap ); -void vj_event_sample_fx_details ( void *ptr, const char format[], va_list ap ); -void vj_event_sample_fx_chain ( void *ptr, const char format[], va_list ap ); -void vj_event_sample_bind_outp_osc ( void *ptr, const char format[], va_list ap ); -void vj_event_sample_release_outp_osc ( void *ptr, const char format[], va_list ap ); -void vj_event_sample_start_osc_sender ( void *ptr, const char format[], va_list ap ); -void vj_event_sample_stop_osc_sender ( void *ptr, const char format[], va_list ap ); -#endif diff --git a/veejay-ng/veejay/vj-eventman.c b/veejay-ng/veejay/vj-eventman.c deleted file mode 100644 index 8cacc6ff..00000000 --- a/veejay-ng/veejay/vj-eventman.c +++ /dev/null @@ -1,1056 +0,0 @@ -/* veejay - Linux VeeJay - * (C) 2002-2005 Niels Elburg - * - * - * 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#include -#include -#include -#include -#include -#include -#ifdef STRICT_CHECKING -#include -#endif - -#define MAX_INDEX 1024 - -#define VIMS_REQUIRE_ALL_PARAMS (1<<0) /* all params needed */ -#define VIMS_DONT_PARSE_PARAMS (1<<1) /* dont parse arguments */ -#define VIMS_LONG_PARAMS (1<<3) /* long string arguments (bundle, plugin) */ -#define VIMS_ALLOW_ANY (1<<4) /* use defaults when optional arguments are not given */ - -#define SAMPLE_ID_HELP "Sample ID (0=current playing, -1=last created, > 0 = Sample ID)" -#define SAMPLE_FX_ENTRY_HELP "Entry ID" -#define STREAM_ID_HELP "Stream ID (-1=last created, > 0 = Stream ID)" -#define SAMPLE_STREAM_ID_HELP "Sample or Stream ID (0=current playing, -1=last created, > 0 = ID)" -static vevo_port_t **index_map_ = NULL; -/* define the function pointer to any event */ -typedef void (*vevo_event)(void *ptr, const char format[], va_list ap); - -void *vj_event_vevo_get_event_function( int id ); -char *vj_event_vevo_get_event_name( int id ); -char *vj_event_vevo_get_event_format( int id ); -int vj_event_vevo_get_num_args(int id); -int vj_event_vevo_get_flags( int id ); -int vj_event_vevo_get_vims_id( int id ); -void vj_init_vevo_events(void); -void vj_event_vevo_inline_fire(void *super, int vims_id, const char *format, ... ); -char *vj_event_vevo_list_serialize(void); -void vj_event_vevo_dump(void); -char *vj_event_vevo_help_vims( int id, int n ); -int vj_event_vevo_get_default_value(int id, int p); -void vj_event_vevo_free(void); - - -static void dump_event_stderr(vevo_port_t *event) -{ - char *fmt = NULL; - char *name = NULL; - int n_arg = 0; - int vims_id = 0; - char *param = NULL; - int i; - char key[10]; - - size_t len = vevo_property_element_size(event, "format", 0 ); - if(len > 0 ) - { - fmt = malloc(sizeof(char) * len); - vevo_property_get( event, "format", 0, &fmt ); - } - name = malloc(sizeof(char) * vevo_property_element_size( event, "description", 0 )); - vevo_property_get( event, "description", 0, &name ); - - vevo_property_get( event, "arguments", 0, &n_arg ); - vevo_property_get( event, "vims_id", 0, &vims_id ); - - veejay_msg(VEEJAY_MSG_INFO, "VIMS selector %03d\t'%s'", vims_id, name ); - if(fmt) - veejay_msg(VEEJAY_MSG_INFO, "\tFORMAT: '%s', where:", fmt ); - - for( i = 0; i < n_arg; i ++ ) - { - sprintf(key, "help_%d", i ); - size_t len2 = vevo_property_element_size( event, key, 0 ); - if(len2 > 0 ) - { - param = malloc(sizeof(char) * len2 ); - vevo_property_get( event, key, 0, ¶m ); - veejay_msg(VEEJAY_MSG_INFO,"\t\tArgument %d is %s", i, param ); - free(param); - } - } - - if(fmt) free(fmt); - free(name); - veejay_msg(VEEJAY_MSG_INFO," "); -} - -int vj_event_vevo_list_size(void) -{ - int i; - int len =0; - for ( i = 0; i < MAX_INDEX ;i ++ ) - { - if( index_map_[i] != NULL ) - { - char *name = vj_event_vevo_get_event_name( i ); - char *format= vj_event_vevo_get_event_format( i ); - len += (name == NULL ? 0: strlen( name )); - len += (format == NULL ? 0: strlen( format )); - len += 12; - if(name) free(name); - if(format)free(format); - } - } - return len; -} - -char *vj_event_vevo_help_vims( int id, int n ) -{ - char *help = NULL; - char key[10]; - sprintf(key, "help_%d", n); - size_t len = vevo_property_element_size( index_map_[id], key, 0 ); - if(len > 0 ) - { - help = (char*) malloc(sizeof(char) * len ); - vevo_property_get( index_map_[id], key, 0, &help ); - } - return help; -} - -char *vj_event_vevo_list_serialize(void) -{ - int len = vj_event_vevo_list_size() + 5; - char *res = (char*) malloc(sizeof(char) * len + 100 ); - int i; - memset( res, 0, len ); - sprintf(res, "%05d", len - 5); - for ( i = 0; i < MAX_INDEX ;i ++ ) - { - if ( index_map_[i] != NULL ) - { - char *name = vj_event_vevo_get_event_name( i ); - char *format= vj_event_vevo_get_event_format( i ); - int name_len = (name == NULL ? 0: strlen( name )); - int fmt_len = (format == NULL? 0: strlen( format )); - char tmp[13]; - sprintf( tmp, "%04d%02d%03d%03d", - i, vj_event_vevo_get_num_args(i), fmt_len, name_len ); - strncat( res, tmp, 12 ); - if( format != NULL ) - strncat( res, format, fmt_len ); - if( name != NULL ) - strncat( res, name, name_len ); - if(name) free(name); - if(format) free(format); - - } - } - return res; -} - -void vj_event_vevo_inline_fire(void *super, int vims_id, const char *format, ... ) -{ - va_list ap; - va_start( ap, format ); - void *func = NULL; - vevo_property_get( index_map_[vims_id], "function", 0, &func ); - vevo_event f = (vevo_event) func; - f( super, format, ap ); - va_end( ap ); -} - -static vevo_port_t *_new_event( - const char *format, - int vims_id, - const char *name, - void *function, - int n_arg, - int flags, - ... ) -{ - int n = 0; - int it = 1; - char param_name[16]; - char descr_name[255]; - -#ifdef STRICT_CHECKING - assert( name != NULL ); - assert( function != NULL ); - assert( vims_id > 0 ); -#endif - - vevo_port_t *p = (void*) vevo_port_new( VEVO_EVENT_PORT ); -#ifdef STRICT_CHECKING - assert( p != NULL ); -#endif - if( format ) - vevo_property_set( p, "format", VEVO_ATOM_TYPE_STRING, 1, &format ); - else - vevo_property_set( p, "format", VEVO_ATOM_TYPE_STRING, 0, NULL ); - - vevo_property_set( p, "description", VEVO_ATOM_TYPE_STRING, 1, &name ); - vevo_property_set( p, "function", VEVO_ATOM_TYPE_VOIDPTR, 1,&function ); - vevo_property_set( p, "arguments", VEVO_ATOM_TYPE_INT, 1, &n_arg ); - vevo_property_set( p, "flags", VEVO_ATOM_TYPE_INT, 1, &flags ); - vevo_property_set( p, "vims_id", VEVO_ATOM_TYPE_INT, 1, &vims_id ); - va_list ap; - va_start(ap, flags); -#ifdef STRICT_CHECKING - veejay_msg(VEEJAY_MSG_DEBUG, - "VIMS %03d: '%s' '%s' %d arguments", vims_id, name, format, n_arg ); -#endif - - for( n = 0; n < n_arg ; n ++) - { - int dd = 0; - char *ds = NULL; - bzero( param_name, 16 ); - bzero( descr_name, 255 ); - - - sprintf(param_name, "argument_%d", n ); - const char *arg = va_arg( ap, const char*); -#ifdef STRICT_CHECKING - if(!arg) veejay_msg(0, "\t%s - %d = '%s' of format %c (%s)",param_name, n, arg, format[it],format ); - assert( arg != NULL ); -#endif - char *descr = (char*) strdup( arg ); - sprintf(descr_name, "help_%d", n ); - - if (format[it] == 'd') - { - dd = va_arg( ap, int ); - vevo_property_set( p, param_name, VEVO_ATOM_TYPE_INT,1, &dd ); - } - else - { - ds = va_arg( ap, char*); - if(!ds) - vevo_property_set( p, param_name, VEVO_ATOM_TYPE_STRING, 0, NULL ); - else - vevo_property_set( p, param_name, VEVO_ATOM_TYPE_STRING,1, &ds ); - } - - vevo_property_set( p, descr_name, VEVO_ATOM_TYPE_STRING, 1,&descr ); - - it += 3; - - if( ds ) - free( ds); - if( descr ) - free( descr ); - } - - va_end(ap); - - return p; -} - -void * vj_event_vevo_get_event_function( int id ) -{ - void *func = NULL; - if( index_map_[id] ) - vevo_property_get( index_map_[id] , "function", 0, &func ); - return func; -} - -char *vj_event_vevo_get_event_name( int id ) -{ - char *descr = NULL; - size_t len = vevo_property_element_size( index_map_[id], "description", 0 ); - if(len > 0 ) - { - descr = (char*) malloc(sizeof(char) * len ); - vevo_property_get( index_map_[id], "description", 0, &descr ); - } - return descr; -} -char *vj_event_vevo_get_event_format( int id ) -{ - char *fmt = NULL; - size_t len = vevo_property_element_size( index_map_[id], "format", 0 ); - if(len > 0 ) - { - fmt = (char*) malloc(sizeof(char) * len ); - vevo_property_get( index_map_[id], "format", 0, &fmt ); - } - return fmt; -} - -int vj_event_exists( int id ) -{ - if( index_map_[id]) - return 1; - return 0; -} - - -int vj_event_vevo_get_default_value(int id, int p) -{ - int n =0; - char key[15]; - sprintf(key, "argument_%d",p); - vevo_property_get(index_map_[id], key, 0, &n ); - return n; -} -int vj_event_vevo_get_num_args(int id) -{ - int n =0; - vevo_property_get(index_map_[id], "arguments", 0, &n ); - return n; -} -int vj_event_vevo_get_flags( int id ) -{ - int flags = 0; - vevo_property_get( index_map_[id], "flags", 0, &flags ); - return flags; -} - -int vj_event_vevo_get_vims_id( int id ) -{ - int vims_id = 0; - vevo_property_get( index_map_[id], "vims_id", 0, &vims_id ); - return vims_id; -} - -void vj_event_vevo_dump(void) -{ - int i; - veejay_msg(VEEJAY_MSG_INFO, "VIMS Syntax: ':;'"); - veejay_msg(VEEJAY_MSG_INFO, "Use arguments according to FORMAT"); - veejay_msg(VEEJAY_MSG_INFO, "FORMAT controls the arguments as in C printf. Interpreted sequences are:"); - veejay_msg(VEEJAY_MSG_INFO, "\t%%d\tinteger"); - veejay_msg(VEEJAY_MSG_INFO, "\t%%s\tstring"); - - for( i = 0; i < MAX_INDEX; i ++ ) - { - if( index_map_[i] ) - { - dump_event_stderr( index_map_[i] ); - } - } -} - -void vj_event_vevo_free(void) -{ - int i; -#ifdef STRICT_CHECKING - assert( index_map_ != NULL ); -#endif - if( !index_map_) - return; - - for( i = 0 ; i < MAX_INDEX ; i ++ ) - if( index_map_[i] ) vevo_port_free( index_map_[i] ); - - free(index_map_); -} - -void vj_init_vevo_events(void) -{ - index_map_ = (vevo_port_t*) malloc(sizeof(vevo_port_t*) * MAX_INDEX ); - memset( index_map_, 0, sizeof( vevo_port_t *) * MAX_INDEX ); - - - index_map_[VIMS_SAMPLE_NEW] = _new_event( - "%d %d %s", - VIMS_SAMPLE_NEW, - "Create a new sample", - vj_event_sample_new, - 3, - VIMS_REQUIRE_ALL_PARAMS, - "Type", - 0, - "Number", - 0, - "Token", - NULL, - NULL ); - - - index_map_[VIMS_SAMPLE_PLAY_FORWARD] = _new_event( - "%d", - VIMS_SAMPLE_PLAY_FORWARD, - "Play forward", - vj_event_play_forward, - 1, - VIMS_ALLOW_ANY, - SAMPLE_ID_HELP, - 0, - NULL ); - - index_map_[VIMS_SAMPLE_PLAY_BACKWARD] = _new_event( - "%d", - VIMS_SAMPLE_PLAY_BACKWARD, - "Play backward", - vj_event_play_reverse, - 1, - VIMS_ALLOW_ANY, - SAMPLE_ID_HELP, - 0, - NULL ); - - index_map_[VIMS_SAMPLE_PLAY_STOP] = _new_event( - "%d", - VIMS_SAMPLE_PLAY_STOP, - "Play stop", - vj_event_play_stop, - 1, - VIMS_ALLOW_ANY, - SAMPLE_ID_HELP, - 0, - NULL ); - - index_map_[VIMS_SAMPLE_SKIP_FRAME] = _new_event( - "%d %d", - VIMS_SAMPLE_SKIP_FRAME, - "Skip N frames forward", - vj_event_inc_frame, - 2, - VIMS_ALLOW_ANY, - SAMPLE_ID_HELP, - 0, - "Number of frames", // param label - 1, // default - NULL ); - - index_map_[VIMS_SAMPLE_PREV_FRAME] = _new_event( - "%d %d", - VIMS_SAMPLE_PREV_FRAME, - "Skip N frames backward", - vj_event_dec_frame, - 2, - VIMS_ALLOW_ANY, - SAMPLE_ID_HELP, - 0, - "Number of frames", - 1, - NULL ); - - index_map_[VIMS_SAMPLE_SKIP_SECOND] = _new_event( - "%d %d", - VIMS_SAMPLE_SKIP_SECOND, - "Skip N seconds forward", - vj_event_next_second, - 2, - VIMS_ALLOW_ANY, - SAMPLE_ID_HELP, - 0, - "Number of seconds", - 1, - NULL ); - - index_map_[VIMS_SAMPLE_PREV_SECOND] = _new_event( - "%d %d", - VIMS_SAMPLE_PREV_SECOND, - "Skip N seconds backward", - vj_event_prev_second, - 2, - VIMS_ALLOW_ANY, - SAMPLE_ID_HELP, - 0, - "Number of seconds", - 1, - NULL ); - - index_map_[VIMS_SAMPLE_GOTO_START] = _new_event( - "%d", - VIMS_SAMPLE_GOTO_START, - "Go to starting position", - vj_event_goto_start, - 1, - VIMS_ALLOW_ANY, - SAMPLE_ID_HELP, - 0, - NULL ); - - index_map_[VIMS_SAMPLE_GOTO_END] = _new_event( - "%d", - VIMS_SAMPLE_GOTO_END, - "Go to ending position", - vj_event_goto_end, - 1, - VIMS_ALLOW_ANY, - SAMPLE_ID_HELP, - 0, - NULL ); - - index_map_[VIMS_SAMPLE_SET_SPEED] = _new_event( - "%d %d", - VIMS_SAMPLE_SET_SPEED, - "Change trickplay speed", - vj_event_play_speed, - 2, - VIMS_ALLOW_ANY, - SAMPLE_ID_HELP, - 0, - "Frame step", - 1, - NULL ); - - index_map_[VIMS_SAMPLE_SET_SLOW] = _new_event( - "%d %d", - VIMS_SAMPLE_SET_SLOW, - "Change repeat speed", - vj_event_play_repeat, - 2, - VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - "Frame repeat", - 0, - NULL ); - - index_map_[VIMS_SAMPLE_SET_FRAME] = _new_event( - "%d %d", - VIMS_SAMPLE_SET_FRAME, - "Set current frame number", - vj_event_set_frame, - 2, - VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - "Frame number", - 0, - NULL ); - - index_map_[VIMS_SAMPLE_DEL] = _new_event( - "%d", - VIMS_SAMPLE_DEL, - "Delete sample", - vj_event_sample_del, - 1, - VIMS_REQUIRE_ALL_PARAMS, - "Sample ID >= 1", - 0, - NULL ); - - index_map_[VIMS_SAMPLE_COPY] = _new_event( - "%d", - VIMS_SAMPLE_COPY, - "Copy sample to new", - vj_event_sample_copy, - 1, - VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - NULL ); - - index_map_[VIMS_SAMPLE_SELECT] = _new_event( - "%d", - VIMS_SAMPLE_SELECT, - "Select and play sample", - vj_event_sample_select, - 1, - VIMS_ALLOW_ANY, - SAMPLE_ID_HELP, - 0, - NULL ); - - index_map_[VIMS_SAMPLE_CHAIN_CLEAR] = _new_event( - "%d", - VIMS_SAMPLE_CHAIN_CLEAR, - "Reset Effect Chain", - vj_event_chain_clear, - 1, - VIMS_ALLOW_ANY, - SAMPLE_STREAM_ID_HELP, - 0, - NULL ); - - index_map_[VIMS_SAMPLE_CHAIN_ENTRY_SET_ACTIVE] = _new_event( - "%d %d %d", - VIMS_SAMPLE_CHAIN_ENTRY_SET_ACTIVE, - "Activate or deactivate processing of a fx slot", - vj_event_chain_entry_set_active, - 3, - VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - SAMPLE_FX_ENTRY_HELP, - 0, - "0=off,1=on", - 1, - NULL ); - index_map_[VIMS_SET_PORT] = _new_event( - "%s", - VIMS_SET_PORT, - "Set properties", - vj_event_none, - 1, - VIMS_REQUIRE_ALL_PARAMS, - "formatted text", - NULL, - NULL ); - - index_map_[VIMS_SAMPLE_CHAIN_ENTRY_SET_FX] = _new_event( - "%d %d %s", - VIMS_SAMPLE_CHAIN_ENTRY_SET_FX, - "Put an Effect on a Entry", - vj_event_chain_entry_set, - 3, - VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - SAMPLE_FX_ENTRY_HELP, - 0, - "Effect name", - NULL, - NULL ); - - index_map_[VIMS_SAMPLE_CHAIN_ENTRY_CLEAR] = _new_event( - "%d %d", - VIMS_SAMPLE_CHAIN_ENTRY_CLEAR, - "Clear an entry", - vj_event_chain_entry_clear, - 2, - VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - SAMPLE_FX_ENTRY_HELP, - 0, - NULL ); - - index_map_[VIMS_SAMPLE_CHAIN_ENTRY_SET_INPUT] = _new_event( - "%d %d %d %d", - VIMS_SAMPLE_CHAIN_ENTRY_SET_INPUT, - "Set Input Channel", - vj_event_chain_entry_set_input, - 4, - VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - SAMPLE_FX_ENTRY_HELP, - 0, - "Input Channel ID", - 0, - SAMPLE_ID_HELP, - 0, - NULL ); - - index_map_[VIMS_SAMPLE_CHAIN_ENTRY_SET_VALUE] = _new_event( - "%d %d %d %s", - VIMS_SAMPLE_CHAIN_ENTRY_SET_VALUE, - "Set Input parameter value", - vj_event_chain_entry_set_parameter_value, - 4, - VIMS_LONG_PARAMS | VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - SAMPLE_FX_ENTRY_HELP, - 0, - "Input Parameter ID", - 0, - "Character string", - NULL, - NULL ); - - index_map_[VIMS_SAMPLE_CHAIN_ENTRY_SET_ALPHA] = _new_event( - "%d %d %d", - VIMS_SAMPLE_CHAIN_ENTRY_SET_ALPHA, - "Set opacity of an entry", - vj_event_chain_entry_set_alpha, - 3, - VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - SAMPLE_FX_ENTRY_HELP, - 0, - "Opacity value", - 256, - NULL ); - - - index_map_[VIMS_SAMPLE_DETACH_OUT_PARAMETER] = _new_event( - "%d %d %d", - VIMS_SAMPLE_DETACH_OUT_PARAMETER, - "Detach output parameter", - vj_event_sample_detach_out_parameter, - 3, - VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - SAMPLE_FX_ENTRY_HELP, - 0, - "Output parameter", - -1, - NULL ); - - index_map_[VIMS_SAMPLE_BIND_OUTP_OSC] = _new_event( - "%d %d %s", - VIMS_SAMPLE_BIND_OUTP_OSC, - "Bind OSC path to fx output parameters", - vj_event_sample_bind_outp_osc, - 3, - VIMS_LONG_PARAMS | VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - SAMPLE_FX_ENTRY_HELP, - 0, - "OSC path", - NULL, - NULL ); - - index_map_[VIMS_SAMPLE_RELEASE_OUTP_OSC] = _new_event( - "%d %d", - VIMS_SAMPLE_RELEASE_OUTP_OSC, - "Release OSC path from fx output parameters", - vj_event_sample_release_outp_osc, - 2, - VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - SAMPLE_FX_ENTRY_HELP, - 0, - NULL ); - - - - index_map_[VIMS_SAMPLE_ATTACH_OUT_PARAMETER] = _new_event( - "%d %d %d %d %d", - VIMS_SAMPLE_ATTACH_OUT_PARAMETER, - "Attach output parameter", - vj_event_sample_attach_out_parameter, - 5, - VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - SAMPLE_FX_ENTRY_HELP, - 0, - "Output parameter", - -1, - SAMPLE_FX_ENTRY_HELP, - 0, - "Input parameter", - -1, - NULL ); - - index_map_[VIMS_SAMPLE_OSC_START] = _new_event( - "%d %d %s", - VIMS_SAMPLE_OSC_START, - "Start new OSC sender", - vj_event_sample_start_osc_sender, - 3, - VIMS_REQUIRE_ALL_PARAMS | VIMS_LONG_PARAMS, - SAMPLE_ID_HELP, - 0, - "Port number", - 0, - "Address", - NULL, - NULL ); - - index_map_[VIMS_SAMPLE_OSC_STOP] = _new_event( - "%d", - VIMS_SAMPLE_OSC_STOP, - "Stop OSC sender", - vj_event_sample_stop_osc_sender, - 1, - VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - NULL ); - - - - index_map_[VIMS_PERFORMER_SETUP_PREVIEW] = _new_event( - "%d %d", - VIMS_PERFORMER_SETUP_PREVIEW, - "Configure preview image", - vj_event_performer_configure_preview, - 2, - VIMS_REQUIRE_ALL_PARAMS, - "Preview mode", - 0, - "Recude", - 0, - NULL ); - - index_map_[VIMS_PERFORMER_GET_PREVIEW] = _new_event( - NULL, - VIMS_PERFORMER_GET_PREVIEW, - "Get preview image", - vj_event_performer_get_preview_image, - 0, - VIMS_REQUIRE_ALL_PARAMS, - NULL, - NULL ); - - index_map_[VIMS_SAMPLE_CONFIGURE_RECORDER] = _new_event( - "%d %d %d %s", - VIMS_SAMPLE_CONFIGURE_RECORDER, - "Configure sample recorder", - vj_event_sample_configure_recorder, - 4, - VIMS_LONG_PARAMS|VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - "Dataformat", - 0, - "Number of frames", - 0, - "Filename", - NULL, - NULL ); - - index_map_ [ VIMS_SAMPLEBANK_LIST ] = _new_event( - NULL, - VIMS_SAMPLEBANK_LIST, - "List samples in samplebank", - vj_event_samplebank_list, - 0, - VIMS_REQUIRE_ALL_PARAMS, - NULL, - NULL ); - - index_map_ [ VIMS_SAMPLEBANK_ADD ] = _new_event( - "%d %d %s", - VIMS_SAMPLEBANK_ADD, - "Add file to samplebank", - vj_event_samplebank_add, - 3, - VIMS_LONG_PARAMS | VIMS_REQUIRE_ALL_PARAMS, - "Type of sample", - 0, - "Extra token", - 0, - "Filename", - NULL, - NULL ); - - index_map_[ VIMS_SAMPLEBANK_DEL ] = _new_event( - "%d", - VIMS_SAMPLEBANK_DEL, - "Delete sample from samplebank", - vj_event_samplebank_del, - 1, - VIMS_REQUIRE_ALL_PARAMS, - "Sample ID", - 0, - NULL ); - - index_map_ [ VIMS_FX_LIST ] = _new_event( - NULL, - VIMS_FX_LIST, - "List all loaded plugins", - vj_event_fx_list, - 0, - VIMS_REQUIRE_ALL_PARAMS, - NULL, - NULL ); - - index_map_[ VIMS_FX_DETAILS ] = _new_event( - "%s", - VIMS_FX_DETAILS, - "Get plugin information", - vj_event_fx_info, - 1, - VIMS_REQUIRE_ALL_PARAMS, - "Plugin name", - NULL, - NULL ); - index_map_[ VIMS_FX_CURRENT_DETAILS ] = _new_event( - "%d %d", - VIMS_FX_DETAILS, - "Get fx information on sample entry", - vj_event_sample_fx_details, - 2, - VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - SAMPLE_FX_ENTRY_HELP, - 0, - NULL ); - - index_map_[ VIMS_FX_CHAIN ] = _new_event( - "%d", - VIMS_FX_CHAIN, - "Get fx chain of sample", - vj_event_sample_fx_chain, - 1, - VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - NULL ); - - index_map_ [ VIMS_SAMPLE_START_RECORDER ] = _new_event( - "%d", - VIMS_SAMPLE_START_RECORDER, - "Start recording from sample", - vj_event_sample_start_recorder, - 1, - VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - NULL ); - - index_map_[ VIMS_SAMPLE_STOP_RECORDER ] = _new_event( - "%d", - VIMS_SAMPLE_STOP_RECORDER, - "Stop recording from sample", - vj_event_sample_stop_recorder, - 1, - VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - NULL ); - - - index_map_[VIMS_SAMPLE_EDL_PASTE_AT] = _new_event( - "%d %d", - VIMS_SAMPLE_EDL_PASTE_AT, - "Paste frames from buffer at frame into edit descision list", - vj_event_el_paste_at, - 2, - VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - "Position to insert frames", - 0, - NULL ); - - index_map_[VIMS_SAMPLE_EDL_CUT] = _new_event( - "%d %d %d", - VIMS_SAMPLE_EDL_CUT, - "Cut frames from edit descision list to buffer", - vj_event_el_cut, - 3, - VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - "Starting position", - 0, - "Ending position", - 0, - NULL ); - - index_map_[VIMS_SAMPLE_EDL_COPY] = _new_event( - "%d %d %d", - VIMS_SAMPLE_EDL_COPY, - "Copy frames from edit descision list to buffer", - vj_event_el_copy, - 3, - VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - "Starting position", - 0, - "Ending position", - 0, - NULL ); - - index_map_[VIMS_SAMPLE_EDL_DEL] = _new_event( - "%d %d", - VIMS_SAMPLE_EDL_DEL, - "Delete frames from editlist (no undo!)", - vj_event_el_del, - 3, - VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - "Starting position", - 0, - "Ending position", - 0, - NULL ); - - - index_map_[VIMS_SAMPLE_EDL_ADD] = _new_event( - "%s", - VIMS_SAMPLE_EDL_ADD, - "Add video file to edit descision list", - vj_event_el_add_video, - 1, - VIMS_LONG_PARAMS | VIMS_REQUIRE_ALL_PARAMS, - "Filename", - NULL, - NULL ); - - index_map_[VIMS_SAMPLE_SET_VOLUME] = _new_event( - "%d %d", - VIMS_SAMPLE_SET_VOLUME, - "Set audio volume", - vj_event_set_volume, - 2, - VIMS_REQUIRE_ALL_PARAMS, - SAMPLE_ID_HELP, - 0, - "Volume 0-100", - 0, - NULL ); - index_map_[VIMS_DEBUG_LEVEL] = _new_event( - NULL, - VIMS_DEBUG_LEVEL, - "More/Less verbosive console output", - vj_event_debug_level, - 0, - VIMS_ALLOW_ANY, - NULL ); - index_map_[VIMS_BEZERK] = _new_event( - NULL, - VIMS_BEZERK, - "Bezerk mode toggle ", - vj_event_bezerk, - 0, - VIMS_ALLOW_ANY, - NULL ); - -#ifdef USE_DISPLAY - index_map_[VIMS_RESIZE_SCREEN] = _new_event( - "%d %d %d %d", - VIMS_RESIZE_SCREEN, - "(OUT) Resize video display", - vj_event_set_screen_size, - 4, - VIMS_REQUIRE_ALL_PARAMS, - "Width", - 0, - "Height", - 0, - "X offset", - 0, - "Y offset", - 0, - NULL ); - index_map_[VIMS_FULLSCREEN] = _new_event( - "%d", - VIMS_FULLSCREEN, - "Enable / Disable Fullscreen video output", - vj_event_fullscreen, - 1, - VIMS_ALLOW_ANY, - "On = 1, Off=0", - 1, - NULL ); - -#endif - index_map_[VIMS_QUIT] = _new_event( - NULL, - VIMS_QUIT, - "Quit Veejay (caution!)", - vj_event_quit, - 0, - VIMS_ALLOW_ANY, - NULL ); - -} - - - diff --git a/veejay-ng/vevosample/vevosample.c b/veejay-ng/vevosample/vevosample.c index 2784cea2..d0ec5631 100644 --- a/veejay-ng/vevosample/vevosample.c +++ b/veejay-ng/vevosample/vevosample.c @@ -130,6 +130,7 @@ typedef struct samplerecord_t *record; sampleinfo_t *info; void *osc; + void *user_data; } sample_runtime_data; @@ -142,7 +143,7 @@ typedef struct /* forward */ -static void sample_fx_clean_up( void *port ); +static void sample_fx_clean_up( void *port, void *user_data ); static void *sample_get_fx_port_values_ptr( int id, int fx_entry ); static void sample_expand_properties( void *sample, const char *key, xmlNodePtr root ); static void sample_expand_port( void *port, xmlNodePtr node ); @@ -163,6 +164,26 @@ static void sample_new_fx_chain(void *sample); * to reduce vevo set/get , cache each step */ +static struct +{ + const char *name; +} protected_properties[] = +{ + "type", + "audio_spas", + "bits", + "rate", + "has_audio", + "channels", + "fx_osc", + "primary_key", + "fps", + "bps", + NULL +}; + + +int compare_elements( char **p1, char **p2 ) { return strcoll(*p1,*p2); } void trap_vevo_sample() {} @@ -370,12 +391,31 @@ static void free_slot(int key) } } + +static int sample_property_is_protected( void *sample , const char *key ) +{ + sample_runtime_data *srd = (sample_runtime_data*) sample; + + int i; + for( i = 0; protected_properties[i].name != NULL ;i ++ ) + { + if(strcasecmp(key,protected_properties[i].name ) == 0 ) + return 1; + } + return 0; +} + int sample_get_key_ptr( void *info ) { + if(!info) + return 0; int pk = 0; sample_runtime_data *srd = (sample_runtime_data*) info; + int error = vevo_property_get( srd->info_port, "primary_key", 0, &pk ); #ifdef STRICT_CHECKING + if( error != VEVO_NO_ERROR ) + veejay_msg(0, "primary_key does not exist, error %d",error); assert( error == VEVO_NO_ERROR ); #endif return pk; @@ -394,7 +434,15 @@ void sample_delete_ptr( void *info ) int pk = 0; int error = vevo_property_get( srd->info_port, "primary_key", 0, &pk ); - sample_fx_clean_up( srd->info_port ); + void *osc_space = NULL; + error = vevo_property_get( srd->info_port, "HOST_osc",0,&osc_space ); +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif + + veejay_osc_del_methods( srd->user_data, osc_space,srd->info_port ,srd); + + sample_fx_clean_up( srd->info_port, srd->user_data ); sample_close( srd ); @@ -402,6 +450,7 @@ void sample_delete_ptr( void *info ) free_slot( pk ); free(srd->info); + free(srd->record); free(srd); if( error == VEVO_NO_ERROR ) @@ -421,7 +470,7 @@ void sample_fx_chain_reset( void *sample ) { sample_runtime_data *srd = (sample_runtime_data*) sample; - sample_fx_clean_up( srd->info_port ); + sample_fx_clean_up( srd->info_port,srd->user_data ); sample_new_fx_chain ( srd->info_port ); } @@ -451,6 +500,8 @@ int sample_fx_set( void *info, int fx_entry, const int new_fx ) void *port = sample_get_fx_port_ptr( info,fx_entry ); void *fx_values = NULL; void *fx_channels = NULL; + sample_runtime_data *srd = (sample_runtime_data*) info; + //int cur_fx_id = 0; int error; #ifdef STRICT_CHECKING @@ -510,12 +561,184 @@ int sample_fx_set( void *info, int fx_entry, const int new_fx ) veejay_msg(0, "Entry %d Plug %d has %d Inputs, %d Outputs",fx_entry, new_fx,n_channels,o_channels ); - + + //@ setup OSC namespace + int pk = 0; + vevo_property_get( srd->info_port, "primary_key", 0, &pk ); + + plug_build_name_space( new_fx, fx_instance, srd->user_data, fx_entry ,pk); //@ FIXME: get default channel configuration // plug_get_channels( fx_instance, fx_channels ); return 1; } +int sample_osc_verify_format( void *vevo_port, char const *types ) +{ + char *format = get_str_vevo( vevo_port, "format" ); + int n = strlen(types); + if(!format) + { + if( n == 0 && format == NULL ) + return 1; + return 0; + } + if( strcasecmp( types,format ) == 0 ) + { + free(format); + return 1; + } + free(format); + return 0; +} +static void sample_osc_print( void *osc_port ) +{ + char **osc_events = vevo_list_properties ( osc_port ); + int i,k,n=0; + + for( i = 0; osc_events[i] != NULL ; i ++ ) + { + void *osc_info = NULL; + int error = vevo_property_get( osc_port, osc_events[i], 0, &osc_info ); +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif + char *format = get_str_vevo( osc_info, "format" ); + + veejay_msg(VEEJAY_MSG_INFO, "OSC PATH %s",osc_events[i] ); + char *descr = get_str_vevo( osc_info, "description" ); + if(descr) + { + veejay_msg(VEEJAY_MSG_INFO,"\t%s", descr); + free(descr); + } + + veejay_msg(VEEJAY_MSG_INFO, "\tFormat=%s", format ); + + + if(format) + { + int n_args = strlen(format); + char key[10]; + int j; + for( j = 0; j < n_args ; j ++ ) + { + sprintf(key, "help_%d", j ); + char *help_str = get_str_vevo( osc_info, key ); + if(help_str) + { + veejay_msg(VEEJAY_MSG_INFO,"\t\tArgument %d : %s", j, help_str ); + free(help_str); + } + } + free(format); + } + veejay_msg(VEEJAY_MSG_INFO,"\t"); + free( osc_events[i]); + } + free(osc_events); + +} +void sample_osc_namespace(void *sample) +{ + sample_runtime_data *srd = (sample_runtime_data*) sample; + + void *osc_namespace = NULL; + int error = vevo_property_get( srd->info_port, "HOST_osc",0, &osc_namespace); +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif + veejay_msg(VEEJAY_MSG_INFO,"OSC namespace:"); + + sample_osc_print( osc_namespace ); + +veejay_msg(VEEJAY_MSG_INFO,"FX:"); + int k; + for( k = 0; k < SAMPLE_CHAIN_LEN ; k ++ ) + { + void *port = sample_get_fx_port_ptr( srd, k ); + void *fx_instance = NULL; + error = vevo_property_get( port, "fx_instance", 0, &fx_instance ); + if( error == VEVO_NO_ERROR ) + { + void *space = plug_get_name_space( fx_instance ); + if(space) sample_osc_print( space ); + } + } +veejay_msg(VEEJAY_MSG_INFO,"End of OSC namespace"); +} + + +void sample_osc_help( void *sample, const char *path ) +{ + +} + +int sample_extract_fx_entry_from_path(void *sample, const char *path ) +{ + char *my_path = strdup(path); + char *token = strtok( my_path, "/"); + + char *res = NULL; + while( (res = strtok(NULL, "/" ) )) + { + if(strncasecmp( res, "fx_", 3 ) == 0 ) + { + int id = 0; + if(sscanf( res+3,"%d", &id ) == 1 ) + return id; + } + } + + free(my_path); + return -1; +} + + +int sample_osc_property_calls_event( void *sample, const char *path, char *types, void **argv[] ) +{ + sample_runtime_data *srd = (sample_runtime_data*) sample; + void *vevo_port = srd->info_port; + void *osc_port = NULL; + int error = vevo_property_get( srd->info_port, "HOST_osc", 0, &osc_port ); +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif + int atom_type = vevo_property_atom_type( osc_port, path ); + if( atom_type == VEVO_ATOM_TYPE_PORTPTR ) + { + // veejay_msg(0, "path %s is PORTPTR", path ); + void *port = NULL; + error = vevo_property_get( osc_port, path,0,&port ); +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif + if(error == VEVO_NO_ERROR ) + { + vevo_event_f f; +//veejay_msg(0, "verify '%s' : %p, types %s, instance=%p", path,port, types,sample); + + + // char *format = get_str_vevo( port, "format" ); +//veejay_msg(0, "format is %s", format); + + + + + + + if( sample_osc_verify_format( port, types ) ) + { + error = vevo_property_get( port, "func",0,&f ); + if( error == VEVO_NO_ERROR ) + { + (*f)( sample, path,types, argv ); + return 1; + } + } + } + } + return 0; +} int sample_fx_set_in_channel( void *info, int fx_entry, int seq_num, const int sample_id ) { void *port = sample_get_fx_port_ptr( info, fx_entry ); @@ -595,6 +818,7 @@ int sample_process_entry( void *data, int fx_entry ) #ifdef STRICT_CHECKING assert( error == VEVO_NO_ERROR ); #endif + return fx_status; } int sample_get_fx_alpha( void *data, int fx_entry ) @@ -721,6 +945,7 @@ int sample_process_fx( void *sample, int fx_entry ) void *fx_out_values = NULL; void *port = sample_get_fx_port_ptr( sample,fx_entry ); + sample_runtime_data *srd = (sample_runtime_data*) sample; #ifdef STRICT_CHECKING assert( port != NULL ); #endif @@ -750,8 +975,9 @@ int sample_process_fx( void *sample, int fx_entry ) sample_apply_bind( sample, port ); + if(srd->osc) //@ send osc message if needed - sample_send_osc_path( sample, port ); + sample_send_osc_path( sample, port ); return VEVO_NO_ERROR; @@ -837,14 +1063,15 @@ void *sample_get_fx_port( int id, int fx_entry ) { return sample_get_fx_port_ptr( find_sample(id),fx_entry ); } -void sample_set_property_ptr( void *ptr, const char *key, int atom_type, void *value ) +int sample_set_property_ptr( void *ptr, const char *key, int atom_type, void *value ) { sample_runtime_data *info = (sample_runtime_data*) ptr; if( info->type == VJ_TAG_TYPE_CAPTURE) { vj_unicap_select_value( info->data,key, atom_type,value ); + return VEVO_NO_ERROR; } - vevo_property_set( info->info_port, key, atom_type,1, value ); + return vevo_property_set( info->info_port, key, atom_type,1, value ); } void sample_set_property( int id, const char *key, int atom_type, void *value ) @@ -858,12 +1085,141 @@ void sample_set_property( int id, const char *key, int atom_type, void *value ) vevo_property_set( info->info_port, key, atom_type,1, value ); } +static char *strip_key( const char *path) +{ + char *start = strdup(path); + int k = strlen(path); + int i; + int n = 0; + char *token = strtok( start, "/" ); + char *s = start; + char *res = NULL; + while( (token = strtok( NULL, "/" ) ) != NULL ) + { + if(res && token) + free(res); + res = strdup(token); + } + free(start); + return res; +} + +static char *strip_port( const char *path) +{ + char *start = strdup(path); + int k = strlen(path); + int i; + int n = 0; + char *token = strtok( start, "/" ); + char *s = start; + char *res = NULL; + char *port = NULL; + while( (token = strtok( NULL, "/" ) ) != NULL ) + { + if(res) + { + if(port) + free(port); + port = strdup(res); + free(res); + res= NULL; + } + res = strdup(token); + } + free(start); + if(res) free(res); + return port; +} + +void sample_set_property_from_path( void *sample, const char *path, void *value ) +{ + sample_runtime_data *info = (sample_runtime_data*) sample; + int len = strlen(path); + int n = 0; + int i; + int error; + for( i =0; i < len ; i ++ ) + if( path[i] == '/' ) + n++; + + char *key = strip_key( path ); + if(!key) + { + veejay_msg(0, "Error getting key from path '%s'", path ); + return; + } + //@ TYPE CAPTURE ! + int atom_type = vevo_property_atom_type( info->info_port, key ); + if( n == 3 ) + { + char *pk = strip_port(path); + void *port = NULL; + int error = vevo_property_get( info->info_port, pk, 0, &port ); + if( port && error == VEVO_NO_ERROR) + { + atom_type = vevo_property_atom_type( port , key ); + if(atom_type) + { + error = vevo_property_set( port,key, atom_type,1, value ); + if( error == VEVO_NO_ERROR ) + veejay_msg(VEEJAY_MSG_INFO, + "OSC path '%s' sets property '%s' %d", path, key,atom_type ); + if(pk) free(pk); + return; + } + } + if(pk) + free(pk); + return; + } + else if (n == 2 ) + { + int error = vevo_property_get( info->info_port, key, 0, NULL ); + + if( error != VEVO_ERROR_PROPERTY_EMPTY && error != VEVO_NO_ERROR ) + { + veejay_msg(0, "Unable to get property '%s'",key); + if(key) + free(key); + return; + } + } + else + return; + + if( info->type == VJ_TAG_TYPE_CAPTURE) + { + veejay_msg(0,"Warning 'key %s' may not be valid", key ); + //@ can make translation map in unicap -> key -> key pairs + vj_unicap_select_value( info->data,key, VEVO_ATOM_TYPE_DOUBLE,value ); + } + + if(info) + error = vevo_property_set( info->info_port,key, atom_type,1, value ); + if( error == VEVO_NO_ERROR ) + veejay_msg(VEEJAY_MSG_INFO, + "OSC path '%s' sets property '%s' %d", path, key,atom_type ); + + free(key); +} + + void sample_get_property( int id, const char *key, void *dst ) { sample_runtime_data *info = (sample_runtime_data*) find_sample( id ); if(info) vevo_property_get( info->info_port, key, 0, dst ); } + +//@ only call after sample_new(), +void sample_set_user_data( void *sample, void *data, int id ) +{ + sample_runtime_data *info = (sample_runtime_data*) sample; + info->user_data = data; + sample_init_namespace( data, sample, id ); + +} + void sample_get_property_ptr( void *ptr, const char *key, void *dst ) { sample_runtime_data *info = (sample_runtime_data*) ptr; @@ -957,7 +1313,7 @@ const char *sample_describe_type( int type ) return NULL; } -static void sample_fx_entry_clean_up( void *sample, int id ) +static void sample_fx_entry_clean_up( void *sample, int id, void *user_data ) { char entry_key[KEY_LEN]; void *entry_port = NULL; @@ -970,8 +1326,12 @@ static void sample_fx_entry_clean_up( void *sample, int id ) void *instance = NULL; error = vevo_property_get( entry_port, "fx_instance",0,&instance ); if(error == VEVO_NO_ERROR ) + { + // delete OSC space + plug_clear_namespace( instance, user_data ); + plug_deactivate( instance ); - + } void *fxv = NULL; error = vevo_property_get( entry_port, "fx_values",0,&fxv ); #ifdef STRICT_CHECKING @@ -983,10 +1343,11 @@ static void sample_fx_entry_clean_up( void *sample, int id ) assert( error == VEVO_NO_ERROR ); #endif - vevo_port_free( fxv ); - vevo_port_free( fxc ); - vevo_port_free( entry_port ); +// vevo_port_free( fxv ); +// vevo_port_free( fxc ); +// vevo_port_free( entry_port ); + vevo_port_recursive_free( entry_port ); error = vevo_property_set( sample, entry_key, VEVO_ATOM_TYPE_PORTPTR, 0, NULL ); #ifdef STRICT_CHECKING @@ -995,19 +1356,24 @@ static void sample_fx_entry_clean_up( void *sample, int id ) } -static void sample_fx_clean_up( void *sample ) +static void sample_fx_clean_up( void *sample, void *user_data ) { int i; int error; for( i = 0 ; i < SAMPLE_CHAIN_LEN; i ++ ) { - sample_fx_entry_clean_up( sample,i ); + sample_fx_entry_clean_up( sample,i,user_data ); } + } static void sample_new_fx_chain_entry( void *sample, int id ) { +#ifdef STRICT_CHECKING + void *port = vevo_port_new( VEVO_FX_ENTRY_PORT,__FUNCTION__,__LINE__ ); +#else void *port = vevo_port_new( VEVO_FX_ENTRY_PORT ); +#endif char entry_key[KEY_LEN]; sprintf(entry_key, "fx_%x", id ); @@ -1016,10 +1382,20 @@ static void sample_new_fx_chain_entry( void *sample, int id ) #ifdef STRICT_CHECKING assert( error == VEVO_NO_ERROR ); #endif + double alpha = 0.0; + error = vevo_property_set( port, "fx_alpha", VEVO_ATOM_TYPE_DOUBLE,1,&alpha ); +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif +#ifdef STRICT_CHECKING + void *fx_values = vevo_port_new( VEVO_FX_VALUES_PORT, __FUNCTION__,__LINE__ ); + void *fx_channels = vevo_port_new( VEVO_ANONYMOUS_PORT, __FUNCTION__,__LINE__ ); + void *fx_out_values = vevo_port_new( VEVO_ANONYMOUS_PORT, __FUNCTION__,__LINE__ ); +#else void *fx_values = vevo_port_new( VEVO_FX_VALUES_PORT ); void *fx_channels = vevo_port_new( VEVO_ANONYMOUS_PORT ); void *fx_out_values = vevo_port_new( VEVO_ANONYMOUS_PORT ); - +#endif error = vevo_property_set( port, "fx_values", VEVO_ATOM_TYPE_PORTPTR,1,&fx_values); #ifdef STRICT_CHECKING assert( error == VEVO_NO_ERROR ); @@ -1060,7 +1436,7 @@ int sample_fx_chain_entry_clear(void *info, int id ) if( id >= 0 && id < SAMPLE_CHAIN_LEN ) { - sample_fx_entry_clean_up( sample->info_port, id ); + sample_fx_entry_clean_up( sample->info_port, id,sample->user_data ); sample_new_fx_chain_entry( sample->info_port, id ); return 1; } @@ -1078,8 +1454,11 @@ void *sample_new( int type ) rtdata->record = (samplerecord_t*) vj_malloc(sizeof(samplerecord_t)); memset(rtdata->record,0,sizeof(samplerecord_t)); rtdata->type = type; +#ifdef STRICT_CHECKING + rtdata->info_port = (void*) vevo_port_new( VEVO_SAMPLE_PORT , __FUNCTION__ , __LINE__ ); +#else rtdata->info_port = (void*) vevo_port_new( VEVO_SAMPLE_PORT ); - +#endif for(i = 0 ; common_property_list[i].name != NULL ; i ++ ) vevo_property_set( rtdata->info_port, @@ -1090,7 +1469,7 @@ void *sample_new( int type ) void *res = NULL; sit->type = type; - + if( type == VJ_TAG_TYPE_NONE ) { if( sample_new_ext( rtdata->info_port )) @@ -1108,6 +1487,163 @@ void *sample_new( int type ) return res; } +char *sample_property_format_osc( void *sample, const char *path ) +{ + sample_runtime_data *srd = (sample_runtime_data*) sample; + int n = 0; + int i = 0; + int len = strlen(path); + for( i =0; i < len ; i ++ ) + if( path[i] == '/' ) + n++; + if(n==2||n==3) + { + char *key = strip_key(path); + if( key == NULL ) + return NULL; + char *fmt = NULL; + // char *fmt = (char*) malloc( n + 1 ); + // bzero(fmt,n + 1); + + if( sample_property_is_protected( srd->info_port ,key)==1 ) + { + free(key); + return NULL; + } + + int atom_type = 0; + int n_elem = vevo_property_num_elements( srd->info_port , key ); + if(n_elem == 0 ) n_elem = 1; + + if(n==2) + atom_type = vevo_property_atom_type( srd->info_port, key ); + else + { + void *port = NULL; + int id = 0; + char *pk = strip_port(path); + int error = vevo_property_get( srd->info_port, pk, 0, &port ); + if( port ) + { + atom_type = vevo_property_atom_type( port , key ); + n_elem = vevo_property_num_elements( port , key ); + if(n_elem == 0 ) n_elem = 1; + fmt = (char*) malloc( n_elem + 1); + bzero(fmt,n_elem+1); + } + if(pk) + free(pk); + if( port ) + { + if( sample_property_is_protected( port ,key)==1 ) + { + if(fmt) free(fmt); + if(key)free(key); + return NULL; + } + + } + } + + if(!fmt) + { + fmt = (char*) malloc( n_elem + 1 ); + bzero(fmt,n_elem+1); + } + + for( i = 0; i < n_elem ; i ++ ) + { + if( atom_type == VEVO_ATOM_TYPE_DOUBLE ) { + fmt[i] = 'd'; + } else if (atom_type == VEVO_ATOM_TYPE_INT ) { + fmt[i] = 'i'; + } else if (atom_type == VEVO_ATOM_TYPE_UINT64 ) { + fmt[i] = 'h'; + } else if (atom_type == VEVO_ATOM_TYPE_BOOL ) { + fmt[i] = 'i'; + } else if( atom_type == VEVO_ATOM_TYPE_STRING ){ + fmt[i] = 's'; + } + else { + free(fmt); + free(key); + return NULL; + } + } + free(key); + return fmt; + } + return NULL; +} + +void sample_init_namespace( void *data, void *sample , int id ) +{ + sample_runtime_data *rtdata = (sample_runtime_data*) sample; + + char name[256]; + int error; + sprintf(name, "/sample_%d",id); + char **namespace = vevo_port_recurse_namespace( rtdata->info_port, name ); + int n = 0; + int k; +#ifdef STRICT_CHECKING + void *osc_namespace = vevo_port_new( VEVO_ANONYMOUS_PORT, __FUNCTION__ , __LINE__ ); +#else + void *osc_namespace = vevo_port_new(VEVO_ANONYMOUS_PORT); +#endif + for ( k = 0; namespace[k] != NULL ; k ++ ) + { + // sample_set_property_from_path( void *sample, const char *path, void *value ); + + char *format = sample_property_format_osc( sample, namespace[k] ); + if(format == NULL ) + { + if( vevo_property_atom_type( rtdata->info_port, namespace[k] ) == VEVO_ATOM_TYPE_PORTPTR ) + { + char **ns_entries = vevo_port_recurse_namespace(rtdata->info_port,namespace[k]); + if(ns_entries) + { + int q; + void *port = NULL; + error = vevo_property_get( rtdata->info_port, namespace[k],0,&port ); +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif + for( q = 0; ns_entries[q] != NULL ; q ++ ) + { + char *fmt = sample_property_format_osc( port, ns_entries[q] ); + vevosample_new_event( data, osc_namespace, sample,NULL, ns_entries[q], fmt, NULL,NULL, NULL,0 ); + + if(fmt) free(fmt); + free(ns_entries[q]); + } + free(ns_entries); + } + } + + } + else + { + vevosample_new_event( data, osc_namespace, sample, NULL, namespace[k], format,NULL, NULL,NULL, 0 ); + free(format); + } + free(namespace[k]); + } + free(namespace); + + + if(rtdata->type == VJ_TAG_TYPE_NONE ) + veejay_osc_add_sample_nonstream_events(data,osc_namespace,rtdata,name); + veejay_osc_add_sample_generic_events( data,osc_namespace,rtdata,name, SAMPLE_CHAIN_LEN ); + + error = vevo_property_set( + rtdata->info_port, "HOST_osc",VEVO_ATOM_TYPE_PORTPTR,1,&osc_namespace); +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif + +} + int vevo_num_devices() { return vj_unicap_num_capture_devices( unicap_data_ ); @@ -1115,7 +1651,11 @@ int vevo_num_devices() void samplebank_init() { +#ifdef STRICT_CHECKING + sample_bank_ = (void*) vevo_port_new( VEVO_SAMPLE_BANK_PORT, __FUNCTION__, __LINE__ ); +#else sample_bank_ = (void*) vevo_port_new( VEVO_SAMPLE_BANK_PORT ); +#endif #ifdef STRICT_CHECKING veejay_msg(2,"VEVO Sampler initialized. (max=%d)", SAMPLE_LIMIT ); #endif @@ -1206,10 +1746,18 @@ int samplebank_add_sample( void *sample ) #ifdef STRICT_CHECKING assert( pk > 0 ); #endif - vevo_property_set( port, "primary_key", VEVO_ATOM_TYPE_INT, 1, &pk ); - + error = vevo_property_set( port, "primary_key", VEVO_ATOM_TYPE_INT, 1, &pk ); +#ifdef STRICT_CHECKING + if(error != 0) + veejay_msg(0, "Fatal error: %d", error ); + assert( error == VEVO_NO_ERROR ); +#endif + sprintf(pri_key, "sample%04x", pk ); - vevo_property_set( sample_bank_, pri_key, VEVO_ATOM_TYPE_VOIDPTR, 1, &sample ); + error = vevo_property_set( sample_bank_, pri_key, VEVO_ATOM_TYPE_VOIDPTR, 1, &sample ); +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif num_samples_ += 1; return pk; } @@ -1359,15 +1907,15 @@ int sample_open( void *sample, const char *token, int extra_token , sample_video sit->bits = project_settings->bits; sit->bps = project_settings->bps; sit->channels = project_settings->chans; - srd->data = vj_audio_init( 16384 * 100, sit->channels, 0 ); +// srd->data = vj_audio_init( 16384 * 100, sit->channels, 0 ); sit->speed = 1; sit->end_pos = 32; sit->looptype = 1; double freq = 200.94; double amp = 5.0; - n_samples = vj_audio_gen_tone( srd->data, 0.04 , sit->rate,freq,amp ); - veejay_msg(2, "Generated tone of %d samples. Freq %2.2f. Amplitude %2.2f", n_samples,freq,amp); +// n_samples = vj_audio_gen_tone( srd->data, 0.04 , sit->rate,freq,amp ); +// veejay_msg(2, "Generated tone of %d samples. Freq %2.2f. Amplitude %2.2f", n_samples,freq,amp); uint64_t rate = (uint64_t) project_settings->rate; @@ -1743,11 +2291,11 @@ int sample_get_audio_frame( void *current_sample, void *buffer, int n_packets ) break; case VJ_TAG_TYPE_COLOR: - error = vevo_property_get( srd->info_port, "audio_spas",0,&tmp); + // error = vevo_property_get( srd->info_port, "audio_spas",0,&tmp); #ifdef STRICT_CHECKING - assert( error == VEVO_NO_ERROR ); + // assert( error == VEVO_NO_ERROR ); #endif - return vj_audio_noise_pack( srd->data, buffer , tmp, sit->bps, n_packets ); + return 0; //vj_audio_noise_pack( srd->data, buffer , tmp, sit->bps, n_packets ); break; default: @@ -1756,8 +2304,9 @@ int sample_get_audio_frame( void *current_sample, void *buffer, int n_packets ) } return 0; } -int sample_get_frame( void *current_sample , VJFrame *slot ) +int sample_get_frame( void *current_sample , void *dslot ) { + VJFrame *slot = (VJFrame*) dslot; sample_runtime_data *srd = (sample_runtime_data*) current_sample; #ifdef STRICT_CHECKING assert( srd->info ); @@ -2162,6 +2711,98 @@ veejay_msg(0, "Entry %d, Param %d, '%s'",fx_entry,p,str); return 0; } + +char *sample_describe_param( void *srd, int fx_entry, int p ) +{ + void *port = sample_get_fx_port_ptr( srd, fx_entry ); + if(port) + { + void *fx_instance = NULL; + int error = vevo_property_get( port, "fx_instance",0,&fx_instance ); + + return plug_describe_param( fx_instance, p ); + } + return NULL; +} + +static int sample_parse_param( void *fx_instance, int num, const char format[], va_list ap ) +{ + int n_elems = strlen( format ); + if( n_elems <= 0 ) + return 0; + + double *g = NULL; + int32_t *i = NULL; + char *s = NULL; + void *p = NULL; + + switch(format[0]) + { + case 'd': + i = (int32_t*) malloc( sizeof(int32_t) * n_elems ); + p = &i; + break; + case 'g': + g = (double*) malloc(sizeof(double) * n_elems ); + p = &g; + break; + case 's': + s = NULL; + p = &s; + break; + default: +#ifdef STRICT_CHECKING + assert(0); +#endif + break; + } + + while(*format) + { + switch(*format) + { + case 'd': + *i++ = (int32_t) *(va_arg( ap, int32_t*)); break; + case 'g': + *g++ = (double) *(va_arg( ap, double*)); break; + case 's': + s = strdup( (char*) va_arg(ap,char*) ); break; + default: + break; + } + *format++; + } + + plug_set_parameter( fx_instance, num,n_elems, p ); + + + if( i ) free( i ); + if( g ) free( g ); + if( s ) free( s ); + + return n_elems; +} + +int sample_set_param( void *srd, int fx_entry, int p, const char format[] , ... ) +{ + va_list ap; + int n = 0; + + void *port = sample_get_fx_port_ptr( srd, fx_entry ); + if(!port) + return n; + + void *fx_instance = NULL; + int error = vevo_property_get( port, "fx_instance",0,&fx_instance ); + if( error != VEVO_NO_ERROR ) + return n; + + va_start( ap, format ); + n = sample_parse_param( fx_instance, p , format, ap ); + va_end(ap); + + return n; +} void sample_process_fx_chain( void *srd ) { int k = 0; @@ -2170,7 +2811,7 @@ void sample_process_fx_chain( void *srd ) { void *port = sample_get_fx_port_ptr( srd, k ); void *fx_instance = NULL; - int fx_status = 0; + /* int fx_status = 0; int error = vevo_property_get( port, "fx_status", 0, &fx_status); #ifdef STRICT_CHECKING @@ -2180,8 +2821,8 @@ void sample_process_fx_chain( void *srd ) //@TODO: Alpha fading if( fx_status ) - { - error = vevo_property_get( port, "fx_instance", 0, &fx_instance ); + {*/ + int error = vevo_property_get( port, "fx_instance", 0, &fx_instance ); #ifdef STRICT_CHECKING assert( error == 0 ); #endif @@ -2193,7 +2834,7 @@ void sample_process_fx_chain( void *srd ) assert( error == 0 ); #endif plug_clone_from_parameters( fx_instance, fx_values ); - } + // } } } @@ -2580,8 +3221,7 @@ static long sample_tc_to_frames( const char *tc, float fps ) return res; } -int sample_configure_recorder( void *sample, int format, const char *filename, int nframes, - sample_video_info_t *ps) +int sample_configure_recorder( void *sample, int format, const char *filename, int nframes) { char fmt = 'Y'; //default uncompressed format int max_size = 0; @@ -2589,7 +3229,7 @@ int sample_configure_recorder( void *sample, int format, const char *filename, i sample_runtime_data *srd = (sample_runtime_data*) sample; sampleinfo_t *sit = srd->info; samplerecord_t *rec = srd->record; - + sample_video_info_t *ps = veejay_get_ps( srd->user_data ); if( !filename ) { veejay_msg(VEEJAY_MSG_ERROR, "No filename given"); @@ -2694,10 +3334,11 @@ int sample_configure_recorder( void *sample, int format, const char *filename, i return VEVO_NO_ERROR; } -int sample_start_recorder( void *sample , sample_video_info_t *ps) +int sample_start_recorder( void *sample ) { sample_runtime_data *srd = (sample_runtime_data*) sample; samplerecord_t *rec = srd->record; + sample_video_info_t *ps = veejay_get_ps( srd->user_data ); if(!rec->con) { @@ -2789,8 +3430,9 @@ int sample_stop_recorder( void *sample ) } -int sample_record_frame( void *sample, VJFrame *frame, uint8_t *audio_buffer, int a_len ) +int sample_record_frame( void *sample, void *dframe, uint8_t *audio_buffer, int a_len ) { + VJFrame *frame = (VJFrame*) dframe; sample_runtime_data *srd = (sample_runtime_data*) sample; samplerecord_t *rec = srd->record; sampleinfo_t *sit = srd->info; @@ -3037,7 +3679,8 @@ void sample_send_osc_path( void *sample, void *fx_entry ) int error = vevo_property_get( fx_entry, "fx_out_values",0,&fx_out_values ); #ifdef STRICT_CHECKING - assert( error == VEVO_NO_ERROR ); + assert( error == VEVO_NO_ERROR ); + assert( srd->osc != NULL ); #endif if( osc_path ) diff --git a/veejay-ng/vevosample/vevosample.h b/veejay-ng/vevosample/vevosample.h index c7fb84c3..b836869b 100644 --- a/veejay-ng/vevosample/vevosample.h +++ b/veejay-ng/vevosample/vevosample.h @@ -18,7 +18,7 @@ */ #ifndef VEVOSAMPLE_H #define VEVOSAMPLE_H -#define SAMPLE_CHAIN_LEN 2 +#define SAMPLE_CHAIN_LEN 5 typedef struct { int w; @@ -44,13 +44,13 @@ void samplebank_free(); int samplebank_size(); void sample_delete_ptr(void *info); int sample_delete(int id); -void sample_set_property_ptr( void *ptr, const char *key, int atom_type, void *value ); +int sample_set_property_ptr( void *ptr, const char *key, int atom_type, void *value ); void sample_set_property( int sample_id, const char *key, int atom_type, void *value ); void sample_get_property( int sample_id, const char *key, void *dst ); void *sample_new( int type ); void sample_free(int sample_id); int sample_open( void *sample, const char *token, int extra_token, sample_video_info_t *settings ); -int sample_get_frame( void *current_sample, VJFrame *slot ); +int sample_get_frame( void *current_sample, void *slot ); void sample_fx_set_parameter( int id, int fx_entry, int param_id,int n, void *data ); void sample_fx_get_parameter( int id, int fx_enty,int param_id,int idx, void *dst ); void sample_toggle_process_entry( void *data, int fx_entry, int v ); @@ -60,9 +60,8 @@ int sample_get_fx_alpha( void *data, int fx_entry ); void sample_set_fx_alpha( void *data, int fx_entry, int v ); void sample_set_itu601( void *current_sample, int status ); int sample_fx_set( void *info, int fx_entry, const int new_fx ); -void sample_set_input_frame( void *info, int fx_entry, int seq_num, VJFrame *frame ); void sample_process_fx_chain( void *srd ); -int sample_fx_del( int id, int fx_entry ); +int sample_fx_del( void *veejay, int id, int fx_entry ); int sample_xml_load( const char *filename, void *samplebank ); int samplebank_xml_save( const char *filename ); void *sample_get_fx_port( int id, int fx_entry ); @@ -97,16 +96,30 @@ int sample_get_key_ptr( void *sample ); int sample_edl_delete( void *current_sample, uint64_t start, uint64_t end ); int sample_edl_paste_from_buffer( void *current_sample, uint64_t insert_at ); int sample_edl_cut_to_buffer( void *current_sample, uint64_t start_pos, uint64_t end_pos ); -int sample_configure_recorder( void *sample, int format, const char *filename, int nframes, sample_video_info_t *ps ); -int sample_start_recorder( void *sample, sample_video_info_t *ps ); +int sample_configure_recorder( void *sample, int format, const char *filename, int nframes ); +int sample_start_recorder( void *sample ); int sample_stop_recorder( void *sample ); -int sample_record_frame( void *sample, VJFrame *frame, uint8_t *audio_buffer, int a_len ); +int sample_record_frame( void *sample, void *frame, uint8_t *audio_buffer, int a_len ); char *sample_get_recorded_file( void *sample ); - int sample_new_osc_sender(void *sample, const char *addr, const char *port ); void sample_close_osc_sender( void *sample ); void sample_add_osc_path( void *sample, const char *path, int fx_entry_id ); void sample_del_osc_path( void *sample, int fx_entry_id ); void sample_send_osc_path( void *sample, void *fx_entry ); +char *sample_describe_param( void *srd, int fx_entry, int p ); +int sample_set_param( void *srd, int fx_entry, int p, const char format[] , ... ); +void sample_set_user_data( void *sample, void *data, int id ); +void sample_set_property_from_path( void *sample, const char *path, void *value ); +char *sample_property_format_osc( void *sample, const char *path ); +void sample_init_namespace( void *data, void *sample , int id ); +int sample_osc_property_calls_event( void *sample, const char *path, char *types, void **argv[] ); + +typedef void (*vevo_event_f)(void *ptr, const char *path,const char *types, void **argv); +int sample_osc_new_sample_event( void *sample, + const char *key, + const char *fmt, + const char **args, + vevo_event_f *func ); +int sample_osc_verify_format( void *vevo_port, char const *types ); #endif diff --git a/veejay-ng/vevosample/vj-unicap.c b/veejay-ng/vevosample/vj-unicap.c index 468d7a73..0d5e2ca5 100644 --- a/veejay-ng/vevosample/vj-unicap.c +++ b/veejay-ng/vevosample/vj-unicap.c @@ -86,9 +86,13 @@ static int vj_unicap_scan_enumerate_devices(void *unicap) unicap_reenumerate_properties( ud->handle, &property_count ); unicap_reenumerate_formats( ud->handle, &format_count ); - void *device_port = vevo_port_new( VEVO_ANONYMOUS_PORT ); - char *device_name = strdup( ud->device.identifier ); + +#ifdef STRICT_CHECKING + void *device_port = vevo_port_new( VEVO_ANONYMOUS_PORT, device_name, i ); +#else + void *device_port = vevo_port_new( VEVO_ANONYMOUS_PORT ); +#endif char *device_location = strdup( ud->device.device ); int error = vevo_property_set( device_port, @@ -132,8 +136,11 @@ void *vj_unicap_init(void) { unicap_driver_t *ud = (unicap_driver_t*) vj_malloc(sizeof(unicap_driver_t)); memset( ud,0,sizeof(unicap_driver_t)); +#ifdef STRICT_CHECKING + ud->device_list = vevo_port_new( VEVO_ANONYMOUS_PORT, __FUNCTION__, __LINE__ ); +#else ud->device_list = vevo_port_new( VEVO_ANONYMOUS_PORT ); - +#endif ud->num_devices = vj_unicap_scan_enumerate_devices( (void*) ud ); veejay_msg(2, "Found %d capture devices on this system", ud->num_devices); return ud;