[FFmpeg-devel] [PATCH] IPv6 support for mingw32

Zuxy Meng zuxy.meng
Thu Jan 7 03:59:51 CET 2010


Hi,

2010/1/6 Martin Storsj? <martin at martin.st>:
> Hi Zuxy,
>
> On Wed, 6 Jan 2010, Zuxy Meng wrote:
>
>> Without this patch mplayer build would fail but ffmpeg is fine,
>> because currently ffmpeg's configure disables IPv6 on Windows.
>
> Could you elaborate on how mplayer's build fails if ffmpeg is configured
> with IPv6 disabled?

The problem is that the link stage would fail when CONFIG_IPV6 is set
for libavformat/udp.c, due to calling convention differences for
getaddrinfo() and freeaddrinfo().

Without explicit options, mplayer's configure enables CONFIG_IPV6 for
mingw but ffmpeg's configure disables it, because the latter tries to
actually build a small program calling getaddrinfo(), which would fail
during linking.

The problem is that the prototype of getaddrinfo() and freeaddrinfo()
are declared in ws2tcpip.h only when _WIN32_WINNT is bigger than
0x0501 (that is, Windows XP):

#if (_WIN32_WINNT >= 0x0501)
void WSAAPI freeaddrinfo (struct addrinfo*);
int WSAAPI getaddrinfo (const char*,const char*,const struct addrinfo*,
                        struct addrinfo**);
int WSAAPI getnameinfo(const struct sockaddr*,socklen_t,char*,DWORD,
                       char*,DWORD,int);
#else
/* FIXME: Need WS protocol-independent API helpers.  */
#endif

And WSAAPI is __stdcall.

>
>> There's a tradeoff however, that the built binaries can't run on Windows
>> 2000 or older, as getaddrinfo() and freeaddrinfo() are available as part
>> of the OS since Windows XP. It's possible to run IPv6 on Windows
>> 2000/ME/98 with IPv6 Technology Preview installed but that requires
>> inclusion of wspiapi.h that isn't shipped in MinGW due to license
>> conflicts.
>
> Skipping backwards compatibility for this kind of feature isn't something
> I'd do lighthandedly.
>
> The common approach to preserve backwards compatibility (without losing
> the IPv6 functionality on the newer versions that actually have a proper
> getaddrinfo) on windows is to load them using GetProcAddress, and provide
> a fallback wrapper if they aren't found. Fallback wrappers already are
> provided in the "[PATCH/RFC] Prefer getaddrinfo over gethostbyname"
> thread, so adding support for loading the proper ones on top of those
> patches is quite easy. I can give that a try.

Actually there is a wspiapi.h that just does that. However it's
copyrighted by MS. You can take a look at it from
http://pf.itd.nrl.navy.mil/mdp/dox/html/wspiapi_8h-source.html for
reference.

>
> In that case, the ipv6 configure check could be simplified to only look
> for e.g. struct ipv6_mreq and other stuff related to multicast/ipv6 - or
> later provide fallbacks for those too and remove the ipv6 configure check
> completely.
>
> As said, I can try to get proper IPv6 getaddrinfo for mingw - without
> breaking backwards compatibility. But in order to know what to aim at, I'd
> like to know what the build problem with mplayer actually is.
>
> // Martin


-- 
Zuxy
Beauty is truth,
While truth is beauty.
PGP KeyID: E8555ED6



More information about the ffmpeg-devel mailing list