]> code.delx.au - pulseaudio/commitdiff
raop: Use the port supplied by avahi when connecting to RAOP devices.
authorColin Guthrie <colin@mageia.org>
Mon, 5 Sep 2011 21:19:41 +0000 (22:19 +0100)
committerColin Guthrie <colin@mageia.org>
Mon, 5 Sep 2011 21:23:17 +0000 (22:23 +0100)
The Apple TV for example uses a non-default port, but we previously ignored
this. We now correctly parse the server string but in so doing, we end up
parsing the address twice. As we need a pure IP/hostname of the device itself
to use in our requests, this is somewhat unavoidable.

Sadly there are still other problems with Apple TVs, but this is still
one step closer.

Fixes part of #950

src/modules/raop/module-raop-discover.c
src/modules/raop/raop_client.c
src/modules/rtp/rtsp_client.c

index de1a2b1c514ce2d7a7add7dfac80a0a31cdad0f0..1a7572c181f4e7086c93889434e0da87a78c85f1 100644 (file)
@@ -186,24 +186,18 @@ static void resolver_cb(
         }
         pa_xfree(dname);
 
-        /*
-         TODO: allow this syntax of server name in things....
-        args = pa_sprintf_malloc("server=[%s]:%u "
-                                 "sink_name=%s",
-                                 avahi_address_snprint(at, sizeof(at), a), port,
-                                 vname);*/
         if (nicename) {
-            args = pa_sprintf_malloc("server=%s "
+            args = pa_sprintf_malloc("server=[%s]:%u "
                                      "sink_name=%s "
                                      "sink_properties=device.description=\"%s\"",
-                                     avahi_address_snprint(at, sizeof(at), a),
+                                     avahi_address_snprint(at, sizeof(at), a), port,
                                      vname,
                                      nicename);
 
         } else {
-            args = pa_sprintf_malloc("server=%s "
+            args = pa_sprintf_malloc("server=[%s]:%u "
                                      "sink_name=%s",
-                                     avahi_address_snprint(at, sizeof(at), a),
+                                     avahi_address_snprint(at, sizeof(at), a), port,
                                      vname);
         }
 
index 96912b23fda3065fa58a685c5086ae71d049b8b2..bbbce5beeab3ab9e2299eabb28e5853ba2525698 100644 (file)
@@ -47,6 +47,7 @@
 #include <pulsecore/iochannel.h>
 #include <pulsecore/socket-util.h>
 #include <pulsecore/log.h>
+#include <pulsecore/parseaddr.h>
 #include <pulsecore/macro.h>
 #include <pulsecore/memchunk.h>
 #include <pulsecore/random.h>
 #define VOLUME_MIN -144
 #define VOLUME_MAX 0
 
+#define RAOP_PORT 5000
+
 
 struct pa_raop_client {
     pa_core *core;
     char *host;
+    uint16_t port;
     char *sid;
     pa_rtsp_client *rtsp;
 
@@ -363,14 +367,23 @@ static void rtsp_cb(pa_rtsp_client *rtsp, pa_rtsp_state state, pa_headerlist* he
 }
 
 pa_raop_client* pa_raop_client_new(pa_core *core, const char* host) {
+    pa_parsed_address a;
     pa_raop_client* c = pa_xnew0(pa_raop_client, 1);
 
     pa_assert(core);
     pa_assert(host);
 
+    if (pa_parse_address(host, &a) < 0 || a.type == PA_PARSED_ADDRESS_UNIX)
+        return NULL;
+
     c->core = core;
     c->fd = -1;
-    c->host = pa_xstrdup(host);
+
+    c->host = pa_xstrdup(a.path_or_host);
+    if (a.port)
+        c->port = a.port;
+    else
+        c->port = RAOP_PORT;
 
     if (pa_raop_connect(c)) {
         pa_raop_client_free(c);
@@ -407,7 +420,7 @@ int pa_raop_connect(pa_raop_client* c) {
         return 0;
     }
 
-    c->rtsp = pa_rtsp_client_new(c->core->mainloop, c->host, 5000, "iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)");
+    c->rtsp = pa_rtsp_client_new(c->core->mainloop, c->host, c->port, "iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)");
 
     /* Initialise the AES encryption system */
     pa_random(c->aes_iv, sizeof(c->aes_iv));
index ecf85b89ee504a667240742c28cad5a2661ab6c9..71692c2c3ae817f9bca71282dcf84ee4bf503bb2 100644 (file)
@@ -324,6 +324,7 @@ int pa_rtsp_connect(pa_rtsp_client *c) {
     pa_xfree(c->session);
     c->session = NULL;
 
+    pa_log_debug("Attempting to connect to server '%s:%d'", c->hostname, c->port);
     if (!(c->sc = pa_socket_client_new_string(c->mainloop, TRUE, c->hostname, c->port))) {
         pa_log("failed to connect to server '%s:%d'", c->hostname, c->port);
         return -1;