Enable and handle JPEG artwork in DAAP

This commit is contained in:
Julien BLACHE 2011-03-30 19:35:13 +02:00
parent c7209ab699
commit 204c9681ca

View File

@ -2643,6 +2643,7 @@ daap_reply_extra_data(struct evhttp_request *req, struct evbuffer *evbuf, char *
char clen[32]; char clen[32];
struct daap_session *s; struct daap_session *s;
const char *param; const char *param;
char *ctype;
int id; int id;
int max_w; int max_w;
int max_h; int max_h;
@ -2696,20 +2697,29 @@ daap_reply_extra_data(struct evhttp_request *req, struct evbuffer *evbuf, char *
} }
if (strcmp(uri[2], "groups") == 0) if (strcmp(uri[2], "groups") == 0)
ret = artwork_get_group(id, max_w, max_h, ART_CAN_PNG, evbuf); ret = artwork_get_group(id, max_w, max_h, ART_CAN_PNG | ART_CAN_JPEG, evbuf);
else if (strcmp(uri[2], "items") == 0) else if (strcmp(uri[2], "items") == 0)
ret = artwork_get_item(id, max_w, max_h, ART_CAN_PNG, evbuf); ret = artwork_get_item(id, max_w, max_h, ART_CAN_PNG | ART_CAN_JPEG, evbuf);
if (ret < 0) switch (ret)
{ {
if (EVBUFFER_LENGTH(evbuf) > 0) case ART_FMT_PNG:
evbuffer_drain(evbuf, EVBUFFER_LENGTH(evbuf)); ctype = "image/png";
break;
goto no_artwork; case ART_FMT_JPEG:
ctype = "image/jpeg";
break;
default:
if (EVBUFFER_LENGTH(evbuf) > 0)
evbuffer_drain(evbuf, EVBUFFER_LENGTH(evbuf));
goto no_artwork;
} }
evhttp_remove_header(req->output_headers, "Content-Type"); evhttp_remove_header(req->output_headers, "Content-Type");
evhttp_add_header(req->output_headers, "Content-Type", "image/png"); evhttp_add_header(req->output_headers, "Content-Type", ctype);
snprintf(clen, sizeof(clen), "%ld", (long)EVBUFFER_LENGTH(evbuf)); snprintf(clen, sizeof(clen), "%ld", (long)EVBUFFER_LENGTH(evbuf));
evhttp_add_header(req->output_headers, "Content-Length", clen); evhttp_add_header(req->output_headers, "Content-Length", clen);