]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Add two new metadata items -- the player's service name, e.g. "Den Speakers" and...
authorMike Brady <4265913+mikebrady@users.noreply.github.com>
Mon, 7 Nov 2022 11:33:05 +0000 (11:33 +0000)
committerMike Brady <4265913+mikebrady@users.noreply.github.com>
Mon, 7 Nov 2022 11:33:05 +0000 (11:33 +0000)
dbus-service.c
metadata_hub.c
metadata_hub.h
mqtt.c
org.gnome.ShairportSync.xml
rtsp.c
shairport.c

index c6cc2ac72422d40437ca7f55982bd5f22f3f2371..b8cfea16ba802de77900387c8610c0ec373cb601 100644 (file)
@@ -68,6 +68,7 @@ void dbus_metadata_watcher(struct metadata_bundle *argc, __attribute__((unused))
                                                    argc->airplay_volume);
 
   shairport_sync_remote_control_set_client(shairportSyncRemoteControlSkeleton, argc->client_ip);
+  shairport_sync_remote_control_set_client_name(shairportSyncRemoteControlSkeleton, argc->client_name);
 
   // although it's a DACP server, the server is in fact, part of the the AirPlay "client" (their
   // term).
@@ -1019,6 +1020,8 @@ static void on_dbus_name_acquired(GDBusConnection *connection, const gchar *name
 //    NULL);
 #endif
 
+  shairport_sync_set_service_name(SHAIRPORT_SYNC(shairportSyncSkeleton), config.service_name);
+
 #ifdef CONFIG_AIRPLAY_2
   shairport_sync_set_protocol(SHAIRPORT_SYNC(shairportSyncSkeleton), "AirPlay 2");
 #else
index b66035a0eb77bf5b2b0b3a187ee5098e92dbf5ea..9ad7052de283893a2c0db4a5125435e2cdf94ff8 100644 (file)
@@ -102,6 +102,7 @@ void run_metadata_watchers(void) {
   // turn off changed flags
   metadata_store.cover_art_pathname_changed = 0;
   metadata_store.client_ip_changed = 0;
+  metadata_store.client_name_changed = 0;
   metadata_store.server_ip_changed = 0;
   metadata_store.progress_string_changed = 0;
   metadata_store.item_id_changed = 0;
@@ -549,6 +550,14 @@ void metadata_hub_process_metadata(uint32_t type, uint32_t code, char *data, uin
       }
       free(cs);
       break;
+    case 'snam':
+      cs = strndup(data, length);
+      if (string_update(&metadata_store.client_name, &metadata_store.client_name_changed, cs)) {
+        changed = 1;
+        debug(1, "MH Client Name set to: \"%s\"", metadata_store.client_name);
+      }
+      free(cs);
+      break;
     case 'prgr':
       cs = strndup(data, length);
       if (string_update(&metadata_store.progress_string, &metadata_store.progress_string_changed,
index bdbbf321e9f584c389952bf1e0a98210424d8391..bb57a8d54120e8a985235927a567ef39fd4604c5 100644 (file)
@@ -43,6 +43,9 @@ typedef struct metadata_bundle {
                    // server
   int client_ip_changed;
 
+  char *client_name; // the name of the client device, if available
+  int client_name_changed;
+
   char *server_ip; // IP number used by Shairport Sync
   int server_ip_changed;
 
diff --git a/mqtt.c b/mqtt.c
index a007cbc6353dcd7b3722b1f26f86352dfa7ccc89..b12eb97d5f3f26b574bd7ad0bcab929f1bccb7cb 100644 (file)
--- a/mqtt.c
+++ b/mqtt.c
@@ -219,6 +219,9 @@ void mqtt_process_metadata(uint32_t type, uint32_t code, char *data, uint32_t le
       case 'svip':
         mqtt_publish("server_ip", data, length);
         break;
+      case 'svna':
+        mqtt_publish("service_name", data, length);
+        break;
       }
     }
   }
index 1051bab618de47974712ce076dc7303795355a2a..c9f5868fa8bb4b64a4dc2361c01910823b65ba31 100644 (file)
@@ -24,6 +24,7 @@
     <property name="Version" type="s" access="read" />
     <property name="VersionString" type="s" access="read" />
     <property name="Protocol" type="s" access="read" />
+    <property name="ServiceName" type="s" access="read" />
   </interface>
   <interface name="org.gnome.ShairportSync.Diagnostics">
     <property name="Verbosity" type="i" access="readwrite" />
@@ -49,6 +50,7 @@
                <property name='PlayerState' type='s' access='read'/>
                <property name='ProgressString' type='s' access='read'/>
                <property name='Client' type='s' access='read'/>
+               <property name='ClientName' type='s' access='read'/>
                <property name='AirplayVolume' type='d' access='read'/>
     <method name="SetAirplayVolume">
       <arg name="volume" type="d" direction="in" />
diff --git a/rtsp.c b/rtsp.c
index b162fbac6d92453e8312494923da1c52d76191dc..0a940b055407c0062adadf5779a41c4d6e9655e6 100644 (file)
--- a/rtsp.c
+++ b/rtsp.c
@@ -2864,6 +2864,7 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp)
           "and open a TCP port.",
           conn->connection_number);
     conn->airplay_stream_category = unspecified_stream_category;
+    
     // figure out what category of stream it is, by looking at the plist
     plist_t timingProtocol = plist_dict_get_item(messagePlist, "timingProtocol");
     if (timingProtocol != NULL) {
@@ -3669,6 +3670,8 @@ void handle_set_parameter_parameter(rtsp_conn_info *conn, rtsp_message *req,
 //    play session is stopped.
 //             `svip` -- the payload is the IP number of the server, i.e. the player itself.
 //             Can be an IPv4 or an IPv6 number.
+//             `svna` -- the payload is the service name of the player, i.e. the name by
+//             which it is seen in the AirPlay menu.
 //    `disc` -- the payload is the IP number of the client, i.e. the sender of audio.
 //             Can be an IPv4 or an IPv6 number. This is an AirPlay-2-only message.
 //    It is sent when a client has been disconnected.
index f8f85ad9ef1910d1d121f98f17097ae7a13821c2..86c01e83d25c79fb112f85153053b60849209b33 100644 (file)
@@ -2537,6 +2537,10 @@ int main(int argc, char **argv) {
   }
 #endif
 
+#ifdef CONFIG_METADATA
+  send_ssnc_metadata('svna', config.service_name, strlen(config.service_name), 1);
+#endif
+
   activity_monitor_start(); // not yet for AP2
   pthread_create(&rtsp_listener_thread, NULL, &rtsp_listen_loop, NULL);
   atexit(exit_rtsp_listener);