Hook up "volumeup" remote control command -- doesn't work on ipv6, it seems

This commit is contained in:
Mike Brady
2017-10-09 22:14:34 +01:00
parent c3bfb048ca
commit ce06d45033
4 changed files with 51 additions and 40 deletions
+6
View 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;
}
+2
View 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);
+41 -40
View File
@@ -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, "Could not create socket");
} else {
debug(1,"Socket created");
// connect!
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/%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");
}
// 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);
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);
}
}
debug(1,"Socket created");
// connect!
if (connect(sockfd, res->ai_addr, res->ai_addrlen) < 0) {
die("connect failed. Error");
}
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);
// 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");
}
// 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);
}
}
} else {
debug(1, "Request to pause non-existent play stream -- ignored.");
debug(1, "Request to pause non-existent play stream -- ignored.");
}
}
+2
View File
@@ -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