]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Generalise volumeup to any command.
authorMike Brady <mikebrady@eircom.net>
Sun, 15 Oct 2017 12:08:21 +0000 (13:08 +0100)
committerMike Brady <mikebrady@eircom.net>
Sun, 15 Oct 2017 12:08:21 +0000 (13:08 +0100)
dbus/src/dbus_service.c
dbus/src/org.gnome.ShairportSync.xml
dbus/src/shairport-sync-dbus-client.c
rtp.c
rtp.h

index 63ee95dfbffb10643995fd90849fceb5fb1a175f..28103243a01ece0d669b1aafd7c51f7a757f2815 100644 (file)
@@ -47,13 +47,13 @@ gboolean notify_volume_callback(ShairportSync *skeleton, gpointer user_data) {
   return TRUE;
 }
 
-static gboolean on_handle_vol_up(ShairportSync *skeleton, GDBusMethodInvocation *invocation, gpointer user_data) {
-  debug(1,"VolUp");
+static gboolean on_handle_remote_command(ShairportSync *skeleton, GDBusMethodInvocation *invocation, const gchar *command, gpointer user_data) {
+  debug(1,"RemoteCommand with command \"%s\".",command);
     if (playing_conn)
-      rtp_send_client_command(playing_conn,"volumeup");
+      rtp_send_client_command(playing_conn,command);
     else
-      debug(1, "no thread playing -- VolUp ignored.");
-  shairport_sync_complete_vol_up(skeleton,invocation);
+      debug(1, "no thread playing -- RemoteCommand ignored.");
+  shairport_sync_complete_remote_command(skeleton,invocation);
   return TRUE;
 }
 
@@ -81,7 +81,7 @@ static void on_name_acquired(GDBusConnection *connection, const gchar *name, gpo
   g_signal_connect(skeleton, "notify::loudness-threshold",
                    G_CALLBACK(notify_loudness_threshold_callback), NULL);
   g_signal_connect(skeleton, "notify::volume", G_CALLBACK(notify_volume_callback), NULL);
-  g_signal_connect(skeleton, "handle-vol-up", G_CALLBACK(on_handle_vol_up), NULL);
+  g_signal_connect(skeleton, "handle-remote-command", G_CALLBACK(on_handle_remote_command), NULL);
 }
 
 int start_dbus_service() {
index b9f152b0d8ca9b0fc4fdf1c9bdbfcd347fcf8a65..8bba3609da5473108f5b5bbecd9db0913063fb29 100644 (file)
@@ -4,7 +4,8 @@
     <property name="LoudnessFilterActive" type="b" access="readwrite" />
     <property name="LoudnessThreshold" type="d" access="readwrite" />
     <property name="Volume" type="d" access="readwrite" />
-    <method name="VolUp">
+    <method name="RemoteCommand">
+      <arg name="command" type="s" direction="in" />
     </method>
   </interface>
 </node>
index c118374c2da6e574f3533315d24cb199badac925..6b576884e87aaaf1b6a55512169765f0ca711a87 100644 (file)
@@ -109,7 +109,7 @@ void main(void) {
   shairport_sync_set_loudness_filter_active(SHAIRPORT_SYNC(proxy), FALSE);
   sleep(1);
   */
-  shairport_sync_call_vol_up(SHAIRPORT_SYNC(proxy), NULL,NULL,NULL);
+  shairport_sync_call_remote_command(SHAIRPORT_SYNC(proxy), "string",NULL,NULL,NULL);
   g_print("Finished test...\n");
   g_main_loop_quit(loop);
   pthread_join(dbus_thread, NULL);
diff --git a/rtp.c b/rtp.c
index 7c5cb5a2bbdc2dfb8b9f8dee39174c467727cac9..5b373dbf4d8c791b4dfafcfd6d260e71ffeb6c4b 100644 (file)
--- a/rtp.c
+++ b/rtp.c
@@ -759,7 +759,7 @@ void rtp_request_resend(seq_t first, uint32_t count, rtsp_conn_info *conn) {
   }
 }
 
-void rtp_send_client_command(rtsp_conn_info *conn, char *command) {
+void rtp_send_client_command(rtsp_conn_info *conn, const char *command) {
   if (conn->rtp_running) {
     if (conn->dacp_port == 0) {
       debug(1, "Can't request a client pause: no valid active remote.");
@@ -768,7 +768,7 @@ void rtp_send_client_command(rtsp_conn_info *conn, char *command) {
       struct addrinfo hints, *res;
       int sockfd;
 
-      char message[1000], server_reply[2000], portstring[10], server[256];
+      char message[20000], server_reply[2000], portstring[10], server[256];
       memset(&message, 0, sizeof(message));
       memset(&server_reply, 0, sizeof(server_reply));
       memset(&portstring, 0, sizeof(portstring));
@@ -814,13 +814,23 @@ void rtp_send_client_command(rtsp_conn_info *conn, char *command) {
           }
 
           // Receive a reply from the server
-          if (recv(sockfd, server_reply, 2000, 0) < 0) {
+          ssize_t reply_size = recv(sockfd, server_reply, 2000, 0);
+          if (reply_size < 0) {
             debug(1, "recv failed");
           }
 
-          if (strstr(server_reply, "HTTP/1.1 204 No Content") != server_reply)
-            debug(1, "Client request to server failed: \"%s\".", server_reply);
-
+          if (strstr(server_reply, "HTTP/1.1 204 No Content") != server_reply) {
+            debug(1, "Client request to server failed with %d characters starting with this response:", reply_size,server_reply);
+           int i;
+           
+           for (i=0;i<reply_size;i++)
+            if (server_reply[i] < ' ')
+              debug(1,"%d  %02x", i, server_reply[i]);
+            else
+              debug(1,"%d  %02x  '%c'", i, server_reply[i],server_reply[i]);
+            //sprintf((char *)message + 2 * i, "%02x", server_reply[i]);
+            //debug(1,"Content is \"%s\".",message);
+          }
           close(sockfd);
         }
       }
diff --git a/rtp.h b/rtp.h
index a44a21df907fe428d646cb94d27d2037009a723b..4555e7ff352b5990fc515fe1e9a2bc2b6c09b2f7 100644 (file)
--- a/rtp.h
+++ b/rtp.h
@@ -25,6 +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);
+void rtp_send_client_command(rtsp_conn_info *conn,const char * command);
 
 #endif // _RTP_H