Add metadata checking of SET_PARAMETERS to RAOP handler
authorJuho Vähä-Herttua <juhovh@iki.fi>
Sun, 13 May 2012 12:05:16 +0000 (15:05 +0300)
committerJuho Vähä-Herttua <juhovh@iki.fi>
Wed, 16 May 2012 21:57:07 +0000 (00:57 +0300)
src/lib/raop.c

index fc57feec22f74041159e2f3a1263ddd3e14ac831..d85756b78b523fbdb07b6dc9e32c4d5885c84d97 100644 (file)
@@ -280,21 +280,29 @@ conn_request(void *ptr, http_request_t *request, http_response_t **response)
                http_response_add_header(res, "Transport", buffer);
                http_response_add_header(res, "Session", "DEADBEEF");
        } else if (!strcmp(method, "SET_PARAMETER")) {
+               const char *content_type;
                const char *data;
                int datalen;
-               char *datastr;
 
+               content_type = http_request_get_header(request, "Content-Type");
                data = http_request_get_data(request, &datalen);
-               datastr = calloc(1, datalen+1);
-               if (data && datastr && conn->raop_rtp) {
-                       memcpy(datastr, data, datalen);
-                       if (!strncmp(datastr, "volume: ", 8)) {
-                               float vol = 0.0;
-                               sscanf(datastr+8, "%f", &vol);
-                               raop_rtp_set_volume(conn->raop_rtp, vol);
+               if (!strcmp(content_type, "text/parameters")) {
+                       char *datastr;
+                       datastr = calloc(1, datalen+1);
+                       if (data && datastr && conn->raop_rtp) {
+                               memcpy(datastr, data, datalen);
+                               if (!strncmp(datastr, "volume: ", 8)) {
+                                       float vol = 0.0;
+                                       sscanf(datastr+8, "%f", &vol);
+                                       raop_rtp_set_volume(conn->raop_rtp, vol);
+                               }
                        }
+                       free(datastr);
+               } else if (!strcmp(content_type, "image/jpeg")) {
+                       logger_log(&conn->raop->logger, LOGGER_INFO, "UNHANDLED: Got image data of %d bytes", datalen);
+               } else if (!strcmp(content_type, "application/x-dmap-tagged")) {
+                       logger_log(&conn->raop->logger, LOGGER_INFO, "UNHANDLED: Got metadata of %d bytes", datalen);
                }
-               free(datastr);
        } else if (!strcmp(method, "FLUSH")) {
                const char *rtpinfo;
                int next_seq = -1;