chiark / gitweb /
speaker: new comments to add/remove RTP recipients
authorRichard Kettlewell <rjk@greenend.org.uk>
Sun, 10 Nov 2013 13:58:33 +0000 (13:58 +0000)
committerRichard Kettlewell <rjk@terraraq.org.uk>
Sun, 10 Nov 2013 14:04:18 +0000 (14:04 +0000)
lib/speaker-protocol.h
server/play.c
server/speaker.c

index 200e4b53029db74f1f28fe8cb661ed21f39e5695..cd6a192bed9098165176be6d17e28811fe94d218 100644 (file)
@@ -26,6 +26,7 @@
 #define SPEAKER_PROTOCOL_H
 
 #include "byte-order.h"
 #define SPEAKER_PROTOCOL_H
 
 #include "byte-order.h"
+#include <netinet/in.h>
 
 /** @brief A message from the main server to the speaker, or vica versa */
 struct speaker_message {
 
 /** @brief A message from the main server to the speaker, or vica versa */
 struct speaker_message {
@@ -37,6 +38,8 @@ struct speaker_message {
    * - @ref SM_RESUME
    * - @ref SM_CANCEL
    * - @ref SM_RELOAD
    * - @ref SM_RESUME
    * - @ref SM_CANCEL
    * - @ref SM_RELOAD
+   * - @ref SM_RTP_REQUEST
+   * - @ref SM_RTP_CANCEL
    *
    * Messages from the speaker:
    * - @ref SM_PAUSED
    *
    * Messages from the speaker:
    * - @ref SM_PAUSED
@@ -53,6 +56,9 @@ struct speaker_message {
   union {
     /** @brief Track ID (including 0 terminator) */
     char id[24];                          /* ID including terminator */
   union {
     /** @brief Track ID (including 0 terminator) */
     char id[24];                          /* ID including terminator */
+
+    /** @brief An IP address (for @ref SM_RTP_REQUEST and @ref SM_RTP_CANCEL) */
+    struct sockaddr_storage address;
   } u;
 };
 
   } u;
 };
 
@@ -76,6 +82,12 @@ struct speaker_message {
 /** @brief Reload configuration */
 #define SM_RELOAD 5
 
 /** @brief Reload configuration */
 #define SM_RELOAD 5
 
+/** @brief Reload configuration */
+#define SM_RTP_REQUEST 6
+
+/** @brief Reload configuration */
+#define SM_RTP_CANCEL 7
+
 /* messages from the speaker */
 /** @brief Paused track @c id, @c data seconds in
  *
 /* messages from the speaker */
 /** @brief Paused track @c id, @c data seconds in
  *
index e15cda1012b43d4cfd0846438a2fdfe28de3dedf..a5d318c425781feb7a274d8629bd34e17eb14193 100644 (file)
@@ -823,6 +823,24 @@ void resume_playing(const char *who) {
   eventlog("state", "resume", (char *)0);
 }
 
   eventlog("state", "resume", (char *)0);
 }
 
+/** @brief Request an RTP stream */
+void rtp_request(const struct sockaddr_storage *sa) {
+  struct speaker_message sm;
+  memset(&sm, 0, sizeof sm);
+  sm.type = SM_RTP_REQUEST;
+  sm.u.address = *sa;
+  speaker_send(speaker_fd, &sm);
+}
+
+/** @brief Cancel an RTP stream */
+void rtp_request_cancel(const struct sockaddr_storage *sa) {
+  struct speaker_message sm;
+  memset(&sm, 0, sizeof sm);
+  sm.type = SM_RTP_CANCEL;
+  sm.u.address = *sa;
+  speaker_send(speaker_fd, &sm);
+}
+
 /*
 Local Variables:
 c-basic-offset:2
 /*
 Local Variables:
 c-basic-offset:2
index e4707596b2921996c6390ee53dda2a98132af66c..a55b074905828adf4cce6e0228743d809d9c283e 100644 (file)
@@ -660,6 +660,15 @@ static void mainloop(void) {
             disorder_error(0, "cannot read configuration");
           disorder_info("reloaded configuration");
          break;
             disorder_error(0, "cannot read configuration");
           disorder_info("reloaded configuration");
          break;
+        case SM_RTP_REQUEST:
+          /* TODO the error behavior here is really unhelpful */
+          if(rtp_add_recipient(&sm.u.address))
+            disorder_error(0, "unacceptable RTP destination");
+          break;
+        case SM_RTP_CANCEL:
+          if(rtp_remove_recipient(&sm.u.address))
+            disorder_error(0, "unacceptable RTP destination for removal");
+          break;
        default:
          disorder_error(0, "unknown message type %d", sm.type);
         }
        default:
          disorder_error(0, "unknown message type %d", sm.type);
         }