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