]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Add the 'dapo' metadata message, giving the DACP port number when found
authorMike Brady <mikebrady@eircom.net>
Sun, 15 Oct 2017 13:23:09 +0000 (14:23 +0100)
committerMike Brady <mikebrady@eircom.net>
Sun, 15 Oct 2017 13:23:09 +0000 (14:23 +0100)
mdns_avahi.c
rtsp.c
rtsp.h

index b0b511ebb7c359fcaeae4690ca85c904e0d18cbf..cceab17c11c77bd6a04f658acedcd8ad50372a14 100644 (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",
diff --git a/rtsp.c b/rtsp.c
index ea4b0144fb319f45ff647ad68bfdf1ac8edf4bfb..873d0a170fd7b453ab3c1e51c674219f655f2635 100644 (file)
--- 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 ec4d5525a5f449c1f2660539feba66fa8e411ef6..eae28dfe87f6d3c8c92973a3bf3f670f5a8c82e2 100644 (file)
--- 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);