4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "audiodevice.inc"
24 #include "playbackconfig.h"
25 #include "recordconfig.h"
26 #include "videodevice.inc"
33 AudioInConfig::AudioInConfig()
40 for(int i = 0; i < MAXDEVICES; i++)
42 oss_enable[i] = (i == 0);
43 sprintf(oss_in_device[i], "/dev/dsp");
47 firewire_channel = 63;
48 strcpy(firewire_path, "/dev/raw1394");
49 esound_in_server[0] = 0;
52 sprintf(alsa_in_device, "default");
54 in_samplerate = 48000;
55 strcpy(dvb_in_adapter,"/dev/dvb/adapter0");
65 AudioInConfig::~AudioInConfig()
69 int AudioInConfig::is_duplex(AudioInConfig *in, AudioOutConfig *out)
71 if(in->driver == out->driver)
76 case AUDIO_OSS_ENVY24:
77 return (!strcmp(in->oss_in_device[0], out->oss_out_device[0]) &&
78 in->oss_in_bits == out->oss_out_bits);
81 // ALSA always opens 2 devices
92 void AudioInConfig::copy_from(AudioInConfig *src)
96 firewire_port = src->firewire_port;
97 firewire_channel = src->firewire_channel;
98 strcpy(firewire_path, src->firewire_path);
100 strcpy(esound_in_server, src->esound_in_server);
101 esound_in_port = src->esound_in_port;
103 for(int i = 0; i < MAXDEVICES; i++)
105 oss_enable[i] = src->oss_enable[i];
106 strcpy(oss_in_device[i], src->oss_in_device[i]);
107 oss_in_bits = src->oss_in_bits;
110 strcpy(alsa_in_device, src->alsa_in_device);
111 alsa_in_bits = src->alsa_in_bits;
112 in_samplerate = src->in_samplerate;
113 strcpy(dvb_in_adapter, src->dvb_in_adapter);
114 dvb_in_device = src->dvb_in_device;
115 dvb_in_bits = src->dvb_in_bits;
116 v4l2_in_bits = src->v4l2_in_bits;
117 channels = src->channels;
118 follow_audio = src->follow_audio;
119 map51_2 = src->map51_2;
120 rec_gain = src->rec_gain;
123 AudioInConfig& AudioInConfig::operator=(AudioInConfig &that)
129 int AudioInConfig::load_defaults(BC_Hash *defaults)
131 driver = defaults->get("R_AUDIOINDRIVER", driver);
132 firewire_port = defaults->get("R_AFIREWIRE_IN_PORT", firewire_port);
133 firewire_channel = defaults->get("R_AFIREWIRE_IN_CHANNEL", firewire_channel);
134 defaults->get("R_AFIREWIRE_IN_PATH", firewire_path);
135 for(int i = 0; i < MAXDEVICES; i++)
137 oss_enable[i] = defaults->getf(oss_enable[i], "R_OSS_ENABLE_%d", i);
138 defaults->getf(oss_in_device[i], "R_OSS_IN_DEVICE_%d", i);
140 oss_in_bits = defaults->get("R_OSS_IN_BITS", oss_in_bits);
141 defaults->get("R_ESOUND_IN_SERVER", esound_in_server);
142 esound_in_port = defaults->get("R_ESOUND_IN_PORT", esound_in_port);
144 defaults->get("R_ALSA_IN_DEVICE", alsa_in_device);
145 alsa_in_bits = defaults->get("R_ALSA_IN_BITS", alsa_in_bits);
146 in_samplerate = defaults->get("R_IN_SAMPLERATE", in_samplerate);
147 defaults->get("R_AUDIO_DVB_IN_ADAPTER", dvb_in_adapter);
148 dvb_in_device = defaults->get("R_AUDIO_DVB_IN_DEVICE", dvb_in_device);
149 dvb_in_bits = defaults->get("R_DVB_IN_BITS", dvb_in_bits);
150 v4l2_in_bits = defaults->get("R_V4L2_IN_BITS", v4l2_in_bits);
151 channels = defaults->get("R_IN_CHANNELS", channels);
152 follow_audio = defaults->get("R_FOLLOW_AUDIO", follow_audio);
153 map51_2 = defaults->get("R_AUDIO_IN_MAP51_2", map51_2);
154 rec_gain = defaults->get("R_AUDIO_IN_GAIN", rec_gain);
158 int AudioInConfig::save_defaults(BC_Hash *defaults)
160 defaults->update("R_AUDIOINDRIVER", driver);
161 defaults->update("R_AFIREWIRE_IN_PORT", firewire_port);
162 defaults->update("R_AFIREWIRE_IN_CHANNEL", firewire_channel);
163 defaults->update("R_AFIREWIRE_IN_PATH", firewire_path);
165 for(int i = 0; i < MAXDEVICES; i++)
167 defaults->updatef(oss_enable[i], "R_OSS_ENABLE_%d", i);
168 defaults->updatef(oss_in_device[i], "R_OSS_IN_DEVICE_%d", i);
171 defaults->update("R_OSS_IN_BITS", oss_in_bits);
172 defaults->update("R_ESOUND_IN_SERVER", esound_in_server);
173 defaults->update("R_ESOUND_IN_PORT", esound_in_port);
175 defaults->update("R_ALSA_IN_DEVICE", alsa_in_device);
176 defaults->update("R_ALSA_IN_BITS", alsa_in_bits);
177 defaults->update("R_IN_SAMPLERATE", in_samplerate);
178 defaults->update("R_AUDIO_DVB_IN_ADAPTER", dvb_in_adapter);
179 defaults->update("R_AUDIO_DVB_IN_DEVICE", dvb_in_device);
180 defaults->update("R_DVB_IN_BITS", dvb_in_bits);
181 defaults->update("R_V4L2_IN_BITS", v4l2_in_bits);
182 defaults->update("R_IN_CHANNELS", channels);
183 defaults->update("R_FOLLOW_AUDIO", follow_audio);
184 defaults->update("R_AUDIO_IN_MAP51_2", map51_2);
185 defaults->update("R_AUDIO_IN_GAIN", rec_gain);
194 const char *VideoInConfig::default_video_device = "/dev/video0";
196 VideoInConfig::VideoInConfig()
198 driver = VIDEO4LINUX2;
199 sprintf(v4l2_in_device, "%s", "/dev/video0");
200 sprintf(v4l2jpeg_in_device, "%s", "/dev/video0");
201 v4l2jpeg_in_fields = 2;
202 sprintf(v4l2mpeg_in_device, "%s", "/dev/video0");
203 strcpy(dvb_in_adapter, "/dev/dvb/adapter0");
205 sprintf(screencapture_display, "%s", "");
207 firewire_channel = 63;
208 sprintf(firewire_path, "/dev/raw1394");
209 // number of frames to read from device during video recording.
210 // capture_length = 15;
214 in_framerate = 29.97;
218 VideoInConfig::~VideoInConfig()
222 const char *VideoInConfig::get_path()
225 case CAPTURE_JPEG_WEBCAM:
226 case CAPTURE_YUYV_WEBCAM:
227 case VIDEO4LINUX2: return v4l2_in_device;
228 case VIDEO4LINUX2JPEG: return v4l2jpeg_in_device;
229 case VIDEO4LINUX2MPEG: return v4l2mpeg_in_device;
230 case CAPTURE_DVB: return dvb_in_adapter;
232 return default_video_device;
235 void VideoInConfig::copy_from(VideoInConfig *src)
237 driver = src->driver;
238 strcpy(v4l2_in_device, src->v4l2_in_device);
239 v4l2jpeg_in_fields = src->v4l2jpeg_in_fields;
240 strcpy(v4l2jpeg_in_device, src->v4l2jpeg_in_device);
241 strcpy(v4l2mpeg_in_device, src->v4l2mpeg_in_device);
242 strcpy(dvb_in_adapter, src->dvb_in_adapter);
243 dvb_in_device = src->dvb_in_device;
244 strcpy(screencapture_display, src->screencapture_display);
245 firewire_port = src->firewire_port;
246 firewire_channel = src->firewire_channel;
247 strcpy(firewire_path, src->firewire_path);
248 capture_length = src->capture_length;
251 in_framerate = src->in_framerate;
252 follow_video = src->follow_video;
255 VideoInConfig& VideoInConfig::operator=(VideoInConfig &that)
261 int VideoInConfig::load_defaults(BC_Hash *defaults)
263 driver = defaults->get("R_VIDEO_IN_DRIVER", driver);
264 defaults->get("R_V4L2_IN_DEVICE", v4l2_in_device);
265 defaults->get("R_V4L2JPEG_IN_DEVICE", v4l2jpeg_in_device);
266 v4l2jpeg_in_fields = defaults->get("R_V4L2JPEG_IN_FIELDS", v4l2jpeg_in_fields);
267 defaults->get("R_V4L2MPEG_IN_DEVICE", v4l2mpeg_in_device);
268 defaults->get("R_VIDEO_DVB_IN_ADAPTER", dvb_in_adapter);
269 dvb_in_device = defaults->get("R_VIDEO_DVB_IN_DEVICE", dvb_in_device);
270 defaults->get("R_SCREENCAPTURE_DISPLAY", screencapture_display);
271 firewire_port = defaults->get("R_VFIREWIRE_IN_PORT", firewire_port);
272 firewire_channel = defaults->get("R_VFIREWIRE_IN_CHANNEL", firewire_channel);
273 defaults->get("R_VFIREWIRE_IN_PATH", firewire_path);
274 capture_length = defaults->get("R_VIDEO_CAPTURE_LENGTH", capture_length);
275 w = defaults->get("RECORD_W", w);
276 h = defaults->get("RECORD_H", h);
277 in_framerate = defaults->get("R_IN_FRAMERATE", in_framerate);
278 follow_video = defaults->get("R_FOLLOW_VIDEO", follow_video);
282 int VideoInConfig::save_defaults(BC_Hash *defaults)
284 defaults->update("R_VIDEO_IN_DRIVER", driver);
285 defaults->update("R_V4L2_IN_DEVICE", v4l2_in_device);
286 defaults->update("R_V4L2JPEG_IN_DEVICE", v4l2jpeg_in_device);
287 defaults->update("R_V4L2JPEG_IN_FIELDS", v4l2jpeg_in_fields);
288 defaults->update("R_V4L2MPEG_IN_DEVICE", v4l2mpeg_in_device);
289 defaults->update("R_VIDEO_DVB_IN_ADAPTER", dvb_in_adapter);
290 defaults->update("R_VIDEO_DVB_IN_DEVICE", dvb_in_device);
291 defaults->update("R_SCREENCAPTURE_DISPLAY", screencapture_display);
292 defaults->update("R_VFIREWIRE_IN_PORT", firewire_port);
293 defaults->update("R_VFIREWIRE_IN_CHANNEL", firewire_channel);
294 defaults->update("R_VFIREWIRE_IN_PATH", firewire_path);
295 defaults->update("R_VIDEO_CAPTURE_LENGTH", capture_length);
296 defaults->update("RECORD_W", w);
297 defaults->update("RECORD_H", h);
298 defaults->update("R_IN_FRAMERATE", in_framerate);
299 defaults->update("R_FOLLOW_VIDEO", follow_video);