Pārlūkot izejas kodu

Fix AirPlay artwork disappearing

philippe44 1 gadu atpakaļ
vecāks
revīzija
0002256630
2 mainītis faili ar 12 papildinājumiem un 6 dzēšanām
  1. 9 5
      components/raop/raop.c
  2. 3 1
      components/raop/raop_sink.c

+ 9 - 5
components/raop/raop.c

@@ -626,15 +626,19 @@ static bool handle_rtsp(raop_ctx_t *ctx, int sock)
 			settings.ctx = &metadata;
 			memset(&metadata, 0, sizeof(struct metadata_s));
 			if (!dmap_parse(&settings, body, len)) {
-				LOG_INFO("[%p]: received metadata\n\tartist: %s\n\talbum:  %s\n\ttitle:  %s",
-						 ctx, metadata.artist ? metadata.artist : "", metadata.album ? metadata.album : "", 
+                uint32_t timestamp = 0;
+                if ((p = kd_lookup(headers, "RTP-Info")) != NULL) sscanf(p, "%*[^=]=%d", &timestamp);
+				LOG_INFO("[%p]: received metadata (ts: %d)\n\tartist: %s\n\talbum:  %s\n\ttitle:  %s",
+						 ctx, timestamp, metadata.artist ? metadata.artist : "", metadata.album ? metadata.album : "", 
                          metadata.title ? metadata.title : "");
-				success = ctx->cmd_cb(RAOP_METADATA, metadata.artist, metadata.album, metadata.title);
+                success = ctx->cmd_cb(RAOP_METADATA, timestamp, metadata.artist, metadata.album, metadata.title);
 				free_metadata(&metadata);
 			}
 		} else if (body && ((p = kd_lookup(headers, "Content-Type")) != NULL) && strcasestr(p, "image/jpeg")) {			
-			LOG_INFO("[%p]: received JPEG image of %d bytes", ctx, len);
-			ctx->cmd_cb(RAOP_ARTWORK, body, len);
+            uint32_t timestamp = 0;
+            if ((p = kd_lookup(headers, "RTP-Info")) != NULL) sscanf(p, "%*[^=]=%d", &timestamp);
+            LOG_INFO("[%p]: received JPEG image of %d bytes (ts:%d)", ctx, len, timestamp);            
+			ctx->cmd_cb(RAOP_ARTWORK, timestamp, body, len);
 		} else {
 			char *dump = kd_dump(headers);
 			LOG_INFO("Unhandled SET PARAMETER\n%s", dump);

+ 3 - 1
components/raop/raop_sink.c

@@ -113,6 +113,7 @@ static bool cmd_handler(raop_event_t event, ...) {
 	case RAOP_SETUP:
 		actrls_set(controls, false, NULL, actrls_ir_action);
 		displayer_control(DISPLAYER_ACTIVATE, "AIRPLAY", true);
+        displayer_artwork(NULL);
 		break;
 	case RAOP_PLAY:
 		displayer_control(DISPLAYER_TIMER_RUN);
@@ -130,12 +131,13 @@ static bool cmd_handler(raop_event_t event, ...) {
 		displayer_control(DISPLAYER_SUSPEND);
 		break;
 	case RAOP_METADATA: {
+        uint32_t timestamp = va_arg(args, uint32_t);
 		char *artist = va_arg(args, char*), *album = va_arg(args, char*), *title = va_arg(args, char*);
 		displayer_metadata(artist, album, title);
-		displayer_artwork(NULL);
 		break;
 	}	
 	case RAOP_ARTWORK: {
+        uint32_t timestamp = va_arg(args, uint32_t);
 		uint8_t *data = va_arg(args, uint8_t*);
 		displayer_artwork(data);
 		break;