mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-03 18:06:04 -05:00
Make script-based transcoding work on rsp
This commit is contained in:
parent
430b0ef9a4
commit
aca2f7701f
@ -409,47 +409,47 @@ int db_sqlite2_insert_id(void) {
|
|||||||
|
|
||||||
char *db_sqlite2_initial1 =
|
char *db_sqlite2_initial1 =
|
||||||
"create table songs (\n"
|
"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"
|
" path VARCHAR(4096) UNIQUE NOT NULL,\n"
|
||||||
" fname VARCHAR(255) NOT NULL,\n"
|
" fname VARCHAR(255) NOT NULL,\n"
|
||||||
" title VARCHAR(1024) DEFAULT NULL,\n"
|
" title VARCHAR(1024) DEFAULT NULL,\n"
|
||||||
" artist 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"
|
" genre VARCHAR(255) DEFAULT NULL,\n"
|
||||||
" comment VARCHAR(4096) DEFAULT NULL,\n"
|
" comment VARCHAR(4096) DEFAULT NULL,\n"
|
||||||
" type VARCHAR(255) DEFAULT NULL,\n"
|
" type VARCHAR(255) DEFAULT NULL,\n"
|
||||||
" composer VARCHAR(1024) 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"
|
" conductor VARCHAR(1024) DEFAULT NULL,\n"
|
||||||
" grouping VARCHAR(1024) DEFAULT NULL,\n"
|
" grouping VARCHAR(1024) DEFAULT NULL,\n"
|
||||||
" url VARCHAR(1024) DEFAULT NULL,\n"
|
" url VARCHAR(1024) DEFAULT NULL,\n"
|
||||||
" bitrate INTEGER DEFAULT 0,\n"
|
" bitrate INTEGER DEFAULT 0,\n"
|
||||||
" samplerate INTEGER DEFAULT 0,\n"
|
" samplerate INTEGER DEFAULT 0,\n" /* 15 */
|
||||||
" song_length INTEGER DEFAULT 0,\n"
|
" song_length INTEGER DEFAULT 0,\n"
|
||||||
" file_size INTEGER DEFAULT 0,\n"
|
" file_size INTEGER DEFAULT 0,\n"
|
||||||
" year INTEGER DEFAULT 0,\n"
|
" year INTEGER DEFAULT 0,\n"
|
||||||
" track 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"
|
" disc INTEGER DEFAULT 0,\n"
|
||||||
" total_discs INTEGER DEFAULT 0,\n"
|
" total_discs INTEGER DEFAULT 0,\n"
|
||||||
" bpm INTEGER DEFAULT 0,\n"
|
" bpm INTEGER DEFAULT 0,\n"
|
||||||
" compilation 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"
|
" play_count INTEGER DEFAULT 0,\n"
|
||||||
" data_kind INTEGER DEFAULT 0,\n"
|
" data_kind INTEGER DEFAULT 0,\n"
|
||||||
" item_kind INTEGER DEFAULT 0,\n"
|
" item_kind INTEGER DEFAULT 0,\n"
|
||||||
" description 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_modified INTEGER DEFAULT 0,\n"
|
||||||
" time_played INTEGER DEFAULT 0,\n"
|
" time_played INTEGER DEFAULT 0,\n"
|
||||||
" db_timestamp INTEGER DEFAULT 0,\n"
|
" db_timestamp INTEGER DEFAULT 0,\n"
|
||||||
" disabled 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"
|
" force_update INTEGER DEFAULT 0,\n"
|
||||||
" codectype VARCHAR(5) DEFAULT NULL,\n"
|
" codectype VARCHAR(5) DEFAULT NULL,\n"
|
||||||
" idx INTEGER NOT NULL,\n"
|
" idx INTEGER NOT NULL,\n"
|
||||||
" has_video INTEGER DEFAULT 0,\n"
|
" has_video INTEGER DEFAULT 0,\n"
|
||||||
" contentrating INTEGER DEFAULT 0\n"
|
" contentrating INTEGER DEFAULT 0\n" /* 40 */
|
||||||
");\n"
|
");\n"
|
||||||
"create table playlistitems (\n"
|
"create table playlistitems (\n"
|
||||||
" id INTEGER PRIMARY KEY NOT NULL,\n"
|
" id INTEGER PRIMARY KEY NOT NULL,\n"
|
||||||
|
@ -137,7 +137,7 @@ static TAGHANDLER taghandlers[] = {
|
|||||||
{ "wma", scan_get_wmainfo, "wma", "wma", "WMA audio file" },
|
{ "wma", scan_get_wmainfo, "wma", "wma", "WMA audio file" },
|
||||||
{ "url", scan_get_urlinfo, "pls", NULL, "Playlist URL" },
|
{ "url", scan_get_urlinfo, "pls", NULL, "Playlist URL" },
|
||||||
{ "pls", 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
|
#ifdef OGGVORBIS
|
||||||
{ "ogg", scan_get_ogginfo, "ogg", "ogg", "Ogg Vorbis audio file" },
|
{ "ogg", scan_get_ogginfo, "ogg", "ogg", "Ogg Vorbis audio file" },
|
||||||
#endif
|
#endif
|
||||||
|
12
src/plugin.c
12
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_fetch_row(char **pe, char ***row, DBQUERYINFO *pinfo);
|
||||||
int pi_db_enum_end(char **pe);
|
int pi_db_enum_end(char **pe);
|
||||||
void pi_stream(WS_CONNINFO *pwsc, DBQUERYINFO *pqi, char *id);
|
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);
|
int pi_sp_parse(PARSETREE tree, char *term);
|
||||||
|
|
||||||
PLUGIN_INPUT_FN pi = {
|
PLUGIN_INPUT_FN pi = {
|
||||||
@ -119,9 +119,13 @@ PLUGIN_INPUT_FN pi = {
|
|||||||
sp_init,
|
sp_init,
|
||||||
pi_sp_parse,
|
pi_sp_parse,
|
||||||
sp_dispose,
|
sp_dispose,
|
||||||
sp_get_error
|
sp_get_error,
|
||||||
|
|
||||||
|
conf_alloc_string,
|
||||||
|
pi_conf_dispose_string
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initialize stuff for plugins
|
* 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) {
|
int pi_sp_parse(PARSETREE tree, char *term) {
|
||||||
return sp_parse(tree, term, 0);
|
return sp_parse(tree, term, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pi_conf_dispose_string(char *str) {
|
||||||
|
free(str);
|
||||||
|
}
|
||||||
|
@ -115,6 +115,9 @@ typedef struct tag_plugin_input_fn {
|
|||||||
int (*sp_parse)(PARSETREE tree, char *term);
|
int (*sp_parse)(PARSETREE tree, char *term);
|
||||||
int (*sp_dispose)(PARSETREE tree);
|
int (*sp_dispose)(PARSETREE tree);
|
||||||
char* (*sp_get_error)(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;
|
} PLUGIN_INPUT_FN;
|
||||||
|
|
||||||
#endif /* _PLUGIN_H_ */
|
#endif /* _PLUGIN_H_ */
|
||||||
|
@ -191,6 +191,9 @@ typedef struct tag_plugin_input_fn {
|
|||||||
int (*sp_parse)(PARSETREE tree, char *term);
|
int (*sp_parse)(PARSETREE tree, char *term);
|
||||||
int (*sp_dispose)(PARSETREE tree);
|
int (*sp_dispose)(PARSETREE tree);
|
||||||
char* (*sp_get_error)(PARSETREE tree);
|
char* (*sp_get_error)(PARSETREE tree);
|
||||||
|
|
||||||
|
char *(*conf_alloc_string)(char *, char *, char *);
|
||||||
|
void (*conf_dispose_string)(char *);
|
||||||
} PLUGIN_INPUT_FN;
|
} PLUGIN_INPUT_FN;
|
||||||
|
|
||||||
|
|
||||||
|
@ -323,6 +323,23 @@ void rsp_playlist(WS_CONNINFO *pwsc, DBQUERYINFO *pqi) {
|
|||||||
int type;
|
int type;
|
||||||
char *query;
|
char *query;
|
||||||
char *estr = NULL;
|
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");
|
query = infn->ws_getvar(pwsc,"query");
|
||||||
if(query) {
|
if(query) {
|
||||||
@ -381,6 +398,8 @@ void rsp_playlist(WS_CONNINFO *pwsc, DBQUERYINFO *pqi) {
|
|||||||
returned = pqi->specifiedtotalcount - pqi->index_low;
|
returned = pqi->specifiedtotalcount - pqi->index_low;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
transcode_codecs = infn->conf_alloc_string("general","ssc_codectypes","");
|
||||||
|
|
||||||
xml_push(pxml,"response");
|
xml_push(pxml,"response");
|
||||||
xml_push(pxml,"status");
|
xml_push(pxml,"status");
|
||||||
xml_output(pxml,"errorcode","0");
|
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)) {
|
while((infn->db_enum_fetch_row(NULL,&row,pqi) == 0) && (row)) {
|
||||||
xml_push(pxml,"item");
|
xml_push(pxml,"item");
|
||||||
rowindex=0;
|
rowindex=0;
|
||||||
|
transcode = 0;
|
||||||
|
if(strstr(transcode_codecs,row[37])) /* FIXME: ticket #21 */
|
||||||
|
transcode = 1;
|
||||||
|
|
||||||
while(rsp_fields[rowindex].name) {
|
while(rsp_fields[rowindex].name) {
|
||||||
if((rsp_fields[rowindex].flags & type) &&
|
if((rsp_fields[rowindex].flags & type) &&
|
||||||
(row[rowindex] && strlen(row[rowindex]))) {
|
(row[rowindex] && strlen(row[rowindex]))) {
|
||||||
xml_output(pxml,rsp_fields[rowindex].name,"%s",
|
if(transcode) {
|
||||||
row[rowindex]);
|
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++;
|
rowindex++;
|
||||||
}
|
}
|
||||||
@ -406,6 +457,7 @@ void rsp_playlist(WS_CONNINFO *pwsc, DBQUERYINFO *pqi) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
infn->db_enum_end(NULL);
|
infn->db_enum_end(NULL);
|
||||||
|
infn->conf_dispose_string(transcode_codecs);
|
||||||
|
|
||||||
xml_pop(pxml); /* items */
|
xml_pop(pxml); /* items */
|
||||||
xml_pop(pxml); /* response */
|
xml_pop(pxml); /* response */
|
||||||
|
@ -102,8 +102,10 @@ void dump_mp3(MP3FILE *pmp3) {
|
|||||||
printf("orchestra.....: %s\n",pmp3->orchestra);
|
printf("orchestra.....: %s\n",pmp3->orchestra);
|
||||||
printf("conductor.....: %s\n",pmp3->conductor);
|
printf("conductor.....: %s\n",pmp3->conductor);
|
||||||
printf("grouping......: %s\n",pmp3->grouping);
|
printf("grouping......: %s\n",pmp3->grouping);
|
||||||
printf("year..........: %d\n",pmp3->year);
|
|
||||||
printf("url...........: %s\n",pmp3->url);
|
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("bitrate.......: %dkb\n",pmp3->bitrate);
|
||||||
printf("samplerate....: %d\n",pmp3->samplerate);
|
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("disc..........: %d of %d\n",pmp3->disc,pmp3->total_discs);
|
||||||
|
|
||||||
printf("compilation...: %d\n",pmp3->compilation);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user