r954: Improve icons of the liveaudio and livevideo effects.
[cinelerra_cv.git] / cinelerra / pluginclient.C
blob9f9ba4438c66de4b3aada1d2000c114002a1fb3a
1 #include "bcsignals.h"
2 #include "edl.h"
3 #include "edlsession.h"
4 #include "language.h"
5 #include "localsession.h"
6 #include "mainundo.h"
7 #include "mwindow.h"
8 #include "pluginclient.h"
9 #include "pluginserver.h"
10 #include "preferences.h"
11 #include "transportque.inc"
13 #include <string.h>
15 PluginClient::PluginClient(PluginServer *server)
17         reset();
18         this->server = server;
21 PluginClient::~PluginClient()
25 int PluginClient::reset()
27         interactive = 0;
28         show_initially = 0;
29         wr = rd = 0;
30         master_gui_on = 0;
31         client_gui_on = 0;
32         realtime_priority = 0;
33         gui_string[0] = 0;
34         total_in_buffers = 0;
35         total_out_buffers = 0;
36         source_position = 0;
37         source_start = 0;
38         total_len = 0;
39         direction = PLAY_FORWARD;
44 // For realtime plugins initialize buffers
45 int PluginClient::plugin_init_realtime(int realtime_priority, 
46         int total_in_buffers,
47         int buffer_size)
50 // Get parameters for all
51         master_gui_on = get_gui_status();
55 // get parameters depending on video or audio
56         init_realtime_parameters();
58         smp = server->preferences->processors - 1;
60         this->realtime_priority = realtime_priority;
62         this->total_in_buffers = this->total_out_buffers = total_in_buffers;
64         this->out_buffer_size = this->in_buffer_size = buffer_size;
66         return 0;
69 int PluginClient::plugin_start_loop(int64_t start, 
70         int64_t end, 
71         int64_t buffer_size, 
72         int total_buffers)
74         this->source_start = start;
75         this->total_len = end - start;
76         this->start = start;
77         this->end = end;
78         this->in_buffer_size = this->out_buffer_size = buffer_size;
79         this->total_in_buffers = this->total_out_buffers = total_buffers;
80         start_loop();
81         return 0;
84 int PluginClient::plugin_process_loop()
86         return process_loop();
89 int PluginClient::plugin_stop_loop()
91         return stop_loop();
94 MainProgressBar* PluginClient::start_progress(char *string, int64_t length)
96         return server->start_progress(string, length);
101 int PluginClient::plugin_get_parameters()
103         int result = get_parameters();
104         return result;
107 // ========================= main loop
109 int PluginClient::is_multichannel() { return 0; }
110 int PluginClient::is_synthesis() { return 0; }
111 int PluginClient::is_realtime() { return 0; }
112 int PluginClient::is_fileio() { return 0; }
113 int PluginClient::delete_buffer_ptrs() { return 0; }
114 char* PluginClient::plugin_title() { return _("Untitled"); }
115 VFrame* PluginClient::new_picon() { return 0; }
116 Theme* PluginClient::new_theme() { return 0; }
121 Theme* PluginClient::get_theme()
123         return server->get_theme();
128 int PluginClient::is_audio() { return 0; }
129 int PluginClient::is_video() { return 0; }
130 int PluginClient::is_theme() { return 0; }
131 int PluginClient::uses_gui() { return 1; }
132 int PluginClient::is_transition() { return 0; }
133 int PluginClient::load_defaults() { return 0; }
134 int PluginClient::save_defaults() { return 0; }
135 int PluginClient::show_gui() { return 0; }
136 int PluginClient::set_string() { return 0; }
137 int PluginClient::get_parameters() { return 0; }
138 int PluginClient::get_samplerate() { return get_project_samplerate(); }
139 double PluginClient::get_framerate() { return get_project_framerate(); }
140 int PluginClient::init_realtime_parameters() { return 0; }
141 int PluginClient::delete_nonrealtime_parameters() { return 0; }
142 int PluginClient::start_loop() { return 0; };
143 int PluginClient::process_loop() { return 0; };
144 int PluginClient::stop_loop() { return 0; };
146 void PluginClient::set_interactive()
148         interactive = 1;
151 int64_t PluginClient::get_in_buffers(int64_t recommended_size)
153         return recommended_size;
156 int64_t PluginClient::get_out_buffers(int64_t recommended_size)
158         return recommended_size;
161 int PluginClient::get_gui_status()
163         return server->get_gui_status();
166 int PluginClient::start_plugin()
168         printf(_("No processing defined for this plugin.\n"));
169         return 0;
172 // close event from client side
173 void PluginClient::client_side_close()
175 // Last command executed
176         server->client_side_close();
179 int PluginClient::stop_gui_client()
181         if(!client_gui_on) return 0;
182         client_gui_on = 0;
183         return 0;
186 int PluginClient::get_project_samplerate()
188         return server->get_project_samplerate();
191 double PluginClient::get_project_framerate()
193         return server->get_project_framerate();
197 void PluginClient::update_display_title()
199         server->generate_display_title(gui_string);
200         set_string();
203 char* PluginClient::get_gui_string()
205         return gui_string;
209 char* PluginClient::get_path()
211         return server->path;
214 int PluginClient::set_string_client(char *string)
216         strcpy(gui_string, string);
217         set_string();
218         return 0;
222 int PluginClient::get_interpolation_type()
224         return server->get_interpolation_type();
228 float PluginClient::get_red()
230         if(server->mwindow)
231                 return server->mwindow->edl->local_session->red;
232         else
233         if(server->edl)
234                 return server->edl->local_session->red;
235         else
236                 return 0;
239 float PluginClient::get_green()
241         if(server->mwindow)
242                 return server->mwindow->edl->local_session->green;
243         else
244         if(server->edl)
245                 return server->edl->local_session->green;
246         else
247                 return 0;
250 float PluginClient::get_blue()
252         if(server->mwindow)
253                 return server->mwindow->edl->local_session->blue;
254         else
255         if(server->edl)
256                 return server->edl->local_session->blue;
257         else
258                 return 0;
263 int64_t PluginClient::get_source_position()
265         return source_position;
268 int64_t PluginClient::get_source_start()
270         return source_start;
273 int64_t PluginClient::get_total_len()
275         return total_len;
278 int PluginClient::get_direction()
280         return direction;
284 int64_t PluginClient::local_to_edl(int64_t position)
286         return position;
289 int64_t PluginClient::edl_to_local(int64_t position)
291         return position;
294 int PluginClient::get_use_opengl()
296         return server->get_use_opengl();
299 int PluginClient::get_total_buffers()
301         return total_in_buffers;
304 int PluginClient::get_buffer_size()
306         return in_buffer_size;
309 int PluginClient::get_project_smp()
311         return smp;
314 char* PluginClient::get_defaultdir()
316         return BCASTDIR;
320 int PluginClient::send_hide_gui()
322 // Stop the GUI server and delete GUI messages
323         client_gui_on = 0;
324         return 0;
327 int PluginClient::send_configure_change()
329         KeyFrame* keyframe = server->get_keyframe();
330         save_data(keyframe);
331         if(server->mwindow)
332                 server->mwindow->undo->update_undo("tweek", LOAD_AUTOMATION, this);
333         server->sync_parameters();
334         return 0;
338 KeyFrame* PluginClient::get_prev_keyframe(int64_t position, int is_local)
340         if(is_local) position = local_to_edl(position);
341         return server->get_prev_keyframe(position);
344 KeyFrame* PluginClient::get_next_keyframe(int64_t position, int is_local)
346         if(is_local) position = local_to_edl(position);
347         return server->get_next_keyframe(position);
350 void PluginClient::get_camera(float *x, float *y, float *z, int64_t position)
352         server->get_camera(x, y, z, position, direction);
355 void PluginClient::get_projector(float *x, float *y, float *z, int64_t position)
357         server->get_projector(x, y, z, position, direction);
361 EDLSession* PluginClient::get_edlsession()
363         if(server->edl) 
364                 return server->edl->session;
365         return 0;
368 int PluginClient::gui_open()
370         return server->gui_open();