#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 {
* - @ref SM_RESUME
* - @ref SM_CANCEL
* - @ref SM_RELOAD
+ * - @ref SM_RTP_REQUEST
+ * - @ref SM_RTP_CANCEL
*
* Messages from the speaker:
* - @ref SM_PAUSED
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;
};
/** @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
*
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
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);
}