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