diff options
author | Thibaut Mattern <tmattern@users.sourceforge.net> | 2004-03-01 22:22:54 +0000 |
---|---|---|
committer | Thibaut Mattern <tmattern@users.sourceforge.net> | 2004-03-01 22:22:54 +0000 |
commit | 32702cb5ac3aaaf4e0282d8e3d943f858253c5d5 (patch) | |
tree | 39d1c9e08fcaffaae82d0d70994401f8b62ef4ab /src | |
parent | 58aa42c5728cae407c2a5f97ad3bece396676f32 (diff) | |
download | xine-lib-32702cb5ac3aaaf4e0282d8e3d943f858253c5d5.tar.gz xine-lib-32702cb5ac3aaaf4e0282d8e3d943f858253c5d5.tar.bz2 |
Multiple multicast client on the same host support.
Patch from Steve <sgbirch at imsmail dot org>
Warning: The code looks ok but I can't test it.
CVS patchset: 6201
CVS date: 2004/03/01 22:22:54
Diffstat (limited to 'src')
-rw-r--r-- | src/input/input_rtp.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/input/input_rtp.c b/src/input/input_rtp.c index 411815b26..7a32662d5 100644 --- a/src/input/input_rtp.c +++ b/src/input/input_rtp.c @@ -167,15 +167,23 @@ static int host_connect_attempt(struct in_addr ia, int port, xine_t *xine) { int s=socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); struct sockaddr_in sin; int optval; - + int multicast = 0; /* boolean, assume unicast */ + if(s == -1) { LOG_MSG(xine, _("socket(): %s.\n"), strerror(errno)); return -1; } - + sin.sin_family = AF_INET; sin.sin_addr = ia; sin.sin_port = htons(port); + + /* Is it a multicast address? */ + if ((ntohl(sin.sin_addr.s_addr) >> 28) == 0xe) { + LOG_MSG(xine, _("IP address specified is multicast\n")); + multicast = 1; /* boolean true */ + } + /* Try to increase receive buffer to 1MB to avoid dropping packets */ optval = 1024 * 1024; @@ -184,7 +192,16 @@ static int host_connect_attempt(struct in_addr ia, int port, xine_t *xine) { LOG_MSG(xine, _("setsockopt(SO_RCVBUF): %s.\n"), strerror(errno)); return -1; } - + + /* If multicast we allow multiple readers to open the same address */ + if (multicast) { + if ((setsockopt(s, SOL_SOCKET, SO_REUSEADDR, + &sin, sizeof(sin))) < 0) { + LOG_MSG(xine, _("setsockopt(SO_REUSEADDR): %s.\n"), strerror(errno)); + return -1; + } + } + /* datagram socket */ if (bind(s, (struct sockaddr *)&sin, sizeof(sin))) { LOG_MSG(xine, _("bind(): %s.\n"), strerror(errno)); @@ -192,10 +209,11 @@ static int host_connect_attempt(struct in_addr ia, int port, xine_t *xine) { } /* multicast ? */ - if ((ntohl(sin.sin_addr.s_addr) >> 28) == 0xe) { + if (multicast) { + #ifdef HAVE_IP_MREQN struct ip_mreqn mreqn; - + mreqn.imr_multiaddr.s_addr = sin.sin_addr.s_addr; mreqn.imr_address.s_addr = INADDR_ANY; mreqn.imr_ifindex = 0; |