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

recordconfig.C

Go to the documentation of this file.
00001 #include "audiodevice.inc"
00002 #include "defaults.h"
00003 #include "playbackconfig.h"
00004 #include "recordconfig.h"
00005 #include "videodevice.inc"
00006 #include <string.h>
00007 
00008 
00009 
00010 
00011 
00012 AudioInConfig::AudioInConfig()
00013 {
00014         driver = AUDIO_OSS;
00015         for(int i = 0; i < MAXDEVICES; i++)
00016         {
00017                 oss_enable[i] = (i == 0);
00018                 sprintf(oss_in_device[i], "/dev/dsp");
00019                 oss_in_channels[i] = 2;
00020         }
00021         oss_in_bits = 16;
00022         firewire_port = 0;
00023         firewire_channel = 63;
00024         strcpy(firewire_path, "/dev/raw1394");
00025         sprintf(esound_in_server, "");
00026         esound_in_port = 0;
00027 
00028         sprintf(alsa_in_device, "default");
00029         alsa_in_channels = 2;
00030         alsa_in_bits = 16;
00031         in_samplerate = 48000;
00032 }
00033 
00034 AudioInConfig::~AudioInConfig()
00035 {
00036 }
00037 
00038 int AudioInConfig::is_duplex(AudioInConfig *in, AudioOutConfig *out)
00039 {
00040         if(in->driver == out->driver)
00041         {
00042                 switch(in->driver)
00043                 {
00044                         case AUDIO_OSS:
00045                         case AUDIO_OSS_ENVY24:
00046                                 return (!strcmp(in->oss_in_device[0], out->oss_out_device[0]) &&
00047                                         in->oss_in_bits == out->oss_out_bits &&
00048                                         in->oss_in_channels[0] == out->oss_out_channels[0]);
00049                                 break;
00050 
00051 // ALSA always opens 2 devices
00052                         case AUDIO_ALSA:
00053                                 return 0;
00054                                 break;
00055                 }
00056         }
00057 
00058         return 0;
00059 }
00060 
00061 
00062 void AudioInConfig::copy_from(AudioInConfig *src)
00063 {
00064         driver = src->driver;
00065 
00066         firewire_port = src->firewire_port;
00067         firewire_channel = src->firewire_channel;
00068         strcpy(firewire_path, src->firewire_path);
00069 
00070         strcpy(esound_in_server, src->esound_in_server);
00071         esound_in_port = src->esound_in_port;
00072 
00073         for(int i = 0; i < MAXDEVICES; i++)
00074         {
00075                 oss_enable[i] = src->oss_enable[i];
00076                 strcpy(oss_in_device[i], src->oss_in_device[i]);
00077                 oss_in_channels[i] = src->oss_in_channels[i];
00078                 oss_in_bits = src->oss_in_bits;
00079         }
00080 
00081         strcpy(alsa_in_device, src->alsa_in_device);
00082         alsa_in_bits = src->alsa_in_bits;
00083         alsa_in_channels = src->alsa_in_channels;
00084         in_samplerate = src->in_samplerate;
00085 }
00086 
00087 AudioInConfig& AudioInConfig::operator=(AudioInConfig &that)
00088 {
00089         copy_from(&that);
00090         return *this;
00091 }
00092 
00093 int AudioInConfig::load_defaults(Defaults *defaults)
00094 {
00095         char string[BCTEXTLEN];
00096         driver =                      defaults->get("AUDIOINDRIVER", driver);
00097         firewire_port =           defaults->get("AFIREWIRE_IN_PORT", firewire_port);
00098         firewire_channel =        defaults->get("AFIREWIRE_IN_CHANNEL", firewire_channel);
00099         defaults->get("AFIREWIRE_IN_PATH", firewire_path);
00100         for(int i = 0; i < MAXDEVICES; i++)
00101         {
00102                 sprintf(string, "OSS_ENABLE_%d", i);
00103                 oss_enable[i] = defaults->get(string, oss_enable[i]);
00104                 sprintf(string, "OSS_IN_DEVICE_%d", i);
00105                 defaults->get(string, oss_in_device[i]);
00106                 sprintf(string, "OSS_IN_CHANNELS_%d", i);
00107                 oss_in_channels[i] = defaults->get(string, oss_in_channels[i]);
00108         }
00109         sprintf(string, "OSS_IN_BITS");
00110         oss_in_bits = defaults->get(string, oss_in_bits);
00111         defaults->get("ESOUND_IN_SERVER", esound_in_server);
00112         esound_in_port =              defaults->get("ESOUND_IN_PORT", esound_in_port);
00113 
00114         defaults->get("ALSA_IN_DEVICE", alsa_in_device);
00115         alsa_in_bits = defaults->get("ALSA_IN_BITS", alsa_in_bits);
00116         alsa_in_channels = defaults->get("ALSA_IN_CHANNELS", alsa_in_channels);
00117         in_samplerate = defaults->get("IN_SAMPLERATE", in_samplerate);
00118         return 0;
00119 }
00120 
00121 int AudioInConfig::save_defaults(Defaults *defaults)
00122 {
00123         char string[BCTEXTLEN];
00124         defaults->update("AUDIOINDRIVER", driver);
00125         defaults->update("AFIREWIRE_IN_PORT", firewire_port);
00126         defaults->update("AFIREWIRE_IN_CHANNEL", firewire_channel);
00127         defaults->update("AFIREWIRE_IN_PATH", firewire_path);
00128 
00129         for(int i = 0; i < MAXDEVICES; i++)
00130         {
00131                 sprintf(string, "OSS_ENABLE_%d", i);
00132                 defaults->update(string, oss_enable[i]);
00133                 sprintf(string, "OSS_IN_DEVICE_%d", i);
00134                 defaults->update(string, oss_in_device[i]);
00135                 sprintf(string, "OSS_IN_CHANNELS_%d", i);
00136                 defaults->update(string, oss_in_channels[i]);
00137         }
00138 
00139         sprintf(string, "OSS_IN_BITS");
00140         defaults->update(string, oss_in_bits);
00141         defaults->update("ESOUND_IN_SERVER", esound_in_server);
00142         defaults->update("ESOUND_IN_PORT", esound_in_port);
00143 
00144         defaults->update("ALSA_IN_DEVICE", alsa_in_device);
00145         defaults->update("ALSA_IN_BITS", alsa_in_bits);
00146         defaults->update("ALSA_IN_CHANNELS", alsa_in_channels);
00147         defaults->update("IN_SAMPLERATE", in_samplerate);
00148         return 0;
00149 }
00150 
00151 
00152 
00153 
00154 
00155 
00156 
00157 VideoInConfig::VideoInConfig()
00158 {
00159         driver = VIDEO4LINUX;
00160         sprintf(v4l_in_device, "/dev/video0");
00161         sprintf(v4l2_in_device, "/dev/video0");
00162         sprintf(v4l2jpeg_in_device, "/dev/video0");
00163         sprintf(lml_in_device, "/dev/mvideo/stream");
00164         sprintf(buz_in_device, "/dev/video0");
00165         sprintf(screencapture_display, "");
00166         firewire_port = 0;
00167         firewire_channel = 63;
00168         sprintf(firewire_path, "/dev/raw1394");
00169 // number of frames to read from device during video recording.
00170 //      capture_length = 15;   
00171         capture_length = 2;   
00172         w = 720;
00173         h = 480;
00174         in_framerate = 29.97;
00175 }
00176 
00177 VideoInConfig::~VideoInConfig()
00178 {
00179 }
00180 
00181 char* VideoInConfig::get_path()
00182 {
00183         switch(driver)
00184         {
00185                 case VIDEO4LINUX:
00186                         return v4l_in_device;
00187                         break;
00188                 case VIDEO4LINUX2:
00189                         return v4l2_in_device;
00190                         break;
00191                 case VIDEO4LINUX2JPEG:
00192                         return v4l2jpeg_in_device;
00193                         break;
00194                 case CAPTURE_BUZ:
00195                         return buz_in_device;
00196                         break;
00197         }
00198         return v4l_in_device;
00199 }
00200 
00201 void VideoInConfig::copy_from(VideoInConfig *src)
00202 {
00203         driver = src->driver;
00204         strcpy(v4l_in_device, src->v4l_in_device);
00205         strcpy(v4l2_in_device, src->v4l2_in_device);
00206         strcpy(v4l2jpeg_in_device, src->v4l2jpeg_in_device);
00207         strcpy(lml_in_device, src->lml_in_device);
00208         strcpy(buz_in_device, src->buz_in_device);
00209         strcpy(screencapture_display, src->screencapture_display);
00210         firewire_port = src->firewire_port;
00211         firewire_channel = src->firewire_channel;
00212         strcpy(firewire_path, src->firewire_path);
00213         capture_length = src->capture_length;
00214         w = src->w;
00215         h = src->h;
00216         in_framerate = src->in_framerate;
00217 }
00218 
00219 VideoInConfig& VideoInConfig::operator=(VideoInConfig &that)
00220 {
00221         copy_from(&that);
00222         return *this;
00223 }
00224 
00225 int VideoInConfig::load_defaults(Defaults *defaults)
00226 {
00227         driver = defaults->get("VIDEO_IN_DRIVER", driver);
00228         defaults->get("V4L_IN_DEVICE", v4l_in_device);
00229         defaults->get("V4L2_IN_DEVICE", v4l2_in_device);
00230         defaults->get("V4L2JPEG_IN_DEVICE", v4l2jpeg_in_device);
00231         defaults->get("LML_IN_DEVICE", lml_in_device);
00232         defaults->get("BUZ_IN_DEVICE", buz_in_device);
00233         defaults->get("SCREENCAPTURE_DISPLAY", screencapture_display);
00234         firewire_port = defaults->get("VFIREWIRE_IN_PORT", firewire_port);
00235         firewire_channel = defaults->get("VFIREWIRE_IN_CHANNEL", firewire_channel);
00236         defaults->get("VFIREWIRE_IN_PATH", firewire_path);
00237         capture_length = defaults->get("VIDEO_CAPTURE_LENGTH", capture_length);
00238         w = defaults->get("RECORD_W", w);
00239         h = defaults->get("RECORD_H", h);
00240         in_framerate = defaults->get("IN_FRAMERATE", in_framerate);
00241         return 0;
00242 }
00243 
00244 int VideoInConfig::save_defaults(Defaults *defaults)
00245 {
00246         defaults->update("VIDEO_IN_DRIVER", driver);
00247         defaults->update("V4L_IN_DEVICE", v4l_in_device);
00248         defaults->update("V4L2_IN_DEVICE", v4l2_in_device);
00249         defaults->update("V4L2JPEG_IN_DEVICE", v4l2jpeg_in_device);
00250         defaults->update("LML_IN_DEVICE", lml_in_device);
00251         defaults->update("BUZ_IN_DEVICE", buz_in_device);
00252         defaults->update("SCREENCAPTURE_DISPLAY", screencapture_display);
00253         defaults->update("VFIREWIRE_IN_PORT", firewire_port);
00254         defaults->update("VFIREWIRE_IN_CHANNEL", firewire_channel);
00255         defaults->update("VFIREWIRE_IN_PATH", firewire_path);
00256         defaults->update("VIDEO_CAPTURE_LENGTH", capture_length);
00257         defaults->update("RECORD_W", w);
00258         defaults->update("RECORD_H", h);
00259         defaults->update("IN_FRAMERATE", in_framerate);
00260         return 0;
00261 }
00262 

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