Fix compilation for Windows.

- Mingw32 didn't read MSDN, so behaves badly despite lean and mean.
- Avoid alignment issues on windows with packed bitfields in the RTP header.
  This change makes the program ill-formed in C99, but I don't know the correct
  fix at the moment, and I don't want to keep the Windows build broken for too
  long.
This commit is contained in:
iphydf 2016-09-08 00:29:44 +01:00
parent d5f9344847
commit 54de13c1c7
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
2 changed files with 16 additions and 19 deletions

View File

@ -37,21 +37,21 @@ enum {
struct RTPHeader {
/* Standard RTP header */
#ifndef WORDS_BIGENDIAN
unsigned cc: 4; /* Contributing sources count */
unsigned xe: 1; /* Extra header */
unsigned pe: 1; /* Padding */
unsigned ve: 2; /* Version */
uint16_t cc: 4; /* Contributing sources count */
uint16_t xe: 1; /* Extra header */
uint16_t pe: 1; /* Padding */
uint16_t ve: 2; /* Version */
unsigned pt: 7; /* Payload type */
unsigned ma: 1; /* Marker */
uint16_t pt: 7; /* Payload type */
uint16_t ma: 1; /* Marker */
#else
unsigned ve: 2; /* Version */
unsigned pe: 1; /* Padding */
unsigned xe: 1; /* Extra header */
unsigned cc: 4; /* Contributing sources count */
uint16_t ve: 2; /* Version */
uint16_t pe: 1; /* Padding */
uint16_t xe: 1; /* Extra header */
uint16_t cc: 4; /* Contributing sources count */
unsigned ma: 1; /* Marker */
unsigned pt: 7; /* Payload type */
uint16_t ma: 1; /* Marker */
uint16_t pt: 7; /* Payload type */
#endif
uint16_t sequnum;

View File

@ -44,15 +44,12 @@
#define WINVER 0x0501
#endif
// See https://msdn.microsoft.com/en-us/library/windows/desktop/ms737629(v=vs.85).aspx
// for why. In short: we need to avoid inclusion of <winsock.h> by <windows.h>,
// so <winsock2.h> doesn't cause issues.
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
// The mingw32/64 Windows library warns about including winsock2.h after
// windows.h even though with the above it's a valid thing to do. So, to make
// mingw32 headers happy, we include winsock2.h first.
#include <winsock2.h>
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#ifndef IPV6_V6ONLY