diff options
author | Joni Valtanen <joni.valtanen@movial.fi> | 2006-06-20 10:31:41 +0000 |
---|---|---|
committer | Wim Taymans <wim.taymans@gmail.com> | 2006-06-20 10:31:41 +0000 |
commit | 7b405d88d315db33572b8020b60120b89b0cff70 (patch) | |
tree | 2065666caa739981107af6636844aa4930bb01a4 /gst | |
parent | 20d3f1d94d2731de0dd64241e920c90653f6120c (diff) |
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.
Diffstat (limited to 'gst')
-rw-r--r-- | gst/rtsp/rtspconnection.c | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/gst/rtsp/rtspconnection.c b/gst/rtsp/rtspconnection.c index 221369d9..b1fb34f1 100644 --- a/gst/rtsp/rtspconnection.c +++ b/gst/rtsp/rtspconnection.c @@ -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; |