option to explicitly exclude codecs
Adrian Smith
10 years ago
120 | 120 | |
121 | 121 | static thread_type thread; |
122 | 122 | |
123 | void decode_init(log_level level, const char *opt) { | |
123 | void decode_init(log_level level, const char *include_codecs, const char *exclude_codecs) { | |
124 | 124 | int i; |
125 | 125 | |
126 | 126 | loglevel = level; |
127 | 127 | |
128 | LOG_INFO("init decode"); | |
128 | LOG_INFO("init decode, include codecs: %s exclude codecs: %s", include_codecs ? include_codecs : "", exclude_codecs); | |
129 | 129 | |
130 | 130 | // register codecs |
131 | 131 | // dsf,dff,alc,wma,wmap,wmal,aac,spt,ogg,ogf,flc,aif,pcm,mp3 |
132 | 132 | i = 0; |
133 | 133 | #if DSD |
134 | if (!opt || strstr(opt, "dsd")) codecs[i++] = register_dsd(); | |
134 | if (!strstr(exclude_codecs, "dsd") && (!include_codecs || strstr(include_codecs, "dsd"))) codecs[i++] = register_dsd(); | |
135 | 135 | #endif |
136 | 136 | #if FFMPEG |
137 | if (!opt || strstr(opt, "alac")) codecs[i++] = register_ff("alc"); | |
138 | if (!opt || strstr(opt, "wma")) codecs[i++] = register_ff("wma"); | |
139 | #endif | |
140 | if (!opt || strstr(opt, "aac")) codecs[i++] = register_faad(); | |
141 | if (!opt || strstr(opt, "ogg")) codecs[i++] = register_vorbis(); | |
142 | if (!opt || strstr(opt, "flac")) codecs[i++] = register_flac(); | |
143 | if (!opt || strstr(opt, "pcm")) codecs[i++] = register_pcm(); | |
137 | if (!strstr(exclude_codecs, "alac") && (!include_codecs || strstr(include_codecs, "alac"))) codecs[i++] = register_ff("alc"); | |
138 | if (!strstr(exclude_codecs, "wma") && (!include_codecs || strstr(include_codecs, "wma"))) codecs[i++] = register_ff("wma"); | |
139 | #endif | |
140 | if (!strstr(exclude_codecs, "aac") && (!include_codecs || strstr(include_codecs, "aac"))) codecs[i++] = register_faad(); | |
141 | if (!strstr(exclude_codecs, "ogg") && (!include_codecs || strstr(include_codecs, "ogg"))) codecs[i++] = register_vorbis(); | |
142 | if (!strstr(exclude_codecs, "flac") && (!include_codecs || strstr(include_codecs, "flac"))) codecs[i++] = register_flac(); | |
143 | if (!strstr(exclude_codecs, "pcm") && (!include_codecs || strstr(include_codecs, "pcm"))) codecs[i++] = register_pcm(); | |
144 | 144 | |
145 | 145 | // try mad then mpg for mp3 unless command line option passed |
146 | if ( !opt || strstr(opt, "mp3") || strstr(opt, "mad")) codecs[i] = register_mad(); | |
147 | if ((!opt || strstr(opt, "mp3") || strstr(opt, "mpg")) && !codecs[i]) codecs[i] = register_mpg(); | |
146 | if (!(strstr(exclude_codecs, "mp3") || strstr(exclude_codecs, "mad")) && | |
147 | (!include_codecs || strstr(include_codecs, "mp3") || strstr(include_codecs, "mad"))) codecs[i] = register_mad(); | |
148 | if (!(strstr(exclude_codecs, "mp3") || strstr(exclude_codecs, "mpg")) && !codecs[i] && | |
149 | (!include_codecs || strstr(include_codecs, "mp3") || strstr(include_codecs, "mpg"))) codecs[i] = register_mpg(); | |
148 | 150 | |
149 | 151 | mutex_create(decode.mutex); |
150 | 152 |
23 | 23 | |
24 | 24 | #define TITLE "Squeezelite " VERSION ", Copyright 2012-2014 Adrian Smith." |
25 | 25 | |
26 | #define CODECS_BASE "flac,pcm,mp3,ogg,aac" | |
27 | #if FFMPEG | |
28 | #define CODECS_FF ",wma,alac" | |
29 | #else | |
30 | #define CODECS_FF "" | |
31 | #endif | |
32 | #if DSD | |
33 | #define CODECS_DSD ",dsd" | |
34 | #else | |
35 | #define CODECS_DSD "" | |
36 | #endif | |
37 | #define CODECS_MP3 " (mad,mpg for specific mp3 codec)" | |
38 | ||
39 | #define CODECS CODECS_BASE CODECS_FF CODECS_DSD CODECS_MP3 | |
40 | ||
26 | 41 | static void usage(const char *argv0) { |
27 | 42 | printf(TITLE " See -t for license terms\n" |
28 | 43 | "Usage: %s [options]\n" |
41 | 56 | #endif |
42 | 57 | " -a <f>\t\tSpecify sample format (16|24|32) of output file when using -o - to output samples to stdout (interleaved little endian only)\n" |
43 | 58 | " -b <stream>:<output>\tSpecify internal Stream and Output buffer sizes in Kbytes\n" |
44 | " -c <codec1>,<codec2>\tRestrict codecs to those specified, otherwise load all available codecs; known codecs: " | |
45 | "flac,pcm,mp3,ogg,aac" | |
46 | #if FFMPEG | |
47 | ",wma,alac" | |
48 | #endif | |
49 | #if DSD | |
50 | ",dsd" | |
51 | #endif | |
52 | " (mad,mpg for specific mp3 codec)\n" | |
59 | " -c <codec1>,<codec2>\tRestrict codecs to those specified, otherwise load all available codecs; known codecs: " CODECS "\n" | |
53 | 60 | " -d <log>=<level>\tSet logging level, logs: all|slimproto|stream|decode|output, level: info|debug|sdebug\n" |
61 | " -e <codec1>,<codec2>\tExplicitly exclude native support of one or more codecs; known codecs: " CODECS "\n" | |
54 | 62 | " -f <logfile>\t\tWrite debug to logfile\n" |
55 | 63 | " -m <mac addr>\t\tSet mac address, format: ab:cd:ef:12:34:56\n" |
56 | 64 | " -n <name>\t\tSet the player name\n" |
156 | 164 | int main(int argc, char **argv) { |
157 | 165 | char *server = NULL; |
158 | 166 | char *output_device = "default"; |
159 | char *codecs = NULL; | |
167 | char *include_codecs = NULL; | |
168 | char *exclude_codecs = ""; | |
160 | 169 | char *name = NULL; |
161 | 170 | char *namefile = NULL; |
162 | 171 | char *logfile = NULL; |
202 | 211 | |
203 | 212 | while (optind < argc && strlen(argv[optind]) >= 2 && argv[optind][0] == '-') { |
204 | 213 | char *opt = argv[optind] + 1; |
205 | if (strstr("oabcdfmnNprs", opt) && optind < argc - 1) { | |
214 | if (strstr("oabcdefmnNprs", opt) && optind < argc - 1) { | |
206 | 215 | optarg = argv[optind + 1]; |
207 | 216 | optind += 2; |
208 | 217 | } else if (strstr("ltz" |
239 | 248 | } |
240 | 249 | break; |
241 | 250 | case 'c': |
242 | codecs = optarg; | |
251 | include_codecs = optarg; | |
252 | break; | |
253 | case 'e': | |
254 | exclude_codecs = optarg; | |
243 | 255 | break; |
244 | 256 | case 'd': |
245 | 257 | { |
451 | 463 | } |
452 | 464 | #endif |
453 | 465 | |
454 | decode_init(log_decode, codecs); | |
466 | decode_init(log_decode, include_codecs, exclude_codecs); | |
455 | 467 | |
456 | 468 | #if RESAMPLE |
457 | 469 | if (resample) { |
465 | 465 | decode_state (*decode)(void); |
466 | 466 | }; |
467 | 467 | |
468 | void decode_init(log_level level, const char *opt); | |
468 | void decode_init(log_level level, const char *include_codecs, const char *exclude_codecs); | |
469 | 469 | void decode_close(void); |
470 | 470 | void decode_flush(void); |
471 | 471 | unsigned decode_newstream(unsigned sample_rate, unsigned supported_rates[]); |