From c9627baca918f81b66acb2538575e4861da4e566 Mon Sep 17 00:00:00 2001 From: hyc Date: Sat, 1 May 2010 11:00:04 +0000 Subject: [PATCH] XBOX compatibility patches (Mostly same as WIN32) git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@464 400ebc74-4327-4243-bc38-086b20814532 --- librtmp/amf.c | 1 + librtmp/amf.h | 12 ++++++++++++ librtmp/bytes.h | 2 +- librtmp/hashswf.c | 13 ++++++++++--- librtmp/log.c | 1 + librtmp/log.h | 1 + librtmp/rtmp.c | 4 ++-- librtmp/rtmp.h | 2 +- librtmp/rtmp_sys.h | 16 ++++++++++++++-- 9 files changed, 43 insertions(+), 9 deletions(-) diff --git a/librtmp/amf.c b/librtmp/amf.c index 4078078..911bb13 100644 --- a/librtmp/amf.c +++ b/librtmp/amf.c @@ -26,6 +26,7 @@ #include #include +#include "rtmp_sys.h" #include "amf.h" #include "log.h" #include "bytes.h" diff --git a/librtmp/amf.h b/librtmp/amf.h index a03774f..18dcf70 100644 --- a/librtmp/amf.h +++ b/librtmp/amf.h @@ -25,7 +25,19 @@ */ #include + +#ifdef _XBOX + +#ifndef __cplusplus +#define bool _Bool +typedef unsigned char _Bool; +#define false 0 +#define true 1 +#endif + +#else #include +#endif #ifdef __cplusplus extern "C" diff --git a/librtmp/bytes.h b/librtmp/bytes.h index 3419b67..62b9226 100644 --- a/librtmp/bytes.h +++ b/librtmp/bytes.h @@ -27,7 +27,7 @@ #include -#ifdef WIN32 +#if defined(WIN32) || defined(_XBOX) /* Windows is little endian only */ #define __LITTLE_ENDIAN 1234 #define __BIG_ENDIAN 4321 diff --git a/librtmp/hashswf.c b/librtmp/hashswf.c index f72b687..b32442d 100644 --- a/librtmp/hashswf.c +++ b/librtmp/hashswf.c @@ -136,7 +136,7 @@ HTTP_get(struct HTTP_ctx *http, const char *url, HTTP_read_callback *cb) } sa.sin_port = htons(port); sb.sb_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (sb.sb_socket < 0) + if (sb.sb_socket == -1) return HTTPRES_LOST_CONNECTION; i = sprintf(sb.sb_buf, @@ -464,12 +464,19 @@ RTMP_HashSWF(const char *url, unsigned int *size, unsigned char *hash, AVal home, hpre; date[0] = '\0'; -#ifdef WIN32 +#if defined(WIN32) || defined(_XBOX) +#ifdef _XBOX + hpre.av_val = "Q:"; + hpre.av_len = 2; + home.av_val = "\\UserData\\cache"; +#else hpre.av_val = getenv("HOMEDRIVE"); hpre.av_len = strlen(hpre.av_val); home.av_val = getenv("HOMEPATH"); +#endif #define DIRSEP "\\" -#else + +#else /* !WIN32 */ hpre.av_val = ""; hpre.av_len = 0; home.av_val = getenv("HOME"); diff --git a/librtmp/log.c b/librtmp/log.c index a827841..5e1c871 100644 --- a/librtmp/log.c +++ b/librtmp/log.c @@ -26,6 +26,7 @@ #include #include +#include "rtmp_sys.h" #include "log.h" #define MAX_PRINT_LEN 2048 diff --git a/librtmp/log.h b/librtmp/log.h index 26784ed..ebc1605 100644 --- a/librtmp/log.h +++ b/librtmp/log.h @@ -58,4 +58,5 @@ RTMP_LogLevel RTMP_LogGetLevel(void); #ifdef __cplusplus } #endif + #endif diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c index f91e60c..2958754 100644 --- a/librtmp/rtmp.c +++ b/librtmp/rtmp.c @@ -807,7 +807,7 @@ RTMP_Connect0(RTMP *r, struct sockaddr * service) } } - setsockopt(r->m_sb.sb_socket, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on)); + setsockopt(r->m_sb.sb_socket, IPPROTO_TCP, TCP_NODELAY, (char *) &on, sizeof(on)); return true; } @@ -3524,7 +3524,7 @@ HTTP_read(RTMP *r, int fill) * packets, 0 if ignorable error, >0 if there is a media packet */ static int -Read_1_Packet(RTMP *r, char *buf, int buflen) +Read_1_Packet(RTMP *r, char *buf, unsigned int buflen) { uint32_t prevTagSize = 0; int rtnGetNextMediaPacket = 0, ret = RTMP_READ_EOF; diff --git a/librtmp/rtmp.h b/librtmp/rtmp.h index 4eab3e3..5ec8916 100644 --- a/librtmp/rtmp.h +++ b/librtmp/rtmp.h @@ -24,7 +24,7 @@ * http://www.gnu.org/copyleft/lgpl.html */ -#ifndef NO_CRYPTO +#if !defined(NO_CRYPTO) && !defined(CRYPTO) #define CRYPTO #endif diff --git a/librtmp/rtmp_sys.h b/librtmp/rtmp_sys.h index a7ab97f..2ba1449 100644 --- a/librtmp/rtmp_sys.h +++ b/librtmp/rtmp_sys.h @@ -21,16 +21,28 @@ * http://www.gnu.org/copyleft/lgpl.html */ -#ifdef WIN32 +#if defined(WIN32) || defined(_XBOX) + +#ifdef _XBOX +#include +#include +#define snprintf _snprintf +#define strcasecmp stricmp +#define strncasecmp strnicmp +#define vsnprintf _vsnprintf + +#else /* !_XBOX */ #include #include +#endif + #define GetSockError() WSAGetLastError() #define setsockopt(a,b,c,d,e) (setsockopt)(a,b,c,(const char *)d,(int)e) #define EWOULDBLOCK WSAETIMEDOUT /* we don't use nonblocking, but we do use timeouts */ #define sleep(n) Sleep(n*1000) #define msleep(n) Sleep(n) #define SET_RCVTIMEO(tv,s) int tv = s*1000 -#else +#else /* !WIN32 && !_XBOX */ #include #include #include -- 2.50.1