Commit ab0812c1 authored by Marton Balint's avatar Marton Balint

avformat/udp: always use IP_ADD_SOURCE_MEMBERSHIP for subscribing to an UDP...

avformat/udp: always use IP_ADD_SOURCE_MEMBERSHIP for subscribing to an UDP multicast source group in IPv4

That alone supports specifying the interface based on its address. Getting the
interface index from the local address seems quite a bit of work in a platform
independent way...

Obviously for IPv6 we still always use MCAST_JOIN_SOURCE_GROUP.

As a side effect this also fixes ticket #7459.
Signed-off-by: 's avatarMarton Balint <cus@passwd.hu>
parent d3bda871
...@@ -246,9 +246,12 @@ static int udp_set_multicast_sources(URLContext *h, ...@@ -246,9 +246,12 @@ static int udp_set_multicast_sources(URLContext *h,
struct sockaddr_storage *sources, struct sockaddr_storage *sources,
int nb_sources, int include) int nb_sources, int include)
{ {
#if HAVE_STRUCT_GROUP_SOURCE_REQ && defined(MCAST_BLOCK_SOURCE) && !defined(_WIN32) && (!defined(TARGET_OS_TV) || !TARGET_OS_TV) int i;
/* These ones are available in the microsoft SDK, but don't seem to work if (addr->sa_family != AF_INET) {
* as on linux, so just prefer the v4-only approach there for now. */ #if HAVE_STRUCT_GROUP_SOURCE_REQ && defined(MCAST_BLOCK_SOURCE)
/* For IPv4 prefer the old approach, as that alone works reliably on
* Windows and it also supports supplying the interface based on its
* address. */
int i; int i;
for (i = 0; i < nb_sources; i++) { for (i = 0; i < nb_sources; i++) {
struct group_source_req mreqs; struct group_source_req mreqs;
...@@ -269,13 +272,14 @@ static int udp_set_multicast_sources(URLContext *h, ...@@ -269,13 +272,14 @@ static int udp_set_multicast_sources(URLContext *h,
return ff_neterrno(); return ff_neterrno();
} }
} }
#elif HAVE_STRUCT_IP_MREQ_SOURCE && defined(IP_BLOCK_SOURCE) return 0;
int i; #else
if (addr->sa_family != AF_INET) {
av_log(NULL, AV_LOG_ERROR, av_log(NULL, AV_LOG_ERROR,
"Setting multicast sources only supported for IPv4\n"); "Setting multicast sources only supported for IPv4\n");
return AVERROR(EINVAL); return AVERROR(EINVAL);
#endif
} }
#if HAVE_STRUCT_IP_MREQ_SOURCE && defined(IP_BLOCK_SOURCE)
for (i = 0; i < nb_sources; i++) { for (i = 0; i < nb_sources; i++) {
struct ip_mreq_source mreqs; struct ip_mreq_source mreqs;
if (sources[i].ss_family != AF_INET) { if (sources[i].ss_family != AF_INET) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment