1 #include "channelpicker.h"
6 #include "edlsession.h"
9 #include "vdeviceprefs.h"
10 #include "videoconfig.h"
11 #include "videodevice.inc"
12 #include "playbackconfig.h"
13 #include "preferences.h"
14 #include "preferencesthread.h"
15 #include "recordconfig.h"
19 VDevicePrefs::VDevicePrefs(int x,
21 PreferencesWindow *pwindow,
22 PreferencesDialog *dialog,
23 VideoOutConfig *out_config,
24 VideoInConfig *in_config,
27 this->pwindow = pwindow;
28 this->dialog = dialog;
31 this->out_config = out_config;
32 this->in_config = in_config;
40 VDevicePrefs::~VDevicePrefs()
47 void VDevicePrefs::reset_objects()
58 firewire_channels = 0;
63 int VDevicePrefs::initialize()
71 driver = &out_config->driver;
75 driver = &in_config->driver;
78 this->driver = *driver;
82 dialog->add_subwindow(menu = new VDriverMenu(x,
87 menu->create_objects();
98 case VIDEO4LINUX2JPEG:
99 create_v4l2jpeg_objs();
102 create_screencap_objs();
112 case PLAYBACK_X11_XV:
115 case PLAYBACK_DV1394:
116 case PLAYBACK_FIREWIRE:
117 case PLAYBACK_IEC61883:
118 case CAPTURE_FIREWIRE:
119 case CAPTURE_IEC61883:
120 create_firewire_objs();
126 int VDevicePrefs::delete_objects()
133 delete channel_picker;
134 delete buz_swap_channels;
140 if(device_text) delete device_text;
142 if(port_title) delete port_title;
143 if(firewire_port) delete firewire_port;
144 if(channel_title) delete channel_title;
145 if(firewire_channel) delete firewire_channel;
146 if(device_title) delete device_title;
147 if(firewire_path) delete firewire_path;
148 if(syt_title) delete syt_title;
149 if(firewire_syt) delete firewire_syt;
156 int VDevicePrefs::create_lml_objs()
159 int x1 = x + menu->get_w() + 5;
160 BC_Resources *resources = BC_WindowBase::get_resources();
165 output_char = out_config->lml_out_device;
168 output_char = in_config->lml_in_device;
171 dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device path:"), MEDIUMFONT, resources->text_default));
172 dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
176 int VDevicePrefs::create_buz_objs()
179 int x1 = x + menu->get_w() + 5;
182 BC_Resources *resources = BC_WindowBase::get_resources();
187 output_char = out_config->buz_out_device;
190 output_char = in_config->buz_in_device;
193 dialog->add_subwindow(device_title = new BC_Title(x1, y1, _("Device path:"), MEDIUMFONT, resources->text_default));
196 dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y1, output_char));
198 if(driver == PLAYBACK_BUZ)
200 dialog->add_subwindow(buz_swap_channels =
201 new VDeviceCheckBox(x2, y1, &out_config->buz_swap_fields, _("Swap fields")));
204 if(driver == PLAYBACK_BUZ)
206 dialog->add_subwindow(output_title = new BC_Title(x1, y1, _("Output channel:")));
208 channel_picker = new PrefsChannelPicker(pwindow->mwindow,
210 pwindow->mwindow->channeldb_buz,
213 channel_picker->create_objects();
218 int VDevicePrefs::create_firewire_objs()
221 char *output_char = 0;
222 int x1 = x + menu->get_w() + 5;
223 BC_Resources *resources = BC_WindowBase::get_resources();
229 if(driver == PLAYBACK_DV1394)
230 output_char = out_config->dv1394_path;
232 if(driver == PLAYBACK_FIREWIRE)
233 output_char = out_config->firewire_path;
236 // Our version of raw1394 doesn't support changing the input path
243 dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device Path:"), MEDIUMFONT, resources->text_default));
244 dialog->add_subwindow(firewire_path = new VDeviceTextBox(x1, y + 20, output_char));
245 x1 += firewire_path->get_w() + 5;
252 if(driver == PLAYBACK_DV1394)
253 output_int = &out_config->dv1394_port;
255 output_int = &out_config->firewire_port;
258 output_int = &in_config->firewire_port;
261 dialog->add_subwindow(port_title = new BC_Title(x1, y, _("Port:"), MEDIUMFONT, resources->text_default));
262 dialog->add_subwindow(firewire_port = new VDeviceIntBox(x1, y + 20, output_int));
263 x1 += firewire_port->get_w() + 5;
269 if(driver == PLAYBACK_DV1394)
270 output_int = &out_config->dv1394_channel;
272 output_int = &out_config->firewire_channel;
275 output_int = &in_config->firewire_channel;
279 dialog->add_subwindow(channel_title = new BC_Title(x1, y, _("Channel:"), MEDIUMFONT, resources->text_default));
280 dialog->add_subwindow(firewire_channel = new VDeviceIntBox(x1, y + 20, output_int));
281 x1 += firewire_channel->get_w() + 5;
288 if(driver == PLAYBACK_DV1394)
289 output_int = &out_config->dv1394_syt;
291 if(driver == PLAYBACK_FIREWIRE)
292 output_int = &out_config->firewire_syt;
302 dialog->add_subwindow(syt_title = new BC_Title(x1, y, _("Syt Offset:"), MEDIUMFONT, resources->text_default));
303 dialog->add_subwindow(firewire_syt = new VDeviceIntBox(x1, y + 20, output_int));
309 int VDevicePrefs::create_v4l_objs()
312 BC_Resources *resources = BC_WindowBase::get_resources();
313 int x1 = x + menu->get_w() + 5;
314 output_char = pwindow->thread->edl->session->vconfig_in->v4l_in_device;
315 dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device path:"), MEDIUMFONT, resources->text_default));
316 dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
320 int VDevicePrefs::create_v4l2_objs()
323 BC_Resources *resources = BC_WindowBase::get_resources();
324 int x1 = x + menu->get_w() + 5;
325 output_char = pwindow->thread->edl->session->vconfig_in->v4l2_in_device;
326 dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device path:"), MEDIUMFONT, resources->text_default));
327 dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
331 int VDevicePrefs::create_v4l2jpeg_objs()
333 BC_Resources *resources = BC_WindowBase::get_resources();
335 int x1 = x + menu->get_w() + 5;
336 output_char = pwindow->thread->edl->session->vconfig_in->v4l2jpeg_in_device;
337 dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device path:"), MEDIUMFONT, resources->text_default));
338 dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
344 int VDevicePrefs::create_screencap_objs()
347 BC_Resources *resources = BC_WindowBase::get_resources();
348 int x1 = x + menu->get_w() + 5;
349 output_char = pwindow->thread->edl->session->vconfig_in->screencapture_display;
350 dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Display:"), MEDIUMFONT, resources->text_default));
351 dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
355 int VDevicePrefs::create_x11_objs()
358 BC_Resources *resources = BC_WindowBase::get_resources();
359 int x1 = x + menu->get_w() + 5;
360 output_char = out_config->x11_host;
361 dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Display for compositor:"), MEDIUMFONT, resources->text_default));
362 dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
369 VDriverMenu::VDriverMenu(int x,
371 VDevicePrefs *device_prefs,
374 : BC_PopupMenu(x, y, 200, driver_to_string(*output))
376 this->output = output;
377 this->do_input = do_input;
378 this->device_prefs = device_prefs;
381 VDriverMenu::~VDriverMenu()
385 char* VDriverMenu::driver_to_string(int driver)
390 sprintf(string, VIDEO4LINUX_TITLE);
393 sprintf(string, VIDEO4LINUX2_TITLE);
395 case VIDEO4LINUX2JPEG:
396 sprintf(string, VIDEO4LINUX2JPEG_TITLE);
399 sprintf(string, SCREENCAPTURE_TITLE);
402 sprintf(string, CAPTURE_BUZ_TITLE);
405 sprintf(string, CAPTURE_LML_TITLE);
408 case CAPTURE_FIREWIRE:
409 sprintf(string, CAPTURE_FIREWIRE_TITLE);
411 case CAPTURE_IEC61883:
412 sprintf(string, CAPTURE_IEC61883_TITLE);
416 sprintf(string, PLAYBACK_X11_TITLE);
418 case PLAYBACK_X11_XV:
419 sprintf(string, PLAYBACK_X11_XV_TITLE);
422 sprintf(string, PLAYBACK_LML_TITLE);
425 sprintf(string, PLAYBACK_BUZ_TITLE);
428 case PLAYBACK_FIREWIRE:
429 sprintf(string, PLAYBACK_FIREWIRE_TITLE);
431 case PLAYBACK_DV1394:
432 sprintf(string, PLAYBACK_DV1394_TITLE);
434 case PLAYBACK_IEC61883:
435 sprintf(string, PLAYBACK_IEC61883_TITLE);
444 int VDriverMenu::create_objects()
448 add_item(new VDriverItem(this, VIDEO4LINUX_TITLE, VIDEO4LINUX));
449 #ifdef HAVE_VIDEO4LINUX2
450 add_item(new VDriverItem(this, VIDEO4LINUX2_TITLE, VIDEO4LINUX2));
451 add_item(new VDriverItem(this, VIDEO4LINUX2JPEG_TITLE, VIDEO4LINUX2JPEG));
453 add_item(new VDriverItem(this, SCREENCAPTURE_TITLE, SCREENCAPTURE));
454 add_item(new VDriverItem(this, CAPTURE_BUZ_TITLE, CAPTURE_BUZ));
456 add_item(new VDriverItem(this, CAPTURE_FIREWIRE_TITLE, CAPTURE_FIREWIRE));
457 add_item(new VDriverItem(this, CAPTURE_IEC61883_TITLE, CAPTURE_IEC61883));
462 add_item(new VDriverItem(this, PLAYBACK_X11_TITLE, PLAYBACK_X11));
463 add_item(new VDriverItem(this, PLAYBACK_X11_XV_TITLE, PLAYBACK_X11_XV));
464 add_item(new VDriverItem(this, PLAYBACK_BUZ_TITLE, PLAYBACK_BUZ));
466 add_item(new VDriverItem(this, PLAYBACK_FIREWIRE_TITLE, PLAYBACK_FIREWIRE));
467 add_item(new VDriverItem(this, PLAYBACK_DV1394_TITLE, PLAYBACK_DV1394));
468 add_item(new VDriverItem(this, PLAYBACK_IEC61883_TITLE, PLAYBACK_IEC61883));
475 VDriverItem::VDriverItem(VDriverMenu *popup, char *text, int driver)
479 this->driver = driver;
482 VDriverItem::~VDriverItem()
486 int VDriverItem::handle_event()
488 popup->set_text(get_text());
489 *(popup->output) = driver;
490 popup->device_prefs->initialize();
497 VDeviceTextBox::VDeviceTextBox(int x, int y, char *output)
498 : BC_TextBox(x, y, 200, 1, output)
500 this->output = output;
503 int VDeviceTextBox::handle_event()
505 strcpy(output, get_text());
508 VDeviceIntBox::VDeviceIntBox(int x, int y, int *output)
509 : BC_TextBox(x, y, 60, 1, *output)
511 this->output = output;
514 int VDeviceIntBox::handle_event()
516 *output = atol(get_text());
522 VDeviceCheckBox::VDeviceCheckBox(int x, int y, int *output, char *text)
523 : BC_CheckBox(x, y, *output, text)
525 this->output = output;
527 int VDeviceCheckBox::handle_event()
529 *output = get_value();