4 * Copyright (C) 2009 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "attachmentpoint.h"
26 #include "bcsignals.h"
27 #include "cplayback.h"
31 #include "edlsession.h"
33 #include "floatautos.h"
34 #include "keyframes.h"
35 #include "localsession.h"
36 #include "mainerror.h"
37 #include "mainprogress.h"
38 #include "menueffects.h"
40 #include "mwindowgui.h"
41 #include "playbackengine.h"
43 #include "pluginaclient.h"
44 #include "pluginaclientlad.h"
45 #include "pluginfclient.h"
46 #include "pluginclient.h"
47 #include "plugincommands.h"
48 #include "pluginserver.h"
49 #include "pluginvclient.h"
50 #include "preferences.h"
53 #include "mainsession.h"
55 #include "trackcanvas.h"
56 #include "transportque.h"
57 #include "vdevicex11.h"
59 #include "videodevice.h"
60 #include "virtualanode.h"
61 #include "virtualvnode.h"
69 #include <sys/types.h>
75 void PluginServer::init()
78 this->plugin_type = PLUGIN_TYPE_UNKNOWN;
79 plugin_obj = new PluginObj();
80 modules = new ArrayList<Module*>;
81 nodes = new ArrayList<VirtualNode*>;
86 PluginServer::PluginServer()
91 PluginServer::PluginServer(MWindow *mwindow, const char *path, int type)
93 char fpath[BCTEXTLEN];
95 this->plugin_type = type;
96 this->mwindow = mwindow;
97 if( type == PLUGIN_TYPE_FFMPEG ) {
98 ff_name = cstrdup(path);
99 sprintf(fpath, "ff_%s", path);
105 PluginServer::PluginServer(PluginServer &that)
108 plugin_type = that.plugin_type;
109 plugin_obj = that.plugin_obj;
110 plugin_obj->add_user();
111 title = !that.title ? 0 : cstrdup(that.title);
112 tip = !that.tip ? 0 : cstrdup(that.tip);
113 path = !that.path ? 0 : cstrdup(that.path);
114 ff_name = !that.ff_name ? 0 : cstrdup(that.ff_name);
115 modules = new ArrayList<Module*>;
116 nodes = new ArrayList<VirtualNode*>;
118 attachment = that.attachment;
119 realtime = that.realtime;
120 multichannel = that.multichannel;
121 preferences = that.preferences;
122 synthesis = that.synthesis;
126 fileio = that.fileio;
127 uses_gui = that.uses_gui;
128 mwindow = that.mwindow;
129 keyframe = that.keyframe;
130 new_plugin = that.new_plugin;
132 lad_descriptor = that.lad_descriptor;
133 lad_descriptor_function = that.lad_descriptor_function;
134 lad_index = that.lad_index;
137 PluginServer::~PluginServer()
147 plugin_obj->remove_user();
150 // Done only once at creation
151 int PluginServer::reset_parameters()
162 lad_descriptor_function = 0;
168 start_auto = end_auto = 0;
172 realtime = multichannel = fileio = 0;
174 audio = video = theme = 0;
181 for( int i=sizeof(args)/sizeof(args[0]); --i>=0; ) args[i] = 0;
196 // Done every time the plugin is opened or closed
197 int PluginServer::cleanup_plugin()
199 in_buffer_size = out_buffer_size = 0;
200 total_in_buffers = total_out_buffers = 0;
205 written_samples = written_frames = 0;
212 void PluginServer::set_mwindow(MWindow *mwindow)
214 this->mwindow = mwindow;
217 void PluginServer::set_attachmentpoint(AttachmentPoint *attachmentpoint)
219 this->attachmentpoint = attachmentpoint;
222 void PluginServer::set_keyframe(KeyFrame *keyframe)
224 this->keyframe = keyframe;
227 void PluginServer::set_prompt(MenuEffectPrompt *prompt)
229 this->prompt = prompt;
232 void PluginServer::set_lad_index(int i)
237 int PluginServer::get_lad_index()
239 return this->lad_index;
242 int PluginServer::is_unknown()
244 return plugin_type == PLUGIN_TYPE_UNKNOWN ? 1 : 0;
247 int PluginServer::is_executable()
249 return plugin_type == PLUGIN_TYPE_EXECUTABLE ? 1 : 0;
252 int PluginServer::is_builtin()
254 return plugin_type == PLUGIN_TYPE_BUILTIN ? 1 : 0;
257 int PluginServer::is_ladspa()
259 return plugin_type == PLUGIN_TYPE_LADSPA ? 1 : 0;
262 int PluginServer::is_ffmpeg()
264 return plugin_type == PLUGIN_TYPE_FFMPEG ? 1 : 0;
267 int PluginServer::is_lv2()
269 return plugin_type == PLUGIN_TYPE_LV2 ? 1 : 0;
272 void PluginServer::set_path(const char *path)
274 delete [] this->path;
275 this->path = cstrdup(path);
278 char* PluginServer::get_path()
283 int PluginServer::get_synthesis()
289 void PluginServer::set_title(const char *string)
292 title = cstrdup(string);
295 void PluginServer::generate_display_title(char *string)
297 char ltitle[BCTEXTLEN];
298 if(BC_Resources::locale_utf8)
299 strcpy(ltitle, _(title));
301 BC_Resources::encode(BC_Resources::encoding, 0,
302 _(title),strlen(title)+1, ltitle,BCTEXTLEN);
303 if(plugin && plugin->track)
304 sprintf(string, "%s: %s", plugin->track->title, ltitle);
306 strcpy(string, ltitle);
309 void *PluginObj::load(const char *plugin_dir, const char *path)
311 char dlpath[BCTEXTLEN], *dp = dlpath;
312 const char *cp = path;
314 const char *bp = plugin_dir;
315 while( *bp ) *dp++ = *bp++;
318 while( *cp ) *dp++ = *cp++;
320 return dlobj = load(dlpath);
323 int PluginServer::load_obj()
325 void *obj = plugin_obj->obj();
326 if( !obj ) obj =plugin_obj->load(preferences->plugin_dir, path);
330 const char *PluginServer::load_error()
332 return plugin_obj->load_error();
335 void *PluginServer::get_sym(const char *sym)
337 if( !plugin_obj->obj() ) return 0;
338 return plugin_obj->load_sym(sym);
341 // Open plugin for signal processing
342 int PluginServer::open_plugin(int master,
343 Preferences *preferences,
347 if(plugin_open) return 0;
349 this->preferences = preferences;
350 this->plugin = plugin;
352 if( !is_ffmpeg() && !is_lv2() && !is_executable() && !load_obj() ) {
353 // If the load failed, can't use error string to detect executable
354 // because locale and language selection changes the load_error() message
355 // if( !strstr(string, "executable") ) { set_title(path); plugin_type = PLUGIN_TYPE_EXECUTABLE; }
356 eprintf("PluginServer::open_plugin: load_obj %s = %s\n", path, load_error());
357 return PLUGINSERVER_NOT_RECOGNIZED;
359 if( is_unknown() || is_builtin() ) {
361 (PluginClient* (*)(PluginServer*)) get_sym("new_plugin");
363 plugin_type = PLUGIN_TYPE_BUILTIN;
365 if( is_unknown() || is_ladspa() ) {
366 lad_descriptor_function =
367 (LADSPA_Descriptor_Function) get_sym("ladspa_descriptor");
368 if( lad_descriptor_function ) {
369 if( lad_index < 0 ) return PLUGINSERVER_IS_LAD;
370 lad_descriptor = lad_descriptor_function(lad_index);
371 if( !lad_descriptor )
372 return PLUGINSERVER_NOT_RECOGNIZED;
373 plugin_type = PLUGIN_TYPE_LADSPA;
377 fprintf(stderr, "PluginServer::open_plugin "
378 " %d: plugin undefined in %s\n", __LINE__, path);
379 return PLUGINSERVER_NOT_RECOGNIZED;
381 switch( plugin_type ) {
382 case PLUGIN_TYPE_EXECUTABLE:
383 return PLUGINSERVER_OK;
384 case PLUGIN_TYPE_BUILTIN:
385 client = new_plugin(this);
387 case PLUGIN_TYPE_FFMPEG:
388 client = new_ffmpeg_plugin();
390 case PLUGIN_TYPE_LADSPA:
391 client = new PluginAClientLAD(this);
393 case PLUGIN_TYPE_LV2:
394 client = new_lv2_plugin();
401 return PLUGINSERVER_NOT_RECOGNIZED;
403 // Run initialization functions
404 realtime = client->is_realtime();
405 // Don't load defaults when probing the directory.
408 client->load_defaults_xml();
410 client->load_defaults();
412 audio = client->is_audio();
413 video = client->is_video();
414 theme = client->is_theme();
415 fileio = client->is_fileio();
416 uses_gui = client->uses_gui();
417 multichannel = client->is_multichannel();
418 synthesis = client->is_synthesis();
419 transition = client->is_transition();
420 set_title(client->plugin_title());
422 //printf("PluginServer::open_plugin 2\n");
424 return PLUGINSERVER_OK;
427 int PluginServer::close_plugin()
429 if(!plugin_open) return 0;
433 // Defaults are saved in the thread.
434 // if(client->defaults) client->save_defaults();
438 // shared object is persistent since plugin deletion would unlink its own object
444 void PluginServer::client_side_close()
446 // Last command executed in client thread
448 mwindow->hide_plugin(plugin, 1);
452 prompt->lock_window();
454 prompt->unlock_window();
458 void PluginServer::render_stop()
461 client->render_stop();
464 void PluginServer::write_table(FILE *fp, const char *path, int idx, int64_t mtime)
467 fprintf(fp, "%d \"%s\" \"%s\" %jd %d %d %d %d %d %d %d %d %d %d %d\n",
468 plugin_type, path, title, mtime, idx, audio, video, theme, realtime,
469 fileio, uses_gui, multichannel, synthesis, transition, lad_index);
472 int PluginServer::scan_table(char *text, int &type, char *path, char *title, int64_t &mtime)
474 int n = sscanf(text, "%d \"%[^\"]\" \"%[^\"]\" %jd", &type, path, title, &mtime);
475 return n < 4 ? 1 : 0;
478 int PluginServer::read_table(char *text)
480 char path[BCTEXTLEN], title[BCTEXTLEN];
482 int n = sscanf(text, "%d \"%[^\"]\" \"%[^\"]\" %jd %d %d %d %d %d %d %d %d %d %d %d",
483 &plugin_type, path, title, &mtime, &dir_idx, &audio, &video, &theme, &realtime,
484 &fileio, &uses_gui, &multichannel, &synthesis, &transition, &lad_index);
485 if( n != 15 ) return 1;
490 int PluginServer::init_realtime(int realtime_sched,
491 int total_in_buffers,
495 if(!plugin_open) return 0;
497 // set for realtime priority
499 // Call start_realtime
500 this->total_in_buffers = this->total_out_buffers = total_in_buffers;
501 client->plugin_init_realtime(realtime_sched,
509 // Replaced by pull method but still needed for transitions
510 void PluginServer::process_transition(VFrame *input,
512 int64_t current_position,
515 if(!plugin_open) return;
516 PluginVClient *vclient = (PluginVClient*)client;
518 vclient->source_position = current_position;
519 vclient->source_start = 0;
520 vclient->total_len = total_len;
522 vclient->input = new VFrame*[1];
523 vclient->output = new VFrame*[1];
525 vclient->input[0] = input;
526 vclient->output[0] = output;
528 vclient->process_realtime(input, output);
530 delete [] vclient->input;
531 delete [] vclient->output;
535 void PluginServer::process_transition(Samples *input,
537 int64_t current_position,
538 int64_t fragment_size,
541 if(!plugin_open) return;
542 PluginAClient *aclient = (PluginAClient*)client;
544 aclient->source_position = current_position;
545 aclient->total_len = total_len;
546 aclient->source_start = 0;
547 aclient->process_realtime(fragment_size,
553 void PluginServer::process_buffer(VFrame **frame,
554 int64_t current_position,
559 if(!plugin_open) return;
560 PluginVClient *vclient = (PluginVClient*)client;
562 vclient->source_position = current_position;
563 vclient->total_len = total_len;
564 vclient->frame_rate = frame_rate;
565 vclient->input = new VFrame*[total_in_buffers];
566 vclient->output = new VFrame*[total_in_buffers];
567 for(int i = 0; i < total_in_buffers; i++)
569 vclient->input[i] = frame[i];
570 vclient->output[i] = frame[i];
575 vclient->source_start = (int64_t)plugin->startproject *
577 vclient->project_frame_rate;
579 vclient->direction = direction;
583 //printf("plugin=%p source_start=%ld\n", plugin, vclient->source_start);
585 vclient->begin_process_buffer();
588 vclient->process_buffer(frame, current_position, frame_rate);
592 vclient->process_buffer(frame[0], current_position, frame_rate);
594 vclient->end_process_buffer();
596 for(int i = 0; i < total_in_buffers; i++)
597 frame[i]->push_prev_effect(title);
599 delete [] vclient->input;
600 delete [] vclient->output;
606 void PluginServer::process_buffer(Samples **buffer,
607 int64_t current_position,
608 int64_t fragment_size,
613 if(!plugin_open) return;
614 PluginAClient *aclient = (PluginAClient*)client;
616 aclient->source_position = current_position;
617 aclient->total_len = total_len;
618 aclient->sample_rate = sample_rate;
621 aclient->source_start = plugin->startproject *
623 aclient->project_sample_rate;
625 aclient->direction = direction;
626 aclient->begin_process_buffer();
629 aclient->process_buffer(fragment_size,
636 aclient->process_buffer(fragment_size,
641 aclient->end_process_buffer();
645 PluginGUIs::PluginGUIs(MWindow *mwindow)
647 this->mwindow = mwindow;
650 PluginGUIs::~PluginGUIs()
654 void PluginGUIs::append(PluginServer *server)
656 server->gui_id = next_id++;
657 ArrayList<PluginServer*>::append(server);
660 PluginServer *PluginGUIs::gui_server(int gui_id)
662 for( int i=0; i<size(); ++i ) {
663 PluginServer *plugin_server = get(i);
664 if( plugin_server->gui_id == gui_id )
665 return plugin_server;
671 void PluginServer::send_render_gui(void *data)
673 //printf("PluginServer::send_render_gui 1 %p\n", attachmentpoint);
674 if(attachmentpoint) attachmentpoint->render_gui(data, this);
677 void PluginServer::send_render_gui(void *data, int size)
679 //printf("PluginServer::send_render_gui 1 %p\n", attachmentpoint);
680 if(attachmentpoint) attachmentpoint->render_gui(data, size, this);
683 void PluginServer::render_gui(void *data)
685 if(client) client->plugin_render_gui(data);
688 void PluginServer::render_gui(void *data, int size)
690 if(client) client->plugin_render_gui(data, size);
693 MainProgressBar* PluginServer::start_progress(char *string, int64_t length)
695 mwindow->gui->lock_window();
696 MainProgressBar *result = mwindow->mainprogress->start_progress(string, length);
697 mwindow->gui->unlock_window();
701 int64_t PluginServer::get_written_samples()
703 if(!plugin_open) return 0;
704 return written_samples;
707 int64_t PluginServer::get_written_frames()
709 if(!plugin_open) return 0;
710 return written_frames;
722 // ======================= Non-realtime plugin
724 int PluginServer::get_parameters(int64_t start, int64_t end, int channels)
726 if(!plugin_open) return 0;
728 client->start = start;
730 client->source_start = start;
731 client->total_len = end - start;
732 client->total_in_buffers = channels;
735 //printf(" source_start=%ld total_len=%ld\n", client->source_start, client->total_len);
737 return client->plugin_get_parameters();
740 int PluginServer::set_interactive()
742 if(!plugin_open) return 0;
743 client->set_interactive();
747 void PluginServer::append_module(Module *module)
749 modules->append(module);
752 void PluginServer::append_node(VirtualNode *node)
757 void PluginServer::reset_nodes()
762 int PluginServer::set_error()
768 int PluginServer::set_realtime_sched()
770 //struct sched_param params;
771 //params.sched_priority = 1;
772 //sched_setscheduler(0, SCHED_RR, ¶m);
777 int PluginServer::process_loop(VFrame **buffers, int64_t &write_length)
779 if(!plugin_open) return 1;
780 return client->plugin_process_loop(buffers, write_length);
783 int PluginServer::process_loop(Samples **buffers, int64_t &write_length)
785 if(!plugin_open) return 1;
786 return client->plugin_process_loop(buffers, write_length);
790 int PluginServer::start_loop(int64_t start,
795 if(!plugin_open) return 0;
796 client->plugin_start_loop(start, end, buffer_size, total_buffers);
800 int PluginServer::stop_loop()
802 if(!plugin_open) return 0;
803 return client->plugin_stop_loop();
806 int PluginServer::read_frame(VFrame *buffer,
808 int64_t start_position)
810 ((VModule*)modules->values[channel])->render(buffer,
813 mwindow->edl->session->frame_rate,
819 int PluginServer::read_samples(Samples *buffer,
822 int64_t start_position,
825 // len is now in buffer
826 if(!multichannel) channel = 0;
828 if(nodes->total > channel)
829 return ((VirtualANode*)nodes->values[channel])->read_data(buffer,
834 if(modules->total > channel)
835 return ((AModule*)modules->values[channel])->render(buffer,
843 printf("PluginServer::read_samples no object available for channel=%d\n",
851 int PluginServer::read_samples(Samples *buffer,
853 int64_t start_position,
856 // total_samples is now set in buffer
857 ((AModule*)modules->values[channel])->render(buffer,
861 mwindow->edl->session->sample_rate,
866 int PluginServer::read_frame(VFrame *buffer,
868 int64_t start_position,
872 // Data source depends on whether we're part of a virtual console or a
876 // If we're a VirtualNode, read_data in the virtual plugin node handles
877 // backward propogation and produces the data.
878 // If we're a Module, render in the module produces the data.
882 if(!multichannel) channel = 0;
884 // Push our name on the next effect stack
885 buffer->push_next_effect(title);
886 //printf("PluginServer::read_frame %p\n", buffer);
887 //buffer->dump_stacks();
889 if(nodes->total > channel)
891 //printf("PluginServer::read_frame %d\n", __LINE__);
892 result = ((VirtualVNode*)nodes->values[channel])->read_data(buffer,
898 if(modules->total > channel)
900 //printf("PluginServer::read_frame %d\n", __LINE__);
901 result = ((VModule*)modules->values[channel])->render(buffer,
912 printf("PluginServer::read_frame no object available for channel=%d\n",
916 // Pop our name from the next effect stack
917 buffer->pop_next_effect();
942 int PluginServer::get_gui_status()
945 return plugin->show ? GUI_ON : GUI_OFF;
950 void PluginServer::raise_window()
952 if(!plugin_open) return;
953 client->raise_window();
956 void PluginServer::show_gui()
958 if(!plugin_open) return;
960 plugin->gui_id = gui_id;
961 client->total_len = plugin->length;
962 client->source_start = plugin->startproject;
966 client->source_position = Units::to_int64(
967 mwindow->edl->local_session->get_selectionstart(1) *
968 mwindow->edl->session->frame_rate);
973 client->source_position = Units::to_int64(
974 mwindow->edl->local_session->get_selectionstart(1) *
975 mwindow->edl->session->sample_rate);
978 client->update_display_title();
982 void PluginServer::hide_gui()
984 if(!plugin_open) return;
985 if( plugin ) plugin->gui_id = -1;
986 if(client->defaults) client->save_defaults();
990 void PluginServer::update_gui()
992 if(!plugin_open || !plugin) return;
994 client->total_len = plugin->length;
995 client->source_start = plugin->startproject;
999 client->source_position = Units::to_int64(
1000 mwindow->edl->local_session->get_selectionstart(1) *
1001 mwindow->edl->session->frame_rate);
1006 client->source_position = Units::to_int64(
1007 mwindow->edl->local_session->get_selectionstart(1) *
1008 mwindow->edl->session->sample_rate);
1011 client->plugin_update_gui();
1014 void PluginServer::update_title()
1016 if(!plugin_open) return;
1018 client->update_display_title();
1022 int PluginServer::set_string(char *string)
1024 if(!plugin_open) return 0;
1026 client->set_string_client(string);
1030 int PluginServer::gui_open()
1032 if(attachmentpoint) return attachmentpoint->gui_open();
1036 void PluginServer::set_use_opengl(int value, VideoDevice *vdevice)
1038 this->use_opengl = value;
1039 this->vdevice = vdevice;
1042 int PluginServer::get_use_opengl()
1048 void PluginServer::run_opengl(PluginClient *plugin_client)
1051 ((VDeviceX11*)vdevice->get_output_base())->run_plugin(plugin_client);
1054 // ============================= queries
1056 void PluginServer::get_defaults_path(char *path)
1058 // Get plugin name from path
1059 char *ptr1 = strrchr(get_path(), '/');
1060 char *ptr2 = strrchr(get_path(), '.');
1061 if(!ptr1) ptr1 = get_path();
1062 if(!ptr2) ptr2 = get_path() + strlen(get_path());
1063 char string2[BCTEXTLEN], *ptr3 = string2;
1064 while( ptr1 < ptr2 ) *ptr3++ = *ptr1++;
1066 sprintf(path, "%s/%s.xml", File::get_config_path(), string2);
1069 void PluginServer::save_defaults()
1071 if(client) client->save_defaults();
1074 int PluginServer::get_samplerate()
1076 if(!plugin_open) return 0;
1079 return client->get_samplerate();
1083 return mwindow->edl->session->sample_rate;
1086 printf("PluginServer::get_samplerate audio and mwindow == NULL\n");
1092 double PluginServer::get_framerate()
1094 if(!plugin_open) return 0;
1097 return client->get_framerate();
1101 return mwindow->edl->session->frame_rate;
1104 printf("PluginServer::get_framerate video and mwindow == NULL\n");
1109 int PluginServer::get_project_samplerate()
1112 return mwindow->edl->session->sample_rate;
1115 return edl->session->sample_rate;
1118 printf("PluginServer::get_project_samplerate mwindow and edl are NULL.\n");
1123 double PluginServer::get_project_framerate()
1126 return mwindow->edl->session->frame_rate;
1129 return edl->session->frame_rate;
1132 printf("PluginServer::get_project_framerate mwindow and edl are NULL.\n");
1139 int PluginServer::detach_buffers()
1141 ring_buffers_out.remove_all();
1142 offset_out_render.remove_all();
1143 double_buffer_out_render.remove_all();
1144 realtime_out_size.remove_all();
1146 ring_buffers_in.remove_all();
1147 offset_in_render.remove_all();
1148 double_buffer_in_render.remove_all();
1149 realtime_in_size.remove_all();
1151 out_buffer_size = 0;
1153 total_out_buffers = 0;
1155 total_in_buffers = 0;
1159 int PluginServer::arm_buffer(int buffer_number,
1162 int double_buffer_in,
1163 int double_buffer_out)
1165 offset_in_render.values[buffer_number] = offset_in;
1166 offset_out_render.values[buffer_number] = offset_out;
1167 double_buffer_in_render.values[buffer_number] = double_buffer_in;
1168 double_buffer_out_render.values[buffer_number] = double_buffer_out;
1173 int PluginServer::set_automation(FloatAutos *autos, FloatAuto **start_auto, FloatAuto **end_auto, int reverse)
1175 this->autos = autos;
1176 this->start_auto = start_auto;
1177 this->end_auto = end_auto;
1178 this->reverse = reverse;
1184 void PluginServer::save_data(KeyFrame *keyframe)
1186 if(!plugin_open) return;
1187 client->save_data(keyframe);
1190 KeyFrame* PluginServer::get_prev_keyframe(int64_t position)
1192 KeyFrame *result = 0;
1194 result = plugin->get_prev_keyframe(position, client->direction);
1200 KeyFrame* PluginServer::get_next_keyframe(int64_t position)
1202 KeyFrame *result = 0;
1204 result = plugin->get_next_keyframe(position, client->direction);
1211 KeyFrame* PluginServer::get_keyframe()
1214 // Realtime plugin case
1215 return plugin->get_keyframe();
1217 // Rendered plugin case
1222 void PluginServer::apply_keyframe(KeyFrame *src)
1226 keyframe->copy_data(src);
1231 plugin->keyframes->update_parameter(src);
1239 void PluginServer::get_camera(float *x, float *y, float *z,
1240 int64_t position, int direction)
1242 plugin->track->automation->get_camera(x, y, z, position, direction);
1245 void PluginServer::get_projector(float *x, float *y, float *z,
1246 int64_t position, int direction)
1248 plugin->track->automation->get_projector(x, y, z, position, direction);
1252 int PluginServer::get_interpolation_type()
1254 return plugin->edl->session->interpolation_type;
1257 Theme* PluginServer::new_theme()
1261 return client->new_theme();
1267 Theme* PluginServer::get_theme()
1269 if(mwindow) return mwindow->theme;
1270 printf("PluginServer::get_theme mwindow not set\n");
1275 void PluginServer::get_plugin_png_name(char *png_name)
1277 char *pp = png_name, *ep = pp + BCSTRLEN-1;
1278 char *cp = strrchr(path, '/');
1279 cp = !cp ? path : cp+1;
1280 char *sp = strrchr(cp, '.');
1281 if( !sp ) sp = cp+strlen(cp);
1282 while( pp < ep && cp < sp ) *pp++ = *cp++;
1283 snprintf(pp, ep-pp, ".png");
1286 int PluginServer::get_plugin_png_path(char *png_path, const char *plugin_icons)
1288 char png_name[BCSTRLEN];
1289 get_plugin_png_name(png_name);
1290 char *pp = png_path, *ep = pp + BCTEXTLEN-1;
1291 pp += snprintf(pp, ep-pp, "%s/picon/%s/%s",
1292 File::get_plugin_path(), plugin_icons, png_name);
1293 return access(png_path,R_OK) ? 1 : 0;
1296 int PluginServer::get_plugin_png_path(char *png_path)
1298 int ret = get_plugin_png_path(png_path, mwindow->preferences->plugin_icons);
1299 if( ret ) ret = get_plugin_png_path(png_path, DEFAULT_PICON);
1303 VFrame *PluginServer::get_plugin_images()
1305 char png_path[BCTEXTLEN];
1306 if( !get_plugin_png_path(png_path) )
1307 return VFramePng::vframe_png(png_path,0,0);
1308 char png_name[BCSTRLEN];
1309 get_plugin_png_name(png_name);
1310 unsigned char *data = mwindow->theme->get_image_data(png_name, 0);
1311 return data ? new VFramePng(data, 0.) : 0;
1314 VFrame *PluginServer::get_picon()
1317 picon = get_plugin_images();
1321 // Called when plugin interface is tweeked
1322 void PluginServer::sync_parameters()
1324 if(video) mwindow->restart_brender();
1325 mwindow->sync_parameters();
1326 mwindow->update_keyframe_guis();
1327 if(mwindow->edl->session->auto_conf->plugins)
1329 mwindow->gui->lock_window("PluginServer::sync_parameters");
1330 mwindow->gui->draw_overlays(1);
1331 mwindow->gui->unlock_window();
1335 int64_t PluginServer::get_startproject()
1337 return !plugin ? -1 : plugin->startproject;
1339 int64_t PluginServer::get_endproject()
1341 return !plugin ? -1 : plugin->startproject + plugin->length;
1344 void PluginServer::dump(FILE *fp)
1346 fprintf(fp," PluginServer %d %p %s %s %d\n",
1347 __LINE__, this, path, title, realtime);