Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

vdeviceprefs.C

Go to the documentation of this file.
00001 #include "channelpicker.h"
00002 #ifdef HAVE_CONFIG_H
00003 #include "config.h"
00004 #endif
00005 #include "edl.h"
00006 #include "edlsession.h"
00007 #include "language.h"
00008 #include "mwindow.h"
00009 #include "vdeviceprefs.h"
00010 #include "videoconfig.h"
00011 #include "videodevice.inc"
00012 #include "playbackconfig.h"
00013 #include "preferences.h"
00014 #include "preferencesthread.h"
00015 #include "recordconfig.h"
00016 #include <string.h>
00017 
00018 
00019 VDevicePrefs::VDevicePrefs(int x, 
00020         int y, 
00021         PreferencesWindow *pwindow, 
00022         PreferencesDialog *dialog, 
00023         VideoOutConfig *out_config,
00024         VideoInConfig *in_config,
00025         int mode)
00026 {
00027         this->pwindow = pwindow;
00028         this->dialog = dialog;
00029         this->driver = -1;
00030         this->mode = mode;
00031         this->out_config = out_config;
00032         this->in_config = in_config;
00033         this->x = x;
00034         this->y = y;
00035         menu = 0;
00036         reset_objects();
00037 
00038 }
00039 
00040 VDevicePrefs::~VDevicePrefs()
00041 {
00042         delete_objects();
00043         if(menu) delete menu;
00044 }
00045 
00046 
00047 void VDevicePrefs::reset_objects()
00048 {
00049         device_text = 0;
00050 
00051         port_title = 0;
00052         channel_title = 0;
00053         device_title = 0;
00054         syt_title = 0;
00055 
00056         firewire_port = 0;
00057         firewire_channel = 0;
00058         firewire_channels = 0;
00059         firewire_syt = 0;
00060         firewire_path = 0;
00061 }
00062 
00063 int VDevicePrefs::initialize()
00064 {
00065         int *driver = 0;
00066         delete_objects();
00067 
00068         switch(mode)
00069         {
00070                 case MODEPLAY:
00071                         driver = &out_config->driver;
00072                         break;
00073 
00074                 case MODERECORD:
00075                         driver = &in_config->driver;
00076                         break;
00077         }
00078         this->driver = *driver;
00079 
00080         if(!menu)
00081         {
00082                 dialog->add_subwindow(menu = new VDriverMenu(x,
00083                         y + 10,
00084                         this, 
00085                         (mode == MODERECORD), 
00086                         driver));
00087                 menu->create_objects();
00088         }
00089 
00090         switch(this->driver)
00091         {
00092                 case VIDEO4LINUX:
00093                         create_v4l_objs();
00094                         break;
00095                 case VIDEO4LINUX2:
00096                         create_v4l2_objs();
00097                         break;
00098                 case VIDEO4LINUX2JPEG:
00099                         create_v4l2jpeg_objs();
00100                         break;
00101                 case SCREENCAPTURE:
00102                         create_screencap_objs();
00103                         break;
00104                 case CAPTURE_LML:
00105                         create_lml_objs();
00106                         break;
00107                 case CAPTURE_BUZ:
00108                 case PLAYBACK_BUZ:
00109                         create_buz_objs();
00110                         break;
00111                 case PLAYBACK_X11:
00112                 case PLAYBACK_X11_XV:
00113                         create_x11_objs();
00114                         break;
00115                 case PLAYBACK_DV1394:
00116                 case PLAYBACK_FIREWIRE:
00117                 case PLAYBACK_IEC61883:
00118                 case CAPTURE_FIREWIRE:
00119                 case CAPTURE_IEC61883:
00120                         create_firewire_objs();
00121                         break;
00122         }
00123         return 0;
00124 }
00125 
00126 int VDevicePrefs::delete_objects()
00127 {
00128         switch(driver)
00129         {
00130                 case PLAYBACK_LML:
00131                 case PLAYBACK_BUZ:
00132                         delete output_title;
00133                         delete channel_picker;
00134                         delete buz_swap_channels;
00135                         break;
00136         }
00137 
00138 
00139         
00140         if(device_text) delete device_text;
00141 
00142         if(port_title) delete port_title;
00143         if(firewire_port) delete firewire_port;
00144         if(channel_title) delete channel_title;
00145         if(firewire_channel) delete firewire_channel;
00146         if(device_title) delete device_title;
00147         if(firewire_path) delete firewire_path;
00148         if(syt_title) delete syt_title;
00149         if(firewire_syt) delete firewire_syt;
00150 
00151         reset_objects();
00152         driver = -1;
00153         return 0;
00154 }
00155 
00156 int VDevicePrefs::create_lml_objs()
00157 {
00158         char *output_char;
00159         int x1 = x + menu->get_w() + 5;
00160         BC_Resources *resources = BC_WindowBase::get_resources();
00161 
00162         switch(mode)
00163         {
00164                 case MODEPLAY: 
00165                         output_char = out_config->lml_out_device;
00166                         break;
00167                 case MODERECORD:
00168                         output_char = in_config->lml_in_device;
00169                         break;
00170         }
00171         dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device path:"), MEDIUMFONT, resources->text_default));
00172         dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
00173         return 0;
00174 }
00175 
00176 int VDevicePrefs::create_buz_objs()
00177 {
00178         char *output_char;
00179         int x1 = x + menu->get_w() + 5;
00180         int x2 = x1 + 210;
00181         int y1 = y;
00182         BC_Resources *resources = BC_WindowBase::get_resources();
00183 
00184         switch(mode)
00185         {
00186                 case MODEPLAY: 
00187                         output_char = out_config->buz_out_device;
00188                         break;
00189                 case MODERECORD:
00190                         output_char = in_config->buz_in_device;
00191                         break;
00192         }
00193         dialog->add_subwindow(device_title = new BC_Title(x1, y1, _("Device path:"), MEDIUMFONT, resources->text_default));
00194 
00195         y1 += 20;
00196         dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y1, output_char));
00197 
00198         if(driver == PLAYBACK_BUZ)
00199         {
00200                 dialog->add_subwindow(buz_swap_channels = 
00201                         new VDeviceCheckBox(x2, y1, &out_config->buz_swap_fields, _("Swap fields")));
00202         }
00203         y1 += 30;
00204         if(driver == PLAYBACK_BUZ)
00205         {
00206                 dialog->add_subwindow(output_title = new BC_Title(x1, y1, _("Output channel:")));
00207                 y1 += 20;
00208                 channel_picker = new PrefsChannelPicker(pwindow->mwindow, 
00209                         this, 
00210                         pwindow->mwindow->channeldb_buz, 
00211                         x1,
00212                         y1);
00213                 channel_picker->create_objects();
00214         }
00215         return 0;
00216 }
00217 
00218 int VDevicePrefs::create_firewire_objs()
00219 {
00220         int *output_int = 0;
00221         char *output_char = 0;
00222         int x1 = x + menu->get_w() + 5;
00223         BC_Resources *resources = BC_WindowBase::get_resources();
00224 
00225 // Firewire path
00226         switch(mode)
00227         {
00228                 case MODEPLAY:
00229                         if(driver == PLAYBACK_DV1394)
00230                                 output_char = out_config->dv1394_path;
00231                         else
00232                         if(driver == PLAYBACK_FIREWIRE)
00233                                 output_char = out_config->firewire_path;
00234                         break;
00235                 case MODERECORD:
00236 // Our version of raw1394 doesn't support changing the input path
00237                         output_char = 0;
00238                         break;
00239         }
00240 
00241         if(output_char)
00242         {
00243                 dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device Path:"), MEDIUMFONT, resources->text_default));
00244                 dialog->add_subwindow(firewire_path = new VDeviceTextBox(x1, y + 20, output_char));
00245                 x1 += firewire_path->get_w() + 5;
00246         }
00247 
00248 // Firewire port
00249         switch(mode)
00250         {
00251                 case MODEPLAY:
00252                         if(driver == PLAYBACK_DV1394)
00253                                 output_int = &out_config->dv1394_port;
00254                         else
00255                                 output_int = &out_config->firewire_port;
00256                         break;
00257                 case MODERECORD:
00258                         output_int = &in_config->firewire_port;
00259                         break;
00260         }
00261         dialog->add_subwindow(port_title = new BC_Title(x1, y, _("Port:"), MEDIUMFONT, resources->text_default));
00262         dialog->add_subwindow(firewire_port = new VDeviceIntBox(x1, y + 20, output_int));
00263         x1 += firewire_port->get_w() + 5;
00264 
00265 // Firewire channel
00266         switch(mode)
00267         {
00268                 case MODEPLAY:
00269                         if(driver == PLAYBACK_DV1394)
00270                                 output_int = &out_config->dv1394_channel;
00271                         else
00272                                 output_int = &out_config->firewire_channel;
00273                         break;
00274                 case MODERECORD:
00275                         output_int = &in_config->firewire_channel;
00276                         break;
00277         }
00278 
00279         dialog->add_subwindow(channel_title = new BC_Title(x1, y, _("Channel:"), MEDIUMFONT, resources->text_default));
00280         dialog->add_subwindow(firewire_channel = new VDeviceIntBox(x1, y + 20, output_int));
00281         x1 += firewire_channel->get_w() + 5;
00282 
00283 
00284 // Firewire syt
00285         switch(mode)
00286         {
00287                 case MODEPLAY:
00288                         if(driver == PLAYBACK_DV1394)
00289                                 output_int = &out_config->dv1394_syt;
00290                         else
00291                         if(driver == PLAYBACK_FIREWIRE)
00292                                 output_int = &out_config->firewire_syt;
00293                         else
00294                                 output_int = 0;
00295                         break;
00296                 case MODERECORD:
00297                         output_int = 0;
00298                         break;
00299         }
00300         if(output_int)
00301         {
00302                 dialog->add_subwindow(syt_title = new BC_Title(x1, y, _("Syt Offset:"), MEDIUMFONT, resources->text_default));
00303                 dialog->add_subwindow(firewire_syt = new VDeviceIntBox(x1, y + 20, output_int));
00304         }
00305 
00306         return 0;
00307 }
00308 
00309 int VDevicePrefs::create_v4l_objs()
00310 {
00311         char *output_char;
00312         BC_Resources *resources = BC_WindowBase::get_resources();
00313         int x1 = x + menu->get_w() + 5;
00314         output_char = pwindow->thread->edl->session->vconfig_in->v4l_in_device;
00315         dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device path:"), MEDIUMFONT, resources->text_default));
00316         dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
00317         return 0;
00318 }
00319 
00320 int VDevicePrefs::create_v4l2_objs()
00321 {
00322         char *output_char;
00323         BC_Resources *resources = BC_WindowBase::get_resources();
00324         int x1 = x + menu->get_w() + 5;
00325         output_char = pwindow->thread->edl->session->vconfig_in->v4l2_in_device;
00326         dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device path:"), MEDIUMFONT, resources->text_default));
00327         dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
00328         return 0;
00329 }
00330 
00331 int VDevicePrefs::create_v4l2jpeg_objs()
00332 {
00333         BC_Resources *resources = BC_WindowBase::get_resources();
00334         char *output_char;
00335         int x1 = x + menu->get_w() + 5;
00336         output_char = pwindow->thread->edl->session->vconfig_in->v4l2jpeg_in_device;
00337         dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device path:"), MEDIUMFONT, resources->text_default));
00338         dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
00339         return 0;
00340 }
00341 
00342 
00343 
00344 int VDevicePrefs::create_screencap_objs()
00345 {
00346         char *output_char;
00347         BC_Resources *resources = BC_WindowBase::get_resources();
00348         int x1 = x + menu->get_w() + 5;
00349         output_char = pwindow->thread->edl->session->vconfig_in->screencapture_display;
00350         dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Display:"), MEDIUMFONT, resources->text_default));
00351         dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
00352         return 0;
00353 }
00354 
00355 int VDevicePrefs::create_x11_objs()
00356 {
00357         char *output_char;
00358         BC_Resources *resources = BC_WindowBase::get_resources();
00359         int x1 = x + menu->get_w() + 5;
00360         output_char = out_config->x11_host;
00361         dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Display for compositor:"), MEDIUMFONT, resources->text_default));
00362         dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
00363         return 0;
00364 }
00365 
00366 
00367 
00368 
00369 VDriverMenu::VDriverMenu(int x, 
00370         int y, 
00371         VDevicePrefs *device_prefs, 
00372         int do_input, 
00373         int *output)
00374  : BC_PopupMenu(x, y, 200, driver_to_string(*output))
00375 {
00376         this->output = output;
00377         this->do_input = do_input;
00378         this->device_prefs = device_prefs;
00379 }
00380 
00381 VDriverMenu::~VDriverMenu()
00382 {
00383 }
00384 
00385 char* VDriverMenu::driver_to_string(int driver)
00386 {
00387         switch(driver)
00388         {
00389                 case VIDEO4LINUX:
00390                         sprintf(string, VIDEO4LINUX_TITLE);
00391                         break;
00392                 case VIDEO4LINUX2:
00393                         sprintf(string, VIDEO4LINUX2_TITLE);
00394                         break;
00395                 case VIDEO4LINUX2JPEG:
00396                         sprintf(string, VIDEO4LINUX2JPEG_TITLE);
00397                         break;
00398                 case SCREENCAPTURE:
00399                         sprintf(string, SCREENCAPTURE_TITLE);
00400                         break;
00401                 case CAPTURE_BUZ:
00402                         sprintf(string, CAPTURE_BUZ_TITLE);
00403                         break;
00404                 case CAPTURE_LML:
00405                         sprintf(string, CAPTURE_LML_TITLE);
00406                         break;
00407                 case CAPTURE_FIREWIRE:
00408                         sprintf(string, CAPTURE_FIREWIRE_TITLE);
00409                         break;
00410                 case CAPTURE_IEC61883:
00411                         sprintf(string, CAPTURE_IEC61883_TITLE);
00412                         break;
00413                 case PLAYBACK_X11:
00414                         sprintf(string, PLAYBACK_X11_TITLE);
00415                         break;
00416                 case PLAYBACK_X11_XV:
00417                         sprintf(string, PLAYBACK_X11_XV_TITLE);
00418                         break;
00419                 case PLAYBACK_LML:
00420                         sprintf(string, PLAYBACK_LML_TITLE);
00421                         break;
00422                 case PLAYBACK_BUZ:
00423                         sprintf(string, PLAYBACK_BUZ_TITLE);
00424                         break;
00425                 case PLAYBACK_FIREWIRE:
00426                         sprintf(string, PLAYBACK_FIREWIRE_TITLE);
00427                         break;
00428                 case PLAYBACK_DV1394:
00429                         sprintf(string, PLAYBACK_DV1394_TITLE);
00430                         break;
00431                 case PLAYBACK_IEC61883:
00432                         sprintf(string, PLAYBACK_IEC61883_TITLE);
00433                         break;
00434                 default:
00435                         sprintf(string, "");
00436         }
00437         return string;
00438 }
00439 
00440 int VDriverMenu::create_objects()
00441 {
00442         if(do_input)
00443         {
00444                 add_item(new VDriverItem(this, VIDEO4LINUX_TITLE, VIDEO4LINUX));
00445 #ifdef HAVE_VIDEO4LINUX2
00446                 add_item(new VDriverItem(this, VIDEO4LINUX2_TITLE, VIDEO4LINUX2));
00447                 add_item(new VDriverItem(this, VIDEO4LINUX2JPEG_TITLE, VIDEO4LINUX2JPEG));
00448 #endif
00449                 add_item(new VDriverItem(this, SCREENCAPTURE_TITLE, SCREENCAPTURE));
00450                 add_item(new VDriverItem(this, CAPTURE_BUZ_TITLE, CAPTURE_BUZ));
00451                 add_item(new VDriverItem(this, CAPTURE_FIREWIRE_TITLE, CAPTURE_FIREWIRE));
00452                 add_item(new VDriverItem(this, CAPTURE_IEC61883_TITLE, CAPTURE_IEC61883));
00453         }
00454         else
00455         {
00456                 add_item(new VDriverItem(this, PLAYBACK_X11_TITLE, PLAYBACK_X11));
00457                 add_item(new VDriverItem(this, PLAYBACK_X11_XV_TITLE, PLAYBACK_X11_XV));
00458                 add_item(new VDriverItem(this, PLAYBACK_BUZ_TITLE, PLAYBACK_BUZ));
00459                 add_item(new VDriverItem(this, PLAYBACK_FIREWIRE_TITLE, PLAYBACK_FIREWIRE));
00460                 add_item(new VDriverItem(this, PLAYBACK_DV1394_TITLE, PLAYBACK_DV1394));
00461                 add_item(new VDriverItem(this, PLAYBACK_IEC61883_TITLE, PLAYBACK_IEC61883));
00462         }
00463         return 0;
00464 }
00465 
00466 
00467 VDriverItem::VDriverItem(VDriverMenu *popup, char *text, int driver)
00468  : BC_MenuItem(text)
00469 {
00470         this->popup = popup;
00471         this->driver = driver;
00472 }
00473 
00474 VDriverItem::~VDriverItem()
00475 {
00476 }
00477 
00478 int VDriverItem::handle_event()
00479 {
00480         popup->set_text(get_text());
00481         *(popup->output) = driver;
00482         popup->device_prefs->initialize();
00483         return 1;
00484 }
00485 
00486 
00487 
00488 
00489 VDeviceTextBox::VDeviceTextBox(int x, int y, char *output)
00490  : BC_TextBox(x, y, 200, 1, output)
00491 { 
00492         this->output = output; 
00493 }
00494 
00495 int VDeviceTextBox::handle_event() 
00496 { 
00497         strcpy(output, get_text()); 
00498 }
00499 
00500 VDeviceIntBox::VDeviceIntBox(int x, int y, int *output)
00501  : BC_TextBox(x, y, 60, 1, *output)
00502 { 
00503         this->output = output; 
00504 }
00505 
00506 int VDeviceIntBox::handle_event() 
00507 { 
00508         *output = atol(get_text()); 
00509         return 1;
00510 }
00511 
00512 
00513 
00514 VDeviceCheckBox::VDeviceCheckBox(int x, int y, int *output, char *text)
00515  : BC_CheckBox(x, y, *output, text)
00516 {
00517         this->output = output;
00518 }
00519 int VDeviceCheckBox::handle_event()
00520 {
00521         *output = get_value();
00522         return 1;
00523 }
00524 

Generated on Sun Jan 8 13:39:01 2006 for Cinelerra-svn by  doxygen 1.4.4