Merge branch 'ct' of git.pipapo.org:cinelerra-ct into ct
[cinelerra_cv/ct.git] / cinelerra / renderengine.h
blob6c7d7596e5e54eca8a44d0f3ab1d3aae50421c1d
1 #ifndef RENDERENGINE_H
2 #define RENDERENGINE_H
5 class RenderEngine;
7 #include "arender.inc"
8 #include "audiodevice.inc"
9 #include "cache.inc"
10 #include "canvas.inc"
11 #include "channel.inc"
12 #include "channeldb.inc"
13 #include "condition.inc"
14 #include "mutex.inc"
15 #include "mwindow.inc"
16 #include "playbackengine.inc"
17 #include "pluginserver.inc"
18 #include "preferences.inc"
19 #include "thread.h"
20 #include "transportque.inc"
21 #include "videodevice.inc"
22 #include "vrender.inc"
24 class RenderEngine : public Thread
26 public:
27 RenderEngine(PlaybackEngine *playback_engine,
28 Preferences *preferences,
29 TransportCommand *command,
30 Canvas *output,
31 ArrayList<PluginServer*> *plugindb,
32 ChannelDB *channeldb);
33 ~RenderEngine();
35 void get_duty();
36 void create_render_threads();
37 void arm_render_threads();
38 void start_render_threads();
39 void wait_render_threads();
40 void interrupt_playback();
41 int get_output_w();
42 int get_output_h();
43 int brender_available(int position, int direction);
44 // Get current channel for the BUZ output
45 Channel* get_current_channel();
46 double get_tracking_position();
47 // Find the plugin whose title matches title and return it
48 PluginServer* scan_plugindb(char *title,
49 int data_type);
50 CICache* get_acache();
51 CICache* get_vcache();
52 void set_acache(CICache *cache);
53 void set_vcache(CICache *cache);
54 // Get levels for tracking
55 void get_output_levels(double *levels, int64_t position);
56 void get_module_levels(ArrayList<double> *module_levels, int64_t position);
58 void run();
59 // Sends the command sequence, compensating for network latency
60 int arm_command(TransportCommand *command,
61 int &current_vchannel,
62 int &current_achannel);
63 // Start the command
64 int start_command();
66 int open_output();
67 int close_output();
68 // return position to synchronize video against
69 int64_t sync_position();
70 // Called by VRender to reset the timers once the first frame is done.
71 void reset_sync_position();
72 // return samples since start of playback
73 int64_t session_position();
75 // Update preferences window
76 void update_framerate(float framerate);
78 // Copy of command
79 TransportCommand *command;
80 // EDL to be used by renderengine since not all commands involve an EDL change
81 EDL *edl;
82 // Pointer to playback config for one head
83 PlaybackConfig *config;
84 // Defined only for the master render engine
85 PlaybackEngine *playback_engine;
86 // Copy of preferences
87 Preferences *preferences;
88 // Canvas if being used for CWindow
89 Canvas *output;
92 // Lock out new commands until completion
93 Condition *input_lock;
94 // Lock out interrupts until started
95 Condition *start_lock;
96 Condition *output_lock;
97 // Lock out audio and synchronization timers until first frame is done
98 Condition *first_frame_lock;
99 // Lock out interrupts before and after renderengine is active
100 Mutex *interrupt_lock;
102 // Show the timecode on the video
103 int show_tc;
105 int done;
106 AudioDevice *audio;
107 VideoDevice *video;
108 ARender *arender;
109 VRender *vrender;
110 int do_audio;
111 int do_video;
112 // Timer for synchronization without audio
113 Timer timer;
114 float actual_frame_rate;
115 // If the termination came from interrupt or end of selection
116 int interrupted;
118 ArrayList<PluginServer*> *plugindb;
119 // Channels for the BUZ output
120 ChannelDB *channeldb;
122 // Samples in audio buffer to process
123 int64_t fragment_len;
124 // Samples to send to audio device after speed adjustment
125 int64_t adjusted_fragment_len;
126 // CICaches for use if no playbackengine exists
127 CICache *audio_cache, *video_cache;
144 // constructing with an audio device forces output buffer allocation
145 // constructing without an audio device puts in one buffer at a time mode
146 RenderEngine(MWindow *mwindow,
147 AudioDevice *audio = 0,
148 VideoDevice *video = 0,
149 PlaybackEngine *playbackengine = 0);
151 // buffersize is in samples
152 int reset_parameters();
154 int arm_playback_audio(int64_t input_length,
155 int64_t amodule_render_fragment,
156 int64_t playback_buffer,
157 int64_t output_length);
159 int arm_playback_video(int every_frame,
160 int64_t read_length,
161 int64_t output_length,
162 int track_w,
163 int track_h,
164 int output_w,
165 int output_h);
167 int64_t get_correction_factor(int reset); // calling it resets the correction factor
169 // start video since vrender is the master
170 int start_video();
173 // information for playback
174 int follow_loop; // loop if mwindow is looped
175 int infinite; // don't stop rendering at the end of the range or loops
177 int64_t start_position; // lowest numbered sample in playback range
178 int64_t end_position; // highest numbered sample in playback range
179 int64_t current_sample;
180 int every_frame;
182 MWindow *mwindow;
192 #endif
194 // Local Variables:
195 // mode: C++
196 // c-file-style: "linux"
197 // End: