From: Mike Brady Date: Sun, 14 Jan 2018 17:02:02 +0000 (+0000) Subject: Add stub for adding classic metadata to metadata hub X-Git-Tag: 3.2d29~119 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c762e6501b9b08e6dfa3f62d6fd8f3a4d8f9da6;p=thirdparty%2Fshairport-sync.git Add stub for adding classic metadata to metadata hub --- diff --git a/metadata_hub.c b/metadata_hub.c index 3f09fc5d..36a93303 100644 --- a/metadata_hub.c +++ b/metadata_hub.c @@ -29,6 +29,7 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include #include #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); +} diff --git a/metadata_hub.h b/metadata_hub.h index c84cd896..3c09eff3 100644 --- a/metadata_hub.h +++ b/metadata_hub.h @@ -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 c28b4a03..254160d9 100644 --- a/rtsp.c +++ b/rtsp.c @@ -63,6 +63,10 @@ #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)