1 #include "attachmentpoint.h"
2 #include "commonrender.h"
4 #include "edlsession.h"
11 #include "pluginarray.h"
12 #include "pluginserver.h"
13 #include "renderengine.h"
14 #include "sharedlocation.h"
17 #include "transportque.h"
20 Module::Module(RenderEngine *renderengine,
21 CommonRender *commonrender,
22 PluginArray *plugin_array,
25 this->renderengine = renderengine;
26 this->commonrender = commonrender;
27 this->plugin_array = plugin_array;
30 transition_server = 0;
32 total_attachments = 0;
33 new_total_attachments = 0;
41 for(int i = 0; i < track->plugin_set.total; i++)
45 // For some reason it isn't used here.
46 // attachments[i]->render_stop(0);
47 delete attachments[i];
50 delete [] attachments;
54 transition_server->close_plugin();
55 delete transition_server;
59 void Module::create_objects()
61 create_new_attachments();
65 EDL* Module::get_edl()
68 return renderengine->edl;
73 void Module::create_new_attachments()
75 // Not used in pluginarray
78 new_total_attachments = track->plugin_set.total;
79 if(new_total_attachments)
81 new_attachments = new AttachmentPoint*[new_total_attachments];
82 for(int i = 0; i < new_total_attachments; i++)
85 track->get_current_plugin(commonrender->current_position,
87 renderengine->command->get_direction(),
91 if(plugin && plugin->plugin_type != PLUGIN_NONE && plugin->on)
92 new_attachments[i] = new_attachment(plugin);
94 new_attachments[i] = 0;
100 // Create plugin servers in virtual console expansion
104 void Module::swap_attachments()
106 // None of this is used in a pluginarray
108 i < new_total_attachments &&
109 i < total_attachments;
112 // Delete new attachment which is identical to the old one and copy
114 if(new_attachments[i] &&
116 new_attachments[i]->identical(attachments[i]))
118 delete new_attachments[i];
119 new_attachments[i] = attachments[i];
124 // Delete old attachments which weren't identical to new ones
125 for(int i = 0; i < total_attachments; i++)
127 if(attachments[i]) delete attachments[i];
132 delete [] attachments;
135 attachments = new_attachments;
136 total_attachments = new_total_attachments;
139 int Module::render_init()
141 for(int i = 0; i < total_attachments; i++)
144 attachments[i]->render_init();
150 AttachmentPoint* Module::attachment_of(Plugin *plugin)
152 //printf("Module::attachment_of 1 %d\n", total_attachments);
153 for(int i = 0; i < total_attachments; i++)
155 //printf("Module::attachment_of 2 %p\n", attachments[i]);
157 attachments[i]->plugin == plugin) return attachments[i];
162 void Module::reset_attachments()
164 //printf("Module::reset_attachments 1 %d\n", total_attachments);
165 for(int i = 0; i < total_attachments; i++)
167 //printf("Module::reset_attachments 2 %p\n", attachments[i]);
168 AttachmentPoint *attachment = attachments[i];
169 if(attachment) attachment->reset_status();
173 // Test plugins for reconfiguration.
175 int Module::test_plugins()
177 if(total_attachments != track->plugin_set.total) return 1;
179 for(int i = 0; i < total_attachments; i++)
181 AttachmentPoint *attachment = attachments[i];
182 Plugin *plugin = track->get_current_plugin(
183 commonrender->current_position,
185 renderengine->command->get_direction(),
188 // One exists and one doesn't
189 int use_plugin = plugin &&
190 plugin->plugin_type != PLUGIN_NONE &&
193 if((attachment && !use_plugin) ||
194 (!attachment && use_plugin)) return 1;
196 // Plugin not the same
199 attachment->plugin &&
200 !plugin->identical(attachment->plugin)) return 1;
206 void Module::update_transition(int64_t current_position,
209 Plugin *transition = track->get_current_transition(current_position,
212 0); // position is already nudged in amodule.C and vmodule.C before calling update_transition!
214 if((!transition && this->transition) ||
215 (transition && this->transition && strcmp(transition->title, this->transition->title)))
217 this->transition = 0;
219 transition_server->close_plugin();
220 delete transition_server;
221 transition_server = 0;
224 if(transition && !this->transition)
226 this->transition = transition;
230 PluginServer *plugin_server = renderengine->scan_plugindb(transition->title,
232 transition_server = new PluginServer(*plugin_server);
233 transition_server->open_plugin(0,
234 renderengine->preferences,
238 transition_server->init_realtime(
239 get_edl()->session->real_time_playback &&
240 renderengine->command->realtime,
247 PluginServer *plugin_server = plugin_array->scan_plugindb(transition->title);
248 transition_server = new PluginServer(*plugin_server);
249 transition_server->open_plugin(0,
250 plugin_array->mwindow->preferences,
254 transition_server->init_realtime(
265 printf(" Module title=%s\n", track->title);
266 printf(" Plugins total_attachments=%d\n", total_attachments);
267 for(int i = 0; i < total_attachments; i++)
269 attachments[i]->dump();