• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files

hvirtual/cinelerra/pluginserver.C

Go to the documentation of this file.
00001 #include "amodule.h"
00002 #include "atrack.h"
00003 #include "attachmentpoint.h"
00004 #include "autoconf.h"
00005 #include "bcsignals.h"
00006 #include "cplayback.h"
00007 #include "cwindow.h"
00008 #include "edl.h"
00009 #include "edlsession.h"
00010 #include "floatautos.h"
00011 #include "localsession.h"
00012 #include "mainprogress.h"
00013 #include "mainundo.h"
00014 #include "menueffects.h"
00015 #include "mwindow.h"
00016 #include "mwindowgui.h"
00017 #include "playbackengine.h"
00018 #include "plugin.h"
00019 #include "pluginaclient.h"
00020 #include "pluginaclientlad.h"
00021 #include "pluginclient.h"
00022 #include "plugincommands.h"
00023 #include "pluginserver.h"
00024 #include "pluginvclient.h"
00025 #include "preferences.h"
00026 #include "sema.h"
00027 #include "mainsession.h"
00028 #include "trackcanvas.h"
00029 #include "transportque.h"
00030 #include "vdevicex11.h"
00031 #include "vframe.h"
00032 #include "videodevice.h"
00033 #include "virtualanode.h"
00034 #include "virtualvnode.h"
00035 #include "vmodule.h"
00036 #include "vtrack.h"
00037 
00038 
00039 #include <sys/types.h>
00040 #include <sys/wait.h>
00041 #include <dlfcn.h>
00042 
00043 
00044 PluginServer::PluginServer()
00045 {
00046         reset_parameters();
00047         modules = new ArrayList<Module*>;
00048         nodes = new ArrayList<VirtualNode*>;
00049 }
00050 
00051 PluginServer::PluginServer(char *path)
00052 {
00053         reset_parameters();
00054         set_path(path);
00055         modules = new ArrayList<Module*>;
00056         nodes = new ArrayList<VirtualNode*>;
00057 }
00058 
00059 PluginServer::PluginServer(PluginServer &that)
00060 {
00061         reset_parameters();
00062 
00063         if(that.title)
00064         {
00065                 title = new char[strlen(that.title) + 1];
00066                 strcpy(title, that.title);
00067         }
00068 
00069         if(that.path)
00070         {
00071                 path = new char[strlen(that.path) + 1];
00072                 strcpy(path, that.path);
00073         }
00074 
00075         modules = new ArrayList<Module*>;
00076         nodes = new ArrayList<VirtualNode*>;
00077 
00078         attachment = that.attachment;   
00079         realtime = that.realtime;
00080         multichannel = that.multichannel;
00081         preferences = that.preferences;
00082         synthesis = that.synthesis;
00083         audio = that.audio;
00084         video = that.video;
00085         theme = that.theme;
00086         fileio = that.fileio;
00087         uses_gui = that.uses_gui;
00088         mwindow = that.mwindow;
00089         keyframe = that.keyframe;
00090         plugin_fd = that.plugin_fd;
00091         new_plugin = that.new_plugin;
00092 
00093         is_lad = that.is_lad;
00094         lad_descriptor = that.lad_descriptor;
00095         lad_descriptor_function = that.lad_descriptor_function;
00096 }
00097 
00098 PluginServer::~PluginServer()
00099 {
00100         close_plugin();
00101         if(path) delete [] path;
00102         if(title) delete [] title;
00103         if(modules) delete modules;
00104         if(nodes) delete nodes;
00105         if(picon) delete picon;
00106 }
00107 
00108 // Done only once at creation
00109 int PluginServer::reset_parameters()
00110 {
00111         mwindow = 0;
00112         keyframe = 0;
00113         prompt = 0;
00114         cleanup_plugin();
00115         plugin_fd = 0;
00116         autos = 0;
00117         plugin = 0;
00118         edl = 0;
00119         preferences = 0;
00120         title = 0;
00121         path = 0;
00122         audio = video = theme = 0;
00123         uses_gui = 0;
00124         realtime = multichannel = fileio = 0;
00125         synthesis = 0;
00126         start_auto = end_auto = 0;
00127         picon = 0;
00128         transition = 0;
00129         new_plugin = 0;
00130         client = 0;
00131         use_opengl = 0;
00132         vdevice = 0;
00133 
00134         is_lad = 0;
00135         lad_descriptor_function = 0;
00136         lad_descriptor = 0;
00137 }
00138 
00139 
00140 // Done every time the plugin is opened or closed
00141 int PluginServer::cleanup_plugin()
00142 {
00143         in_buffer_size = out_buffer_size = 0;
00144         total_in_buffers = total_out_buffers = 0;
00145         error_flag = 0;
00146         written_samples = 0;
00147         shared_buffers = 0;
00148         new_buffers = 0;
00149         written_samples = written_frames = 0;
00150         gui_on = 0;
00151         plugin = 0;
00152         plugin_open = 0;
00153 }
00154 
00155 void PluginServer::set_mwindow(MWindow *mwindow)
00156 {
00157         this->mwindow = mwindow;
00158 }
00159 
00160 void PluginServer::set_attachmentpoint(AttachmentPoint *attachmentpoint)
00161 {
00162         this->attachmentpoint = attachmentpoint;
00163 }
00164 
00165 void PluginServer::set_keyframe(KeyFrame *keyframe)
00166 {
00167         this->keyframe = keyframe;
00168 }
00169 
00170 void PluginServer::set_prompt(MenuEffectPrompt *prompt)
00171 {
00172         this->prompt = prompt;
00173 }
00174 
00175 
00176 int PluginServer::set_path(char *path)
00177 {
00178         if(this->path) delete [] this->path;
00179         this->path = new char[strlen(path) + 1];
00180         strcpy(this->path, path);
00181 }
00182 
00183 void PluginServer::set_title(char *string)
00184 {
00185         if(title) delete [] title;
00186         title = new char[strlen(string) + 1];
00187         strcpy(title, string);
00188 }
00189 
00190 void PluginServer::generate_display_title(char *string)
00191 {
00192         if(plugin && plugin->track) 
00193                 sprintf(string, "%s: %s", plugin->track->title, title);
00194         else
00195                 strcpy(string, title);
00196 }
00197 
00198 // Open plugin for signal processing
00199 int PluginServer::open_plugin(int master, 
00200         Preferences *preferences,
00201         EDL *edl, 
00202         Plugin *plugin,
00203         int lad_index)
00204 {
00205         if(plugin_open) return 0;
00206 
00207         this->preferences = preferences;
00208         this->plugin = plugin;
00209         this->edl = edl;
00210 
00211 
00212 
00213         if(!new_plugin && !plugin_fd) plugin_fd = dlopen(path, RTLD_NOW);
00214 
00215         if(!new_plugin && !plugin_fd)
00216         {
00217 // If the dlopen failed it may still be an executable tool for a specific
00218 // file format, in which case we just store the path.
00219                 set_title(path);
00220                 char string[BCTEXTLEN];
00221                 strcpy(string, dlerror());
00222 
00223                 if(!strstr(string, "executable"))
00224                         printf("PluginServer::open_plugin: %s\n", string);
00225                 
00226                 return 0;
00227         }
00228 
00229 
00230         if(!new_plugin && !lad_descriptor)
00231         {
00232                 new_plugin = (PluginClient* (*)(PluginServer*))dlsym(plugin_fd, "new_plugin");
00233 
00234 // Probably a LAD plugin but we're not going to instantiate it here anyway.
00235                 if(!new_plugin)
00236                 {
00237                         lad_descriptor_function = (LADSPA_Descriptor_Function)dlsym(
00238                                 plugin_fd,
00239                                 "ladspa_descriptor");
00240 
00241                         if(!lad_descriptor_function)
00242                         {
00243 // Not a recognized plugin
00244                                 fprintf(stderr, "PluginServer::open_plugin: new_plugin undefined in %s\n", path);
00245                                 dlclose(plugin_fd);
00246                                 plugin_fd = 0;
00247                                 return PLUGINSERVER_NOT_RECOGNIZED;
00248                         }
00249                         else
00250                         {
00251 // LAD plugin,  Load the descriptor and get parameters.
00252                                 is_lad = 1;
00253                                 if(lad_index >= 0)
00254                                 {
00255                                         lad_descriptor = lad_descriptor_function(lad_index);
00256                                 }
00257 
00258 // make plugin initializer handle the subplugins in the LAD plugin or stop
00259 // trying subplugins.
00260                                 if(!lad_descriptor)
00261                                 {
00262                                         dlclose(plugin_fd);
00263                                         plugin_fd = 0;
00264                                         return PLUGINSERVER_IS_LAD;
00265                                 }
00266                         }
00267                 }
00268         }
00269 
00270 
00271         if(is_lad)
00272         {
00273                 client = new PluginAClientLAD(this);
00274         }
00275         else
00276         {
00277                 client = new_plugin(this);
00278         }
00279 
00280         realtime = client->is_realtime();
00281         audio = client->is_audio();
00282         video = client->is_video();
00283         theme = client->is_theme();
00284         fileio = client->is_fileio();
00285         uses_gui = client->uses_gui();
00286         multichannel = client->is_multichannel();
00287         synthesis = client->is_synthesis();
00288         transition = client->is_transition();
00289         set_title(client->plugin_title());
00290 
00291         if(master)
00292         {
00293                 picon = client->new_picon();
00294         }
00295 
00296 //printf("PluginServer::open_plugin 2\n");
00297         plugin_open = 1;
00298         return PLUGINSERVER_OK;
00299 }
00300 
00301 int PluginServer::close_plugin()
00302 {
00303         if(!plugin_open) return 0;
00304 
00305         int plugin_status, result;
00306         if(client) delete client;
00307 
00308 // shared object is persistent since plugin deletion would unlink its own object
00309 //      dlclose(plugin_fd);
00310         plugin_open = 0;
00311 
00312         cleanup_plugin();
00313 
00314         return 0;
00315 }
00316 
00317 void PluginServer::client_side_close()
00318 {
00319 // Last command executed in client thread
00320         if(plugin)
00321                 mwindow->hide_plugin(plugin, 1);
00322         else
00323         if(prompt)
00324         {
00325                 prompt->lock_window();
00326                 prompt->set_done(1);
00327                 prompt->unlock_window();
00328         }
00329 }
00330 
00331 void PluginServer::render_stop()
00332 {
00333         if(client)
00334                 client->render_stop();
00335 }
00336 
00337 
00338 int PluginServer::init_realtime(int realtime_sched,
00339                 int total_in_buffers, 
00340                 int buffer_size)
00341 {
00342 
00343         if(!plugin_open) return 0;
00344 
00345 // set for realtime priority
00346 // initialize plugin
00347 // Call start_realtime
00348         this->total_in_buffers = this->total_out_buffers = total_in_buffers;
00349         client->plugin_init_realtime(realtime_sched, 
00350                 total_in_buffers, 
00351                 buffer_size);
00352 
00353 }
00354 
00355 
00356 // Replaced by pull method but still needed for transitions
00357 void PluginServer::process_transition(VFrame *input, 
00358                 VFrame *output, 
00359                 int64_t current_position,
00360                 int64_t total_len)
00361 {
00362         if(!plugin_open) return;
00363         PluginVClient *vclient = (PluginVClient*)client;
00364 
00365         vclient->source_position = current_position;
00366         vclient->source_start = 0;
00367         vclient->total_len = total_len;
00368 
00369         vclient->input = new VFrame*[1];
00370         vclient->output = new VFrame*[1];
00371 
00372         vclient->input[0] = input;
00373         vclient->output[0] = output;
00374 
00375         vclient->process_realtime(input, output);
00376         vclient->age_temp();
00377         delete [] vclient->input;
00378         delete [] vclient->output;
00379         use_opengl = 0;
00380 }
00381 
00382 void PluginServer::process_transition(double *input, 
00383                 double *output,
00384                 int64_t current_position, 
00385                 int64_t fragment_size,
00386                 int64_t total_len)
00387 {
00388         if(!plugin_open) return;
00389         PluginAClient *aclient = (PluginAClient*)client;
00390 
00391         aclient->source_position = current_position;
00392         aclient->total_len = total_len;
00393         aclient->source_start = 0;
00394         aclient->process_realtime(fragment_size,
00395                 input, 
00396                 output);
00397 }
00398 
00399 
00400 void PluginServer::process_buffer(VFrame **frame, 
00401         int64_t current_position,
00402         double frame_rate,
00403         int64_t total_len,
00404         int direction)
00405 {
00406         if(!plugin_open) return;
00407         PluginVClient *vclient = (PluginVClient*)client;
00408 
00409         vclient->source_position = current_position;
00410         vclient->total_len = total_len;
00411         vclient->frame_rate = frame_rate;
00412         vclient->input = new VFrame*[total_in_buffers];
00413         vclient->output = new VFrame*[total_in_buffers];
00414         for(int i = 0; i < total_in_buffers; i++)
00415         {
00416                 vclient->input[i] = frame[i];
00417                 vclient->output[i] = frame[i];
00418         }
00419         vclient->source_start = (int64_t)(plugin ? 
00420                 plugin->startproject * 
00421                 frame_rate /
00422                 vclient->project_frame_rate :
00423                 0);
00424         vclient->direction = direction;
00425 
00426 
00427         if(multichannel)
00428         {
00429                 vclient->process_buffer(frame, current_position, frame_rate);
00430         }
00431         else
00432         {
00433                 vclient->process_buffer(frame[0], current_position, frame_rate);
00434         }
00435 
00436         for(int i = 0; i < total_in_buffers; i++)
00437                 frame[i]->push_prev_effect(title);
00438 
00439         delete [] vclient->input;
00440         delete [] vclient->output;
00441 
00442     vclient->age_temp();
00443         use_opengl = 0;
00444 }
00445 
00446 void PluginServer::process_buffer(double **buffer,
00447         int64_t current_position,
00448         int64_t fragment_size,
00449         int64_t sample_rate,
00450         int64_t total_len,
00451         int direction)
00452 {
00453         if(!plugin_open) return;
00454         PluginAClient *aclient = (PluginAClient*)client;
00455         aclient->source_position = current_position;
00456         aclient->total_len = total_len;
00457         aclient->sample_rate = sample_rate;
00458         if(plugin)
00459                 aclient->source_start = plugin->startproject * 
00460                         sample_rate /
00461                         aclient->project_sample_rate;
00462         aclient->direction = direction;
00463         if(multichannel)
00464                 aclient->process_buffer(fragment_size, 
00465                         buffer, 
00466                         current_position, 
00467                         sample_rate);
00468         else
00469         {
00470                 aclient->process_buffer(fragment_size, 
00471                         buffer[0], 
00472                         current_position, 
00473                         sample_rate);
00474         }
00475 }
00476 
00477 
00478 void PluginServer::send_render_gui(void *data)
00479 {
00480 //printf("PluginServer::send_render_gui 1 %p\n", attachmentpoint);
00481         if(attachmentpoint) attachmentpoint->render_gui(data);
00482 }
00483 
00484 void PluginServer::send_render_gui(void *data, int size)
00485 {
00486 //printf("PluginServer::send_render_gui 1 %p\n", attachmentpoint);
00487         if(attachmentpoint) attachmentpoint->render_gui(data, size);
00488 }
00489 
00490 void PluginServer::render_gui(void *data)
00491 {
00492         if(client) client->plugin_render_gui(data);
00493 }
00494 
00495 void PluginServer::render_gui(void *data, int size)
00496 {
00497         if(client) client->plugin_render_gui(data, size);
00498 }
00499 
00500 MainProgressBar* PluginServer::start_progress(char *string, int64_t length)
00501 {
00502         mwindow->gui->lock_window();
00503         MainProgressBar *result = mwindow->mainprogress->start_progress(string, length);
00504         mwindow->gui->unlock_window();
00505         return result;
00506 }
00507 
00508 int64_t PluginServer::get_written_samples()
00509 {
00510         if(!plugin_open) return 0;
00511         return written_samples;
00512 }
00513 
00514 int64_t PluginServer::get_written_frames()
00515 {
00516         if(!plugin_open) return 0;
00517         return written_frames;
00518 }
00519 
00520 
00521 
00522 
00523 
00524 
00525 
00526 
00527 
00528 
00529 // ======================= Non-realtime plugin
00530 
00531 int PluginServer::get_parameters(int64_t start, int64_t end, int channels)      
00532 {
00533         if(!plugin_open) return 0;
00534 
00535         client->start = start;
00536         client->end = end;
00537         client->source_start = start;
00538         client->total_len = end - start;
00539         client->total_in_buffers = channels;
00540         return client->plugin_get_parameters();
00541 }
00542 
00543 int PluginServer::set_interactive()
00544 {
00545         if(!plugin_open) return 0;
00546         client->set_interactive();
00547         return 0;
00548 }
00549 
00550 void PluginServer::append_module(Module *module)
00551 {
00552         modules->append(module);
00553 }
00554 
00555 void PluginServer::append_node(VirtualNode *node)
00556 {
00557         nodes->append(node);
00558 }
00559 
00560 void PluginServer::reset_nodes()
00561 {
00562         nodes->remove_all();
00563 }
00564 
00565 int PluginServer::set_error()
00566 {
00567         error_flag = 1;
00568         return 0;
00569 }
00570 
00571 int PluginServer::set_realtime_sched()
00572 {
00573         struct sched_param params;
00574         params.sched_priority = 1;
00575         return 0;
00576 }
00577 
00578 
00579 int PluginServer::process_loop(VFrame **buffers, int64_t &write_length)
00580 {
00581         if(!plugin_open) return 1;
00582         return client->plugin_process_loop(buffers, write_length);
00583 }
00584 
00585 int PluginServer::process_loop(double **buffers, int64_t &write_length)
00586 {
00587         if(!plugin_open) return 1;
00588         return client->plugin_process_loop(buffers, write_length);
00589 }
00590 
00591 
00592 int PluginServer::start_loop(int64_t start, 
00593         int64_t end, 
00594         int64_t buffer_size, 
00595         int total_buffers)
00596 {
00597         if(!plugin_open) return 0;
00598         client->plugin_start_loop(start, end, buffer_size, total_buffers);
00599         return 0;
00600 }
00601 
00602 int PluginServer::stop_loop()
00603 {
00604         if(!plugin_open) return 0;
00605         return client->plugin_stop_loop();
00606 }
00607 
00608 int PluginServer::read_frame(VFrame *buffer, 
00609         int channel, 
00610         int64_t start_position)
00611 {
00612         ((VModule*)modules->values[channel])->render(buffer,
00613                 start_position,
00614                 PLAY_FORWARD,
00615                 mwindow->edl->session->frame_rate,
00616                 0,
00617                 0);
00618         return 0;
00619 }
00620 
00621 int PluginServer::read_samples(double *buffer, 
00622         int channel, 
00623         int64_t start_position, 
00624         int64_t total_samples)
00625 {
00626         ((AModule*)modules->values[channel])->render(buffer, 
00627                 start_position,
00628                 total_samples, 
00629                 PLAY_FORWARD,
00630                 mwindow->edl->session->sample_rate,
00631                 0);
00632         return 0;
00633 }
00634 
00635 int PluginServer::read_frame(VFrame *buffer, 
00636         int channel, 
00637         int64_t start_position, 
00638         double frame_rate,
00639         int use_opengl)
00640 {
00641 // Data source depends on whether we're part of a virtual console or a
00642 // plugin array.
00643 //     VirtualNode
00644 //     Module
00645 // If we're a VirtualNode, read_data in the virtual plugin node handles
00646 //     backward propogation and produces the data.
00647 // If we're a Module, render in the module produces the data.
00648 
00649         int result = -1;
00650         if(!multichannel) channel = 0;
00651 
00652 // Push our name on the next effect stack
00653         buffer->push_next_effect(title);
00654 //printf("PluginServer::read_frame %p\n", buffer);
00655 //buffer->dump_stacks();
00656 
00657         if(nodes->total > channel)
00658         {
00659                 result = ((VirtualVNode*)nodes->values[channel])->read_data(buffer,
00660                         start_position,
00661                         frame_rate,
00662                         use_opengl);
00663         }
00664         else
00665         if(modules->total > channel)
00666         {
00667                 result = ((VModule*)modules->values[channel])->render(buffer,
00668                         start_position,
00669                         PLAY_FORWARD,
00670                         frame_rate,
00671                         0,
00672                         0,
00673                         use_opengl);
00674         }
00675         else
00676         {
00677                 printf("PluginServer::read_frame no object available for channel=%d\n",
00678                         channel);
00679         }
00680 
00681 // Pop our name from the next effect stack
00682         buffer->pop_next_effect();
00683 
00684         return result;
00685 }
00686 
00687 int PluginServer::read_samples(double *buffer,
00688         int channel,
00689         int64_t sample_rate,
00690         int64_t start_position, 
00691         int64_t len)
00692 {
00693         if(!multichannel) channel = 0;
00694 
00695         if(nodes->total > channel)
00696                 return ((VirtualANode*)nodes->values[channel])->read_data(buffer,
00697                         start_position,
00698                         len,
00699                         sample_rate);
00700         else
00701         if(modules->total > channel)
00702                 return ((AModule*)modules->values[channel])->render(buffer,
00703                         start_position,
00704                         len,
00705                         PLAY_FORWARD,
00706                         sample_rate,
00707                         0);
00708         else
00709         {
00710                 printf("PluginServer::read_samples no object available for channel=%d\n",
00711                         channel);
00712         }
00713 
00714         return -1;
00715 }
00716 
00717 
00718 
00719 
00720 
00721 
00722 
00723 
00724 
00725 
00726 
00727 
00728 
00729 
00730 
00731 
00732 
00733 
00734 
00735 
00736 // Called by client
00737 int PluginServer::get_gui_status()
00738 {
00739         if(plugin)
00740                 return plugin->show ? GUI_ON : GUI_OFF;
00741         else
00742                 return GUI_OFF;
00743 }
00744 
00745 void PluginServer::raise_window()
00746 {
00747         if(!plugin_open) return;
00748         client->raise_window();
00749 }
00750 
00751 void PluginServer::show_gui()
00752 {
00753         if(!plugin_open) return;
00754         client->smp = preferences->processors - 1;
00755         if(plugin) client->total_len = plugin->length;
00756         if(plugin) client->source_start = plugin->startproject;
00757         if(video)
00758         {
00759                 client->source_position = Units::to_int64(
00760                         mwindow->edl->local_session->get_selectionstart(1) * 
00761                                 mwindow->edl->session->frame_rate);
00762         }
00763         else
00764         if(audio)
00765         {
00766                 client->source_position = Units::to_int64(
00767                         mwindow->edl->local_session->get_selectionstart(1) * 
00768                                 mwindow->edl->session->sample_rate);
00769         }
00770         client->update_display_title();
00771         client->show_gui();
00772 }
00773 
00774 void PluginServer::update_gui()
00775 {
00776         if(!plugin_open || !plugin) return;
00777 
00778         client->total_len = plugin->length;
00779         client->source_start = plugin->startproject;
00780         if(video)
00781         {
00782                 client->source_position = Units::to_int64(
00783                         mwindow->edl->local_session->get_selectionstart(1) * 
00784                                 mwindow->edl->session->frame_rate);
00785         }
00786         else
00787         if(audio)
00788         {
00789                 client->source_position = Units::to_int64(
00790                         mwindow->edl->local_session->get_selectionstart(1) * 
00791                                 mwindow->edl->session->sample_rate);
00792         }
00793         client->update_gui();
00794 }
00795 
00796 void PluginServer::update_title()
00797 {
00798         if(!plugin_open) return;
00799         
00800         client->update_display_title();
00801 }
00802 
00803 
00804 int PluginServer::set_string(char *string)
00805 {
00806         if(!plugin_open) return 0;
00807 
00808         client->set_string_client(string);
00809         return 0;
00810 }
00811 
00812 int PluginServer::gui_open()
00813 {
00814         if(attachmentpoint) return attachmentpoint->gui_open();
00815         return 0;
00816 }
00817 
00818 void PluginServer::set_use_opengl(int value, VideoDevice *vdevice)
00819 {
00820         this->use_opengl = value;
00821         this->vdevice = vdevice;
00822 }
00823 
00824 int PluginServer::get_use_opengl()
00825 {
00826         return use_opengl;
00827 }
00828 
00829 
00830 void PluginServer::run_opengl(PluginClient *plugin_client)
00831 {
00832         if(vdevice)
00833                 ((VDeviceX11*)vdevice->get_output_base())->run_plugin(plugin_client);
00834 }
00835 
00836 // ============================= queries
00837 
00838 int PluginServer::get_samplerate()
00839 {
00840         if(!plugin_open) return 0;
00841         if(audio)
00842         {
00843                 return client->get_samplerate();
00844         }
00845         else
00846         if(mwindow)
00847                 return mwindow->edl->session->sample_rate;
00848         else
00849         {
00850                 printf("PluginServer::get_samplerate audio and mwindow == NULL\n");
00851                 return 1;
00852         }
00853 }
00854 
00855 
00856 double PluginServer::get_framerate()
00857 {
00858         if(!plugin_open) return 0;
00859         if(video)
00860         {
00861                 return client->get_framerate();
00862         }
00863         else
00864         if(mwindow)
00865                 return mwindow->edl->session->frame_rate;
00866         else 
00867         {
00868                 printf("PluginServer::get_framerate video and mwindow == NULL\n");
00869                 return 1;
00870         }
00871 }
00872 
00873 int PluginServer::get_project_samplerate()
00874 {
00875         if(mwindow)
00876                 return mwindow->edl->session->sample_rate;
00877         else
00878         if(edl)
00879                 return edl->session->sample_rate;
00880         else
00881         {
00882                 printf("PluginServer::get_project_samplerate mwindow and edl are NULL.\n");
00883                 return 1;
00884         }
00885 }
00886 
00887 double PluginServer::get_project_framerate()
00888 {
00889         if(mwindow)
00890                 return mwindow->edl->session->frame_rate;
00891         else
00892         if(edl)
00893                 return edl->session->frame_rate;
00894         else
00895         {
00896                 printf("PluginServer::get_project_framerate mwindow and edl are NULL.\n");
00897                 return 1;
00898         }
00899 }
00900 
00901 
00902 
00903 int PluginServer::detach_buffers()
00904 {
00905         ring_buffers_out.remove_all();
00906         offset_out_render.remove_all();
00907         double_buffer_out_render.remove_all();
00908         realtime_out_size.remove_all();
00909 
00910         ring_buffers_in.remove_all();
00911         offset_in_render.remove_all();
00912         double_buffer_in_render.remove_all();
00913         realtime_in_size.remove_all();
00914         
00915         out_buffer_size = 0;
00916         shared_buffers = 0;
00917         total_out_buffers = 0;
00918         in_buffer_size = 0;
00919         total_in_buffers = 0;
00920         return 0;
00921 }
00922 
00923 int PluginServer::arm_buffer(int buffer_number, 
00924                 int64_t offset_in, 
00925                 int64_t offset_out,
00926                 int double_buffer_in,
00927                 int double_buffer_out)
00928 {
00929         offset_in_render.values[buffer_number] = offset_in;
00930         offset_out_render.values[buffer_number] = offset_out;
00931         double_buffer_in_render.values[buffer_number] = double_buffer_in;
00932         double_buffer_out_render.values[buffer_number] = double_buffer_out;
00933 }
00934 
00935 
00936 int PluginServer::set_automation(FloatAutos *autos, FloatAuto **start_auto, FloatAuto **end_auto, int reverse)
00937 {
00938         this->autos = autos;
00939         this->start_auto = start_auto;
00940         this->end_auto = end_auto;
00941         this->reverse = reverse;
00942 }
00943 
00944 
00945 
00946 void PluginServer::save_data(KeyFrame *keyframe)
00947 {
00948         if(!plugin_open) return;
00949         client->save_data(keyframe);
00950 }
00951 
00952 KeyFrame* PluginServer::get_prev_keyframe(int64_t position)
00953 {
00954         KeyFrame *result = 0;
00955         if(plugin)
00956                 result = plugin->get_prev_keyframe(position, client->direction);
00957         else
00958                 result = keyframe;
00959         return result;
00960 }
00961 
00962 KeyFrame* PluginServer::get_next_keyframe(int64_t position)
00963 {
00964         KeyFrame *result = 0;
00965         if(plugin)
00966                 result = plugin->get_next_keyframe(position, client->direction);
00967         else
00968                 result = keyframe;
00969         return result;
00970 }
00971 
00972 KeyFrame* PluginServer::get_keyframe()
00973 {
00974         if(plugin)
00975                 return plugin->get_keyframe();
00976         else
00977                 return keyframe;
00978 }
00979 
00980 void PluginServer::get_camera(float *x, float *y, float *z,
00981         int64_t position, int direction)
00982 {
00983         plugin->track->automation->get_camera(x, y, z, position, direction);
00984 }
00985 
00986 void PluginServer::get_projector(float *x, float *y, float *z,
00987         int64_t position, int direction)
00988 {
00989         plugin->track->