From: Mike Brady Date: Mon, 9 Oct 2017 21:14:34 +0000 (+0100) Subject: Hook up "volumeup" remote control command -- doesn't work on ipv6, it seems X-Git-Tag: 3.2d10~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce06d4503331bf68e8deff66c6189aca3a19aa8f;p=thirdparty%2Fshairport-sync.git Hook up "volumeup" remote control command -- doesn't work on ipv6, it seems --- diff --git a/dbus/src/dbus_service.c b/dbus/src/dbus_service.c index 1c87c03e..63ee95df 100644 --- a/dbus/src/dbus_service.c +++ b/dbus/src/dbus_service.c @@ -6,6 +6,8 @@ #include "../../player.h" #include "../../rtsp.h" +#include "../../rtp.h" + #include "dbus_service.h" gboolean notify_loudness_filter_active_callback(ShairportSync *skeleton, gpointer user_data) { @@ -47,6 +49,10 @@ gboolean notify_volume_callback(ShairportSync *skeleton, gpointer user_data) { static gboolean on_handle_vol_up(ShairportSync *skeleton, GDBusMethodInvocation *invocation, gpointer user_data) { debug(1,"VolUp"); + if (playing_conn) + rtp_send_client_command(playing_conn,"volumeup"); + else + debug(1, "no thread playing -- VolUp ignored."); shairport_sync_complete_vol_up(skeleton,invocation); return TRUE; } diff --git a/dbus/src/shairport-sync-dbus-client.c b/dbus/src/shairport-sync-dbus-client.c index 0e73489b..c118374c 100644 --- a/dbus/src/shairport-sync-dbus-client.c +++ b/dbus/src/shairport-sync-dbus-client.c @@ -87,6 +87,7 @@ void main(void) { g_signal_connect(proxy, "notify::volume", G_CALLBACK(notify_volume_callback), NULL); g_print("Starting test...\n"); + /* shairport_sync_set_volume(SHAIRPORT_SYNC(proxy), -20.0); sleep(1); shairport_sync_set_volume(SHAIRPORT_SYNC(proxy), -10.0); @@ -107,6 +108,7 @@ void main(void) { sleep(10); shairport_sync_set_loudness_filter_active(SHAIRPORT_SYNC(proxy), FALSE); sleep(1); + */ shairport_sync_call_vol_up(SHAIRPORT_SYNC(proxy), NULL,NULL,NULL); g_print("Finished test...\n"); g_main_loop_quit(loop); diff --git a/rtp.c b/rtp.c index 34d305a2..bbee1b88 100644 --- a/rtp.c +++ b/rtp.c @@ -758,7 +758,9 @@ void rtp_request_resend(seq_t first, uint32_t count, rtsp_conn_info *conn) { } } -void rtp_request_client_pause(rtsp_conn_info *conn) { + +// this doesn't seem to work for ipv6 +void rtp_send_client_command(rtsp_conn_info *conn,char * command) { if (conn->rtp_running) { if (conn->dacp_port == 0) { debug(1, "Can't request a client pause: no valid active remote."); @@ -768,17 +770,15 @@ void rtp_request_client_pause(rtsp_conn_info *conn) { int sockfd; char message[1000], server_reply[2000], portstring[10]; + memset(&message, 0, sizeof(message)); + memset(&server_reply, 0, sizeof(server_reply)); + memset(&portstring, 0, sizeof(portstring)); sprintf(portstring,"%u",conn->dacp_port); - debug(1, - "Attempting to send:\nGET /ctrl-int/1/pause HTTP/1.1\r\nHost: %s:%u\r\nActive-Remote: %u\r\n\r\n", - conn->client_ip_string, conn->dacp_port, conn->dacp_active_remote); - - // first, load up address structs with getaddrinfo(): - memset(&hints, 0, sizeof hints); + memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; @@ -789,40 +789,41 @@ void rtp_request_client_pause(rtsp_conn_info *conn) { sockfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol); if (sockfd == -1) { - die("Could not create socket"); - } - debug(1,"Socket created"); - - // connect! + debug(1, "Could not create socket"); + } else { + debug(1,"Socket created"); + + // connect! - if (connect(sockfd, res->ai_addr, res->ai_addrlen) < 0) { - die("connect failed. Error"); - } - debug(1,"Connect successful"); + if (connect(sockfd, res->ai_addr, res->ai_addrlen) < 0) { + debug(1,"connect failed. Error"); + } else { + debug(1,"Connect successful"); - sprintf(message, - "GET /ctrl-int/1/pause HTTP/1.1\r\nHost: %s:%u\r\nActive-Remote: %u\r\n\r\n", - conn->client_ip_string, conn->dacp_port, conn->dacp_active_remote); - debug(1,"Sending this message: \"%s\".",message); + sprintf(message, + "GET /ctrl-int/1/%s HTTP/1.1\r\nHost: %s:%u\r\nActive-Remote: %u\r\n\r\n", + command,conn->client_ip_string, conn->dacp_port, conn->dacp_active_remote); - // Send some data - if (send(sockfd, message, strlen(message), 0) < 0) { - debug(1, "Send failed"); - } + // Send some data + if (send(sockfd, message, strlen(message), 0) < 0) { + debug(1, "Send failed"); + } - // Receive a reply from the server - if (recv(sockfd, server_reply, 2000, 0) < 0) { - debug(1, "recv failed"); - } + // Receive a reply from the server + if (recv(sockfd, server_reply, 2000, 0) < 0) { + debug(1, "recv failed"); + } - // debug(1,"Server replied: \"%s\".",server_reply); + // debug(1,"Server replied: \"%s\".",server_reply); - if (strstr(server_reply, "HTTP/1.1 204 No Content") != server_reply) - debug(1, "Client pause request failed."); - // debug(1,"Client pause request failed: \"%s\".",server_reply); - close(sockfd); - } + if (strstr(server_reply, "HTTP/1.1 204 No Content") != server_reply) + debug(1, "Client pause request failed."); + // debug(1,"Client pause request failed: \"%s\".",server_reply); + close(sockfd); + } + } + } } else { - debug(1, "Request to pause non-existent play stream -- ignored."); + debug(1, "Request to pause non-existent play stream -- ignored."); } } diff --git a/rtp.h b/rtp.h index 641d9623..a44a21df 100644 --- a/rtp.h +++ b/rtp.h @@ -25,4 +25,6 @@ void clear_reference_timestamp(rtsp_conn_info *conn); uint64_t static local_to_remote_time_jitters; uint64_t static local_to_remote_time_jitters_count; +void rtp_send_client_command(rtsp_conn_info *conn,char * command); + #endif // _RTP_H