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