00001 #include "attachmentpoint.h"
00002 #include "filexml.h"
00003 #include "edl.h"
00004 #include "edlsession.h"
00005 #include "mwindow.h"
00006 #include "plugin.h"
00007 #include "pluginserver.h"
00008 #include "renderengine.h"
00009 #include "transportque.h"
00010 #include "virtualnode.h"
00011
00012
00013
00014 AttachmentPoint::AttachmentPoint(RenderEngine *renderengine,
00015 Plugin *plugin,
00016 int data_type)
00017 {
00018 reset_parameters();
00019 this->plugin = plugin;
00020 this->plugin_id = plugin->id;
00021 this->renderengine = renderengine;
00022 this->data_type = data_type;
00023 plugin_server = renderengine->scan_plugindb(plugin->title,
00024 data_type);
00025 }
00026
00027 AttachmentPoint::~AttachmentPoint()
00028 {
00029 delete_buffer_vector();
00030 plugin_servers.remove_all_objects();
00031 }
00032
00033
00034 int AttachmentPoint::reset_parameters()
00035 {
00036 plugin_server = 0;
00037 reset_status();
00038 return 0;
00039 }
00040
00041
00042 void AttachmentPoint::reset_status()
00043 {
00044 if(!this) printf("AttachmentPoint::reset_status NULL\n");
00045 start_position = 0;
00046 len = 0;
00047 sample_rate = 0;
00048 frame_rate = 0;
00049 is_processed = 0;
00050 }
00051
00052
00053 int AttachmentPoint::identical(AttachmentPoint *old)
00054 {
00055 return plugin_id == old->plugin_id;
00056 }
00057
00058
00059 int AttachmentPoint::render_init()
00060 {
00061 if(!this) printf("AttachmentPoint::render_init NULL\n");
00062 if(plugin_server && plugin->on)
00063 {
00064
00065
00066
00067 if(virtual_plugins.total != new_virtual_plugins.total)
00068 {
00069 plugin_servers.remove_all_objects();
00070 for(int i = 0; i < new_virtual_plugins.total; i++)
00071 {
00072 if(i == 0 || !plugin_server->multichannel)
00073 {
00074 PluginServer *new_server;
00075 plugin_servers.append(new_server = new PluginServer(*plugin_server));
00076 new_server->set_attachmentpoint(this);
00077 plugin_servers.values[i]->open_plugin(0,
00078 renderengine->preferences,
00079 renderengine->edl,
00080 plugin,
00081 -1);
00082 plugin_servers.values[i]->init_realtime(
00083 renderengine->edl->session->real_time_playback &&
00084 renderengine->command->realtime,
00085 plugin_server->multichannel ? new_virtual_plugins.total : 1,
00086 get_buffer_size());
00087 }
00088 }
00089 }
00090
00091
00092 if(plugin_server->multichannel && plugin_servers.total)
00093 {
00094 PluginServer *new_server = plugin_servers.values[0];
00095 new_server->reset_nodes();
00096 for(int i = 0; i < new_virtual_plugins.total; i++)
00097 {
00098 new_server->append_node(new_virtual_plugins.values[i]);
00099 }
00100 }
00101 else
00102 {
00103 for(int i = 0; i < new_virtual_plugins.total; i++)
00104 {
00105 PluginServer *new_server = plugin_servers.values[i];
00106 new_server->reset_nodes();
00107 new_server->append_node(new_virtual_plugins.values[i]);
00108 }
00109 }
00110 }
00111
00112
00113 delete_buffer_vector();
00114 virtual_plugins.remove_all();
00115
00116
00117 for(int i = 0; i < new_virtual_plugins.total; i++)
00118 virtual_plugins.append(new_virtual_plugins.values[i]);
00119 new_virtual_plugins.remove_all();
00120
00121
00122 return 0;
00123 }
00124
00125 int AttachmentPoint::render_stop(int duplicate)
00126 {
00127 if(!this) printf("AttachmentPoint::render_stop NULL\n");
00128
00129
00130 if(plugin_server && plugin->on && virtual_plugins.total && !duplicate)
00131 {
00132
00133 for(int i = 0; i < virtual_plugins.total; i++)
00134 {
00135 if(i == 0 || !plugin_server->multichannel)
00136 {
00137 plugin_servers.values[i]->close_plugin();
00138 }
00139 }
00140 plugin_servers.remove_all_objects();
00141 }
00142 return 0;
00143 }
00144
00145 int AttachmentPoint::attach_virtual_plugin(VirtualNode *virtual_plugin)
00146 {
00147 if(!this) printf("AttachmentPoint::attach_virtual_plugin NULL\n");
00148 int buffer_number = 0;
00149
00150 if(plugin_server && plugin->on)
00151 {
00152
00153 new_virtual_plugins.append(virtual_plugin);
00154
00155
00156
00157 buffer_number = new_virtual_plugins.total - 1;
00158 }
00159 else
00160 if(!plugin->on)
00161 {
00162 printf("AttachmentPoint::attach_virtual_plugin attempt to attach plugin when off.\n");
00163 }
00164 else
00165 if(!plugin_server)
00166 {
00167 printf("AttachmentPoint::attach_virtual_plugin attempt to attach when no plugin_server.\n");
00168 }
00169
00170 return buffer_number;
00171 }
00172
00173 int AttachmentPoint::multichannel_shared(int search_new)
00174 {
00175 if(!this) printf("AttachmentPoint::multichannel_shared NULL\n");
00176 if(search_new)
00177 {
00178 if(new_virtual_plugins.total &&
00179 plugin_server &&
00180 plugin_server->multichannel) return 1;
00181 }
00182 else
00183 {
00184 if(virtual_plugins.total &&
00185 plugin_server &&
00186 plugin_server->multichannel) return 1;
00187 }
00188 return 0;
00189 }
00190
00191 int AttachmentPoint::singlechannel()
00192 {
00193 if(!this) printf("AttachmentPoint::singlechannel NULL\n");
00194 if(plugin_server && !plugin_server->multichannel) return 1;
00195 return 0;
00196 }
00197
00198
00199 void AttachmentPoint::render_gui(void *data)
00200 {
00201 if(!this) printf("AttachmentPoint::render_gui 1 NULL\n");
00202 if(renderengine && renderengine->mwindow)
00203 renderengine->mwindow->render_plugin_gui(data, plugin);
00204 }
00205
00206 void AttachmentPoint::render_gui(void *data, int size)
00207 {
00208 if(!this) printf("AttachmentPoint::render_gui 2 NULL\n");
00209 if(renderengine && renderengine->mwindow)
00210 renderengine->mwindow->render_plugin_gui(data, size, plugin);
00211 }
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225 int AttachmentPoint::dump()
00226 {
00227 if(this)
00228 {
00229 printf(" Attachmentpoint %x virtual_plugins=%d\n", this, new_virtual_plugins.total);
00230 if(plugin_server) plugin_server->dump();
00231 }
00232 else
00233 {
00234 printf(" No Plugin\n");
00235 }
00236 }
00237
00238
00239
00240