diff --git a/src/db-sql-sqlite2.c b/src/db-sql-sqlite2.c index 01cb1836..0702e5bf 100644 --- a/src/db-sql-sqlite2.c +++ b/src/db-sql-sqlite2.c @@ -409,47 +409,47 @@ int db_sqlite2_insert_id(void) { char *db_sqlite2_initial1 = "create table songs (\n" -" id INTEGER PRIMARY KEY NOT NULL,\n" +" id INTEGER PRIMARY KEY NOT NULL,\n" /* 0 */ " path VARCHAR(4096) UNIQUE NOT NULL,\n" " fname VARCHAR(255) NOT NULL,\n" " title VARCHAR(1024) DEFAULT NULL,\n" " artist VARCHAR(1024) DEFAULT NULL,\n" -" album VARCHAR(1024) DEFAULT NULL,\n" +" album VARCHAR(1024) DEFAULT NULL,\n" /* 5 */ " genre VARCHAR(255) DEFAULT NULL,\n" " comment VARCHAR(4096) DEFAULT NULL,\n" " type VARCHAR(255) DEFAULT NULL,\n" " composer VARCHAR(1024) DEFAULT NULL,\n" -" orchestra VARCHAR(1024) DEFAULT NULL,\n" +" orchestra VARCHAR(1024) DEFAULT NULL,\n" /* 10 */ " conductor VARCHAR(1024) DEFAULT NULL,\n" " grouping VARCHAR(1024) DEFAULT NULL,\n" " url VARCHAR(1024) DEFAULT NULL,\n" " bitrate INTEGER DEFAULT 0,\n" -" samplerate INTEGER DEFAULT 0,\n" +" samplerate INTEGER DEFAULT 0,\n" /* 15 */ " song_length INTEGER DEFAULT 0,\n" " file_size INTEGER DEFAULT 0,\n" " year INTEGER DEFAULT 0,\n" " track INTEGER DEFAULT 0,\n" -" total_tracks INTEGER DEFAULT 0,\n" +" total_tracks INTEGER DEFAULT 0,\n" /* 20 */ " disc INTEGER DEFAULT 0,\n" " total_discs INTEGER DEFAULT 0,\n" " bpm INTEGER DEFAULT 0,\n" " compilation INTEGER DEFAULT 0,\n" -" rating INTEGER DEFAULT 0,\n" +" rating INTEGER DEFAULT 0,\n" /* 25 */ " play_count INTEGER DEFAULT 0,\n" " data_kind INTEGER DEFAULT 0,\n" " item_kind INTEGER DEFAULT 0,\n" " description INTEGER DEFAULT 0,\n" -" time_added INTEGER DEFAULT 0,\n" +" time_added INTEGER DEFAULT 0,\n" /* 30 */ " time_modified INTEGER DEFAULT 0,\n" " time_played INTEGER DEFAULT 0,\n" " db_timestamp INTEGER DEFAULT 0,\n" " disabled INTEGER DEFAULT 0,\n" -" sample_count INTEGER DEFAULT 0,\n" +" sample_count INTEGER DEFAULT 0,\n" /* 35 */ " force_update INTEGER DEFAULT 0,\n" " codectype VARCHAR(5) DEFAULT NULL,\n" " idx INTEGER NOT NULL,\n" " has_video INTEGER DEFAULT 0,\n" -" contentrating INTEGER DEFAULT 0\n" +" contentrating INTEGER DEFAULT 0\n" /* 40 */ ");\n" "create table playlistitems (\n" " id INTEGER PRIMARY KEY NOT NULL,\n" diff --git a/src/mp3-scanner.c b/src/mp3-scanner.c index 658b1898..7d6d68b4 100644 --- a/src/mp3-scanner.c +++ b/src/mp3-scanner.c @@ -137,7 +137,7 @@ static TAGHANDLER taghandlers[] = { { "wma", scan_get_wmainfo, "wma", "wma", "WMA audio file" }, { "url", scan_get_urlinfo, "pls", NULL, "Playlist URL" }, { "pls", scan_get_urlinfo, "pls", NULL, "Playlist URL" }, - { "m4v", scan_get_mp4info, "m4v", "mp4v", "MPEG-4 video file" }, + { "m4v", scan_get_mp4info, "m4v", "mp4v", "MPEG-4 video file" }, #ifdef OGGVORBIS { "ogg", scan_get_ogginfo, "ogg", "ogg", "Ogg Vorbis audio file" }, #endif diff --git a/src/plugin.c b/src/plugin.c index b31b210f..c6b8af31 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -91,7 +91,7 @@ int pi_db_enum_start(char **pe, DBQUERYINFO *pinfo); int pi_db_enum_fetch_row(char **pe, char ***row, DBQUERYINFO *pinfo); int pi_db_enum_end(char **pe); void pi_stream(WS_CONNINFO *pwsc, DBQUERYINFO *pqi, char *id); - +void pi_conf_dispose_string(char *str); int pi_sp_parse(PARSETREE tree, char *term); PLUGIN_INPUT_FN pi = { @@ -119,9 +119,13 @@ PLUGIN_INPUT_FN pi = { sp_init, pi_sp_parse, sp_dispose, - sp_get_error + sp_get_error, + + conf_alloc_string, + pi_conf_dispose_string }; + /** * initialize stuff for plugins * @@ -582,3 +586,7 @@ void pi_stream(WS_CONNINFO *pwsc, DBQUERYINFO *pqi, char *id) { int pi_sp_parse(PARSETREE tree, char *term) { return sp_parse(tree, term, 0); } + +void pi_conf_dispose_string(char *str) { + free(str); +} diff --git a/src/plugin.h b/src/plugin.h index f277b3de..8a3c4b23 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -115,6 +115,9 @@ typedef struct tag_plugin_input_fn { int (*sp_parse)(PARSETREE tree, char *term); int (*sp_dispose)(PARSETREE tree); char* (*sp_get_error)(PARSETREE tree); + + char *(*conf_alloc_string)(char *section, char *key, char *dflt); + void (*conf_dispose_string)(char *str); } PLUGIN_INPUT_FN; #endif /* _PLUGIN_H_ */ diff --git a/src/plugins/mtd-plugins.h b/src/plugins/mtd-plugins.h index bc352e3e..8d344763 100644 --- a/src/plugins/mtd-plugins.h +++ b/src/plugins/mtd-plugins.h @@ -191,6 +191,9 @@ typedef struct tag_plugin_input_fn { int (*sp_parse)(PARSETREE tree, char *term); int (*sp_dispose)(PARSETREE tree); char* (*sp_get_error)(PARSETREE tree); + + char *(*conf_alloc_string)(char *, char *, char *); + void (*conf_dispose_string)(char *); } PLUGIN_INPUT_FN; diff --git a/src/plugins/rsp.c b/src/plugins/rsp.c index ff021582..7e893760 100644 --- a/src/plugins/rsp.c +++ b/src/plugins/rsp.c @@ -323,6 +323,23 @@ void rsp_playlist(WS_CONNINFO *pwsc, DBQUERYINFO *pqi) { int type; char *query; char *estr = NULL; + char *transcode_codecs; + int transcode; + int samplerate; + // char *user_agent; + + /* + user_agent = infn->ws_getrequestheader(pwsc,"user-agent"); + if(user_agent) { + if(strncmp(user_agent,"iTunes",6)==0) { + trancode_codecs = "wma,ogg,flac,mpc"; + } else if(strncmp(user_agent,"Roku",4)==0) { + transcode_codecs = "ogg,flac,mpc,alac"; + } else { + transcode_codecs = "wma,ogg,flac,mpc,alac"; + } + } + */ query = infn->ws_getvar(pwsc,"query"); if(query) { @@ -381,6 +398,8 @@ void rsp_playlist(WS_CONNINFO *pwsc, DBQUERYINFO *pqi) { returned = pqi->specifiedtotalcount - pqi->index_low; } + transcode_codecs = infn->conf_alloc_string("general","ssc_codectypes",""); + xml_push(pxml,"response"); xml_push(pxml,"status"); xml_output(pxml,"errorcode","0"); @@ -394,11 +413,43 @@ void rsp_playlist(WS_CONNINFO *pwsc, DBQUERYINFO *pqi) { while((infn->db_enum_fetch_row(NULL,&row,pqi) == 0) && (row)) { xml_push(pxml,"item"); rowindex=0; + transcode = 0; + if(strstr(transcode_codecs,row[37])) /* FIXME: ticket #21 */ + transcode = 1; + while(rsp_fields[rowindex].name) { if((rsp_fields[rowindex].flags & type) && (row[rowindex] && strlen(row[rowindex]))) { - xml_output(pxml,rsp_fields[rowindex].name,"%s", - row[rowindex]); + if(transcode) { + switch(rowindex) { + case 8: + xml_output(pxml,rsp_fields[rowindex].name,"%s","wav"); + break; + case 29: + xml_output(pxml,rsp_fields[rowindex].name,"%s", + "wav audio file"); + break; + case 15: + samplerate = atoi(row[15]); + if(samplerate) { + samplerate = (samplerate * 4 * 8)/1000; + } + xml_output(pxml,rsp_fields[rowindex].name,"%d", + samplerate); + break; + case 37: + xml_output(pxml,rsp_fields[rowindex].name,"%s","wav"); + break; + default: + xml_output(pxml,rsp_fields[rowindex].name,"%s", + row[rowindex]); + break; + } + } else { + xml_output(pxml,rsp_fields[rowindex].name,"%s", + row[rowindex]); + } + } rowindex++; } @@ -406,6 +457,7 @@ void rsp_playlist(WS_CONNINFO *pwsc, DBQUERYINFO *pqi) { } infn->db_enum_end(NULL); + infn->conf_dispose_string(transcode_codecs); xml_pop(pxml); /* items */ xml_pop(pxml); /* response */ diff --git a/src/scanner-driver.c b/src/scanner-driver.c index 229facbb..048c44b4 100644 --- a/src/scanner-driver.c +++ b/src/scanner-driver.c @@ -102,8 +102,10 @@ void dump_mp3(MP3FILE *pmp3) { printf("orchestra.....: %s\n",pmp3->orchestra); printf("conductor.....: %s\n",pmp3->conductor); printf("grouping......: %s\n",pmp3->grouping); - printf("year..........: %d\n",pmp3->year); printf("url...........: %s\n",pmp3->url); + printf("description...: %s\n",pmp3->description); + printf("codectype.....: %s\n",pmp3->codectype); + printf("year..........: %d\n",pmp3->year); printf("bitrate.......: %dkb\n",pmp3->bitrate); printf("samplerate....: %d\n",pmp3->samplerate); @@ -114,6 +116,11 @@ void dump_mp3(MP3FILE *pmp3) { printf("disc..........: %d of %d\n",pmp3->disc,pmp3->total_discs); printf("compilation...: %d\n",pmp3->compilation); + + printf("rating........: %d\n",pmp3->rating); + printf("disabled......: %d\n",pmp3->disabled); + printf("bpm...........: %d\n",pmp3->bpm); + printf("has_video.....: %d\n",pmp3->has_video); }