2 #include "edlsession.h"
3 #include "pluginclient.h"
4 #include "pluginserver.h"
8 #define _(String) gettext(String)
9 #define gettext_noop(String) String
10 #define N_(String) gettext_noop (String)
12 PluginClient::PluginClient(PluginServer *server)
15 this->server = server;
18 PluginClient::~PluginClient()
22 int PluginClient::reset()
33 realtime_priority = 0;
36 total_out_buffers = 0;
42 int PluginClient::plugin_init(int argc, char *argv[])
46 printf(_("This is a plugin for Broadcast 2000a. Grow a mane.\n"));
51 // get the message pipes
52 messages = new Messages(MESSAGE_TO_PLUGIN, MESSAGE_FROM_PLUGIN, atol(argv[1]));
54 if(atol(argv[2]) >= 0)
56 gui_messages = new Messages(MESSAGE_TO_PLUGIN, MESSAGE_FROM_PLUGIN, atol(argv[2]));
57 gui_messages->write_message(GET_STRING);
58 gui_messages->read_message(gui_string);
60 show_initially = 1; // flag for plugin
70 // For realtime plugins initialize buffers
71 int PluginClient::plugin_init_realtime(int realtime_priority,
75 //printf("PluginClient::plugin_init_realtime 1\n");
76 // Get parameters for all
77 master_gui_on = get_gui_status();
79 //printf("PluginClient::plugin_init_realtime 1\n");
80 // get parameters depending on video or audio
81 init_realtime_parameters();
82 //printf("PluginClient::plugin_init_realtime 1\n");
83 smp = server->edl->session->smp;
84 this->realtime_priority = realtime_priority;
85 this->total_in_buffers = this->total_out_buffers = total_in_buffers;
86 this->out_buffer_size = this->in_buffer_size = buffer_size;
87 //printf("PluginClient::plugin_init_realtime 1\n");
91 int PluginClient::plugin_start_loop(int64_t start, int64_t end, int64_t buffer_size, int total_buffers)
95 this->in_buffer_size = this->out_buffer_size = buffer_size;
96 //printf("PluginClient::plugin_start_loop 1 %d\n", in_buffer_size);
97 this->total_in_buffers = this->total_out_buffers = total_buffers;
98 sample_rate = get_project_samplerate();
99 frame_rate = get_project_framerate();
104 int PluginClient::plugin_process_loop()
106 return process_loop();
109 int PluginClient::plugin_stop_loop()
114 MainProgressBar* PluginClient::start_progress(char *string, int64_t length)
116 return server->start_progress(string, length);
121 int PluginClient::plugin_get_parameters()
123 sample_rate = get_project_samplerate();
124 frame_rate = get_project_framerate();
125 int result = get_parameters();
129 // ========================= main loop
131 int PluginClient::is_multichannel() { return 0; }
132 int PluginClient::is_synthesis() { return 0; }
133 int PluginClient::is_realtime() { return 0; }
134 int PluginClient::is_fileio() { return 0; }
135 int PluginClient::delete_buffer_ptrs() { return 0; }
136 char* PluginClient::plugin_title() { return _("Untitled"); }
137 VFrame* PluginClient::new_picon() { return 0; }
138 Theme* PluginClient::new_theme() { return 0; }
139 int PluginClient::is_audio() { return 0; }
140 int PluginClient::is_video() { return 0; }
141 int PluginClient::is_theme() { return 0; }
142 int PluginClient::uses_gui() { return 1; }
143 int PluginClient::is_transition() { return 0; }
144 int PluginClient::load_defaults() { return 0; }
145 int PluginClient::save_defaults() { return 0; }
146 //int PluginClient::start_gui() { return 0; }
147 //int PluginClient::stop_gui() { return 0; }
148 int PluginClient::show_gui() { return 0; }
149 //int PluginClient::hide_gui() { return 0; }
150 int PluginClient::set_string() { return 0; }
151 int PluginClient::get_parameters() { return 0; }
152 int PluginClient::get_samplerate() { return get_project_samplerate(); }
153 double PluginClient::get_framerate() { return get_project_framerate(); }
154 int PluginClient::init_realtime_parameters() { return 0; }
155 int PluginClient::delete_nonrealtime_parameters() { return 0; }
156 int PluginClient::start_loop() { return 0; };
157 int PluginClient::process_loop() { return 0; };
158 int PluginClient::stop_loop() { return 0; };
160 void PluginClient::set_interactive()
165 int64_t PluginClient::get_in_buffers(int64_t recommended_size)
167 return recommended_size;
170 int64_t PluginClient::get_out_buffers(int64_t recommended_size)
172 return recommended_size;
175 int PluginClient::get_gui_status()
177 return server->get_gui_status();
180 int PluginClient::plugin_start_plugin()
182 // Create any necessary pointers and download any parameters for the derived plugin.
183 smp = get_project_smp();
187 delete_nonrealtime_parameters();
192 int PluginClient::start_plugin()
194 printf(_("No processing defined for this plugin.\n"));
198 // close event from client side
199 void PluginClient::client_side_close()
201 // Last command executed
202 server->client_side_close();
205 int PluginClient::stop_gui_client()
207 if(!client_gui_on) return 0;
209 // stop_gui(); // give to plugin
213 int PluginClient::get_project_samplerate()
215 return server->get_project_samplerate();
218 double PluginClient::get_project_framerate()
220 return server->get_project_framerate();
224 void PluginClient::update_display_title()
226 server->generate_display_title(gui_string);
230 char* PluginClient::get_gui_string()
236 char* PluginClient::get_path()
241 int PluginClient::set_string_client(char *string)
243 strcpy(gui_string, string);
248 int PluginClient::save_data_client()
250 // save_data(messages->get_message_buffer()); // user puts data directly into buffer
251 // messages->write_message_raw();
255 int PluginClient::load_data_client()
257 // read_data(messages->read_message_raw()); // user reads data directly from buffer
261 KeyFrame* PluginClient::get_prev_keyframe(int64_t position)
263 return server->get_prev_keyframe(position);
266 KeyFrame* PluginClient::get_next_keyframe(int64_t position)
268 return server->get_next_keyframe(position);
271 int PluginClient::get_interpolation_type()
273 return server->get_interpolation_type();
277 int PluginClient::automation_used() // If automation is used
282 float PluginClient::get_automation_value(int64_t position) // Get the automation value for the position in the current fragment
285 for(i = automation.total - 1; i >= 0; i--)
287 if(automation.values[i].position <= position)
289 return automation.values[i].intercept + automation.values[i].slope * (position - automation.values[i].position);
295 int64_t PluginClient::get_source_len()
300 int64_t PluginClient::get_source_position()
302 return source_position;
305 int64_t PluginClient::get_source_start()
307 return server->get_source_start();
310 int64_t PluginClient::get_total_len()
316 int PluginClient::get_configure_change()
318 // read_data(messages->read_message_raw());
323 int PluginClient::get_project_smp()
328 char* PluginClient::get_defaultdir()
334 int PluginClient::send_completed()
336 messages->write_message(COMPLETED);
339 int PluginClient::send_cancelled()
341 messages->write_message(CANCEL);
344 int PluginClient::send_hide_gui()
346 // Stop the GUI server and delete GUI messages
351 int PluginClient::send_configure_change()
353 // handle everything using the gui messages
354 //printf("PluginClient::send_configure_change 1 %p\n", server);
355 KeyFrame* keyframe = server->get_keyframe();
356 //printf("PluginClient::send_configure_change 1\n");
358 //printf("PluginClient::send_configure_change 1\n");
359 server->sync_parameters();
360 //printf("PluginClient::send_configure_change 2\n");
364 int PluginClient::write_frames(int64_t total_frames)
366 // buffers are preloaded by client
367 messages->write_message(WRITE_FRAMES);
369 messages->write_message(total_frames);
370 int result = messages->read_message();
371 if(result == OK) return 0;
375 int PluginClient::write_samples(int64_t total_samples)
377 // buffers are preloaded by client
378 messages->write_message(WRITE_SAMPLES);
380 messages->write_message(total_samples);
381 int result = messages->read_message();
382 if(result == OK) return 0;