r753: Add raise_window() commands when making various windows
[cinelerra_cv/mob.git] / cinelerra / pluginserver.h
bloba287da6cf9777577f1ef5f62424a2cfa540518b3
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 "virtualnode.inc"
30 #include <stdio.h>
31 #include <stdint.h>
32 #include <string.h>
33 #include <unistd.h>
39 class PluginServer
41 public:
42 PluginServer();
43 PluginServer(char *path);
44 PluginServer(PluginServer &);
45 virtual ~PluginServer();
48 friend class PluginAClientLAD;
49 friend class PluginAClientConfig;
50 friend class PluginAClientWindow;
52 // open a plugin and wait for commands
53 // Get information for plugindb if master.
54 #define PLUGINSERVER_IS_LAD 2
55 #define PLUGINSERVER_NOT_RECOGNIZED 1
56 #define PLUGINSERVER_OK 0
57 int open_plugin(int master,
58 Preferences *preferences,
59 EDL *edl,
60 Plugin *plugin,
61 int lad_index /* = -1 */);
62 // close the plugin
63 int close_plugin();
64 void dump();
67 // queries
68 void set_title(char *string);
69 // Generate title for display
70 void generate_display_title(char *string);
71 // Get keyframes for configuration. Position is always relative to EDL rate.
72 KeyFrame* get_prev_keyframe(int64_t position);
73 KeyFrame* get_next_keyframe(int64_t position);
74 // Get interpolation used by EDL
75 int get_interpolation_type();
76 // Get or create keyframe for writing, depending on whether auto keyframes
77 // is enabled. Called by PluginClient::send_configure_change
78 KeyFrame* get_keyframe();
79 // Create new theme object. Used by theme plugins.
80 Theme* new_theme();
81 // Get theme being used by Cinelerra currently. Used by all plugins.
82 Theme* get_theme();
87 // =============================== for realtime plugins
88 // save configuration of plugin
89 void save_data(KeyFrame *keyframe);
90 // Update EDL and playback engines to reflect changes
91 void sync_parameters();
92 // set for realtime processor usage
93 int set_realtime_sched();
94 int get_gui_status();
95 // Raise the GUI
96 void raise_window();
97 // cause the plugin to show the GUI
98 // Called by MWindow::show_plugin
99 void show_gui();
100 // Update GUI with keyframe settings
101 void update_gui();
102 void update_title();
103 void client_side_close();
106 // set the string that appears on the plugin title
107 int set_string(char *string);
108 // give the buffers and sizes and prepare processing realtime data
109 int init_realtime(int realtime_sched,
110 int total_in_buffers,
111 int buffer_size);
112 // process the data in the buffers
113 // Really process_realtime replaced by pull method but still needed for transitions
114 // input - the current edit's data
115 // output - the previous edit's data and the destination of the transition output
116 // current_position - Position from start of the transition and
117 // relative to the transition.
118 // total_len - total len for transition
119 void process_transition(VFrame *input,
120 VFrame *output,
121 int64_t current_position,
122 int64_t total_len);
123 void process_transition(double *input,
124 double *output,
125 int64_t current_position,
126 int64_t fragment_size,
127 int64_t total_len);
129 // Process using pull method.
130 // current_position - start of region if forward, end of region if reverse
131 // relative to requested rate
132 // fragment_size - amount of data to put in buffer relative to requested rate
133 // sample_rate - sample rate of requested output
134 // frame_rate - frame rate of requested output
135 // total_len - length of plugin in track units relative to the EDL rate
136 // Units are kept relative to the EDL rate so plugins don't need to convert rates
137 // to get the keyframes.
138 void process_buffer(VFrame **frame,
139 int64_t current_position,
140 double frame_rate,
141 int64_t total_len,
142 int direction);
143 void process_buffer(double **buffer,
144 int64_t current_position,
145 int64_t fragment_size,
146 int64_t sample_rate,
147 int64_t total_len,
148 int direction);
150 // Called by rendering client to cause the GUI to display something with the data.
151 void send_render_gui(void *data);
152 void send_render_gui(void *data, int size);
153 // Called by MWindow to cause GUI to display
154 void render_gui(void *data);
155 void render_gui(void *data, int size);
157 // Send the boundary autos of the next fragment
158 int set_automation(FloatAutos *autos, FloatAuto **start_auto, FloatAuto **end_auto, int reverse);
162 // set the fragment position of a buffer before rendering
163 int arm_buffer(int buffer_number,
164 int64_t in_fragment_position,
165 int64_t out_fragment_position,
166 int double_buffer_in,
167 int double_buffer_out);
168 // Detach all the shared buffers.
169 int detach_buffers();
171 int send_buffer_info();
179 // ============================ for non realtime plugins
180 // start processing data in plugin
181 int start_loop(int64_t start, int64_t end, int64_t buffer_size, int total_buffers);
182 // Do one iteration of a nonrealtime plugin and return if finished
183 int process_loop(VFrame **buffers, int64_t &write_length);
184 int process_loop(double **buffers, int64_t &write_length);
185 int stop_loop();
188 // Called by client to read data in non-realtime effect
189 int read_frame(VFrame *buffer,
190 int channel,
191 int64_t start_position);
192 int read_samples(double *buffer,
193 int channel,
194 int64_t start_position,
195 int64_t total_samples);
198 // Called by client to read data in realtime effect. Returns -1 if error or 0
199 // if success.
200 int read_frame(VFrame *buffer,
201 int channel,
202 int64_t start_position,
203 double frame_rate);
204 int read_samples(double *buffer,
205 int channel,
206 int64_t sample_rate,
207 int64_t start_position,
208 int64_t len);
210 // For non realtime, prompt user for parameters, waits for plugin to finish and returns a result
211 int get_parameters(int64_t start, int64_t end, int channels);
212 int get_samplerate(); // get samplerate produced by plugin
213 double get_framerate(); // get framerate produced by plugin
214 int get_project_samplerate(); // get samplerate of project data before processing
215 double get_project_framerate(); // get framerate of project data before processing
216 int set_path(char *path); // required first
217 // Used by PluginArray and MenuEffects to get user parameters and progress bar.
218 // Set pointer to mwindow for opening GUI and reconfiguring EDL.
219 void set_mwindow(MWindow *mwindow);
220 // Used in VirtualConsole
221 // Set pointer to AttachmentPoint to render GUI.
222 void set_attachmentpoint(AttachmentPoint *attachmentpoint);
223 // Set pointer to a default keyframe when there is no plugin
224 void set_keyframe(KeyFrame *keyframe);
225 // Set pointer to menueffect window
226 void set_prompt(MenuEffectPrompt *prompt);
227 int set_interactive(); // make this the master plugin for progress bars
228 int set_error(); // flag to send plugin an error on next request
229 MainProgressBar* start_progress(char *string, int64_t length);
231 // add track to the list of affected tracks for a non realtime plugin
232 void append_module(Module *module);
233 // add node for realtime plugin
234 void append_node(VirtualNode *node);
235 // reset node table after virtual console reconfiguration
236 void reset_nodes();
238 int64_t get_written_samples(); // after samples are written, get the number written
239 int64_t get_written_frames(); // after frames are written, get the number written
242 // buffers
243 int64_t out_buffer_size; // size of a send buffer to the plugin
244 int64_t in_buffer_size; // size of a recieve buffer from the plugin
245 int total_in_buffers;
246 int total_out_buffers;
248 // number of double buffers for each channel
249 ArrayList<int> ring_buffers_in;
250 ArrayList<int> ring_buffers_out;
251 // Parameters for automation. Setting autos to 0 disables automation.
252 FloatAuto **start_auto, **end_auto;
253 FloatAutos *autos;
254 int reverse;
256 // size of each buffer
257 ArrayList<int64_t> realtime_in_size;
258 ArrayList<int64_t> realtime_out_size;
260 // When arming buffers need to know the offsets in all the buffers and which
261 // double buffers for each channel before rendering.
262 ArrayList<int64_t> offset_in_render;
263 ArrayList<int64_t> offset_out_render;
264 ArrayList<int64_t> double_buffer_in_render;
265 ArrayList<int64_t> double_buffer_out_render;
267 // don't delete buffers if they belong to a virtual module
268 int shared_buffers;
269 // Send new buffer information for next render
270 int new_buffers;
273 int plugin_open; // Whether or not the plugin is open.
274 // Specifies what type of plugin.
275 int realtime, multichannel, fileio;
276 // Plugin generates media
277 int synthesis;
278 // What data types the plugin can handle. One of these is set.
279 int audio, video, theme;
280 // Can display a GUI
281 int uses_gui;
282 // Plugin is a transition
283 int transition;
284 // name of plugin in english. Compared against the title value in the plugin.
285 char *title;
286 int64_t written_samples, written_frames;
287 char *path; // location of plugin on disk
288 char *data_text; // pointer to the data that was requested by a save_data command
289 char *args[4];
290 int total_args;
291 int error_flag; // send plugin an error code on next request
292 // Pointers to tracks affected by this plugin during a non realtime operation.
293 // Allows read functions to read data.
294 ArrayList<Module*> *modules;
295 // Used by realtime read functions to get data. Corresponds to the buffer table in the
296 // attachment point.
297 ArrayList<VirtualNode*> *nodes;
298 AttachmentPoint *attachmentpoint;
299 MWindow *mwindow;
300 // Pointer to keyframe when plugin is not available
301 KeyFrame *keyframe;
302 AttachmentPoint *attachment;
303 // Storage of keyframes and GUI status
304 Plugin *plugin;
306 // Storage of session parameters
307 EDL *edl;
308 Preferences *preferences;
309 MenuEffectPrompt *prompt;
310 int gui_on;
312 VFrame *temp_frame;
314 // Icon for Asset Window
315 VFrame *picon;
317 private:
318 int reset_parameters();
319 int cleanup_plugin();
321 // Base class created by client
322 PluginClient *client;
323 // Handle from dlopen. Plugins are opened once at startup and stored in the master
324 // plugindb.
325 void *plugin_fd;
326 // If no path, this is going to be set to a function which
327 // instantiates the plugin.
328 PluginClient* (*new_plugin)(PluginServer*);
330 // LAD support
331 int is_lad;
332 LADSPA_Descriptor_Function lad_descriptor_function;
333 const LADSPA_Descriptor *lad_descriptor;
337 #endif