From: Mike Brady Date: Sun, 15 Oct 2017 13:23:09 +0000 (+0100) Subject: Add the 'dapo' metadata message, giving the DACP port number when found X-Git-Tag: 3.2d10~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3cb86f400bc7239b7a4c6224b2718fae4fedd02b;p=thirdparty%2Fshairport-sync.git Add the 'dapo' metadata message, giving the DACP port number when found --- diff --git a/mdns_avahi.c b/mdns_avahi.c index b0b511eb..cceab17c 100644 --- a/mdns_avahi.c +++ b/mdns_avahi.c @@ -30,6 +30,7 @@ #include "common.h" #include "mdns.h" +#include "rtsp.h" #include #include @@ -85,6 +86,12 @@ static void resolve_callback(AvahiServiceResolver *r, AVAHI_GCC_UNUSED AvahiIfIn if (*p != port) { debug(1, "Client's DACP port: %u.", port); *p = port; + #ifdef CONFIG_METADATA + char portstring[10]; + memset(portstring,0,sizeof(portstring)); + sprintf(portstring, "%u", port); + send_ssnc_metadata('dapo', strdup(portstring), strlen(portstring), 0); + #endif } } } else { @@ -108,7 +115,7 @@ static void browse_callback(AvahiServiceBrowser *b, AvahiIfIndex interface, Avah avahi_threaded_poll_quit(tpoll); break; case AVAHI_BROWSER_NEW: - // debug(1, "(Browser) NEW: service '%s' of type '%s' in domain '%s'.", name, type, domain); + debug(1, "(Browser) NEW: service '%s' of type '%s' in domain '%s'.", name, type, domain); /* We ignore the returned resolver object. In the callback function we free it. If the server is terminated before the callback function is called the server will free @@ -429,18 +436,21 @@ int avahi_dacp_monitor(char *dacp_id, uint16_t *port, void **private_pointer) { void avahi_dacp_dont_monitor(void **private_pointer) { dacp_browser_struct **pdbs = (dacp_browser_struct **)private_pointer; - - // stop and dispose of everything - if ((*pdbs)->service_poll) - avahi_threaded_poll_stop((*pdbs)->service_poll); - if ((*pdbs)->service_browser) - avahi_service_browser_free((*pdbs)->service_browser); - if ((*pdbs)->service_client) - avahi_client_free((*pdbs)->service_client); - if ((*pdbs)->service_poll) - avahi_threaded_poll_free((*pdbs)->service_poll); - free((char *)(*pdbs)); - *pdbs = NULL; + if (*pdbs) { + // stop and dispose of everything + if ((*pdbs)->service_poll) + avahi_threaded_poll_stop((*pdbs)->service_poll); + if ((*pdbs)->service_browser) + avahi_service_browser_free((*pdbs)->service_browser); + if ((*pdbs)->service_client) + avahi_client_free((*pdbs)->service_client); + if ((*pdbs)->service_poll) + avahi_threaded_poll_free((*pdbs)->service_poll); + free((char *)(*pdbs)); + *pdbs = NULL; + } else { + debug(1,"DHCP Monitor is not running."); + } } mdns_backend mdns_avahi = {.name = "avahi", diff --git a/rtsp.c b/rtsp.c index ea4b0144..873d0a17 100644 --- a/rtsp.c +++ b/rtsp.c @@ -938,6 +938,7 @@ static void handle_set_parameter_parameter(rtsp_conn_info *conn, rtsp_message *r // to send commands to the source's remote control (if it has one). // `clip` -- the payload is the IP number of the client, i.e. the sender of audio. // Can be an IPv4 or an IPv6 number. +// `dapo` -- the payload is the port number (as text) on the server to which remote control commands should be sent. It is 3689 for iTunes but varies for iOS devices. // A special sub-protocol is used for sending large data items over UDP // If the payload exceeded 4 MB, it is chunked using the following format: @@ -2022,7 +2023,7 @@ void rtsp_listen_loop(void) { inet_ntop(AF_INET, &(sa->sin_addr), remote_ip4, INET_ADDRSTRLEN); unsigned short int rport = ntohs(sa->sin_port); #ifdef CONFIG_METADATA - send_ssnc_metadata('clip', strdup(remote_ip4), strlen(remote_ip4), 1); + send_ssnc_metadata'clip', strdup(remote_ip4), strlen(remote_ip4), 1); send_ssnc_metadata('svip', strdup(ip4), strlen(ip4), 1); #endif debug(1, "New RTSP connection from %s:%u to self at %s:%u on conversation thread %d.", diff --git a/rtsp.h b/rtsp.h index ec4d5525..eae28dfe 100644 --- a/rtsp.h +++ b/rtsp.h @@ -15,8 +15,8 @@ void metadata_init(void); // sends metadata out to the metadata pipe, if enabled. // It is sent with the type 'ssnc' the given code, data and length -// The handler at the other end must kknow what to do with the data -// e.g. it it's malloced, to free it, etc. +// The handler at the other end must know what to do with the data +// e.g. if it's malloced, to free it, etc. // nothing is done automatically int send_ssnc_metadata(uint32_t code, char *data, uint32_t length, int block);