Add the 'dapo' metadata message, giving the DACP port number when found

This commit is contained in:
Mike Brady
2017-10-15 14:23:09 +01:00
parent 415b3f4ba9
commit 3cb86f400b
3 changed files with 27 additions and 16 deletions
+23 -13
View File
@@ -30,6 +30,7 @@
#include "common.h"
#include "mdns.h"
#include "rtsp.h"
#include <string.h>
#include <avahi-client/client.h>
@@ -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",
+2 -1
View File
@@ -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.",
+2 -2
View File
@@ -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);