diff options
Diffstat (limited to 'graphics/ffmpeg/patches/patch-libavformat_udp_c')
| -rw-r--r-- | graphics/ffmpeg/patches/patch-libavformat_udp_c | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/graphics/ffmpeg/patches/patch-libavformat_udp_c b/graphics/ffmpeg/patches/patch-libavformat_udp_c deleted file mode 100644 index ff1e234..0000000 --- a/graphics/ffmpeg/patches/patch-libavformat_udp_c +++ /dev/null | |||
| @@ -1,82 +0,0 @@ | |||
| 1 | - avformat/udp: set ttl upper bound to 255 | ||
| 2 | - avformat/udp: properly check for valid ttl in url | ||
| 3 | - avformat/udp: use one setsockopt for ipv4/ipv6 | ||
| 4 | - avformat/udp: Fix IP_MULTICAST_TTL for BSD compatibility | ||
| 5 | - avformat/udp: remove IPPROTO_IPV6 macro | ||
| 6 | |||
| 7 | Index: libavformat/udp.c | ||
| 8 | --- libavformat/udp.c.orig | ||
| 9 | +++ libavformat/udp.c | ||
| 10 | @@ -134,7 +134,7 @@ static const AVOption options[] = { | ||
| 11 | { "reuse", "explicitly allow reusing UDP sockets", OFFSET(reuse_socket), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, D|E }, | ||
| 12 | { "reuse_socket", "explicitly allow reusing UDP sockets", OFFSET(reuse_socket), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, .flags = D|E }, | ||
| 13 | { "broadcast", "explicitly allow or disallow broadcast destination", OFFSET(is_broadcast), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E }, | ||
| 14 | - { "ttl", "Time to live (multicast only)", OFFSET(ttl), AV_OPT_TYPE_INT, { .i64 = 16 }, 0, INT_MAX, E }, | ||
| 15 | + { "ttl", "Time to live (multicast only)", OFFSET(ttl), AV_OPT_TYPE_INT, { .i64 = 16 }, 0, 255, E }, | ||
| 16 | { "connect", "set if connect() should be called on socket", OFFSET(is_connected), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, .flags = D|E }, | ||
| 17 | { "fifo_size", "set the UDP receiving circular buffer size, expressed as a number of packets with size of 188 bytes", OFFSET(circular_buffer_size), AV_OPT_TYPE_INT, {.i64 = 7*4096}, 0, INT_MAX, D }, | ||
| 18 | { "overrun_nonfatal", "survive in case of UDP receiving circular buffer overrun", OFFSET(overrun_nonfatal), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, D }, | ||
| 19 | @@ -161,22 +161,40 @@ static const AVClass udplite_context_class = { | ||
| 20 | static int udp_set_multicast_ttl(int sockfd, int mcastTTL, | ||
| 21 | struct sockaddr *addr) | ||
| 22 | { | ||
| 23 | + int protocol, cmd; | ||
| 24 | + | ||
| 25 | + /* There is some confusion in the world whether IP_MULTICAST_TTL | ||
| 26 | + * takes a byte or an int as an argument. | ||
| 27 | + * BSD seems to indicate byte so we are going with that and use | ||
| 28 | + * int and fall back to byte to be safe */ | ||
| 29 | + switch (addr->sa_family) { | ||
| 30 | #ifdef IP_MULTICAST_TTL | ||
| 31 | - if (addr->sa_family == AF_INET) { | ||
| 32 | - if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &mcastTTL, sizeof(mcastTTL)) < 0) { | ||
| 33 | - ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IP_MULTICAST_TTL)"); | ||
| 34 | - return ff_neterrno(); | ||
| 35 | - } | ||
| 36 | - } | ||
| 37 | + case AF_INET: | ||
| 38 | + protocol = IPPROTO_IP; | ||
| 39 | + cmd = IP_MULTICAST_TTL; | ||
| 40 | + break; | ||
| 41 | #endif | ||
| 42 | -#if defined(IPPROTO_IPV6) && defined(IPV6_MULTICAST_HOPS) | ||
| 43 | - if (addr->sa_family == AF_INET6) { | ||
| 44 | - if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &mcastTTL, sizeof(mcastTTL)) < 0) { | ||
| 45 | - ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IPV6_MULTICAST_HOPS)"); | ||
| 46 | +#ifdef IPV6_MULTICAST_HOPS | ||
| 47 | + case AF_INET6: | ||
| 48 | + protocol = IPPROTO_IPV6; | ||
| 49 | + cmd = IPV6_MULTICAST_HOPS; | ||
| 50 | + break; | ||
| 51 | +#endif | ||
| 52 | + default: | ||
| 53 | + return 0; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + if (setsockopt(sockfd, protocol, cmd, &mcastTTL, sizeof(mcastTTL)) < 0) { | ||
| 57 | + /* BSD compatibility */ | ||
| 58 | + unsigned char ttl = (unsigned char) mcastTTL; | ||
| 59 | + | ||
| 60 | + ff_log_net_error(NULL, AV_LOG_DEBUG, "setsockopt(IPV4/IPV6 MULTICAST TTL)"); | ||
| 61 | + if (setsockopt(sockfd, protocol, cmd, &ttl, sizeof(ttl)) < 0) { | ||
| 62 | + ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IPV4/IPV6 MULTICAST TTL)"); | ||
| 63 | return ff_neterrno(); | ||
| 64 | } | ||
| 65 | } | ||
| 66 | -#endif | ||
| 67 | + | ||
| 68 | return 0; | ||
| 69 | } | ||
| 70 | |||
| 71 | @@ -673,6 +691,11 @@ static int udp_open(URLContext *h, const char *uri, in | ||
| 72 | } | ||
| 73 | if (av_find_info_tag(buf, sizeof(buf), "ttl", p)) { | ||
| 74 | s->ttl = strtol(buf, NULL, 10); | ||
| 75 | + if (s->ttl < 0 || s->ttl > 255) { | ||
| 76 | + av_log(h, AV_LOG_ERROR, "ttl(%d) should be in range [0,255]\n", s->ttl); | ||
| 77 | + ret = AVERROR(EINVAL); | ||
| 78 | + goto fail; | ||
| 79 | + } | ||
| 80 | } | ||
| 81 | if (av_find_info_tag(buf, sizeof(buf), "udplite_coverage", p)) { | ||
| 82 | s->udplite_coverage = strtol(buf, NULL, 10); | ||
