[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 | |
---|
[205] | 12 | {ROAR_CODEC_OGG_VORBIS, "oggvorbis", "Ogg Vorbis decoder", NULL, |
---|
| 13 | cf_vorbis_open, cf_vorbis_close, NULL, NULL, cf_vorbis_read, NULL}, |
---|
| 14 | |
---|
[221] | 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 | |
---|
[361] | 19 | #ifdef ROAR_HAVE_LIBCELT |
---|
[330] | 20 | {ROAR_CODEC_ROAR_CELT, "RoarCELT", "RoarAudio CELT", NULL, |
---|
| 21 | cf_celt_open, cf_celt_close, NULL, NULL, cf_celt_read, NULL}, |
---|
[361] | 22 | #endif |
---|
[330] | 23 | |
---|
[201] | 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}, |
---|
[179] | 33 | |
---|
| 34 | {-1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL} // end of list |
---|
[173] | 35 | }; |
---|
| 36 | |
---|
[175] | 37 | void print_codecfilterlist (void) { |
---|
| 38 | int i; |
---|
| 39 | |
---|
| 40 | for (i = 0; g_codecfilter[i].name != NULL; i++) { |
---|
[178] | 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); |
---|
[175] | 46 | } |
---|
| 47 | } |
---|
| 48 | |
---|
[194] | 49 | int 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 | |
---|
[196] | 67 | info->codecfilter = *codecfilter_id; |
---|
[194] | 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 | |
---|
[180] | 78 | int 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 | |
---|
| 90 | int 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 | |
---|
| 100 | int 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 | |
---|
| 110 | int 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 | |
---|
| 120 | int 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 | |
---|
[169] | 130 | //ll |
---|