4 * Copyright (C) 2010 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"
23 #include "audioconfig.h"
24 #include "audiodevice.inc"
25 #include "bcsignals.h"
29 #include "edlsession.h"
32 #include "mainsession.h"
34 #include "overlayframe.inc"
35 #include "playbackprefs.h"
36 #include "preferences.h"
38 #include "vdeviceprefs.h"
39 #include "videodevice.inc"
43 PlaybackPrefs::PlaybackPrefs(MWindow *mwindow, PreferencesWindow *pwindow, int config_number)
44 : PreferencesDialog(mwindow, pwindow)
46 this->config_number = config_number;
53 PlaybackPrefs::~PlaybackPrefs()
61 void PlaybackPrefs::create_objects()
64 char string[BCTEXTLEN];
65 BC_WindowBase *window;
68 playback_config = pwindow->thread->edl->session->playback_config;
70 x = mwindow->theme->preferencesoptions_x;
71 y = mwindow->theme->preferencesoptions_y;
72 //int margin = mwindow->theme->widget_border;
75 add_subwindow(new BC_Title(x,
81 y += get_text_height(LARGEFONT) + 5;
84 BC_Title *title1, *title2;
85 add_subwindow(title2 = new BC_Title(x, y, _("Playback buffer samples:"), MEDIUMFONT));
86 x2 = MAX(title2->get_w(), title2->get_w()) + 10;
89 sprintf(string, "%d", playback_config->aconfig->fragment_size);
90 PlaybackModuleFragment *menu;
91 add_subwindow(menu = new PlaybackModuleFragment(x2,
96 menu->add_item(new BC_MenuItem("1024"));
97 menu->add_item(new BC_MenuItem("2048"));
98 menu->add_item(new BC_MenuItem("4096"));
99 menu->add_item(new BC_MenuItem("8192"));
100 menu->add_item(new BC_MenuItem("16384"));
101 menu->add_item(new BC_MenuItem("32768"));
102 menu->add_item(new BC_MenuItem("65536"));
103 menu->add_item(new BC_MenuItem("131072"));
104 menu->add_item(new BC_MenuItem("262144"));
106 y += menu->get_h() + 5;
108 add_subwindow(title1 = new BC_Title(x2, y, _("Audio offset (sec):")));
109 x2 += title1->get_w() + 5;
110 audio_offset = new PlaybackAudioOffset(pwindow, this, x2, y);
111 audio_offset->create_objects();
112 y += audio_offset->get_h() + 5;
115 add_subwindow(new PlaybackViewFollows(pwindow,
116 pwindow->thread->edl->session->view_follows_playback, y));
118 add_subwindow(new PlaybackSoftwareTimer(pwindow,
119 pwindow->thread->edl->session->playback_software_position, y));
121 add_subwindow(new PlaybackRealTime(pwindow,
122 pwindow->thread->edl->session->real_time_playback, y));
124 PlaybackMap51_2 *map51_2 = new PlaybackMap51_2(pwindow, this,
125 playback_config->aconfig->map51_2, y);
126 add_subwindow(map51_2);
127 x2 = map51_2->get_x() + map51_2->get_w() + 15;
128 y2 = y + BC_TextBox::calculate_h(this,MEDIUMFONT,1,1) - get_text_height(MEDIUMFONT);
130 add_subwindow(title2 = new BC_Title(x2, y2, _("Gain:")));
131 x2 += title2->get_w() + 8;
132 play_gain = new PlaybackGain(x2, y, pwindow, this);
133 play_gain->create_objects();
135 add_subwindow(new BC_Title(x, y, _("Audio Driver:")));
136 audio_device = new ADevicePrefs(x + 100, y, pwindow,
137 this, playback_config->aconfig, 0, MODEPLAY);
138 audio_device->initialize(0);
145 y += audio_device->get_h();
148 add_subwindow(new BC_Bar(5, y, get_w() - 10));
152 add_subwindow(new BC_Title(x, y, _("Video Out"), LARGEFONT));
156 add_subwindow(window = new VideoEveryFrame(pwindow, this, x, y));
158 add_subwindow(new BC_Title(x + 200, y + 5, _("Framerate achieved:")));
159 add_subwindow(framerate_title = new BC_Title(x + 350, y + 5, "--", MEDIUMFONT, RED));
161 y += window->get_h() + 5;
163 add_subwindow(asynchronous = new VideoAsynchronous(pwindow, x, y));
164 y += asynchronous->get_h() + 10;
167 add_subwindow(title1 = new BC_Title(x, y, _("Scaling equation: Enlarge / Reduce ")));
168 VScalingEquation *vscaling_equation =
169 new VScalingEquation(x + title1->get_w() + 10, y,
170 &pwindow->thread->edl->session->interpolation_type);
171 add_subwindow(vscaling_equation);
172 vscaling_equation->create_objects();
176 add_subwindow(title1 = new BC_Title(x, y, _("DVD Subtitle to display:")));
177 PlaybackSubtitleNumber *subtitle_number;
178 subtitle_number = new PlaybackSubtitleNumber(x + title1->get_w() + 10,
182 subtitle_number->create_objects();
184 x2 = x + title1->get_w() + 10 + subtitle_number->get_w() + 30;
185 PlaybackSubtitle *subtitle_toggle;
186 add_subwindow(subtitle_toggle = new PlaybackSubtitle(x2, y, pwindow, this));
187 y += subtitle_toggle->get_h();
189 PlaybackLabelCells *label_cells_toggle;
190 add_subwindow(label_cells_toggle = new PlaybackLabelCells(x2, y, pwindow, this));
191 y2 = y + label_cells_toggle->get_h();
193 add_subwindow(title1=new BC_Title(x2, y2, _("TOC Program No:"), MEDIUMFONT));
194 PlaybackProgramNumber *program_number;
195 program_number = new PlaybackProgramNumber(
196 x2 + title1->get_w() + 10, y2, pwindow, this);
197 program_number->create_objects();
199 add_subwindow(interpolate_raw = new PlaybackInterpolateRaw( x, y,
201 y += interpolate_raw->get_h();
203 add_subwindow(white_balance_raw = new PlaybackWhiteBalanceRaw( x, y,
205 y += white_balance_raw->get_h() + 10;
206 if(!pwindow->thread->edl->session->interpolate_raw)
207 white_balance_raw->disable();
212 // add_subwindow(new PlaybackDeblock(pwindow, 10, y));
214 add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
215 video_device = new VDevicePrefs(x + vdevice_title->get_w() + 10, y,
216 pwindow, this, playback_config->vconfig, 0, MODEPLAY);
217 video_device->initialize(0);
223 int PlaybackPrefs::draw_framerate(int flush)
225 //printf("PlaybackPrefs::draw_framerate 1 %f\n", mwindow->session->actual_frame_rate);
226 char string[BCTEXTLEN];
227 sprintf(string, "%.4f", mwindow->session->actual_frame_rate);
228 framerate_title->update(string, flush);
234 PlaybackAudioOffset::PlaybackAudioOffset(PreferencesWindow *pwindow,
235 PlaybackPrefs *playback, int x, int y)
236 : BC_TumbleTextBox(playback, playback->playback_config->aconfig->audio_offset,
237 -10.0, 10.0, x, y, 100)
239 this->pwindow = pwindow;
240 this->playback = playback;
245 int PlaybackAudioOffset::handle_event()
247 playback->playback_config->aconfig->audio_offset = atof(get_text());
254 PlaybackModuleFragment::PlaybackModuleFragment(int x, int y,
255 PreferencesWindow *pwindow, PlaybackPrefs *playback, char *text)
256 : BC_PopupMenu(x, y, 100, text, 1)
258 this->pwindow = pwindow;
259 this->playback = playback;
262 int PlaybackModuleFragment::handle_event()
264 playback->playback_config->aconfig->fragment_size = atol(get_text());
269 PlaybackViewFollows::PlaybackViewFollows(PreferencesWindow *pwindow, int value, int y)
270 : BC_CheckBox(10, y, value, _("View follows playback"))
272 this->pwindow = pwindow;
275 int PlaybackViewFollows::handle_event()
277 pwindow->thread->edl->session->view_follows_playback = get_value();
282 PlaybackSoftwareTimer::PlaybackSoftwareTimer(PreferencesWindow *pwindow, int value, int y)
283 : BC_CheckBox(10, y, value, _("Use software for positioning information"))
285 this->pwindow = pwindow;
288 int PlaybackSoftwareTimer::handle_event()
290 pwindow->thread->edl->session->playback_software_position = get_value();
295 PlaybackRealTime::PlaybackRealTime(PreferencesWindow *pwindow, int value, int y)
296 : BC_CheckBox(10, y, value, _("Audio playback in real time priority (root only)"))
298 this->pwindow = pwindow;
301 int PlaybackRealTime::handle_event()
303 pwindow->thread->edl->session->real_time_playback = get_value();
308 PlaybackMap51_2::PlaybackMap51_2(PreferencesWindow *pwindow,
309 PlaybackPrefs *playback_prefs, int value, int y)
310 : BC_CheckBox(10, y, value, _("Map 5.1->2"))
312 this->pwindow = pwindow;
313 this->playback_prefs = playback_prefs;
316 int PlaybackMap51_2::handle_event()
318 playback_prefs->playback_config->aconfig->map51_2 = get_value();
323 PlaybackInterpolateRaw::PlaybackInterpolateRaw( int x, int y,
324 PreferencesWindow *pwindow, PlaybackPrefs *playback)
327 pwindow->thread->edl->session->interpolate_raw,
328 _("Interpolate CR2 images"))
330 this->pwindow = pwindow;
331 this->playback = playback;
334 int PlaybackInterpolateRaw::handle_event()
336 pwindow->thread->edl->session->interpolate_raw = get_value();
337 if(!pwindow->thread->edl->session->interpolate_raw) {
338 playback->white_balance_raw->update(0, 0);
339 playback->white_balance_raw->disable();
342 playback->white_balance_raw->update(pwindow->thread->edl->session->white_balance_raw, 0);
343 playback->white_balance_raw->enable();
349 PlaybackWhiteBalanceRaw::PlaybackWhiteBalanceRaw( int x, int y,
350 PreferencesWindow *pwindow, PlaybackPrefs *playback)
353 pwindow->thread->edl->session->interpolate_raw &&
354 pwindow->thread->edl->session->white_balance_raw,
355 _("White balance CR2 images"))
357 this->pwindow = pwindow;
358 this->playback = playback;
359 if(!pwindow->thread->edl->session->interpolate_raw) disable();
362 int PlaybackWhiteBalanceRaw::handle_event()
364 pwindow->thread->edl->session->white_balance_raw = get_value();
369 VideoAsynchronous::VideoAsynchronous(PreferencesWindow *pwindow, int x, int y)
371 pwindow->thread->edl->session->video_every_frame &&
372 pwindow->thread->edl->session->video_asynchronous,
373 _("Decode frames asynchronously"))
375 this->pwindow = pwindow;
376 if(!pwindow->thread->edl->session->video_every_frame)
380 int VideoAsynchronous::handle_event()
382 pwindow->thread->edl->session->video_asynchronous = get_value();
387 VideoEveryFrame::VideoEveryFrame(PreferencesWindow *pwindow,
388 PlaybackPrefs *playback_prefs, int x, int y)
389 : BC_CheckBox(x, y, pwindow->thread->edl->session->video_every_frame, _("Play every frame"))
391 this->pwindow = pwindow;
392 this->playback_prefs = playback_prefs;
395 int VideoEveryFrame::handle_event()
397 pwindow->thread->edl->session->video_every_frame = get_value();
398 if(!pwindow->thread->edl->session->video_every_frame) {
399 playback_prefs->asynchronous->update(0, 0);
400 playback_prefs->asynchronous->disable();
403 playback_prefs->asynchronous->update(pwindow->thread->edl->session->video_asynchronous, 0);
404 playback_prefs->asynchronous->enable();
410 PlaybackSubtitle::PlaybackSubtitle(int x, int y,
411 PreferencesWindow *pwindow, PlaybackPrefs *playback)
413 pwindow->thread->edl->session->decode_subtitles,
414 _("Enable subtitles/captioning"))
416 this->pwindow = pwindow;
417 this->playback = playback;
420 int PlaybackSubtitle::handle_event()
422 pwindow->thread->edl->session->decode_subtitles = get_value();
427 PlaybackSubtitleNumber::PlaybackSubtitleNumber(int x, int y,
428 PreferencesWindow *pwindow, PlaybackPrefs *playback)
429 : BC_TumbleTextBox(playback, pwindow->thread->edl->session->subtitle_number,
432 this->pwindow = pwindow;
433 this->playback = playback;
436 int PlaybackSubtitleNumber::handle_event()
438 pwindow->thread->edl->session->subtitle_number = atoi(get_text());
443 PlaybackLabelCells::PlaybackLabelCells(int x, int y,
444 PreferencesWindow *pwindow, PlaybackPrefs *playback)
446 pwindow->thread->edl->session->label_cells,
449 this->pwindow = pwindow;
450 this->playback = playback;
453 int PlaybackLabelCells::handle_event()
455 pwindow->thread->edl->session->label_cells = get_value();
460 PlaybackProgramNumber::PlaybackProgramNumber(int x, int y,
461 PreferencesWindow *pwindow, PlaybackPrefs *playback)
462 : BC_TumbleTextBox(playback,
463 pwindow->thread->edl->session->program_no,
466 this->pwindow = pwindow;
467 this->playback = playback;
470 int PlaybackProgramNumber::handle_event()
472 pwindow->thread->edl->session->program_no = atoi(get_text());
476 PlaybackGain::PlaybackGain(int x, int y,
477 PreferencesWindow *pwindow, PlaybackPrefs *playback)
478 : BC_TumbleTextBox(playback,
479 pwindow->thread->edl->session->playback_config->aconfig->play_gain,
480 0.0001f, 10000.0f, x, y, 72)
482 this->pwindow = pwindow;
483 this->set_increment(0.1);
486 int PlaybackGain::handle_event()
488 pwindow->thread->edl->session->playback_config->
489 aconfig->play_gain = atof(get_text());