[rtmpdump] r76 - in trunk: Makefile amf.c amf.h bytes.c bytes.h rtmp.c
hyc
subversion at mplayerhq.hu
Wed Dec 16 22:16:10 CET 2009
Author: hyc
Date: Wed Dec 16 22:16:10 2009
New Revision: 76
Log:
Move bytes.c functions out of main namespace
Deleted:
trunk/bytes.c
Modified:
trunk/Makefile
trunk/amf.c
trunk/amf.h
trunk/bytes.h
trunk/rtmp.c
Modified: trunk/Makefile
==============================================================================
--- trunk/Makefile Wed Dec 16 21:38:58 2009 (r75)
+++ trunk/Makefile Wed Dec 16 22:16:10 2009 (r76)
@@ -40,14 +40,13 @@ clean:
streams: bytes.o log.o rtmp.o AMFObject.o rtmppacket.o streams.o parseurl.o dh.o handshake.o
$(CXX) $(LDFLAGS) $^ -o $@$(EXT) $(SLIBS)
-rtmpdump: log.o rtmp.o dh.o amf.o bytes.o rtmpdump.o parseurl.o
+rtmpdump: log.o rtmp.o dh.o amf.o rtmpdump.o parseurl.o
$(CC) $(LDFLAGS) $^ -o $@$(EXT) $(LIBS)
-bytes.o: bytes.c bytes.h Makefile
log.o: log.c log.h Makefile
parseurl.o: parseurl.c parseurl.h log.h Makefile
streams.o: streams.cpp rtmp.h log.h Makefile
dh.o: dh.c dh.h log.h Makefile
rtmp.o: rtmp.c rtmp.h handshake.h log.h amf.h Makefile
-amf.o: amf.c amf.h Makefile
+amf.o: amf.c amf.h bytes.h Makefile
rtmpdump.o: rtmpdump.c rtmp.h log.h amf.h Makefile
Modified: trunk/amf.c
==============================================================================
--- trunk/amf.c Wed Dec 16 21:38:58 2009 (r75)
+++ trunk/amf.c Wed Dec 16 22:16:10 2009 (r76)
@@ -58,12 +58,55 @@ AMF_DecodeInt32(const char *data)
}
void
-AMF_DecodeString(const char *data, AVal *bv)
+AMF_DecodeString(const char *data, AVal * bv)
{
bv->av_len = AMF_DecodeInt16(data);
bv->av_val = (bv->av_len > 0) ? (char *) data + 2 : NULL;
}
+double
+AMF_DecodeNumber(const char *data)
+{
+#if __FLOAT_WORD_ORDER == __BYTE_ORDER
+#if __BYTE_ORDER == __BIG_ENDIAN
+ double dVal;
+ memcpy(&dVal, data, 8);
+ return dVal;
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+ double dVal;
+ unsigned char *ci, *co;
+ ci = (unsigned char *) data;
+ co = (unsigned char *) &dVal;
+ co[0] = ci[7];
+ co[1] = ci[6];
+ co[2] = ci[5];
+ co[3] = ci[4];
+ co[4] = ci[3];
+ co[5] = ci[2];
+ co[6] = ci[1];
+ co[7] = ci[0];
+ return dVal;
+#endif
+#else
+#if __BYTE_ORDER == __LITTLE_ENDIAN // __FLOAT_WORD_ORER == __BIG_ENDIAN
+ uint32_t in1 = *((uint32_t *) data);
+ uint32_t in2 = *((uint32_t *) (data + 4));
+
+ in1 = __bswap_32(in1);
+ in2 = __bswap_32(in2);
+
+ uint64_t res = ((uint64_t) in2 << 32) | (uint64_t) in1;
+ return *((double *) &res);
+#else // __BYTE_ORDER == __BIG_ENDIAN && __FLOAT_WORD_ORER == __LITTLE_ENDIAN
+ uint32_t in1 = *((uint32_t *) data);
+ uint32_t in2 = *((uint32_t *) (data + 4));
+
+ uint64_t res = ((uint64_t) in1 << 32) | (uint64_t) in2;
+ return *((double *) &res);
+#endif
+#endif
+}
+
bool
AMF_DecodeBoolean(const char *data)
{
@@ -98,7 +141,7 @@ AMF_EncodeInt32(char *output, int nVal)
}
int
-AMF_EncodeString(char *output, const AVal *bv)
+AMF_EncodeString(char *output, const AVal * bv)
{
char *buf = output;
*buf++ = AMF_STRING;
@@ -114,11 +157,57 @@ AMF_EncodeString(char *output, const AVa
int
AMF_EncodeNumber(char *output, double dVal)
{
- char *buf = output;
- *buf++ = AMF_NUMBER; // type: Number
+ *output++ = AMF_NUMBER; // type: Number
- WriteNumber(buf, dVal);
- buf += 8;
+#if __FLOAT_WORD_ORDER == __BYTE_ORDER
+#if __BYTE_ORDER == __BIG_ENDIAN
+ memcpy(output, &dVal, 8);
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+ {
+ unsigned char *ci, *co;
+ ci = (unsigned char *) &dVal;
+ co = (unsigned char *) output;
+ co[0] = ci[7];
+ co[1] = ci[6];
+ co[2] = ci[5];
+ co[3] = ci[4];
+ co[4] = ci[3];
+ co[5] = ci[2];
+ co[6] = ci[1];
+ co[7] = ci[0];
+ }
+#endif
+#else
+#if __BYTE_ORDER == __LITTLE_ENDIAN /* __FLOAT_WORD_ORER == __BIG_ENDIAN */
+ {
+ unsigned char *ci, *co;
+ ci = (unsigned char *) &dVal;
+ co = (unsigned char *) output;
+ co[0] = ci[3];
+ co[1] = ci[2];
+ co[2] = ci[1];
+ co[3] = ci[0];
+ co[4] = ci[7];
+ co[5] = ci[6];
+ co[6] = ci[5];
+ co[7] = ci[4];
+ }
+#else /* __BYTE_ORDER == __BIG_ENDIAN && __FLOAT_WORD_ORER == __LITTLE_ENDIAN */
+ {
+ unsigned char *ci, *co;
+ ci = (unsigned char *) &dVal;
+ co = (unsigned char *) output;
+ co[0] = ci[4];
+ co[1] = ci[5];
+ co[2] = ci[6];
+ co[3] = ci[7];
+ co[4] = ci[0];
+ co[5] = ci[1];
+ co[6] = ci[2];
+ co[7] = ci[3];
+ }
+#endif
+#endif
return 9;
}
@@ -136,55 +225,55 @@ AMF_EncodeBoolean(char *output, bool bVa
}
void
-AMFProp_GetName(AMFObjectProperty *prop, AVal *name)
+AMFProp_GetName(AMFObjectProperty * prop, AVal * name)
{
*name = prop->p_name;
}
void
-AMFProp_SetName(AMFObjectProperty *prop, AVal *name)
+AMFProp_SetName(AMFObjectProperty * prop, AVal * name)
{
prop->p_name = *name;
}
AMFDataType
-AMFProp_GetType(AMFObjectProperty *prop)
+AMFProp_GetType(AMFObjectProperty * prop)
{
return prop->p_type;
}
double
-AMFProp_GetNumber(AMFObjectProperty *prop)
+AMFProp_GetNumber(AMFObjectProperty * prop)
{
return prop->p_vu.p_number;
}
int
-AMFProp_GetBoolean(AMFObjectProperty *prop)
+AMFProp_GetBoolean(AMFObjectProperty * prop)
{
return prop->p_vu.p_number != 0;
}
void
-AMFProp_GetString(AMFObjectProperty *prop, AVal *str)
+AMFProp_GetString(AMFObjectProperty * prop, AVal * str)
{
*str = prop->p_vu.p_aval;
}
void
-AMFProp_GetObject(AMFObjectProperty *prop, AMFObject *obj)
+AMFProp_GetObject(AMFObjectProperty * prop, AMFObject * obj)
{
*obj = prop->p_vu.p_object;
}
int
-AMFProp_IsValid(AMFObjectProperty *prop)
+AMFProp_IsValid(AMFObjectProperty * prop)
{
return prop->p_type != AMF_INVALID;
}
int
-AMFProp_Encode(AMFObjectProperty *prop, char *pBuffer, int nSize)
+AMFProp_Encode(AMFObjectProperty * prop, char *pBuffer, int nSize)
{
int nBytes = 0;
@@ -252,7 +341,7 @@ AMFProp_Encode(AMFObjectProperty *prop,
#define AMF3_INTEGER_MIN -268435456
int
-AMF3ReadInteger(const char *data, int32_t *valp)
+AMF3ReadInteger(const char *data, int32_t * valp)
{
int i = 0;
int32_t val = 0;
@@ -292,7 +381,7 @@ AMF3ReadInteger(const char *data, int32_
}
int
-AMF3ReadString(const char *data, AVal *str)
+AMF3ReadString(const char *data, AVal * str)
{
assert(str != 0);
@@ -321,7 +410,7 @@ AMF3ReadString(const char *data, AVal *s
}
int
-AMF3Prop_Decode(AMFObjectProperty *prop, const char *pBuffer, int nSize,
+AMF3Prop_Decode(AMFObjectProperty * prop, const char *pBuffer, int nSize,
int bDecodeName)
{
int nOriginalSize = nSize;
@@ -380,7 +469,7 @@ AMF3Prop_Decode(AMFObjectProperty *prop,
case AMF3_DOUBLE:
if (nSize < 8)
return -1;
- prop->p_vu.p_number = ReadNumber(pBuffer);
+ prop->p_vu.p_number = AMF_DecodeNumber(pBuffer);
prop->p_type = AMF_NUMBER;
nSize -= 8;
break;
@@ -411,7 +500,7 @@ AMF3Prop_Decode(AMFObjectProperty *prop,
if (nSize < 8)
return -1;
- prop->p_vu.p_number = ReadNumber(pBuffer);
+ prop->p_vu.p_number = AMF_DecodeNumber(pBuffer);
nSize -= 8;
prop->p_type = AMF_NUMBER;
}
@@ -438,7 +527,7 @@ AMF3Prop_Decode(AMFObjectProperty *prop,
}
int
-AMFProp_Decode(AMFObjectProperty *prop, const char *pBuffer, int nSize,
+AMFProp_Decode(AMFObjectProperty * prop, const char *pBuffer, int nSize,
int bDecodeName)
{
int nOriginalSize = nSize;
@@ -489,7 +578,7 @@ AMFProp_Decode(AMFObjectProperty *prop,
case AMF_NUMBER:
if (nSize < 8)
return -1;
- prop->p_vu.p_number = ReadNumber(pBuffer);
+ prop->p_vu.p_number = AMF_DecodeNumber(pBuffer);
nSize -= 8;
break;
case AMF_BOOLEAN:
@@ -570,7 +659,7 @@ AMFProp_Decode(AMFObjectProperty *prop,
if (nSize < 10)
return -1;
- prop->p_vu.p_number = ReadNumber(pBuffer);
+ prop->p_vu.p_number = AMF_DecodeNumber(pBuffer);
prop->p_UTCoffset = AMF_DecodeInt16(pBuffer + 8);
nSize -= 10;
@@ -623,7 +712,7 @@ AMFProp_Decode(AMFObjectProperty *prop,
}
void
-AMFProp_Dump(AMFObjectProperty *prop)
+AMFProp_Dump(AMFObjectProperty * prop)
{
char strRes[256];
char str[256];
@@ -641,12 +730,15 @@ AMFProp_Dump(AMFObjectProperty *prop)
return;
}
- if (prop->p_name.av_len) {
- name = prop->p_name;
- } else {
- name.av_val = "no-name.";
- name.av_len = sizeof("no-name.")-1;
- }
+ if (prop->p_name.av_len)
+ {
+ name = prop->p_name;
+ }
+ else
+ {
+ name.av_val = "no-name.";
+ name.av_len = sizeof("no-name.") - 1;
+ }
if (name.av_len > 25)
name.av_len = 25;
@@ -669,7 +761,8 @@ AMFProp_Dump(AMFObjectProperty *prop)
prop->p_vu.p_number != 0.0 ? "TRUE" : "FALSE");
break;
case AMF_STRING:
- snprintf(str, 255, "STRING:\t%.*s", prop->p_vu.p_aval.av_len, prop->p_vu.p_aval.av_val);
+ snprintf(str, 255, "STRING:\t%.*s", prop->p_vu.p_aval.av_len,
+ prop->p_vu.p_aval.av_val);
break;
case AMF_DATE:
snprintf(str, 255, "DATE:\ttimestamp: %.2f, UTC offset: %d",
@@ -683,7 +776,7 @@ AMFProp_Dump(AMFObjectProperty *prop)
}
void
-AMFProp_Reset(AMFObjectProperty *prop)
+AMFProp_Reset(AMFObjectProperty * prop)
{
if (prop->p_type == AMF_OBJECT)
AMF_Reset(&prop->p_vu.p_object);
@@ -698,7 +791,7 @@ AMFProp_Reset(AMFObjectProperty *prop)
/* AMFObject */
int
-AMF_Encode(AMFObject *obj, char *pBuffer, int nSize)
+AMF_Encode(AMFObject * obj, char *pBuffer, int nSize)
{
int nOriginalSize = nSize;
int i;
@@ -733,7 +826,7 @@ AMF_Encode(AMFObject *obj, char *pBuffer
}
int
-AMF_DecodeArray(AMFObject *obj, const char *pBuffer, int nSize,
+AMF_DecodeArray(AMFObject * obj, const char *pBuffer, int nSize,
int nArrayLen, bool bDecodeName)
{
int nOriginalSize = nSize;
@@ -763,7 +856,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, bool bAMFData)
{
int nOriginalSize = nSize;
int32_t ref;
@@ -899,7 +992,7 @@ 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, bool 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 */
@@ -945,7 +1038,7 @@ AMF_Decode(AMFObject *obj, const char *p
}
void
-AMF_AddProp(AMFObject *obj, const AMFObjectProperty *prop)
+AMF_AddProp(AMFObject * obj, const AMFObjectProperty * prop)
{
if (!(obj->o_num & 0x0f))
obj->o_props =
@@ -954,13 +1047,13 @@ AMF_AddProp(AMFObject *obj, const AMFObj
}
int
-AMF_CountProp(AMFObject *obj)
+AMF_CountProp(AMFObject * obj)
{
return obj->o_num;
}
AMFObjectProperty *
-AMF_GetProp(AMFObject *obj, const AVal *name, int nIndex)
+AMF_GetProp(AMFObject * obj, const AVal * name, int nIndex)
{
if (nIndex >= 0)
{
@@ -981,7 +1074,7 @@ AMF_GetProp(AMFObject *obj, const AVal *
}
void
-AMF_Dump(AMFObject *obj)
+AMF_Dump(AMFObject * obj)
{
int n;
for (n = 0; n < obj->o_num; n++)
@@ -991,7 +1084,7 @@ AMF_Dump(AMFObject *obj)
}
void
-AMF_Reset(AMFObject *obj)
+AMF_Reset(AMFObject * obj)
{
int n;
for (n = 0; n < obj->o_num; n++)
@@ -1007,7 +1100,7 @@ AMF_Reset(AMFObject *obj)
/* AMF3ClassDefinition */
void
-AMF3CD_AddProp(AMF3ClassDef *cd, AVal *prop)
+AMF3CD_AddProp(AMF3ClassDef * cd, AVal * prop)
{
if (!(cd->cd_num & 0x0f))
cd->cd_props = realloc(cd->cd_props, (cd->cd_num + 16) * sizeof(AVal));
@@ -1015,9 +1108,9 @@ AMF3CD_AddProp(AMF3ClassDef *cd, AVal *p
}
AVal *
-AMF3CD_GetProp(AMF3ClassDef *cd, int nIndex)
+AMF3CD_GetProp(AMF3ClassDef * cd, int nIndex)
{
if (nIndex >= cd->cd_num)
- return (AVal *)&AV_empty;
+ return (AVal *) & AV_empty;
return &cd->cd_props[nIndex];
}
Modified: trunk/amf.h
==============================================================================
--- trunk/amf.h Wed Dec 16 21:38:58 2009 (r75)
+++ trunk/amf.h Wed Dec 16 22:16:10 2009 (r76)
@@ -80,56 +80,58 @@ extern "C"
int16_t p_UTCoffset;
} AMFObjectProperty;
- int AMF_EncodeString (char *output, const AVal * str);
- int AMF_EncodeNumber (char *output, double dVal);
- int AMF_EncodeInt16 (char *output, short nVal);
- int AMF_EncodeInt24 (char *output, int nVal);
- int AMF_EncodeInt32 (char *output, int nVal);
- int AMF_EncodeBoolean (char *output, bool bVal);
+ int AMF_EncodeString(char *output, const AVal * str);
+ int AMF_EncodeNumber(char *output, double dVal);
+ int AMF_EncodeInt16(char *output, short nVal);
+ int AMF_EncodeInt24(char *output, int nVal);
+ int AMF_EncodeInt32(char *output, int nVal);
+ int AMF_EncodeBoolean(char *output, bool 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);
- bool AMF_DecodeBoolean (const char *data);
+ 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);
+ bool AMF_DecodeBoolean(const char *data);
+ double AMF_DecodeNumber(const char *data);
- int AMF_Encode (AMFObject * obj, char *pBuffer, int nSize);
- int AMF_Decode (AMFObject * obj, const char *pBuffer, int nSize,
+ int AMF_Encode(AMFObject * obj, char *pBuffer, int nSize);
+ int AMF_Decode(AMFObject * obj, const char *pBuffer, int nSize,
+ bool bDecodeName);
+ int AMF_DecodeArray(AMFObject * obj, const char *pBuffer, int nSize,
+ int nArrayLen, bool bDecodeName);
+ int AMF3_Decode(AMFObject * obj, const char *pBuffer, int nSize,
bool bDecodeName);
- int AMF_DecodeArray (AMFObject * obj, const char *pBuffer, int nSize,
- int nArrayLen, bool bDecodeName);
- int AMF3_Decode (AMFObject * obj, const char *pBuffer, int nSize,
- bool bDecodeName);
- void AMF_Dump (AMFObject * obj);
- void AMF_Reset (AMFObject * obj);
+ void AMF_Dump(AMFObject * obj);
+ void AMF_Reset(AMFObject * obj);
- void AMF_AddProp (AMFObject * obj, const AMFObjectProperty * prop);
- int AMF_CountProp (AMFObject * obj);
- AMFObjectProperty *AMF_GetProp (AMFObject * obj, const AVal *name, int nIndex);
+ void AMF_AddProp(AMFObject * obj, const AMFObjectProperty * prop);
+ int AMF_CountProp(AMFObject * obj);
+ AMFObjectProperty *AMF_GetProp(AMFObject * obj, const AVal * name,
+ int nIndex);
- AMFDataType AMFProp_GetType (AMFObjectProperty * prop);
- void AMFProp_SetNumber (AMFObjectProperty * prop, double dval);
- void AMFProp_SetBoolean (AMFObjectProperty * prop, bool bflag);
- void AMFProp_SetString (AMFObjectProperty * prop, AVal * str);
- void AMFProp_SetObject (AMFObjectProperty * prop, AMFObject * obj);
+ AMFDataType AMFProp_GetType(AMFObjectProperty * prop);
+ void AMFProp_SetNumber(AMFObjectProperty * prop, double dval);
+ void AMFProp_SetBoolean(AMFObjectProperty * prop, bool 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);
- void AMFProp_GetString (AMFObjectProperty * prop, AVal * str);
- void AMFProp_GetObject (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);
+ void AMFProp_GetString(AMFObjectProperty * prop, AVal * str);
+ void AMFProp_GetObject(AMFObjectProperty * prop, AMFObject * obj);
- bool AMFProp_IsValid (AMFObjectProperty * prop);
+ bool AMFProp_IsValid(AMFObjectProperty * prop);
- int AMFProp_Encode (AMFObjectProperty * prop, char *pBuffer, int nSize);
- int AMF3Prop_Decode (AMFObjectProperty * prop, const char *pBuffer,
- int nSize, bool bDecodeName);
- int AMFProp_Decode (AMFObjectProperty * prop, const char *pBuffer,
+ int AMFProp_Encode(AMFObjectProperty * prop, char *pBuffer, int nSize);
+ int AMF3Prop_Decode(AMFObjectProperty * prop, const char *pBuffer,
int nSize, bool bDecodeName);
+ int AMFProp_Decode(AMFObjectProperty * prop, const char *pBuffer,
+ int nSize, bool bDecodeName);
- void AMFProp_Dump (AMFObjectProperty * prop);
- void AMFProp_Reset (AMFObjectProperty * prop);
+ void AMFProp_Dump(AMFObjectProperty * prop);
+ void AMFProp_Reset(AMFObjectProperty * prop);
typedef struct AMF3ClassDef
{
@@ -140,8 +142,8 @@ extern "C"
AVal *cd_props;
} AMF3ClassDef;
- void AMF3CD_AddProp (AMF3ClassDef * cd, AVal * prop);
- AVal *AMF3CD_GetProp (AMF3ClassDef * cd, int idx);
+ void AMF3CD_AddProp(AMF3ClassDef * cd, AVal * prop);
+ AVal *AMF3CD_GetProp(AMF3ClassDef * cd, int idx);
#ifdef __cplusplus
}
Modified: trunk/bytes.h
==============================================================================
--- trunk/bytes.h Wed Dec 16 21:38:58 2009 (r75)
+++ trunk/bytes.h Wed Dec 16 22:16:10 2009 (r76)
@@ -3,10 +3,6 @@
#include <stdint.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#ifdef WIN32
// Windows is little endian only
#define __LITTLE_ENDIAN 1234
@@ -15,15 +11,6 @@ extern "C" {
#define __FLOAT_WORD_ORDER __BYTE_ORDER
typedef unsigned char uint8_t;
-/*typedef signed char int8_t;
-typedef signed short int16_t;
-typedef signed long int int32_t;
-typedef signed long long int int64_t;
-typedef unsigned char uint8_t;
-typedef unsigned short uint16_t;
-typedef unsigned long int uint32_t;
-typedef unsigned long long int uint64_t;
-*/
#elif (defined(__FreeBSD__) && __FreeBSD_version >= 470000) || defined(__OpenBSD__) || defined(__NetBSD__) // *BSD
#include <sys/endian.h>
@@ -52,18 +39,6 @@ typedef unsigned long long int uint64_t;
(((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
#endif
-#ifndef __bswap_64
-#define __bswap_64(x) \
- ((((x) & 0xff00000000000000ull) >> 56) \
- | (((x) & 0x00ff000000000000ull) >> 40) \
- | (((x) & 0x0000ff0000000000ull) >> 24) \
- | (((x) & 0x000000ff00000000ull) >> 8) \
- | (((x) & 0x00000000ff000000ull) << 8) \
- | (((x) & 0x0000000000ff0000ull) << 24) \
- | (((x) & 0x000000000000ff00ull) << 40) \
- | (((x) & 0x00000000000000ffull) << 56))
-#endif
-
// define default endianness
#ifndef __LITTLE_ENDIAN
#define __LITTLE_ENDIAN 1234
@@ -96,15 +71,5 @@ typedef unsigned long long int uint64_t;
#error "Unknown/unsupported byte order!"
#endif
-void WriteNumber(char *data, double dVal);
-double ReadNumber(const char *data);
-
-int ReadInt32LE(const char *data);
-int EncodeInt32LE(char *output, int nVal);
-
-#ifdef __cplusplus
-}
-#endif
-
#endif
Modified: trunk/rtmp.c
==============================================================================
--- trunk/rtmp.c Wed Dec 16 21:38:58 2009 (r75)
+++ trunk/rtmp.c Wed Dec 16 22:16:10 2009 (r76)
@@ -41,7 +41,6 @@
#include "rtmp.h"
#include "log.h"
-#include "bytes.h"
#define RTMP_SIG_SIZE 1536
#define RTMP_LARGE_HEADER_SIZE 12
@@ -1753,6 +1752,29 @@ HandleClientBW(RTMP * r, const RTMPPacke
r->m_nClientBW2);
}
+static int
+DecodeInt32LE(const char *data)
+{
+ unsigned char *c = (unsigned char *)data;
+ unsigned int val;
+
+ val = (c[3] << 24) | (c[2] << 16) | (c[1] << 8) | c[0];
+ return val;
+}
+
+static int
+EncodeInt32LE(char *output, int nVal)
+{
+ output[0] = nVal;
+ nVal >>= 8;
+ output[1] = nVal;
+ nVal >>= 8;
+ output[2] = nVal;
+ nVal >>= 8;
+ output[3] = nVal;
+ return 4;
+}
+
static bool
ReadPacket(RTMP * r, RTMPPacket * packet)
{
@@ -1830,7 +1852,7 @@ ReadPacket(RTMP * r, RTMPPacket * packet
packet->m_packetType = header[6];
if (nSize == 11)
- packet->m_nInfoField2 = ReadInt32LE(header + 7);
+ packet->m_nInfoField2 = DecodeInt32LE(header + 7);
}
}
}
More information about the rtmpdump
mailing list