]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Add name of client when we can get it in AP2
authorMike Brady <4265913+mikebrady@users.noreply.github.com>
Thu, 29 Sep 2022 15:39:01 +0000 (16:39 +0100)
committerMike Brady <4265913+mikebrady@users.noreply.github.com>
Thu, 29 Sep 2022 15:39:01 +0000 (16:39 +0100)
rtsp.c

diff --git a/rtsp.c b/rtsp.c
index d61ffeb14a515079edfc9aca30ba5c752f130b6d..b03d6f4efa00ade7169793fa7b635800c1e53b73 100644 (file)
--- a/rtsp.c
+++ b/rtsp.c
@@ -1622,7 +1622,7 @@ void handle_record(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp)
     if (conn->player_thread)
       warn("Connection %d: RECORD: Duplicate RECORD message -- ignored", conn->connection_number);
     else {
-      debug(1, "Connection %d: AP1 ALAC Stream, from %s:%u to self at %s:%u.",
+      debug(1, "Connection %d: Classic AirPlay connection from %s:%u to self at %s:%u.",
             conn->connection_number, conn->client_ip_string, conn->client_rtsp_port,
             conn->self_ip_string, conn->self_rtsp_port);
       activity_monitor_signify_activity(1);
@@ -2830,6 +2830,15 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp)
   plist_t messagePlist = plist_from_rtsp_content(req);
   plist_t setupResponsePlist = plist_new_dict();
   resp->respcode = 400;
+  
+  // see if we can get a name for the client
+  char *clientNameString = NULL;
+  plist_t nameItem = plist_dict_get_item(messagePlist, "name");
+  if (nameItem != NULL) {
+    plist_get_string_val(nameItem, &clientNameString);
+  } else {
+    clientNameString = strdup("<unknown>");
+  }
 
   // see if the incoming plist contains a "streams" array
   plist_t streams = plist_dict_get_item(messagePlist, "streams");
@@ -2847,8 +2856,8 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp)
       plist_get_string_val(timingProtocol, &timingProtocolString);
       if (timingProtocolString) {
         if (strcmp(timingProtocolString, "PTP") == 0) {
-          debug(2, "Connection %d: AP2 PTP connection from %s:%u to self at %s:%u.",
-                conn->connection_number, conn->client_ip_string, conn->client_rtsp_port,
+          debug(1, "Connection %d: AP2 PTP connection from %s:%u (\"%s\") to self at %s:%u.",
+                conn->connection_number, conn->client_ip_string, conn->client_rtsp_port, clientNameString, 
                 conn->self_ip_string, conn->self_rtsp_port);
           conn->airplay_stream_category = ptp_stream;
           conn->timing_type = ts_ptp;
@@ -2862,20 +2871,24 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp)
           send_ssnc_metadata('svip', conn->self_ip_string, strlen(conn->self_ip_string), 1);
 #endif
         } else if (strcmp(timingProtocolString, "NTP") == 0) {
-          debug(1, "Connection %d: SETUP: NTP setup detected.", conn->connection_number);
+          debug(1, "Connection %d: SETUP: NTP setup from %s:%u (\"%s\") to self at %s:%u.",
+          conn->connection_number, conn->client_ip_string, conn->client_rtsp_port, clientNameString, 
+                conn->self_ip_string, conn->self_rtsp_port);
           conn->airplay_stream_category = ntp_stream;
           conn->timing_type = ts_ntp;
         } else if (strcmp(timingProtocolString, "None") == 0) {
-          debug(2, "Connection %d: SETUP: a \"None\" setup detected.", conn->connection_number);
+          debug(3, "Connection %d: SETUP: a \"None\" setup detected from %s:%u (\"%s\") to self at %s:%u.",
+          conn->connection_number, conn->client_ip_string, conn->client_rtsp_port, clientNameString,
+                conn->self_ip_string, conn->self_rtsp_port);
           // now check to see if it's got the "isRemoteControlOnly" item and check it's true
           plist_t isRemoteControlOnly = plist_dict_get_item(messagePlist, "isRemoteControlOnly");
           if (isRemoteControlOnly != NULL) {
             uint8_t isRemoteControlOnlyBoolean = 0;
             plist_get_bool_val(isRemoteControlOnly, &isRemoteControlOnlyBoolean);
             if (isRemoteControlOnlyBoolean != 0) {
-              debug(2, "Connection %d: Remote Control connection from %s:%u to self at %s:%u.",
-                    conn->connection_number, conn->client_ip_string, conn->client_rtsp_port,
-                    conn->self_ip_string, conn->self_rtsp_port);
+              debug(1, "Connection %d: Remote Control connection from %s:%u (\"%s\") to self at %s:%u.",
+                conn->connection_number, conn->client_ip_string, conn->client_rtsp_port, clientNameString,
+                conn->self_ip_string, conn->self_rtsp_port);
               conn->airplay_stream_category = remote_control_stream;
             } else {
               debug(1,
@@ -3354,6 +3367,8 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp)
     msg_add_header(resp, "Content-Type", "application/x-apple-binary-plist");
   }
   plist_free(messagePlist);
+  if (clientNameString != NULL)
+    free(clientNameString);
   debug_log_rtsp_message(2, " SETUP response", resp);
 }
 #endif
@@ -4407,7 +4422,9 @@ static void handle_announce(rtsp_conn_info *conn, rtsp_message *req, rtsp_messag
 #ifdef CONFIG_AIRPLAY_2
     conn->airplay_type = ap_1;
     conn->timing_type = ts_ntp;
-    debug(1, "Connection %d. AirPlay 1 Audio Stream Detected.", conn->connection_number);
+    debug(1, "Connection %d: Classic AirPlay connection from %s:%u to self at %s:%u.",
+                conn->connection_number, conn->client_ip_string, conn->client_rtsp_port,
+                conn->self_ip_string, conn->self_rtsp_port);
 #endif
 
     conn->stream.type = ast_unknown;
@@ -5460,7 +5477,7 @@ void *rtsp_listen_loop(__attribute((unused)) void *arg) {
           inet_ntop(conn->connection_ip_family, self_addr, conn->self_ip_string,
                     sizeof(conn->self_ip_string));
 
-          debug(1, "Connection %d: New connection from %s:%u to self at %s:%u.",
+          debug(2, "Connection %d: New connection from %s:%u to self at %s:%u.",
                 conn->connection_number, conn->client_ip_string, conn->client_rtsp_port,
                 conn->self_ip_string, conn->self_rtsp_port);
           conn->connection_start_time = get_absolute_time_in_ns();