1 #include "attachmentpoint.h"
3 #include "automation.h"
6 #include "floatautos.h"
15 #include "pluginserver.h"
16 #include "renderengine.h"
18 #include "transition.h"
19 #include "transportque.h"
20 #include "virtualconsole.h"
21 #include "virtualnode.h"
23 VirtualNode::VirtualNode(RenderEngine *renderengine,
24 VirtualConsole *vconsole,
28 VirtualNode *parent_node)
30 this->renderengine = renderengine;
31 this->vconsole = vconsole;
32 this->real_module = real_module;
33 this->real_plugin = real_plugin;
35 this->parent_node = parent_node;
38 waiting_real_plugin = 0;
39 plugin_buffer_number = 0;
41 plugin_auto_before = plugin_auto_after = 0;
44 //printf("VirtualNode::VirtualNode 1\n");
47 VirtualNode::~VirtualNode()
49 subnodes.remove_all_objects();
50 //printf("VirtualNode::VirtualNode 2\n");
53 #define PRINT_INDENT for(int j = 0; j < indent; j++) printf(" ");
55 void VirtualNode::dump(int indent)
58 printf("VirtualNode %p title=%s real_module=%p %s\n",
66 printf(" Plugins total=%d\n", subnodes.total);
67 for(int i = 0; i < subnodes.total; i++)
69 subnodes.values[i]->dump(indent + 2);
75 printf(" Plugin %s\n", real_plugin->title);
79 int VirtualNode::expand(int persistent_plugins, int64_t current_position)
81 // module needs to know where the input data for the next process is
84 expand_as_module(persistent_plugins, current_position);
89 // attach to a real plugin for a plugin
90 // plugin always takes data from input to output
91 expand_as_plugin(persistent_plugins);
97 int VirtualNode::expand_as_module(int duplicate, int64_t current_position)
99 Transition *transition = 0;
101 // create the plugins for this module
102 for(int i = 0; i < track->plugin_set.total; i++)
104 Plugin *plugin = track->get_current_plugin(current_position,
106 renderengine->command->get_direction(),
110 // Switch off if circular reference. This happens if a plugin set or a track is deleted.
111 if(plugin == real_plugin) continue;
114 if(plugin && plugin->on)
116 int plugin_type = plugin->plugin_type;
117 if(plugin_type == PLUGIN_SHAREDMODULE)
119 // plugin is a module
120 attach_virtual_module(plugin,
126 if(plugin_type == PLUGIN_SHAREDPLUGIN ||
127 plugin_type == PLUGIN_STANDALONE)
129 // plugin is a plugin
130 attach_virtual_plugin(plugin,
139 if(!parent_node) vconsole->append_exit_node(this);
144 int VirtualNode::expand_as_plugin(int duplicate)
146 plugin_type = real_plugin->plugin_type;
148 if(plugin_type == PLUGIN_SHAREDPLUGIN)
150 // Attached to a shared plugin.
151 // Get the real real plugin it's attached to.
153 // Redirect the real_plugin to the shared plugin.
154 int real_module_number = real_plugin->shared_location.module;
155 int real_plugin_number = real_plugin->shared_location.plugin;
156 Module *real_module = vconsole->module_number(real_module_number);
158 // module references are absolute so may get the wrong data type track.
161 attachment = real_module->get_attachment(real_plugin_number);
162 // Attachment is NULL if off
165 real_plugin = attachment->plugin;
167 // Real plugin not on then null it.
168 if(!real_plugin || !real_plugin->on) real_plugin = 0;
178 if(plugin_type == PLUGIN_STANDALONE)
181 Module *module = vconsole->module_of(track);
183 attachment = module->attachment_of(real_plugin);
190 // Add to real plugin's list of virtual plugins for configuration updates
191 // and plugin_server initializations.
192 // Input and output are taken care of when the parent module creates this plugin.
193 // Get number for passing to render.
194 // real_plugin may become NULL after shared plugin test.
195 if(real_plugin && attachment)
198 plugin_buffer_number = attachment->attach_virtual_plugin(this);
207 int VirtualNode::attach_virtual_module(Plugin *plugin,
210 int64_t current_position)
214 int real_module_number = plugin->shared_location.module;
215 Module *real_module = vconsole->module_number(real_module_number);
216 // If a track is deleted real_module is not found
217 if(!real_module) return 1;
219 Track *track = real_module->track;
221 // Switch off if circular reference. This happens if a track is deleted.
222 if(this->real_module && track == this->real_module->track) return 1;
227 VirtualNode *virtual_module = create_module(plugin,
231 subnodes.append(virtual_module);
232 virtual_module->expand(duplicate, current_position);
238 int VirtualNode::attach_virtual_plugin(Plugin *plugin,
241 int64_t current_position)
243 // Get real plugin and test if it is on.
245 if(plugin->plugin_type == PLUGIN_SHAREDPLUGIN)
247 int real_module_number = plugin->shared_location.module;
248 int real_plugin_number = plugin->shared_location.plugin;
249 Module *real_module = vconsole->module_number(real_module_number);
252 AttachmentPoint *attachment = real_module->get_attachment(real_plugin_number);
255 Plugin *real_plugin = attachment->plugin;
256 if(!real_plugin || !real_plugin->on)
268 VirtualNode *virtual_plugin = create_plugin(plugin);
269 subnodes.append(virtual_plugin);
270 virtual_plugin->expand(duplicate, current_position);
275 VirtualNode* VirtualNode::get_previous_plugin(VirtualNode *current_node)
277 for(int i = 0; i < subnodes.total; i++)
279 // Assume plugin is on
280 if(subnodes.values[i] == current_node)
283 return subnodes.values[i - 1];
293 void VirtualNode::get_mute_fragment(int64_t input_position,
300 if(use_nudge) input_position += track->nudge;
302 IntAuto *prev_keyframe = 0;
303 IntAuto *next_keyframe = 0;
304 prev_keyframe = (IntAuto*)autos->get_prev_auto(input_position,
306 (Auto* &)prev_keyframe);
307 next_keyframe = (IntAuto*)autos->get_next_auto(input_position,
309 (Auto* &)next_keyframe);
311 if(direction == PLAY_FORWARD)
313 // Two distinct keyframes within range
314 if(next_keyframe->position > prev_keyframe->position)
316 mute_constant = prev_keyframe->value;
318 if(next_keyframe->position < input_position + fragment_len)
319 fragment_len = next_keyframe->position - input_position;
322 // One keyframe within range
324 mute_constant = prev_keyframe->value;
329 // Two distinct keyframes within range
330 if(next_keyframe->position < prev_keyframe->position)
332 mute_constant = next_keyframe->value;
334 if(next_keyframe->position > input_position - fragment_len)
335 fragment_len = input_position - next_keyframe->position;
338 // One keyframe within range
340 mute_constant = next_keyframe->value;