[FFmpeg-devel] [PATCH] IOS-IPv6-only-network-use-hardcode-IPv4-fix

Steven Liu lingjiujianke at gmail.com
Wed Aug 24 04:34:20 EEST 2016


2016-08-24 9:03 GMT+08:00 liu jc <jcliu at outlook.com>:

>
>  there is a bug when useing getaddrinfo in IOS when use
>  hardcode IPv4 address and in IPv6-only networks.It can not
>  accept a port number as second parameter as an alternative
>  you can pass a service name  or it will cause connect fail.
>  In current video CDN dispatching mechanism the hardcode
>  IPv4 is widly used for better performance. This problem
>  cause many APP use ffmpeg to play this type CDN dispatched
>  video were rejected by APP store. This patch fix this by
>  adding a port to name map for widly used port number that
>  these CDN use to dispatch video.
>
> ---
>  libavformat/tcp.c |   17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
>  mode change 100644 => 100755 libavformat/tcp.c
>
> diff --git a/libavformat/tcp.c b/libavformat/tcp.c
> old mode 100644
> new mode 100755
> index c105479..0de7710
> --- a/libavformat/tcp.c
> +++ b/libavformat/tcp.c
> @@ -72,7 +72,7 @@ static int tcp_open(URLContext *h, const char *uri, int
> flags)
>      char buf[256];
>      int ret;
>      char hostname[1024],proto[1024],path[1024];
> -    char portstr[10];
> +    char portstr[64];
>      s->open_timeout = 5000000;
>
>      av_url_split(proto, sizeof(proto), NULL, 0, hostname,
> sizeof(hostname),
> @@ -105,7 +105,19 @@ static int tcp_open(URLContext *h, const char *uri,
> int flags)
>      }
>      hints.ai_family = AF_UNSPEC;
>      hints.ai_socktype = SOCK_STREAM;
> -    snprintf(portstr, sizeof(portstr), "%d", port);
> +
> +       switch (port) {
> +        case 80:
> +            snprintf(portstr, sizeof(portstr), "%s", "http");
> +            break;
> +        case 1935:
> +            snprintf(portstr, sizeof(portstr), "%s", "macromedia-fcs");
> //know as rtmp
>
i have one quetion: When the rtmp server listen the port 1936, what about
the portstr?

> +            break;
> +        default:
> +            snprintf(portstr, sizeof(portstr), "%d", port);
> +            break;
> +    }
> +
>      if (s->listen)
>          hints.ai_flags |= AI_PASSIVE;
>      if (!hostname[0])
> @@ -268,3 +280,4 @@ const URLProtocol ff_tcp_protocol = {
>      .flags               = URL_PROTOCOL_FLAG_NETWORK,
>      .priv_data_class     = &tcp_class,
>  };
> +
>
delete this line.

> --
> 1.7.9.5
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


More information about the ffmpeg-devel mailing list