On Fri, Jun 1, 2012 at 6:21 PM, Luca Barbato <[email protected]> wrote:

> On 01/06/12 00:54, Martin Storsjö wrote:
> > On Thu, 31 May 2012, Luca Barbato wrote:
> >
> >> @@ -163,6 +166,49 @@ static struct addrinfo* udp_resolve_host(const
> >> char *hostname, int port,
> >>     return res;
> >> }
> >>
> >> +static int udp_set_multicast_sources(int sockfd, struct sockaddr *addr,
> >> +                                     char **sources, int nb_sources,
> >> +                                     int include)
> >> +{
> >> +    int i;
> >> +    if (addr->sa_family != AF_INET) {
> >> +        av_log(NULL, AV_LOG_ERROR,
> >> +               "Setting multicast sources only supported for IPv4 for
> >> now\n");
> >> +        return AVERROR_PATCHWELCOME;
> >> +    }
> >> +#if HAVE_STRUCT_IP_MREQ_SOURCE && defined(IP_BLOCK_SOURCE)
> >> +    for (i = 0; i < nb_sources; i++) {
> >> +        struct ip_mreq_source mreqs;
> >> +        struct addrinfo *sourceaddr = udp_resolve_host(sources[i], 0,
> >> +                                                       SOCK_DGRAM,
> >> AF_UNSPEC,
> >> +                                                       AI_NUMERICHOST);
> >> +        if (!sourceaddr)
> >> +            return -1;
> >> +        if (sourceaddr->ai_addr->sa_family != AF_INET) {
> >> +            freeaddrinfo(sourceaddr);
> >> +            av_log(NULL, AV_LOG_ERROR, "%s is of incorrect protocol
> >> family\n",
> >> +                   sources[i]);
> >> +            return AVERROR(EINVAL);
> >> +        }
> >> +
> >> +        mreqs.imr_multiaddr.s_addr = ((struct sockaddr_in
> >> *)addr)->sin_addr.s_addr;
> >> +        mreqs.imr_interface.s_addr = INADDR_ANY;
> >> +        mreqs.imr_sourceaddr.s_addr = ((struct sockaddr_in
> >> *)sourceaddr->ai_addr)->sin_addr.s_addr;
> >> +        freeaddrinfo(sourceaddr);
> >> +
> >> +        if (setsockopt(sockfd, IPPROTO_IP,
> >> +                       include ? IP_ADD_SOURCE_MEMBERSHIP :
> >> IP_BLOCK_SOURCE,
> >> +                       (const void *)&mreqs, sizeof(mreqs)) < 0) {
> >> +            int err = errno;
> >> +            av_log(NULL, AV_LOG_ERROR, "setsockopt(%s): %s\n",
> >> +                   include ? "IP_ADD_SOURCE_MEMBERSHIP" :
> >> "IP_BLOCK_SOURCE",
> >> +                   strerror(err));
> >> +            return AVERROR(err);
> >> +        }
> >
> > Was this errno fix the only change from my version?
>
> other AVERROR bits up there.
>
> > This doesn't
> > necessarily work on windows, we should use ff_neterrno() instead, but
> > I'm not sure if we have anything hooked up for using that with strerror
> > (otoh, iirc winsock doesn't even have any function for getting a
> > suitable string for a socket error). While this in principle is better
> > than just returning -1, I'm afraid this might just return 0 on windows.
>
> You are right, let's use it ^^;
>
> lu
>
>
I can test on windows if you can provide a build

-- 
Aviad Rozenhek
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to