r1014: Enable horizontal scrolling with the mouse wheel by pressing Ctrl.
[cinelerra_cv/ct.git] / cinelerra / recordconfig.C
blob4a3df2fc00d83f755057ab3b909d8ee768b8c994
1 #include "audiodevice.inc"
2 #include "bchash.h"
3 #include "playbackconfig.h"
4 #include "recordconfig.h"
5 #include "videodevice.inc"
6 #include <string.h>
12 AudioInConfig::AudioInConfig()
14         driver = AUDIO_OSS;
15         for(int i = 0; i < MAXDEVICES; i++)
16         {
17                 oss_enable[i] = (i == 0);
18                 sprintf(oss_in_device[i], "/dev/dsp");
19         }
20         oss_in_bits = 16;
21         firewire_port = 0;
22         firewire_channel = 63;
23         strcpy(firewire_path, "/dev/dv1394");
24         sprintf(esound_in_server, "");
25         esound_in_port = 0;
27         sprintf(alsa_in_device, "default");
28         alsa_in_bits = 16;
29         in_samplerate = 48000;
30         channels = 2;
33 AudioInConfig::~AudioInConfig()
37 int AudioInConfig::is_duplex(AudioInConfig *in, AudioOutConfig *out)
39         if(in->driver == out->driver)
40         {
41                 switch(in->driver)
42                 {
43                         case AUDIO_OSS:
44                         case AUDIO_OSS_ENVY24:
45                                 return (!strcmp(in->oss_in_device[0], out->oss_out_device[0]) &&
46                                         in->oss_in_bits == out->oss_out_bits);
47                                 break;
49 // ALSA always opens 2 devices
50                         case AUDIO_ALSA:
51                                 return 0;
52                                 break;
53                 }
54         }
56         return 0;
60 void AudioInConfig::copy_from(AudioInConfig *src)
62         driver = src->driver;
64         firewire_port = src->firewire_port;
65         firewire_channel = src->firewire_channel;
66         strcpy(firewire_path, src->firewire_path);
68         strcpy(esound_in_server, src->esound_in_server);
69         esound_in_port = src->esound_in_port;
71         for(int i = 0; i < MAXDEVICES; i++)
72         {
73                 oss_enable[i] = src->oss_enable[i];
74                 strcpy(oss_in_device[i], src->oss_in_device[i]);
75                 oss_in_bits = src->oss_in_bits;
76         }
78         strcpy(alsa_in_device, src->alsa_in_device);
79         alsa_in_bits = src->alsa_in_bits;
80         in_samplerate = src->in_samplerate;
81         channels = src->channels;
84 AudioInConfig& AudioInConfig::operator=(AudioInConfig &that)
86         copy_from(&that);
87         return *this;
90 int AudioInConfig::load_defaults(BC_Hash *defaults)
92         char string[BCTEXTLEN];
93         driver =                      defaults->get("AUDIOINDRIVER", driver);
94         firewire_port =           defaults->get("AFIREWIRE_IN_PORT", firewire_port);
95         firewire_channel =        defaults->get("AFIREWIRE_IN_CHANNEL", firewire_channel);
96         defaults->get("AFIREWIRE_IN_PATH", firewire_path);
97         for(int i = 0; i < MAXDEVICES; i++)
98         {
99                 sprintf(string, "OSS_ENABLE_%d", i);
100                 oss_enable[i] = defaults->get(string, oss_enable[i]);
101                 sprintf(string, "OSS_IN_DEVICE_%d", i);
102                 defaults->get(string, oss_in_device[i]);
103         }
104         sprintf(string, "OSS_IN_BITS");
105         oss_in_bits = defaults->get(string, oss_in_bits);
106         defaults->get("ESOUND_IN_SERVER", esound_in_server);
107         esound_in_port =              defaults->get("ESOUND_IN_PORT", esound_in_port);
109         defaults->get("ALSA_IN_DEVICE", alsa_in_device);
110         alsa_in_bits = defaults->get("ALSA_IN_BITS", alsa_in_bits);
111         in_samplerate = defaults->get("IN_SAMPLERATE", in_samplerate);
112         channels = defaults->get("IN_CHANNELS", channels);
113         return 0;
116 int AudioInConfig::save_defaults(BC_Hash *defaults)
118         char string[BCTEXTLEN];
119         defaults->update("AUDIOINDRIVER", driver);
120         defaults->update("AFIREWIRE_IN_PORT", firewire_port);
121         defaults->update("AFIREWIRE_IN_CHANNEL", firewire_channel);
122         defaults->update("AFIREWIRE_IN_PATH", firewire_path);
124         for(int i = 0; i < MAXDEVICES; i++)
125         {
126                 sprintf(string, "OSS_ENABLE_%d", i);
127                 defaults->update(string, oss_enable[i]);
128                 sprintf(string, "OSS_IN_DEVICE_%d", i);
129                 defaults->update(string, oss_in_device[i]);
130         }
132         sprintf(string, "OSS_IN_BITS");
133         defaults->update(string, oss_in_bits);
134         defaults->update("ESOUND_IN_SERVER", esound_in_server);
135         defaults->update("ESOUND_IN_PORT", esound_in_port);
137         defaults->update("ALSA_IN_DEVICE", alsa_in_device);
138         defaults->update("ALSA_IN_BITS", alsa_in_bits);
139         defaults->update("IN_SAMPLERATE", in_samplerate);
140         defaults->update("IN_CHANNELS", channels);
141         return 0;
150 VideoInConfig::VideoInConfig()
152         driver = VIDEO4LINUX;
153         sprintf(v4l_in_device, "/dev/video0");
154         sprintf(v4l2_in_device, "/dev/video0");
155         sprintf(v4l2jpeg_in_device, "/dev/video0");
156         sprintf(lml_in_device, "/dev/mvideo/stream");
157         sprintf(buz_in_device, "/dev/video0");
158         sprintf(screencapture_display, "");
161 // DVB
162         sprintf(dvb_in_host, "echephyle");
163         dvb_in_port = 400;
164         dvb_in_number = 0;
170         firewire_port = 0;
171         firewire_channel = 63;
172         sprintf(firewire_path, "/dev/dv1394");
173 // number of frames to read from device during video recording.
174 //      capture_length = 15;   
175         capture_length = 2;   
176         w = 720;
177         h = 480;
178         in_framerate = 29.97;
181 VideoInConfig::~VideoInConfig()
185 char* VideoInConfig::get_path()
187         switch(driver)
188         {
189                 case VIDEO4LINUX:
190                         return v4l_in_device;
191                         break;
192                 case VIDEO4LINUX2:
193                         return v4l2_in_device;
194                         break;
195                 case VIDEO4LINUX2JPEG:
196                         return v4l2jpeg_in_device;
197                         break;
198                 case CAPTURE_BUZ:
199                         return buz_in_device;
200                         break;
201                 case CAPTURE_DVB:
202                         return dvb_in_host;
203                         break;
204         }
205         return v4l_in_device;
208 void VideoInConfig::copy_from(VideoInConfig *src)
210         driver = src->driver;
211         strcpy(v4l_in_device, src->v4l_in_device);
212         strcpy(v4l2_in_device, src->v4l2_in_device);
213         strcpy(v4l2jpeg_in_device, src->v4l2jpeg_in_device);
214         strcpy(lml_in_device, src->lml_in_device);
215         strcpy(buz_in_device, src->buz_in_device);
216         strcpy(screencapture_display, src->screencapture_display);
222         strcpy(dvb_in_host, src->dvb_in_host);
223         dvb_in_port = src->dvb_in_port;
224         dvb_in_number = src->dvb_in_number;
230         firewire_port = src->firewire_port;
231         firewire_channel = src->firewire_channel;
232         strcpy(firewire_path, src->firewire_path);
233         capture_length = src->capture_length;
234         w = src->w;
235         h = src->h;
236         in_framerate = src->in_framerate;
239 VideoInConfig& VideoInConfig::operator=(VideoInConfig &that)
241         copy_from(&that);
242         return *this;
245 int VideoInConfig::load_defaults(BC_Hash *defaults)
247         driver = defaults->get("VIDEO_IN_DRIVER", driver);
248         defaults->get("V4L_IN_DEVICE", v4l_in_device);
249         defaults->get("V4L2_IN_DEVICE", v4l2_in_device);
250         defaults->get("V4L2JPEG_IN_DEVICE", v4l2jpeg_in_device);
251         defaults->get("LML_IN_DEVICE", lml_in_device);
252         defaults->get("BUZ_IN_DEVICE", buz_in_device);
253         defaults->get("SCREENCAPTURE_DISPLAY", screencapture_display);
255         defaults->get("DVB_IN_HOST", dvb_in_host);
256         dvb_in_port = defaults->get("DVB_IN_PORT", dvb_in_port);
257         dvb_in_number = defaults->get("DVB_IN_NUMBER", dvb_in_number);
259         firewire_port = defaults->get("VFIREWIRE_IN_PORT", firewire_port);
260         firewire_channel = defaults->get("VFIREWIRE_IN_CHANNEL", firewire_channel);
261         defaults->get("VFIREWIRE_IN_PATH", firewire_path);
262         capture_length = defaults->get("VIDEO_CAPTURE_LENGTH", capture_length);
263         w = defaults->get("RECORD_W", w);
264         h = defaults->get("RECORD_H", h);
265         in_framerate = defaults->get("IN_FRAMERATE", in_framerate);
266         return 0;
269 int VideoInConfig::save_defaults(BC_Hash *defaults)
271         defaults->update("VIDEO_IN_DRIVER", driver);
272         defaults->update("V4L_IN_DEVICE", v4l_in_device);
273         defaults->update("V4L2_IN_DEVICE", v4l2_in_device);
274         defaults->update("V4L2JPEG_IN_DEVICE", v4l2jpeg_in_device);
275         defaults->update("LML_IN_DEVICE", lml_in_device);
276         defaults->update("BUZ_IN_DEVICE", buz_in_device);
277         defaults->update("SCREENCAPTURE_DISPLAY", screencapture_display);
282         defaults->update("DVB_IN_HOST", dvb_in_host);
283         defaults->update("DVB_IN_PORT", dvb_in_port);
284         defaults->update("DVB_IN_NUMBER", dvb_in_number);
290         defaults->update("VFIREWIRE_IN_PORT", firewire_port);
291         defaults->update("VFIREWIRE_IN_CHANNEL", firewire_channel);
292         defaults->update("VFIREWIRE_IN_PATH", firewire_path);
293         defaults->update("VIDEO_CAPTURE_LENGTH", capture_length);
294         defaults->update("RECORD_W", w);
295         defaults->update("RECORD_H", h);
296         defaults->update("IN_FRAMERATE", in_framerate);
297         return 0;