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;
45 // *** CONTEXT_HELP ***
46 context_help_set_keyword("Recording");
49 RecordPrefs::~RecordPrefs()
51 delete audio_in_device;
52 delete video_in_device;
53 delete recording_format;
54 // delete duplex_device;
57 void RecordPrefs::create_objects()
59 int xs5 = xS(5), xs10 = xS(10), xs30 = xS(30);
60 int ys5 = yS(5), ys27 = yS(27), ys30 = yS(30);
62 char string[BCTEXTLEN];
63 BC_Resources *resources = BC_WindowBase::get_resources();
65 BC_Title *title0, *title1, *title2, *title3;
68 x = mwindow->theme->preferencesoptions_x;
69 y = mwindow->theme->preferencesoptions_y;
70 int margin = mwindow->theme->widget_border;
73 add_subwindow(title = new BC_Title(x, y, _("File Format:"),
74 LARGEFONT, resources->text_default));
75 title->context_help_set_keyword("File Format section");
76 y += title->get_h() + margin;
78 recording_format = new FormatTools(mwindow, this,
79 pwindow->thread->edl->session->recording_format);
81 recording_format->create_objects(x, y,
82 1, // Include tools for audio
83 1, // Include tools for video
84 1, // Include checkbox for audio
85 1, // Include checkbox for video
88 0, // Select compressors to be offered
89 1, // Prompt for recording options
90 0, // prompt for use labels
91 0); // Supply file formats for background rendering
93 realtime_toc = new RecordRealtimeTOC(mwindow, pwindow,
94 x0+xS(400), y0, pwindow->thread->edl->session->record_realtime_toc);
95 add_subwindow(realtime_toc);
96 realtime_toc->context_help_set_keyword("File Format section");
99 add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
103 add_subwindow(title = new BC_Title(x, y,
104 _("Audio In"), LARGEFONT,
105 resources->text_default));
106 title->context_help_set_keyword("Audio In section");
108 y += title->get_h() + margin;
110 add_subwindow(title = new BC_Title(x, y, _("Record Driver:"),
111 MEDIUMFONT, resources->text_default));
112 title->context_help_set_keyword("Audio In section");
113 audio_in_device = new ADevicePrefs(x + xS(110), y, pwindow, this, 0,
114 pwindow->thread->edl->session->aconfig_in, MODERECORD);
115 audio_in_device->initialize(1);
116 y += audio_in_device->get_h(1) + margin;
119 int pad = RecordWriteLength::calculate_h(this,
120 MEDIUMFONT, 1, 1) + mwindow->theme->widget_border;
121 add_subwindow(title0 = new BC_Title(x, y, _("Samples read from device:")));
122 title0->context_help_set_keyword("Audio In section");
123 add_subwindow(title1 = new BC_Title(x, y + pad, _("Samples to write to disk:")));
124 title1->context_help_set_keyword("Audio In section");
125 add_subwindow(title2 = new BC_Title(x, y + pad * 2, _("Sample rate for recording:")));
126 title2->context_help_set_keyword("Audio In section");
127 add_subwindow(title3 = new BC_Title(x, y + pad * 3, _("Channels to record:")));
128 title3->context_help_set_keyword("Audio In section");
129 x2 = MAX(title0->get_w(), title1->get_w()) + margin;
130 x2 = MAX(x2, title2->get_w() + margin);
131 x2 = MAX(x2, title3->get_w() + margin);
134 sprintf(string, "%ld", (long)pwindow->thread->edl->session->record_fragment_size);
135 RecordFragment *menu;
136 add_subwindow(menu = new RecordFragment(x2, y, pwindow, this, string));
137 y += menu->get_h() + mwindow->theme->widget_border;
138 menu->add_item(new BC_MenuItem("1024"));
139 menu->add_item(new BC_MenuItem("2048"));
140 menu->add_item(new BC_MenuItem("4096"));
141 menu->add_item(new BC_MenuItem("8192"));
142 menu->add_item(new BC_MenuItem("16384"));
143 menu->add_item(new BC_MenuItem("32768"));
144 menu->add_item(new BC_MenuItem("65536"));
145 menu->add_item(new BC_MenuItem("131072"));
146 menu->add_item(new BC_MenuItem("262144"));
147 menu->context_help_set_keyword("Audio In section");
149 sprintf(string, "%jd", pwindow->thread->edl->session->record_write_length);
150 add_subwindow(textbox = new RecordWriteLength(mwindow, pwindow, x2, y, string));
151 textbox->context_help_set_keyword("Audio In section");
152 y += textbox->get_h() + mwindow->theme->widget_border;
153 add_subwindow(textbox = new RecordSampleRate(pwindow, x2, y));
154 textbox->context_help_set_keyword("Audio In section");
155 add_subwindow(new SampleRatePulldown(mwindow, textbox, x2 + textbox->get_w(), y));
156 y += textbox->get_h() + mwindow->theme->widget_border;
158 RecordChannels *channels = new RecordChannels(pwindow, this, x2, y);
159 channels->create_objects();
160 y += channels->get_h() + mwindow->theme->widget_border;
162 RecordMap51_2 *record_map51_2 = new RecordMap51_2(mwindow, pwindow, x, y,
163 pwindow->thread->edl->session->aconfig_in->map51_2);
164 add_subwindow(record_map51_2);
165 record_map51_2->context_help_set_keyword("Audio In section");
167 x2 = x + record_map51_2->get_w() + xs30;
168 int y2 = y + BC_TextBox::calculate_h(this,MEDIUMFONT,1,1) - get_text_height(MEDIUMFONT);
169 add_subwindow(title = new BC_Title(x2, y2, _("Gain:")));
170 title->context_help_set_keyword("Audio In section");
171 x2 += title->get_w() + xS(8);
172 RecordGain *rec_gain = new RecordGain(pwindow, this, x2, y);
173 rec_gain->create_objects();
175 x2 += rec_gain->get_w() + xs30;
176 add_subwindow(new RecordRealTime(mwindow, pwindow, x2, y,
177 pwindow->thread->edl->session->real_time_record));
183 add_subwindow(new BC_Bar(xs5, y, get_w() - xs10));
186 add_subwindow(title1 = new BC_Title(x, y, _("Video In"), LARGEFONT,
187 resources->text_default));
188 title1->context_help_set_keyword("Video In section");
189 y += title1->get_h() + margin;
191 add_subwindow(title1 = new BC_Title(x, y, _("Record Driver:"), MEDIUMFONT,
192 resources->text_default));
193 title1->context_help_set_keyword("Video In section");
194 video_in_device = new VDevicePrefs(x + title1->get_w() + margin, y,
195 pwindow, this, 0, pwindow->thread->edl->session->vconfig_in, MODERECORD);
196 video_in_device->initialize(1);
197 y += video_in_device->get_h() + margin;
199 add_subwindow(title1 = new BC_Title(x, y, _("Frames to record to disk at a time:")));
200 title1->context_help_set_keyword("Video In section");
201 x1 = x + title1->get_w() + margin;
202 sprintf(string, "%d", pwindow->thread->edl->session->video_write_length);
203 add_subwindow(textbox = new VideoWriteLength(pwindow, string, x1, y));
204 textbox->context_help_set_keyword("Video In section");
205 x1 += textbox->get_w() + margin;
206 add_subwindow(new CaptureLengthTumbler(pwindow, textbox, x1, y));
209 add_subwindow(title1 = new BC_Title(x, y, _("Frames to buffer in device:")));
210 title1->context_help_set_keyword("Video In section");
211 x1 = x + title1->get_w() + margin;
212 sprintf(string, "%d", pwindow->thread->edl->session->vconfig_in->capture_length);
213 add_subwindow(textbox = new VideoCaptureLength(pwindow, string, x1, y));
214 textbox->context_help_set_keyword("Video In section");
215 x1 += textbox->get_w() + margin;
216 add_subwindow(new CaptureLengthTumbler(pwindow, textbox, x1, y));
220 add_subwindow(title1 = new BC_Title(x1, y, _("Positioning:")));
221 title1->context_help_set_keyword("Video In section");
223 add_subwindow(textbox = new BC_TextBox(x1, y, xS(200), 1, ""));
224 textbox->context_help_set_keyword("Video In section");
225 RecordPositioning *positioning = new RecordPositioning(pwindow,textbox);
226 add_subwindow(positioning);
227 positioning->create_objects();
228 positioning->context_help_set_keyword("Video In section");
229 y += positioning->get_h() + ys5;
231 add_subwindow(new RecordSyncDrives(pwindow,
232 pwindow->thread->edl->session->record_sync_drives,
236 BC_TextBox *w_text, *h_text;
237 add_subwindow(title1 = new BC_Title(x, y, _("Size of captured frame:")));
238 title1->context_help_set_keyword("Video In section");
239 x += title1->get_w() + margin;
240 add_subwindow(w_text = new RecordW(pwindow, x, y));
241 w_text->context_help_set_keyword("Video In section");
242 x += w_text->get_w() + margin;
243 add_subwindow(title1 = new BC_Title(x, y, "x"));
244 title1->context_help_set_keyword("Video In section");
245 x += title1->get_w() + margin;
246 add_subwindow(h_text = new RecordH(pwindow, x, y));
247 h_text->context_help_set_keyword("Video In section");
248 x += h_text->get_w() + margin;
249 FrameSizePulldown *frame_sizes;
250 add_subwindow(frame_sizes = new FrameSizePulldown(mwindow->theme,
251 w_text, h_text, x, y));
252 frame_sizes->context_help_set_keyword("Video In section");
253 y += frame_sizes->get_h() + margin;
255 x = mwindow->theme->preferencesoptions_x;
256 add_subwindow(title1 = new BC_Title(x, y, _("Frame rate for recording:")));
257 title1->context_help_set_keyword("Video In section");
258 x += title1->get_w() + margin;
259 add_subwindow(textbox = new RecordFrameRate(pwindow, x, y));
260 textbox->context_help_set_keyword("Video In section");
261 x += textbox->get_w() + margin;
262 add_subwindow(new FrameRatePulldown(mwindow, textbox, x, y));
267 int RecordPrefs::show_window(int flush)
269 PreferencesDialog::show_window(flush);
270 if( pwindow->thread->edl->session->recording_format->format == FILE_MPEG &&
271 pwindow->thread->edl->session->vconfig_in->driver == CAPTURE_DVB &&
272 pwindow->thread->edl->session->aconfig_in->driver == AUDIO_DVB )
273 return realtime_toc->show_window(flush);
274 return realtime_toc->hide_window(flush);
278 RecordFragment::RecordFragment(int x,
280 PreferencesWindow *pwindow,
283 : BC_PopupMenu(x, y, xS(100), text, 1)
285 this->pwindow = pwindow;
286 this->record = record;
289 int RecordFragment::handle_event()
291 pwindow->thread->edl->session->record_fragment_size = atol(get_text());
296 RecordWriteLength::RecordWriteLength(MWindow *mwindow, PreferencesWindow *pwindow, int x, int y, char *text)
297 : BC_TextBox(x, y, xS(100), 1, text)
299 this->pwindow = pwindow;
302 int RecordWriteLength::handle_event()
304 pwindow->thread->edl->session->record_write_length = atol(get_text());
309 RecordRealTime::RecordRealTime(MWindow *mwindow,
310 PreferencesWindow *pwindow, int x, int y, int value)
311 : BC_CheckBox(x, y, value,
312 _("Record in realtime priority (root only)"))
314 this->pwindow = pwindow;
315 // *** CONTEXT_HELP ***
316 context_help_set_keyword("Audio In section");
319 int RecordRealTime::handle_event()
321 pwindow->thread->edl->session->real_time_record = get_value();
326 RecordMap51_2::RecordMap51_2(MWindow *mwindow,
327 PreferencesWindow *pwindow, int x, int y, int value)
328 : BC_CheckBox(x, y, value, _("Map 5.1->2"))
330 this->pwindow = pwindow;
333 int RecordMap51_2::handle_event()
335 pwindow->thread->edl->session->aconfig_in->map51_2 = get_value();
340 RecordSampleRate::RecordSampleRate(PreferencesWindow *pwindow, int x, int y)
341 : BC_TextBox(x, y, xS(70), 1, pwindow->thread->edl->session->aconfig_in->in_samplerate)
343 this->pwindow = pwindow;
345 int RecordSampleRate::handle_event()
347 pwindow->thread->edl->session->aconfig_in->in_samplerate = atol(get_text());
352 RecordRealtimeTOC::RecordRealtimeTOC(MWindow *mwindow,
353 PreferencesWindow *pwindow, int x, int y, int value)
354 : BC_CheckBox(x, y, value, _("Realtime TOC"))
356 this->pwindow = pwindow;
359 int RecordRealtimeTOC::handle_event()
361 pwindow->thread->edl->session->record_realtime_toc = get_value();
366 // DuplexEnable::DuplexEnable(MWindow *mwindow, PreferencesWindow *pwindow, int x, int y, int value)
367 // : BC_CheckBox(x, y, value, _("Enable full duplex"))
368 // { this->pwindow = pwindow; }
370 // int DuplexEnable::handle_event()
372 // pwindow->thread->edl->session->enable_duplex = get_value();
377 RecordW::RecordW(PreferencesWindow *pwindow, int x, int y)
378 : BC_TextBox(x, y, xS(70), 1, pwindow->thread->edl->session->vconfig_in->w)
380 this->pwindow = pwindow;
382 int RecordW::handle_event()
384 pwindow->thread->edl->session->vconfig_in->w = atol(get_text());
388 RecordH::RecordH(PreferencesWindow *pwindow, int x, int y)
389 : BC_TextBox(x, y, xS(70), 1, pwindow->thread->edl->session->vconfig_in->h)
391 this->pwindow = pwindow;
393 int RecordH::handle_event()
395 pwindow->thread->edl->session->vconfig_in->h = atol(get_text());
399 RecordFrameRate::RecordFrameRate(PreferencesWindow *pwindow, int x, int y)
400 : BC_TextBox(x, y, xS(140), 1, pwindow->thread->edl->session->vconfig_in->in_framerate)
402 this->pwindow = pwindow;
404 int RecordFrameRate::handle_event()
406 pwindow->thread->edl->session->vconfig_in->in_framerate = atof(get_text());
412 RecordChannels::RecordChannels(PreferencesWindow *pwindow, BC_SubWindow *gui, int x, int y)
413 : BC_TumbleTextBox(gui,
414 pwindow->thread->edl->session->aconfig_in->channels,
415 1, MAX_CHANNELS, x, y, xS(100))
417 this->pwindow = pwindow;
420 int RecordChannels::handle_event()
422 pwindow->thread->edl->session->aconfig_in->channels = atoi(get_text());
426 RecordGain::RecordGain(PreferencesWindow *pwindow, BC_SubWindow *gui, int x, int y)
427 : BC_TumbleTextBox(gui,
428 pwindow->thread->edl->session->aconfig_in->rec_gain,
429 0.0001f, 10000.0f, x, y, xS(72))
431 this->pwindow = pwindow;
432 this->set_increment(0.1);
435 int RecordGain::handle_event()
437 pwindow->thread->edl->session->aconfig_in->rec_gain = atof(get_text());
443 VideoWriteLength::VideoWriteLength(PreferencesWindow *pwindow, char *text, int x, int y)
444 : BC_TextBox(x, y, xS(100), 1, text)
446 this->pwindow = pwindow;
449 int VideoWriteLength::handle_event()
451 pwindow->thread->edl->session->video_write_length = atol(get_text());
456 VideoCaptureLength::VideoCaptureLength(PreferencesWindow *pwindow, char *text, int x, int y)
457 : BC_TextBox(x, y, xS(100), 1, text)
459 this->pwindow = pwindow;
462 int VideoCaptureLength::handle_event()
464 pwindow->thread->edl->session->vconfig_in->capture_length = atol(get_text());
468 CaptureLengthTumbler::CaptureLengthTumbler(PreferencesWindow *pwindow, BC_TextBox *text, int x, int y)
471 this->pwindow = pwindow;
473 // *** CONTEXT_HELP ***
474 context_help_set_keyword("Video In section");
477 int CaptureLengthTumbler::handle_up_event()
479 int value = atol(text->get_text());
481 char string[BCTEXTLEN];
482 sprintf(string, "%d", value);
483 text->update(string);
484 text->handle_event();
488 int CaptureLengthTumbler::handle_down_event()
490 int value = atol(text->get_text());
492 value = MAX(1, value);
493 char string[BCTEXTLEN];
494 sprintf(string, "%d", value);
495 text->update(string);
496 text->handle_event();
500 RecordPositioning::RecordPositioning(PreferencesWindow *pwindow, BC_TextBox *textbox)
501 : BC_ListBox(textbox->get_x() + textbox->get_w(), textbox->get_y(),
502 xS(200), yS(100), LISTBOX_TEXT, &position_type, 0, 0, 1, 0, 1)
504 this->pwindow = pwindow;
505 this->textbox = textbox;
508 RecordPositioning::~RecordPositioning()
510 for( int i=0; i<position_type.total; ++i )
511 delete position_type.values[i];
514 void RecordPositioning::create_objects()
516 position_type.append(new BC_ListBoxItem(_("Presentation Timestamps")));
517 position_type.append(new BC_ListBoxItem(_("Software timing")));
518 position_type.append(new BC_ListBoxItem(_("Device Position")));
519 position_type.append(new BC_ListBoxItem(_("Sample Position")));
520 int value = pwindow->thread->edl->session->record_positioning;
521 textbox->update(position_type.values[value]->get_text());
524 int RecordPositioning::handle_event()
526 int v = get_selection_number(0, 0);
527 pwindow->thread->edl->session->record_positioning = v;
528 textbox->update(position_type.values[v]->get_text());
529 textbox->handle_event();
534 RecordSyncDrives::RecordSyncDrives(PreferencesWindow *pwindow, int value, int x, int y)
535 : BC_CheckBox(x, y, value, _("Sync drives automatically"))
537 this->pwindow = pwindow;
538 // *** CONTEXT_HELP ***
539 context_help_set_keyword("Video In section");
542 int RecordSyncDrives::handle_event()
544 pwindow->thread->edl->session->record_sync_drives = get_value();