Message ID | SG2PR0201MB09337F406B8D226930F753A5A5EA0@SG2PR0201MB0933.apcprd02.prod.outlook.com |
---|---|
State | Changes Requested |
Headers | show |
2016-08-24 9:03 GMT+08:00 liu jc <jcliu@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@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >
this patch just deal with the standard condition (most people use 1935). Although you still can use the port and service map in mac (/etc/services) to cheat. If you rtmp server listen 1936 following the mac services list you can just pass a service name "jetcmeserver" then you tcp connection can establish successful. But for not resulting ambiguity it is recommend use standard port number for specific service. ________________________________ 发件人: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> 代表 Steven Liu <lingjiujianke@gmail.com> 发送时间: 2016年8月24日 1:34 收件人: FFmpeg development discussions and patches 主题: Re: [FFmpeg-devel] [PATCH] IOS-IPv6-only-network-use-hardcode-IPv4-fix 2016-08-24 9:03 GMT+08:00 liu jc <jcliu@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@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ffmpeg-devel Info Page<http://ffmpeg.org/mailman/listinfo/ffmpeg-devel> ffmpeg.org This list is about FFmpeg development discussions and patches; but not for bug-reports. Please read the Code-of-conduct. To see the collection of prior postings to ... > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
2016-08-24 10:40 GMT+08:00 liu jc <jcliu@outlook.com>: > this patch just deal with the standard condition (most people use 1935). > Although you still can use the port and service map in mac (/etc/services) > to cheat. If you rtmp server listen 1936 following the mac services list > you can just pass a > > service name "jetcmeserver" then you tcp connection can establish > successful. But for not resulting ambiguity it is recommend use standard > port number for specific service. > But without this patch, i can publish stream to rtmp server listening 1936 or other. > > > ________________________________ > 发件人: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> 代表 Steven Liu < > lingjiujianke@gmail.com> > 发送时间: 2016年8月24日 1:34 > 收件人: FFmpeg development discussions and patches > 主题: Re: [FFmpeg-devel] [PATCH] IOS-IPv6-only-network-use-hardcode-IPv4-fix > > 2016-08-24 9:03 GMT+08:00 liu jc <jcliu@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@ffmpeg.org > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > ffmpeg-devel Info Page<http://ffmpeg.org/mailman/listinfo/ffmpeg-devel> > ffmpeg.org > This list is about FFmpeg development discussions and patches; but not for > bug-reports. Please read the Code-of-conduct. To see the collection of > prior postings to ... > > > > > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >
On Wed, 24 Aug 2016 01:03:00 +0000 liu jc <jcliu@outlook.com> wrote: > > there is a bug when useing getaddrinfo in IOS when use if this is an IOS hack, it should be ifdef'd? also i thought we had a policy against putting os bugfixes in our codebase? although i dislike this policy... > - 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 > + break; > + default: > + snprintf(portstr, sizeof(portstr), "%d", port); > + break; so only 80, 1935 ? rtmp uses some other ports too. 443 etc. i am not against patch, i hope there is a way to fix this. do we have any apple contacts to report this bug? is it possible to use a different getaddrinfo on ios? thanks for patch. -compn
It is not a ios hack, It compatible with any system that in accordance with the POSIX standards. The second parameter of function getaddrinfo can accept the port name or a service name. If you give a service name to it it will translate it to a standard port number. ________________________________ 发件人: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> 代表 compn <tempn@mi.rr.com> 发送时间: 2016年8月24日 2:57 收件人: FFmpeg development discussions and patches 主题: Re: [FFmpeg-devel] [PATCH] IOS-IPv6-only-network-use-hardcode-IPv4-fix On Wed, 24 Aug 2016 01:03:00 +0000 liu jc <jcliu@outlook.com> wrote: > > there is a bug when useing getaddrinfo in IOS when use if this is an IOS hack, it should be ifdef'd? also i thought we had a policy against putting os bugfixes in our codebase? although i dislike this policy... > - 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 > + break; > + default: > + snprintf(portstr, sizeof(portstr), "%d", port); > + break; so only 80, 1935 ? rtmp uses some other ports too. 443 etc. i am not against patch, i hope there is a way to fix this. do we have any apple contacts to report this bug? is it possible to use a different getaddrinfo on ios? thanks for patch. -compn _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ffmpeg-devel Info Page<http://ffmpeg.org/mailman/listinfo/ffmpeg-devel> ffmpeg.org This list is about FFmpeg development discussions and patches; but not for bug-reports. Please read the Code-of-conduct. To see the collection of prior postings to ...
Yes you can. But if you are in the IPv6 only network and use a hardcode IPv4 address ,in latest IOS version if you just use a port number as the second parameter of function getaddrinfo, you will get a connection fail when you connect to you server. ________________________________ 发件人: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> 代表 Steven Liu <lingjiujianke@gmail.com> 发送时间: 2016年8月24日 2:46 收件人: FFmpeg development discussions and patches 主题: Re: [FFmpeg-devel] 答复: [PATCH] IOS-IPv6-only-network-use-hardcode-IPv4-fix 2016-08-24 10:40 GMT+08:00 liu jc <jcliu@outlook.com>: > this patch just deal with the standard condition (most people use 1935). > Although you still can use the port and service map in mac (/etc/services) > to cheat. If you rtmp server listen 1936 following the mac services list > you can just pass a > > service name "jetcmeserver" then you tcp connection can establish > successful. But for not resulting ambiguity it is recommend use standard > port number for specific service. > But without this patch, i can publish stream to rtmp server listening 1936 or other. > > > ________________________________ > 发件人: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> 代表 Steven Liu < > lingjiujianke@gmail.com> > 发送时间: 2016年8月24日 1:34 > 收件人: FFmpeg development discussions and patches > 主题: Re: [FFmpeg-devel] [PATCH] IOS-IPv6-only-network-use-hardcode-IPv4-fix > > 2016-08-24 9:03 GMT+08:00 liu jc <jcliu@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@ffmpeg.org > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ffmpeg-devel Info Page<http://ffmpeg.org/mailman/listinfo/ffmpeg-devel> ffmpeg.org This list is about FFmpeg development discussions and patches; but not for bug-reports. Please read the Code-of-conduct. To see the collection of prior postings to ... > ffmpeg-devel Info Page<http://ffmpeg.org/mailman/listinfo/ffmpeg-devel> > ffmpeg.org > This list is about FFmpeg development discussions and patches; but not for > bug-reports. Please read the Code-of-conduct. To see the collection of > prior postings to ... > > > > > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
2016-08-24 15:19 GMT+08:00 liu jc <jcliu@outlook.com>: > Yes you can. But if you are in the IPv6 only network and use a hardcode > IPv4 address ,in latest IOS version if you just use a port number as the > second parameter of function getaddrinfo, you will get a connection fail > when you connect to you server. > > I think you have fixed a bug, but make some new bug with this patch, Why don't fix the protocol by default work flow? > > ________________________________ > 发件人: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> 代表 Steven Liu < > lingjiujianke@gmail.com> > 发送时间: 2016年8月24日 2:46 > 收件人: FFmpeg development discussions and patches > 主题: Re: [FFmpeg-devel] 答复: [PATCH] IOS-IPv6-only-network-use- > hardcode-IPv4-fix > > 2016-08-24 10:40 GMT+08:00 liu jc <jcliu@outlook.com>: > > > this patch just deal with the standard condition (most people use 1935). > > Although you still can use the port and service map in mac > (/etc/services) > > to cheat. If you rtmp server listen 1936 following the mac services list > > you can just pass a > > > > service name "jetcmeserver" then you tcp connection can establish > > successful. But for not resulting ambiguity it is recommend use standard > > port number for specific service. > > > But without this patch, i can publish stream to rtmp server listening 1936 > or other. > > > > > > > ________________________________ > > 发件人: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> 代表 Steven Liu < > > lingjiujianke@gmail.com> > > 发送时间: 2016年8月24日 1:34 > > 收件人: FFmpeg development discussions and patches > > 主题: Re: [FFmpeg-devel] [PATCH] IOS-IPv6-only-network-use- > hardcode-IPv4-fix > > > > 2016-08-24 9:03 GMT+08:00 liu jc <jcliu@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@ffmpeg.org > > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > ffmpeg-devel Info Page<http://ffmpeg.org/mailman/listinfo/ffmpeg-devel> > ffmpeg.org > This list is about FFmpeg development discussions and patches; but not for > bug-reports. Please read the Code-of-conduct. To see the collection of > prior postings to ... > > > > > ffmpeg-devel Info Page<http://ffmpeg.org/mailman/listinfo/ffmpeg-devel> > > ffmpeg.org > > This list is about FFmpeg development discussions and patches; but not > for > > bug-reports. Please read the Code-of-conduct. To see the collection of > > prior postings to ... > > > > > > > > > > > _______________________________________________ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > _______________________________________________ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >
On Wed, Aug 24, 2016 at 07:15:29AM +0000, liu jc wrote:
> It is not a ios hack, It compatible with any system that in accordance with the POSIX standards. The second parameter of function getaddrinfo can accept the port name or a service name. If you give a service name to it it will translate it to a standard port number.
POSIX says this:
http://pubs.opengroup.org/onlinepubs/009695399/functions/freeaddrinfo.html
"If servname is null, the call shall return network-level addresses for the specified nodename. If servname is not null, it is a null-terminated character string identifying the requested service. This can be either a descriptive name or a numeric representation suitable for use with the address family or families. If the specified address family is AF_INET, [IP6] [Option Start] AF_INET6, [Option End] or AF_UNSPEC, the service can be specified as a string specifying a decimal port number."
so port numbers are required to be supported by POSIX
some IOS version fails with that,
that IOS version is buggy, the bug in fact seems known and has been
fixed already IIUC
also see
http://stackoverflow.com/questions/37386161/service-port-is-missed-when-using-getaddrinfo-to-convert-ipv4-addr-to-ipv6-addr
also macromedia-fcs is not in my /etc/services so your patch
would break POSIX systems
If you wish to workaround a IOS bug i dont mind but that has to be
clean and work.
your patch half works on IOS (only 2 port numbers supported) and half
breaks POSIX systems
[...]
Yes it is better to modify it in all protocol that need call getaddrinfo. This patch just can fix one usage scenarios . I think it is enough for the Video APP that use FFMPEG to pass the APPLEreview for IPv6. Other than that APPLE already know this bug i think it will be fix in the future. ________________________________ 发件人: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> 代表 Steven Liu <lingjiujianke@gmail.com> 发送时间: 2016年8月24日 7:23 收件人: FFmpeg development discussions and patches 主题: Re: [FFmpeg-devel] 答复: 答复: [PATCH] IOS-IPv6-only-network-use-hardcode-IPv4-fix 2016-08-24 15:19 GMT+08:00 liu jc <jcliu@outlook.com>: > Yes you can. But if you are in the IPv6 only network and use a hardcode > IPv4 address ,in latest IOS version if you just use a port number as the > second parameter of function getaddrinfo, you will get a connection fail > when you connect to you server. > > I think you have fixed a bug, but make some new bug with this patch, Why don't fix the protocol by default work flow? > > ________________________________ > 发件人: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> 代表 Steven Liu < > lingjiujianke@gmail.com> > 发送时间: 2016年8月24日 2:46 > 收件人: FFmpeg development discussions and patches > 主题: Re: [FFmpeg-devel] 答复: [PATCH] IOS-IPv6-only-network-use- > hardcode-IPv4-fix > > 2016-08-24 10:40 GMT+08:00 liu jc <jcliu@outlook.com>: > > > this patch just deal with the standard condition (most people use 1935). > > Although you still can use the port and service map in mac > (/etc/services) > > to cheat. If you rtmp server listen 1936 following the mac services list > > you can just pass a > > > > service name "jetcmeserver" then you tcp connection can establish > > successful. But for not resulting ambiguity it is recommend use standard > > port number for specific service. > > > But without this patch, i can publish stream to rtmp server listening 1936 > or other. > > > > > > > ________________________________ > > 发件人: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> 代表 Steven Liu < > > lingjiujianke@gmail.com> > > 发送时间: 2016年8月24日 1:34 > > 收件人: FFmpeg development discussions and patches > > 主题: Re: [FFmpeg-devel] [PATCH] IOS-IPv6-only-network-use- > hardcode-IPv4-fix > > > > 2016-08-24 9:03 GMT+08:00 liu jc <jcliu@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@ffmpeg.org > > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ffmpeg-devel Info Page<http://ffmpeg.org/mailman/listinfo/ffmpeg-devel> ffmpeg.org This list is about FFmpeg development discussions and patches; but not for bug-reports. Please read the Code-of-conduct. To see the collection of prior postings to ... > ffmpeg-devel Info Page<http://ffmpeg.org/mailman/listinfo/ffmpeg-devel> > ffmpeg.org > This list is about FFmpeg development discussions and patches; but not for > bug-reports. Please read the Code-of-conduct. To see the collection of > prior postings to ... > > > > > ffmpeg-devel Info Page<http://ffmpeg.org/mailman/listinfo/ffmpeg-devel> > > ffmpeg.org > > This list is about FFmpeg development discussions and patches; but not > for > > bug-reports. Please read the Code-of-conduct. To see the collection of > > prior postings to ... > > > > > > > > > > > _______________________________________________ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > _______________________________________________ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Awesome the second workaround seem a better way i will try it.
________________________________
发件人: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> 代表 Michael Niedermayer <michael@niedermayer.cc>
发送时间: 2016年8月24日 8:11
收件人: FFmpeg development discussions and patches
主题: Re: [FFmpeg-devel] 答复: [PATCH] IOS-IPv6-only-network-use-hardcode-IPv4-fix
On Wed, Aug 24, 2016 at 07:15:29AM +0000, liu jc wrote:
> It is not a ios hack, It compatible with any system that in accordance with the POSIX standards. The second parameter of function getaddrinfo can accept the port name or a service name. If you give a service name to it it will translate it to a standard port number.
POSIX says this:
http://pubs.opengroup.org/onlinepubs/009695399/functions/freeaddrinfo.html
"If servname is null, the call shall return network-level addresses for the specified nodename. If servname is not null, it is a null-terminated character string identifying the requested service. This can be either a descriptive name or a numeric representation suitable for use with the address family or families. If the specified address family is AF_INET, [IP6] [Option Start] AF_INET6, [Option End] or AF_UNSPEC, the service can be specified as a string specifying a decimal port number."
so port numbers are required to be supported by POSIX
some IOS version fails with that,
that IOS version is buggy, the bug in fact seems known and has been
fixed already IIUC
also see
http://stackoverflow.com/questions/37386161/service-port-is-missed-when-using-getaddrinfo-to-convert-ipv4-addr-to-ipv6-addr
also macromedia-fcs is not in my /etc/services so your patch
would break POSIX systems
If you wish to workaround a IOS bug i dont mind but that has to be
clean and work.
your patch half works on IOS (only 2 port numbers supported) and half
breaks POSIX systems
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope
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 + 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, }; +