4 * Copyright (C) 2008-2013 Adam Williams <broadcast at earthling dot net>
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.
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.
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
22 #include "adeviceprefs.h"
24 #include "audioconfig.h"
27 #include "edlsession.h"
28 #include "formattools.h"
32 #include "preferences.h"
33 #include "recordconfig.h"
34 #include "recordprefs.h"
36 #include "vdeviceprefs.h"
41 RecordPrefs::RecordPrefs(MWindow *mwindow, PreferencesWindow *pwindow)
42 : PreferencesDialog(mwindow, pwindow)
44 this->mwindow = mwindow;
47 RecordPrefs::~RecordPrefs()
49 delete audio_in_device;
50 delete video_in_device;
51 delete recording_format;
52 // delete duplex_device;
55 void RecordPrefs::create_objects()
57 int xs5 = xS(5), xs10 = xS(10), xs30 = xS(30);
58 int ys5 = yS(5), ys27 = yS(27), ys30 = yS(30);
60 char string[BCTEXTLEN];
61 BC_Resources *resources = BC_WindowBase::get_resources();
63 BC_Title *title0, *title1, *title2, *title3;
66 x = mwindow->theme->preferencesoptions_x;
67 y = mwindow->theme->preferencesoptions_y;
68 int margin = mwindow->theme->widget_border;
71 add_subwindow(title = new BC_Title(x, y, _("File Format:"),
72 LARGEFONT, resources->text_default));
73 y += title->get_h() + margin;
75 recording_format = new FormatTools(mwindow, this,
76 pwindow->thread->edl->session->recording_format);
78 recording_format->create_objects(x, y,
79 1, // Include tools for audio
80 1, // Include tools for video
81 1, // Include checkbox for audio
82 1, // Include checkbox for video
85 0, // Select compressors to be offered
86 1, // Prompt for recording options
87 0, // prompt for use labels
88 0); // Supply file formats for background rendering
90 realtime_toc = new RecordRealtimeTOC(mwindow, pwindow,
91 x0+xS(400), y0, pwindow->thread->edl->session->record_realtime_toc);
92 add_subwindow(realtime_toc);
95 add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
99 add_subwindow(title = new BC_Title(x, y,
100 _("Audio In"), LARGEFONT,
101 resources->text_default));
103 y += title->get_h() + margin;
105 add_subwindow(new BC_Title(x, y, _("Record Driver:"),
106 MEDIUMFONT, resources->text_default));
107 audio_in_device = new ADevicePrefs(x + xS(110), y, pwindow, this, 0,
108 pwindow->thread->edl->session->aconfig_in, MODERECORD);
109 audio_in_device->initialize(1);
110 y += audio_in_device->get_h(1) + margin;
113 int pad = RecordWriteLength::calculate_h(this,
114 MEDIUMFONT, 1, 1) + mwindow->theme->widget_border;
115 add_subwindow(title0 = new BC_Title(x, y, _("Samples read from device:")));
116 add_subwindow(title1 = new BC_Title(x, y + pad, _("Samples to write to disk:")));
117 add_subwindow(title2 = new BC_Title(x, y + pad * 2, _("Sample rate for recording:")));
118 add_subwindow(title3 = new BC_Title(x, y + pad * 3, _("Channels to record:")));
119 x2 = MAX(title0->get_w(), title1->get_w()) + margin;
120 x2 = MAX(x2, title2->get_w() + margin);
121 x2 = MAX(x2, title3->get_w() + margin);
124 sprintf(string, "%ld", (long)pwindow->thread->edl->session->record_fragment_size);
125 RecordFragment *menu;
126 add_subwindow(menu = new RecordFragment(x2, y, pwindow, this, string));
127 y += menu->get_h() + mwindow->theme->widget_border;
128 menu->add_item(new BC_MenuItem("1024"));
129 menu->add_item(new BC_MenuItem("2048"));
130 menu->add_item(new BC_MenuItem("4096"));
131 menu->add_item(new BC_MenuItem("8192"));
132 menu->add_item(new BC_MenuItem("16384"));
133 menu->add_item(new BC_MenuItem("32768"));
134 menu->add_item(new BC_MenuItem("65536"));
135 menu->add_item(new BC_MenuItem("131072"));
136 menu->add_item(new BC_MenuItem("262144"));
138 sprintf(string, "%jd", pwindow->thread->edl->session->record_write_length);
139 add_subwindow(textbox = new RecordWriteLength(mwindow, pwindow, x2, y, string));
140 y += textbox->get_h() + mwindow->theme->widget_border;
141 add_subwindow(textbox = new RecordSampleRate(pwindow, x2, y));
142 add_subwindow(new SampleRatePulldown(mwindow, textbox, x2 + textbox->get_w(), y));
143 y += textbox->get_h() + mwindow->theme->widget_border;
145 RecordChannels *channels = new RecordChannels(pwindow, this, x2, y);
146 channels->create_objects();
147 y += channels->get_h() + mwindow->theme->widget_border;
149 RecordMap51_2 *record_map51_2 = new RecordMap51_2(mwindow, pwindow, x, y,
150 pwindow->thread->edl->session->aconfig_in->map51_2);
151 add_subwindow(record_map51_2);
153 x2 = x + record_map51_2->get_w() + xs30;
154 int y2 = y + BC_TextBox::calculate_h(this,MEDIUMFONT,1,1) - get_text_height(MEDIUMFONT);
155 add_subwindow(title = new BC_Title(x2, y2, _("Gain:")));
156 x2 += title->get_w() + xS(8);
157 RecordGain *rec_gain = new RecordGain(pwindow, this, x2, y);
158 rec_gain->create_objects();
160 x2 += rec_gain->get_w() + xs30;
161 add_subwindow(new RecordRealTime(mwindow, pwindow, x2, y,
162 pwindow->thread->edl->session->real_time_record));
168 add_subwindow(new BC_Bar(xs5, y, get_w() - xs10));
171 add_subwindow(title1 = new BC_Title(x, y, _("Video In"), LARGEFONT,
172 resources->text_default));
173 y += title1->get_h() + margin;
175 add_subwindow(title1 = new BC_Title(x, y, _("Record Driver:"), MEDIUMFONT,
176 resources->text_default));
177 video_in_device = new VDevicePrefs(x + title1->get_w() + margin, y,
178 pwindow, this, 0, pwindow->thread->edl->session->vconfig_in, MODERECORD);
179 video_in_device->initialize(1);
180 y += video_in_device->get_h() + margin;
182 add_subwindow(title1 = new BC_Title(x, y, _("Frames to record to disk at a time:")));
183 x1 = x + title1->get_w() + margin;
184 sprintf(string, "%d", pwindow->thread->edl->session->video_write_length);
185 add_subwindow(textbox = new VideoWriteLength(pwindow, string, x1, y));
186 x1 += textbox->get_w() + margin;
187 add_subwindow(new CaptureLengthTumbler(pwindow, textbox, x1, y));
190 add_subwindow(title1 = new BC_Title(x, y, _("Frames to buffer in device:")));
191 x1 = x + title1->get_w() + margin;
192 sprintf(string, "%d", pwindow->thread->edl->session->vconfig_in->capture_length);
193 add_subwindow(textbox = new VideoCaptureLength(pwindow, string, x1, y));
194 x1 += textbox->get_w() + margin;
195 add_subwindow(new CaptureLengthTumbler(pwindow, textbox, x1, y));
199 add_subwindow(new BC_Title(x1, y, _("Positioning:")));
201 add_subwindow(textbox = new BC_TextBox(x1, y, xS(200), 1, ""));
202 RecordPositioning *positioning = new RecordPositioning(pwindow,textbox);
203 add_subwindow(positioning);
204 positioning->create_objects();
205 y += positioning->get_h() + ys5;
207 add_subwindow(new RecordSyncDrives(pwindow,
208 pwindow->thread->edl->session->record_sync_drives,
212 BC_TextBox *w_text, *h_text;
213 add_subwindow(title1 = new BC_Title(x, y, _("Size of captured frame:")));
214 x += title1->get_w() + margin;
215 add_subwindow(w_text = new RecordW(pwindow, x, y));
216 x += w_text->get_w() + margin;
217 add_subwindow(title1 = new BC_Title(x, y, "x"));
218 x += title1->get_w() + margin;
219 add_subwindow(h_text = new RecordH(pwindow, x, y));
220 x += h_text->get_w() + margin;
221 FrameSizePulldown *frame_sizes;
222 add_subwindow(frame_sizes = new FrameSizePulldown(mwindow->theme,
223 w_text, h_text, x, y));
224 y += frame_sizes->get_h() + margin;
226 x = mwindow->theme->preferencesoptions_x;
227 add_subwindow(title1 = new BC_Title(x, y, _("Frame rate for recording:")));
228 x += title1->get_w() + margin;
229 add_subwindow(textbox = new RecordFrameRate(pwindow, x, y));
230 x += textbox->get_w() + margin;
231 add_subwindow(new FrameRatePulldown(mwindow, textbox, x, y));
236 int RecordPrefs::show_window(int flush)
238 PreferencesDialog::show_window(flush);
239 if( pwindow->thread->edl->session->recording_format->format == FILE_MPEG &&
240 pwindow->thread->edl->session->vconfig_in->driver == CAPTURE_DVB &&
241 pwindow->thread->edl->session->aconfig_in->driver == AUDIO_DVB )
242 return realtime_toc->show_window(flush);
243 return realtime_toc->hide_window(flush);
247 RecordFragment::RecordFragment(int x,
249 PreferencesWindow *pwindow,
252 : BC_PopupMenu(x, y, xS(100), text, 1)
254 this->pwindow = pwindow;
255 this->record = record;
258 int RecordFragment::handle_event()
260 pwindow->thread->edl->session->record_fragment_size = atol(get_text());
265 RecordWriteLength::RecordWriteLength(MWindow *mwindow, PreferencesWindow *pwindow, int x, int y, char *text)
266 : BC_TextBox(x, y, xS(100), 1, text)
268 this->pwindow = pwindow;
271 int RecordWriteLength::handle_event()
273 pwindow->thread->edl->session->record_write_length = atol(get_text());
278 RecordRealTime::RecordRealTime(MWindow *mwindow,
279 PreferencesWindow *pwindow, int x, int y, int value)
280 : BC_CheckBox(x, y, value,
281 _("Record in realtime priority (root only)"))
283 this->pwindow = pwindow;
286 int RecordRealTime::handle_event()
288 pwindow->thread->edl->session->real_time_record = get_value();
293 RecordMap51_2::RecordMap51_2(MWindow *mwindow,
294 PreferencesWindow *pwindow, int x, int y, int value)
295 : BC_CheckBox(x, y, value, _("Map 5.1->2"))
297 this->pwindow = pwindow;
300 int RecordMap51_2::handle_event()
302 pwindow->thread->edl->session->aconfig_in->map51_2 = get_value();
307 RecordSampleRate::RecordSampleRate(PreferencesWindow *pwindow, int x, int y)
308 : BC_TextBox(x, y, xS(70), 1, pwindow->thread->edl->session->aconfig_in->in_samplerate)
310 this->pwindow = pwindow;
312 int RecordSampleRate::handle_event()
314 pwindow->thread->edl->session->aconfig_in->in_samplerate = atol(get_text());
319 RecordRealtimeTOC::RecordRealtimeTOC(MWindow *mwindow,
320 PreferencesWindow *pwindow, int x, int y, int value)
321 : BC_CheckBox(x, y, value, _("Realtime TOC"))
323 this->pwindow = pwindow;
326 int RecordRealtimeTOC::handle_event()
328 pwindow->thread->edl->session->record_realtime_toc = get_value();
333 // DuplexEnable::DuplexEnable(MWindow *mwindow, PreferencesWindow *pwindow, int x, int y, int value)
334 // : BC_CheckBox(x, y, value, _("Enable full duplex"))
335 // { this->pwindow = pwindow; }
337 // int DuplexEnable::handle_event()
339 // pwindow->thread->edl->session->enable_duplex = get_value();
344 RecordW::RecordW(PreferencesWindow *pwindow, int x, int y)
345 : BC_TextBox(x, y, xS(70), 1, pwindow->thread->edl->session->vconfig_in->w)
347 this->pwindow = pwindow;
349 int RecordW::handle_event()
351 pwindow->thread->edl->session->vconfig_in->w = atol(get_text());
355 RecordH::RecordH(PreferencesWindow *pwindow, int x, int y)
356 : BC_TextBox(x, y, xS(70), 1, pwindow->thread->edl->session->vconfig_in->h)
358 this->pwindow = pwindow;
360 int RecordH::handle_event()
362 pwindow->thread->edl->session->vconfig_in->h = atol(get_text());
366 RecordFrameRate::RecordFrameRate(PreferencesWindow *pwindow, int x, int y)
367 : BC_TextBox(x, y, xS(140), 1, pwindow->thread->edl->session->vconfig_in->in_framerate)
369 this->pwindow = pwindow;
371 int RecordFrameRate::handle_event()
373 pwindow->thread->edl->session->vconfig_in->in_framerate = atof(get_text());
379 RecordChannels::RecordChannels(PreferencesWindow *pwindow, BC_SubWindow *gui, int x, int y)
380 : BC_TumbleTextBox(gui,
381 pwindow->thread->edl->session->aconfig_in->channels,
382 1, MAX_CHANNELS, x, y, xS(100))
384 this->pwindow = pwindow;
387 int RecordChannels::handle_event()
389 pwindow->thread->edl->session->aconfig_in->channels = atoi(get_text());
393 RecordGain::RecordGain(PreferencesWindow *pwindow, BC_SubWindow *gui, int x, int y)
394 : BC_TumbleTextBox(gui,
395 pwindow->thread->edl->session->aconfig_in->rec_gain,
396 0.0001f, 10000.0f, x, y, xS(72))
398 this->pwindow = pwindow;
399 this->set_increment(0.1);
402 int RecordGain::handle_event()
404 pwindow->thread->edl->session->aconfig_in->rec_gain = atof(get_text());
410 VideoWriteLength::VideoWriteLength(PreferencesWindow *pwindow, char *text, int x, int y)
411 : BC_TextBox(x, y, xS(100), 1, text)
413 this->pwindow = pwindow;
416 int VideoWriteLength::handle_event()
418 pwindow->thread->edl->session->video_write_length = atol(get_text());
423 VideoCaptureLength::VideoCaptureLength(PreferencesWindow *pwindow, char *text, int x, int y)
424 : BC_TextBox(x, y, xS(100), 1, text)
426 this->pwindow = pwindow;
429 int VideoCaptureLength::handle_event()
431 pwindow->thread->edl->session->vconfig_in->capture_length = atol(get_text());
435 CaptureLengthTumbler::CaptureLengthTumbler(PreferencesWindow *pwindow, BC_TextBox *text, int x, int y)
438 this->pwindow = pwindow;
442 int CaptureLengthTumbler::handle_up_event()
444 int value = atol(text->get_text());
446 char string[BCTEXTLEN];
447 sprintf(string, "%d", value);
448 text->update(string);
449 text->handle_event();
453 int CaptureLengthTumbler::handle_down_event()
455 int value = atol(text->get_text());
457 value = MAX(1, value);
458 char string[BCTEXTLEN];
459 sprintf(string, "%d", value);
460 text->update(string);
461 text->handle_event();
465 RecordPositioning::RecordPositioning(PreferencesWindow *pwindow, BC_TextBox *textbox)
466 : BC_ListBox(textbox->get_x() + textbox->get_w(), textbox->get_y(),
467 xS(200), yS(100), LISTBOX_TEXT, &position_type, 0, 0, 1, 0, 1)
469 this->pwindow = pwindow;
470 this->textbox = textbox;
473 RecordPositioning::~RecordPositioning()
475 for( int i=0; i<position_type.total; ++i )
476 delete position_type.values[i];
479 void RecordPositioning::create_objects()
481 position_type.append(new BC_ListBoxItem(_("Presentation Timestamps")));
482 position_type.append(new BC_ListBoxItem(_("Software timing")));
483 position_type.append(new BC_ListBoxItem(_("Device Position")));
484 position_type.append(new BC_ListBoxItem(_("Sample Position")));
485 int value = pwindow->thread->edl->session->record_positioning;
486 textbox->update(position_type.values[value]->get_text());
489 int RecordPositioning::handle_event()
491 int v = get_selection_number(0, 0);
492 pwindow->thread->edl->session->record_positioning = v;
493 textbox->update(position_type.values[v]->get_text());
494 textbox->handle_event();
499 RecordSyncDrives::RecordSyncDrives(PreferencesWindow *pwindow, int value, int x, int y)
500 : BC_CheckBox(x, y, value, _("Sync drives automatically"))
502 this->pwindow = pwindow;
505 int RecordSyncDrives::handle_event()
507 pwindow->thread->edl->session->record_sync_drives = get_value();