fix awdw solo vicon crash, fix nested clip for binfolders, open edit edl
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / renderengine.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef RENDERENGINE_H
23 #define RENDERENGINE_H
24
25
26 class RenderEngine;
27
28 #include "arender.inc"
29 #include "audiodevice.inc"
30 #include "bctimer.h"
31 #include "cache.inc"
32 #include "canvas.inc"
33 #include "channel.inc"
34 #include "channeldb.inc"
35 #include "condition.inc"
36 #include "mutex.inc"
37 #include "mwindow.inc"
38 #include "playbackengine.inc"
39 #include "pluginserver.inc"
40 #include "preferences.inc"
41 #include "thread.h"
42 #include "transportque.inc"
43 #include "videodevice.inc"
44 #include "vrender.inc"
45
46 class RenderEngine : public Thread
47 {
48 public:
49         RenderEngine(PlaybackEngine *playback_engine,
50                 Preferences *preferences,
51                 Canvas *output,
52                 int is_nested);
53         ~RenderEngine();
54
55         void get_duty();
56         void create_render_threads();
57         void arm_render_threads();
58         void start_render_threads();
59         void wait_render_threads();
60         void interrupt_playback();
61         void wait_done();
62         int get_output_w();
63         int get_output_h();
64         int brender_available(int position, int direction);
65         double get_tracking_position();
66         CICache* get_acache();
67         CICache* get_vcache();
68         void set_acache(CICache *cache);
69         void set_vcache(CICache *cache);
70 // Get levels for tracking
71         void get_output_levels(double *levels, int64_t position);
72         void get_module_levels(ArrayList<double> *module_levels, int64_t position);
73         EDL* get_edl();
74
75         void run();
76 // Sends the command sequence, compensating for network latency
77         int arm_command(TransportCommand *command);
78 // Start the command
79         int start_command();
80
81         int open_output();
82         int close_output();
83 // return position to synchronize video against
84         int64_t sync_position();
85 // Called by VRender to reset the timers once the first frame is done.
86         void reset_sync_position();
87
88 // Update preferences window
89         void update_framerate(float framerate);
90 // update canvas scope gui
91         void update_scope(VFrame *frame);
92
93 // Copy of command
94         TransportCommand *command;
95 // Pointer to playback config for one head
96         PlaybackConfig *config;
97 // Defined only for the master render engine
98         PlaybackEngine *playback_engine;
99 // Copy of preferences
100         Preferences *preferences;
101 // Canvas if being used for CWindow
102         Canvas *output;
103
104 // Lock out new commands until completion
105         Condition *input_lock;
106 // Lock out interrupts until started
107         Condition *start_lock;
108         Condition *output_lock;
109         Condition *render_active;
110 // Lock out audio and synchronization timers until first frame is done
111         Condition *first_frame_lock;
112 // Lock out interrupts before and after renderengine is active
113         Condition *interrupt_lock;
114
115         int done;
116         int is_nested;
117 // If nested, the devices are owned by someone else
118         AudioDevice *audio;
119         VideoDevice *video;
120         ARender *arender;
121         VRender *vrender;
122         int do_audio;
123         int do_video;
124 // Timer for synchronization without audio
125         Timer timer;
126 // If the termination came from interrupt or end of selection
127         int interrupted;
128
129 // Samples in audio buffer to process
130         int64_t fragment_len;
131 // Samples to send to audio device after speed adjustment
132         int64_t adjusted_fragment_len;
133 // CICaches for use if no playbackengine exists
134         CICache *audio_cache, *video_cache;
135
136
137 // constructing with an audio device forces output buffer allocation
138 // constructing without an audio device puts in one buffer at a time mode
139         RenderEngine(MWindow *mwindow,
140                 AudioDevice *audio = 0,
141                 VideoDevice *video = 0,
142                 PlaybackEngine *playbackengine = 0);
143
144         void reset_parameters();
145
146 // buffersize is in samples
147         void arm_playback_audio(int64_t input_length,
148                         int64_t amodule_render_fragment,
149                         int64_t playback_buffer,
150                         int64_t output_length);
151
152         void arm_playback_video(int every_frame,
153                         int64_t read_length,
154                         int64_t output_length,
155                         int track_w,
156                         int track_h,
157                         int output_w,
158                         int output_h);
159
160 // start video since vrender is the master
161         void start_video();
162
163
164 // information for playback
165         int follow_loop;       // loop if mwindow is looped
166         int infinite;          // don't stop rendering at the end of the range or loops
167
168         int64_t start_position;      // lowest numbered sample in playback range
169         int64_t end_position;        // highest numbered sample in playback range
170         int64_t current_sample;
171         int every_frame;
172 // This is created in the first arm_command and not changed until deletion.
173 // The EDL in the command changes & pointers in it should not be referenced.
174         EDL *edl;
175
176         MWindow *mwindow;
177 };
178
179
180
181
182
183
184
185
186 #endif