2 #include "playbackconfig.h"
3 #include "videodevice.inc"
6 AudioOutConfig::AudioOutConfig(int duplex)
10 fragment_size = 16384;
14 for(int i = 0; i < MAXDEVICES; i++)
16 oss_enable[i] = (i == 0);
17 sprintf(oss_out_device[i], "/dev/dsp");
18 oss_out_channels[i] = 2;
21 sprintf(esound_out_server, "");
24 sprintf(alsa_out_device, "default");
25 alsa_out_channels = 2;
28 firewire_channels = 2;
29 firewire_channel = 63;
31 strcpy(firewire_path, "/dev/video1394");
37 strcpy(dv1394_path, "/dev/dv1394");
40 bzero(do_channel, sizeof(int) * MAX_CHANNELS);
43 AudioOutConfig::~AudioOutConfig()
49 int AudioOutConfig::operator!=(AudioOutConfig &that)
51 return !(*this == that);
54 int AudioOutConfig::operator==(AudioOutConfig &that)
57 (fragment_size == that.fragment_size &&
58 driver == that.driver) &&
59 !strcmp(oss_out_device[0], that.oss_out_device[0]) &&
60 (oss_out_channels[0] == that.oss_out_channels[0]) &&
61 (oss_out_bits == that.oss_out_bits) &&
62 !strcmp(esound_out_server, that.esound_out_server) &&
63 (esound_out_port == that.esound_out_port) &&
64 !strcmp(alsa_out_device, that.alsa_out_device) &&
65 (alsa_out_channels == that.alsa_out_channels) &&
66 (alsa_out_bits == that.alsa_out_bits) &&
68 firewire_channels == that.firewire_channels &&
69 firewire_channel == that.firewire_channel &&
70 firewire_port == that.firewire_port &&
71 firewire_syt == that.firewire_syt &&
72 !strcmp(firewire_path, that.firewire_path) &&
74 dv1394_channels == that.dv1394_channels &&
75 dv1394_channel == that.dv1394_channel &&
76 dv1394_port == that.dv1394_port &&
77 dv1394_syt == that.dv1394_syt &&
78 !strcmp(dv1394_path, that.dv1394_path);
83 AudioOutConfig& AudioOutConfig::operator=(AudioOutConfig &that)
89 void AudioOutConfig::copy_from(AudioOutConfig *src)
91 fragment_size = src->fragment_size;
93 strcpy(esound_out_server, src->esound_out_server);
94 esound_out_port = src->esound_out_port;
95 for(int i = 0; i < MAXDEVICES; i++)
97 oss_enable[i] = src->oss_enable[i];
98 strcpy(oss_out_device[i], src->oss_out_device[i]);
99 oss_out_channels[i] = src->oss_out_channels[i];
101 oss_out_bits = src->oss_out_bits;
103 strcpy(alsa_out_device, src->alsa_out_device);
104 alsa_out_channels = src->alsa_out_channels;
105 alsa_out_bits = src->alsa_out_bits;
107 firewire_channels = src->firewire_channels;
108 firewire_channel = src->firewire_channel;
109 firewire_port = src->firewire_port;
110 firewire_syt = src->firewire_syt;
111 strcpy(firewire_path, src->firewire_path);
113 dv1394_channels = src->dv1394_channels;
114 dv1394_channel = src->dv1394_channel;
115 dv1394_port = src->dv1394_port;
116 dv1394_syt = src->dv1394_syt;
117 strcpy(dv1394_path, src->dv1394_path);
119 for(int i = 0; i < MAXCHANNELS; i++)
120 do_channel[i] = src->do_channel[i];
123 int AudioOutConfig::load_defaults(Defaults *defaults)
125 char string[BCTEXTLEN];
127 fragment_size = defaults->get("FRAGMENT_SIZE", fragment_size);
128 sprintf(string, "AUDIO_OUT_DRIVER_%d", duplex);
129 driver = defaults->get(string, driver);
131 for(int i = 0; i < MAXDEVICES; i++)
133 sprintf(string, "OSS_ENABLE_%d_%d", i, duplex);
134 oss_enable[i] = defaults->get(string, oss_enable[i]);
135 sprintf(string, "OSS_OUT_DEVICE_%d_%d", i, duplex);
136 defaults->get(string, oss_out_device[i]);
137 sprintf(string, "OSS_OUT_CHANNELS_%d_%d", i, duplex);
138 oss_out_channels[i] = defaults->get(string, oss_out_channels[i]);
140 sprintf(string, "OSS_OUT_BITS_%d", duplex);
141 oss_out_bits = defaults->get(string, oss_out_bits);
143 defaults->get("ALSA_OUT_DEVICE", alsa_out_device);
144 alsa_out_channels = defaults->get("ALSA_OUT_CHANNELS", alsa_out_channels);
145 alsa_out_bits = defaults->get("ALSA_OUT_BITS", alsa_out_bits);
147 sprintf(string, "ESOUND_OUT_SERVER_%d", duplex);
148 defaults->get(string, esound_out_server);
149 sprintf(string, "ESOUND_OUT_PORT_%d", duplex);
150 esound_out_port = defaults->get(string, esound_out_port);
152 sprintf(string, "AFIREWIRE_OUT_CHANNELS");
153 firewire_channels = defaults->get(string, firewire_channels);
154 sprintf(string, "AFIREWIRE_OUT_CHANNEL");
155 firewire_channel = defaults->get(string, firewire_channel);
156 sprintf(string, "AFIREWIRE_OUT_PORT");
157 firewire_port = defaults->get(string, firewire_port);
158 sprintf(string, "AFIREWIRE_OUT_PATH");
159 defaults->get(string, firewire_path);
160 sprintf(string, "AFIREWIRE_OUT_SYT");
161 firewire_syt = defaults->get(string, firewire_syt);
163 sprintf(string, "ADV1394_OUT_CHANNELS");
164 dv1394_channels = defaults->get(string, dv1394_channels);
165 sprintf(string, "ADV1394_OUT_CHANNEL");
166 dv1394_channel = defaults->get(string, dv1394_channel);
167 sprintf(string, "ADV1394_OUT_PORT");
168 dv1394_port = defaults->get(string, dv1394_port);
169 sprintf(string, "ADV1394_OUT_PATH");
170 defaults->get(string, dv1394_path);
171 sprintf(string, "ADV1394_OUT_SYT");
172 dv1394_syt = defaults->get(string, dv1394_syt);
177 int AudioOutConfig::save_defaults(Defaults *defaults)
179 char string[BCTEXTLEN];
181 defaults->update("FRAGMENT_SIZE", fragment_size);
182 sprintf(string, "AUDIO_OUT_DRIVER_%d", duplex);
183 defaults->update(string, driver);
185 for(int i = 0; i < MAXDEVICES; i++)
187 sprintf(string, "OSS_ENABLE_%d_%d", i, duplex);
188 defaults->update(string, oss_enable[i]);
189 sprintf(string, "OSS_OUT_DEVICE_%d_%d", i, duplex);
190 defaults->update(string, oss_out_device[i]);
191 sprintf(string, "OSS_OUT_CHANNELS_%d_%d", i, duplex);
192 defaults->update(string, oss_out_channels[i]);
194 sprintf(string, "OSS_OUT_BITS_%d", duplex);
195 defaults->update(string, oss_out_bits);
198 defaults->update("ALSA_OUT_DEVICE", alsa_out_device);
199 defaults->update("ALSA_OUT_CHANNELS", alsa_out_channels);
200 defaults->update("ALSA_OUT_BITS", alsa_out_bits);
202 sprintf(string, "ESOUND_OUT_SERVER_%d", duplex);
203 defaults->update(string, esound_out_server);
204 sprintf(string, "ESOUND_OUT_PORT_%d", duplex);
205 defaults->update(string, esound_out_port);
207 sprintf(string, "AFIREWIRE_OUT_CHANNELS");
208 defaults->update(string, firewire_channels);
209 sprintf(string, "AFIREWIRE_OUT_CHANNEL");
210 defaults->update(string, firewire_channel);
211 sprintf(string, "AFIREWIRE_OUT_PORT");
212 defaults->update(string, firewire_port);
213 sprintf(string, "AFIREWIRE_OUT_PATH");
214 defaults->update(string, firewire_path);
215 sprintf(string, "AFIREWIRE_OUT_SYT");
216 defaults->update(string, firewire_syt);
219 sprintf(string, "ADV1394_OUT_CHANNELS");
220 defaults->update(string, dv1394_channels);
221 sprintf(string, "ADV1394_OUT_CHANNEL");
222 defaults->update(string, dv1394_channel);
223 sprintf(string, "ADV1394_OUT_PORT");
224 defaults->update(string, dv1394_port);
225 sprintf(string, "ADV1394_OUT_PATH");
226 defaults->update(string, dv1394_path);
227 sprintf(string, "ADV1394_OUT_SYT");
228 defaults->update(string, dv1394_syt);
233 int AudioOutConfig::total_output_channels()
238 case AUDIO_OSS_ENVY24:
241 for(int i = 0; i < MAXDEVICES; i++)
243 if(oss_enable[i]) total += oss_out_channels[i];
250 return alsa_out_channels;
255 return firewire_channels;
259 return dv1394_channels;
273 int AudioOutConfig::total_playable_channels()
276 for(int i = 0; i < MAXCHANNELS; i++)
277 if(do_channel[i]) result++;
281 int AudioOutConfig::playable_channel_number(int number)
283 for(int i = 0; i < MAXCHANNELS; i++)
288 if(number < 0) return i;
302 VideoOutConfig::VideoOutConfig()
304 sprintf(lml_out_device, "/dev/mvideo/stream");
305 sprintf(buz_out_device, "/dev/video0");
306 driver = PLAYBACK_X11_XV;
307 for(int i = 0; i < MAX_CHANNELS; i++) do_channel[i] = 0;
310 sprintf(x11_host, "");
311 x11_use_fields = USE_NO_FIELDS;
313 firewire_channel = 63;
315 strcpy(firewire_path, "/dev/video1394");
316 firewire_syt = 30000;
320 strcpy(dv1394_path, "/dev/dv1394");
330 VideoOutConfig::~VideoOutConfig()
335 int VideoOutConfig::operator!=(VideoOutConfig &that)
337 return !(*this == that);
340 int VideoOutConfig::operator==(VideoOutConfig &that)
342 return (driver == that.driver) &&
343 !strcmp(lml_out_device, that.lml_out_device) &&
344 !strcmp(buz_out_device, that.buz_out_device) &&
345 (buz_out_channel == that.buz_out_channel) &&
346 (buz_swap_fields == that.buz_swap_fields) &&
347 !strcmp(x11_host, that.x11_host) &&
348 (x11_use_fields == that.x11_use_fields) &&
349 (brightness == that.brightness) &&
351 (color == that.color) &&
352 (contrast == that.contrast) &&
353 (whiteness == that.whiteness) &&
355 (firewire_channel == that.firewire_channel) &&
356 (firewire_port == that.firewire_port) &&
357 !strcmp(firewire_path, that.firewire_path) &&
358 (firewire_syt == that.firewire_syt) &&
360 (dv1394_channel == that.dv1394_channel) &&
361 (dv1394_port == that.dv1394_port) &&
362 !strcmp(dv1394_path, that.dv1394_path) &&
363 (dv1394_syt == that.dv1394_syt);
371 VideoOutConfig& VideoOutConfig::operator=(VideoOutConfig &that)
377 void VideoOutConfig::copy_from(VideoOutConfig *src)
379 this->driver = src->driver;
380 strcpy(this->lml_out_device, src->lml_out_device);
381 strcpy(this->buz_out_device, src->buz_out_device);
382 this->buz_out_channel = src->buz_out_channel;
383 this->buz_swap_fields = src->buz_swap_fields;
384 strcpy(this->x11_host, src->x11_host);
385 this->x11_use_fields = src->x11_use_fields;
386 for(int i = 0; i < MAX_CHANNELS; i++)
387 this->do_channel[i] = src->do_channel[i];
389 firewire_channel = src->firewire_channel;
390 firewire_port = src->firewire_port;
391 strcpy(firewire_path, src->firewire_path);
392 firewire_syt = src->firewire_syt;
394 dv1394_channel = src->dv1394_channel;
395 dv1394_port = src->dv1394_port;
396 strcpy(dv1394_path, src->dv1394_path);
397 dv1394_syt = src->dv1394_syt;
400 char* VideoOutConfig::get_path()
405 return buz_out_device;
408 case PLAYBACK_X11_XV:
411 case PLAYBACK_DV1394:
414 case PLAYBACK_FIREWIRE:
415 return firewire_path;
418 return buz_out_device;
421 int VideoOutConfig::load_defaults(Defaults *defaults)
423 char string[BCTEXTLEN];
424 sprintf(string, "VIDEO_OUT_DRIVER");
425 driver = defaults->get(string, driver);
426 sprintf(string, "LML_OUT_DEVICE");
427 defaults->get(string, lml_out_device);
428 sprintf(string, "BUZ_OUT_DEVICE");
429 defaults->get(string, buz_out_device);
430 sprintf(string, "BUZ_OUT_CHANNEL");
431 buz_out_channel = defaults->get(string, buz_out_channel);
432 sprintf(string, "BUZ_SWAP_FIELDS");
433 buz_swap_fields = defaults->get(string, buz_swap_fields);
434 sprintf(string, "X11_OUT_DEVICE");
435 defaults->get(string, x11_host);
436 x11_use_fields = defaults->get("X11_USE_FIELDS", x11_use_fields);
440 sprintf(string, "VFIREWIRE_OUT_CHANNEL");
441 firewire_channel = defaults->get(string, firewire_channel);
442 sprintf(string, "VFIREWIRE_OUT_PORT");
443 firewire_port = defaults->get(string, firewire_port);
444 sprintf(string, "VFIREWIRE_OUT_PATH");
445 defaults->get(string, firewire_path);
446 sprintf(string, "VFIREWIRE_OUT_SYT");
447 firewire_syt = defaults->get(string, firewire_syt);
449 sprintf(string, "VDV1394_OUT_CHANNEL");
450 dv1394_channel = defaults->get(string, dv1394_channel);
451 sprintf(string, "VDV1394_OUT_PORT");
452 dv1394_port = defaults->get(string, dv1394_port);
453 sprintf(string, "VDV1394_OUT_PATH");
454 defaults->get(string, dv1394_path);
455 sprintf(string, "VDV1394_OUT_SYT");
456 dv1394_syt = defaults->get(string, dv1394_syt);
460 int VideoOutConfig::save_defaults(Defaults *defaults)
462 char string[BCTEXTLEN];
463 sprintf(string, "VIDEO_OUT_DRIVER");
464 defaults->update(string, driver);
465 sprintf(string, "LML_OUT_DEVICE");
466 defaults->update(string, lml_out_device);
467 sprintf(string, "BUZ_OUT_DEVICE");
468 defaults->update(string, buz_out_device);
469 sprintf(string, "BUZ_OUT_CHANNEL");
470 defaults->update(string, buz_out_channel);
471 sprintf(string, "BUZ_SWAP_FIELDS");
472 defaults->update(string, buz_swap_fields);
473 sprintf(string, "X11_OUT_DEVICE");
474 defaults->update(string, x11_host);
475 defaults->update("X11_USE_FIELDS", x11_use_fields);
477 sprintf(string, "VFIREWIRE_OUT_CHANNEL");
478 defaults->update(string, firewire_channel);
479 sprintf(string, "VFIREWIRE_OUT_PORT");
480 defaults->update(string, firewire_port);
481 sprintf(string, "VFIREWIRE_OUT_PATH");
482 defaults->update(string, firewire_path);
483 sprintf(string, "VFIREWIRE_OUT_SYT");
484 defaults->update(string, firewire_syt);
486 sprintf(string, "VDV1394_OUT_CHANNEL");
487 defaults->update(string, dv1394_channel);
488 sprintf(string, "VDV1394_OUT_PORT");
489 defaults->update(string, dv1394_port);
490 sprintf(string, "VDV1394_OUT_PATH");
491 defaults->update(string, dv1394_path);
492 sprintf(string, "VDV1394_OUT_SYT");
493 defaults->update(string, dv1394_syt);
497 int VideoOutConfig::total_playable_channels()
500 for(int i = 0; i < MAXCHANNELS; i++)
501 if(do_channel[i]) result++;
513 PlaybackConfig::PlaybackConfig()
515 aconfig = new AudioOutConfig(0);
516 vconfig = new VideoOutConfig;
517 sprintf(hostname, "localhost");
521 PlaybackConfig::~PlaybackConfig()
527 PlaybackConfig& PlaybackConfig::operator=(PlaybackConfig &that)
533 void PlaybackConfig::copy_from(PlaybackConfig *src)
535 aconfig->copy_from(src->aconfig);
536 vconfig->copy_from(src->vconfig);
537 strcpy(hostname, src->hostname);
541 int PlaybackConfig::load_defaults(Defaults *defaults)
544 sprintf(string, "PLAYBACK_HOSTNAME");
545 defaults->get(string, hostname);
546 sprintf(string, "PLAYBACK_PORT");
547 port = defaults->get(string, port);
548 aconfig->load_defaults(defaults);
549 vconfig->load_defaults(defaults);
553 int PlaybackConfig::save_defaults(Defaults *defaults)
556 sprintf(string, "PLAYBACK_HOSTNAME");
557 defaults->update(string, hostname);
558 sprintf(string, "PLAYBACK_PORT");
559 defaults->update(string, port);
560 aconfig->save_defaults(defaults);
561 vconfig->save_defaults(defaults);