2 #include "playbackconfig.h"
3 #include "videodevice.inc"
6 AudioOutConfig::AudioOutConfig(int playback_strategy, int engine_number, int duplex)
9 this->playback_strategy = playback_strategy;
10 this->engine_number = engine_number;
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, "");
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 (driver == that.driver) &&
58 !strcmp(oss_out_device[0], that.oss_out_device[0]) &&
59 (oss_out_channels[0] == that.oss_out_channels[0]) &&
60 (oss_out_bits == that.oss_out_bits) &&
61 !strcmp(esound_out_server, that.esound_out_server) &&
62 (esound_out_port == that.esound_out_port) &&
63 !strcmp(alsa_out_device, that.alsa_out_device) &&
64 (alsa_out_channels == that.alsa_out_channels) &&
65 (alsa_out_bits == that.alsa_out_bits) &&
67 firewire_channels == that.firewire_channels &&
68 firewire_channel == that.firewire_channel &&
69 firewire_port == that.firewire_port &&
70 firewire_syt == that.firewire_syt &&
71 !strcmp(firewire_path, that.firewire_path) &&
73 dv1394_channels == that.dv1394_channels &&
74 dv1394_channel == that.dv1394_channel &&
75 dv1394_port == that.dv1394_port &&
76 dv1394_syt == that.dv1394_syt &&
77 !strcmp(dv1394_path, that.dv1394_path);
82 AudioOutConfig& AudioOutConfig::operator=(AudioOutConfig &that)
85 strcpy(esound_out_server, that.esound_out_server);
86 esound_out_port = that.esound_out_port;
87 for(int i = 0; i < MAXDEVICES; i++)
89 oss_enable[i] = that.oss_enable[i];
90 strcpy(oss_out_device[i], that.oss_out_device[i]);
91 oss_out_channels[i] = that.oss_out_channels[i];
93 oss_out_bits = that.oss_out_bits;
95 strcpy(alsa_out_device, that.alsa_out_device);
96 alsa_out_channels = that.alsa_out_channels;
97 alsa_out_bits = that.alsa_out_bits;
99 firewire_channels = that.firewire_channels;
100 firewire_channel = that.firewire_channel;
101 firewire_port = that.firewire_port;
102 firewire_syt = that.firewire_syt;
103 strcpy(firewire_path, that.firewire_path);
105 dv1394_channels = that.dv1394_channels;
106 dv1394_channel = that.dv1394_channel;
107 dv1394_port = that.dv1394_port;
108 dv1394_syt = that.dv1394_syt;
109 strcpy(dv1394_path, that.dv1394_path);
111 for(int i = 0; i < MAXCHANNELS; i++)
112 do_channel[i] = that.do_channel[i];
113 // printf("AudioOutConfig::operator= ");
114 // for(int i = 0; i < MAXCHANNELS; i++)
115 // printf("%d", do_channel[i]);
120 int AudioOutConfig::load_defaults(Defaults *defaults)
122 char string[BCTEXTLEN];
124 sprintf(string, "AUDIO_OUT_DRIVER_%d_%d_%d", playback_strategy, engine_number, duplex);
125 driver = defaults->get(string, driver);
126 // sprintf(string, "OSS_OUT_DEVICE_%d_%d_%d", playback_strategy, engine_number, duplex);
127 // defaults->get(string, oss_out_device);
128 // sprintf(string, "OSS_OUT_CHANNELS_%d_%d_%d", playback_strategy, engine_number, duplex);
129 // oss_out_channels = defaults->get(string, oss_out_channels);
130 // sprintf(string, "OSS_OUT_BITS_%d_%d_%d", playback_strategy, engine_number, duplex);
131 // oss_out_bits = defaults->get(string, oss_out_bits);
133 for(int i = 0; i < MAXDEVICES; i++)
135 sprintf(string, "OSS_ENABLE_%d_%d", i, duplex);
136 oss_enable[i] = defaults->get(string, oss_enable[i]);
137 sprintf(string, "OSS_OUT_DEVICE_%d_%d", i, duplex);
138 defaults->get(string, oss_out_device[i]);
139 sprintf(string, "OSS_OUT_CHANNELS_%d_%d", i, duplex);
140 oss_out_channels[i] = defaults->get(string, oss_out_channels[i]);
142 sprintf(string, "OSS_OUT_BITS_%d", duplex);
143 oss_out_bits = defaults->get(string, oss_out_bits);
145 defaults->get("ALSA_OUT_DEVICE", alsa_out_device);
146 alsa_out_channels = defaults->get("ALSA_OUT_CHANNELS", alsa_out_channels);
147 alsa_out_bits = defaults->get("ALSA_OUT_BITS", alsa_out_bits);
149 sprintf(string, "ESOUND_OUT_SERVER_%d_%d_%d", playback_strategy, engine_number, duplex);
150 defaults->get(string, esound_out_server);
151 sprintf(string, "ESOUND_OUT_PORT_%d_%d_%d", playback_strategy, engine_number, duplex);
152 esound_out_port = defaults->get(string, esound_out_port);
154 sprintf(string, "AFIREWIRE_OUT_CHANNELS_%d_%d", playback_strategy, engine_number);
155 firewire_channels = defaults->get(string, firewire_channels);
156 sprintf(string, "AFIREWIRE_OUT_CHANNEL_%d_%d", playback_strategy, engine_number);
157 firewire_channel = defaults->get(string, firewire_channel);
158 sprintf(string, "AFIREWIRE_OUT_PORT_%d_%d", playback_strategy, engine_number);
159 firewire_port = defaults->get(string, firewire_port);
160 sprintf(string, "AFIREWIRE_OUT_PATH_%d_%d", playback_strategy, engine_number);
161 defaults->get(string, firewire_path);
162 sprintf(string, "AFIREWIRE_OUT_SYT_%d_%d", playback_strategy, engine_number);
163 firewire_syt = defaults->get(string, firewire_syt);
165 sprintf(string, "ADV1394_OUT_CHANNELS_%d_%d", playback_strategy, engine_number);
166 dv1394_channels = defaults->get(string, dv1394_channels);
167 sprintf(string, "ADV1394_OUT_CHANNEL_%d_%d", playback_strategy, engine_number);
168 dv1394_channel = defaults->get(string, dv1394_channel);
169 sprintf(string, "ADV1394_OUT_PORT_%d_%d", playback_strategy, engine_number);
170 dv1394_port = defaults->get(string, dv1394_port);
171 sprintf(string, "ADV1394_OUT_PATH_%d_%d", playback_strategy, engine_number);
172 defaults->get(string, dv1394_path);
173 sprintf(string, "ADV1394_OUT_SYT_%d_%d", playback_strategy, engine_number);
174 dv1394_syt = defaults->get(string, dv1394_syt);
179 int AudioOutConfig::save_defaults(Defaults *defaults)
181 char string[BCTEXTLEN];
183 sprintf(string, "AUDIO_OUT_DRIVER_%d_%d_%d", playback_strategy, engine_number, duplex);
184 defaults->update(string, driver);
185 // sprintf(string, "OSS_OUT_DEVICE_%d_%d_%d", playback_strategy, engine_number, duplex);
186 // defaults->update(string, oss_out_device);
187 // sprintf(string, "OSS_OUT_CHANNELS_%d_%d_%d", playback_strategy, engine_number, duplex);
188 // defaults->update(string, oss_out_channels);
189 // sprintf(string, "OSS_OUT_BITS_%d_%d_%d", playback_strategy, engine_number, duplex);
190 // defaults->update(string, oss_out_bits);
192 for(int i = 0; i < MAXDEVICES; i++)
194 sprintf(string, "OSS_ENABLE_%d_%d", i, duplex);
195 defaults->update(string, oss_enable[i]);
196 sprintf(string, "OSS_OUT_DEVICE_%d_%d", i, duplex);
197 defaults->update(string, oss_out_device[i]);
198 sprintf(string, "OSS_OUT_CHANNELS_%d_%d", i, duplex);
199 defaults->update(string, oss_out_channels[i]);
201 sprintf(string, "OSS_OUT_BITS_%d", duplex);
202 defaults->update(string, oss_out_bits);
205 defaults->update("ALSA_OUT_DEVICE", alsa_out_device);
206 defaults->update("ALSA_OUT_CHANNELS", alsa_out_channels);
207 defaults->update("ALSA_OUT_BITS", alsa_out_bits);
209 sprintf(string, "ESOUND_OUT_SERVER_%d_%d_%d", playback_strategy, engine_number, duplex);
210 defaults->update(string, esound_out_server);
211 sprintf(string, "ESOUND_OUT_PORT_%d_%d_%d", playback_strategy, engine_number, duplex);
212 defaults->update(string, esound_out_port);
214 sprintf(string, "AFIREWIRE_OUT_CHANNELS_%d_%d", playback_strategy, engine_number);
215 defaults->update(string, firewire_channels);
216 sprintf(string, "AFIREWIRE_OUT_CHANNEL_%d_%d", playback_strategy, engine_number);
217 defaults->update(string, firewire_channel);
218 sprintf(string, "AFIREWIRE_OUT_PORT_%d_%d", playback_strategy, engine_number);
219 defaults->update(string, firewire_port);
220 sprintf(string, "AFIREWIRE_OUT_PATH_%d_%d", playback_strategy, engine_number);
221 defaults->update(string, firewire_path);
222 sprintf(string, "AFIREWIRE_OUT_SYT_%d_%d", playback_strategy, engine_number);
223 defaults->update(string, firewire_syt);
226 sprintf(string, "ADV1394_OUT_CHANNELS_%d_%d", playback_strategy, engine_number);
227 defaults->update(string, dv1394_channels);
228 sprintf(string, "ADV1394_OUT_CHANNEL_%d_%d", playback_strategy, engine_number);
229 defaults->update(string, dv1394_channel);
230 sprintf(string, "ADV1394_OUT_PORT_%d_%d", playback_strategy, engine_number);
231 defaults->update(string, dv1394_port);
232 sprintf(string, "ADV1394_OUT_PATH_%d_%d", playback_strategy, engine_number);
233 defaults->update(string, dv1394_path);
234 sprintf(string, "ADV1394_OUT_SYT_%d_%d", playback_strategy, engine_number);
235 defaults->update(string, dv1394_syt);
240 int AudioOutConfig::total_output_channels()
245 case AUDIO_OSS_ENVY24:
248 for(int i = 0; i < MAXDEVICES; i++)
250 if(oss_enable[i]) total += oss_out_channels[i];
257 return alsa_out_channels;
262 return firewire_channels;
266 return dv1394_channels;
280 int AudioOutConfig::total_playable_channels()
283 for(int i = 0; i < MAXCHANNELS; i++)
284 if(do_channel[i]) result++;
288 int AudioOutConfig::playable_channel_number(int number)
290 for(int i = 0; i < MAXCHANNELS; i++)
295 if(number < 0) return i;
309 VideoOutConfig::VideoOutConfig(int playback_strategy, int engine_number)
311 sprintf(lml_out_device, "/dev/mvideo/stream");
312 sprintf(buz_out_device, "/dev/video0");
313 this->playback_strategy = playback_strategy;
314 this->engine_number = engine_number;
315 driver = PLAYBACK_X11_XV;
316 for(int i = 0; i < MAX_CHANNELS; i++) do_channel[i] = 0;
319 sprintf(x11_host, "");
320 x11_use_fields = USE_NO_FIELDS;
322 firewire_channel = 63;
324 strcpy(firewire_path, "/dev/video1394");
325 firewire_syt = 30000;
329 strcpy(dv1394_path, "/dev/dv1394");
333 VideoOutConfig::~VideoOutConfig()
338 int VideoOutConfig::operator!=(VideoOutConfig &that)
340 return !(*this == that);
343 int VideoOutConfig::operator==(VideoOutConfig &that)
345 return (driver == that.driver) &&
346 !strcmp(lml_out_device, that.lml_out_device) &&
347 !strcmp(buz_out_device, that.buz_out_device) &&
348 (buz_out_channel == that.buz_out_channel) &&
349 (buz_swap_fields == that.buz_swap_fields) &&
350 !strcmp(x11_host, that.x11_host) &&
351 (x11_use_fields == that.x11_use_fields) &&
352 (brightness == that.brightness) &&
354 (color == that.color) &&
355 (contrast == that.contrast) &&
356 (whiteness == that.whiteness) &&
358 (firewire_channel == that.firewire_channel) &&
359 (firewire_port == that.firewire_port) &&
360 !strcmp(firewire_path, that.firewire_path) &&
361 (firewire_syt == that.firewire_syt) &&
363 (dv1394_channel == that.dv1394_channel) &&
364 (dv1394_port == that.dv1394_port) &&
365 !strcmp(dv1394_path, that.dv1394_path) &&
366 (dv1394_syt == that.dv1394_syt);
374 VideoOutConfig& VideoOutConfig::operator=(VideoOutConfig &that)
376 this->driver = that.driver;
377 strcpy(this->lml_out_device, that.lml_out_device);
378 strcpy(this->buz_out_device, that.buz_out_device);
379 this->buz_out_channel = that.buz_out_channel;
380 this->buz_swap_fields = that.buz_swap_fields;
381 strcpy(this->x11_host, that.x11_host);
382 this->x11_use_fields = that.x11_use_fields;
383 for(int i = 0; i < MAX_CHANNELS; i++)
384 this->do_channel[i] = that.do_channel[i];
386 firewire_channel = that.firewire_channel;
387 firewire_port = that.firewire_port;
388 strcpy(firewire_path, that.firewire_path);
389 firewire_syt = that.firewire_syt;
391 dv1394_channel = that.dv1394_channel;
392 dv1394_port = that.dv1394_port;
393 strcpy(dv1394_path, that.dv1394_path);
394 dv1394_syt = that.dv1394_syt;
399 char* VideoOutConfig::get_path()
404 return buz_out_device;
407 case PLAYBACK_X11_XV:
410 case PLAYBACK_DV1394:
413 case PLAYBACK_FIREWIRE:
414 return firewire_path;
417 return buz_out_device;
420 int VideoOutConfig::load_defaults(Defaults *defaults)
422 char string[BCTEXTLEN];
423 sprintf(string, "VIDEO_OUT_DRIVER_%d_%d", playback_strategy, engine_number);
424 driver = defaults->get(string, driver);
425 sprintf(string, "LML_OUT_DEVICE_%d_%d", playback_strategy, engine_number);
426 defaults->get(string, lml_out_device);
427 sprintf(string, "BUZ_OUT_DEVICE_%d_%d", playback_strategy, engine_number);
428 defaults->get(string, buz_out_device);
429 sprintf(string, "BUZ_OUT_CHANNEL_%d_%d", playback_strategy, engine_number);
430 buz_out_channel = defaults->get(string, buz_out_channel);
431 sprintf(string, "BUZ_SWAP_FIELDS_%d_%d", playback_strategy, engine_number);
432 buz_swap_fields = defaults->get(string, buz_swap_fields);
433 sprintf(string, "X11_OUT_DEVICE_%d_%d", playback_strategy, engine_number);
434 defaults->get(string, x11_host);
435 x11_use_fields = defaults->get("X11_USE_FIELDS", x11_use_fields);
439 sprintf(string, "VFIREWIRE_OUT_CHANNEL_%d_%d", playback_strategy, engine_number);
440 firewire_channel = defaults->get(string, firewire_channel);
441 sprintf(string, "VFIREWIRE_OUT_PORT_%d_%d", playback_strategy, engine_number);
442 firewire_port = defaults->get(string, firewire_port);
443 sprintf(string, "VFIREWIRE_OUT_PATH_%d_%d", playback_strategy, engine_number);
444 defaults->get(string, firewire_path);
445 sprintf(string, "VFIREWIRE_OUT_SYT_%d_%d", playback_strategy, engine_number);
446 firewire_syt = defaults->get(string, firewire_syt);
448 sprintf(string, "VDV1394_OUT_CHANNEL_%d_%d", playback_strategy, engine_number);
449 dv1394_channel = defaults->get(string, dv1394_channel);
450 sprintf(string, "VDV1394_OUT_PORT_%d_%d", playback_strategy, engine_number);
451 dv1394_port = defaults->get(string, dv1394_port);
452 sprintf(string, "VDV1394_OUT_PATH_%d_%d", playback_strategy, engine_number);
453 defaults->get(string, dv1394_path);
454 sprintf(string, "VDV1394_OUT_SYT_%d_%d", playback_strategy, engine_number);
455 dv1394_syt = defaults->get(string, dv1394_syt);
459 int VideoOutConfig::save_defaults(Defaults *defaults)
461 char string[BCTEXTLEN];
462 sprintf(string, "VIDEO_OUT_DRIVER_%d_%d", playback_strategy, engine_number);
463 defaults->update(string, driver);
464 sprintf(string, "LML_OUT_DEVICE_%d_%d", playback_strategy, engine_number);
465 defaults->update(string, lml_out_device);
466 sprintf(string, "BUZ_OUT_DEVICE_%d_%d", playback_strategy, engine_number);
467 defaults->update(string, buz_out_device);
468 sprintf(string, "BUZ_OUT_CHANNEL_%d_%d", playback_strategy, engine_number);
469 defaults->update(string, buz_out_channel);
470 sprintf(string, "BUZ_SWAP_FIELDS_%d_%d", playback_strategy, engine_number);
471 defaults->update(string, buz_swap_fields);
472 sprintf(string, "X11_OUT_DEVICE_%d_%d", playback_strategy, engine_number);
473 defaults->update(string, x11_host);
474 defaults->update("X11_USE_FIELDS", x11_use_fields);
476 sprintf(string, "VFIREWIRE_OUT_CHANNEL_%d_%d", playback_strategy, engine_number);
477 defaults->update(string, firewire_channel);
478 sprintf(string, "VFIREWIRE_OUT_PORT_%d_%d", playback_strategy, engine_number);
479 defaults->update(string, firewire_port);
480 sprintf(string, "VFIREWIRE_OUT_PATH_%d_%d", playback_strategy, engine_number);
481 defaults->update(string, firewire_path);
482 sprintf(string, "VFIREWIRE_OUT_SYT_%d_%d", playback_strategy, engine_number);
483 defaults->update(string, firewire_syt);
485 sprintf(string, "VDV1394_OUT_CHANNEL_%d_%d", playback_strategy, engine_number);
486 defaults->update(string, dv1394_channel);
487 sprintf(string, "VDV1394_OUT_PORT_%d_%d", playback_strategy, engine_number);
488 defaults->update(string, dv1394_port);
489 sprintf(string, "VDV1394_OUT_PATH_%d_%d", playback_strategy, engine_number);
490 defaults->update(string, dv1394_path);
491 sprintf(string, "VDV1394_OUT_SYT_%d_%d", playback_strategy, engine_number);
492 defaults->update(string, dv1394_syt);
496 int VideoOutConfig::total_playable_channels()
499 for(int i = 0; i < MAXCHANNELS; i++)
500 if(do_channel[i]) result++;
512 PlaybackConfig::PlaybackConfig(int playback_strategy, int engine_number)
514 aconfig = new AudioOutConfig(playback_strategy, engine_number, 0);
515 vconfig = new VideoOutConfig(playback_strategy, engine_number);
516 this->playback_strategy = playback_strategy;
517 this->engine_number = engine_number;
518 sprintf(hostname, "localhost");
522 PlaybackConfig::~PlaybackConfig()
528 PlaybackConfig& PlaybackConfig::operator=(PlaybackConfig &that)
530 *aconfig = *that.aconfig;
531 *vconfig = *that.vconfig;
532 strcpy(hostname, that.hostname);
537 int PlaybackConfig::load_defaults(Defaults *defaults)
540 sprintf(string, "PLAYBACK_HOSTNAME_%d_%d", playback_strategy, engine_number);
541 defaults->get(string, hostname);
542 sprintf(string, "PLAYBACK_PORT_%d_%d", playback_strategy, engine_number);
543 port = defaults->get(string, port);
544 aconfig->load_defaults(defaults);
545 vconfig->load_defaults(defaults);
549 int PlaybackConfig::save_defaults(Defaults *defaults)
552 sprintf(string, "PLAYBACK_HOSTNAME_%d_%d", playback_strategy, engine_number);
553 defaults->update(string, hostname);
554 sprintf(string, "PLAYBACK_PORT_%d_%d", playback_strategy, engine_number);
555 defaults->update(string, port);
556 aconfig->save_defaults(defaults);
557 vconfig->save_defaults(defaults);