4 // inherited by plugins
8 #include "attachmentpoint.inc"
10 #include "floatauto.inc"
11 #include "floatautos.inc"
12 #include "keyframe.inc"
14 #include "mainprogress.inc"
15 #include "maxbuffers.h"
16 #include "menueffects.inc"
18 #include "mwindow.inc"
20 #include "pluginaclientlad.inc"
21 #include "pluginclient.inc"
22 #include "pluginserver.inc"
23 #include "preferences.inc"
28 #include "videodevice.inc"
29 #include "virtualnode.inc"
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
,
62 int lad_index
/* = -1 */);
66 // Release any objects which are required after playback stops.
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.
88 // Get theme being used by Cinelerra currently. Used by all plugins.
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();
104 // cause the plugin to show the GUI
105 // Called by MWindow::show_plugin
107 // Update GUI with keyframe settings
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
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
,
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
,
139 int64_t current_position
,
141 void process_transition(double *input
,
143 int64_t current_position
,
144 int64_t fragment_size
,
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
,
161 void process_buffer(double **buffer
,
162 int64_t current_position
,
163 int64_t fragment_size
,
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
);
206 // Called by client to read data in non-realtime effect
207 int read_frame(VFrame
*buffer
,
209 int64_t start_position
);
210 int read_samples(double *buffer
,
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
,
220 int64_t start_position
,
222 // Set to 1 if the reader can use OpenGL objects.
224 int read_samples(double *buffer
,
227 int64_t start_position
,
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
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
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
;
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
289 // Send new buffer information for next render
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
298 // What data types the plugin can handle. One of these is set.
299 int audio
, video
, theme
;
302 // Plugin is a transition
304 // name of plugin in english.
305 // Compared against the title value in the plugin for resolving symbols.
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
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
318 ArrayList
<VirtualNode
*> *nodes
;
319 AttachmentPoint
*attachmentpoint
;
321 // Pointer to keyframe when plugin is not available
323 AttachmentPoint
*attachment
;
324 // Storage of keyframes and GUI status
327 // Storage of session parameters
329 Preferences
*preferences
;
330 MenuEffectPrompt
*prompt
;
335 // Icon for Asset Window
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
347 // If no path, this is going to be set to a function which
348 // instantiates the plugin.
349 PluginClient
* (*new_plugin
)(PluginServer
*);
353 LADSPA_Descriptor_Function lad_descriptor_function
;
354 const LADSPA_Descriptor
*lad_descriptor
;
356 // Driver for opengl calls.
357 VideoDevice
*vdevice
;