static void v_cycleActor (int prev) { const char *name; name = prev ? visual_actor_get_prev_by_name(actor_name.c_str()) : visual_actor_get_next_by_name(actor_name.c_str()); if (!name) { name = prev ? visual_actor_get_prev_by_name(0) : visual_actor_get_next_by_name(0); } actor_name = name; }
static void init( int &argc, char **&argv ) { VisVideoDepth depth; visual_init( &argc, &argv ); bin = visual_bin_new (); depth = visual_video_depth_enum_from_value( 24 ); if( !plugin ) plugin = visual_actor_get_next_by_name( 0 ); if( !plugin ) exit( "Actor plugin not found!" ); visual_bin_set_supported_depth( bin, VISUAL_VIDEO_DEPTH_ALL ); if( NULL == (video = visual_video_new()) ) exit( "Cannot create a video surface" ); if( visual_video_set_depth( video, depth ) < 0 ) exit( "Cannot set video depth" ); visual_video_set_dimension( video, 320, 200 ); if( visual_bin_set_video( bin, video ) ) exit( "Cannot set video" ); visual_bin_connect_by_names( bin, (char*)plugin, 0 ); if( visual_bin_get_depth( bin ) == VISUAL_VIDEO_DEPTH_GL ) { visual_video_set_depth( video, VISUAL_VIDEO_DEPTH_GL ); pluginIsGL = true; } SDL::create( 320, 200 ); SDL_WM_SetCaption( plugin, 0 ); /* Called so the flag is set to false, seen we create the initial environment here */ visual_bin_depth_changed( bin ); VisInput *input = visual_bin_get_input( bin ); if( visual_input_set_callback( input, upload_callback, NULL ) < 0 ) exit( "Cannot set input plugin callback" ); visual_bin_switch_set_style( bin, VISUAL_SWITCH_STYLE_MORPH ); visual_bin_switch_set_automatic( bin, true ); visual_bin_switch_set_steps( bin, 100 ); visual_bin_realize( bin ); visual_bin_sync( bin, false ); std::cout << "[PANA] Libvisual version " << visual_get_version() << '\n'; std::cout << "[PANA] bpp: " << video->bpp << std::endl; std::cout << "[PANA] GL: " << (pluginIsGL ? "true\n" : "false\n"); }
int main( int argc, char** argv ) { if( argc <= 1 || std::strcmp( argv[1], "--list" ) == 0 ) { visual_init( &argc, &argv ); #if 0 VisList *list = visual_actor_get_list(); for( VisListEntry *entry = list->head->next; entry != list->tail; entry = entry->next ) { VisPluginInfo *info = static_cast<VisActor*>(entry->data)->plugin->ref->info; std::cout << info->name << '|' << info->about << std::endl; } #endif const char *plugin = 0; while( (plugin = visual_actor_get_next_by_name( plugin )) ) std::cout << plugin << '\n'; std::exit( 0 ); } else if( argc == 3 ) Vis::plugin = argv[2]; //connect to socket const int sockfd = tryConnect( argv[1] ); //register fd/pid combo with Pana { pid_t pid = ::getpid(); char buf[32] = "REG"; *(pid_t*)&buf[4] = pid; ::send( sockfd, buf, 4 + sizeof(pid_t), 0 ); } //init SDL::init(); Vis::init( argc, argv ); //main loop // 1. we sleep for a bit, listening for messages from Pana // 2. render a frame timeval tv; fd_set fds; int nbytes = 0; uint render_time = 0; while( nbytes != -1 && SDL::event_handler() ) { //set the time to wait tv.tv_sec = 0; tv.tv_usec = render_time > 16 ? 0 : (16 - render_time) * 1000; //60Hz //get select to watch the right file descriptor FD_ZERO( &fds ); FD_SET( sockfd, &fds ); ::select( sockfd+1, &fds, 0, 0, &tv ); if( FD_ISSET( sockfd, &fds) ) { //Pana sent us some data char command[16]; ::recv( sockfd, command, 16, 0 ); if( std::strcmp( command, "fullscreen" ) == 0 ) SDL::toggleFullScreen(); } //request pcm data ::send( sockfd, "PCM", 4, 0 ); nbytes = ::recv( sockfd, Vis::pcm_data, 1024 * sizeof( int16_t ), 0 ); render_time = LibVisual::render(); } ::close( sockfd ); return 0; }
bg_plugin_info_t * bg_lv_get_info(const char * filename) { int i; VisVideoAttributeOptions *vidoptions; bg_x11_window_t * win; bg_plugin_info_t * ret; VisPluginRef * ref; VisList * list; VisActor * actor; VisPluginInfo * info; char * tmp_string; const char * actor_name = NULL; check_init(); list = visual_plugin_get_registry(); /* Find out if there is a plugin matching the filename */ while((actor_name = visual_actor_get_next_by_name(actor_name))) { ref = visual_plugin_find(list, actor_name); if(ref && !strcmp(ref->file, filename)) break; } if(!actor_name) return NULL; actor = visual_actor_new(actor_name); if(!actor) return NULL; ret = calloc(1, sizeof(*ret)); info = visual_plugin_get_info(visual_actor_get_plugin(actor)); ret->name = bg_sprintf("vis_lv_%s", actor_name); ret->long_name = gavl_strdup(info->name); ret->type = BG_PLUGIN_VISUALIZATION; ret->api = BG_PLUGIN_API_LV; ret->description = bg_sprintf(TR("libvisual plugin")); ret->module_filename = gavl_strdup(filename); /* Optional info */ if(info->author && *info->author) { tmp_string = bg_sprintf(TR("\nAuthor: %s"), info->author); ret->description = gavl_strcat(ret->description, tmp_string); free(tmp_string); } if(info->version && *info->version) { tmp_string = bg_sprintf(TR("\nVersion: %s"), info->version); ret->description = gavl_strcat(ret->description, tmp_string); free(tmp_string); } if(info->about && *info->about) { tmp_string = bg_sprintf(TR("\nAbout: %s"), info->about); ret->description = gavl_strcat(ret->description, tmp_string); free(tmp_string); } if(info->help && *info->help) { tmp_string = bg_sprintf(TR("\nHelp: %s"), info->help); ret->description = gavl_strcat(ret->description, tmp_string); free(tmp_string); } if(info->license && *info->license) { tmp_string = bg_sprintf(TR("\nLicense: %s"), info->license); ret->description = gavl_strcat(ret->description, tmp_string); free(tmp_string); } /* Check out if it's an OpenGL plugin */ if(visual_actor_get_supported_depth(actor) & VISUAL_VIDEO_DEPTH_GL) { ret->flags |= BG_PLUGIN_VISUALIZE_GL; win = bg_x11_window_create(NULL); /* Create an OpenGL context. For this, we need the OpenGL attributes */ vidoptions = visual_actor_get_video_attribute_options(actor); for(i = 0; i < VISUAL_GL_ATTRIBUTE_LAST; i++) { if((vidoptions->gl_attributes[i].mutated) && (bg_attributes[i] >= 0)) { bg_x11_window_set_gl_attribute(win, bg_attributes[i], vidoptions->gl_attributes[i].value); } } /* Set bogus dimensions, will be corrected by the size_callback */ bg_x11_window_set_size(win, 640, 480); bg_x11_window_realize(win); if(!bg_x11_window_start_gl(win)) { ret->flags |= BG_PLUGIN_UNSUPPORTED; } else bg_x11_window_set_gl(win); } else { ret->flags |= BG_PLUGIN_VISUALIZE_FRAME; win = NULL; } ret->priority = 1; /* Must realize the actor to get the parameters */ if(!(ret->flags & BG_PLUGIN_UNSUPPORTED)) { visual_actor_realize(actor); ret->parameters = create_parameters(actor, NULL, NULL); visual_object_unref(VISUAL_OBJECT(actor)); } if(win) { bg_x11_window_unset_gl(win); bg_x11_window_stop_gl(win); bg_x11_window_destroy(win); } return ret; }