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 void AttachmentPoint::render_stop()
00126 {
00127 if(plugin_server && plugin->on)
00128 {
00129 for(int i = 0; i < plugin_servers.total; i++)
00130 {
00131 plugin_servers.values[i]->render_stop();
00132 }
00133 }
00134 }
00135
00136 int AttachmentPoint::attach_virtual_plugin(VirtualNode *virtual_plugin)
00137 {
00138 if(!this) printf("AttachmentPoint::attach_virtual_plugin NULL\n");
00139 int buffer_number = 0;
00140
00141 if(plugin_server && plugin->on)
00142 {
00143
00144 new_virtual_plugins.append(virtual_plugin);
00145
00146
00147
00148 buffer_number = new_virtual_plugins.total - 1;
00149 }
00150 else
00151 if(!plugin->on)
00152 {
00153 printf("AttachmentPoint::attach_virtual_plugin attempt to attach plugin when off.\n");
00154 }
00155 else
00156 if(!plugin_server)
00157 {
00158 printf("AttachmentPoint::attach_virtual_plugin attempt to attach when no plugin_server.\n");
00159 }
00160
00161 return buffer_number;
00162 }
00163
00164 int AttachmentPoint::multichannel_shared(int search_new)
00165 {
00166 if(!this) printf("AttachmentPoint::multichannel_shared NULL\n");
00167 if(search_new)
00168 {
00169 if(new_virtual_plugins.total &&
00170 plugin_server &&
00171 plugin_server->multichannel) return 1;
00172 }
00173 else
00174 {
00175 if(virtual_plugins.total &&
00176 plugin_server &&
00177 plugin_server->multichannel) return 1;
00178 }
00179 return 0;
00180 }
00181
00182 int AttachmentPoint::singlechannel()
00183 {
00184 if(!this) printf("AttachmentPoint::singlechannel NULL\n");
00185 if(plugin_server && !plugin_server->multichannel) return 1;
00186 return 0;
00187 }
00188
00189
00190 void AttachmentPoint::render_gui(void *data)
00191 {
00192 if(!this) printf("AttachmentPoint::render_gui 1 NULL\n");
00193 if(renderengine && renderengine->mwindow)
00194 renderengine->mwindow->render_plugin_gui(data, plugin);
00195 }
00196
00197 void AttachmentPoint::render_gui(void *data, int size)
00198 {
00199 if(!this) printf("AttachmentPoint::render_gui 2 NULL\n");
00200 if(renderengine && renderengine->mwindow)
00201 renderengine->mwindow->render_plugin_gui(data, size, plugin);
00202 }
00203
00204 int AttachmentPoint::gui_open()
00205 {
00206 if(renderengine && renderengine->mwindow)
00207 return renderengine->mwindow->plugin_gui_open(plugin);
00208 return 0;
00209 }
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221 int AttachmentPoint::dump()
00222 {
00223 if(this)
00224 {
00225 printf(" Attachmentpoint %x virtual_plugins=%d\n", this, new_virtual_plugins.total);
00226 if(plugin_server) plugin_server->dump();
00227 }
00228 else
00229 {
00230 printf(" No Plugin\n");
00231 }
00232 }
00233
00234
00235
00236