gst/rtsp/rtspconnection.c: Make RTSP plugin compile on windows. Fixes #345301.

Original commit message from CVS:
Patch by: Joni Valtanen <joni dot valtanen at movial dot fi>
* gst/rtsp/rtspconnection.c: (inet_aton), (rtsp_connection_send),
(rtsp_connection_close):
Make RTSP plugin compile on windows. Fixes #345301.
Some changes to original patch to catch errors better.
use ifdef WIN32 instead of ifndef.
This commit is contained in:
Joni Valtanen 2006-06-20 10:31:41 +00:00 committed by Wim Taymans
parent 20d3f1d94d
commit 7b405d88d3
2 changed files with 59 additions and 1 deletions

View file

@ -1,3 +1,13 @@
2006-06-20 Wim Taymans <wim@fluendo.com>
Patch by: Joni Valtanen <joni dot valtanen at movial dot fi>
* gst/rtsp/rtspconnection.c: (inet_aton), (rtsp_connection_send),
(rtsp_connection_close):
Make RTSP plugin compile on windows. Fixes #345301.
Some changes to original patch to catch errors better.
use ifdef WIN32 instead of ifndef.
2006-06-19 Zaheer Abbas Merali <zaheerabbas at merali dot org>
* configure.ac:

View file

@ -22,13 +22,34 @@
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
#include <winsock2.h>
#else
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
#include "rtspconnection.h"
#ifdef WIN32
/* note that inet_aton is deprecated on unix because
* inet_addr returns -1 (INADDR_NONE) for the valid 255.255.255.255
* address. */
static int
inet_aton (const char *c, struct in_addr *paddr)
{
paddr->s_addr = inet_addr (c);
if (paddr->s_addr == INADDR_NONE)
return 0;
return 1;
}
#endif
RTSPResult
rtsp_connection_open (RTSPUrl * url, RTSPConnection ** conn)
{
@ -129,6 +150,17 @@ rtsp_connection_send (RTSPConnection * conn, RTSPMessage * message)
if (conn == NULL || message == NULL)
return RTSP_EINVAL;
#ifdef WIN32
WSADATA w;
int error = WSAStartup (0x0202, &w);
if (error)
goto startup_error;
if (w.wVersion != 0x0202)
goto version_error;
#endif
str = g_string_new ("");
/* create request string, add CSeq */
@ -183,6 +215,18 @@ rtsp_connection_send (RTSPConnection * conn, RTSPMessage * message)
return RTSP_OK;
#ifdef WIN32
startup_error:
{
GST_DEBUG_OBJECT (self, "Error %d on WSAStartup", error);
return RTSP_ERROR;
}
version_error:
{
WSACleanup ();
return RTSP_ERROR;
}
#endif
write_error:
{
g_string_free (str, TRUE);
@ -536,8 +580,12 @@ rtsp_connection_close (RTSPConnection * conn)
if (conn == NULL)
return RTSP_EINVAL;
#ifdef WIN32
res = socketclose (conn->fd);
WSACleanup ();
#else
res = close (conn->fd);
#endif
conn->fd = -1;
if (res != 0)
goto sys_error;