}
}
-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.");
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;
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.");
}
}