From: Dennis S. <sy...@yo...> - 2004-04-16 14:08:56
|
Well, 0.1 pre3 seems to work quite well this far, however people please test and report on the list ;)! Gustavo can compile goom2. JC, this was because there was a space in his build path, not sure why that bugs but everything is auto generated so i can't do something about that, atleast not that i know off. I think it's time to explain the basics about the application API. This is especially for Gustavo who is going to make python bindings and freevo support. _____ Basic application api summary: Libvisual consists (at this moment) of two 'stacks'. That is the 'actor' (visual plugin) stack and the 'input' (pcm data plugin) stack. The actor consists out of VisActorPlugin which is completely abstracted in an VisActor. The VisActor type is the high end application type for an actor. To run an actor on screen you'll also need an VisVideo which holds data like, width, height, bpp, pointer to screenbuffer, depth. The input consists out of VisInputPlugin which is also completely abstracted in VisInput. The VisInput type is the high end application type for an input plugin. To process audio data you'll also need an VisAudio which holds the pcm data, fft analyzer data, and some more stuff like audio energy, in the future it'll contain more audio analyse data. To automaticly pump input data to the actor and run both input plugin and actor plugin you'll need an VisBin. A VisBin is an container to pack the actor and input in. API that is needed for an basic app: VisActor *actor; /* The actor type */ VisVideo *video; /* The video information type */ VisList *actlist; /* The actor plugin list */ VisPalette *pal = NULL; /* Palette for 8 bits mode */ VisInput *input; /* The input type */ VisList *inlist; /* The input plugin list */ VisBin *bin; /* The container type */ ____ int depth; int bpp; Create an actor plugin: /* give plugin path or NULL for default * The actlist should not be destroyed before termination * of the render pipe, this is because the list contains * the references to the plugins and the ref count */ actlist = visual_actor_get_list (NULL); /* Load the goom visual into the actor */ actor = visual_actor_new (actlist, "goom"); /* Goom couldn't be loaded */ if (actor->plugin == NULL) exit (-1); /* Get the highest supported depth by the plugin */ depth = visual_actor_depth_get_highest (actor); /* init video before visual_actor_realize * this is so opengl plugins can do opengl * init magic in their plugin init function */ /* startup the plugin */ visual_actor_realize (actor); /* Create a new video context information holder */ video = visual_video_new (); /* Link it to the actor */ visual_actor_set_video (actor, video); /* Set the depth on the video context */ visual_video_set_opts (video, "depth", depth); /* Set the size on the video context, * WARNING: The api for this will change in 0.2 */ visual_video_set_dimension (video, width, height); /* Negotiate the actor and video, if needed it'll set up * depth transformation, size transformation here * Size nego is broken in pre3 tho, so you're warned about that */ if (visual_actor_video_negotiate (actor) == -1) exit (-1); /* It's now time to allocate a buffer for the plugin to draw in */ bpp = visual_video_bpp_from_enum (depth); /* you can also use video->bpp btw */ scrbuf = malloc (video->size * bpp); memset (scrbuf, 0, video->size * bpp); /* Connect the buffer to the video */ visual_video_set_buffer (video, scrbuf); /* Get the input plugin list, same goes for actor, don't free * the list till destroying all your render stuff */ inlist = visual_input_get_list (NULL); /* Create the input plugin */ input = visual_input_new (inlist, "esd"); /* Create an container */ bin = visual_bin_new (); /* Pack the actor and input in the container */ visual_bin_connect (bin, actor, input); /* Realize the bin and it's childeren, all that already * is realized won't be realized again */ visual_bin_realize (bin); /* remember for opengl you need a special case, check * libvisual-0.1/examples/simplesdl.c how this works */ while (render_eyecandy) { /* Run the pipeline */ visual_bin_run (bin); /* Retrieve palette info */ pal = visual_actor_get_pal (actor); if (pal != NULL) /* Use your own function here to * set the pal for your screen target * pals can be accessed by: * pal->r[0..255], ->g[0..255], b->[0..255] */ set_pal (pal); /* Your own function that draws on your screen target * the image buffer is in video->screenbuffer */ draw_screen (video); } On resize: visual_video_set_dimension (video, width, height); visual_actor_video_negotiate (actor); /* Free and malloc the buffer as done on the initialize. */ ... /* And add the new buffer */ visual_video_set_buffer (video, scrbuf); On exit: /* Destroy the bin, and it's childeren */ visual_bin_destroy (bin); /* free the video, you can use visual_video_free_with_buffer * to free the screenbuffer as well */ visual_video_free (video); /* Destroy the plugin, and reference lists */ visual_actor_list_destroy (actlist); visual_input_list_destroy (inlist); List of actor plugins: ___ VisPluginRef *ref; VisList *list; VisListEntry *entry = NULL; list = visual_actor_get_list (NULL); while ((ref = visual_list_next (list, &entry)) != NULL) { printf ("Plugin ref: %s %s %d\n", ref->file, ref->name, ref->usecount); } ___ There is also an API to get more info from the plugin like, author, about, help but the api is not yet set in stone so wait till 0.2 for that ;) I hope the explanation is kinda clear, but if there are any questions just shoot, i'll be glad to answer. Also if there are comments on the API, things that are rather seen differently, please comment as well! Cheers, Dennis |