r503 - in trunk: librtmp/amf.c librtmp/amf.h librtmp/dh.h librtmp/handshake.h librtmp/hashswf.c librtmp/parseurl.c librtmp/rtmp.c librtmp/rtmp.h librtmp/rtmp_sys.h rtmpdump.c rtmpgw.c rtmpsrv.c rtm...
Author: hyc Date: Wed Jun 2 18:52:55 2010 New Revision: 503 Log: Kill all use of bool, just use int Modified: trunk/librtmp/amf.c trunk/librtmp/amf.h trunk/librtmp/dh.h trunk/librtmp/handshake.h trunk/librtmp/hashswf.c trunk/librtmp/parseurl.c trunk/librtmp/rtmp.c trunk/librtmp/rtmp.h trunk/librtmp/rtmp_sys.h trunk/rtmpdump.c trunk/rtmpgw.c trunk/rtmpsrv.c trunk/rtmpsuck.c Modified: trunk/librtmp/amf.c ============================================================================== --- trunk/librtmp/amf.c Wed Jun 2 18:15:24 2010 (r502) +++ trunk/librtmp/amf.c Wed Jun 2 18:52:55 2010 (r503) @@ -126,7 +126,7 @@ AMF_DecodeNumber(const char *data) return dVal; } -bool +int AMF_DecodeBoolean(const char *data) { return *data != 0; @@ -255,7 +255,7 @@ AMF_EncodeNumber(char *output, char *out } char * -AMF_EncodeBoolean(char *output, char *outend, bool bVal) +AMF_EncodeBoolean(char *output, char *outend, int bVal) { if (output+2 > outend) return NULL; @@ -294,7 +294,7 @@ AMF_EncodeNamedNumber(char *output, char } char * -AMF_EncodeNamedBoolean(char *output, char *outend, const AVal *strName, bool bVal) +AMF_EncodeNamedBoolean(char *output, char *outend, const AVal *strName, int bVal) { if (output+2+strName->av_len > outend) return NULL; @@ -330,7 +330,7 @@ AMFProp_GetNumber(AMFObjectProperty *pro return prop->p_vu.p_number; } -bool +int AMFProp_GetBoolean(AMFObjectProperty *prop) { return prop->p_vu.p_number != 0; @@ -348,7 +348,7 @@ AMFProp_GetObject(AMFObjectProperty *pro *obj = prop->p_vu.p_object; } -bool +int AMFProp_IsValid(AMFObjectProperty *prop) { return prop->p_type != AMF_INVALID; @@ -478,7 +478,7 @@ AMF3ReadString(const char *data, AVal *s int AMF3Prop_Decode(AMFObjectProperty *prop, const char *pBuffer, int nSize, - bool bDecodeName) + int bDecodeName) { int nOriginalSize = nSize; AMF3DataType type; @@ -575,7 +575,7 @@ AMF3Prop_Decode(AMFObjectProperty *prop, } case AMF3_OBJECT: { - int nRes = AMF3_Decode(&prop->p_vu.p_object, pBuffer, nSize, true); + int nRes = AMF3_Decode(&prop->p_vu.p_object, pBuffer, nSize, TRUE); if (nRes == -1) return -1; nSize -= nRes; @@ -595,7 +595,7 @@ AMF3Prop_Decode(AMFObjectProperty *prop, int AMFProp_Decode(AMFObjectProperty *prop, const char *pBuffer, int nSize, - bool bDecodeName) + int bDecodeName) { int nOriginalSize = nSize; int nRes; @@ -667,7 +667,7 @@ AMFProp_Decode(AMFObjectProperty *prop, } case AMF_OBJECT: { - int nRes = AMF_Decode(&prop->p_vu.p_object, pBuffer, nSize, true); + int nRes = AMF_Decode(&prop->p_vu.p_object, pBuffer, nSize, TRUE); if (nRes == -1) return -1; nSize -= nRes; @@ -695,7 +695,7 @@ AMFProp_Decode(AMFObjectProperty *prop, nSize -= 4; /* next comes the rest, mixed array has a final 0x000009 mark and names, so its an object */ - nRes = AMF_Decode(&prop->p_vu.p_object, pBuffer + 4, nSize, true); + nRes = AMF_Decode(&prop->p_vu.p_object, pBuffer + 4, nSize, TRUE); if (nRes == -1) return -1; nSize -= nRes; @@ -713,7 +713,7 @@ AMFProp_Decode(AMFObjectProperty *prop, nSize -= 4; nRes = AMF_DecodeArray(&prop->p_vu.p_object, pBuffer + 4, nSize, - nArrayLen, false); + nArrayLen, FALSE); if (nRes == -1) return -1; nSize -= nRes; @@ -763,7 +763,7 @@ AMFProp_Decode(AMFObjectProperty *prop, } case AMF_AVMPLUS: { - int nRes = AMF3_Decode(&prop->p_vu.p_object, pBuffer, nSize, true); + int nRes = AMF3_Decode(&prop->p_vu.p_object, pBuffer, nSize, TRUE); if (nRes == -1) return -1; nSize -= nRes; @@ -893,10 +893,10 @@ AMF_Encode(AMFObject *obj, char *pBuffer int AMF_DecodeArray(AMFObject *obj, const char *pBuffer, int nSize, - int nArrayLen, bool bDecodeName) + int nArrayLen, int bDecodeName) { int nOriginalSize = nSize; - bool bError = false; + int bError = FALSE; obj->o_num = 0; obj->o_props = NULL; @@ -908,7 +908,7 @@ AMF_DecodeArray(AMFObject *obj, const ch nRes = AMFProp_Decode(&prop, pBuffer, nSize, bDecodeName); if (nRes == -1) - bError = true; + bError = TRUE; else { nSize -= nRes; @@ -923,7 +923,7 @@ AMF_DecodeArray(AMFObject *obj, const ch } int -AMF3_Decode(AMFObject *obj, const char *pBuffer, int nSize, bool bAMFData) +AMF3_Decode(AMFObject *obj, const char *pBuffer, int nSize, int bAMFData) { int nOriginalSize = nSize; int32_t ref; @@ -1007,7 +1007,7 @@ AMF3_Decode(AMFObject *obj, const char * RTMP_Log(RTMP_LOGDEBUG, "Externalizable, TODO check"); - nRes = AMF3Prop_Decode(&prop, pBuffer, nSize, false); + nRes = AMF3Prop_Decode(&prop, pBuffer, nSize, FALSE); if (nRes == -1) RTMP_Log(RTMP_LOGDEBUG, "%s, failed to decode AMF3 property!", __FUNCTION__); @@ -1025,7 +1025,7 @@ AMF3_Decode(AMFObject *obj, const char * int nRes, i; for (i = 0; i < cd.cd_num; i++) /* non-dynamic */ { - nRes = AMF3Prop_Decode(&prop, pBuffer, nSize, false); + nRes = AMF3Prop_Decode(&prop, pBuffer, nSize, FALSE); if (nRes == -1) RTMP_Log(RTMP_LOGDEBUG, "%s, failed to decode AMF3 property!", __FUNCTION__); @@ -1042,7 +1042,7 @@ AMF3_Decode(AMFObject *obj, const char * do { - nRes = AMF3Prop_Decode(&prop, pBuffer, nSize, true); + nRes = AMF3Prop_Decode(&prop, pBuffer, nSize, TRUE); AMF_AddProp(obj, &prop); pBuffer += nRes; @@ -1059,10 +1059,10 @@ AMF3_Decode(AMFObject *obj, const char * } int -AMF_Decode(AMFObject *obj, const char *pBuffer, int nSize, bool bDecodeName) +AMF_Decode(AMFObject *obj, const char *pBuffer, int nSize, int bDecodeName) { int nOriginalSize = nSize; - bool bError = false; /* if there is an error while decoding - try to at least find the end mark AMF_OBJECT_END */ + int bError = FALSE; /* if there is an error while decoding - try to at least find the end mark AMF_OBJECT_END */ obj->o_num = 0; obj->o_props = NULL; @@ -1074,7 +1074,7 @@ AMF_Decode(AMFObject *obj, const char *p if (nSize >=3 && AMF_DecodeInt24(pBuffer) == AMF_OBJECT_END) { nSize -= 3; - bError = false; + bError = FALSE; break; } @@ -1089,7 +1089,7 @@ AMF_Decode(AMFObject *obj, const char *p nRes = AMFProp_Decode(&prop, pBuffer, nSize, bDecodeName); if (nRes == -1) - bError = true; + bError = TRUE; else { nSize -= nRes; Modified: trunk/librtmp/amf.h ============================================================================== --- trunk/librtmp/amf.h Wed Jun 2 18:15:24 2010 (r502) +++ trunk/librtmp/amf.h Wed Jun 2 18:52:55 2010 (r503) @@ -26,19 +26,6 @@ #include <stdint.h> -#ifdef _XBOX - -#ifndef __cplusplus -#define bool _Bool -typedef unsigned char _Bool; -#define false 0 -#define true 1 -#endif - -#else -#include <stdbool.h> -#endif - #ifdef __cplusplus extern "C" { @@ -95,28 +82,28 @@ extern "C" char *AMF_EncodeInt16(char *output, char *outend, short nVal); char *AMF_EncodeInt24(char *output, char *outend, int nVal); char *AMF_EncodeInt32(char *output, char *outend, int nVal); - char *AMF_EncodeBoolean(char *output, char *outend, bool bVal); + char *AMF_EncodeBoolean(char *output, char *outend, int bVal); /* Shortcuts for AMFProp_Encode */ char *AMF_EncodeNamedString(char *output, char *outend, const AVal * name, const AVal * value); char *AMF_EncodeNamedNumber(char *output, char *outend, const AVal * name, double dVal); - char *AMF_EncodeNamedBoolean(char *output, char *outend, const AVal * name, bool bVal); + char *AMF_EncodeNamedBoolean(char *output, char *outend, const AVal * name, int bVal); unsigned short AMF_DecodeInt16(const char *data); unsigned int AMF_DecodeInt24(const char *data); unsigned int AMF_DecodeInt32(const char *data); void AMF_DecodeString(const char *data, AVal * str); void AMF_DecodeLongString(const char *data, AVal * str); - bool AMF_DecodeBoolean(const char *data); + int AMF_DecodeBoolean(const char *data); double AMF_DecodeNumber(const char *data); char *AMF_Encode(AMFObject * obj, char *pBuffer, char *pBufEnd); int AMF_Decode(AMFObject * obj, const char *pBuffer, int nSize, - bool bDecodeName); + int bDecodeName); int AMF_DecodeArray(AMFObject * obj, const char *pBuffer, int nSize, - int nArrayLen, bool bDecodeName); + int nArrayLen, int bDecodeName); int AMF3_Decode(AMFObject * obj, const char *pBuffer, int nSize, - bool bDecodeName); + int bDecodeName); void AMF_Dump(AMFObject * obj); void AMF_Reset(AMFObject * obj); @@ -127,24 +114,24 @@ extern "C" AMFDataType AMFProp_GetType(AMFObjectProperty * prop); void AMFProp_SetNumber(AMFObjectProperty * prop, double dval); - void AMFProp_SetBoolean(AMFObjectProperty * prop, bool bflag); + void AMFProp_SetBoolean(AMFObjectProperty * prop, int bflag); void AMFProp_SetString(AMFObjectProperty * prop, AVal * str); void AMFProp_SetObject(AMFObjectProperty * prop, AMFObject * obj); void AMFProp_GetName(AMFObjectProperty * prop, AVal * name); void AMFProp_SetName(AMFObjectProperty * prop, AVal * name); double AMFProp_GetNumber(AMFObjectProperty * prop); - bool AMFProp_GetBoolean(AMFObjectProperty * prop); + int AMFProp_GetBoolean(AMFObjectProperty * prop); void AMFProp_GetString(AMFObjectProperty * prop, AVal * str); void AMFProp_GetObject(AMFObjectProperty * prop, AMFObject * obj); - bool AMFProp_IsValid(AMFObjectProperty * prop); + int AMFProp_IsValid(AMFObjectProperty * prop); char *AMFProp_Encode(AMFObjectProperty * prop, char *pBuffer, char *pBufEnd); int AMF3Prop_Decode(AMFObjectProperty * prop, const char *pBuffer, - int nSize, bool bDecodeName); + int nSize, int bDecodeName); int AMFProp_Decode(AMFObjectProperty * prop, const char *pBuffer, - int nSize, bool bDecodeName); + int nSize, int bDecodeName); void AMFProp_Dump(AMFObjectProperty * prop); void AMFProp_Reset(AMFObjectProperty * prop); Modified: trunk/librtmp/dh.h ============================================================================== --- trunk/librtmp/dh.h Wed Jun 2 18:15:24 2010 (r502) +++ trunk/librtmp/dh.h Wed Jun 2 18:52:55 2010 (r503) @@ -150,10 +150,10 @@ typedef BIGNUM * MP_t; #include "dhgroups.h" /* RFC 2631, Section 2.1.5, http://www.ietf.org/rfc/rfc2631.txt */ -static bool +static int isValidPublicKey(MP_t y, MP_t p, MP_t q) { - int ret = true; + int ret = TRUE; MP_t bn; assert(y); @@ -165,7 +165,7 @@ isValidPublicKey(MP_t y, MP_t p, MP_t q) if (MP_cmp(y, bn) < 0) { RTMP_Log(RTMP_LOGERROR, "DH public key must be at least 2"); - ret = false; + ret = FALSE; goto failed; } @@ -175,7 +175,7 @@ isValidPublicKey(MP_t y, MP_t p, MP_t q) if (MP_cmp(y, bn) > 0) { RTMP_Log(RTMP_LOGERROR, "DH public key must be at most p-2"); - ret = false; + ret = FALSE; goto failed; } Modified: trunk/librtmp/handshake.h ============================================================================== --- trunk/librtmp/handshake.h Wed Jun 2 18:15:24 2010 (r502) +++ trunk/librtmp/handshake.h Wed Jun 2 18:52:55 2010 (r503) @@ -286,7 +286,7 @@ CalculateDigest(unsigned int digestPos, HMACsha256(message, messageLen, key, keyLen, digest); } -static bool +static int VerifyDigest(unsigned int digestPos, uint8_t *handshakeMessage, const uint8_t *key, size_t keyLen) { @@ -357,13 +357,13 @@ static void rtmpe8_sig(uint8_t *in, uint out[7] = v1; } -static bool -HandShake(RTMP * r, bool FP9HandShake) +static int +HandShake(RTMP * r, int FP9HandShake) { int i, offalg = 0; int dhposClient = 0; int digestPosClient = 0; - bool encrypted = r->Link.protocol & RTMP_FEATURE_ENC; + int encrypted = r->Link.protocol & RTMP_FEATURE_ENC; RC4_handle keyIn = 0; RC4_handle keyOut = 0; @@ -377,9 +377,9 @@ HandShake(RTMP * r, bool FP9HandShake) getoff *getdh = NULL, *getdig = NULL; if (encrypted || r->Link.SWFSize) - FP9HandShake = true; + FP9HandShake = TRUE; else - FP9HandShake = false; + FP9HandShake = FALSE; r->Link.rc4keyIn = r->Link.rc4keyOut = 0; @@ -439,7 +439,7 @@ HandShake(RTMP * r, bool FP9HandShake) { RTMP_Log(RTMP_LOGERROR, "%s: Couldn't initialize Diffie-Hellmann!", __FUNCTION__); - return false; + return FALSE; } dhposClient = getdh(clientsig, RTMP_SIG_SIZE); @@ -449,13 +449,13 @@ HandShake(RTMP * r, bool FP9HandShake) { RTMP_Log(RTMP_LOGERROR, "%s: Couldn't generate Diffie-Hellmann public key!", __FUNCTION__); - return false; + return FALSE; } if (!DHGetPublicKey(r->Link.dh, &clientsig[dhposClient], 128)) { RTMP_Log(RTMP_LOGERROR, "%s: Couldn't write public key!", __FUNCTION__); - return false; + return FALSE; } } @@ -477,10 +477,10 @@ HandShake(RTMP * r, bool FP9HandShake) #endif if (!WriteN(r, (char *)clientsig-1, RTMP_SIG_SIZE + 1)) - return false; + return FALSE; if (ReadN(r, (char *)&type, 1) != 1) /* 0x03 or 0x06 */ - return false; + return FALSE; RTMP_Log(RTMP_LOGDEBUG, "%s: Type Answer : %02X", __FUNCTION__, type); @@ -489,7 +489,7 @@ HandShake(RTMP * r, bool FP9HandShake) __FUNCTION__, clientsig[-1], type); if (ReadN(r, (char *)serversig, RTMP_SIG_SIZE) != RTMP_SIG_SIZE) - return false; + return FALSE; /* decode server response */ memcpy(&uptime, serversig, 4); @@ -500,7 +500,7 @@ HandShake(RTMP * r, bool FP9HandShake) serversig[5], serversig[6], serversig[7]); if (FP9HandShake && type == 3 && !serversig[4]) - FP9HandShake = false; + FP9HandShake = FALSE; #ifdef _DEBUG RTMP_Log(RTMP_LOGDEBUG, "Server signature:"); @@ -526,7 +526,7 @@ HandShake(RTMP * r, bool FP9HandShake) if (!VerifyDigest(digestPosServer, serversig, GenuineFMSKey, 36)) { RTMP_Log(RTMP_LOGERROR, "Couldn't verify the server digest"); /* continuing anyway will probably fail */ - return false; + return FALSE; } } @@ -560,7 +560,7 @@ HandShake(RTMP * r, bool FP9HandShake) if (len < 0) { RTMP_Log(RTMP_LOGDEBUG, "%s: Wrong secret key position!", __FUNCTION__); - return false; + return FALSE; } RTMP_Log(RTMP_LOGDEBUG, "%s: Secret key: ", __FUNCTION__); @@ -633,11 +633,11 @@ HandShake(RTMP * r, bool FP9HandShake) RTMP_LogHex(RTMP_LOGDEBUG, reply, RTMP_SIG_SIZE); #endif if (!WriteN(r, (char *)reply, RTMP_SIG_SIZE)) - return false; + return FALSE; /* 2nd part of handshake */ if (ReadN(r, (char *)serversig, RTMP_SIG_SIZE) != RTMP_SIG_SIZE) - return false; + return FALSE; #ifdef _DEBUG RTMP_Log(RTMP_LOGDEBUG, "%s: 2nd handshake: ", __FUNCTION__); @@ -697,7 +697,7 @@ HandShake(RTMP * r, bool FP9HandShake) SHA256_DIGEST_LENGTH) != 0) { RTMP_Log(RTMP_LOGWARNING, "%s: Server not genuine Adobe!", __FUNCTION__); - return false; + return FALSE; } else { @@ -734,10 +734,10 @@ HandShake(RTMP * r, bool FP9HandShake) } RTMP_Log(RTMP_LOGDEBUG, "%s: Handshaking finished....", __FUNCTION__); - return true; + return TRUE; } -static bool +static int SHandShake(RTMP * r) { int i, offalg = 0; @@ -745,8 +745,8 @@ SHandShake(RTMP * r) int digestPosServer = 0; RC4_handle keyIn = 0; RC4_handle keyOut = 0; - bool FP9HandShake = false; - bool encrypted; + int FP9HandShake = FALSE; + int encrypted; int32_t *ip; uint8_t clientsig[RTMP_SIG_SIZE]; @@ -756,23 +756,23 @@ SHandShake(RTMP * r) getoff *getdh = NULL, *getdig = NULL; if (ReadN(r, (char *)&type, 1) != 1) /* 0x03 or 0x06 */ - return false; + return FALSE; if (ReadN(r, (char *)clientsig, RTMP_SIG_SIZE) != RTMP_SIG_SIZE) - return false; + return FALSE; RTMP_Log(RTMP_LOGDEBUG, "%s: Type Requested : %02X", __FUNCTION__, type); RTMP_LogHex(RTMP_LOGDEBUG2, clientsig, RTMP_SIG_SIZE); if (type == 3) { - encrypted = false; + encrypted = FALSE; } else if (type == 6 || type == 8) { offalg = 1; - encrypted = true; - FP9HandShake = true; + encrypted = TRUE; + FP9HandShake = TRUE; r->Link.protocol |= RTMP_FEATURE_ENC; /* use FP10 if client is capable */ if (clientsig[4] == 128) @@ -782,11 +782,11 @@ SHandShake(RTMP * r) { RTMP_Log(RTMP_LOGERROR, "%s: Unknown version %02x", __FUNCTION__, type); - return false; + return FALSE; } if (!FP9HandShake && clientsig[4]) - FP9HandShake = true; + FP9HandShake = TRUE; serversig[-1] = type; @@ -831,7 +831,7 @@ SHandShake(RTMP * r) { RTMP_Log(RTMP_LOGERROR, "%s: Couldn't initialize Diffie-Hellmann!", __FUNCTION__); - return false; + return FALSE; } dhposServer = getdh(serversig, RTMP_SIG_SIZE); @@ -841,14 +841,14 @@ SHandShake(RTMP * r) { RTMP_Log(RTMP_LOGERROR, "%s: Couldn't generate Diffie-Hellmann public key!", __FUNCTION__); - return false; + return FALSE; } if (!DHGetPublicKey (r->Link.dh, (uint8_t *) &serversig[dhposServer], 128)) { RTMP_Log(RTMP_LOGERROR, "%s: Couldn't write public key!", __FUNCTION__); - return false; + return FALSE; } } @@ -868,7 +868,7 @@ SHandShake(RTMP * r) RTMP_LogHex(RTMP_LOGDEBUG2, serversig, RTMP_SIG_SIZE); if (!WriteN(r, (char *)serversig-1, RTMP_SIG_SIZE + 1)) - return false; + return FALSE; /* decode client response */ memcpy(&uptime, clientsig, 4); @@ -898,7 +898,7 @@ SHandShake(RTMP * r) if (!VerifyDigest(digestPosClient, clientsig, GenuineFPKey, 30)) { RTMP_Log(RTMP_LOGERROR, "Couldn't verify the client digest"); /* continuing anyway will probably fail */ - return false; + return FALSE; } } @@ -934,7 +934,7 @@ SHandShake(RTMP * r) if (len < 0) { RTMP_Log(RTMP_LOGDEBUG, "%s: Wrong secret key position!", __FUNCTION__); - return false; + return FALSE; } RTMP_Log(RTMP_LOGDEBUG, "%s: Secret key: ", __FUNCTION__); @@ -997,11 +997,11 @@ SHandShake(RTMP * r) RTMP_LogHex(RTMP_LOGDEBUG2, clientsig, RTMP_SIG_SIZE); if (!WriteN(r, (char *)clientsig, RTMP_SIG_SIZE)) - return false; + return FALSE; /* 2nd part of handshake */ if (ReadN(r, (char *)clientsig, RTMP_SIG_SIZE) != RTMP_SIG_SIZE) - return false; + return FALSE; RTMP_Log(RTMP_LOGDEBUG2, "%s: 2nd handshake: ", __FUNCTION__); RTMP_LogHex(RTMP_LOGDEBUG2, clientsig, RTMP_SIG_SIZE); @@ -1052,7 +1052,7 @@ SHandShake(RTMP * r) SHA256_DIGEST_LENGTH) != 0) { RTMP_Log(RTMP_LOGWARNING, "%s: Client not genuine Adobe!", __FUNCTION__); - return false; + return FALSE; } else { @@ -1088,5 +1088,5 @@ SHandShake(RTMP * r) } RTMP_Log(RTMP_LOGDEBUG, "%s: Handshaking finished....", __FUNCTION__); - return true; + return TRUE; } Modified: trunk/librtmp/hashswf.c ============================================================================== --- trunk/librtmp/hashswf.c Wed Jun 2 18:15:24 2010 (r502) +++ trunk/librtmp/hashswf.c Wed Jun 2 18:52:55 2010 (r503) @@ -186,7 +186,7 @@ HTTP_get(struct HTTP_ctx *http, const ch } sb.sb_size = 0; - sb.sb_timedout = false; + sb.sb_timedout = FALSE; if (RTMPSockBuf_Fill(&sb) < 1) { ret = HTTPRES_LOST_CONNECTION; Modified: trunk/librtmp/parseurl.c ============================================================================== --- trunk/librtmp/parseurl.c Wed Jun 2 18:15:24 2010 (r502) +++ trunk/librtmp/parseurl.c Wed Jun 2 18:52:55 2010 (r503) @@ -29,7 +29,7 @@ #include "rtmp_sys.h" #include "log.h" -bool RTMP_ParseURL(const char *url, int *protocol, AVal *host, unsigned int *port, +int RTMP_ParseURL(const char *url, int *protocol, AVal *host, unsigned int *port, AVal *playpath, AVal *app) { char *p, *end, *col, *ques, *slash; @@ -49,7 +49,7 @@ bool RTMP_ParseURL(const char *url, int p = strstr(url, "://"); if(!p) { RTMP_Log(RTMP_LOGERROR, "RTMP URL: No :// in url!"); - return false; + return FALSE; } { int len = (int)(p-url); @@ -83,7 +83,7 @@ parsehost: /* check for sudden death */ if(*p==0) { RTMP_Log(RTMP_LOGWARNING, "No hostname in URL!"); - return false; + return FALSE; } end = p + strlen(p); @@ -125,7 +125,7 @@ parsehost: if(!slash) { RTMP_Log(RTMP_LOGWARNING, "No application or playpath in URL!"); - return true; + return TRUE; } p = slash+1; @@ -178,7 +178,7 @@ parsehost: RTMP_ParsePlaypath(&av, playpath); } - return true; + return TRUE; } /* Modified: trunk/librtmp/rtmp.c ============================================================================== --- trunk/librtmp/rtmp.c Wed Jun 2 18:15:24 2010 (r502) +++ trunk/librtmp/rtmp.c Wed Jun 2 18:52:55 2010 (r503) @@ -47,7 +47,7 @@ TLS_CTX RTMP_TLS_ctx; static const int packetSize[] = { 12, 8, 4, 1 }; -bool RTMP_ctrlC; +int RTMP_ctrlC; const char RTMPProtocolStrings[][7] = { "RTMP", @@ -84,24 +84,24 @@ typedef enum { RTMPT_OPEN=0, RTMPT_SEND, RTMPT_IDLE, RTMPT_CLOSE } RTMPTCmd; -static bool DumpMetaData(AMFObject *obj); -static bool HandShake(RTMP *r, bool FP9HandShake); -static bool SocksNegotiate(RTMP *r); +static int DumpMetaData(AMFObject *obj); +static int HandShake(RTMP *r, int FP9HandShake); +static int SocksNegotiate(RTMP *r); -static bool SendConnectPacket(RTMP *r, RTMPPacket *cp); -static bool SendCheckBW(RTMP *r); -static bool SendCheckBWResult(RTMP *r, double txn); -static bool SendDeleteStream(RTMP *r, double dStreamId); -static bool SendFCSubscribe(RTMP *r, AVal *subscribepath); -static bool SendPlay(RTMP *r); -static bool SendBytesReceived(RTMP *r); +static int SendConnectPacket(RTMP *r, RTMPPacket *cp); +static int SendCheckBW(RTMP *r); +static int SendCheckBWResult(RTMP *r, double txn); +static int SendDeleteStream(RTMP *r, double dStreamId); +static int SendFCSubscribe(RTMP *r, AVal *subscribepath); +static int SendPlay(RTMP *r); +static int SendBytesReceived(RTMP *r); #if 0 /* unused */ -static bool SendBGHasStream(RTMP *r, double dId, AVal *playpath); +static int SendBGHasStream(RTMP *r, double dId, AVal *playpath); #endif static int HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize); -static bool HandleMetadata(RTMP *r, char *body, unsigned int len); +static int HandleMetadata(RTMP *r, char *body, unsigned int len); static void HandleChangeChunkSize(RTMP *r, const RTMPPacket *packet); static void HandleAudio(RTMP *r, const RTMPPacket *packet); static void HandleVideo(RTMP *r, const RTMPPacket *packet); @@ -110,7 +110,7 @@ static void HandleServerBW(RTMP *r, cons static void HandleClientBW(RTMP *r, const RTMPPacket *packet); static int ReadN(RTMP *r, char *buffer, int n); -static bool WriteN(RTMP *r, const char *buffer, int n); +static int WriteN(RTMP *r, const char *buffer, int n); static void DecodeTEA(AVal *key, AVal *text); @@ -142,7 +142,7 @@ RTMP_GetTime() void RTMP_UserInterrupt() { - RTMP_ctrlC = true; + RTMP_ctrlC = TRUE; } void @@ -153,20 +153,20 @@ RTMPPacket_Reset(RTMPPacket *p) p->m_nChannel = 0; p->m_nTimeStamp = 0; p->m_nInfoField2 = 0; - p->m_hasAbsTimestamp = false; + p->m_hasAbsTimestamp = FALSE; p->m_nBodySize = 0; p->m_nBytesRead = 0; } -bool +int RTMPPacket_Alloc(RTMPPacket *p, int nSize) { char *ptr = calloc(1, nSize + RTMP_MAX_HEADER_SIZE); if (!ptr) - return false; + return FALSE; p->m_body = ptr + RTMP_MAX_HEADER_SIZE; p->m_nBytesRead = 0; - return true; + return TRUE; } void @@ -271,13 +271,13 @@ RTMP_GetDuration(RTMP *r) return r->m_fDuration; } -bool +int RTMP_IsConnected(RTMP *r) { return r->m_sb.sb_socket != -1; } -bool +int RTMP_IsTimedout(RTMP *r) { return r->m_sb.sb_timedout; @@ -329,7 +329,7 @@ RTMP_SetupStream(RTMP *r, AVal *flashVer, AVal *subscribepath, int dStart, - int dStop, bool bLiveStream, long int timeout) + int dStop, int bLiveStream, long int timeout) { RTMP_Log(RTMP_LOGDEBUG, "Protocol : %s", RTMPProtocolStrings[protocol&7]); RTMP_Log(RTMP_LOGDEBUG, "Hostname : %.*s", host->av_len, host->av_val); @@ -599,7 +599,7 @@ parseAMF(AMFObject *obj, AVal *av, int * return 0; } -bool RTMP_SetOpt(RTMP *r, const AVal *opt, AVal *arg) +int RTMP_SetOpt(RTMP *r, const AVal *opt, AVal *arg) { int i; void *v; @@ -629,7 +629,7 @@ bool RTMP_SetOpt(RTMP *r, const AVal *op break; case OPT_CONN: if (parseAMF(&r->Link.extras, arg, &r->Link.edepth)) - return false; + return FALSE; break; } break; @@ -637,17 +637,17 @@ bool RTMP_SetOpt(RTMP *r, const AVal *op if (!options[i].name.av_len) { RTMP_Log(RTMP_LOGERROR, "Unknown option %s", opt->av_val); RTMP_OptUsage(); - return false; + return FALSE; } - return true; + return TRUE; } -bool RTMP_SetupURL(RTMP *r, char *url) +int RTMP_SetupURL(RTMP *r, char *url) { AVal opt, arg; char *p1, *p2, *ptr = strchr(url, ' '); - bool ret; + int ret; unsigned int port = 0; if (ptr) @@ -684,7 +684,7 @@ bool RTMP_SetupURL(RTMP *r, char *url) if (*p1 == '\\') { unsigned int c; if (port < 3) - return false; + return FALSE; sscanf(p1+1, "%02x", &c); *p2++ = c; port -= 3; @@ -725,14 +725,14 @@ bool RTMP_SetupURL(RTMP *r, char *url) else r->Link.port = 1935; } - return true; + return TRUE; } -static bool +static int add_addr_info(struct sockaddr_in *service, AVal *host, int port) { char *hostname; - bool ret = true; + int ret = TRUE; if (host->av_val[host->av_len]) { hostname = malloc(host->av_len+1); @@ -751,7 +751,7 @@ add_addr_info(struct sockaddr_in *servic if (host == NULL || host->h_addr == NULL) { RTMP_Log(RTMP_LOGERROR, "Problem accessing the DNS. (addr: %s)", hostname); - ret = false; + ret = FALSE; goto finish; } service->sin_addr = *(struct in_addr *)host->h_addr; @@ -764,11 +764,11 @@ finish: return ret; } -bool +int RTMP_Connect0(RTMP *r, struct sockaddr * service) { int on = 1; - r->m_sb.sb_timedout = false; + r->m_sb.sb_timedout = FALSE; r->m_pausing = 0; r->m_fDuration = 0.0; @@ -781,7 +781,7 @@ RTMP_Connect0(RTMP *r, struct sockaddr * RTMP_Log(RTMP_LOGERROR, "%s, failed to connect socket. %d (%s)", __FUNCTION__, err, strerror(err)); RTMP_Close(r); - return false; + return FALSE; } if (r->Link.socksport) @@ -791,7 +791,7 @@ RTMP_Connect0(RTMP *r, struct sockaddr * { RTMP_Log(RTMP_LOGERROR, "%s, SOCKS negotiation failed.", __FUNCTION__); RTMP_Close(r); - return false; + return FALSE; } } } @@ -799,7 +799,7 @@ RTMP_Connect0(RTMP *r, struct sockaddr * { RTMP_Log(RTMP_LOGERROR, "%s, failed to create socket. Error: %d", __FUNCTION__, GetSockError()); - return false; + return FALSE; } /* set timeout */ @@ -815,10 +815,10 @@ RTMP_Connect0(RTMP *r, struct sockaddr * setsockopt(r->m_sb.sb_socket, IPPROTO_TCP, TCP_NODELAY, (char *) &on, sizeof(on)); - return true; + return TRUE; } -bool +int RTMP_Connect1(RTMP *r, RTMPPacket *cp) { if (r->Link.protocol & RTMP_FEATURE_SSL) @@ -830,12 +830,12 @@ RTMP_Connect1(RTMP *r, RTMPPacket *cp) { RTMP_Log(RTMP_LOGERROR, "%s, TLS_Connect failed", __FUNCTION__); RTMP_Close(r); - return false; + return FALSE; } #else RTMP_Log(RTMP_LOGERROR, "%s, no SSL/TLS support", __FUNCTION__); RTMP_Close(r); - return false; + return FALSE; #endif } @@ -849,11 +849,11 @@ RTMP_Connect1(RTMP *r, RTMPPacket *cp) r->m_msgCounter = 0; } RTMP_Log(RTMP_LOGDEBUG, "%s, ... connected, handshaking", __FUNCTION__); - if (!HandShake(r, true)) + if (!HandShake(r, TRUE)) { RTMP_Log(RTMP_LOGERROR, "%s, handshake failed.", __FUNCTION__); RTMP_Close(r); - return false; + return FALSE; } RTMP_Log(RTMP_LOGDEBUG, "%s, handshaked", __FUNCTION__); @@ -861,17 +861,17 @@ RTMP_Connect1(RTMP *r, RTMPPacket *cp) { RTMP_Log(RTMP_LOGERROR, "%s, RTMP connect failed.", __FUNCTION__); RTMP_Close(r); - return false; + return FALSE; } - return true; + return TRUE; } -bool +int RTMP_Connect(RTMP *r, RTMPPacket *cp) { struct sockaddr_in service; if (!r->Link.hostname.av_len) - return false; + return FALSE; memset(&service, 0, sizeof(struct sockaddr_in)); service.sin_family = AF_INET; @@ -880,24 +880,24 @@ RTMP_Connect(RTMP *r, RTMPPacket *cp) { /* Connect via SOCKS */ if (!add_addr_info(&service, &r->Link.sockshost, r->Link.socksport)) - return false; + return FALSE; } else { /* Connect directly */ if (!add_addr_info(&service, &r->Link.hostname, r->Link.port)) - return false; + return FALSE; } if (!RTMP_Connect0(r, (struct sockaddr *)&service)) - return false; + return FALSE; - r->m_bSendCounter = true; + r->m_bSendCounter = TRUE; return RTMP_Connect1(r, cp); } -static bool +static int SocksNegotiate(RTMP *r) { unsigned long addr; @@ -920,21 +920,21 @@ SocksNegotiate(RTMP *r) WriteN(r, packet, sizeof packet); if (ReadN(r, packet, 8) != 8) - return false; + return FALSE; if (packet[0] == 0 && packet[1] == 90) { - return true; + return TRUE; } else { RTMP_Log(RTMP_LOGERROR, "%s, SOCKS returned error code %d", packet[1]); - return false; + return FALSE; } } } -bool +int RTMP_ConnectStream(RTMP *r, int seekTime) { RTMPPacket packet = { 0 }; @@ -970,7 +970,7 @@ RTMP_ConnectStream(RTMP *r, int seekTime return r->m_bPlaying; } -bool +int RTMP_ReconnectStream(RTMP *r, int seekTime) { RTMP_DeleteStream(r); @@ -980,21 +980,21 @@ RTMP_ReconnectStream(RTMP *r, int seekTi return RTMP_ConnectStream(r, seekTime); } -bool +int RTMP_ToggleStream(RTMP *r) { - bool res; + int res; if (!r->m_pausing) { - res = RTMP_SendPause(r, true, r->m_pauseStamp); + res = RTMP_SendPause(r, TRUE, r->m_pauseStamp); if (!res) return res; r->m_pausing = 1; sleep(1); } - res = RTMP_SendPause(r, false, r->m_pauseStamp); + res = RTMP_SendPause(r, FALSE, r->m_pauseStamp); r->m_pausing = 3; return res; } @@ -1005,7 +1005,7 @@ RTMP_DeleteStream(RTMP *r) if (r->m_stream_id < 0) return; - r->m_bPlaying = false; + r->m_bPlaying = FALSE; SendDeleteStream(r, r->m_stream_id); r->m_stream_id = -1; @@ -1049,7 +1049,7 @@ RTMP_GetNextMediaPacket(RTMP *r, RTMPPac } if (bHasMediaPacket) - r->m_bPlaying = true; + r->m_bPlaying = TRUE; else if (r->m_sb.sb_timedout && !r->m_pausing) r->m_pauseStamp = r->m_channelTimestamp[r->m_mediaChannel]; @@ -1224,7 +1224,7 @@ ReadN(RTMP *r, char *buffer, int n) int avail; char *ptr; - r->m_sb.sb_timedout = false; + r->m_sb.sb_timedout = FALSE; #ifdef _DEBUG memset(buffer, 0, n); @@ -1313,7 +1313,7 @@ ReadN(RTMP *r, char *buffer, int n) return nOriginalSize - n; } -static bool +static int WriteN(RTMP *r, const char *buffer, int n) { const char *ptr = buffer; @@ -1390,7 +1390,7 @@ SAVC(secureTokenResponse); SAVC(type); SAVC(nonprivate); -static bool +static int SendConnectPacket(RTMP *r, RTMPPacket *cp) { RTMPPacket packet; @@ -1398,7 +1398,7 @@ SendConnectPacket(RTMP *r, RTMPPacket *c char *enc; if (cp) - return RTMP_SendPacket(r, cp, true); + return RTMP_SendPacket(r, cp, TRUE); packet.m_nChannel = 0x03; /* control channel (invoke) */ packet.m_headerType = RTMP_PACKET_SIZE_LARGE; @@ -1415,63 +1415,63 @@ SendConnectPacket(RTMP *r, RTMPPacket *c enc = AMF_EncodeNamedString(enc, pend, &av_app, &r->Link.app); if (!enc) - return false; + return FALSE; if (r->Link.protocol & RTMP_FEATURE_WRITE) { enc = AMF_EncodeNamedString(enc, pend, &av_type, &av_nonprivate); if (!enc) - return false; + return FALSE; } if (r->Link.flashVer.av_len) { enc = AMF_EncodeNamedString(enc, pend, &av_flashVer, &r->Link.flashVer); if (!enc) - return false; + return FALSE; } if (r->Link.swfUrl.av_len) { enc = AMF_EncodeNamedString(enc, pend, &av_swfUrl, &r->Link.swfUrl); if (!enc) - return false; + return FALSE; } if (r->Link.tcUrl.av_len) { enc = AMF_EncodeNamedString(enc, pend, &av_tcUrl, &r->Link.tcUrl); if (!enc) - return false; + return FALSE; } if (!(r->Link.protocol & RTMP_FEATURE_WRITE)) { - enc = AMF_EncodeNamedBoolean(enc, pend, &av_fpad, false); + enc = AMF_EncodeNamedBoolean(enc, pend, &av_fpad, FALSE); if (!enc) - return false; + return FALSE; enc = AMF_EncodeNamedNumber(enc, pend, &av_capabilities, 15.0); if (!enc) - return false; + return FALSE; enc = AMF_EncodeNamedNumber(enc, pend, &av_audioCodecs, r->m_fAudioCodecs); if (!enc) - return false; + return FALSE; enc = AMF_EncodeNamedNumber(enc, pend, &av_videoCodecs, r->m_fVideoCodecs); if (!enc) - return false; + return FALSE; enc = AMF_EncodeNamedNumber(enc, pend, &av_videoFunction, 1.0); if (!enc) - return false; + return FALSE; if (r->Link.pageUrl.av_len) { enc = AMF_EncodeNamedString(enc, pend, &av_pageUrl, &r->Link.pageUrl); if (!enc) - return false; + return FALSE; } } if (r->m_fEncoding != 0.0 || r->m_bSendEncoding) { /* AMF0, AMF3 not fully supported yet */ enc = AMF_EncodeNamedNumber(enc, pend, &av_objectEncoding, r->m_fEncoding); if (!enc) - return false; + return FALSE; } if (enc + 3 >= pend) - return false; + return FALSE; *enc++ = 0; *enc++ = 0; /* end of object - 0x00 0x00 0x09 */ *enc++ = AMF_OBJECT_END; @@ -1481,10 +1481,10 @@ SendConnectPacket(RTMP *r, RTMPPacket *c { enc = AMF_EncodeBoolean(enc, pend, r->Link.lFlags & RTMP_LF_AUTH); if (!enc) - return false; + return FALSE; enc = AMF_EncodeString(enc, pend, &r->Link.auth); if (!enc) - return false; + return FALSE; } if (r->Link.extras.o_num) { @@ -1493,18 +1493,18 @@ SendConnectPacket(RTMP *r, RTMPPacket *c { enc = AMFProp_Encode(&r->Link.extras.o_props[i], enc, pend); if (!enc) - return false; + return FALSE; } } packet.m_nBodySize = enc - packet.m_body; - return RTMP_SendPacket(r, &packet, true); + return RTMP_SendPacket(r, &packet, TRUE); } #if 0 /* unused */ SAVC(bgHasStream); -static bool +static int SendBGHasStream(RTMP *r, double dId, AVal *playpath) { RTMPPacket packet; @@ -1526,17 +1526,17 @@ SendBGHasStream(RTMP *r, double dId, AVa enc = AMF_EncodeString(enc, pend, playpath); if (enc == NULL) - return false; + return FALSE; packet.m_nBodySize = enc - packet.m_body; - return RTMP_SendPacket(r, &packet, true); + return RTMP_SendPacket(r, &packet, TRUE); } #endif SAVC(createStream); -bool +int RTMP_SendCreateStream(RTMP *r) { RTMPPacket packet; @@ -1558,12 +1558,12 @@ RTMP_SendCreateStream(RTMP *r) packet.m_nBodySize = enc - packet.m_body; - return RTMP_SendPacket(r, &packet, true); + return RTMP_SendPacket(r, &packet, TRUE); } SAVC(FCSubscribe); -static bool +static int SendFCSubscribe(RTMP *r, AVal *subscribepath) { RTMPPacket packet; @@ -1585,16 +1585,16 @@ SendFCSubscribe(RTMP *r, AVal *subscribe enc = AMF_EncodeString(enc, pend, subscribepath); if (!enc) - return false; + return FALSE; packet.m_nBodySize = enc - packet.m_body; - return RTMP_SendPacket(r, &packet, true); + return RTMP_SendPacket(r, &packet, TRUE); } SAVC(releaseStream); -static bool +static int SendReleaseStream(RTMP *r) { RTMPPacket packet; @@ -1615,16 +1615,16 @@ SendReleaseStream(RTMP *r) *enc++ = AMF_NULL; enc = AMF_EncodeString(enc, pend, &r->Link.playpath); if (!enc) - return false; + return FALSE; packet.m_nBodySize = enc - packet.m_body; - return RTMP_SendPacket(r, &packet, false); + return RTMP_SendPacket(r, &packet, FALSE); } SAVC(FCPublish); -static bool +static int SendFCPublish(RTMP *r) { RTMPPacket packet; @@ -1645,16 +1645,16 @@ SendFCPublish(RTMP *r) *enc++ = AMF_NULL; enc = AMF_EncodeString(enc, pend, &r->Link.playpath); if (!enc) - return false; + return FALSE; packet.m_nBodySize = enc - packet.m_body; - return RTMP_SendPacket(r, &packet, false); + return RTMP_SendPacket(r, &packet, FALSE); } SAVC(FCUnpublish); -static bool +static int SendFCUnpublish(RTMP *r) { RTMPPacket packet; @@ -1675,18 +1675,18 @@ SendFCUnpublish(RTMP *r) *enc++ = AMF_NULL; enc = AMF_EncodeString(enc, pend, &r->Link.playpath); if (!enc) - return false; + return FALSE; packet.m_nBodySize = enc - packet.m_body; - return RTMP_SendPacket(r, &packet, false); + return RTMP_SendPacket(r, &packet, FALSE); } SAVC(publish); SAVC(live); SAVC(record); -static bool +static int SendPublish(RTMP *r) { RTMPPacket packet; @@ -1707,21 +1707,21 @@ SendPublish(RTMP *r) *enc++ = AMF_NULL; enc = AMF_EncodeString(enc, pend, &r->Link.playpath); if (!enc) - return false; + return FALSE; /* FIXME: should we choose live based on Link.lFlags & RTMP_LF_LIVE? */ enc = AMF_EncodeString(enc, pend, &av_live); if (!enc) - return false; + return FALSE; packet.m_nBodySize = enc - packet.m_body; - return RTMP_SendPacket(r, &packet, true); + return RTMP_SendPacket(r, &packet, TRUE); } SAVC(deleteStream); -static bool +static int SendDeleteStream(RTMP *r, double dStreamId) { RTMPPacket packet; @@ -1745,13 +1745,13 @@ SendDeleteStream(RTMP *r, double dStream packet.m_nBodySize = enc - packet.m_body; /* no response expected */ - return RTMP_SendPacket(r, &packet, false); + return RTMP_SendPacket(r, &packet, FALSE); } SAVC(pause); -bool -RTMP_SendPause(RTMP *r, bool DoPause, int iTime) +int +RTMP_SendPause(RTMP *r, int DoPause, int iTime) { RTMPPacket packet; char pbuf[256], *pend = pbuf + sizeof(pbuf); @@ -1775,12 +1775,12 @@ RTMP_SendPause(RTMP *r, bool DoPause, in packet.m_nBodySize = enc - packet.m_body; RTMP_Log(RTMP_LOGDEBUG, "%s, %d, pauseTime=%d", __FUNCTION__, DoPause, iTime); - return RTMP_SendPacket(r, &packet, true); + return RTMP_SendPacket(r, &packet, TRUE); } SAVC(seek); -bool +int RTMP_SendSeek(RTMP *r, int iTime) { RTMPPacket packet; @@ -1806,10 +1806,10 @@ RTMP_SendSeek(RTMP *r, int iTime) r->m_read.flags |= RTMP_READ_SEEKING; r->m_read.nResumeTS = 0; - return RTMP_SendPacket(r, &packet, true); + return RTMP_SendPacket(r, &packet, TRUE); } -bool +int RTMP_SendServerBW(RTMP *r) { RTMPPacket packet; @@ -1826,10 +1826,10 @@ RTMP_SendServerBW(RTMP *r) packet.m_nBodySize = 4; AMF_EncodeInt32(packet.m_body, pend, r->m_nServerBW); - return RTMP_SendPacket(r, &packet, false); + return RTMP_SendPacket(r, &packet, FALSE); } -bool +int RTMP_SendClientBW(RTMP *r) { RTMPPacket packet; @@ -1847,10 +1847,10 @@ RTMP_SendClientBW(RTMP *r) AMF_EncodeInt32(packet.m_body, pend, r->m_nClientBW); packet.m_body[4] = r->m_nClientBW2; - return RTMP_SendPacket(r, &packet, false); + return RTMP_SendPacket(r, &packet, FALSE); } -static bool +static int SendBytesReceived(RTMP *r) { RTMPPacket packet; @@ -1870,12 +1870,12 @@ SendBytesReceived(RTMP *r) r->m_nBytesInSent = r->m_nBytesIn; /*RTMP_Log(RTMP_LOGDEBUG, "Send bytes report. 0x%x (%d bytes)", (unsigned int)m_nBytesIn, m_nBytesIn); */ - return RTMP_SendPacket(r, &packet, false); + return RTMP_SendPacket(r, &packet, FALSE); } SAVC(_checkbw); -static bool +static int SendCheckBW(RTMP *r) { RTMPPacket packet; @@ -1898,12 +1898,12 @@ SendCheckBW(RTMP *r) packet.m_nBodySize = enc - packet.m_body; /* triggers _onbwcheck and eventually results in _onbwdone */ - return RTMP_SendPacket(r, &packet, false); + return RTMP_SendPacket(r, &packet, FALSE); } SAVC(_result); -static bool +static int SendCheckBWResult(RTMP *r, double txn) { RTMPPacket packet; @@ -1926,12 +1926,12 @@ SendCheckBWResult(RTMP *r, double txn) packet.m_nBodySize = enc - packet.m_body; - return RTMP_SendPacket(r, &packet, false); + return RTMP_SendPacket(r, &packet, FALSE); } SAVC(play); -static bool +static int SendPlay(RTMP *r) { RTMPPacket packet; @@ -1956,7 +1956,7 @@ SendPlay(RTMP *r) r->Link.playpath.av_val); enc = AMF_EncodeString(enc, pend, &r->Link.playpath); if (!enc) - return false; + return FALSE; /* Optional parameters start and len. * @@ -1976,7 +1976,7 @@ SendPlay(RTMP *r) enc = AMF_EncodeNumber(enc, pend, 0.0); /*-2000.0);*/ /* recorded as default, -2000.0 is not reliable since that freezes the player if the stream is not found */ } if (!enc) - return false; + return FALSE; /* len: -1, 0, positive number * -1: plays live or recorded stream to the end (default) @@ -1988,18 +1988,18 @@ SendPlay(RTMP *r) { enc = AMF_EncodeNumber(enc, pend, r->Link.stopTime - r->Link.seekTime); if (!enc) - return false; + return FALSE; } packet.m_nBodySize = enc - packet.m_body; - return RTMP_SendPacket(r, &packet, true); + return RTMP_SendPacket(r, &packet, TRUE); } SAVC(set_playlist); SAVC(0); -static bool +static int SendPlaylist(RTMP *r) { RTMPPacket packet; @@ -2025,19 +2025,19 @@ SendPlaylist(RTMP *r) *enc++ = AMF_OBJECT; enc = AMF_EncodeNamedString(enc, pend, &av_0, &r->Link.playpath); if (!enc) - return false; + return FALSE; if (enc + 3 >= pend) - return false; + return FALSE; *enc++ = 0; *enc++ = 0; *enc++ = AMF_OBJECT_END; packet.m_nBodySize = enc - packet.m_body; - return RTMP_SendPacket(r, &packet, true); + return RTMP_SendPacket(r, &packet, TRUE); } -static bool +static int SendSecureTokenResponse(RTMP *r, AVal *resp) { RTMPPacket packet; @@ -2058,11 +2058,11 @@ SendSecureTokenResponse(RTMP *r, AVal *r *enc++ = AMF_NULL; enc = AMF_EncodeString(enc, pend, resp); if (!enc) - return false; + return FALSE; packet.m_nBodySize = enc - packet.m_body; - return RTMP_SendPacket(r, &packet, false); + return RTMP_SendPacket(r, &packet, FALSE); } /* @@ -2081,7 +2081,7 @@ The type of Ping packet is 0x4 and conta * type 26: SWFVerification request * type 27: SWFVerification response */ -bool +int RTMP_SendCtrl(RTMP *r, short nType, unsigned int nObject, unsigned int nTime) { RTMPPacket packet; @@ -2132,11 +2132,11 @@ RTMP_SendCtrl(RTMP *r, short nType, unsi buf = AMF_EncodeInt32(buf, pend, nTime); } - return RTMP_SendPacket(r, &packet, false); + return RTMP_SendPacket(r, &packet, FALSE); } static void -AV_erase(RTMP_METHOD *vals, int *num, int i, bool freeit) +AV_erase(RTMP_METHOD *vals, int *num, int i, int freeit) { if (freeit) free(vals[i].name.av_val); @@ -2151,7 +2151,7 @@ AV_erase(RTMP_METHOD *vals, int *num, in } void -RTMP_DropRequest(RTMP *r, int i, bool freeit) +RTMP_DropRequest(RTMP *r, int i, int freeit) { AV_erase(r->m_methodCalls, &r->m_numCalls, i, freeit); } @@ -2220,7 +2220,7 @@ HandleInvoke(RTMP *r, const char *body, return 0; } - nRes = AMF_Decode(&obj, body, nBodySize, false); + nRes = AMF_Decode(&obj, body, nBodySize, FALSE); if (nRes < 0) { RTMP_Log(RTMP_LOGERROR, "%s, error decoding invoke packet", __FUNCTION__); @@ -2240,7 +2240,7 @@ HandleInvoke(RTMP *r, const char *body, for (i=0; i<r->m_numCalls; i++) { if (r->m_methodCalls[i].num == txn) { methodInvoked = r->m_methodCalls[i].name; - AV_erase(r->m_methodCalls, &r->m_numCalls, i, false); + AV_erase(r->m_methodCalls, &r->m_numCalls, i, FALSE); break; } } @@ -2304,7 +2304,7 @@ HandleInvoke(RTMP *r, const char *body, else if (AVMATCH(&methodInvoked, &av_play) || AVMATCH(&methodInvoked, &av_publish)) { - r->m_bPlaying = true; + r->m_bPlaying = TRUE; } free(methodInvoked.av_val); } @@ -2331,7 +2331,7 @@ HandleInvoke(RTMP *r, const char *body, for (i = 0; i < r->m_numCalls; i++) if (AVMATCH(&r->m_methodCalls[i].name, &av__checkbw)) { - AV_erase(r->m_methodCalls, &r->m_numCalls, i, true); + AV_erase(r->m_methodCalls, &r->m_numCalls, i, TRUE); break; } } @@ -2366,12 +2366,12 @@ HandleInvoke(RTMP *r, const char *body, else if (AVMATCH(&code, &av_NetStream_Play_Start)) { int i; - r->m_bPlaying = true; + r->m_bPlaying = TRUE; for (i = 0; i < r->m_numCalls; i++) { if (AVMATCH(&r->m_methodCalls[i].name, &av_play)) { - AV_erase(r->m_methodCalls, &r->m_numCalls, i, true); + AV_erase(r->m_methodCalls, &r->m_numCalls, i, TRUE); break; } } @@ -2380,12 +2380,12 @@ HandleInvoke(RTMP *r, const char *body, else if (AVMATCH(&code, &av_NetStream_Publish_Start)) { int i; - r->m_bPlaying = true; + r->m_bPlaying = TRUE; for (i = 0; i < r->m_numCalls; i++) { if (AVMATCH(&r->m_methodCalls[i].name, &av_publish)) { - AV_erase(r->m_methodCalls, &r->m_numCalls, i, true); + AV_erase(r->m_methodCalls, &r->m_numCalls, i, TRUE); break; } } @@ -2409,7 +2409,7 @@ HandleInvoke(RTMP *r, const char *body, { if (r->m_pausing == 1 || r->m_pausing == 2) { - RTMP_SendPause(r, false, r->m_pauseStamp); + RTMP_SendPause(r, FALSE, r->m_pauseStamp); r->m_pausing = 3; } } @@ -2421,7 +2421,7 @@ HandleInvoke(RTMP *r, const char *body, { if (AVMATCH(&r->m_methodCalls[i].name, &av_set_playlist)) { - AV_erase(r->m_methodCalls, &r->m_numCalls, i, true); + AV_erase(r->m_methodCalls, &r->m_numCalls, i, TRUE); break; } } @@ -2435,7 +2435,7 @@ leave: return ret; } -bool +int RTMP_FindFirstMatchingProperty(AMFObject *obj, const AVal *name, AMFObjectProperty * p) { @@ -2448,20 +2448,20 @@ RTMP_FindFirstMatchingProperty(AMFObject if (AVMATCH(&prop->p_name, name)) { *p = *prop; - return true; + return TRUE; } if (prop->p_type == AMF_OBJECT) { if (RTMP_FindFirstMatchingProperty(&prop->p_vu.p_object, name, p)) - return true; + return TRUE; } } - return false; + return FALSE; } /* Like above, but only check if name is a prefix of property */ -bool +int RTMP_FindPrefixProperty(AMFObject *obj, const AVal *name, AMFObjectProperty * p) { @@ -2474,19 +2474,19 @@ RTMP_FindPrefixProperty(AMFObject *obj, !memcmp(prop->p_name.av_val, name->av_val, name->av_len)) { *p = *prop; - return true; + return TRUE; } if (prop->p_type == AMF_OBJECT) { if (RTMP_FindPrefixProperty(&prop->p_vu.p_object, name, p)) - return true; + return TRUE; } } - return false; + return FALSE; } -static bool +static int DumpMetaData(AMFObject *obj) { AMFObjectProperty *prop; @@ -2533,7 +2533,7 @@ DumpMetaData(AMFObject *obj) DumpMetaData(&prop->p_vu.p_object); } } - return false; + return FALSE; } SAVC(onMetaData); @@ -2541,7 +2541,7 @@ SAVC(duration); SAVC(video); SAVC(audio); -static bool +static int HandleMetadata(RTMP *r, char *body, unsigned int len) { /* allright we get some info here, so parse it and print it */ @@ -2549,13 +2549,13 @@ HandleMetadata(RTMP *r, char *body, unsi AMFObject obj; AVal metastring; - bool ret = false; + int ret = FALSE; - int nRes = AMF_Decode(&obj, body, len, false); + int nRes = AMF_Decode(&obj, body, len, FALSE); if (nRes < 0) { RTMP_Log(RTMP_LOGERROR, "%s, error decoding meta data packet", __FUNCTION__); - return false; + return FALSE; } AMF_Dump(&obj); @@ -2577,7 +2577,7 @@ HandleMetadata(RTMP *r, char *body, unsi r->m_read.dataType |= 1; if (RTMP_FindPrefixProperty(&obj, &av_audio, &prop)) r->m_read.dataType |= 4; - ret = true; + ret = TRUE; } AMF_Reset(&obj); return ret; @@ -2691,12 +2691,12 @@ HandleCtrl(RTMP *r, const RTMPPacket *pa if (!r->m_pausing) { r->m_pauseStamp = r->m_channelTimestamp[r->m_mediaChannel]; - RTMP_SendPause(r, true, r->m_pauseStamp); + RTMP_SendPause(r, TRUE, r->m_pauseStamp); r->m_pausing = 1; } else if (r->m_pausing == 2) { - RTMP_SendPause(r, false, r->m_pauseStamp); + RTMP_SendPause(r, FALSE, r->m_pauseStamp); r->m_pausing = 3; } break; @@ -2781,19 +2781,19 @@ EncodeInt32LE(char *output, int nVal) return 4; } -bool +int RTMP_ReadPacket(RTMP *r, RTMPPacket *packet) { char hbuf[RTMP_MAX_HEADER_SIZE] = { 0 }, *header = hbuf; int nSize, hSize, nToRead, nChunk; - bool didAlloc = false; + int didAlloc = FALSE; RTMP_Log(RTMP_LOGDEBUG2, "%s: fd=%d", __FUNCTION__, r->m_sb.sb_socket); if (ReadN(r, hbuf, 1) == 0) { RTMP_Log(RTMP_LOGERROR, "%s, failed to read RTMP packet header", __FUNCTION__); - return false; + return FALSE; } packet->m_headerType = (hbuf[0] & 0xc0) >> 6; @@ -2805,7 +2805,7 @@ RTMP_ReadPacket(RTMP *r, RTMPPacket *pac { RTMP_Log(RTMP_LOGERROR, "%s, failed to read RTMP packet header 2nd byte", __FUNCTION__); - return false; + return FALSE; } packet->m_nChannel = (unsigned)hbuf[1]; packet->m_nChannel += 64; @@ -2818,7 +2818,7 @@ RTMP_ReadPacket(RTMP *r, RTMPPacket *pac { RTMP_Log(RTMP_LOGERROR, "%s, failed to read RTMP packet header 3nd byte", __FUNCTION__); - return false; + return FALSE; } tmp = (((unsigned)hbuf[2]) << 8) + (unsigned)hbuf[1]; packet->m_nChannel = tmp + 64; @@ -2829,7 +2829,7 @@ RTMP_ReadPacket(RTMP *r, RTMPPacket *pac nSize = packetSize[packet->m_headerType]; if (nSize == RTMP_LARGE_HEADER_SIZE) /* if we get a full header the timestamp is absolute */ - packet->m_hasAbsTimestamp = true; + packet->m_hasAbsTimestamp = TRUE; else if (nSize < RTMP_LARGE_HEADER_SIZE) { /* using values from the last message of this channel */ @@ -2844,7 +2844,7 @@ RTMP_ReadPacket(RTMP *r, RTMPPacket *pac { RTMP_Log(RTMP_LOGERROR, "%s, failed to read RTMP packet header. type: %x", __FUNCTION__, (unsigned int)hbuf[0]); - return false; + return FALSE; } hSize = nSize + (header - hbuf); @@ -2875,7 +2875,7 @@ RTMP_ReadPacket(RTMP *r, RTMPPacket *pac { RTMP_Log(RTMP_LOGERROR, "%s, failed to read extended timestamp", __FUNCTION__); - return false; + return FALSE; } packet->m_nTimeStamp = AMF_DecodeInt32(header + nSize); hSize += 4; @@ -2889,9 +2889,9 @@ RTMP_ReadPacket(RTMP *r, RTMPPacket *pac if (!RTMPPacket_Alloc(packet, packet->m_nBodySize)) { RTMP_Log(RTMP_LOGDEBUG, "%s, failed to allocate packet", __FUNCTION__); - return false; + return FALSE; } - didAlloc = true; + didAlloc = TRUE; packet->m_headerType = (hbuf[0] & 0xc0) >> 6; } @@ -2913,7 +2913,7 @@ RTMP_ReadPacket(RTMP *r, RTMPPacket *pac { RTMP_Log(RTMP_LOGERROR, "%s, failed to read RTMP packet body. len: %lu", __FUNCTION__, packet->m_nBodySize); - return false; + return FALSE; } RTMP_LogHexString(RTMP_LOGDEBUG2, (uint8_t *)packet->m_body + packet->m_nBytesRead, nChunk); @@ -2937,23 +2937,23 @@ RTMP_ReadPacket(RTMP *r, RTMPPacket *pac /* arrives and requests to re-use some info (small packet header) */ r->m_vecChannelsIn[packet->m_nChannel]->m_body = NULL; r->m_vecChannelsIn[packet->m_nChannel]->m_nBytesRead = 0; - r->m_vecChannelsIn[packet->m_nChannel]->m_hasAbsTimestamp = false; /* can only be false if we reuse header */ + r->m_vecChannelsIn[packet->m_nChannel]->m_hasAbsTimestamp = FALSE; /* can only be false if we reuse header */ } else { packet->m_body = NULL; /* so it won't be erased on free */ } - return true; + return TRUE; } #ifndef CRYPTO -static bool -HandShake(RTMP *r, bool FP9HandShake) +static int +HandShake(RTMP *r, int FP9HandShake) { int i; uint32_t uptime, suptime; - bool bMatch; + int bMatch; char type; char clientbuf[RTMP_SIG_SIZE + 1], *clientsig = clientbuf + 1; char serversig[RTMP_SIG_SIZE]; @@ -2974,10 +2974,10 @@ HandShake(RTMP *r, bool FP9HandShake) #endif if (!WriteN(r, clientbuf, RTMP_SIG_SIZE + 1)) - return false; + return FALSE; if (ReadN(r, &type, 1) != 1) /* 0x03 or 0x06 */ - return false; + return FALSE; RTMP_Log(RTMP_LOGDEBUG, "%s: Type Answer : %02X", __FUNCTION__, type); @@ -2986,7 +2986,7 @@ HandShake(RTMP *r, bool FP9HandShake) __FUNCTION__, clientbuf[0], type); if (ReadN(r, serversig, RTMP_SIG_SIZE) != RTMP_SIG_SIZE) - return false; + return FALSE; /* decode server response */ @@ -2999,30 +2999,30 @@ HandShake(RTMP *r, bool FP9HandShake) /* 2nd part of handshake */ if (!WriteN(r, serversig, RTMP_SIG_SIZE)) - return false; + return FALSE; if (ReadN(r, serversig, RTMP_SIG_SIZE) != RTMP_SIG_SIZE) - return false; + return FALSE; bMatch = (memcmp(serversig, clientsig, RTMP_SIG_SIZE) == 0); if (!bMatch) { RTMP_Log(RTMP_LOGWARNING, "%s, client signature does not match!", __FUNCTION__); } - return true; + return TRUE; } -static bool +static int SHandShake(RTMP *r) { int i; char serverbuf[RTMP_SIG_SIZE + 1], *serversig = serverbuf + 1; char clientsig[RTMP_SIG_SIZE]; uint32_t uptime; - bool bMatch; + int bMatch; if (ReadN(r, serverbuf, 1) != 1) /* 0x03 or 0x06 */ - return false; + return FALSE; RTMP_Log(RTMP_LOGDEBUG, "%s: Type Request : %02X", __FUNCTION__, serverbuf[0]); @@ -3030,7 +3030,7 @@ SHandShake(RTMP *r) { RTMP_Log(RTMP_LOGERROR, "%s: Type unknown: client sent %02X", __FUNCTION__, serverbuf[0]); - return false; + return FALSE; } uptime = htonl(RTMP_GetTime()); @@ -3046,10 +3046,10 @@ SHandShake(RTMP *r) #endif if (!WriteN(r, serverbuf, RTMP_SIG_SIZE + 1)) - return false; + return FALSE; if (ReadN(r, clientsig, RTMP_SIG_SIZE) != RTMP_SIG_SIZE) - return false; + return FALSE; /* decode client response */ @@ -3062,24 +3062,24 @@ SHandShake(RTMP *r) /* 2nd part of handshake */ if (!WriteN(r, clientsig, RTMP_SIG_SIZE)) - return false; + return FALSE; if (ReadN(r, clientsig, RTMP_SIG_SIZE) != RTMP_SIG_SIZE) - return false; + return FALSE; bMatch = (memcmp(serversig, clientsig, RTMP_SIG_SIZE) == 0); if (!bMatch) { RTMP_Log(RTMP_LOGWARNING, "%s, client signature does not match!", __FUNCTION__); } - return true; + return TRUE; } #endif -bool +int RTMP_SendChunk(RTMP *r, RTMPChunk *chunk) { - bool wrote; + int wrote; char hbuf[RTMP_MAX_HEADER_SIZE]; RTMP_Log(RTMP_LOGDEBUG2, "%s: fd=%d, size=%d", __FUNCTION__, r->m_sb.sb_socket, @@ -3100,8 +3100,8 @@ RTMP_SendChunk(RTMP *r, RTMPChunk *chunk return wrote; } -bool -RTMP_SendPacket(RTMP *r, RTMPPacket *packet, bool queue) +int +RTMP_SendPacket(RTMP *r, RTMPPacket *packet, int queue) { const RTMPPacket *prevPacket = r->m_vecChannelsOut[packet->m_nChannel]; uint32_t last = 0; @@ -3131,7 +3131,7 @@ RTMP_SendPacket(RTMP *r, RTMPPacket *pac { RTMP_Log(RTMP_LOGERROR, "sanity failed!! trying to send header of type: 0x%02x.", (unsigned char)packet->m_headerType); - return false; + return FALSE; } nSize = packetSize[packet->m_headerType]; @@ -3219,7 +3219,7 @@ RTMP_SendPacket(RTMP *r, RTMPPacket *pac tlen = chunks * (cSize + 1) + nSize + hSize; tbuf = malloc(tlen); if (!tbuf) - return false; + return FALSE; toff = tbuf; } } @@ -3241,7 +3241,7 @@ RTMP_SendPacket(RTMP *r, RTMPPacket *pac { wrote = WriteN(r, header, nChunkSize + hSize); if (!wrote) - return false; + return FALSE; } nSize -= nChunkSize; buffer += nChunkSize; @@ -3272,7 +3272,7 @@ RTMP_SendPacket(RTMP *r, RTMPPacket *pac free(tbuf); tbuf = NULL; if (!wrote) - return false; + return FALSE; } /* we invoked a remote method */ @@ -3295,10 +3295,10 @@ RTMP_SendPacket(RTMP *r, RTMPPacket *pac if (!r->m_vecChannelsOut[packet->m_nChannel]) r->m_vecChannelsOut[packet->m_nChannel] = malloc(sizeof(RTMPPacket)); memcpy(r->m_vecChannelsOut[packet->m_nChannel], packet, sizeof(RTMPPacket)); - return true; + return TRUE; } -bool +int RTMP_Serve(RTMP *r) { return SHandShake(r); @@ -3366,7 +3366,7 @@ RTMP_Close(RTMP *r) r->m_numCalls = 0; r->m_numInvokes = 0; - r->m_bPlaying = false; + r->m_bPlaying = FALSE; r->m_sb.sb_size = 0; r->m_msgCounter = 0; @@ -3430,7 +3430,7 @@ RTMPSockBuf_Fill(RTMPSockBuf *sb) if (sockerr == EWOULDBLOCK || sockerr == EAGAIN) { - sb->sb_timedout = true; + sb->sb_timedout = TRUE; nBytes = 0; } } @@ -3627,7 +3627,7 @@ Read_1_Packet(RTMP *r, char *buf, unsign uint32_t prevTagSize = 0; int rtnGetNextMediaPacket = 0, ret = RTMP_READ_EOF; RTMPPacket packet = { 0 }; - bool recopy = false; + int recopy = FALSE; unsigned int size; char *ptr, *pend; uint32_t nTimeStamp = 0; @@ -3692,7 +3692,7 @@ Read_1_Packet(RTMP *r, char *buf, unsign { AMFObject metaObj; int nRes = - AMF_Decode(&metaObj, packetBody, nPacketLen, false); + AMF_Decode(&metaObj, packetBody, nPacketLen, FALSE); if (nRes >= 0) { AVal metastring; @@ -3926,7 +3926,7 @@ Read_1_Packet(RTMP *r, char *buf, unsign ret = RTMP_READ_ERROR; /* fatal error */ break; } - recopy = true; + recopy = TRUE; ptr = r->m_read.buf; } else @@ -4258,7 +4258,7 @@ RTMP_Write(RTMP *r, const char *buf, int if (!RTMPPacket_Alloc(pkt, pkt->m_nBodySize)) { RTMP_Log(RTMP_LOGDEBUG, "%s, failed to allocate packet", __FUNCTION__); - return false; + return FALSE; } enc = pkt->m_body; pend = enc + pkt->m_nBodySize; @@ -4281,7 +4281,7 @@ RTMP_Write(RTMP *r, const char *buf, int buf += num; if (pkt->m_nBytesRead == pkt->m_nBodySize) { - ret = RTMP_SendPacket(r, pkt, false); + ret = RTMP_SendPacket(r, pkt, FALSE); RTMPPacket_Free(pkt); pkt->m_nBytesRead = 0; if (!ret) Modified: trunk/librtmp/rtmp.h ============================================================================== --- trunk/librtmp/rtmp.h Wed Jun 2 18:15:24 2010 (r502) +++ trunk/librtmp/rtmp.h Wed Jun 2 18:52:55 2010 (r503) @@ -66,7 +66,7 @@ extern "C" extern const char RTMPProtocolStringsLower[][7]; extern const AVal RTMP_DefaultFlashVer; - extern bool RTMP_ctrlC; + extern int RTMP_ctrlC; uint32_t RTMP_GetTime(void); @@ -109,13 +109,13 @@ extern "C" int sb_size; /* number of unprocessed bytes in buffer */ char *sb_start; /* pointer into sb_pBuffer of next byte to process */ char sb_buf[RTMP_BUFFER_CACHE_SIZE]; /* data read from socket */ - bool sb_timedout; + int sb_timedout; void *sb_ssl; } RTMPSockBuf; void RTMPPacket_Reset(RTMPPacket *p); void RTMPPacket_Dump(RTMPPacket *p); - bool RTMPPacket_Alloc(RTMPPacket *p, int nSize); + int RTMPPacket_Alloc(RTMPPacket *p, int nSize); void RTMPPacket_Free(RTMPPacket *p); #define RTMPPacket_IsReady(a) ((a)->m_nBytesRead == (a)->m_nBodySize) @@ -252,15 +252,15 @@ extern "C" RTMP_LNK Link; } RTMP; - bool RTMP_ParseURL(const char *url, int *protocol, AVal *host, + int RTMP_ParseURL(const char *url, int *protocol, AVal *host, unsigned int *port, AVal *playpath, AVal *app); void RTMP_ParsePlaypath(AVal *in, AVal *out); void RTMP_SetBufferMS(RTMP *r, int size); void RTMP_UpdateBufferMS(RTMP *r); - bool RTMP_SetOpt(RTMP *r, const AVal *opt, AVal *arg); - bool RTMP_SetupURL(RTMP *r, char *url); + int RTMP_SetOpt(RTMP *r, const AVal *opt, AVal *arg); + int RTMP_SetupURL(RTMP *r, char *url); void RTMP_SetupStream(RTMP *r, int protocol, AVal *hostname, unsigned int port, @@ -276,24 +276,24 @@ extern "C" AVal *flashVer, AVal *subscribepath, int dStart, - int dStop, bool bLiveStream, long int timeout); + int dStop, int bLiveStream, long int timeout); - bool RTMP_Connect(RTMP *r, RTMPPacket *cp); + int RTMP_Connect(RTMP *r, RTMPPacket *cp); struct sockaddr; - bool RTMP_Connect0(RTMP *r, struct sockaddr *svc); - bool RTMP_Connect1(RTMP *r, RTMPPacket *cp); - bool RTMP_Serve(RTMP *r); + int RTMP_Connect0(RTMP *r, struct sockaddr *svc); + int RTMP_Connect1(RTMP *r, RTMPPacket *cp); + int RTMP_Serve(RTMP *r); - bool RTMP_ReadPacket(RTMP *r, RTMPPacket *packet); - bool RTMP_SendPacket(RTMP *r, RTMPPacket *packet, bool queue); - bool RTMP_SendChunk(RTMP *r, RTMPChunk *chunk); - bool RTMP_IsConnected(RTMP *r); - bool RTMP_IsTimedout(RTMP *r); + int RTMP_ReadPacket(RTMP *r, RTMPPacket *packet); + int RTMP_SendPacket(RTMP *r, RTMPPacket *packet, int queue); + int RTMP_SendChunk(RTMP *r, RTMPChunk *chunk); + int RTMP_IsConnected(RTMP *r); + int RTMP_IsTimedout(RTMP *r); double RTMP_GetDuration(RTMP *r); - bool RTMP_ToggleStream(RTMP *r); + int RTMP_ToggleStream(RTMP *r); - bool RTMP_ConnectStream(RTMP *r, int seekTime); - bool RTMP_ReconnectStream(RTMP *r, int seekTime); + int RTMP_ConnectStream(RTMP *r, int seekTime); + int RTMP_ReconnectStream(RTMP *r, int seekTime); void RTMP_DeleteStream(RTMP *r); int RTMP_GetNextMediaPacket(RTMP *r, RTMPPacket *packet); int RTMP_ClientPacket(RTMP *r, RTMPPacket *packet); @@ -307,21 +307,21 @@ extern "C" int RTMP_LibVersion(void); void RTMP_UserInterrupt(void); /* user typed Ctrl-C */ - bool RTMP_SendCtrl(RTMP *r, short nType, unsigned int nObject, + int RTMP_SendCtrl(RTMP *r, short nType, unsigned int nObject, unsigned int nTime); - bool RTMP_SendPause(RTMP *r, bool DoPause, int dTime); - bool RTMP_FindFirstMatchingProperty(AMFObject *obj, const AVal *name, + int RTMP_SendPause(RTMP *r, int DoPause, int dTime); + int RTMP_FindFirstMatchingProperty(AMFObject *obj, const AVal *name, AMFObjectProperty * p); int RTMPSockBuf_Fill(RTMPSockBuf *sb); int RTMPSockBuf_Send(RTMPSockBuf *sb, const char *buf, int len); int RTMPSockBuf_Close(RTMPSockBuf *sb); - bool RTMP_SendCreateStream(RTMP *r); - bool RTMP_SendSeek(RTMP *r, int dTime); - bool RTMP_SendServerBW(RTMP *r); - bool RTMP_SendClientBW(RTMP *r); - void RTMP_DropRequest(RTMP *r, int i, bool freeit); + int RTMP_SendCreateStream(RTMP *r); + int RTMP_SendSeek(RTMP *r, int dTime); + int RTMP_SendServerBW(RTMP *r); + int RTMP_SendClientBW(RTMP *r); + void RTMP_DropRequest(RTMP *r, int i, int freeit); int RTMP_Read(RTMP *r, char *buf, int size); int RTMP_Write(RTMP *r, const char *buf, int size); Modified: trunk/librtmp/rtmp_sys.h ============================================================================== --- trunk/librtmp/rtmp_sys.h Wed Jun 2 18:15:24 2010 (r502) +++ trunk/librtmp/rtmp_sys.h Wed Jun 2 18:52:55 2010 (r503) @@ -60,6 +60,12 @@ #define SET_RCVTIMEO(tv,s) struct timeval tv = {s,0} #endif +/* macros for people who don't understand C */ +#undef TRUE +#undef FALSE +#define TRUE 1 +#define FALSE 0 + #include "rtmp.h" #ifdef USE_POLARSSL Modified: trunk/rtmpdump.c ============================================================================== --- trunk/rtmpdump.c Wed Jun 2 18:15:24 2010 (r502) +++ trunk/rtmpdump.c Wed Jun 2 18:52:55 2010 (r503) @@ -51,7 +51,7 @@ #define DEF_SKIPFRM 0 // starts sockets -bool +int InitSockets() { #ifdef WIN32 @@ -61,7 +61,7 @@ InitSockets() version = MAKEWORD(1, 1); return (WSAStartup(version, &wsaData) == 0); #else - return true; + return TRUE; #endif } @@ -90,7 +90,7 @@ FILE *file = 0; void sigIntHandler(int sig) { - RTMP_ctrlC = true; + RTMP_ctrlC = TRUE; RTMP_LogPrintf("Caught signal: %d, cleaning up, just a second...\n", sig); // ignore all these signals now and let the connection close signal(SIGINT, SIG_IGN); @@ -193,7 +193,7 @@ OpenResumeFile(const char *flvFile, // f // go through the file to find the meta data! off_t pos = dataOffset + 4; - bool bFoundMetaHeader = false; + int bFoundMetaHeader = FALSE; while (pos < *size - 4 && !bFoundMetaHeader) { @@ -221,7 +221,7 @@ OpenResumeFile(const char *flvFile, // f break; AMFObject metaObj; - int nRes = AMF_Decode(&metaObj, buffer, dataSize, false); + int nRes = AMF_Decode(&metaObj, buffer, dataSize, FALSE); if (nRes < 0) { RTMP_Log(RTMP_LOGERROR, "%s, error decoding meta data packet", @@ -251,7 +251,7 @@ OpenResumeFile(const char *flvFile, // f RTMP_Log(RTMP_LOGDEBUG, "File has duration: %f", *duration); } - bFoundMetaHeader = true; + bFoundMetaHeader = TRUE; break; } //metaObj.Reset(); @@ -279,7 +279,7 @@ GetLastKeyframe(FILE * file, // output f const size_t bufferSize = 16; char buffer[bufferSize]; uint8_t dataType; - bool bAudioOnly; + int bAudioOnly; off_t size; fseek(file, 0, SEEK_END); @@ -429,7 +429,7 @@ GetLastKeyframe(FILE * file, // output f // make sure the WriteStream doesn't write headers and ignores all the 0ms TS packets // (including several meta data headers and the keyframe we seeked to) - //bNoHeader = true; if bResume==true this is true anyway + //bNoHeader = TRUE; if bResume==true this is true anyway } //} @@ -439,7 +439,7 @@ GetLastKeyframe(FILE * file, // output f int Download(RTMP * rtmp, // connected RTMP object - FILE * file, uint32_t dSeek, uint32_t dStopOffset, double duration, bool bResume, char *metaHeader, uint32_t nMetaHeaderSize, char *initialFrame, int initialFrameType, uint32_t nInitialFrameSize, int nSkipKeyFrames, bool bStdoutMode, bool bLiveStream, bool bHashes, bool bOverrideBufferTime, uint32_t bufferTime, double *percent) // percentage downloaded [out] + FILE * file, uint32_t dSeek, uint32_t dStopOffset, double duration, int bResume, char *metaHeader, uint32_t nMetaHeaderSize, char *initialFrame, int initialFrameType, uint32_t nInitialFrameSize, int nSkipKeyFrames, int bStdoutMode, int bLiveStream, int bHashes, int bOverrideBufferTime, uint32_t bufferTime, double *percent) // percentage downloaded [out] { int32_t now, lastUpdate; int bufferSize = 64 * 1024; @@ -718,9 +718,9 @@ main(int argc, char **argv) int nSkipKeyFrames = DEF_SKIPFRM; // skip this number of keyframes when resuming - bool bOverrideBufferTime = false; // if the user specifies a buffer time override this is true - bool bStdoutMode = true; // if true print the stream directly to stdout, messages go to stderr - bool bResume = false; // true in resume mode + int bOverrideBufferTime = FALSE; // if the user specifies a buffer time override this is true + int bStdoutMode = TRUE; // if true print the stream directly to stdout, messages go to stderr + int bResume = FALSE; // true in resume mode uint32_t dSeek = 0; // seek position in resume mode, 0 otherwise uint32_t bufferTime = DEF_BUFTIME; @@ -740,8 +740,8 @@ main(int argc, char **argv) int port = -1; int protocol = RTMP_PROTOCOL_UNDEFINED; int retries = 0; - bool bLiveStream = false; // is it a live stream? then we can't seek/resume - bool bHashes = false; // display byte counters not hashes by default + int bLiveStream = FALSE; // is it a live stream? then we can't seek/resume + int bHashes = FALSE; // display byte counters not hashes by default long int timeout = DEF_TIMEOUT; // timeout connection after 120 seconds uint32_t dStartOffset = 0; // seek position in non-live mode @@ -921,12 +921,12 @@ main(int argc, char **argv) else { bufferTime = bt; - bOverrideBufferTime = true; + bOverrideBufferTime = TRUE; } break; } case 'v': - bLiveStream = true; // no seeking or resuming possible! + bLiveStream = TRUE; // no seeking or resuming possible! break; case 'd': STR2AVAL(subscribepath, optarg); @@ -1001,11 +1001,11 @@ main(int argc, char **argv) case 'o': flvFile = optarg; if (strcmp(flvFile, "-")) - bStdoutMode = false; + bStdoutMode = FALSE; break; case 'e': - bResume = true; + bResume = TRUE; break; case 'u': STR2AVAL(auth, optarg); @@ -1036,7 +1036,7 @@ main(int argc, char **argv) } break; case '#': - bHashes = true; + bHashes = TRUE; break; case 'q': RTMP_debuglevel = RTMP_LOGCRIT; @@ -1097,20 +1097,20 @@ main(int argc, char **argv) { RTMP_Log(RTMP_LOGWARNING, "You haven't specified an output file (-o filename), using stdout"); - bStdoutMode = true; + bStdoutMode = TRUE; } if (bStdoutMode && bResume) { RTMP_Log(RTMP_LOGWARNING, "Can't resume in stdout mode, ignoring --resume option"); - bResume = false; + bResume = FALSE; } if (bLiveStream && bResume) { RTMP_Log(RTMP_LOGWARNING, "Can't resume live stream, ignoring --resume option"); - bResume = false; + bResume = FALSE; } #ifdef CRYPTO @@ -1186,7 +1186,7 @@ main(int argc, char **argv) if (!file) { // file does not exist, so go back into normal mode - bResume = false; // we are back in fresh file mode (otherwise finalizing file won't be done) + bResume = FALSE; // we are back in fresh file mode (otherwise finalizing file won't be done) } else { @@ -1203,7 +1203,7 @@ main(int argc, char **argv) { RTMP_Log(RTMP_LOGDEBUG, "Last keyframe is first frame in stream, switching from resume to normal mode!"); - bResume = false; + bResume = FALSE; } } } @@ -1331,7 +1331,7 @@ main(int argc, char **argv) nStatus = RD_INCOMPLETE; break; } - bResume = true; + bResume = TRUE; } nStatus = Download(&rtmp, file, dSeek, dStopOffset, duration, bResume, Modified: trunk/rtmpgw.c ============================================================================== --- trunk/rtmpgw.c Wed Jun 2 18:15:24 2010 (r502) +++ trunk/rtmpgw.c Wed Jun 2 18:52:55 2010 (r503) @@ -78,7 +78,7 @@ typedef struct AVal hostname; int rtmpport; int protocol; - bool bLiveStream; // is it a live stream? then we can't seek/resume + int bLiveStream; // is it a live stream? then we can't seek/resume long int timeout; // timeout connection after 120 seconds uint32_t bufferTime; @@ -207,7 +207,7 @@ parseAMF(AMFObject *obj, const char *arg * parameters in the GET request. */ RTMP_REQUEST defaultRTMPRequest; -bool ParseOption(char opt, char *arg, RTMP_REQUEST * req); +int ParseOption(char opt, char *arg, RTMP_REQUEST * req); #ifdef _DEBUG uint32_t debugTS = 0; @@ -310,15 +310,15 @@ ssize_t readHTTPLine(int sockfd, char *b return i; } -bool isHTTPRequestEOF(char *line, size_t length) +int isHTTPRequestEOF(char *line, size_t length) { if(length < 2) - return true; + return TRUE; if(line[0]=='\r' && line[1]=='\n') - return true; + return TRUE; - return false; + return FALSE; } */ @@ -746,7 +746,7 @@ stopStreaming(STREAMING_SERVER * server) void sigIntHandler(int sig) { - RTMP_ctrlC = true; + RTMP_ctrlC = TRUE; RTMP_LogPrintf("Caught signal: %d, cleaning up, just a second...\n", sig); if (httpServer) stopStreaming(httpServer); @@ -777,7 +777,7 @@ int hex2bin(char *str, char **hex) // Return values: true (option parsing ok) // false (option not parsed/invalid) -bool +int ParseOption(char opt, char *arg, RTMP_REQUEST * req) { switch (opt) @@ -844,7 +844,7 @@ ParseOption(char opt, char *arg, RTMP_RE break; } case 'v': - req->bLiveStream = true; // no seeking or resuming possible! + req->bLiveStream = TRUE; // no seeking or resuming possible! break; case 'd': STR2AVAL(req->subscribepath, arg); @@ -862,7 +862,7 @@ ParseOption(char opt, char *arg, RTMP_RE { RTMP_Log(RTMP_LOGERROR, "Unknown protocol specified: %d, using default", protocol); - return false; + return FALSE; } else { @@ -954,9 +954,9 @@ ParseOption(char opt, char *arg, RTMP_RE break; default: RTMP_LogPrintf("unknown option: %c, arg: %s\n", opt, arg); - return false; + return FALSE; } - return true; + return TRUE; } int @@ -978,7 +978,7 @@ main(int argc, char **argv) defaultRTMPRequest.rtmpport = -1; defaultRTMPRequest.protocol = RTMP_PROTOCOL_UNDEFINED; - defaultRTMPRequest.bLiveStream = false; // is it a live stream? then we can't seek/resume + defaultRTMPRequest.bLiveStream = FALSE; // is it a live stream? then we can't seek/resume defaultRTMPRequest.timeout = 120; // timeout connection after 120 seconds defaultRTMPRequest.bufferTime = 20 * 1000; Modified: trunk/rtmpsrv.c ============================================================================== --- trunk/rtmpsrv.c Wed Jun 2 18:15:24 2010 (r502) +++ trunk/rtmpsrv.c Wed Jun 2 18:52:55 2010 (r503) @@ -96,7 +96,7 @@ typedef struct char *hostname; int rtmpport; int protocol; - bool bLiveStream; // is it a live stream? then we can't seek/resume + int bLiveStream; // is it a live stream? then we can't seek/resume long int timeout; // timeout connection afte 300 seconds uint32_t bufferTime; @@ -159,7 +159,7 @@ SAVC(code); SAVC(description); SAVC(secureToken); -static bool +static int SendConnectResult(RTMP *r, double txn) { RTMPPacket packet; @@ -220,10 +220,10 @@ SendConnectResult(RTMP *r, double txn) packet.m_nBodySize = enc - packet.m_body; - return RTMP_SendPacket(r, &packet, false); + return RTMP_SendPacket(r, &packet, FALSE); } -static bool +static int SendResultNumber(RTMP *r, double txn, double ID) { RTMPPacket packet; @@ -245,7 +245,7 @@ SendResultNumber(RTMP *r, double txn, do packet.m_nBodySize = enc - packet.m_body; - return RTMP_SendPacket(r, &packet, false); + return RTMP_SendPacket(r, &packet, FALSE); } SAVC(onStatus); @@ -257,7 +257,7 @@ static const AVal av_Stopped_playing = A SAVC(details); SAVC(clientid); -static bool +static int SendPlayStart(RTMP *r) { RTMPPacket packet; @@ -286,10 +286,10 @@ SendPlayStart(RTMP *r) *enc++ = AMF_OBJECT_END; packet.m_nBodySize = enc - packet.m_body; - return RTMP_SendPacket(r, &packet, false); + return RTMP_SendPacket(r, &packet, FALSE); } -static bool +static int SendPlayStop(RTMP *r) { RTMPPacket packet; @@ -318,7 +318,7 @@ SendPlayStop(RTMP *r) *enc++ = AMF_OBJECT_END; packet.m_nBodySize = enc - packet.m_body; - return RTMP_SendPacket(r, &packet, false); + return RTMP_SendPacket(r, &packet, FALSE); } static void @@ -470,7 +470,7 @@ ServeInvoke(STREAMING_SERVER *server, RT } AMFObject obj; - nRes = AMF_Decode(&obj, body, nBodySize, false); + nRes = AMF_Decode(&obj, body, nBodySize, FALSE); if (nRes < 0) { RTMP_Log(RTMP_LOGERROR, "%s, error decoding invoke packet", __FUNCTION__); @@ -1012,7 +1012,7 @@ stopStreaming(STREAMING_SERVER * server) void sigIntHandler(int sig) { - RTMP_ctrlC = true; + RTMP_ctrlC = TRUE; RTMP_LogPrintf("Caught signal: %d, cleaning up, just a second...\n", sig); if (rtmpServer) stopStreaming(rtmpServer); @@ -1043,7 +1043,7 @@ main(int argc, char **argv) defaultRTMPRequest.rtmpport = -1; defaultRTMPRequest.protocol = RTMP_PROTOCOL_UNDEFINED; - defaultRTMPRequest.bLiveStream = false; // is it a live stream? then we can't seek/resume + defaultRTMPRequest.bLiveStream = FALSE; // is it a live stream? then we can't seek/resume defaultRTMPRequest.timeout = 300; // timeout connection afte 300 seconds defaultRTMPRequest.bufferTime = 20 * 1000; Modified: trunk/rtmpsuck.c ============================================================================== --- trunk/rtmpsuck.c Wed Jun 2 18:15:24 2010 (r502) +++ trunk/rtmpsuck.c Wed Jun 2 18:52:55 2010 (r503) @@ -170,7 +170,7 @@ ServeInvoke(STREAMING_SERVER *server, in } AMFObject obj; - nRes = AMF_Decode(&obj, body, nBodySize, false); + nRes = AMF_Decode(&obj, body, nBodySize, FALSE); if (nRes < 0) { RTMP_Log(RTMP_LOGERROR, "%s, error decoding invoke packet", __FUNCTION__); @@ -280,7 +280,7 @@ ServeInvoke(STREAMING_SERVER *server, in else if (AVMATCH(&pname, &av_objectEncoding)) { server->rc.m_fEncoding = cobj.o_props[i].p_vu.p_number; - server->rc.m_bSendEncoding = true; + server->rc.m_bSendEncoding = TRUE; } /* Dup'd a string we didn't recognize? */ if (pval.av_val) @@ -301,7 +301,7 @@ ServeInvoke(STREAMING_SERVER *server, in /* failed */ return 1; } - server->rc.m_bSendCounter = false; + server->rc.m_bSendCounter = FALSE; } else if (AVMATCH(&method, &av_play)) { @@ -426,7 +426,7 @@ ServeInvoke(STREAMING_SERVER *server, in for (server->f_cur = server->f_head; server->f_cur && !server->f_cur->f_file; server->f_cur = server->f_cur->f_next) ; } - server->rc.m_bPlaying = true; + server->rc.m_bPlaying = TRUE; } // Return 1 if this is a Play.Complete or Play.Stop @@ -725,7 +725,7 @@ void doServe(STREAMING_SERVER * server, RTMPChunk rk = { 0 }; char *buf = NULL; unsigned int buflen = 131072; - bool paused = false; + int paused = FALSE; // timeout for http requests fd_set rfds; @@ -807,7 +807,7 @@ void doServe(STREAMING_SERVER * server, server->rc.m_pauseStamp = server->rc.m_channelTimestamp[server->rc.m_mediaChannel]; if (RTMP_ToggleStream(&server->rc)) { - paused = true; + paused = TRUE; continue; } } @@ -881,7 +881,7 @@ void doServe(STREAMING_SERVER * server, server->f_cur->f_file = NULL; server->f_cur = NULL; } - RTMP_SendPacket(&server->rc, &ps, false); + RTMP_SendPacket(&server->rc, &ps, FALSE); RTMPPacket_Free(&ps); break; } @@ -1107,7 +1107,7 @@ stopStreaming(STREAMING_SERVER * server) void sigIntHandler(int sig) { - RTMP_ctrlC = true; + RTMP_ctrlC = TRUE; RTMP_LogPrintf("Caught signal: %d, cleaning up, just a second...\n", sig); if (rtmpServer) stopStreaming(rtmpServer);
participants (1)
-
hyc