From ac73ee0ce58a56edd4118b1acc41ae04f0a8f079 Mon Sep 17 00:00:00 2001 From: Julien BLACHE Date: Wed, 30 Mar 2011 19:35:13 +0200 Subject: [PATCH] Enable and handle JPEG artwork in DACP --- src/httpd_dacp.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/httpd_dacp.c b/src/httpd_dacp.c index 8ccc7b80..4a9cf52a 100644 --- a/src/httpd_dacp.c +++ b/src/httpd_dacp.c @@ -1220,6 +1220,7 @@ dacp_reply_nowplayingartwork(struct evhttp_request *req, struct evbuffer *evbuf, char clen[32]; struct daap_session *s; const char *param; + char *ctype; uint32_t id; int max_w; int max_h; @@ -1269,17 +1270,26 @@ dacp_reply_nowplayingartwork(struct evhttp_request *req, struct evbuffer *evbuf, if (ret < 0) goto no_artwork; - ret = artwork_get_item(id, max_w, max_h, ART_CAN_PNG, evbuf); - if (ret < 0) + ret = artwork_get_item(id, max_w, max_h, ART_CAN_PNG | ART_CAN_JPEG, evbuf); + switch (ret) { - if (EVBUFFER_LENGTH(evbuf) > 0) - evbuffer_drain(evbuf, EVBUFFER_LENGTH(evbuf)); + case ART_FMT_PNG: + 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_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)); evhttp_add_header(req->output_headers, "Content-Length", clen);