Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

pluginserver.h

Go to the documentation of this file.
00001 #ifndef PLUGINSERVER_H
00002 #define PLUGINSERVER_H
00003 
00004 // inherited by plugins
00005 
00006 
00007 #include "arraylist.h"
00008 #include "attachmentpoint.inc"
00009 #include "edl.inc"
00010 #include "floatauto.inc"
00011 #include "floatautos.inc"
00012 #include "keyframe.inc"
00013 #include "ladspa.h"
00014 #include "mainprogress.inc"
00015 #include "maxbuffers.h"
00016 #include "menueffects.inc"
00017 #include "module.inc"
00018 #include "mwindow.inc"
00019 #include "plugin.inc"
00020 #include "pluginaclientlad.inc"
00021 #include "pluginclient.inc"
00022 #include "pluginserver.inc"
00023 #include "preferences.inc"
00024 #include "theme.inc"
00025 #include "thread.h"
00026 #include "track.inc"
00027 #include "vframe.inc"
00028 #include "virtualnode.inc"
00029 
00030 #include <stdio.h>
00031 #include <stdint.h>
00032 #include <string.h>
00033 #include <unistd.h>
00034 
00035 
00036 
00037 
00038 
00039 class PluginServer
00040 {
00041 public:
00042         PluginServer();
00043         PluginServer(char *path);
00044         PluginServer(PluginServer &);
00045         virtual ~PluginServer();
00046 
00047 
00048         friend class PluginAClientLAD;
00049         friend class PluginAClientConfig;
00050         friend class PluginAClientWindow;
00051 
00052 // open a plugin and wait for commands
00053 // Get information for plugindb if master.
00054 #define PLUGINSERVER_IS_LAD 2
00055 #define PLUGINSERVER_NOT_RECOGNIZED 1
00056 #define PLUGINSERVER_OK 0
00057         int open_plugin(int master, 
00058                 Preferences *preferences,
00059                 EDL *edl, 
00060                 Plugin *plugin,
00061                 int lad_index /* = -1 */);
00062 // close the plugin
00063         int close_plugin();    
00064         void dump();
00065 
00066 
00067 // queries
00068         void set_title(char *string);
00069 // Generate title for display
00070         void generate_display_title(char *string);
00071 // Get keyframes for configuration.  Position is always relative to EDL rate.
00072         KeyFrame* get_prev_keyframe(int64_t position);
00073         KeyFrame* get_next_keyframe(int64_t position);
00074 // Get interpolation used by EDL
00075         int get_interpolation_type();
00076 // Get or create keyframe for writing, depending on whether auto keyframes
00077 // is enabled.  Called by PluginClient::send_configure_change
00078         KeyFrame* get_keyframe();
00079 // Create new theme object.  Used by theme plugins.
00080         Theme* new_theme();
00081 // Get theme being used by Cinelerra currently.  Used by all plugins.
00082         Theme* get_theme();
00083 
00084 
00085 
00086 
00087 // =============================== for realtime plugins
00088 // save configuration of plugin
00089         void save_data(KeyFrame *keyframe);          
00090 // Update EDL and playback engines to reflect changes
00091         void sync_parameters();
00092 // set for realtime processor usage
00093         int set_realtime_sched();
00094         int get_gui_status();
00095 // Raise the GUI
00096         void raise_window();
00097 // cause the plugin to show the GUI
00098 // Called by MWindow::show_plugin
00099         void show_gui();          
00100 // Update GUI with keyframe settings
00101         void update_gui();
00102         void update_title();
00103         void client_side_close();
00104         
00105 
00106 // set the string that appears on the plugin title
00107         int set_string(char *string);
00108 // give the buffers and sizes and prepare processing realtime data
00109         int init_realtime(int realtime_sched,
00110                 int total_in_buffers,
00111                 int buffer_size);   
00112 // process the data in the buffers
00113 // Really process_realtime replaced by pull method but still needed for transitions
00114 // input - the current edit's data
00115 // output - the previous edit's data and the destination of the transition output
00116 // current_position - Position from start of the transition and 
00117 //     relative to the transition.
00118 // total_len - total len for transition
00119         void process_transition(VFrame *input, 
00120                 VFrame *output, 
00121                 int64_t current_position,
00122                 int64_t total_len);  
00123         void process_transition(double *input, 
00124                 double *output,
00125                 int64_t current_position, 
00126                 int64_t fragment_size,
00127                 int64_t total_len);
00128 
00129 // Process using pull method.
00130 // current_position - start of region if forward, end of region if reverse
00131 //     relative to requested rate
00132 // fragment_size - amount of data to put in buffer relative to requested rate
00133 // sample_rate - sample rate of requested output
00134 // frame_rate - frame rate of requested output
00135 // total_len - length of plugin in track units relative to the EDL rate
00136 // Units are kept relative to the EDL rate so plugins don't need to convert rates
00137 // to get the keyframes.
00138         void process_buffer(VFrame **frame, 
00139                 int64_t current_position,
00140                 double frame_rate,
00141                 int64_t total_len,
00142                 int direction);
00143         void process_buffer(double **buffer,
00144                 int64_t current_position,
00145                 int64_t fragment_size,
00146                 int64_t sample_rate,
00147                 int64_t total_len,
00148                 int direction);
00149 
00150 // Called by rendering client to cause the GUI to display something with the data.
00151         void send_render_gui(void *data);
00152         void send_render_gui(void *data, int size);
00153 // Called by MWindow to cause GUI to display
00154         void render_gui(void *data);
00155         void render_gui(void *data, int size);
00156 
00157 // Send the boundary autos of the next fragment
00158         int set_automation(FloatAutos *autos, FloatAuto **start_auto, FloatAuto **end_auto, int reverse);
00159 
00160 
00161 
00162 // set the fragment position of a buffer before rendering
00163         int arm_buffer(int buffer_number, 
00164                                 int64_t in_fragment_position, 
00165                                 int64_t out_fragment_position,
00166                                 int double_buffer_in,
00167                                 int double_buffer_out);
00168 // Detach all the shared buffers.
00169         int detach_buffers();
00170 
00171         int send_buffer_info();
00172 
00173 
00174 
00175 
00176 
00177 
00178 
00179 // ============================ for non realtime plugins
00180 // start processing data in plugin
00181         int start_loop(int64_t start, int64_t end, int64_t buffer_size, int total_buffers);
00182 // Do one iteration of a nonrealtime plugin and return if finished
00183         int process_loop(VFrame **buffers, int64_t &write_length);
00184         int process_loop(double **buffers, int64_t &write_length);
00185         int stop_loop();
00186 
00187 
00188 // Called by client to read data in non-realtime effect
00189         int read_frame(VFrame *buffer, 
00190                 int channel, 
00191                 int64_t start_position);
00192         int read_samples(double *buffer, 
00193                 int channel, 
00194                 int64_t start_position, 
00195                 int64_t total_samples);
00196 
00197 
00198 // Called by client to read data in realtime effect.  Returns -1 if error or 0 
00199 // if success.
00200         int read_frame(VFrame *buffer, 
00201                 int channel, 
00202                 int64_t start_position, 
00203                 double frame_rate);
00204         int read_samples(double *buffer,
00205                 int channel,
00206                 int64_t sample_rate,
00207                 int64_t start_position, 
00208                 int64_t len);
00209 
00210 // For non realtime, prompt user for parameters, waits for plugin to finish and returns a result
00211         int get_parameters(int64_t start, int64_t end, int channels);
00212         int get_samplerate();      // get samplerate produced by plugin
00213         double get_framerate();     // get framerate produced by plugin
00214         int get_project_samplerate();            // get samplerate of project data before processing
00215         double get_project_framerate();         // get framerate of project data before processing
00216         int set_path(char *path);    // required first
00217 // Used by PluginArray and MenuEffects to get user parameters and progress bar.
00218 // Set pointer to mwindow for opening GUI and reconfiguring EDL.
00219         void set_mwindow(MWindow *mwindow);
00220 // Used in VirtualConsole
00221 // Set pointer to AttachmentPoint to render GUI.
00222         void set_attachmentpoint(AttachmentPoint *attachmentpoint);
00223 // Set pointer to a default keyframe when there is no plugin
00224         void set_keyframe(KeyFrame *keyframe);
00225 // Set pointer to menueffect window
00226         void set_prompt(MenuEffectPrompt *prompt);
00227         int set_interactive();             // make this the master plugin for progress bars
00228         int set_error();         // flag to send plugin an error on next request
00229         MainProgressBar* start_progress(char *string, int64_t length);
00230 
00231 // add track to the list of affected tracks for a non realtime plugin
00232         void append_module(Module *module);
00233 // add node for realtime plugin
00234         void append_node(VirtualNode *node);
00235 // reset node table after virtual console reconfiguration
00236         void reset_nodes();
00237 
00238         int64_t get_written_samples();   // after samples are written, get the number written
00239         int64_t get_written_frames();   // after frames are written, get the number written
00240 
00241 
00242 // buffers
00243         int64_t out_buffer_size;   // size of a send buffer to the plugin
00244         int64_t in_buffer_size;    // size of a recieve buffer from the plugin
00245         int total_in_buffers;
00246         int total_out_buffers;
00247 
00248 // number of double buffers for each channel
00249         ArrayList<int> ring_buffers_in;    
00250         ArrayList<int> ring_buffers_out;
00251 // Parameters for automation.  Setting autos to 0 disables automation.
00252         FloatAuto **start_auto, **end_auto;
00253         FloatAutos *autos;
00254         int reverse;
00255 
00256 // size of each buffer
00257         ArrayList<int64_t> realtime_in_size;
00258         ArrayList<int64_t> realtime_out_size;
00259 
00260 // When arming buffers need to know the offsets in all the buffers and which
00261 // double buffers for each channel before rendering.
00262         ArrayList<int64_t> offset_in_render;
00263         ArrayList<int64_t> offset_out_render;
00264         ArrayList<int64_t> double_buffer_in_render;
00265         ArrayList<int64_t> double_buffer_out_render;
00266 
00267 // don't delete buffers if they belong to a virtual module
00268         int shared_buffers;
00269 // Send new buffer information for next render
00270         int new_buffers;
00271 
00272 
00273         int plugin_open;                 // Whether or not the plugin is open.
00274 // Specifies what type of plugin.
00275         int realtime, multichannel, fileio;  
00276 // Plugin generates media
00277         int synthesis;
00278 // What data types the plugin can handle.  One of these is set.
00279         int audio, video, theme;
00280 // Can display a GUI
00281         int uses_gui;
00282 // Plugin is a transition
00283         int transition;
00284 // name of plugin in english.  Compared against the title value in the plugin.
00285         char *title;
00286         int64_t written_samples, written_frames;
00287         char *path;           // location of plugin on disk
00288         char *data_text;      // pointer to the data that was requested by a save_data command
00289         char *args[4];
00290         int total_args;
00291         int error_flag;      // send plugin an error code on next request
00292 // Pointers to tracks affected by this plugin during a non realtime operation.
00293 // Allows read functions to read data.
00294         ArrayList<Module*> *modules;
00295 // Used by realtime read functions to get data.  Corresponds to the buffer table in the
00296 // attachment point.
00297         ArrayList<VirtualNode*> *nodes;
00298         AttachmentPoint *attachmentpoint;
00299         MWindow *mwindow;
00300 // Pointer to keyframe when plugin is not available
00301         KeyFrame *keyframe;
00302         AttachmentPoint *attachment;
00303 // Storage of keyframes and GUI status
00304         Plugin *plugin;
00305 
00306 // Storage of session parameters
00307         EDL *edl;
00308         Preferences *preferences;
00309         MenuEffectPrompt *prompt;
00310         int gui_on;
00311 
00312         VFrame *temp_frame;
00313 
00314 // Icon for Asset Window
00315         VFrame *picon;
00316 
00317 private:
00318         int reset_parameters();
00319         int cleanup_plugin();
00320 
00321 // Base class created by client
00322         PluginClient *client;
00323 // Handle from dlopen.  Plugins are opened once at startup and stored in the master
00324 // plugindb.
00325         void *plugin_fd;
00326 // If no path, this is going to be set to a function which 
00327 // instantiates the plugin.
00328         PluginClient* (*new_plugin)(PluginServer*);
00329 
00330 // LAD support
00331         int is_lad;
00332         LADSPA_Descriptor_Function lad_descriptor_function;
00333         const LADSPA_Descriptor *lad_descriptor;
00334 };
00335 
00336 
00337 #endif

Generated on Sun Jan 8 13:38:59 2006 for Cinelerra-svn by  doxygen 1.4.4