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