3 #include "channelpicker.h"
8 #include "edlsession.h"
9 #include "formattools.h"
12 #include "vdeviceprefs.h"
13 #include "videoconfig.h"
14 #include "videodevice.inc"
15 #include "playbackconfig.h"
16 #include "preferences.h"
17 #include "preferencesthread.h"
18 #include "recordconfig.h"
19 #include "recordprefs.h"
23 VDevicePrefs::VDevicePrefs(int x,
25 PreferencesWindow *pwindow,
26 PreferencesDialog *dialog,
27 VideoOutConfig *out_config,
28 VideoInConfig *in_config,
31 this->pwindow = pwindow;
32 this->dialog = dialog;
35 this->out_config = out_config;
36 this->in_config = in_config;
44 VDevicePrefs::~VDevicePrefs()
48 pwindow->mwindow->channeldb_buz->save("channeldb_buz");
52 void VDevicePrefs::reset_objects()
69 firewire_channels = 0;
73 buz_swap_channels = 0;
78 int VDevicePrefs::initialize(int creation)
86 driver = &out_config->driver;
90 driver = &in_config->driver;
93 this->driver = *driver;
97 dialog->add_subwindow(menu = new VDriverMenu(x,
100 (mode == MODERECORD),
102 menu->create_objects();
113 case VIDEO4LINUX2JPEG:
114 create_v4l2jpeg_objs();
117 create_screencap_objs();
127 case PLAYBACK_X11_XV:
128 case PLAYBACK_X11_GL:
131 case PLAYBACK_DV1394:
132 case PLAYBACK_FIREWIRE:
133 case PLAYBACK_IEC61883:
134 case CAPTURE_FIREWIRE:
135 case CAPTURE_IEC61883:
136 create_firewire_objs();
145 // Update driver dependancies in file format
146 if(mode == MODERECORD && dialog && !creation)
148 RecordPrefs *record_prefs = (RecordPrefs*)dialog;
149 record_prefs->recording_format->update_driver(this->driver);
155 int VDevicePrefs::delete_objects()
160 delete channel_picker;
162 delete buz_swap_channels;
171 delete device_number;
175 if(firewire_port) delete firewire_port;
177 if(channel_title) delete channel_title;
179 if(firewire_channel) delete firewire_channel;
182 if(firewire_path) delete firewire_path;
184 if(syt_title) delete syt_title;
186 if(firewire_syt) delete firewire_syt;
194 int VDevicePrefs::create_dvb_objs()
196 int x1 = x + menu->get_w() + 5;
197 dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Host:")));
198 dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, in_config->dvb_in_host));
199 x1 += device_text->get_w() + 10;
200 dialog->add_subwindow(port_title = new BC_Title(x1, y, _("Port:")));
201 device_port = new VDeviceTumbleBox(this, x1, y + 20, &in_config->dvb_in_port, 1, 65536);
202 device_port->create_objects();
203 x1 += device_port->get_w() + 10;
204 dialog->add_subwindow(number_title = new BC_Title(x1, y, _("Adaptor:")));
205 device_number = new VDeviceTumbleBox(this, x1, y + 20, &in_config->dvb_in_number, 0, 16);
206 device_number->create_objects();
209 int VDevicePrefs::create_lml_objs()
212 int x1 = x + menu->get_w() + 5;
213 BC_Resources *resources = BC_WindowBase::get_resources();
218 output_char = out_config->lml_out_device;
221 output_char = in_config->lml_in_device;
224 dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device path:"), MEDIUMFONT, resources->text_default));
225 x1 += device_title->get_w() + 10;
226 dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
230 int VDevicePrefs::create_buz_objs()
233 int x1 = x + menu->get_w() + 5;
236 BC_Resources *resources = BC_WindowBase::get_resources();
241 output_char = out_config->buz_out_device;
244 output_char = in_config->buz_in_device;
247 dialog->add_subwindow(device_title = new BC_Title(x1, y1, _("Device path:"), MEDIUMFONT, resources->text_default));
250 dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y1, output_char));
252 if(driver == PLAYBACK_BUZ)
254 dialog->add_subwindow(buz_swap_channels =
255 new VDeviceCheckBox(x2, y1, &out_config->buz_swap_fields, _("Swap fields")));
258 if(driver == PLAYBACK_BUZ)
260 dialog->add_subwindow(output_title = new BC_Title(x1, y1, _("Output channel:")));
262 channel_picker = new PrefsChannelPicker(pwindow->mwindow,
264 pwindow->mwindow->channeldb_buz,
267 channel_picker->create_objects();
272 int VDevicePrefs::create_firewire_objs()
275 char *output_char = 0;
276 int x1 = x + menu->get_w() + 5;
277 BC_Resources *resources = BC_WindowBase::get_resources();
283 if(driver == PLAYBACK_DV1394)
284 output_char = out_config->dv1394_path;
286 if(driver == PLAYBACK_FIREWIRE)
287 output_char = out_config->firewire_path;
290 if(driver == CAPTURE_FIREWIRE)
291 output_char = in_config->firewire_path;
297 dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device Path:"), MEDIUMFONT, resources->text_default));
298 dialog->add_subwindow(firewire_path = new VDeviceTextBox(x1, y + 20, output_char));
299 x1 += firewire_path->get_w() + 5;
306 if(driver == PLAYBACK_DV1394)
307 output_int = &out_config->dv1394_port;
309 output_int = &out_config->firewire_port;
312 output_int = &in_config->firewire_port;
315 dialog->add_subwindow(port_title = new BC_Title(x1, y, _("Port:"), MEDIUMFONT, resources->text_default));
316 dialog->add_subwindow(firewire_port = new VDeviceIntBox(x1, y + 20, output_int));
317 x1 += firewire_port->get_w() + 5;
323 if(driver == PLAYBACK_DV1394)
324 output_int = &out_config->dv1394_channel;
326 output_int = &out_config->firewire_channel;
329 output_int = &in_config->firewire_channel;
333 dialog->add_subwindow(channel_title = new BC_Title(x1, y, _("Channel:"), MEDIUMFONT, resources->text_default));
334 dialog->add_subwindow(firewire_channel = new VDeviceIntBox(x1, y + 20, output_int));
335 x1 += firewire_channel->get_w() + 5;
342 if(driver == PLAYBACK_DV1394)
343 output_int = &out_config->dv1394_syt;
345 if(driver == PLAYBACK_FIREWIRE)
346 output_int = &out_config->firewire_syt;
356 dialog->add_subwindow(syt_title = new BC_Title(x1, y, _("Syt Offset:"), MEDIUMFONT, resources->text_default));
357 dialog->add_subwindow(firewire_syt = new VDeviceIntBox(x1, y + 20, output_int));
363 int VDevicePrefs::create_v4l_objs()
366 BC_Resources *resources = BC_WindowBase::get_resources();
367 int x1 = x + menu->get_w() + 5;
368 output_char = pwindow->thread->edl->session->vconfig_in->v4l_in_device;
369 dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device path:"), MEDIUMFONT, resources->text_default));
370 dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
374 int VDevicePrefs::create_v4l2_objs()
377 BC_Resources *resources = BC_WindowBase::get_resources();
378 int x1 = x + menu->get_w() + 5;
379 output_char = pwindow->thread->edl->session->vconfig_in->v4l2_in_device;
380 dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device path:"), MEDIUMFONT, resources->text_default));
381 dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
386 int VDevicePrefs::create_v4l2jpeg_objs()
388 BC_Resources *resources = BC_WindowBase::get_resources();
390 int x1 = x + menu->get_w() + 5;
391 output_char = pwindow->thread->edl->session->vconfig_in->v4l2jpeg_in_device;
392 dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device path:"), MEDIUMFONT, resources->text_default));
393 dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
400 int VDevicePrefs::create_screencap_objs()
403 BC_Resources *resources = BC_WindowBase::get_resources();
404 int x1 = x + menu->get_w() + 5;
405 output_char = pwindow->thread->edl->session->vconfig_in->screencapture_display;
406 dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Display:"), MEDIUMFONT, resources->text_default));
407 dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
411 int VDevicePrefs::create_x11_objs()
414 BC_Resources *resources = BC_WindowBase::get_resources();
415 int x1 = x + menu->get_w() + 5;
416 output_char = out_config->x11_host;
417 dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Display for compositor:"), MEDIUMFONT, resources->text_default));
418 dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
425 VDriverMenu::VDriverMenu(int x,
427 VDevicePrefs *device_prefs,
430 : BC_PopupMenu(x, y, 200, driver_to_string(*output))
432 this->output = output;
433 this->do_input = do_input;
434 this->device_prefs = device_prefs;
437 VDriverMenu::~VDriverMenu()
441 char* VDriverMenu::driver_to_string(int driver)
446 sprintf(string, VIDEO4LINUX_TITLE);
449 sprintf(string, VIDEO4LINUX2_TITLE);
451 case VIDEO4LINUX2JPEG:
452 sprintf(string, VIDEO4LINUX2JPEG_TITLE);
455 sprintf(string, SCREENCAPTURE_TITLE);
458 sprintf(string, CAPTURE_BUZ_TITLE);
461 sprintf(string, CAPTURE_LML_TITLE);
464 case CAPTURE_FIREWIRE:
465 sprintf(string, CAPTURE_FIREWIRE_TITLE);
467 case CAPTURE_IEC61883:
468 sprintf(string, CAPTURE_IEC61883_TITLE);
472 sprintf(string, CAPTURE_DVB_TITLE);
475 sprintf(string, PLAYBACK_X11_TITLE);
477 case PLAYBACK_X11_XV:
478 sprintf(string, PLAYBACK_X11_XV_TITLE);
480 case PLAYBACK_X11_GL:
481 sprintf(string, PLAYBACK_X11_GL_TITLE);
484 sprintf(string, PLAYBACK_LML_TITLE);
487 sprintf(string, PLAYBACK_BUZ_TITLE);
490 case PLAYBACK_FIREWIRE:
491 sprintf(string, PLAYBACK_FIREWIRE_TITLE);
493 case PLAYBACK_DV1394:
494 sprintf(string, PLAYBACK_DV1394_TITLE);
496 case PLAYBACK_IEC61883:
497 sprintf(string, PLAYBACK_IEC61883_TITLE);
506 int VDriverMenu::create_objects()
510 add_item(new VDriverItem(this, VIDEO4LINUX_TITLE, VIDEO4LINUX));
511 #ifdef HAVE_VIDEO4LINUX2
512 add_item(new VDriverItem(this, VIDEO4LINUX2_TITLE, VIDEO4LINUX2));
513 add_item(new VDriverItem(this, VIDEO4LINUX2JPEG_TITLE, VIDEO4LINUX2JPEG));
515 add_item(new VDriverItem(this, SCREENCAPTURE_TITLE, SCREENCAPTURE));
516 add_item(new VDriverItem(this, CAPTURE_BUZ_TITLE, CAPTURE_BUZ));
518 add_item(new VDriverItem(this, CAPTURE_FIREWIRE_TITLE, CAPTURE_FIREWIRE));
519 add_item(new VDriverItem(this, CAPTURE_IEC61883_TITLE, CAPTURE_IEC61883));
521 add_item(new VDriverItem(this, CAPTURE_DVB_TITLE, CAPTURE_DVB));
525 add_item(new VDriverItem(this, PLAYBACK_X11_TITLE, PLAYBACK_X11));
526 add_item(new VDriverItem(this, PLAYBACK_X11_XV_TITLE, PLAYBACK_X11_XV));
528 add_item(new VDriverItem(this, PLAYBACK_X11_GL_TITLE, PLAYBACK_X11_GL));
530 add_item(new VDriverItem(this, PLAYBACK_BUZ_TITLE, PLAYBACK_BUZ));
532 add_item(new VDriverItem(this, PLAYBACK_FIREWIRE_TITLE, PLAYBACK_FIREWIRE));
533 add_item(new VDriverItem(this, PLAYBACK_DV1394_TITLE, PLAYBACK_DV1394));
534 add_item(new VDriverItem(this, PLAYBACK_IEC61883_TITLE, PLAYBACK_IEC61883));
541 VDriverItem::VDriverItem(VDriverMenu *popup, char *text, int driver)
545 this->driver = driver;
548 VDriverItem::~VDriverItem()
552 int VDriverItem::handle_event()
554 popup->set_text(get_text());
555 *(popup->output) = driver;
556 popup->device_prefs->initialize();
563 VDeviceTextBox::VDeviceTextBox(int x, int y, char *output)
564 : BC_TextBox(x, y, 200, 1, output)
566 this->output = output;
569 int VDeviceTextBox::handle_event()
571 strcpy(output, get_text());
574 VDeviceTumbleBox::VDeviceTumbleBox(VDevicePrefs *prefs,
580 : BC_TumbleTextBox(prefs->dialog,
588 this->output = output;
591 int VDeviceTumbleBox::handle_event()
593 *output = atol(get_text());
602 VDeviceIntBox::VDeviceIntBox(int x, int y, int *output)
603 : BC_TextBox(x, y, 60, 1, *output)
605 this->output = output;
608 int VDeviceIntBox::handle_event()
610 *output = atol(get_text());
618 VDeviceCheckBox::VDeviceCheckBox(int x, int y, int *output, char *text)
619 : BC_CheckBox(x, y, *output, text)
621 this->output = output;
623 int VDeviceCheckBox::handle_event()
625 *output = get_value();