bool init(void) { if(!f0r_init)return false; if(!f0r_get_plugin_info)return false; if(!f0r_get_param_info)return false; if(!f0r_construct)return false; if(!f0r_destruct)return false; if(!f0r_set_param_value)return false; if(!f0r_get_param_value)return false; if(!f0r_deinit)return false; int err=0; if(f0r_init) err=f0r_init(); f0r_plugin_info_t info; f0r_get_plugin_info(&info); m_name = info.name; m_author = info.author; m_type = info.plugin_type; switch(m_type) { case (F0R_PLUGIN_TYPE_SOURCE): case (F0R_PLUGIN_TYPE_FILTER): break; default: ::error("[pix_frei0r] only supports sources/filters, no mixers!"); return false; } #ifdef __GNUC__ # warning check color type #endif m_color = info.color_model; #ifdef __GNUC__ # warning check compatibility #endif m_frei0rVersion = info.frei0r_version; m_majorVersion = info.major_version; m_minorVersion = info.minor_version; m_explanation = info.explanation; ::post("%s by %s", info.name, info.author); ::post("%d:: %s", m_type, info.explanation); if(!f0r_update)return false; // if(!f0r_update2)return false; int numparameters = info.num_params; int i=0; m_parameterNames.clear(); m_parameterTypes.clear(); m_parameter.clear(); // dummy parameter (so we start at 1) m_parameterNames.push_back(""); m_parameterTypes.push_back(0); for(i=0; i<numparameters; i++) { f0r_param_info_t pinfo; f0r_get_param_info(&pinfo, i); m_parameterNames.push_back(pinfo.name); m_parameterTypes.push_back(pinfo.type); ::post("parm%02d[%s]: %s", i+1, pinfo.name, pinfo.explanation); } return true; }
static void * load_lib( mlt_profile profile, mlt_service_type type , void* handle){ int i=0; void (*f0r_get_plugin_info)(f0r_plugin_info_t*), *f0r_construct , *f0r_update , *f0r_destruct, (*f0r_get_param_info)(f0r_param_info_t* info, int param_index), (*f0r_init)(void) , *f0r_deinit , (*f0r_set_param_value)(f0r_instance_t instance, f0r_param_t param, int param_index), (*f0r_get_param_value)(f0r_instance_t instance, f0r_param_t param, int param_index), (*f0r_update2) (f0r_instance_t instance, double time, const uint32_t* inframe1, const uint32_t* inframe2,const uint32_t* inframe3, uint32_t* outframe); if ( ( f0r_construct = dlsym(handle, "f0r_construct") ) && (f0r_update = dlsym(handle,"f0r_update") ) && (f0r_destruct = dlsym(handle,"f0r_destruct") ) && (f0r_get_plugin_info = dlsym(handle,"f0r_get_plugin_info") ) && (f0r_get_param_info = dlsym(handle,"f0r_get_param_info") ) && (f0r_set_param_value= dlsym(handle,"f0r_set_param_value" ) ) && (f0r_get_param_value= dlsym(handle,"f0r_get_param_value" ) ) && (f0r_init= dlsym(handle,"f0r_init" ) ) && (f0r_deinit= dlsym(handle,"f0r_deinit" ) ) ){ f0r_update2=dlsym(handle,"f0r_update2"); f0r_plugin_info_t info; f0r_get_plugin_info(&info); void* ret=NULL; mlt_properties properties=NULL; if (type == producer_type && info.plugin_type == F0R_PLUGIN_TYPE_SOURCE ){ mlt_producer this = mlt_producer_new( ); if ( this != NULL ) { this->get_frame = producer_get_frame; this->close = ( mlt_destructor )producer_close; f0r_init(); properties=MLT_PRODUCER_PROPERTIES ( this ); for (i=0;i<info.num_params;i++){ f0r_param_info_t pinfo; f0r_get_param_info(&pinfo,i); } ret=this; } } else if (type == filter_type && info.plugin_type == F0R_PLUGIN_TYPE_FILTER ){ mlt_filter this = mlt_filter_new( ); if ( this != NULL ) { this->process = filter_process; this->close = filter_close; f0r_init(); properties=MLT_FILTER_PROPERTIES ( this ); for (i=0;i<info.num_params;i++){ f0r_param_info_t pinfo; f0r_get_param_info(&pinfo,i); } ret=this; } }else if (type == transition_type && info.plugin_type == F0R_PLUGIN_TYPE_MIXER2){ mlt_transition transition = mlt_transition_new( ); if ( transition != NULL ) { transition->process = transition_process; transition->close = transition_close; properties=MLT_TRANSITION_PROPERTIES( transition ); mlt_properties_set_int(properties, "_transition_type", 1 ); ret=transition; } } mlt_properties_set_data(properties, "_dlclose_handle", handle , sizeof (void*) , NULL , NULL ); mlt_properties_set_data(properties, "_dlclose", dlclose , sizeof (void*) , NULL , NULL ); mlt_properties_set_data(properties, "f0r_construct", f0r_construct , sizeof(void*),NULL,NULL); mlt_properties_set_data(properties, "f0r_update", f0r_update , sizeof(void*),NULL,NULL); if (f0r_update2) mlt_properties_set_data(properties, "f0r_update2", f0r_update2 , sizeof(void*),NULL,NULL); mlt_properties_set_data(properties, "f0r_destruct", f0r_destruct , sizeof(void*),NULL,NULL); mlt_properties_set_data(properties, "f0r_get_plugin_info", f0r_get_plugin_info , sizeof(void*),NULL,NULL); mlt_properties_set_data(properties, "f0r_get_param_info", f0r_get_param_info , sizeof(void*),NULL,NULL); mlt_properties_set_data(properties, "f0r_set_param_value", f0r_set_param_value , sizeof(void*),NULL,NULL); mlt_properties_set_data(properties, "f0r_get_param_value", f0r_get_param_value , sizeof(void*),NULL,NULL); return ret; }else{ printf("some was wrong\n"); dlerror(); } return NULL; }
static void * load_lib( mlt_profile profile, mlt_service_type type , void* handle, const char *name ){ int i=0; void (*f0r_get_plugin_info)(f0r_plugin_info_t*), *f0r_construct , *f0r_update , *f0r_destruct, (*f0r_get_param_info)(f0r_param_info_t* info, int param_index), (*f0r_init)(void) , *f0r_deinit , (*f0r_set_param_value)(f0r_instance_t instance, f0r_param_t param, int param_index), (*f0r_get_param_value)(f0r_instance_t instance, f0r_param_t param, int param_index), (*f0r_update2) (f0r_instance_t instance, double time, const uint32_t* inframe1, const uint32_t* inframe2,const uint32_t* inframe3, uint32_t* outframe); if ( ( f0r_construct = dlsym(handle, "f0r_construct") ) && (f0r_destruct = dlsym(handle,"f0r_destruct") ) && (f0r_get_plugin_info = dlsym(handle,"f0r_get_plugin_info") ) && (f0r_get_param_info = dlsym(handle,"f0r_get_param_info") ) && (f0r_set_param_value= dlsym(handle,"f0r_set_param_value" ) ) && (f0r_get_param_value= dlsym(handle,"f0r_get_param_value" ) ) && (f0r_init= dlsym(handle,"f0r_init" ) ) && (f0r_deinit= dlsym(handle,"f0r_deinit" ) ) ){ f0r_update=dlsym(handle,"f0r_update"); f0r_update2=dlsym(handle,"f0r_update2"); f0r_plugin_info_t info; f0r_get_plugin_info(&info); void* ret=NULL; mlt_properties properties=NULL; char minor[12]; if (type == producer_type && info.plugin_type == F0R_PLUGIN_TYPE_SOURCE ){ mlt_producer this = mlt_producer_new( profile ); if ( this != NULL ) { this->get_frame = producer_get_frame; this->close = ( mlt_destructor )producer_close; f0r_init(); properties=MLT_PRODUCER_PROPERTIES ( this ); for (i=0;i<info.num_params;i++){ f0r_param_info_t pinfo; f0r_get_param_info(&pinfo,i); } ret=this; } } else if (type == filter_type && info.plugin_type == F0R_PLUGIN_TYPE_FILTER ){ mlt_filter this = mlt_filter_new( ); if ( this != NULL ) { this->process = filter_process; this->close = filter_close; f0r_init(); properties=MLT_FILTER_PROPERTIES ( this ); for (i=0;i<info.num_params;i++){ f0r_param_info_t pinfo; f0r_get_param_info(&pinfo,i); } ret=this; } }else if (type == transition_type && info.plugin_type == F0R_PLUGIN_TYPE_MIXER2){ mlt_transition transition = mlt_transition_new( ); if ( transition != NULL ) { transition->process = transition_process; transition->close = transition_close; properties=MLT_TRANSITION_PROPERTIES( transition ); mlt_properties_set_int(properties, "_transition_type", 1 ); ret=transition; } } check_thread_safe( properties, name ); mlt_properties_set_data(properties, "_dlclose_handle", handle , sizeof ( handle ) , NULL , NULL ); mlt_properties_set_data(properties, "_dlclose", dlclose , sizeof (void*) , NULL , NULL ); mlt_properties_set_data(properties, "f0r_construct", f0r_construct , sizeof( f0r_construct ),NULL,NULL); mlt_properties_set_data(properties, "f0r_update", f0r_update , sizeof( f0r_update ),NULL,NULL); if (f0r_update2) mlt_properties_set_data(properties, "f0r_update2", f0r_update2 , sizeof( f0r_update2 ),NULL,NULL); mlt_properties_set_data(properties, "f0r_destruct", f0r_destruct , sizeof( f0r_destruct ),NULL,NULL); mlt_properties_set_data(properties, "f0r_get_plugin_info", f0r_get_plugin_info , sizeof(void*),NULL,NULL); mlt_properties_set_data(properties, "f0r_get_param_info", f0r_get_param_info , sizeof(void*),NULL,NULL); mlt_properties_set_data(properties, "f0r_set_param_value", f0r_set_param_value , sizeof(void*),NULL,NULL); mlt_properties_set_data(properties, "f0r_get_param_value", f0r_get_param_value , sizeof(void*),NULL,NULL); // Let frei0r plugin version be serialized using same format as metadata snprintf( minor, sizeof( minor ), "%d", info.minor_version ); mlt_properties_set_double( properties, "version", info.major_version + info.minor_version / pow( 10, strlen( minor ) ) ); // Use the global param name map for backwards compatibility when // param names change and setting frei0r params by name instead of index. mlt_properties param_name_map = mlt_properties_get_data( mlt_global_properties(), "frei0r.param_name_map", NULL ); if ( param_name_map ) { // Lookup my plugin in the map param_name_map = mlt_properties_get_data( param_name_map, name, NULL ); mlt_properties_set_data( properties, "_param_name_map", param_name_map, 0, NULL, NULL ); } return ret; }else{ mlt_log_error( NULL, "frei0r plugin \"%s\" is missing a function\n", name ); dlerror(); } return NULL; }