r1009: Move the dependencies to newer package names
[cinelerra_cv/mob.git] / cinelerra / pluginserver.h
blobee7a11de1dd1eebddf0b816a995376522ed4076c
1 #ifndef PLUGINSERVER_H
2 #define PLUGINSERVER_H
4 // inherited by plugins
7 #include "arraylist.h"
8 #include "attachmentpoint.inc"
9 #include "edl.inc"
10 #include "floatauto.inc"
11 #include "floatautos.inc"
12 #include "keyframe.inc"
13 #include "ladspa.h"
14 #include "mainprogress.inc"
15 #include "maxbuffers.h"
16 #include "menueffects.inc"
17 #include "module.inc"
18 #include "mwindow.inc"
19 #include "plugin.inc"
20 #include "pluginaclientlad.inc"
21 #include "pluginclient.inc"
22 #include "pluginserver.inc"
23 #include "preferences.inc"
24 #include "theme.inc"
25 #include "thread.h"
26 #include "track.inc"
27 #include "vframe.inc"
28 #include "videodevice.inc"
29 #include "virtualnode.inc"
31 #include <stdio.h>
32 #include <stdint.h>
33 #include <string.h>
34 #include <unistd.h>
40 class PluginServer
42 public:
43 PluginServer();
44 PluginServer(char *path);
45 PluginServer(PluginServer &);
46 virtual ~PluginServer();
49 friend class PluginAClientLAD;
50 friend class PluginAClientConfig;
51 friend class PluginAClientWindow;
53 // open a plugin and wait for commands
54 // Get information for plugindb if master.
55 #define PLUGINSERVER_IS_LAD 2
56 #define PLUGINSERVER_NOT_RECOGNIZED 1
57 #define PLUGINSERVER_OK 0
58 int open_plugin(int master,
59 Preferences *preferences,
60 EDL *edl,
61 Plugin *plugin,
62 int lad_index /* = -1 */);
63 // close the plugin
64 int close_plugin();
65 void dump();
66 // Release any objects which are required after playback stops.
67 void render_stop();
69 // queries
70 void set_title(char *string);
71 // Generate title for display
72 void generate_display_title(char *string);
73 // Get keyframes for configuration. Position is always relative to EDL rate.
74 KeyFrame* get_prev_keyframe(int64_t position);
75 KeyFrame* get_next_keyframe(int64_t position);
76 // get camera and projector positions
77 void get_camera(float *x, float *y, float *z,
78 int64_t position, int direction);
79 void get_projector(float *x, float *y, float *z,
80 int64_t position, int direction);
81 // Get interpolation used by EDL
82 int get_interpolation_type();
83 // Get or create keyframe for writing, depending on whether auto keyframes
84 // is enabled. Called by PluginClient::send_configure_change
85 KeyFrame* get_keyframe();
86 // Create new theme object. Used by theme plugins.
87 Theme* new_theme();
88 // Get theme being used by Cinelerra currently. Used by all plugins.
89 Theme* get_theme();
94 // =============================== for realtime plugins
95 // save configuration of plugin
96 void save_data(KeyFrame *keyframe);
97 // Update EDL and playback engines to reflect changes
98 void sync_parameters();
99 // set for realtime processor usage
100 int set_realtime_sched();
101 int get_gui_status();
102 // Raise the GUI
103 void raise_window();
104 // cause the plugin to show the GUI
105 // Called by MWindow::show_plugin
106 void show_gui();
107 // Update GUI with keyframe settings
108 void update_gui();
109 void update_title();
110 void client_side_close();
111 // Set to 1 before every process call if the user supports OpenGL buffers.
112 // Also provides the driver location.
113 void set_use_opengl(int value, VideoDevice *vdevice);
114 // Plugin must call this before performing OpenGL operations.
115 int get_use_opengl();
117 // Called from plugin client
118 // Returns 1 if a GUI is open so OpenGL routines can determine if
119 // they can run.
120 int gui_open();
122 // Called by plugin client to request synchronous routine.
123 void run_opengl(PluginClient *plugin_client);
125 // set the string that appears on the plugin title
126 int set_string(char *string);
127 // give the buffers and sizes and prepare processing realtime data
128 int init_realtime(int realtime_sched,
129 int total_in_buffers,
130 int buffer_size);
131 // process the data in the buffers
132 // input - the current edit's data
133 // output - the previous edit's data and the destination of the transition output
134 // current_position - Position from start of the transition and
135 // relative to the transition.
136 // total_len - total len for transition
137 void process_transition(VFrame *input,
138 VFrame *output,
139 int64_t current_position,
140 int64_t total_len);
141 void process_transition(double *input,
142 double *output,
143 int64_t current_position,
144 int64_t fragment_size,
145 int64_t total_len);
147 // Process using pull method.
148 // current_position - start of region if forward, end of region if reverse
149 // relative to requested rate
150 // fragment_size - amount of data to put in buffer relative to requested rate
151 // sample_rate - sample rate of requested output
152 // frame_rate - frame rate of requested output
153 // total_len - length of plugin in track units relative to the EDL rate
154 // Units are kept relative to the EDL rate so plugins don't need to convert rates
155 // to get the keyframes.
156 void process_buffer(VFrame **frame,
157 int64_t current_position,
158 double frame_rate,
159 int64_t total_len,
160 int direction);
161 void process_buffer(double **buffer,
162 int64_t current_position,
163 int64_t fragment_size,
164 int64_t sample_rate,
165 int64_t total_len,
166 int direction);
168 // Called by rendering client to cause the GUI to display something with the data.
169 void send_render_gui(void *data);
170 void send_render_gui(void *data, int size);
171 // Called by MWindow to cause GUI to display
172 void render_gui(void *data);
173 void render_gui(void *data, int size);
175 // Send the boundary autos of the next fragment
176 int set_automation(FloatAutos *autos, FloatAuto **start_auto, FloatAuto **end_auto, int reverse);
180 // set the fragment position of a buffer before rendering
181 int arm_buffer(int buffer_number,
182 int64_t in_fragment_position,
183 int64_t out_fragment_position,
184 int double_buffer_in,
185 int double_buffer_out);
186 // Detach all the shared buffers.
187 int detach_buffers();
189 int send_buffer_info();
197 // ============================ for non realtime plugins
198 // start processing data in plugin
199 int start_loop(int64_t start, int64_t end, int64_t buffer_size, int total_buffers);
200 // Do one iteration of a nonrealtime plugin and return if finished
201 int process_loop(VFrame **buffers, int64_t &write_length);
202 int process_loop(double **buffers, int64_t &write_length);
203 int stop_loop();
206 // Called by client to read data in non-realtime effect
207 int read_frame(VFrame *buffer,
208 int channel,
209 int64_t start_position);
210 int read_samples(double *buffer,
211 int channel,
212 int64_t start_position,
213 int64_t total_samples);
216 // Called by client to read data in realtime effect.
217 // Returns -1 if error or 0 if success.
218 int read_frame(VFrame *buffer,
219 int channel,
220 int64_t start_position,
221 double frame_rate,
222 // Set to 1 if the reader can use OpenGL objects.
223 int use_opengl = 0);
224 int read_samples(double *buffer,
225 int channel,
226 int64_t sample_rate,
227 int64_t start_position,
228 int64_t len);
230 // For non realtime, prompt user for parameters, waits for plugin to finish and returns a result
231 int get_parameters(int64_t start, int64_t end, int channels);
232 int get_samplerate(); // get samplerate produced by plugin
233 double get_framerate(); // get framerate produced by plugin
234 int get_project_samplerate(); // get samplerate of project data before processing
235 double get_project_framerate(); // get framerate of project data before processing
236 int set_path(char *path); // required first
237 // Used by PluginArray and MenuEffects to get user parameters and progress bar.
238 // Set pointer to mwindow for opening GUI and reconfiguring EDL.
239 void set_mwindow(MWindow *mwindow);
240 // Used in VirtualConsole
241 // Set pointer to AttachmentPoint to render GUI.
242 void set_attachmentpoint(AttachmentPoint *attachmentpoint);
243 // Set pointer to a default keyframe when there is no plugin
244 void set_keyframe(KeyFrame *keyframe);
245 // Set pointer to menueffect window
246 void set_prompt(MenuEffectPrompt *prompt);
247 int set_interactive(); // make this the master plugin for progress bars
248 int set_error(); // flag to send plugin an error on next request
249 MainProgressBar* start_progress(char *string, int64_t length);
251 // add track to the list of affected tracks for a non realtime plugin
252 void append_module(Module *module);
253 // add node for realtime plugin
254 void append_node(VirtualNode *node);
255 // reset node table after virtual console reconfiguration
256 void reset_nodes();
258 int64_t get_written_samples(); // after samples are written, get the number written
259 int64_t get_written_frames(); // after frames are written, get the number written
262 // buffers
263 int64_t out_buffer_size; // size of a send buffer to the plugin
264 int64_t in_buffer_size; // size of a recieve buffer from the plugin
265 int total_in_buffers;
266 int total_out_buffers;
268 // number of double buffers for each channel
269 ArrayList<int> ring_buffers_in;
270 ArrayList<int> ring_buffers_out;
271 // Parameters for automation. Setting autos to 0 disables automation.
272 FloatAuto **start_auto, **end_auto;
273 FloatAutos *autos;
274 int reverse;
276 // size of each buffer
277 ArrayList<int64_t> realtime_in_size;
278 ArrayList<int64_t> realtime_out_size;
280 // When arming buffers need to know the offsets in all the buffers and which
281 // double buffers for each channel before rendering.
282 ArrayList<int64_t> offset_in_render;
283 ArrayList<int64_t> offset_out_render;
284 ArrayList<int64_t> double_buffer_in_render;
285 ArrayList<int64_t> double_buffer_out_render;
287 // don't delete buffers if they belong to a virtual module
288 int shared_buffers;
289 // Send new buffer information for next render
290 int new_buffers;
293 int plugin_open; // Whether or not the plugin is open.
294 // Specifies what type of plugin.
295 int realtime, multichannel, fileio;
296 // Plugin generates media
297 int synthesis;
298 // What data types the plugin can handle. One of these is set.
299 int audio, video, theme;
300 // Can display a GUI
301 int uses_gui;
302 // Plugin is a transition
303 int transition;
304 // name of plugin in english.
305 // Compared against the title value in the plugin for resolving symbols.
306 char *title;
307 int64_t written_samples, written_frames;
308 char *path; // location of plugin on disk
309 char *data_text; // pointer to the data that was requested by a save_data command
310 char *args[4];
311 int total_args;
312 int error_flag; // send plugin an error code on next request
313 // Pointers to tracks affected by this plugin during a non realtime operation.
314 // Allows read functions to read data.
315 ArrayList<Module*> *modules;
316 // Used by realtime read functions to get data. Corresponds to the buffer table in the
317 // attachment point.
318 ArrayList<VirtualNode*> *nodes;
319 AttachmentPoint *attachmentpoint;
320 MWindow *mwindow;
321 // Pointer to keyframe when plugin is not available
322 KeyFrame *keyframe;
323 AttachmentPoint *attachment;
324 // Storage of keyframes and GUI status
325 Plugin *plugin;
327 // Storage of session parameters
328 EDL *edl;
329 Preferences *preferences;
330 MenuEffectPrompt *prompt;
331 int gui_on;
333 VFrame *temp_frame;
335 // Icon for Asset Window
336 VFrame *picon;
338 private:
339 int reset_parameters();
340 int cleanup_plugin();
342 // Base class created by client
343 PluginClient *client;
344 // Handle from dlopen. Plugins are opened once at startup and stored in the master
345 // plugindb.
346 void *plugin_fd;
347 // If no path, this is going to be set to a function which
348 // instantiates the plugin.
349 PluginClient* (*new_plugin)(PluginServer*);
351 // LAD support
352 int is_lad;
353 LADSPA_Descriptor_Function lad_descriptor_function;
354 const LADSPA_Descriptor *lad_descriptor;
355 int use_opengl;
356 // Driver for opengl calls.
357 VideoDevice *vdevice;
361 #endif