r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / recordconfig.C
blobdea99f375703eeefee12b99d0b8ebee205d54018
1 #include "audiodevice.inc"
2 #include "defaults.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                 oss_in_channels[i] = 2;
20         }
21         oss_in_bits = 16;
22         firewire_port = 0;
23         firewire_channel = 63;
24         strcpy(firewire_path, "/dev/raw1394");
25         sprintf(esound_in_server, "");
26         esound_in_port = 0;
28         sprintf(alsa_in_device, "");
29         alsa_in_channels = 2;
30         alsa_in_bits = 16;
31         in_samplerate = 48000;
34 AudioInConfig::~AudioInConfig()
38 int AudioInConfig::is_duplex(AudioInConfig *in, AudioOutConfig *out)
40         if(in->driver == out->driver)
41         {
42                 switch(in->driver)
43                 {
44                         case AUDIO_OSS:
45                         case AUDIO_OSS_ENVY24:
46                                 return (!strcmp(in->oss_in_device[0], out->oss_out_device[0]) &&
47                                         in->oss_in_bits == out->oss_out_bits &&
48                                         in->oss_in_channels[0] == out->oss_out_channels[0]);
49                                 break;
51 // ALSA always opens 2 devices
52                         case AUDIO_ALSA:
53                                 return 0;
54                                 break;
55                 }
56         }
58         return 0;
62 AudioInConfig& AudioInConfig::operator=(AudioInConfig &that)
64         driver = that.driver;
66         firewire_port = that.firewire_port;
67         firewire_channel = that.firewire_channel;
68         strcpy(firewire_path, that.firewire_path);
70         strcpy(esound_in_server, that.esound_in_server);
71         esound_in_port = that.esound_in_port;
73         for(int i = 0; i < MAXDEVICES; i++)
74         {
75                 oss_enable[i] = that.oss_enable[i];
76                 strcpy(oss_in_device[i], that.oss_in_device[i]);
77                 oss_in_channels[i] = that.oss_in_channels[i];
78                 oss_in_bits = that.oss_in_bits;
79         }
81         strcpy(alsa_in_device, that.alsa_in_device);
82         alsa_in_bits = that.alsa_in_bits;
83         alsa_in_channels = that.alsa_in_channels;
84         in_samplerate = that.in_samplerate;
85         return *this;
88 int AudioInConfig::load_defaults(Defaults *defaults)
90         char string[BCTEXTLEN];
91         driver =                      defaults->get("AUDIOINDRIVER", driver);
92         firewire_port =           defaults->get("AFIREWIRE_IN_PORT", firewire_port);
93         firewire_channel =        defaults->get("AFIREWIRE_IN_CHANNEL", firewire_channel);
94         defaults->get("AFIREWIRE_IN_PATH", firewire_path);
95         for(int i = 0; i < MAXDEVICES; i++)
96         {
97                 sprintf(string, "OSS_ENABLE_%d", i);
98                 oss_enable[i] = defaults->get(string, oss_enable[i]);
99                 sprintf(string, "OSS_IN_DEVICE_%d", i);
100                 defaults->get(string, oss_in_device[i]);
101                 sprintf(string, "OSS_IN_CHANNELS_%d", i);
102                 oss_in_channels[i] = defaults->get(string, oss_in_channels[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         alsa_in_channels = defaults->get("ALSA_IN_CHANNELS", alsa_in_channels);
112         in_samplerate = defaults->get("IN_SAMPLERATE", in_samplerate);
113         return 0;
116 int AudioInConfig::save_defaults(Defaults *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                 sprintf(string, "OSS_IN_CHANNELS_%d", i);
131                 defaults->update(string, oss_in_channels[i]);
132         }
134         sprintf(string, "OSS_IN_BITS");
135         defaults->update(string, oss_in_bits);
136         defaults->update("ESOUND_IN_SERVER", esound_in_server);
137         defaults->update("ESOUND_IN_PORT", esound_in_port);
139         defaults->update("ALSA_IN_DEVICE", alsa_in_device);
140         defaults->update("ALSA_IN_BITS", alsa_in_bits);
141         defaults->update("ALSA_IN_CHANNELS", alsa_in_channels);
142         defaults->update("IN_SAMPLERATE", in_samplerate);
143         return 0;
152 VideoInConfig::VideoInConfig()
154         driver = VIDEO4LINUX;
155         sprintf(v4l_in_device, "/dev/video0");
156         sprintf(lml_in_device, "/dev/mvideo/stream");
157         sprintf(buz_in_device, "/dev/video0");
158         sprintf(screencapture_display, "");
159         firewire_port = 0;
160         firewire_channel = 63;
161         sprintf(firewire_path, "/dev/raw1394");
162 // number of frames to read from device during video recording.
163 //      capture_length = 15;   
164         capture_length = 2;   
165         w = 720;
166         h = 480;
167         in_framerate = 29.97;
170 VideoInConfig::~VideoInConfig()
174 char* VideoInConfig::get_path()
176         switch(driver)
177         {
178                 case VIDEO4LINUX:
179                         return v4l_in_device;
180                         break;
181                 case CAPTURE_BUZ:
182                         return buz_in_device;
183                         break;
184         }
185         return v4l_in_device;
188 VideoInConfig& VideoInConfig::operator=(VideoInConfig &that)
190         driver = that.driver;
191         strcpy(v4l_in_device, that.v4l_in_device);
192         strcpy(lml_in_device, that.lml_in_device);
193         strcpy(buz_in_device, that.buz_in_device);
194         strcpy(screencapture_display, that.screencapture_display);
195         firewire_port = that.firewire_port;
196         firewire_channel = that.firewire_channel;
197         strcpy(firewire_path, that.firewire_path);
198         capture_length = that.capture_length;
199         w = that.w;
200         h = that.h;
201         in_framerate = that.in_framerate;
202         return *this;
205 int VideoInConfig::load_defaults(Defaults *defaults)
207         driver = defaults->get("VIDEO_IN_DRIVER", driver);
208         defaults->get("V4L_IN_DEVICE", v4l_in_device);
209         defaults->get("LML_IN_DEVICE", lml_in_device);
210         defaults->get("BUZ_IN_DEVICE", buz_in_device);
211         defaults->get("SCREENCAPTURE_DISPLAY", screencapture_display);
212         firewire_port = defaults->get("VFIREWIRE_IN_PORT", firewire_port);
213         firewire_channel = defaults->get("VFIREWIRE_IN_CHANNEL", firewire_channel);
214         defaults->get("VFIREWIRE_IN_PATH", firewire_path);
215         capture_length = defaults->get("VIDEO_CAPTURE_LENGTH", capture_length);
216         w = defaults->get("RECORD_W", w);
217         h = defaults->get("RECORD_H", h);
218         in_framerate = defaults->get("IN_FRAMERATE", in_framerate);
219         return 0;
222 int VideoInConfig::save_defaults(Defaults *defaults)
224         defaults->update("VIDEO_IN_DRIVER", driver);
225         defaults->update("V4L_IN_DEVICE", v4l_in_device);
226         defaults->update("LML_IN_DEVICE", lml_in_device);
227         defaults->update("BUZ_IN_DEVICE", buz_in_device);
228         defaults->update("SCREENCAPTURE_DISPLAY", screencapture_display);
229         defaults->update("VFIREWIRE_IN_PORT", firewire_port);
230         defaults->update("VFIREWIRE_IN_CHANNEL", firewire_channel);
231         defaults->update("VFIREWIRE_IN_PATH", firewire_path);
232         defaults->update("VIDEO_CAPTURE_LENGTH", capture_length);
233         defaults->update("RECORD_W", w);
234         defaults->update("RECORD_H", h);
235         defaults->update("IN_FRAMERATE", in_framerate);
236         return 0;