chiark / gitweb /
rtp-address command allows client to query server config
authorRichard Kettlewell <rjk@greenend.org.uk>
Sun, 7 Oct 2007 14:32:54 +0000 (15:32 +0100)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sun, 7 Oct 2007 14:32:54 +0000 (15:32 +0100)
clients/disorder.c
doc/disorder.1.in
doc/disorder_protocol.5.in
lib/client.c
lib/client.h
server/server.c

index 5ccb625812b4b937ca43e97dca1015bfd5f45ce5..156a02ddd7b62c509684096c5612f4f52fe13303 100644 (file)
@@ -399,6 +399,14 @@ static void cf_new(disorder_client *c,
     xprintf("%s\n", nullcheck(utf82mb(*vec++)));
 }
 
+static void cf_rtp_address(disorder_client *c,
+                          char attribute((unused)) **argv) {
+  char *address, *port;
+
+  if(disorder_rtp_address(c, &address, &port)) exit(EXIT_FAILURE);
+  xprintf("address: %s\nport: %s\n", address, port);
+}
+
 static const struct command {
   const char *name;
   int min, max;
@@ -467,6 +475,8 @@ static const struct command {
                       "Resolve alias for TRACK" },
   { "resume",         0, 0, cf_resume, 0, "",
                       "Resume after a pause" },
+  { "rtp-address",    0, 0, cf_rtp_address, 0, "",
+                      "Report server's broadcast address" },
   { "scratch",        0, 0, cf_scratch, 0, "",
                       "Scratch the currently playing track" },
   { "scratch-id",     1, 1, cf_scratch, 0, "ID",
index 4e6e184f61cd700536d013bbcc8cbd74c61dda9e..a05ca8c1b9b58637689507e75e144aa992f51412 100644 (file)
@@ -152,6 +152,9 @@ Resolve aliases for \fITRACK\fR and print out the real track name.
 .B resume
 Resume the current track after a pause.
 .TP
+.B rtp-address
+Report the RTP brodcast address used by the server (if any).
+.TP
 .B scratch
 Scratch the currently playing track.
 .TP
@@ -168,7 +171,7 @@ for example:
 You can limit the search to tracks with a particular tag, too, using the
 \fBtag:\fR modifier.  For example:
 .IP
-.B "disorder search 'love tag:depressing'
+.B "disorder search 'love tag:depressing'"
 .TP
 .B set \fITRACK\fR \fIKEY\fR \fIVALUE\fR
 Set the preference \fIKEY\fR for \fITRACK\fR to \fIVALUE\fR.
index ef18bb9b7655aba590287eff336f2be3260383da..4fe53ced51f471de30a84510de3aca67478d29da 100644 (file)
@@ -192,6 +192,10 @@ Resolve a track name, i.e. if this is an alias then return the real track name.
 .B resume
 Resume the current track after a \fBpause\fR command.
 .TP
+.B rtp-address
+Reports the RTP broadcast (or multicast) address, in the form \fIADDRESS
+PORT\fR.
+.TP
 .B scratch \fR[\fIID\fR]
 Remove the track identified by \fIID\fR, or the currently playing track if no
 \fIID\fR is specified.  If \fBrestrict scratch\fR is enabled in the server's
@@ -287,10 +291,6 @@ Text part is just commentary; a dot-stuffed body follows.
 Text part is just commentary; an indefinite dot-stuffed body follows.  (Used
 for \fBlog\fR.)
 .TP
-.B 4
-Text part is just commentary; an indefinite dot-stuffed body follows.  (Used
-for \fBlog\fR.)
-.TP
 .B 9
 The text part is just commentary (but would normally be a response for this
 command) e.g. \fBplaying\fR.
index d68d9d76a9ded92d3932cb762c7f4410a5db4d11..27b7beb7692afde6ec4fb89dacd7eac64091e54c 100644 (file)
@@ -629,6 +629,23 @@ int disorder_get_global(disorder_client *c, const char *key, char **valuep) {
   return disorder_simple(c, valuep, "get-global", key, (char *)0);
 }
 
+int disorder_rtp_address(disorder_client *c, char **addressp, char **portp) {
+  char *r;
+  int rc, n;
+  char **vec;
+
+  if((rc = disorder_simple(c, &r, "rtp-address", (char *)0)))
+    return rc;
+  vec = split(r, &n, SPLIT_QUOTES, 0, 0);
+  if(n != 2) {
+    error(0, "malformed rtp-address reply");
+    return -1;
+  }
+  *addressp = vec[0];
+  *portp = vec[1];
+  return 0;
+}
+
 /*
 Local Variables:
 c-basic-offset:2
index 773c555baf8e11620c6f1dd5c797da4bb2f50ed9..39a68304d80498ca4400344c5293974bbb4c6268 100644 (file)
@@ -186,6 +186,8 @@ int disorder_new_tracks(disorder_client *c,
                        int max);
 /* get new tracks */
 
+int disorder_rtp_address(disorder_client *c, char **addressp, char **portp);
+
 #endif /* CLIENT_H */
 
 /*
index c5fb0108f3516bfd5794f09199fa02723701358d..4ba43a63fb09904d81b3ad358112826ded338959 100644 (file)
@@ -930,6 +930,18 @@ static int c_new(struct conn *c,
 
 }
 
+static int c_rtp_address(struct conn *c,
+                        char attribute((unused)) **vec,
+                        int attribute((unused)) nvec) {
+  if(config->speaker_backend == BACKEND_NETWORK) {
+    sink_printf(ev_writer_sink(c->w), "252 %s %s\n",
+               quoteutf8(config->broadcast.s[0]),
+               quoteutf8(config->broadcast.s[1]));
+  } else
+    sink_writes(ev_writer_sink(c->w), "550 No RTP\n");
+  return 1;
+}
 #define C_AUTH         0001            /* must be authenticated */
 #define C_TRUSTED      0002            /* must be trusted user */
 
@@ -970,6 +982,7 @@ static const struct command {
   { "rescan",         0, 0,       c_rescan,         C_AUTH|C_TRUSTED },
   { "resolve",        1, 1,       c_resolve,        C_AUTH },
   { "resume",         0, 0,       c_resume,         C_AUTH },
+  { "rtp-address",    0, 0,       c_rtp_address,    C_AUTH },
   { "scratch",        0, 1,       c_scratch,        C_AUTH },
   { "search",         1, 1,       c_search,         C_AUTH },
   { "set",            3, 3,       c_set,            C_AUTH, },