]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Add stub for adding classic metadata to metadata hub
authorMike Brady <mikebrady@eircom.net>
Sun, 14 Jan 2018 17:02:02 +0000 (17:02 +0000)
committerMike Brady <mikebrady@eircom.net>
Sun, 14 Jan 2018 17:02:02 +0000 (17:02 +0000)
metadata_hub.c
metadata_hub.h
rtsp.c

index 3f09fc5d08ce6f3908398c4984431ede2f9bf24d..36a933033afe99fb40137effb1dd135acd248bbe 100644 (file)
@@ -29,6 +29,7 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
+#include <stdlib.h>
 #include <string.h>
 
 #include "dacp.h"
@@ -59,3 +60,58 @@ void run_metadata_watchers(void) {
     }
   }
 }
+
+void metadata_hub_process_metadata(uint32_t type, uint32_t code, char *data, uint32_t length) {
+  // metadata coming in from the audio source or from Shairport Sync itself passes through here
+  // this has more information about tags, which might be relevant:
+  // https://code.google.com/p/ytrack/wiki/DMAP
+  char *payload;
+  if (length < 2048)
+    payload = strndup(data, length);
+  else
+    payload = NULL;
+  switch (code) {
+  case 'asal':
+    debug(1, "MH Album Name: \"%s\".", payload);
+    break;
+  case 'asar':
+    debug(1, "MH Artist: \"%s\".", payload);
+    break;
+  case 'ascm':
+    debug(1, "MH Comment: \"%s\".", payload);
+    break;
+  case 'asgn':
+    debug(1, "MH Genre: \"%s\".", payload);
+    break;
+  case 'minm':
+    debug(1, "MH Title: \"%s\".", payload);
+    break;
+  case 'ascp':
+    debug(1, "MH Composer: \"%s\".", payload);
+    break;
+  case 'asdt':
+    debug(1, "MH File kind: \"%s\".", payload);
+    break;
+  case 'assn':
+    debug(1, "MH Sort as: \"%s\".", payload);
+    break;
+  case 'PICT':
+    debug(1, "MH Picture received, length %u bytes.", length);
+    break;
+  case 'clip':
+    debug(1, "MH Client's IP: \"%s\".", payload);
+    break;
+  default:
+    if (type == 'ssnc') {
+      char typestring[5];
+      *(uint32_t *)typestring = htonl(type);
+      typestring[4] = 0;
+      char codestring[5];
+      *(uint32_t *)codestring = htonl(code);
+      codestring[4] = 0;
+      debug(1, "MH \"%s\" \"%s\": \"%s\".", typestring, codestring, payload);
+    }
+  }
+  if (payload)
+    free(payload);
+}
index c84cd896cbc7d79347517f9811a08c7f1f7345e6..3c09eff343524d3f752ffbf582bc49142f9dbe17 100644 (file)
@@ -79,3 +79,4 @@ void add_metadata_watcher(metadata_watcher fn, void *userdata);
 void run_metadata_watchers(void);
 
 void metadata_hub_init(void);
+void metadata_hub_process_metadata(uint32_t type, uint32_t code, char *data, uint32_t length);
diff --git a/rtsp.c b/rtsp.c
index c28b4a039a114a4a2161c22c7fa358eb45a16dd9..254160d9f59ad237905458814635b1dee8a69415 100644 (file)
--- a/rtsp.c
+++ b/rtsp.c
 #include "rtp.h"
 #include "rtsp.h"
 
+#ifdef HAVE_METADATA_HUB
+#include "metadata_hub.h"
+#endif
+
 #ifdef AF_INET6
 #define INETx_ADDRSTRLEN INET6_ADDRSTRLEN
 #else
@@ -1195,9 +1199,12 @@ void *metadata_thread_function(void *ignore) {
   metadata_package pack;
   while (1) {
     pc_queue_get_item(&metadata_queue, &pack);
-    if (config.metadata_enabled)
+    if (config.metadata_enabled) {
       metadata_process(pack.type, pack.code, pack.data, pack.length);
-
+#ifdef HAVE_METADATA_HUB
+      metadata_hub_process_metadata(pack.type, pack.code, pack.data, pack.length);
+#endif
+    }
     if (pack.carrier)
       msg_free(pack.carrier); // release the message
     else if (pack.data)