Add stub for adding classic metadata to metadata hub

This commit is contained in:
Mike Brady
2018-01-14 17:02:02 +00:00
parent 44258bd196
commit 7c762e6501
3 changed files with 66 additions and 2 deletions
+56
View 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);
}
+1
View 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);
+9 -2
View File
@@ -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)