mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-24 03:49:14 -05:00
Fix problems with iTunes 12.1, see issue #100
- don't announce group support to iTunes - support for absolute http url streaming requests
This commit is contained in:
parent
907c1725f2
commit
ebfff85afa
@ -822,7 +822,15 @@ daap_reply_server_info(struct evhttp_request *req, struct evbuffer *evbuf, char
|
||||
dmap_add_int(content, "aeSV", apro); // com.apple.itunes.music-sharing-version (determines if itunes shows share types)
|
||||
|
||||
dmap_add_short(content, "ated", 7); // daap.supportsextradata
|
||||
dmap_add_short(content, "asgr", 3); // daap.supportsgroups
|
||||
|
||||
/* Sub-optimal user-agent sniffing to solve the problem that iTunes 12.1
|
||||
* does not work if we announce support for groups.
|
||||
*/
|
||||
ua = evhttp_find_header(headers, "User-Agent");
|
||||
if (ua && (strncmp(ua, "iTunes", strlen("iTunes")) == 0))
|
||||
dmap_add_short(content, "asgr", 0); // daap.supportsgroups (1=artists, 2=albums, 3=both)
|
||||
else
|
||||
dmap_add_short(content, "asgr", 3); // daap.supportsgroups (1=artists, 2=albums, 3=both)
|
||||
|
||||
// dmap_add_long(content, "asse", 0x80000); // unknown - used by iTunes
|
||||
|
||||
@ -857,6 +865,9 @@ daap_reply_server_info(struct evhttp_request *req, struct evbuffer *evbuf, char
|
||||
|
||||
dmap_add_int(content, "msdc", 1); // dmap.databasescount
|
||||
|
||||
// dmap_add_int(content, "mstc", ); // dmap.utctime
|
||||
// dmap_add_int(content, "msto", ); // dmap.utcoffset
|
||||
|
||||
// Create container
|
||||
dmap_add_container(evbuf, "msrv", EVBUFFER_LENGTH(content));
|
||||
evbuffer_add_buffer(evbuf, content);
|
||||
@ -2331,14 +2342,9 @@ daap_reply_extra_data(struct evhttp_request *req, struct evbuffer *evbuf, char *
|
||||
static int
|
||||
daap_stream(struct evhttp_request *req, struct evbuffer *evbuf, char **uri, struct evkeyvalq *query, const char *ua)
|
||||
{
|
||||
struct daap_session *s;
|
||||
int id;
|
||||
int ret;
|
||||
|
||||
s = daap_session_find(req, query, evbuf);
|
||||
if (!s)
|
||||
return -1;
|
||||
|
||||
ret = safe_atoi32(uri[3], &id);
|
||||
if (ret < 0)
|
||||
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
|
||||
@ -2348,6 +2354,23 @@ daap_stream(struct evhttp_request *req, struct evbuffer *evbuf, char **uri, stru
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *
|
||||
uri_relative(char *uri, const char *protocol)
|
||||
{
|
||||
char *ret;
|
||||
|
||||
if (strncmp(uri, protocol, strlen(protocol)) != 0)
|
||||
return NULL;
|
||||
|
||||
ret = strchr(uri + strlen(protocol), '/');
|
||||
if (!ret)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DAAP, "Malformed DAAP Request URI '%s'\n", uri);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *
|
||||
daap_fix_request_uri(struct evhttp_request *req, char *uri)
|
||||
@ -2356,25 +2379,21 @@ daap_fix_request_uri(struct evhttp_request *req, char *uri)
|
||||
|
||||
/* iTunes 9 gives us an absolute request-uri like
|
||||
* daap://10.1.1.20:3689/server-info
|
||||
* iTunes 12.1 gives us an absolute request-uri for streaming like
|
||||
* http://10.1.1.20:3689/databases/1/items/1.mp3
|
||||
*/
|
||||
|
||||
if (strncmp(uri, "daap://", strlen("daap://")) != 0)
|
||||
return uri;
|
||||
|
||||
if ( (ret = uri_relative(uri, "daap://")) || (ret = uri_relative(uri, "http://")) )
|
||||
{
|
||||
/* Clear the proxy request flag set by evhttp
|
||||
* due to the request URI being absolute.
|
||||
* It has side-effects on Connection: keep-alive
|
||||
*/
|
||||
req->flags &= ~EVHTTP_PROXY_REQUEST;
|
||||
|
||||
ret = strchr(uri + strlen("daap://"), '/');
|
||||
if (!ret)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DAAP, "Malformed DAAP Request URI '%s'\n", uri);
|
||||
return NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return uri;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user