6 * Copyright (C) 2015 Adam Williams <broadcast at earthling dot net>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "arraylist.h"
25 #include "audiodevice.inc"
28 #include "bctimer.inc"
29 #include "convert.inc"
31 #include "formattools.h"
33 #include "mainprogress.inc"
35 #include "mwindow.inc"
36 #include "packagerenderer.h"
39 class ConvertRender : public Thread
42 ConvertRender(MWindow *mwindow);
45 void to_convert_path(char *new_path, Indexable *idxbl);
46 int from_convert_path(char *new_path, Indexable *idxbl);
48 ArrayList<Indexable *> orig_idxbls; // originals which match the convert assets
49 ArrayList<Asset *> orig_copies; // convert assets
50 ArrayList<Indexable *> needed_idxbls; // originals which match the needed_assets
51 ArrayList<Asset *> needed_copies; // assets which must be created
53 double get_video_length(Indexable *idxbl);
54 double get_audio_length(Indexable *idxbl);
55 double get_length(Indexable *idxbl);
56 int match_format(Asset *asset);
57 EDL *convert_edl(EDL *edl, Indexable *idxbl); // create render edl for this indexable
58 int add_original(EDL *edl, Indexable *idxbl);
59 void add_needed(Indexable *idxbl, Asset *convert);
60 int find_convertable_assets(EDL *edl);
62 // if user canceled progress bar
64 void set_format(Asset *asset, const char *suffix);
65 void start_convert(float beep, int remove_originals);
67 void create_copy(int i);
68 void start_progress();
69 void stop_progress(const char *msg);
74 MainProgressBar *progress;
75 ConvertProgress *convert_progress;
76 Timer *progress_timer;
79 int total_rendered, remove_originals;
80 int failed, canceled, result;
84 class ConvertMenuItem : public BC_MenuItem
87 ConvertMenuItem(MWindow *mwindow);
91 void create_objects();
94 ConvertDialog *dialog;
97 class ConvertFormatTools : public FormatTools
100 ConvertFormatTools(MWindow *mwindow, ConvertWindow *gui, Asset *asset);
102 void update_format();
106 class ConvertSuffixText : public BC_TextBox
109 ConvertSuffixText(ConvertWindow *gui, ConvertDialog *dialog, int x, int y);
110 ~ConvertSuffixText();
114 ConvertDialog *dialog;
117 class ConvertRemoveOriginals : public BC_CheckBox
120 ConvertRemoveOriginals(ConvertWindow *gui, int x, int y);
121 ~ConvertRemoveOriginals();
128 class ConvertBeepOnDone : public BC_FPot
131 ConvertBeepOnDone(ConvertWindow *gui, int x, int y);
138 class ConvertPackageRenderer : public PackageRenderer
141 ConvertPackageRenderer(ConvertRender *render);
142 ~ConvertPackageRenderer();
146 void set_result(int value);
147 void set_progress(int64_t value);
148 int progress_cancelled();
150 ConvertRender *render;
153 class ConvertProgress : public Thread
156 ConvertProgress(MWindow *mwindow, ConvertRender *render);
162 ConvertRender *render;
166 class ConvertWindow : public BC_Window
169 ConvertWindow(MWindow *mwindow, ConvertDialog *dialog,
173 void create_objects();
176 ConvertDialog *dialog;
178 ConvertSuffixText *suffix_text;
179 ConvertFormatTools *format_tools;
180 ConvertRemoveOriginals *remove_originals;
181 ConvertBeepOnDone *beep_on_done;
184 class ConvertDialog : public BC_DialogThread
187 ConvertDialog(MWindow *mwindow);
189 BC_Window* new_gui();
191 void handle_close_event(int result);
197 char suffix[BCTEXTLEN];
198 ConvertRender *convert_render;
200 int orig_scale, new_scale;
201 int use_scaler, auto_scale;
203 int remove_originals;
207 class ConvertBeep : public Thread
210 enum { BEEP_SAMPLE_RATE=48000 };
211 typedef int16_t audio_data_t;
212 ConvertBeep(MWindow *mwindow);
218 void tone(double freq, double secs, double gain);
221 double freq, secs, gain;
223 int playing_audio, interrupted;