improve ffmpeg format selection popup menu, more ffmpeg audio fixes
[goodguy/history.git] / cinelerra-5.0 / cinelerra / formattools.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 FORMATTOOLS_H
23 #define FORMATTOOLS_H
24
25 #include "asset.inc"
26 #include "guicast.h"
27 #include "bitspopup.h"
28 #include "browsebutton.h"
29 #include "compresspopup.h"
30 #include "file.inc"
31 #include "formatpopup.h"
32 #include "mwindow.inc"
33
34 class FormatAParams;
35 class FormatVParams;
36 class FormatAThread;
37 class FormatVThread;
38 class FormatChannels;
39 class FormatPathButton;
40 class FormatPathText;
41 class FormatFormat;
42 class FormatFFMPEG;
43 class FFMpegType;
44 class FormatAudio;
45 class FormatVideo;
46 class FormatMultiple;
47
48 class FormatTools
49 {
50 public:
51         FormatTools(MWindow *mwindow,
52                                 BC_WindowBase *window, 
53                                 Asset *asset);
54         virtual ~FormatTools();
55
56         void create_objects(int &init_x, 
57                                                 int &init_y, 
58                                                 int do_audio,    // Include tools for audio
59                                                 int do_video,   // Include tools for video
60                                                 int prompt_audio,  // Include checkbox for audio
61                                                 int prompt_video,  // Include checkbox for video
62                                                 int prompt_audio_channels,
63                                                 int prompt_video_compression,
64                                                 char *locked_compressor,  // Select compressors to be offered
65                                                 int recording, // Change captions for recording
66                                                 int *strategy,  // If nonzero, prompt for insertion strategy
67                                                 int brender); // Supply file formats for background rendering
68 // In recording preferences, aspects of the format are locked 
69 // depending on the driver used.
70         void update_driver(int driver);
71         void update_format();
72
73
74         void reposition_window(int &init_x, int &init_y);
75 // Put new asset's parameters in and change asset.
76         void update(Asset *asset, int *strategy);
77 // Update filename extension when format is changed.
78         void update_extension();
79         void close_format_windows();
80         Asset* get_asset();
81
82 // Handle change in path text.  Used in BatchRender.
83         virtual int handle_event();
84
85         int set_audio_options();
86         int set_video_options();
87         void set_w(int w);
88         int get_w();
89
90         BC_WindowBase *window;
91         Asset *asset;
92
93         FormatAParams *aparams_button;
94         FormatVParams *vparams_button;
95         FormatAThread *aparams_thread;
96         FormatVThread *vparams_thread;
97         BrowseButton *path_button;
98         FormatPathText *path_textbox;
99         BC_Title *format_title;
100         FormatFormat *format_button;
101         BC_TextBox *format_text;
102         FormatFFMPEG *format_ffmpeg;
103         FFMpegType *ffmpeg_type;
104         BC_ITumbler *channels_tumbler;
105
106         BC_Title *audio_title;
107         BC_Title *channels_title;
108         FormatChannels *channels_button;
109         FormatAudio *audio_switch;
110
111         BC_Title *video_title;
112         FormatVideo *video_switch;
113
114         FormatMultiple *multiple_files;
115
116 // Suggestions for the textbox
117         ArrayList<BC_ListBoxItem*> *file_entries;
118         ArrayList<PluginServer*> *plugindb;
119         MWindow *mwindow;
120         char *locked_compressor;
121         int recording;
122         int use_brender;
123         int do_audio;
124         int do_video;
125         int prompt_audio;
126         int prompt_audio_channels;
127         int prompt_video;
128         int prompt_video_compression;
129         int *strategy;
130         int w;
131 // Determines what the configuration buttons do.
132         int video_driver;
133 };
134
135
136
137 class FormatPathText : public BC_TextBox
138 {
139 public:
140         FormatPathText(int x, int y, FormatTools *format);
141         ~FormatPathText();
142         int handle_event();
143         
144         FormatTools *format;
145 };
146
147
148
149 class FormatFormat : public FormatPopup
150 {
151 public:
152         FormatFormat(int x, int y, FormatTools *format);
153         ~FormatFormat();
154         
155         int handle_event();
156         FormatTools *format;
157 };
158
159 class FormatFFMPEG : public FFMPEGPopup
160 {
161 public:
162         FormatFFMPEG(int x, int y, FormatTools *format);
163         ~FormatFFMPEG();
164         
165         int handle_event();
166         FormatTools *format;
167 // squash show/hide window
168         int show_window(int flush=1) { return 0; }
169         int hide_window(int flush=1) { return 0; }
170         int show(int flush=1) { return BC_SubWindow::show_window(flush); }
171         int hide(int flush=1) { return BC_SubWindow::hide_window(flush); }
172 };
173
174 class FFMpegType : public BC_TextBox
175 {
176 public:
177         FFMpegType(int x, int y, int w, int h, const char *text)
178          : BC_TextBox(x, y, w, h, text) {}
179         ~FFMpegType() {}
180 // squash show/hide window
181         int show_window(int flush=1) { return 0; }
182         int hide_window(int flush=1) { return 0; }
183         int show(int flush=1) { return BC_SubWindow::show_window(flush); }
184         int hide(int flush=1) { return BC_SubWindow::hide_window(flush); }
185 };
186
187 class FormatAParams : public BC_Button
188 {
189 public:
190         FormatAParams(MWindow *mwindow, FormatTools *format, int x, int y);
191         ~FormatAParams();
192         int handle_event();
193         FormatTools *format;
194 };
195
196 class FormatVParams : public BC_Button
197 {
198 public:
199         FormatVParams(MWindow *mwindow, FormatTools *format, int x, int y);
200         ~FormatVParams();
201         int handle_event();
202         FormatTools *format;
203 };
204
205
206 class FormatAThread : public Thread
207 {
208 public:
209         FormatAThread(FormatTools *format);
210         ~FormatAThread();
211         
212         void run();
213         void start();
214         void join() { if( !joined ) { joined = 1; Thread::join(); } }
215
216         FormatTools *format;
217         File *file;
218         int joined;
219 };
220
221 class FormatVThread : public Thread
222 {
223 public:
224         FormatVThread(FormatTools *format);
225         ~FormatVThread();
226         
227         void run();
228         void start();
229         void join() { if( !joined ) { joined = 1; Thread::join(); } }
230
231         FormatTools *format;
232         File *file;
233         int joined;
234 };
235
236 class FormatAudio : public BC_CheckBox
237 {
238 public:
239         FormatAudio(int x, int y, FormatTools *format, int default_);
240         ~FormatAudio();
241         int handle_event();
242         FormatTools *format;
243 };
244
245 class FormatVideo : public BC_CheckBox
246 {
247 public:
248         FormatVideo(int x, int y, FormatTools *format, int default_);
249         ~FormatVideo();
250         int handle_event();
251         FormatTools *format;
252 };
253
254
255 class FormatChannels : public BC_TextBox
256 {
257 public:
258         FormatChannels(int x, int y, FormatTools *format);
259         ~FormatChannels();
260         int handle_event();
261         FormatTools *format;
262 };
263
264 class FormatToTracks : public BC_CheckBox
265 {
266 public:
267         FormatToTracks(int x, int y, int *output);
268         ~FormatToTracks();
269         int handle_event();
270         int *output;
271 };
272
273 class FormatMultiple : public BC_CheckBox
274 {
275 public:
276         FormatMultiple(MWindow *mwindow, int x, int y, int *output);
277         ~FormatMultiple();
278         int handle_event();
279         void update(int *output);
280         int *output;
281         MWindow *mwindow;
282 };
283
284
285 #endif