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

playbackconfig.C

Go to the documentation of this file.
00001 #include "clip.h"
00002 #include "defaults.h"
00003 #include "playbackconfig.h"
00004 #include "videodevice.inc"
00005 #include <string.h>
00006 
00007 AudioOutConfig::AudioOutConfig(int duplex)
00008 {
00009         this->duplex = duplex;
00010 
00011         fragment_size = 16384;
00012         driver = AUDIO_OSS;
00013 
00014         audio_offset = 0.0;
00015 
00016         oss_out_bits = 16;
00017         for(int i = 0; i < MAXDEVICES; i++)
00018         {
00019                 oss_enable[i] = (i == 0);
00020                 sprintf(oss_out_device[i], "/dev/dsp");
00021                 oss_out_channels[i] = 2;
00022         }
00023 
00024         sprintf(esound_out_server, "");
00025         esound_out_port = 0;
00026 
00027         sprintf(alsa_out_device, "default");
00028         alsa_out_channels = 2;
00029         alsa_out_bits = 16;
00030         interrupt_workaround = 0;
00031 
00032         firewire_channels = 2;
00033         firewire_channel = 63;
00034         firewire_port = 0;
00035         strcpy(firewire_path, "/dev/video1394");
00036         firewire_syt = 30000;
00037 
00038         dv1394_channels = 2;
00039         dv1394_channel = 63;
00040         dv1394_port = 0;
00041         strcpy(dv1394_path, "/dev/dv1394");
00042         dv1394_syt = 30000;
00043 
00044         bzero(do_channel, sizeof(int) * MAX_CHANNELS);
00045 }
00046 
00047 AudioOutConfig::~AudioOutConfig()
00048 {
00049 }
00050 
00051 
00052 
00053 int AudioOutConfig::operator!=(AudioOutConfig &that)
00054 {
00055         return !(*this == that);
00056 }
00057 
00058 int AudioOutConfig::operator==(AudioOutConfig &that)
00059 {
00060         return 
00061                 fragment_size == that.fragment_size &&
00062                 driver == that.driver &&
00063                 EQUIV(audio_offset, that.audio_offset) &&
00064 
00065 
00066                 !strcmp(oss_out_device[0], that.oss_out_device[0]) && 
00067                 (oss_out_channels[0] == that.oss_out_channels[0]) && 
00068                 (oss_out_bits == that.oss_out_bits) && 
00069 
00070 
00071 
00072                 !strcmp(esound_out_server, that.esound_out_server) && 
00073                 (esound_out_port == that.esound_out_port) && 
00074 
00075 
00076 
00077                 !strcmp(alsa_out_device, that.alsa_out_device) &&
00078                 (alsa_out_channels == that.alsa_out_channels) &&
00079                 (alsa_out_bits == that.alsa_out_bits) &&
00080                 (interrupt_workaround == that.interrupt_workaround) &&
00081 
00082                 firewire_channels == that.firewire_channels &&
00083                 firewire_channel == that.firewire_channel &&
00084                 firewire_port == that.firewire_port &&
00085                 firewire_syt == that.firewire_syt &&
00086                 !strcmp(firewire_path, that.firewire_path) &&
00087 
00088                 dv1394_channels == that.dv1394_channels &&
00089                 dv1394_channel == that.dv1394_channel &&
00090                 dv1394_port == that.dv1394_port &&
00091                 dv1394_syt == that.dv1394_syt &&
00092                 !strcmp(dv1394_path, that.dv1394_path);
00093 }
00094 
00095 
00096 
00097 AudioOutConfig& AudioOutConfig::operator=(AudioOutConfig &that)
00098 {
00099         copy_from(&that);
00100         return *this;
00101 }
00102 
00103 void AudioOutConfig::copy_from(AudioOutConfig *src)
00104 {
00105         fragment_size = src->fragment_size;
00106         driver = src->driver;
00107         audio_offset = src->audio_offset;
00108 
00109         strcpy(esound_out_server, src->esound_out_server);
00110         esound_out_port = src->esound_out_port;
00111         for(int i = 0; i < MAXDEVICES; i++)
00112         {
00113                 oss_enable[i] = src->oss_enable[i];
00114                 strcpy(oss_out_device[i], src->oss_out_device[i]);
00115                 oss_out_channels[i] = src->oss_out_channels[i];
00116         }
00117         oss_out_bits = src->oss_out_bits;
00118 
00119         strcpy(alsa_out_device, src->alsa_out_device);
00120         alsa_out_channels = src->alsa_out_channels;
00121         alsa_out_bits = src->alsa_out_bits;
00122         interrupt_workaround = src->interrupt_workaround;
00123 
00124         firewire_channels = src->firewire_channels;
00125         firewire_channel = src->firewire_channel;
00126         firewire_port = src->firewire_port;
00127         firewire_syt = src->firewire_syt;
00128         strcpy(firewire_path, src->firewire_path);
00129 
00130         dv1394_channels = src->dv1394_channels;
00131         dv1394_channel = src->dv1394_channel;
00132         dv1394_port = src->dv1394_port;
00133         dv1394_syt = src->dv1394_syt;
00134         strcpy(dv1394_path, src->dv1394_path);
00135 
00136         for(int i = 0; i < MAXCHANNELS; i++)
00137                 do_channel[i] = src->do_channel[i];
00138 }
00139 
00140 int AudioOutConfig::load_defaults(Defaults *defaults)
00141 {
00142         char string[BCTEXTLEN];
00143 
00144         fragment_size = defaults->get("FRAGMENT_SIZE", fragment_size);
00145         audio_offset = defaults->get("AUDIO_OFFSET", audio_offset);
00146         sprintf(string, "AUDIO_OUT_DRIVER_%d", duplex);
00147         driver = defaults->get(string, driver);
00148 
00149         for(int i = 0; i < MAXDEVICES; i++)
00150         {
00151                 sprintf(string, "OSS_ENABLE_%d_%d", i, duplex);
00152                 oss_enable[i] = defaults->get(string, oss_enable[i]);
00153                 sprintf(string, "OSS_OUT_DEVICE_%d_%d", i, duplex);
00154                 defaults->get(string, oss_out_device[i]);
00155                 sprintf(string, "OSS_OUT_CHANNELS_%d_%d", i, duplex);
00156                 oss_out_channels[i] = defaults->get(string, oss_out_channels[i]);
00157         }
00158         sprintf(string, "OSS_OUT_BITS_%d", duplex);
00159         oss_out_bits = defaults->get(string, oss_out_bits);
00160 
00161         defaults->get("ALSA_OUT_DEVICE", alsa_out_device);
00162         alsa_out_channels = defaults->get("ALSA_OUT_CHANNELS", alsa_out_channels);
00163         alsa_out_bits = defaults->get("ALSA_OUT_BITS", alsa_out_bits);
00164         interrupt_workaround = defaults->get("ALSA_INTERRUPT_WORKAROUND", interrupt_workaround);
00165 
00166         sprintf(string, "ESOUND_OUT_SERVER_%d", duplex);
00167         defaults->get(string, esound_out_server);
00168         sprintf(string, "ESOUND_OUT_PORT_%d", duplex);
00169         esound_out_port =             defaults->get(string, esound_out_port);
00170 
00171         sprintf(string, "AFIREWIRE_OUT_CHANNELS");
00172         firewire_channels = defaults->get(string, firewire_channels);
00173         sprintf(string, "AFIREWIRE_OUT_CHANNEL");
00174         firewire_channel = defaults->get(string, firewire_channel);
00175         sprintf(string, "AFIREWIRE_OUT_PORT");
00176         firewire_port = defaults->get(string, firewire_port);
00177         sprintf(string, "AFIREWIRE_OUT_PATH");
00178         defaults->get(string, firewire_path);
00179         sprintf(string, "AFIREWIRE_OUT_SYT");
00180         firewire_syt = defaults->get(string, firewire_syt);
00181 
00182         sprintf(string, "ADV1394_OUT_CHANNELS");
00183         dv1394_channels = defaults->get(string, dv1394_channels);
00184         sprintf(string, "ADV1394_OUT_CHANNEL");
00185         dv1394_channel = defaults->get(string, dv1394_channel);
00186         sprintf(string, "ADV1394_OUT_PORT");
00187         dv1394_port = defaults->get(string, dv1394_port);
00188         sprintf(string, "ADV1394_OUT_PATH");
00189         defaults->get(string, dv1394_path);
00190         sprintf(string, "ADV1394_OUT_SYT");
00191         dv1394_syt = defaults->get(string, dv1394_syt);
00192 
00193         return 0;
00194 }
00195 
00196 int AudioOutConfig::save_defaults(Defaults *defaults)
00197 {
00198         char string[BCTEXTLEN];
00199 
00200         defaults->update("FRAGMENT_SIZE", fragment_size);
00201         defaults->update("AUDIO_OFFSET", audio_offset);
00202 
00203         sprintf(string, "AUDIO_OUT_DRIVER_%d", duplex);
00204         defaults->update(string, driver);
00205 
00206         for(int i = 0; i < MAXDEVICES; i++)
00207         {
00208                 sprintf(string, "OSS_ENABLE_%d_%d", i, duplex);
00209                 defaults->update(string, oss_enable[i]);
00210                 sprintf(string, "OSS_OUT_DEVICE_%d_%d", i, duplex);
00211                 defaults->update(string, oss_out_device[i]);
00212                 sprintf(string, "OSS_OUT_CHANNELS_%d_%d", i, duplex);
00213                 defaults->update(string, oss_out_channels[i]);
00214         }
00215         sprintf(string, "OSS_OUT_BITS_%d", duplex);
00216         defaults->update(string, oss_out_bits);
00217 
00218 
00219         defaults->update("ALSA_OUT_DEVICE", alsa_out_device);
00220         defaults->update("ALSA_OUT_CHANNELS", alsa_out_channels);
00221         defaults->update("ALSA_OUT_BITS", alsa_out_bits);
00222         defaults->update("ALSA_INTERRUPT_WORKAROUND", interrupt_workaround);
00223 
00224         sprintf(string, "ESOUND_OUT_SERVER_%d", duplex);
00225         defaults->update(string, esound_out_server);
00226         sprintf(string, "ESOUND_OUT_PORT_%d", duplex);
00227         defaults->update(string, esound_out_port);
00228 
00229         sprintf(string, "AFIREWIRE_OUT_CHANNELS");
00230         defaults->update(string, firewire_channels);
00231         sprintf(string, "AFIREWIRE_OUT_CHANNEL");
00232         defaults->update(string, firewire_channel);
00233         sprintf(string, "AFIREWIRE_OUT_PORT");
00234         defaults->update(string, firewire_port);
00235         sprintf(string, "AFIREWIRE_OUT_PATH");
00236         defaults->update(string, firewire_path);
00237         sprintf(string, "AFIREWIRE_OUT_SYT");
00238         defaults->update(string, firewire_syt);
00239 
00240 
00241         sprintf(string, "ADV1394_OUT_CHANNELS");
00242         defaults->update(string, dv1394_channels);
00243         sprintf(string, "ADV1394_OUT_CHANNEL");
00244         defaults->update(string, dv1394_channel);
00245         sprintf(string, "ADV1394_OUT_PORT");
00246         defaults->update(string, dv1394_port);
00247         sprintf(string, "ADV1394_OUT_PATH");
00248         defaults->update(string, dv1394_path);
00249         sprintf(string, "ADV1394_OUT_SYT");
00250         defaults->update(string, dv1394_syt);
00251 
00252         return 0;
00253 }
00254 
00255 int AudioOutConfig::total_output_channels()
00256 {
00257         switch(driver)
00258         {
00259                 case AUDIO_OSS:
00260                 case AUDIO_OSS_ENVY24:
00261                 {
00262                         int total = 0;
00263                         for(int i = 0; i < MAXDEVICES; i++)
00264                         {
00265                                 if(oss_enable[i]) total += oss_out_channels[i];
00266                         }
00267                         return total;
00268                         break;
00269                 }
00270 
00271                 case AUDIO_ALSA:
00272                         return alsa_out_channels;
00273                         break;
00274 
00275 
00276                 case AUDIO_1394:
00277                 case AUDIO_IEC61883:
00278                         return firewire_channels;
00279                         break;
00280 
00281                 case AUDIO_DV1394:
00282                         return dv1394_channels;
00283                         break;
00284 
00285                 case AUDIO_ESOUND:
00286                         return 2;
00287                         break;
00288 
00289                 default:
00290                         return 0;
00291                         break;
00292         }
00293         return 0;
00294 }
00295 
00296 int AudioOutConfig::total_playable_channels()
00297 {
00298         int result = 0;
00299         for(int i = 0; i < MAXCHANNELS; i++)
00300                 if(do_channel[i]) result++;
00301         return result;
00302 }
00303 
00304 int AudioOutConfig::playable_channel_number(int number)
00305 {
00306         for(int i = 0; i < MAXCHANNELS; i++)
00307         {
00308                 if(do_channel[i])
00309                 {
00310                         number--;
00311                         if(number < 0) return i;
00312                 }
00313         }
00314         return 0;
00315 }
00316 
00317 
00318 
00319 
00320 
00321 
00322 
00323 
00324 
00325 VideoOutConfig::VideoOutConfig()
00326 {
00327         sprintf(lml_out_device, "/dev/mvideo/stream");
00328         sprintf(buz_out_device, "/dev/video0");
00329         driver = PLAYBACK_X11_XV;
00330         for(int i = 0; i < MAX_CHANNELS; i++) do_channel[i] = 0;
00331         buz_out_channel = 0;
00332         buz_swap_fields = 0;
00333         sprintf(x11_host, "");
00334         x11_use_fields = USE_NO_FIELDS;
00335 
00336         firewire_channel = 63;
00337         firewire_port = 0;
00338         strcpy(firewire_path, "/dev/video1394");
00339         firewire_syt = 30000;
00340 
00341         dv1394_channel = 63;
00342         dv1394_port = 0;
00343         strcpy(dv1394_path, "/dev/dv1394");
00344         dv1394_syt = 30000;
00345 
00346         brightness = 32768;
00347         hue = 32768;
00348         color = 32768;
00349         contrast = 32768;
00350         whiteness = 32768;
00351 }
00352 
00353 VideoOutConfig::~VideoOutConfig()
00354 {
00355 }
00356 
00357 
00358 int VideoOutConfig::operator!=(VideoOutConfig &that)
00359 {
00360         return !(*this == that);
00361 }
00362 
00363 int VideoOutConfig::operator==(VideoOutConfig &that)
00364 {
00365         return (driver == that.driver) &&
00366                 !strcmp(lml_out_device, that.lml_out_device) && 
00367                 !strcmp(buz_out_device, that.buz_out_device) && 
00368                 (buz_out_channel == that.buz_out_channel) && 
00369                 (buz_swap_fields == that.buz_swap_fields) &&
00370                 !strcmp(x11_host, that.x11_host) && 
00371                 (x11_use_fields == that.x11_use_fields) &&
00372                 (brightness == that.brightness) && 
00373                 (hue == that.hue) && 
00374                 (color == that.color) && 
00375                 (contrast == that.contrast) && 
00376                 (whiteness == that.whiteness) &&
00377 
00378                 (firewire_channel == that.firewire_channel) &&
00379                 (firewire_port == that.firewire_port) &&
00380                 !strcmp(firewire_path, that.firewire_path) &&
00381                 (firewire_syt == that.firewire_syt) &&
00382 
00383                 (dv1394_channel == that.dv1394_channel) &&
00384                 (dv1394_port == that.dv1394_port) &&
00385                 !strcmp(dv1394_path, that.dv1394_path) &&
00386                 (dv1394_syt == that.dv1394_syt);
00387 }
00388 
00389 
00390 
00391 
00392 
00393 
00394 VideoOutConfig& VideoOutConfig::operator=(VideoOutConfig &that)
00395 {
00396         copy_from(&that);
00397         return *this;
00398 }
00399 
00400 void VideoOutConfig::copy_from(VideoOutConfig *src)
00401 {
00402         this->driver = src->driver;
00403         strcpy(this->lml_out_device, src->lml_out_device);
00404         strcpy(this->buz_out_device, src->buz_out_device);
00405         this->buz_out_channel = src->buz_out_channel;
00406         this->buz_swap_fields = src->buz_swap_fields;
00407         strcpy(this->x11_host, src->x11_host);
00408         this->x11_use_fields = src->x11_use_fields;
00409         for(int i = 0; i < MAX_CHANNELS; i++) 
00410                 this->do_channel[i] = src->do_channel[i];
00411 
00412         firewire_channel = src->firewire_channel;
00413         firewire_port = src->firewire_port;
00414         strcpy(firewire_path, src->firewire_path);
00415         firewire_syt = src->firewire_syt;
00416 
00417         dv1394_channel = src->dv1394_channel;
00418         dv1394_port = src->dv1394_port;
00419         strcpy(dv1394_path, src->dv1394_path);
00420         dv1394_syt = src->dv1394_syt;
00421 }
00422 
00423 char* VideoOutConfig::get_path()
00424 {
00425         switch(driver)
00426         {
00427                 case PLAYBACK_BUZ:
00428                         return buz_out_device;
00429                         break;
00430                 case PLAYBACK_X11:
00431                 case PLAYBACK_X11_XV:
00432                         return x11_host;
00433                         break;
00434                 case PLAYBACK_DV1394:
00435                         return dv1394_path;
00436                         break;
00437                 case PLAYBACK_FIREWIRE:
00438                         return firewire_path;
00439                         break;
00440         };
00441         return buz_out_device;
00442 }
00443 
00444 int VideoOutConfig::load_defaults(Defaults *defaults)
00445 {
00446         char string[BCTEXTLEN];
00447         sprintf(string, "VIDEO_OUT_DRIVER");
00448         driver = defaults->get(string, driver);
00449         sprintf(string, "LML_OUT_DEVICE");
00450         defaults->get(string, lml_out_device);
00451         sprintf(string, "BUZ_OUT_DEVICE");
00452         defaults->get(string, buz_out_device);
00453         sprintf(string, "BUZ_OUT_CHANNEL");
00454         buz_out_channel = defaults->get(string, buz_out_channel);
00455         sprintf(string, "BUZ_SWAP_FIELDS");
00456         buz_swap_fields = defaults->get(string, buz_swap_fields);
00457         sprintf(string, "X11_OUT_DEVICE");
00458         defaults->get(string, x11_host);
00459         x11_use_fields = defaults->get("X11_USE_FIELDS", x11_use_fields);
00460 
00461 
00462 
00463         sprintf(string, "VFIREWIRE_OUT_CHANNEL");
00464         firewire_channel = defaults->get(string, firewire_channel);
00465         sprintf(string, "VFIREWIRE_OUT_PORT");
00466         firewire_port = defaults->get(string, firewire_port);
00467         sprintf(string, "VFIREWIRE_OUT_PATH");
00468         defaults->get(string, firewire_path);
00469         sprintf(string, "VFIREWIRE_OUT_SYT");
00470         firewire_syt = defaults->get(string, firewire_syt);
00471 
00472         sprintf(string, "VDV1394_OUT_CHANNEL");
00473         dv1394_channel = defaults->get(string, dv1394_channel);
00474         sprintf(string, "VDV1394_OUT_PORT");
00475         dv1394_port = defaults->get(string, dv1394_port);
00476         sprintf(string, "VDV1394_OUT_PATH");
00477         defaults->get(string, dv1394_path);
00478         sprintf(string, "VDV1394_OUT_SYT");
00479         dv1394_syt = defaults->get(string, dv1394_syt);
00480         return 0;
00481 }
00482 
00483 int VideoOutConfig::save_defaults(Defaults *defaults)
00484 {
00485         char string[BCTEXTLEN];
00486         sprintf(string, "VIDEO_OUT_DRIVER");
00487         defaults->update(string, driver);
00488         sprintf(string, "LML_OUT_DEVICE");
00489         defaults->update(string, lml_out_device);
00490         sprintf(string, "BUZ_OUT_DEVICE");
00491         defaults->update(string, buz_out_device);
00492         sprintf(string, "BUZ_OUT_CHANNEL");
00493         defaults->update(string, buz_out_channel);
00494         sprintf(string, "BUZ_SWAP_FIELDS");
00495         defaults->update(string, buz_swap_fields);
00496         sprintf(string, "X11_OUT_DEVICE");
00497         defaults->update(string, x11_host);
00498         defaults->update("X11_USE_FIELDS", x11_use_fields);
00499 
00500         sprintf(string, "VFIREWIRE_OUT_CHANNEL");
00501         defaults->update(string, firewire_channel);
00502         sprintf(string, "VFIREWIRE_OUT_PORT");
00503         defaults->update(string, firewire_port);
00504         sprintf(string, "VFIREWIRE_OUT_PATH");
00505         defaults->update(string, firewire_path);
00506         sprintf(string, "VFIREWIRE_OUT_SYT");
00507         defaults->update(string, firewire_syt);
00508 
00509         sprintf(string, "VDV1394_OUT_CHANNEL");
00510         defaults->update(string, dv1394_channel);
00511         sprintf(string, "VDV1394_OUT_PORT");
00512         defaults->update(string, dv1394_port);
00513         sprintf(string, "VDV1394_OUT_PATH");
00514         defaults->update(string, dv1394_path);
00515         sprintf(string, "VDV1394_OUT_SYT");
00516         defaults->update(string, dv1394_syt);
00517         return 0;
00518 }
00519 
00520 int VideoOutConfig::total_playable_channels()
00521 {
00522         int result = 0;
00523         for(int i = 0; i < MAXCHANNELS; i++)
00524                 if(do_channel[i]) result++;
00525         return result;
00526 }
00527 
00528 
00529 
00530 
00531 
00532 
00533 
00534 
00535 
00536 PlaybackConfig::PlaybackConfig()
00537 {
00538         aconfig = new AudioOutConfig(0);
00539         vconfig = new VideoOutConfig;
00540         sprintf(hostname, "localhost");
00541         port = 23456;
00542 }
00543 
00544 PlaybackConfig::~PlaybackConfig()
00545 {
00546         delete aconfig;
00547         delete vconfig;
00548 }
00549 
00550 PlaybackConfig& PlaybackConfig::operator=(PlaybackConfig &that)
00551 {
00552         copy_from(&that);
00553         return *this;
00554 }
00555 
00556 void PlaybackConfig::copy_from(PlaybackConfig *src)
00557 {
00558         aconfig->copy_from(src->aconfig);
00559         vconfig->copy_from(src->vconfig);
00560         strcpy(hostname, src->hostname);
00561         port = src->port;
00562 }
00563 
00564 int PlaybackConfig::load_defaults(Defaults *defaults)
00565 {
00566         char string[1024];
00567         sprintf(string, "PLAYBACK_HOSTNAME");
00568         defaults->get(string, hostname);
00569         sprintf(string, "PLAYBACK_PORT");
00570         port = defaults->get(string, port);
00571         aconfig->load_defaults(defaults);
00572         vconfig->load_defaults(defaults);
00573         return 0;
00574 }
00575 
00576 int PlaybackConfig::save_defaults(Defaults *defaults)
00577 {
00578         char string[1024];
00579         sprintf(string, "PLAYBACK_HOSTNAME");
00580         defaults->update(string, hostname);
00581         sprintf(string, "PLAYBACK_PORT");
00582         defaults->update(string, port);
00583         aconfig->save_defaults(defaults);
00584         vconfig->save_defaults(defaults);
00585         return 0;
00586 }
00587 
00588 

Generated on Sun Jan 8 13:38:58 2006 for Cinelerra-svn by  doxygen 1.4.4