mirror of
https://github.com/owntone/owntone-server.git
synced 2025-03-31 01:33:44 -04:00
Updates for iTunes 4.5. Some problems with seeking on mac, though
This commit is contained in:
parent
366a44702e
commit
3d2c60572d
21
src/daap.c
21
src/daap.c
@ -195,7 +195,7 @@ DAAP_BLOCK *daap_response_content_codes(void) {
|
|||||||
DAAP_BLOCK *daap_response_login(char *hostname) {
|
DAAP_BLOCK *daap_response_login(char *hostname) {
|
||||||
DAAP_BLOCK *root;
|
DAAP_BLOCK *root;
|
||||||
int g=1;
|
int g=1;
|
||||||
int session;
|
int session=0;
|
||||||
|
|
||||||
DPRINTF(ERR_DEBUG,"Preparing to send login response\n");
|
DPRINTF(ERR_DEBUG,"Preparing to send login response\n");
|
||||||
|
|
||||||
@ -557,18 +557,29 @@ DAAP_BLOCK *daap_response_dbinfo(char *name) {
|
|||||||
*
|
*
|
||||||
* handle the daap block for the /server-info URI
|
* handle the daap block for the /server-info URI
|
||||||
*/
|
*/
|
||||||
DAAP_BLOCK *daap_response_server_info(char *name) {
|
DAAP_BLOCK *daap_response_server_info(char *name, char *client_version) {
|
||||||
DAAP_BLOCK *root;
|
DAAP_BLOCK *root;
|
||||||
int g=1;
|
int g=1;
|
||||||
|
|
||||||
DPRINTF(ERR_DEBUG,"Preparing to send server info\n");
|
DPRINTF(ERR_DEBUG,"Preparing to send server info for client version %s\n",client_version);
|
||||||
|
|
||||||
root=daap_add_empty(NULL,"msrv");
|
root=daap_add_empty(NULL,"msrv");
|
||||||
|
|
||||||
if(root) {
|
if(root) {
|
||||||
g = (int)daap_add_int(root,"mstt",200); /* result */
|
g = (int)daap_add_int(root,"mstt",200); /* result */
|
||||||
g = g && daap_add_int(root,"mpro",2 << 16); /* dmap proto ? */
|
if((!client_version)||(!strcmp(client_version,"3.0"))) {
|
||||||
g = g && daap_add_int(root,"apro",2 << 16); /* daap protocol */
|
g = g && daap_add_int(root,"mpro",2 << 16); /* dmap proto ? */
|
||||||
|
g = g && daap_add_int(root,"apro",3 << 16); /* daap protocol */
|
||||||
|
} else {
|
||||||
|
if(!strcmp(client_version,"1.0")) {
|
||||||
|
g = g && daap_add_int(root,"mpro",1 << 16); /* dmap proto ? */
|
||||||
|
g = g && daap_add_int(root,"apro",1 << 16); /* daap protocol */
|
||||||
|
} else if(!strcmp(client_version,"2.0")) {
|
||||||
|
g = g && daap_add_int(root,"mpro",1 << 16); /* dmap proto ? */
|
||||||
|
g = g && daap_add_int(root,"apro",2 << 16); /* daap protocol */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g = g && daap_add_string(root,"minm",name); /* server name */
|
g = g && daap_add_string(root,"minm",name); /* server name */
|
||||||
g = g && daap_add_char(root,"mslr",config.readpassword != NULL); /* logon required */
|
g = g && daap_add_char(root,"mslr",config.readpassword != NULL); /* logon required */
|
||||||
g = g && daap_add_int(root,"mstm",1800); /* timeout - iTunes=1800 */
|
g = g && daap_add_int(root,"mstm",1800); /* timeout - iTunes=1800 */
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "daap-proto.h"
|
#include "daap-proto.h"
|
||||||
|
|
||||||
DAAP_BLOCK *daap_response_server_info(char *name);
|
DAAP_BLOCK *daap_response_server_info(char *name, char *client_version);
|
||||||
DAAP_BLOCK *daap_response_content_codes(void);
|
DAAP_BLOCK *daap_response_content_codes(void);
|
||||||
DAAP_BLOCK *daap_response_login(char *hostname);
|
DAAP_BLOCK *daap_response_login(char *hostname);
|
||||||
DAAP_BLOCK *daap_response_update(int fd, int clientver);
|
DAAP_BLOCK *daap_response_update(int fd, int clientver);
|
||||||
|
25
src/main.c
25
src/main.c
@ -108,8 +108,8 @@ void daap_handler(WS_CONNINFO *pwsc) {
|
|||||||
|
|
||||||
int img_fd;
|
int img_fd;
|
||||||
|
|
||||||
off_t offset=0;
|
long offset=0;
|
||||||
off_t file_len;
|
long file_len;
|
||||||
|
|
||||||
close=pwsc->close;
|
close=pwsc->close;
|
||||||
pwsc->close=1; /* in case we have any errors */
|
pwsc->close=1; /* in case we have any errors */
|
||||||
@ -125,7 +125,8 @@ void daap_handler(WS_CONNINFO *pwsc) {
|
|||||||
|
|
||||||
if(!strcasecmp(pwsc->uri,"/server-info")) {
|
if(!strcasecmp(pwsc->uri,"/server-info")) {
|
||||||
config_set_status(pwsc,session_id,"Sending server info");
|
config_set_status(pwsc,session_id,"Sending server info");
|
||||||
root=daap_response_server_info(config.servername);
|
root=daap_response_server_info(config.servername,
|
||||||
|
ws_getrequestheader(pwsc,"Client-DAAP-Version"));
|
||||||
} else if (!strcasecmp(pwsc->uri,"/content-codes")) {
|
} else if (!strcasecmp(pwsc->uri,"/content-codes")) {
|
||||||
config_set_status(pwsc,session_id,"Sending content codes");
|
config_set_status(pwsc,session_id,"Sending content codes");
|
||||||
root=daap_response_content_codes();
|
root=daap_response_content_codes();
|
||||||
@ -248,8 +249,8 @@ void daap_handler(WS_CONNINFO *pwsc) {
|
|||||||
pwsc->close=1;
|
pwsc->close=1;
|
||||||
|
|
||||||
if(ws_getrequestheader(pwsc,"range")) {
|
if(ws_getrequestheader(pwsc,"range")) {
|
||||||
offset=atol(ws_getrequestheader(pwsc,"range") + 6);
|
offset=(long)atol(ws_getrequestheader(pwsc,"range") + 6);
|
||||||
DPRINTF(ERR_DEBUG,"Thread %d: Skipping to byte %ld\n",pwsc->threadno,offset);
|
DPRINTF(ERR_DEBUG,"Offset is %ld\n",offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
pmp3=db_find(item);
|
pmp3=db_find(item);
|
||||||
@ -266,7 +267,10 @@ void daap_handler(WS_CONNINFO *pwsc) {
|
|||||||
config_set_status(pwsc,session_id,NULL);
|
config_set_status(pwsc,session_id,NULL);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
file_len=lseek(file_fd,0,SEEK_END);
|
file_len=(long)lseek(file_fd,0,SEEK_END);
|
||||||
|
DPRINTF(ERR_DEBUG,"Thread %d: length of file is %ld\n",
|
||||||
|
pwsc->threadno,(long)file_len);
|
||||||
|
|
||||||
lseek(file_fd,0,SEEK_SET);
|
lseek(file_fd,0,SEEK_SET);
|
||||||
file_len -= offset;
|
file_len -= offset;
|
||||||
|
|
||||||
@ -285,15 +289,15 @@ void daap_handler(WS_CONNINFO *pwsc) {
|
|||||||
if(!offset)
|
if(!offset)
|
||||||
config.stats.songs_served++; /* FIXME: remove stat races */
|
config.stats.songs_served++; /* FIXME: remove stat races */
|
||||||
|
|
||||||
if((config.artfilename) &&
|
if((config.artfilename) &&
|
||||||
((img_fd=da_get_image_fd(pmp3->path)) != -1) && (!offset) &&
|
(!offset) && (strncasecmp(pmp3->type,".mp3",4) ==0) &&
|
||||||
(strncasecmp(pmp3->type,".mp3",4) ==0)) {
|
((img_fd=da_get_image_fd(pmp3->path)) != -1)) {
|
||||||
DPRINTF(ERR_INFO,"Dynamically attaching artwork to %s (fd %d)\n",
|
DPRINTF(ERR_INFO,"Dynamically attaching artwork to %s (fd %d)\n",
|
||||||
pmp3->fname, img_fd);
|
pmp3->fname, img_fd);
|
||||||
da_attach_image(img_fd, pwsc->fd, file_fd, offset);
|
da_attach_image(img_fd, pwsc->fd, file_fd, offset);
|
||||||
} else if(offset) {
|
} else if(offset) {
|
||||||
DPRINTF(ERR_INFO,"Seeking to offset %d\n",offset);
|
DPRINTF(ERR_INFO,"Seeking to offset %d\n",offset);
|
||||||
lseek(file_fd,offset,SEEK_SET);
|
lseek(file_fd,(fpos_t)offset,SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(copyfile(file_fd,pwsc->fd)) {
|
if(copyfile(file_fd,pwsc->fd)) {
|
||||||
@ -438,7 +442,6 @@ int drop_privs(char *user) {
|
|||||||
* This thread merely spins waiting for signals
|
* This thread merely spins waiting for signals
|
||||||
*/
|
*/
|
||||||
void *signal_handler(void *arg) {
|
void *signal_handler(void *arg) {
|
||||||
int error;
|
|
||||||
sigset_t intmask;
|
sigset_t intmask;
|
||||||
int sig;
|
int sig;
|
||||||
|
|
||||||
|
@ -688,6 +688,19 @@ void *ws_dispatcher(void *arg) {
|
|||||||
first=ws_urldecode(pwsc->uri);
|
first=ws_urldecode(pwsc->uri);
|
||||||
free(pwsc->uri);
|
free(pwsc->uri);
|
||||||
pwsc->uri=first;
|
pwsc->uri=first;
|
||||||
|
|
||||||
|
/* Strip out the proxy stuff - iTunes 4.5 */
|
||||||
|
first=strstr(pwsc->uri,"://");
|
||||||
|
if(first) {
|
||||||
|
first += 3;
|
||||||
|
first=strchr(first,'/');
|
||||||
|
if(first) {
|
||||||
|
first=strdup(first);
|
||||||
|
free(pwsc->uri);
|
||||||
|
pwsc->uri=first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DPRINTF(ERR_DEBUG,"Thread %d: Translated URI: %s\n",pwsc->threadno,
|
DPRINTF(ERR_DEBUG,"Thread %d: Translated URI: %s\n",pwsc->threadno,
|
||||||
pwsc->uri);
|
pwsc->uri);
|
||||||
@ -945,11 +958,12 @@ int ws_testarg(ARGLIST *root, char *key, char *value) {
|
|||||||
char *ws_getarg(ARGLIST *root, char *key) {
|
char *ws_getarg(ARGLIST *root, char *key) {
|
||||||
ARGLIST *pcurrent=root->next;
|
ARGLIST *pcurrent=root->next;
|
||||||
|
|
||||||
while((pcurrent)&&(strcasecmp(pcurrent->key,key)))
|
while((pcurrent)&&(strcasecmp(pcurrent->key,key)))
|
||||||
pcurrent=pcurrent->next;
|
pcurrent=pcurrent->next;
|
||||||
|
|
||||||
if(pcurrent)
|
if(pcurrent)
|
||||||
return pcurrent->value;
|
return pcurrent->value;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1132,6 +1146,8 @@ int ws_findhandler(WS_PRIVATE *pwsp, WS_CONNINFO *pwsc,
|
|||||||
|
|
||||||
ws_lock_unsafe();
|
ws_lock_unsafe();
|
||||||
|
|
||||||
|
*preq=NULL;
|
||||||
|
|
||||||
DPRINTF(ERR_DEBUG,"Thread %d: Preparing to find handler\n",
|
DPRINTF(ERR_DEBUG,"Thread %d: Preparing to find handler\n",
|
||||||
pwsc->threadno);
|
pwsc->threadno);
|
||||||
|
|
||||||
@ -1287,7 +1303,7 @@ int ws_addresponseheader(WS_CONNINFO *pwsc, char *header, char *fmt, ...) {
|
|||||||
* Simple wrapper around the CONNINFO request vars
|
* Simple wrapper around the CONNINFO request vars
|
||||||
*/
|
*/
|
||||||
char *ws_getvar(WS_CONNINFO *pwsc, char *var) {
|
char *ws_getvar(WS_CONNINFO *pwsc, char *var) {
|
||||||
return ws_getarg(&pwsc->request_vars,var);
|
return ws_getarg(&(pwsc->request_vars),var);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *ws_getrequestheader(WS_CONNINFO *pwsc, char *header) {
|
char *ws_getrequestheader(WS_CONNINFO *pwsc, char *header) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user