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