1 #include "attachmentpoint.h"
3 #include "commonrender.h"
5 #include "edlsession.h"
12 #include "pluginarray.h"
13 #include "pluginserver.h"
14 #include "renderengine.h"
15 #include "sharedlocation.h"
18 #include "transportque.h"
21 Module::Module(RenderEngine *renderengine,
22 CommonRender *commonrender,
23 PluginArray *plugin_array,
26 this->renderengine = renderengine;
27 this->commonrender = commonrender;
28 this->plugin_array = plugin_array;
31 transition_server = 0;
33 total_attachments = 0;
34 new_total_attachments = 0;
42 for(int i = 0; i < track->plugin_set.total; i++)
46 // For some reason it isn't used here.
47 // attachments[i]->render_stop(0);
48 delete attachments[i];
51 delete [] attachments;
55 transition_server->close_plugin();
56 delete transition_server;
60 void Module::create_objects()
62 create_new_attachments();
66 EDL* Module::get_edl()
69 return renderengine->edl;
74 void Module::create_new_attachments()
76 // Not used in pluginarray
79 new_total_attachments = track->plugin_set.total;
80 if(new_total_attachments)
82 new_attachments = new AttachmentPoint*[new_total_attachments];
83 for(int i = 0; i < new_total_attachments; i++)
86 track->get_current_plugin(commonrender->current_position,
88 renderengine->command->get_direction(),
92 if(plugin && plugin->plugin_type != PLUGIN_NONE && plugin->on)
93 new_attachments[i] = new_attachment(plugin);
95 new_attachments[i] = 0;
101 // Create plugin servers in virtual console expansion
105 void Module::swap_attachments()
107 // None of this is used in a pluginarray
109 i < new_total_attachments &&
110 i < total_attachments;
113 // Delete new attachment which is identical to the old one and copy
115 if(new_attachments[i] &&
117 new_attachments[i]->identical(attachments[i]))
119 delete new_attachments[i];
120 new_attachments[i] = attachments[i];
125 // Delete old attachments which weren't identical to new ones
126 for(int i = 0; i < total_attachments; i++)
128 if(attachments[i]) delete attachments[i];
133 delete [] attachments;
136 attachments = new_attachments;
137 total_attachments = new_total_attachments;
140 int Module::render_init()
142 for(int i = 0; i < total_attachments; i++)
145 attachments[i]->render_init();
151 AttachmentPoint* Module::attachment_of(Plugin *plugin)
153 //printf("Module::attachment_of 1 %d\n", total_attachments);
154 for(int i = 0; i < total_attachments; i++)
156 //printf("Module::attachment_of 2 %p\n", attachments[i]);
158 attachments[i]->plugin == plugin) return attachments[i];
163 AttachmentPoint* Module::get_attachment(int number)
165 if(number < total_attachments)
166 return attachments[number];
171 void Module::reset_attachments()
173 //printf("Module::reset_attachments 1 %d\n", total_attachments);
174 for(int i = 0; i < total_attachments; i++)
176 //printf("Module::reset_attachments 2 %p\n", attachments[i]);
177 AttachmentPoint *attachment = attachments[i];
178 if(attachment) attachment->reset_status();
182 // Test plugins for reconfiguration.
184 int Module::test_plugins()
186 if(total_attachments != track->plugin_set.total) return 1;
188 for(int i = 0; i < total_attachments; i++)
190 AttachmentPoint *attachment = attachments[i];
191 Plugin *plugin = track->get_current_plugin(
192 commonrender->current_position,
194 renderengine->command->get_direction(),
197 // One exists and one doesn't
198 int use_plugin = plugin &&
199 plugin->plugin_type != PLUGIN_NONE &&
202 if((attachment && !use_plugin) ||
203 (!attachment && use_plugin)) return 1;
205 // Plugin not the same
208 attachment->plugin &&
209 !plugin->identical(attachment->plugin)) return 1;
215 void Module::update_transition(int64_t current_position,
219 transition = track->get_current_transition(current_position,
222 0); // position is already nudged in amodule.C and vmodule.C before calling update_transition!
225 // for situations where we had transition and have no more, we keep the server open:
226 // maybe the same transition will follow and we won't need to reinit... (happens a lot while scrubbing over transitions left and right)
227 // if((prev_transition && !transition) ||
228 if ((transition && transition_server && strcmp(transition->title, transition_server->plugin->title)))
230 transition_server->close_plugin();
231 delete transition_server;
232 transition_server = 0;
236 if(transition && !transition_server)
242 PluginServer *plugin_server = renderengine->scan_plugindb(transition->title,
244 transition_server = new PluginServer(*plugin_server);
245 transition_server->open_plugin(0,
246 renderengine->preferences,
250 transition_server->init_realtime(
251 get_edl()->session->real_time_playback &&
252 renderengine->command->realtime,
260 PluginServer *plugin_server = plugin_array->scan_plugindb(transition->title);
262 transition_server = new PluginServer(*plugin_server);
264 transition_server->open_plugin(0,
265 plugin_array->mwindow->preferences,
270 transition_server->init_realtime(
282 printf(" Module title=%s\n", track->title);
283 printf(" Plugins total_attachments=%d\n", total_attachments);
284 for(int i = 0; i < total_attachments; i++)
286 attachments[i]->dump();