From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Mon, 7 Nov 2022 11:33:05 +0000 (+0000) Subject: Add two new metadata items -- the player's service name, e.g. "Den Speakers" and... X-Git-Tag: 4.1.1~2^2~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e4b67e97de4abc9776ec91f184aef631d5a447d;p=thirdparty%2Fshairport-sync.git Add two new metadata items -- the player's service name, e.g. "Den Speakers" and the name of the current client, if any, e.g. "Joe's iPhone". --- diff --git a/dbus-service.c b/dbus-service.c index c6cc2ac7..b8cfea16 100644 --- a/dbus-service.c +++ b/dbus-service.c @@ -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 diff --git a/metadata_hub.c b/metadata_hub.c index b66035a0..9ad7052d 100644 --- a/metadata_hub.c +++ b/metadata_hub.c @@ -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, diff --git a/metadata_hub.h b/metadata_hub.h index bdbbf321..bb57a8d5 100644 --- a/metadata_hub.h +++ b/metadata_hub.h @@ -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 a007cbc6..b12eb97d 100644 --- 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; } } } diff --git a/org.gnome.ShairportSync.xml b/org.gnome.ShairportSync.xml index 1051bab6..c9f5868f 100644 --- a/org.gnome.ShairportSync.xml +++ b/org.gnome.ShairportSync.xml @@ -24,6 +24,7 @@ + @@ -49,6 +50,7 @@ + diff --git a/rtsp.c b/rtsp.c index b162fbac..0a940b05 100644 --- 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. diff --git a/shairport.c b/shairport.c index f8f85ad9..86c01e83 100644 --- a/shairport.c +++ b/shairport.c @@ -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);