]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Hook up "volumeup" remote control command -- doesn't work on ipv6, it seems
authorMike Brady <mikebrady@eircom.net>
Mon, 9 Oct 2017 21:14:34 +0000 (22:14 +0100)
committerMike Brady <mikebrady@eircom.net>
Mon, 9 Oct 2017 21:14:34 +0000 (22:14 +0100)
dbus/src/dbus_service.c
dbus/src/shairport-sync-dbus-client.c
rtp.c
rtp.h

index 1c87c03e749f459a277155c2d0c93a08e758def7..63ee95dfbffb10643995fd90849fceb5fb1a175f 100644 (file)
@@ -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;
 }
index 0e73489bc996b81f07d149593c0e5a26373242a1..c118374c2da6e574f3533315d24cb199badac925 100644 (file)
@@ -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 34d305a2bb9db6729f6ba1870e12ab8576826174..bbee1b8829b3bd4e3fcdb146e2fea25d32e7c239 100644 (file)
--- 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 641d9623f33f14e3a932ad79f470ed399576610d..a44a21df907fe428d646cb94d27d2037009a723b 100644 (file)
--- 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