r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / virtualnode.h
blob498569e44135efb5c568b0b1b26e6d8b16f6f00c
1 #ifndef VIRTUALNODE_H
2 #define VIRTUALNODE_H
4 #include "arraylist.h"
5 #include "auto.inc"
6 #include "autos.inc"
7 #include "floatauto.inc"
8 #include "floatautos.inc"
9 #include "mwindow.inc"
10 #include "maxbuffers.h"
11 #include "patch.h"
12 #include "plugin.inc"
13 #include "pluginserver.inc"
14 #include "track.inc"
15 #include "transition.inc"
16 #include "virtualconsole.inc"
18 // The virtual node makes up the virtual console.
19 // It can be either a virtual module or a virtual plugin.
22 class VirtualNode
24 public:
25 VirtualNode(RenderEngine *renderengine,
26 VirtualConsole *vconsole,
27 Module *real_module,
28 Plugin *real_plugin,
29 Track *track,
30 VirtualNode *parent_module,
31 int input_is_master,
32 int output_is_master,
33 int in,
34 int out);
36 virtual ~VirtualNode();
37 void dump(int indent);
39 // derived node creates buffers here
40 virtual void new_output_buffer() { };
41 virtual void new_input_buffer() { };
44 // expand plugins
45 int expand(int persistant_plugins, int64_t current_position);
46 // create buffers and convenience pointers
47 int expand_buffers();
48 // create convenience pointers to shared memory depending on the data type
49 virtual int create_buffer_ptrs() {};
50 // create a node for a module
51 int attach_virtual_module(Plugin *plugin,
52 int plugin_number,
53 int duplicate,
54 int64_t current_position);
55 // create a node for a plugin
56 int attach_virtual_plugin(Plugin *plugin,
57 int plugin_number,
58 int duplicate,
59 int64_t current_position);
60 virtual VirtualNode* create_module(Plugin *real_plugin,
61 Module *real_module,
62 Track *track) { return 0; };
63 virtual VirtualNode* create_plugin(Plugin *real_plugin) { return 0; };
65 int render_as_plugin(int64_t source_len,
66 int64_t source_position,
67 int ring_buffer,
68 int64_t fragment_position,
69 int64_t fragment_len);
71 int get_plugin_input(int &double_buffer_in, int64_t &fragment_position_in,
72 int &double_buffer_out, int64_t &fragment_position_out,
73 int double_buffer, int64_t fragment_position);
75 // Get the order to render modules and plugins attached to this.
76 // Return 1 if not completed after this pass.
77 int sort(ArrayList<VirtualNode*>*render_list);
79 // virtual plugins this module owns
80 ArrayList<VirtualNode*> vplugins;
81 // Attachment point in Module if this is a virtual plugin
82 AttachmentPoint *attachment;
84 VirtualConsole *vconsole;
85 // module which created this node.
86 VirtualNode *parent_module;
87 // use these to determine if this node is a plugin or module
88 // Top level virtual node of module
89 Module *real_module;
90 // When this node is a plugin. Redirected to the shared plugin in expansion.
91 Plugin *real_plugin;
94 Track *track;
95 RenderEngine *renderengine;
97 // for rendering need to know if the buffer is a master or copy
98 // These are set in expand()
99 int input_is_master;
100 int output_is_master;
101 int ring_buffers; // number of buffers for master buffers
102 int64_t buffer_size; // number of units in a master segment
103 int64_t fragment_size; // number of units in a node segment
104 int plugin_type; // type of plugin in case user changes it
105 int render_count; // times this plugin has been added to the render list
106 int waiting_real_plugin; // real plugin tests this to see if virtual plugin is waiting on it when sorting
107 // for deleting need to know if buffers are owned by someone else
108 int shared_input;
109 int shared_output;
110 // where this node should get its input and output from
111 int in;
112 int out;
113 // module needs to know where the input data for the next process is
114 int data_in_input;
115 // plugin needs to know what buffer number each fragment position corresponds to
116 int plugin_buffer_number;
118 // Mute automation.
119 // Return whether the next samples are muted and store the duration
120 // of the next status in fragment_len
121 void get_mute_fragment(int64_t input_position,
122 int &mute_constant,
123 int64_t &fragment_len,
124 Autos *autos);
126 // convenience routines for fade automation
127 void get_fade_automation(double &slope,
128 double &intercept,
129 int64_t input_position,
130 int64_t &slope_len,
131 Autos *autos);
132 void get_pan_automation(double &slope,
133 double &intercept,
134 int64_t input_position,
135 int64_t &slope_len,
136 Autos *autos,
137 int channel);
139 int init_automation(int &automate,
140 double &constant,
141 int64_t input_position,
142 int64_t buffer_len,
143 Autos *autos,
144 Auto **before,
145 Auto **after);
147 int init_slope(Autos *autos, Auto **before, Auto **after);
148 int get_slope(Autos *autos, int64_t buffer_len, int64_t buffer_position);
149 int advance_slope(Autos *autos);
151 protected:
153 // ======================= plugin automation
154 FloatAutos *plugin_autos;
155 FloatAuto *plugin_auto_before, *plugin_auto_after;
157 // temporary variables for automation
158 Auto *current_auto;
159 double slope_value;
160 double slope_start;
161 double slope_end;
162 double slope_position;
163 double slope;
164 double value;
166 int reverse; // Temporary set for each render
167 int64_t input_start, input_end;
168 int64_t buffer_position; // position in both input and output buffer
170 private:
171 int sort_as_module(ArrayList<VirtualNode*>*render_list, int &result, int &total_result);
172 int sort_as_plugin(ArrayList<VirtualNode*>*render_list, int &result, int &total_result);
173 int expand_as_module(int duplicate, int64_t current_position);
174 int expand_as_plugin(int duplicate);
179 #endif