Credit Andrew - fix vorbis audio which was scratchy and ensure aging plugin does...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / formattools.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  * Copyright (C) 2003-2016 Cinelerra CV contributors
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  *
21  */
22
23 #ifndef FORMATTOOLS_H
24 #define FORMATTOOLS_H
25
26 #include "asset.inc"
27 #include "guicast.h"
28 #include "bitspopup.h"
29 #include "browsebutton.h"
30 #include "compresspopup.h"
31 #include "file.inc"
32 #include "ffmpeg.h"
33 #include "formatpopup.h"
34 #include "formattools.inc"
35 #include "mwindow.inc"
36
37 class FormatTools
38 {
39 public:
40         FormatTools(MWindow *mwindow, BC_WindowBase *window, Asset *asset);
41         virtual ~FormatTools();
42
43         void create_objects(int &init_x, int &init_y,
44                 int do_audio, int do_video,   // Include tools for audio, video
45                 int prompt_audio,  int prompt_video,  // Include checkbox for audio, video
46                 int prompt_audio_channels, int prompt_video_compression,
47                 const char *locked_compressor,  // Select compressors to be offered
48                 int recording, // Change captions for recording
49                 int *file_per_label,  // prompt if nonzero
50                 int brender,   // Supply file formats for background rendering
51                 int horizontal_layout = 0);
52 // In recording preferences, aspects of the format are locked
53 // depending on the driver used.
54         void update_driver(int driver);
55         virtual void update_format();
56
57
58         void reposition_window(int &init_x, int &init_y);
59 // Put new asset's parameters in and change asset.
60         void update(Asset *asset, int *file_per_label);
61 // Update filename extension when format is changed.
62         void update_extension();
63         void close_format_windows();
64         Asset* get_asset();
65
66 // Handle change in path text.  Used in BatchRender.
67         virtual int handle_event();
68
69         int set_audio_options();
70         int set_video_options();
71         void set_w(int w);
72         int get_w();
73
74         BC_WindowBase *window;
75         Asset *asset;
76
77         FormatAParams *aparams_button;
78         FormatVParams *vparams_button;
79         FormatAThread *aparams_thread;
80         FormatVThread *vparams_thread;
81         BrowseButton *path_button;
82         FormatPathText *path_textbox;
83         BC_RecentList *path_recent;
84         BC_Title *format_title;
85         FormatFormat *format_button;
86         BC_TextBox *format_text;
87         FormatFFMPEG *format_ffmpeg;
88         FFMpegType *ffmpeg_type;
89
90         BC_Title *audio_title;
91         FormatAudio *audio_switch;
92
93         BC_Title *video_title;
94         FormatVideo *video_switch;
95
96         FormatFilePerLabel *labeled_files;
97
98         MWindow *mwindow;
99         const char *locked_compressor;
100         int recording;
101         int use_brender;
102         int do_audio;
103         int do_video;
104         int prompt_audio;
105         int prompt_audio_channels;
106         int prompt_video;
107         int prompt_video_compression;
108         int *file_per_label;
109         int w;
110 // Determines what the configuration buttons do.
111         int video_driver;
112 };
113
114
115
116 class FormatPathText : public BC_TextBox
117 {
118 public:
119         FormatPathText(int x, int y, FormatTools *format);
120         ~FormatPathText();
121         int handle_event();
122
123         FormatTools *format;
124 };
125
126
127
128 class FormatFormat : public FormatPopup
129 {
130 public:
131         FormatFormat(int x, int y, FormatTools *format);
132         ~FormatFormat();
133
134         int handle_event();
135         FormatTools *format;
136 };
137
138 class FormatFFMPEG : public FFMPEGPopup
139 {
140 public:
141         FormatFFMPEG(int x, int y, FormatTools *format);
142         ~FormatFFMPEG();
143
144         int handle_event();
145         FormatTools *format;
146
147 // squash show/hide window
148         int show_window(int flush=1) { return 0; }
149         int hide_window(int flush=1) { return 0; }
150         int show(int flush=1) { return BC_SubWindow::show_window(flush); }
151         int hide(int flush=1) { return BC_SubWindow::hide_window(flush); }
152 };
153
154 class FFMpegType : public BC_TextBox
155 {
156 public:
157         FFMpegType(int x, int y, int w, int h, const char *text)
158          : BC_TextBox(x, y, w, h, text) {}
159         ~FFMpegType() {}
160 // squash show/hide window
161         int show_window(int flush=1) { return 0; }
162         int hide_window(int flush=1) { return 0; }
163         int show(int flush=1) { return BC_SubWindow::show_window(flush); }
164         int hide(int flush=1) { return BC_SubWindow::hide_window(flush); }
165 };
166
167 class FormatAParams : public BC_Button
168 {
169 public:
170         FormatAParams(MWindow *mwindow, FormatTools *format, int x, int y);
171         ~FormatAParams();
172         int handle_event();
173         FormatTools *format;
174 };
175
176 class FormatVParams : public BC_Button
177 {
178 public:
179         FormatVParams(MWindow *mwindow, FormatTools *format, int x, int y);
180         ~FormatVParams();
181         int handle_event();
182         FormatTools *format;
183 };
184
185
186 class FormatAThread : public Thread
187 {
188 public:
189         FormatAThread(FormatTools *format);
190         ~FormatAThread();
191
192         void run();
193         void start();
194         void join() { if( !joined ) { joined = 1; Thread::join(); } }
195
196         FormatTools *format;
197         File *file;
198         int joined;
199 };
200
201 class FormatVThread : public Thread
202 {
203 public:
204         FormatVThread(FormatTools *format);
205         ~FormatVThread();
206
207         void run();
208         void start();
209         void join() { if( !joined ) { joined = 1; Thread::join(); } }
210
211         FormatTools *format;
212         File *file;
213         int joined;
214 };
215
216 class FormatAudio : public BC_CheckBox
217 {
218 public:
219         FormatAudio(int x, int y, FormatTools *format, int default_);
220         ~FormatAudio();
221         int handle_event();
222         FormatTools *format;
223 };
224
225 class FormatVideo : public BC_CheckBox
226 {
227 public:
228         FormatVideo(int x, int y, FormatTools *format, int default_);
229         ~FormatVideo();
230         int handle_event();
231         FormatTools *format;
232 };
233
234
235 class FormatFilePerLabel : public BC_CheckBox
236 {
237 public:
238         FormatFilePerLabel(FormatTools *format, int x, int y, int *output);
239         ~FormatFilePerLabel();
240         int handle_event();
241         void update(int *output);
242
243         FormatTools *format;
244         int *output;
245 };
246
247
248 #endif