summaryrefslogtreecommitdiff
path: root/src/modules/raop
diff options
context:
space:
mode:
authorHajime Fujita <crisp.fujita@nifty.com>2016-11-06 12:54:18 -0600
committerTanu Kaskinen <tanuk@iki.fi>2017-01-19 03:10:19 +0200
commit3de65e61e4ed682da0c8dccb7dd9eda4fef2b94f (patch)
tree518592d776afb66bdc8bdcd3444d70b4111c6d7d /src/modules/raop
parent3e53f47c8de04f598ab95cc16a467c1778684fc9 (diff)
downloadpulseaudio-3de65e61e4ed682da0c8dccb7dd9eda4fef2b94f.tar.gz
raop: Add IPv6 support
Diffstat (limited to 'src/modules/raop')
-rw-r--r--src/modules/raop/raop-client.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c
index cf415d00b..574f10b09 100644
--- a/src/modules/raop/raop-client.c
+++ b/src/modules/raop/raop-client.c
@@ -752,6 +752,7 @@ static int open_bind_udp_socket(pa_raop_client *c, uint16_t *actual_port) {
if (inet_pton(AF_INET, pa_rtsp_localip(c->rtsp), &sa4.sin_addr) > 0) {
sa4.sin_family = af = AF_INET;
sa4.sin_port = htons(port);
+ sa4.sin_addr.s_addr = INADDR_ANY;
sa = (struct sockaddr *) &sa4;
salen = sizeof(sa4);
sa_port = &sa4.sin_port;
@@ -759,6 +760,7 @@ static int open_bind_udp_socket(pa_raop_client *c, uint16_t *actual_port) {
} else if (inet_pton(AF_INET6, pa_rtsp_localip(c->rtsp), &sa6.sin6_addr) > 0) {
sa6.sin6_family = af = AF_INET6;
sa6.sin6_port = htons(port);
+ sa6.sin6_addr = in6addr_any;
sa = (struct sockaddr *) &sa6;
salen = sizeof(sa6);
sa_port = &sa6.sin6_port;
@@ -849,11 +851,18 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, pa_rtsp_state_t state, pa_rtsp_
int frames = 0;
const char *ip;
char *url;
+ int ipv;
pa_log_debug("RAOP: CONNECTED");
ip = pa_rtsp_localip(c->rtsp);
- url = pa_sprintf_malloc("rtsp://%s/%s", ip, c->sid);
+ if (pa_is_ip6_address(ip)) {
+ ipv = 6;
+ url = pa_sprintf_malloc("rtsp://[%s]/%s", ip, c->sid);
+ } else {
+ ipv = 4;
+ url = pa_sprintf_malloc("rtsp://%s/%s", ip, c->sid);
+ }
pa_rtsp_set_url(c->rtsp, url);
if (c->protocol == PA_RAOP_PROTOCOL_TCP)
@@ -865,14 +874,14 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, pa_rtsp_state_t state, pa_rtsp_
case PA_RAOP_ENCRYPTION_NONE: {
sdp = pa_sprintf_malloc(
"v=0\r\n"
- "o=iTunes %s 0 IN IP4 %s\r\n"
+ "o=iTunes %s 0 IN IP%d %s\r\n"
"s=iTunes\r\n"
- "c=IN IP4 %s\r\n"
+ "c=IN IP%d %s\r\n"
"t=0 0\r\n"
"m=audio 0 RTP/AVP 96\r\n"
"a=rtpmap:96 AppleLossless\r\n"
"a=fmtp:96 %d 0 16 40 10 14 2 255 0 0 44100\r\n",
- c->sid, ip, c->host, frames);
+ c->sid, ipv, ip, ipv, c->host, frames);
break;
}
@@ -886,16 +895,16 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, pa_rtsp_state_t state, pa_rtsp_
sdp = pa_sprintf_malloc(
"v=0\r\n"
- "o=iTunes %s 0 IN IP4 %s\r\n"
+ "o=iTunes %s 0 IN IP%d %s\r\n"
"s=iTunes\r\n"
- "c=IN IP4 %s\r\n"
+ "c=IN IP%d %s\r\n"
"t=0 0\r\n"
"m=audio 0 RTP/AVP 96\r\n"
"a=rtpmap:96 AppleLossless\r\n"
"a=fmtp:96 %d 0 16 40 10 14 2 255 0 0 44100\r\n"
"a=rsaaeskey:%s\r\n"
"a=aesiv:%s\r\n",
- c->sid, ip, c->host, frames, key, iv);
+ c->sid, ipv, ip, ipv, c->host, frames, key, iv);
pa_xfree(key);
pa_xfree(iv);