prevent popup deactivation while button_down
[goodguy/history.git] / cinelerra-5.0 / cinelerra / pluginvclient.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 PLUGINVCLIENT_H
23 #define PLUGINVCLIENT_H
24
25
26 #include "maxbuffers.h"
27 #include "pluginclient.h"
28 #include "vframe.inc"
29
30 // Maximum dimensions for a temporary frame a plugin should retain between 
31 // process_buffer calls.  This allows memory conservation.
32 #define PLUGIN_MAX_W 2000
33 #define PLUGIN_MAX_H 1000
34
35
36
37 class PluginVClient : public PluginClient
38 {
39 public:
40         PluginVClient(PluginServer *server);
41         virtual ~PluginVClient();
42
43         int get_render_ptrs();
44         int init_realtime_parameters();
45         int delete_nonrealtime_parameters();
46         int is_video();
47 // Replaced by pull method
48 /*
49  *      void plugin_process_realtime(VFrame **input, 
50  *              VFrame **output, 
51  *              int64_t current_position,
52  *              int64_t total_len);
53  */
54 // Multichannel buffer process for backwards compatibility
55         virtual int process_realtime(VFrame **input, 
56                 VFrame **output);
57 // Single channel buffer process for backwards compatibility and transitions
58         virtual int process_realtime(VFrame *input, 
59                 VFrame *output);
60
61 // Process buffer using pull method.  By default this loads the input into *frame
62 //     and calls process_realtime with input and output pointing to frame.
63 // start_position - requested position relative to frame rate. Relative
64 //     to start of EDL.  End of buffer if reverse.
65 // sample_rate - scale of start_position.
66 // These should return 1 if error or 0 if success.
67         virtual int process_buffer(VFrame **frame,
68                 int64_t start_position,
69                 double frame_rate);
70         virtual int process_buffer(VFrame *frame,
71                 int64_t start_position,
72                 double frame_rate);
73
74
75         virtual int process_loop(VFrame **buffers) { return 1; };
76         virtual int process_loop(VFrame *buffer) { return 1; };
77         int plugin_process_loop(VFrame **buffers, int64_t &write_length);
78
79         int plugin_start_loop(int64_t start, 
80                 int64_t end, 
81                 int64_t buffer_size, 
82                 int total_buffers);
83         int plugin_get_parameters();
84
85 // Called by non-realtime client to read frame for processing.
86 // buffer - output frame
87 // channel - channel of the plugin input for a multichannel plugin
88 // start_position - start of frame in forward.  end of frame in reverse.  
89 //     Relative to start of EDL.
90         int read_frame(VFrame *buffer, 
91                 int channel, 
92                 int64_t start_position);
93         int read_frame(VFrame *buffer, 
94                 int64_t start_position);
95
96 // Called by realtime plugin to read frame from previous entity
97 // framerate - framerate start_position is relative to.  Used by preceeding plugiun
98 //     to calculate output frame number.  Provided so the client can get data
99 //     at a higher fidelity than provided by the EDL.
100 // start_position - start of frame in forward.  end of frame in reverse.  
101 //     Relative to start of EDL.
102 // frame_rate - frame rate position is scaled to
103         int read_frame(VFrame *buffer, 
104                 int channel, 
105                 int64_t start_position,
106                 double frame_rate,
107                 int use_opengl /* = 0 */);
108
109
110 // User calls this to request an opengl routine to be run synchronously.
111         int run_opengl();
112
113 // Called by Playback3D to run opengl commands synchronously.
114 // Overridden by the user with the commands to run synchronously.
115         virtual int handle_opengl();
116
117 // Used by the opengl handlers to get the 
118 // arguments to process_buffer.
119 // For realtime plugins, they're identical for input and output.
120         VFrame* get_input(int channel = 0);
121         VFrame* get_output(int channel = 0);
122
123 // For aggregation, this does case sensitive compares with the
124 // the stack in the frame object.
125 // Only possible for video because VFrame stores the effect stacks.
126         int next_effect_is(const char *title);
127         int prev_effect_is(const char *title);
128
129 // Called by user to allocate the temporary for the current process_buffer.  
130 // It may be deleted after the process_buffer to conserve memory.
131         VFrame* new_temp(int w, int h, int color_model);
132 // Called by PluginServer after process_buffer to delete the temp if it's too
133 // large.
134         void age_temp();
135 // Get the temporary created by new_temp.  Only valid if it occurs after new_temp
136 // in the same process_buffer call.
137         VFrame* get_temp();
138
139 // Frame rate relative to EDL
140         double get_project_framerate();
141 // Frame rate requested
142         double get_framerate();
143
144         int64_t local_to_edl(int64_t position);
145         int64_t edl_to_local(int64_t position);
146
147 // ======================== Non realtime buffer pointers =======================
148 // Channels of arrays of frames that the client uses.
149         VFrame ***video_in, ***video_out;
150
151 // point to the start of the buffers
152         ArrayList<VFrame***> input_ptr_master;
153         ArrayList<VFrame***> output_ptr_master;
154 // Pointers to the regions for a single render.
155 // Arrays are channels of arrays of frames.
156         VFrame ***input_ptr_render;
157         VFrame ***output_ptr_render;
158
159 // ======================== Realtime buffer pointers ===========================
160 // These are provided by the plugin server for the opengl handler.
161         VFrame **input;
162         VFrame **output;
163
164
165 // Frame rate of EDL
166         double project_frame_rate;
167 // Local parameters set by non realtime plugin about the file to be generated.
168 // Retrieved by server to set output file format.
169 // In realtime plugins, these are set before every process_buffer as the
170 // requested rates.
171         double frame_rate;
172         int project_color_model;
173 // Whether user wants floating point calculations.
174         int use_float;   
175 // Whether user wants alpha calculations.
176         int use_alpha;   
177 // Whether user wants pixel interpolation.
178         int use_interpolation;   
179 // Aspect ratio
180         float aspect_w;
181         float aspect_h;  
182
183 // Temp
184         VFrame *temp;
185 };
186
187
188
189 #endif