source: roaraudio/roard/codecfilter.c @ 361:1d702adb724a

Last change on this file since 361:1d702adb724a was 361:1d702adb724a, checked in by phi, 16 years ago

only build CELT code if we habe CELT support

File size: 3.4 KB
Line 
1//codecfilter.c:
2
3#include "roard.h"
4
5struct roar_codecfilter g_codecfilter[] = {
6 {-1,                     "null", "null codec filter", NULL,                      NULL, NULL, NULL, NULL, NULL, NULL},
7
8 {ROAR_CODEC_OGG_GENERAL, "cmd",  "ogg123",
9  "ogg123 -q -d raw -f - -",
10  cf_cmd_open, NULL, NULL, NULL, NULL, NULL},
11
12 {ROAR_CODEC_OGG_VORBIS, "oggvorbis", "Ogg Vorbis decoder", NULL,
13 cf_vorbis_open, cf_vorbis_close, NULL, NULL, cf_vorbis_read, NULL},
14
15 {ROAR_CODEC_MIDI_FILE, "MIDIFILE", "timidity MIDI synth",
16  "timidity -Or1sl -s %R -o - -",
17  cf_cmd_open, NULL, NULL, NULL, NULL, NULL},
18
19#ifdef ROAR_HAVE_LIBCELT
20 {ROAR_CODEC_ROAR_CELT, "RoarCELT", "RoarAudio CELT", NULL,
21  cf_celt_open, cf_celt_close, NULL, NULL, cf_celt_read, NULL},
22#endif
23
24 {ROAR_CODEC_FLAC, "cmd",  "ogg123",
25#if BYTE_ORDER == BIG_ENDIAN
26  "flac --silent --force-raw-format --sign=signed --endian=big -d - -o -",
27#elif BYTE_ORDER == LITTLE_ENDIAN
28  "flac --silent --force-raw-format --sign=signed --endian=little -d - -o -",
29#else
30  "false",
31#endif
32  cf_cmd_open, NULL, NULL, NULL, NULL, NULL},
33
34 {-1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL} // end of list
35};
36
37void print_codecfilterlist (void) {
38 int i;
39
40 for (i = 0; g_codecfilter[i].name != NULL; i++) {
41  printf("  %-8s %-8s - %s (options: %s)\n",
42             roar_codec2str(g_codecfilter[i].codec),
43             g_codecfilter[i].name,
44             g_codecfilter[i].desc,
45             g_codecfilter[i].options);
46 }
47}
48
49int codecfilter_open (CODECFILTER_USERDATA_T * inst,
50                 int * codecfilter_id, char * codecfilter /* NOTE: this is not part of struct roar_codecfilter's def! */,
51                 int codec, struct roar_stream_server * info) {
52 int i;
53 struct roar_codecfilter   * filter = NULL;
54
55 *codecfilter_id = -1;
56
57 for (i = 0; g_codecfilter[i].name != NULL; i++) {
58  if ( g_codecfilter[i].codec == codec ) {
59   if ( !codecfilter || strcmp(codecfilter, g_codecfilter[i].name) == 0 ) {
60    *codecfilter_id = i;
61    filter = &g_codecfilter[i];
62    break;
63   }
64  }
65 }
66
67 info->codecfilter = *codecfilter_id;
68
69 if (*codecfilter_id != -1) {
70  if ( filter->open )
71   return filter->open(inst, codec, info, filter);
72  return 0;
73 }
74
75 return -1;
76}
77
78int codecfilter_close(CODECFILTER_USERDATA_T   inst, int codecfilter) {
79 ROAR_DBG("codecfilter_close(inst=%p, codecfilter=%i) = ?", inst, codecfilter);
80
81 if ( codecfilter == -1 )
82  return -1;
83
84 if ( g_codecfilter[codecfilter].close )
85  return g_codecfilter[codecfilter].close(inst);
86
87 return 0;
88}
89
90int codecfilter_pause(CODECFILTER_USERDATA_T   inst, int codecfilter, int newstate) {
91 if ( codecfilter == -1 )
92  return -1;
93
94 if ( g_codecfilter[codecfilter].pause )
95  return g_codecfilter[codecfilter].pause(inst, newstate);
96
97 return 0;
98}
99
100int codecfilter_write(CODECFILTER_USERDATA_T   inst, int codecfilter, char * buf, int len) {
101 if ( codecfilter == -1 )
102  return -1;
103
104 if ( g_codecfilter[codecfilter].write )
105  return g_codecfilter[codecfilter].write(inst, buf, len);
106
107 return 0;
108}
109
110int codecfilter_read (CODECFILTER_USERDATA_T   inst, int codecfilter, char * buf, int len) {
111 if ( codecfilter == -1 )
112  return -1;
113
114 if ( g_codecfilter[codecfilter].read )
115  return g_codecfilter[codecfilter].read(inst, buf, len);
116
117 return 0;
118}
119
120int codecfilter_flush(CODECFILTER_USERDATA_T   inst, int codecfilter) {
121 if ( codecfilter == -1 )
122  return -1;
123
124 if ( g_codecfilter[codecfilter].flush )
125  return g_codecfilter[codecfilter].flush(inst);
126
127 return 0;
128}
129
130//ll
Note: See TracBrowser for help on using the repository browser.