rework keyframe hide popup, keyframe auto render, textbox set_selection wide text
[goodguy/history.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 "cache.inc"
31 #include "canvas.inc"
32 #include "channel.inc"
33 #include "channeldb.inc"
34 #include "condition.inc"
35 #include "mutex.inc"
36 #include "mwindow.inc"
37 #include "playbackengine.inc"
38 #include "pluginserver.inc"
39 #include "preferences.inc"
40 #include "thread.h"
41 #include "transportque.inc"
42 #include "videodevice.inc"
43 #include "vrender.inc"
44
45 class RenderEngine : public Thread
46 {
47 public:
48         RenderEngine(PlaybackEngine *playback_engine,
49                 Preferences *preferences,
50                 Canvas *output,
51                 ChannelDB *channeldb,
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         int get_output_w();
62         int get_output_h();
63         int brender_available(int position, int direction);
64 // Get current channel for the BUZ output
65         Channel* get_current_channel();
66         double get_tracking_position();
67         CICache* get_acache();
68         CICache* get_vcache();
69         void set_acache(CICache *cache);
70         void set_vcache(CICache *cache);
71 // Get levels for tracking
72         void get_output_levels(double *levels, int64_t position);
73         void get_module_levels(ArrayList<double> *module_levels, int64_t position);
74         EDL* get_edl();
75
76         void run();
77 // Sends the command sequence, compensating for network latency
78         int arm_command(TransportCommand *command);
79 // Start the command
80         int start_command();
81
82         int open_output();
83         int close_output();
84 // return position to synchronize video against
85         int64_t sync_position();
86 // Called by VRender to reset the timers once the first frame is done.
87         void reset_sync_position();
88 // return samples since start of playback
89         int64_t session_position();
90
91 // Update preferences window
92         void update_framerate(float framerate);
93
94 // Copy of command
95         TransportCommand *command;
96 // Pointer to playback config for one head
97         PlaybackConfig *config;
98 // Defined only for the master render engine
99         PlaybackEngine *playback_engine;
100 // Copy of preferences
101         Preferences *preferences;
102 // Canvas if being used for CWindow
103         Canvas *output;
104
105
106 // Lock out new commands until completion
107         Condition *input_lock;
108 // Lock out interrupts until started
109         Condition *start_lock;
110         Condition *output_lock;
111 // Lock out audio and synchronization timers until first frame is done
112         Condition *first_frame_lock;
113 // Lock out interrupts before and after renderengine is active
114         Mutex *interrupt_lock;
115
116 // Show the timecode on the video
117         int show_tc;
118
119         int done;
120         int is_nested;
121 // If nested, the devices are owned by someone else
122         AudioDevice *audio;
123         VideoDevice *video;
124         ARender *arender;
125         VRender *vrender;
126         int do_audio;
127         int do_video;
128 // Timer for synchronization without audio
129         Timer timer;
130 // If the termination came from interrupt or end of selection
131         int interrupted;
132
133 // Channels for the BUZ output
134         ChannelDB *channeldb;
135
136 // Samples in audio buffer to process
137         int64_t fragment_len;
138 // Samples to send to audio device after speed adjustment
139         int64_t adjusted_fragment_len;
140 // CICaches for use if no playbackengine exists
141         CICache *audio_cache, *video_cache;
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158 // constructing with an audio device forces output buffer allocation
159 // constructing without an audio device puts in one buffer at a time mode
160         RenderEngine(MWindow *mwindow,
161                 AudioDevice *audio = 0,
162                 VideoDevice *video = 0,
163                 PlaybackEngine *playbackengine = 0);
164
165         void reset_parameters();
166
167 // buffersize is in samples
168         void arm_playback_audio(int64_t input_length,
169                         int64_t amodule_render_fragment,
170                         int64_t playback_buffer,
171                         int64_t output_length);
172
173         void arm_playback_video(int every_frame,
174                         int64_t read_length,
175                         int64_t output_length,
176                         int track_w,
177                         int track_h,
178                         int output_w,
179                         int output_h);
180
181 // start video since vrender is the master
182         void start_video();
183
184
185 // information for playback
186         int follow_loop;       // loop if mwindow is looped
187         int infinite;          // don't stop rendering at the end of the range or loops
188
189         int64_t start_position;      // lowest numbered sample in playback range
190         int64_t end_position;        // highest numbered sample in playback range
191         int64_t current_sample;
192         int every_frame;
193 // This is created in the first arm_command and not changed until deletion.
194 // The EDL in the command changes & pointers in it should not be referenced.
195         EDL *edl;
196
197         MWindow *mwindow;
198 };
199
200
201
202
203
204
205
206
207 #endif