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()
58 char string[BCTEXTLEN];
59 BC_Resources *resources = BC_WindowBase::get_resources();
62 x = mwindow->theme->preferencesoptions_x;
63 y = mwindow->theme->preferencesoptions_y;
66 add_subwindow(title = new BC_Title(x, y, _("File Format:"),
67 LARGEFONT, resources->text_default));
68 y += title->get_h() + 5;
70 recording_format = new FormatTools(mwindow, this,
71 pwindow->thread->edl->session->recording_format);
73 recording_format->create_objects(x, y,
74 1, // Include tools for audio
75 1, // Include tools for video
76 1, // Include checkbox for audio
77 1, // Include checkbox for video
80 0, // Select compressors to be offered
81 1, // Prompt for recording options
82 0, // If nonzero, prompt for insertion strategy
83 0); // Supply file formats for background rendering
85 realtime_toc = new RecordRealtimeTOC(mwindow, pwindow,
86 x0+400, y0, pwindow->thread->edl->session->record_realtime_toc);
87 add_subwindow(realtime_toc);
90 add_subwindow(new BC_Bar(5, y, get_w() - 10));
94 add_subwindow(title = new BC_Title(x, y,
95 _("Audio In"), LARGEFONT,
96 resources->text_default));
98 y += title->get_h() + 5;
100 add_subwindow(new BC_Title(x, y, _("Record Driver:"),
101 MEDIUMFONT, resources->text_default));
102 audio_in_device = new ADevicePrefs(x + 110, y, pwindow, this, 0,
103 pwindow->thread->edl->session->aconfig_in, MODERECORD);
104 audio_in_device->initialize(1);
105 y += audio_in_device->get_h(1);
109 BC_Title *title0, *title1, *title2, *title3;
110 int pad = RecordWriteLength::calculate_h(this,
114 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()) + mwindow->theme->widget_border;
120 x2 = MAX(x2, title2->get_w() + mwindow->theme->widget_border);
121 x2 = MAX(x2, title3->get_w() + mwindow->theme->widget_border);
124 sprintf(string, "%ld", (long)pwindow->thread->edl->session->record_fragment_size);
125 RecordFragment *menu;
126 add_subwindow(menu = new RecordFragment(x2,
131 y += menu->get_h() + mwindow->theme->widget_border;
132 menu->add_item(new BC_MenuItem("1024"));
133 menu->add_item(new BC_MenuItem("2048"));
134 menu->add_item(new BC_MenuItem("4096"));
135 menu->add_item(new BC_MenuItem("8192"));
136 menu->add_item(new BC_MenuItem("16384"));
137 menu->add_item(new BC_MenuItem("32768"));
138 menu->add_item(new BC_MenuItem("65536"));
139 menu->add_item(new BC_MenuItem("131072"));
140 menu->add_item(new BC_MenuItem("262144"));
142 sprintf(string, "%jd", pwindow->thread->edl->session->record_write_length);
143 add_subwindow(textbox = new RecordWriteLength(mwindow, pwindow, x2, y, string));
144 y += textbox->get_h() + mwindow->theme->widget_border;
145 add_subwindow(textbox = new RecordSampleRate(pwindow, x2, y));
146 add_subwindow(new SampleRatePulldown(mwindow,
148 x2 + textbox->get_w(),
150 y += textbox->get_h() + mwindow->theme->widget_border;
152 RecordChannels *channels = new RecordChannels(pwindow, this, x2, y);
153 channels->create_objects();
154 y += channels->get_h() + mwindow->theme->widget_border;
156 RecordMap51_2 *record_map51_2 = new RecordMap51_2(mwindow, pwindow, x, y,
157 pwindow->thread->edl->session->aconfig_in->map51_2);
158 add_subwindow(record_map51_2);
160 x2 = x + record_map51_2->get_w() + 30;
161 int y2 = y + BC_TextBox::calculate_h(this,MEDIUMFONT,1,1) - get_text_height(MEDIUMFONT);
162 add_subwindow(title = new BC_Title(x2, y2, _("Gain:")));
163 x2 += title->get_w() + 8;
164 RecordGain *rec_gain = new RecordGain(pwindow, this, x2, y);
165 rec_gain->create_objects();
167 x2 += rec_gain->get_w() + 30;
168 add_subwindow(new RecordRealTime(mwindow, pwindow, x2, y,
169 pwindow->thread->edl->session->real_time_record));
175 add_subwindow(new BC_Bar(5, y, get_w() - 10));
178 add_subwindow(new BC_Title(x, y, _("Video In"), LARGEFONT,
179 resources->text_default));
182 add_subwindow(new BC_Title(x, y, _("Record Driver:"), MEDIUMFONT,
183 resources->text_default));
184 video_in_device = new VDevicePrefs(x + 110, y, pwindow, this, 0,
185 pwindow->thread->edl->session->vconfig_in, MODERECORD);
186 video_in_device->initialize(1);
189 sprintf(string, "%d", pwindow->thread->edl->session->video_write_length);
190 add_subwindow(textbox = new VideoWriteLength(pwindow, string, y));
191 add_subwindow(new CaptureLengthTumbler(pwindow, textbox, textbox->get_x() + textbox->get_w(), y));
192 add_subwindow(new BC_Title(x, y, _("Frames to record to disk at a time:")));
194 sprintf(string, "%d", pwindow->thread->edl->session->vconfig_in->capture_length);
195 add_subwindow(textbox = new VideoCaptureLength(pwindow, string, y));
196 add_subwindow(new CaptureLengthTumbler(pwindow, textbox, textbox->get_x() + textbox->get_w(), y));
197 add_subwindow(new BC_Title(x, y, _("Frames to buffer in device:")));
201 add_subwindow(new BC_Title(x1, y, _("Positioning:")));
203 add_subwindow(textbox = new BC_TextBox(x1, y, 200, 1, ""));
204 RecordPositioning *positioning = new RecordPositioning(pwindow,textbox);
205 add_subwindow(positioning);
206 positioning->create_objects();
207 y += positioning->get_h() + 5;
209 add_subwindow(new RecordSyncDrives(pwindow,
210 pwindow->thread->edl->session->record_sync_drives,
214 BC_TextBox *w_text, *h_text;
215 add_subwindow(new BC_Title(x, y, _("Size of captured frame:")));
217 add_subwindow(w_text = new RecordW(pwindow, x, y));
218 x += w_text->get_w() + 2;
219 add_subwindow(new BC_Title(x, y, "x"));
221 add_subwindow(h_text = new RecordH(pwindow, x, y));
222 x += h_text->get_w();
223 add_subwindow(new FrameSizePulldown(mwindow->theme,
224 w_text, h_text, x, y));
228 add_subwindow(new BC_Title(x, y, _("Frame rate for recording:")));
230 add_subwindow(textbox = new RecordFrameRate(pwindow, x, y));
232 add_subwindow(new FrameRatePulldown(mwindow, textbox, x, y));
237 int RecordPrefs::show_window(int flush)
239 PreferencesDialog::show_window(flush);
240 if( pwindow->thread->edl->session->recording_format->format == FILE_MPEG &&
241 pwindow->thread->edl->session->vconfig_in->driver == CAPTURE_DVB &&
242 pwindow->thread->edl->session->aconfig_in->driver == AUDIO_DVB )
243 return realtime_toc->show_window(flush);
244 return realtime_toc->hide_window(flush);
251 RecordFragment::RecordFragment(int x,
253 PreferencesWindow *pwindow,
262 this->pwindow = pwindow;
263 this->record = record;
266 int RecordFragment::handle_event()
268 pwindow->thread->edl->session->record_fragment_size = atol(get_text());
278 RecordWriteLength::RecordWriteLength(MWindow *mwindow, PreferencesWindow *pwindow, int x, int y, char *text)
279 : BC_TextBox(x, y, 100, 1, text)
281 this->pwindow = pwindow;
284 int RecordWriteLength::handle_event()
286 pwindow->thread->edl->session->record_write_length = atol(get_text());
291 RecordRealTime::RecordRealTime(MWindow *mwindow,
292 PreferencesWindow *pwindow, int x, int y, int value)
293 : BC_CheckBox(x, y, value,
294 _("Record in realtime priority (root only)"))
296 this->pwindow = pwindow;
299 int RecordRealTime::handle_event()
301 pwindow->thread->edl->session->real_time_record = get_value();
306 RecordMap51_2::RecordMap51_2(MWindow *mwindow,
307 PreferencesWindow *pwindow, int x, int y, int value)
308 : BC_CheckBox(x, y, value, _("Map 5.1->2"))
310 this->pwindow = pwindow;
313 int RecordMap51_2::handle_event()
315 pwindow->thread->edl->session->aconfig_in->map51_2 = get_value();
320 RecordSampleRate::RecordSampleRate(PreferencesWindow *pwindow, int x, int y)
321 : BC_TextBox(x, y, 70, 1, pwindow->thread->edl->session->aconfig_in->in_samplerate)
323 this->pwindow = pwindow;
325 int RecordSampleRate::handle_event()
327 pwindow->thread->edl->session->aconfig_in->in_samplerate = atol(get_text());
332 RecordRealtimeTOC::RecordRealtimeTOC(MWindow *mwindow,
333 PreferencesWindow *pwindow, int x, int y, int value)
334 : BC_CheckBox(x, y, value, _("Realtime TOC"))
336 this->pwindow = pwindow;
339 int RecordRealtimeTOC::handle_event()
341 pwindow->thread->edl->session->record_realtime_toc = get_value();
346 // DuplexEnable::DuplexEnable(MWindow *mwindow, PreferencesWindow *pwindow, int x, int y, int value)
347 // : BC_CheckBox(x, y, value, _("Enable full duplex"))
348 // { this->pwindow = pwindow; }
350 // int DuplexEnable::handle_event()
352 // pwindow->thread->edl->session->enable_duplex = get_value();
357 RecordW::RecordW(PreferencesWindow *pwindow, int x, int y)
358 : BC_TextBox(x, y, 70, 1, pwindow->thread->edl->session->vconfig_in->w)
360 this->pwindow = pwindow;
362 int RecordW::handle_event()
364 pwindow->thread->edl->session->vconfig_in->w = atol(get_text());
368 RecordH::RecordH(PreferencesWindow *pwindow, int x, int y)
369 : BC_TextBox(x, y, 70, 1, pwindow->thread->edl->session->vconfig_in->h)
371 this->pwindow = pwindow;
373 int RecordH::handle_event()
375 pwindow->thread->edl->session->vconfig_in->h = atol(get_text());
379 RecordFrameRate::RecordFrameRate(PreferencesWindow *pwindow, int x, int y)
380 : BC_TextBox(x, y, 70, 1, pwindow->thread->edl->session->vconfig_in->in_framerate)
382 this->pwindow = pwindow;
384 int RecordFrameRate::handle_event()
386 pwindow->thread->edl->session->vconfig_in->in_framerate = atof(get_text());
392 RecordChannels::RecordChannels(PreferencesWindow *pwindow, BC_SubWindow *gui, int x, int y)
393 : BC_TumbleTextBox(gui,
394 pwindow->thread->edl->session->aconfig_in->channels,
395 1, MAX_CHANNELS, x, y, 100)
397 this->pwindow = pwindow;
400 int RecordChannels::handle_event()
402 pwindow->thread->edl->session->aconfig_in->channels = atoi(get_text());
406 RecordGain::RecordGain(PreferencesWindow *pwindow, BC_SubWindow *gui, int x, int y)
407 : BC_TumbleTextBox(gui,
408 pwindow->thread->edl->session->aconfig_in->rec_gain,
409 0.0001f, 10000.0f, x, y, 72)
411 this->pwindow = pwindow;
412 this->set_increment(0.1);
415 int RecordGain::handle_event()
417 pwindow->thread->edl->session->aconfig_in->rec_gain = atof(get_text());
423 VideoWriteLength::VideoWriteLength(PreferencesWindow *pwindow, char *text, int y)
424 : BC_TextBox(260, y, 100, 1, text)
426 this->pwindow = pwindow;
429 int VideoWriteLength::handle_event()
431 pwindow->thread->edl->session->video_write_length = atol(get_text());
436 VideoCaptureLength::VideoCaptureLength(PreferencesWindow *pwindow, char *text, int y)
437 : BC_TextBox(260, y, 100, 1, text)
439 this->pwindow = pwindow;
442 int VideoCaptureLength::handle_event()
444 pwindow->thread->edl->session->vconfig_in->capture_length = atol(get_text());
448 CaptureLengthTumbler::CaptureLengthTumbler(PreferencesWindow *pwindow, BC_TextBox *text, int x, int y)
451 this->pwindow = pwindow;
455 int CaptureLengthTumbler::handle_up_event()
457 int value = atol(text->get_text());
459 char string[BCTEXTLEN];
460 sprintf(string, "%d", value);
461 text->update(string);
462 text->handle_event();
466 int CaptureLengthTumbler::handle_down_event()
468 int value = atol(text->get_text());
470 value = MAX(1, value);
471 char string[BCTEXTLEN];
472 sprintf(string, "%d", value);
473 text->update(string);
474 text->handle_event();
478 RecordPositioning::RecordPositioning(PreferencesWindow *pwindow, BC_TextBox *textbox)
479 : BC_ListBox(textbox->get_x() + textbox->get_w(), textbox->get_y(),
480 200, 100, LISTBOX_TEXT, &position_type, 0, 0, 1, 0, 1)
482 this->pwindow = pwindow;
483 this->textbox = textbox;
486 RecordPositioning::~RecordPositioning()
488 for( int i=0; i<position_type.total; ++i )
489 delete position_type.values[i];
492 void RecordPositioning::create_objects()
494 position_type.append(new BC_ListBoxItem(_("Presentation Timestamps")));
495 position_type.append(new BC_ListBoxItem(_("Software timing")));
496 position_type.append(new BC_ListBoxItem(_("Device Position")));
497 position_type.append(new BC_ListBoxItem(_("Sample Position")));
498 int value = pwindow->thread->edl->session->record_positioning;
499 textbox->update(position_type.values[value]->get_text());
502 int RecordPositioning::handle_event()
504 int v = get_selection_number(0, 0);
505 pwindow->thread->edl->session->record_positioning = v;
506 textbox->update(position_type.values[v]->get_text());
507 textbox->handle_event();
512 RecordSyncDrives::RecordSyncDrives(PreferencesWindow *pwindow, int value, int x, int y)
513 : BC_CheckBox(x, y, value, _("Sync drives automatically"))
515 this->pwindow = pwindow;
518 int RecordSyncDrives::handle_event()
520 pwindow->thread->edl->session->record_sync_drives = get_value();