#LIBS=-lgnutls -lz
THREADLIB=-lpthread
LIBRTMP=librtmp/librtmp.a
+INCRTMP=librtmp/rtmp_sys.h librtmp/rtmp.h librtmp/log.h librtmp/amf.h
SLIBS=$(THREADLIB) $(LIBS)
EXT=
rm -f *.o rtmpdump$(EXT) rtmpgw$(EXT) rtmpsrv$(EXT) rtmpsuck$(EXT)
@$(MAKE) -C librtmp clean
-$(LIBRTMP):
+FORCE:
+
+$(LIBRTMP): FORCE
@$(MAKE) -C librtmp all CC="$(CC)" CFLAGS="$(CFLAGS)"
rtmpdump: rtmpdump.o $(LIBRTMP)
rtmpgw: rtmpgw.o thread.o $(LIBRTMP)
$(CC) $(LDFLAGS) $^ -o $@$(EXT) $(SLIBS)
-rtmpgw.o: rtmpgw.c librtmp/rtmp.h librtmp/log.h librtmp/amf.h Makefile
-rtmpdump.o: rtmpdump.c librtmp/rtmp.h librtmp/log.h librtmp/amf.h Makefile
-rtmpsrv.o: rtmpsrv.c librtmp/rtmp.h librtmp/log.h librtmp/amf.h Makefile
+rtmpgw.o: rtmpgw.c $(INCRTMP) Makefile
+rtmpdump.o: rtmpdump.c $(INCRTMP) Makefile
+rtmpsrv.o: rtmpsrv.c $(INCRTMP) Makefile
+rtmpsuck.o: rtmpsuck.c $(INCRTMP) Makefile
thread.o: thread.c thread.h
log.o: log.c log.h Makefile
rtmp.o: rtmp.c rtmp.h rtmp_sys.h handshake.h dh.h log.h amf.h Makefile
amf.o: amf.c amf.h bytes.h log.h Makefile
-hashswf.o: hashswf.c http.h rtmp.h rtmp_sys.h
-parseurl.o: parseurl.c
+hashswf.o: hashswf.c http.h rtmp.h rtmp_sys.h Makefile
+parseurl.o: parseurl.c rtmp_sys.h log.h Makefile
unsigned int
AMF_DecodeInt32(const char *data)
{
- unsigned char *c = (unsigned char *) data;
+ unsigned char *c = (unsigned char *)data;
unsigned int val;
val = (c[0] << 24) | (c[1] << 16) | (c[2] << 8) | c[3];
return val;
}
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;
+ bv->av_val = (bv->av_len > 0) ? (char *)data + 2 : NULL;
}
void
-AMF_DecodeLongString(const char *data, AVal * bv)
+AMF_DecodeLongString(const char *data, AVal *bv)
{
bv->av_len = AMF_DecodeInt32(data);
- bv->av_val = (bv->av_len > 0) ? (char *) data + 4 : NULL;
+ bv->av_val = (bv->av_len > 0) ? (char *)data + 4 : NULL;
}
double
memcpy(&dVal, data, 8);
#elif __BYTE_ORDER == __LITTLE_ENDIAN
unsigned char *ci, *co;
- ci = (unsigned char *) data;
- co = (unsigned char *) &dVal;
+ ci = (unsigned char *)data;
+ co = (unsigned char *)&dVal;
co[0] = ci[7];
co[1] = ci[6];
co[2] = ci[5];
#else
#if __BYTE_ORDER == __LITTLE_ENDIAN // __FLOAT_WORD_ORER == __BIG_ENDIAN
unsigned char *ci, *co;
- ci = (unsigned char *) data;
- co = (unsigned char *) &dVal;
+ ci = (unsigned char *)data;
+ co = (unsigned char *)&dVal;
co[0] = ci[3];
co[1] = ci[2];
co[2] = ci[1];
co[7] = ci[4];
#else // __BYTE_ORDER == __BIG_ENDIAN && __FLOAT_WORD_ORER == __LITTLE_ENDIAN
unsigned char *ci, *co;
- ci = (unsigned char *) data;
- co = (unsigned char *) &dVal;
+ ci = (unsigned char *)data;
+ co = (unsigned char *)&dVal;
co[0] = ci[4];
co[1] = ci[5];
co[2] = ci[6];
}
char *
-AMF_EncodeString(char *output, char *outend, const AVal * bv)
+AMF_EncodeString(char *output, char *outend, const AVal *bv)
{
if ((bv->av_len < 65536 && output + 1 + 2 + bv->av_len > outend) ||
output + 1 + 4 + bv->av_len > outend)
#elif __BYTE_ORDER == __LITTLE_ENDIAN
{
unsigned char *ci, *co;
- ci = (unsigned char *) &dVal;
- co = (unsigned char *) output;
+ ci = (unsigned char *)&dVal;
+ co = (unsigned char *)output;
co[0] = ci[7];
co[1] = ci[6];
co[2] = ci[5];
#if __BYTE_ORDER == __LITTLE_ENDIAN /* __FLOAT_WORD_ORER == __BIG_ENDIAN */
{
unsigned char *ci, *co;
- ci = (unsigned char *) &dVal;
- co = (unsigned char *) output;
+ ci = (unsigned char *)&dVal;
+ co = (unsigned char *)output;
co[0] = ci[3];
co[1] = ci[2];
co[2] = ci[1];
#else /* __BYTE_ORDER == __BIG_ENDIAN && __FLOAT_WORD_ORER == __LITTLE_ENDIAN */
{
unsigned char *ci, *co;
- ci = (unsigned char *) &dVal;
- co = (unsigned char *) output;
+ ci = (unsigned char *)&dVal;
+ co = (unsigned char *)output;
co[0] = ci[4];
co[1] = ci[5];
co[2] = ci[6];
}
char *
-AMF_EncodeNamedString(char *output, char *outend, const AVal * strName, const AVal * strValue)
+AMF_EncodeNamedString(char *output, char *outend, const AVal *strName, const AVal *strValue)
{
if (output+2+strName->av_len > outend)
return NULL;
}
char *
-AMF_EncodeNamedNumber(char *output, char *outend, const AVal * strName, double dVal)
+AMF_EncodeNamedNumber(char *output, char *outend, const AVal *strName, double dVal)
{
if (output+2+strName->av_len > outend)
return NULL;
}
char *
-AMF_EncodeNamedBoolean(char *output, char *outend, const AVal * strName, bool bVal)
+AMF_EncodeNamedBoolean(char *output, char *outend, const AVal *strName, bool bVal)
{
if (output+2+strName->av_len > outend)
return NULL;
}
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;
}
bool
-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;
}
bool
-AMFProp_IsValid(AMFObjectProperty * prop)
+AMFProp_IsValid(AMFObjectProperty *prop)
{
return prop->p_type != AMF_INVALID;
}
char *
-AMFProp_Encode(AMFObjectProperty * prop, char *pBuffer, char *pBufEnd)
+AMFProp_Encode(AMFObjectProperty *prop, char *pBuffer, char *pBufEnd)
{
if (prop->p_type == AMF_INVALID)
return NULL;
break;
default:
- Log(LOGERROR, "%s, invalid type. %d", __FUNCTION__, prop->p_type);
+ RTMP_Log(RTMP_LOGERROR, "%s, invalid type. %d", __FUNCTION__, prop->p_type);
pBuffer = NULL;
};
#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;
}
int
-AMF3ReadString(const char *data, AVal * str)
+AMF3ReadString(const char *data, AVal *str)
{
assert(str != 0);
if ((ref & 0x1) == 0)
{ /* reference: 0xxx */
uint32_t refIndex = (ref >> 1);
- Log(LOGDEBUG,
+ RTMP_Log(RTMP_LOGDEBUG,
"%s, string reference, index: %d, not supported, ignoring!",
__FUNCTION__, refIndex);
return len;
{
uint32_t nSize = (ref >> 1);
- str->av_val = (char *) data;
+ str->av_val = (char *)data;
str->av_len = nSize;
return len + nSize;
}
int
-AMF3Prop_Decode(AMFObjectProperty * prop, const char *pBuffer, int nSize,
+AMF3Prop_Decode(AMFObjectProperty *prop, const char *pBuffer, int nSize,
bool bDecodeName)
{
int nOriginalSize = nSize;
if (nSize == 0 || !pBuffer)
{
- Log(LOGDEBUG, "empty buffer/no buffer pointer!");
+ RTMP_Log(RTMP_LOGDEBUG, "empty buffer/no buffer pointer!");
return -1;
}
{
int32_t res = 0;
int len = AMF3ReadInteger(pBuffer, &res);
- prop->p_vu.p_number = (double) res;
+ prop->p_vu.p_number = (double)res;
prop->p_type = AMF_NUMBER;
nSize -= len;
break;
if ((res & 0x1) == 0)
{ /* reference */
uint32_t nIndex = (res >> 1);
- Log(LOGDEBUG, "AMF3_DATE reference: %d, not supported!", nIndex);
+ RTMP_Log(RTMP_LOGDEBUG, "AMF3_DATE reference: %d, not supported!", nIndex);
}
else
{
case AMF3_ARRAY:
case AMF3_BYTE_ARRAY:
default:
- Log(LOGDEBUG, "%s - AMF3 unknown/unsupported datatype 0x%02x, @0x%08X",
- __FUNCTION__, (unsigned char) (*pBuffer), pBuffer);
+ RTMP_Log(RTMP_LOGDEBUG, "%s - AMF3 unknown/unsupported datatype 0x%02x, @0x%08X",
+ __FUNCTION__, (unsigned char)(*pBuffer), pBuffer);
return -1;
}
}
int
-AMFProp_Decode(AMFObjectProperty * prop, const char *pBuffer, int nSize,
+AMFProp_Decode(AMFObjectProperty *prop, const char *pBuffer, int nSize,
bool bDecodeName)
{
int nOriginalSize = nSize;
if (nSize == 0 || !pBuffer)
{
- Log(LOGDEBUG, "%s: Empty buffer/no buffer pointer!", __FUNCTION__);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Empty buffer/no buffer pointer!", __FUNCTION__);
return -1;
}
if (bDecodeName && nSize < 4)
{ /* at least name (length + at least 1 byte) and 1 byte of data */
- Log(LOGDEBUG,
- "%s: Not enough data for decoding with name, less then 4 bytes!",
+ RTMP_Log(RTMP_LOGDEBUG,
+ "%s: Not enough data for decoding with name, less than 4 bytes!",
__FUNCTION__);
return -1;
}
unsigned short nNameSize = AMF_DecodeInt16(pBuffer);
if (nNameSize > nSize - 2)
{
- Log(LOGDEBUG,
+ RTMP_Log(RTMP_LOGDEBUG,
"%s: Name size out of range: namesize (%d) > len (%d) - 2",
__FUNCTION__, nNameSize, nSize);
return -1;
case AMF_BOOLEAN:
if (nSize < 1)
return -1;
- prop->p_vu.p_number = (double) AMF_DecodeBoolean(pBuffer);
+ prop->p_vu.p_number = (double)AMF_DecodeBoolean(pBuffer);
nSize--;
break;
case AMF_STRING:
{
unsigned short nStringSize = AMF_DecodeInt16(pBuffer);
- if (nSize < (long) nStringSize + 2)
+ if (nSize < (long)nStringSize + 2)
return -1;
AMF_DecodeString(pBuffer, &prop->p_vu.p_aval);
nSize -= (2 + nStringSize);
}
case AMF_MOVIECLIP:
{
- Log(LOGERROR, "AMF_MOVIECLIP reserved!");
+ RTMP_Log(RTMP_LOGERROR, "AMF_MOVIECLIP reserved!");
return -1;
break;
}
break;
case AMF_REFERENCE:
{
- Log(LOGERROR, "AMF_REFERENCE not supported!");
+ RTMP_Log(RTMP_LOGERROR, "AMF_REFERENCE not supported!");
return -1;
break;
}
}
case AMF_DATE:
{
- Log(LOGDEBUG, "AMF_DATE");
+ RTMP_Log(RTMP_LOGDEBUG, "AMF_DATE");
if (nSize < 10)
return -1;
case AMF_LONG_STRING:
{
unsigned int nStringSize = AMF_DecodeInt32(pBuffer);
- if (nSize < (long) nStringSize + 4)
+ if (nSize < (long)nStringSize + 4)
return -1;
AMF_DecodeLongString(pBuffer, &prop->p_vu.p_aval);
nSize -= (4 + nStringSize);
}
case AMF_RECORDSET:
{
- Log(LOGERROR, "AMF_RECORDSET reserved!");
+ RTMP_Log(RTMP_LOGERROR, "AMF_RECORDSET reserved!");
return -1;
break;
}
case AMF_XML_DOC:
{
- Log(LOGERROR, "AMF_XML_DOC not supported!");
+ RTMP_Log(RTMP_LOGERROR, "AMF_XML_DOC not supported!");
return -1;
break;
}
case AMF_TYPED_OBJECT:
{
- Log(LOGERROR, "AMF_TYPED_OBJECT not supported!");
+ RTMP_Log(RTMP_LOGERROR, "AMF_TYPED_OBJECT not supported!");
return -1;
break;
}
break;
}
default:
- Log(LOGDEBUG, "%s - unknown datatype 0x%02x, @0x%08X", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s - unknown datatype 0x%02x, @0x%08X", __FUNCTION__,
prop->p_type, pBuffer - 1);
return -1;
}
}
void
-AMFProp_Dump(AMFObjectProperty * prop)
+AMFProp_Dump(AMFObjectProperty *prop)
{
char strRes[256];
char str[256];
if (prop->p_type == AMF_INVALID)
{
- Log(LOGDEBUG, "Property: INVALID");
+ RTMP_Log(RTMP_LOGDEBUG, "Property: INVALID");
return;
}
if (prop->p_type == AMF_NULL)
{
- Log(LOGDEBUG, "Property: NULL");
+ RTMP_Log(RTMP_LOGDEBUG, "Property: NULL");
return;
}
if (prop->p_type == AMF_OBJECT)
{
- Log(LOGDEBUG, "Property: <%sOBJECT>", strRes);
+ RTMP_Log(RTMP_LOGDEBUG, "Property: <%sOBJECT>", strRes);
AMF_Dump(&prop->p_vu.p_object);
return;
}
prop->p_vu.p_number, prop->p_UTCoffset);
break;
default:
- snprintf(str, 255, "INVALID TYPE 0x%02x", (unsigned char) prop->p_type);
+ snprintf(str, 255, "INVALID TYPE 0x%02x", (unsigned char)prop->p_type);
}
- Log(LOGDEBUG, "Property: <%s%s>", strRes, str);
+ RTMP_Log(RTMP_LOGDEBUG, "Property: <%s%s>", strRes, str);
}
void
-AMFProp_Reset(AMFObjectProperty * prop)
+AMFProp_Reset(AMFObjectProperty *prop)
{
if (prop->p_type == AMF_OBJECT)
AMF_Reset(&prop->p_vu.p_object);
/* AMFObject */
char *
-AMF_Encode(AMFObject * obj, char *pBuffer, char *pBufEnd)
+AMF_Encode(AMFObject *obj, char *pBuffer, char *pBufEnd)
{
int i;
char *res = AMFProp_Encode(&obj->o_props[i], pBuffer, pBufEnd);
if (res == NULL)
{
- Log(LOGERROR, "AMF_Encode - failed to encode property in index %d",
+ RTMP_Log(RTMP_LOGERROR, "AMF_Encode - failed to encode property in index %d",
i);
break;
}
}
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;
}
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;
if (bAMFData)
{
if (*pBuffer != AMF3_OBJECT)
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"AMF3 Object encapsulated in AMF stream does not start with AMF3_OBJECT!");
pBuffer++;
nSize--;
{ /* object reference, 0xxx */
uint32_t objectIndex = (ref >> 1);
- Log(LOGDEBUG, "Object reference, index: %d", objectIndex);
+ RTMP_Log(RTMP_LOGDEBUG, "Object reference, index: %d", objectIndex);
}
else /* object instance */
{
if ((classRef & 0x1) == 0)
{ /* class reference */
uint32_t classIndex = (classRef >> 1);
- Log(LOGDEBUG, "Class reference: %d", classIndex);
+ RTMP_Log(RTMP_LOGDEBUG, "Class reference: %d", classIndex);
}
else
{
//std::string str = className;
- Log(LOGDEBUG,
+ RTMP_Log(RTMP_LOGDEBUG,
"Class name: %s, externalizable: %d, dynamic: %d, classMembers: %d",
cd.cd_name.av_val, cd.cd_externalizable, cd.cd_dynamic,
cd.cd_num);
{
AVal memberName;
len = AMF3ReadString(pBuffer, &memberName);
- Log(LOGDEBUG, "Member: %s", memberName.av_val);
+ RTMP_Log(RTMP_LOGDEBUG, "Member: %s", memberName.av_val);
AMF3CD_AddProp(&cd, &memberName);
nSize -= len;
pBuffer += len;
int nRes;
AVal name = AVC("DEFAULT_ATTRIBUTE");
- Log(LOGDEBUG, "Externalizable, TODO check");
+ RTMP_Log(RTMP_LOGDEBUG, "Externalizable, TODO check");
nRes = AMF3Prop_Decode(&prop, pBuffer, nSize, false);
if (nRes == -1)
- Log(LOGDEBUG, "%s, failed to decode AMF3 property!",
+ RTMP_Log(RTMP_LOGDEBUG, "%s, failed to decode AMF3 property!",
__FUNCTION__);
else
{
{
nRes = AMF3Prop_Decode(&prop, pBuffer, nSize, false);
if (nRes == -1)
- Log(LOGDEBUG, "%s, failed to decode AMF3 property!",
+ RTMP_Log(RTMP_LOGDEBUG, "%s, failed to decode AMF3 property!",
__FUNCTION__);
AMFProp_SetName(&prop, AMF3CD_GetProp(&cd, i));
while (len > 0);
}
}
- Log(LOGDEBUG, "class object!");
+ RTMP_Log(RTMP_LOGDEBUG, "class object!");
}
return nOriginalSize - nSize;
}
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 */
if (bError)
{
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"DECODING ERROR, IGNORING BYTES UNTIL NEXT KNOWN PATTERN!");
nSize--;
pBuffer++;
}
void
-AMF_AddProp(AMFObject * obj, const AMFObjectProperty * prop)
+AMF_AddProp(AMFObject *obj, const AMFObjectProperty *prop)
{
if (!(obj->o_num & 0x0f))
obj->o_props =
}
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)
{
}
}
- return (AMFObjectProperty *) & AMFProp_Invalid;
+ return (AMFObjectProperty *)&AMFProp_Invalid;
}
void
-AMF_Dump(AMFObject * obj)
+AMF_Dump(AMFObject *obj)
{
int n;
- Log(LOGDEBUG, "(object begin)");
+ RTMP_Log(RTMP_LOGDEBUG, "(object begin)");
for (n = 0; n < obj->o_num; n++)
{
AMFProp_Dump(&obj->o_props[n]);
}
- Log(LOGDEBUG, "(object end)");
+ RTMP_Log(RTMP_LOGDEBUG, "(object end)");
}
void
-AMF_Reset(AMFObject * obj)
+AMF_Reset(AMFObject *obj)
{
int n;
for (n = 0; n < obj->o_num; n++)
/* 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));
}
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];
}
MP_set_w(bn, 1);
if (MP_cmp(y, bn) < 0)
{
- Log(LOGWARNING, "DH public key must be at least 2");
+ RTMP_Log(RTMP_LOGERROR, "DH public key must be at least 2");
ret = false;
goto failed;
}
MP_sub_w(bn, 1);
if (MP_cmp(y, bn) > 0)
{
- Log(LOGWARNING, "DH public key must be at most p-2");
+ RTMP_Log(RTMP_LOGERROR, "DH public key must be at most p-2");
ret = false;
goto failed;
}
if (MP_cmp_1(bn) != 0)
{
- Log(LOGWARNING, "DH public key does not fulfill y^q mod p = 1");
+ RTMP_Log(RTMP_LOGWARNING, "DH public key does not fulfill y^q mod p = 1");
}
}
HMAC_crunch(ctx, pubKeyIn, 128);
HMAC_finish(ctx, digest, digestLen);
- Log(LOGDEBUG, "RC4 Out Key: ");
- LogHex(LOGDEBUG, (char *) digest, 16);
+ RTMP_Log(RTMP_LOGDEBUG, "RC4 Out Key: ");
+ RTMP_LogHex(RTMP_LOGDEBUG, (char *) digest, 16);
RC4_setkey(*rc4keyOut, 16, digest);
HMAC_crunch(ctx, pubKeyOut, 128);
HMAC_finish(ctx, digest, digestLen);
- Log(LOGDEBUG, "RC4 In Key: ");
- LogHex(LOGDEBUG, (char *) digest, 16);
+ RTMP_Log(RTMP_LOGDEBUG, "RC4 In Key: ");
+ RTMP_LogHex(RTMP_LOGDEBUG, (char *) digest, 16);
RC4_setkey(*rc4keyIn, 16, digest);
}
if (res + 128 > 767)
{
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"%s: Couldn't calculate correct DH offset (got %d), exiting!\n",
__FUNCTION__, res);
exit(1);
if (res + 32 > 1535)
{
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"%s: Couldn't calculate correct digest offset (got %d), exiting\n",
__FUNCTION__, res);
exit(1);
if (res + 128 > 1531)
{
- Log(LOGERROR, "%s: Couldn't calculate DH offset (got %d), exiting!\n",
+ RTMP_Log(RTMP_LOGERROR, "%s: Couldn't calculate DH offset (got %d), exiting!\n",
__FUNCTION__, res);
exit(1);
}
if (res + 32 > 771)
{
- Log(LOGDEBUG,
+ RTMP_Log(RTMP_LOGDEBUG,
"%s: Couldn't calculate digest offset (got %d), exiting!\n",
__FUNCTION__, res);
exit(1);
clientsig[5] = 0;
clientsig[7] = 2;
- Log(LOGDEBUG, "%s: Client type: %02X\n", __FUNCTION__, clientsig[-1]);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Client type: %02X\n", __FUNCTION__, clientsig[-1]);
}
else
{
r->Link.dh = DHInit(128); /* 1024 */
if (!r->Link.dh)
{
- Log(LOGERROR, "%s: Couldn't initialize Diffie-Hellmann!",
+ RTMP_Log(RTMP_LOGERROR, "%s: Couldn't initialize Diffie-Hellmann!",
__FUNCTION__);
return false;
}
dhposClient = getdh(clientsig, RTMP_SIG_SIZE);
- Log(LOGDEBUG, "%s: DH pubkey position: %d", __FUNCTION__, dhposClient);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: DH pubkey position: %d", __FUNCTION__, dhposClient);
if (!DHGenerateKey(r->Link.dh))
{
- Log(LOGERROR, "%s: Couldn't generate Diffie-Hellmann public key!",
+ RTMP_Log(RTMP_LOGERROR, "%s: Couldn't generate Diffie-Hellmann public key!",
__FUNCTION__);
return false;
}
if (!DHGetPublicKey
(r->Link.dh, (uint8_t *) &clientsig[dhposClient], 128))
{
- Log(LOGERROR, "%s: Couldn't write public key!", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s: Couldn't write public key!", __FUNCTION__);
return false;
}
}
digestPosClient = getdig(clientsig, RTMP_SIG_SIZE); /* reuse this value in verification */
- Log(LOGDEBUG, "%s: Client digest offset: %d", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Client digest offset: %d", __FUNCTION__,
digestPosClient);
CalculateDigest(digestPosClient, clientsig, GenuineFPKey, 30,
&clientsig[digestPosClient]);
- Log(LOGDEBUG, "%s: Initial client digest: ", __FUNCTION__);
- LogHex(LOGDEBUG, (char *) clientsig + digestPosClient,
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Initial client digest: ", __FUNCTION__);
+ RTMP_LogHex(RTMP_LOGDEBUG, (char *) clientsig + digestPosClient,
SHA256_DIGEST_LENGTH);
}
#ifdef _DEBUG
- Log(LOGDEBUG, "Clientsig: ");
- LogHex(LOGDEBUG, clientsig, RTMP_SIG_SIZE);
+ RTMP_Log(RTMP_LOGDEBUG, "Clientsig: ");
+ RTMP_LogHex(RTMP_LOGDEBUG, clientsig, RTMP_SIG_SIZE);
#endif
if (!WriteN(r, clientsig-1, RTMP_SIG_SIZE + 1))
if (ReadN(r, &type, 1) != 1) /* 0x03 or 0x06 */
return false;
- Log(LOGDEBUG, "%s: Type Answer : %02X", __FUNCTION__, type);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Type Answer : %02X", __FUNCTION__, type);
if (type != clientsig[-1])
- Log(LOGWARNING, "%s: Type mismatch: client sent %d, server answered %d",
+ RTMP_Log(RTMP_LOGWARNING, "%s: Type mismatch: client sent %d, server answered %d",
__FUNCTION__, clientsig[-1], type);
if (ReadN(r, serversig, RTMP_SIG_SIZE) != RTMP_SIG_SIZE)
memcpy(&uptime, serversig, 4);
uptime = ntohl(uptime);
- Log(LOGDEBUG, "%s: Server Uptime : %d", __FUNCTION__, uptime);
- Log(LOGDEBUG, "%s: FMS Version : %d.%d.%d.%d", __FUNCTION__, serversig[4],
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Server Uptime : %d", __FUNCTION__, uptime);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: FMS Version : %d.%d.%d.%d", __FUNCTION__, serversig[4],
serversig[5], serversig[6], serversig[7]);
#ifdef _DEBUG
- Log(LOGDEBUG, "Server signature:");
- LogHex(LOGDEBUG, serversig, RTMP_SIG_SIZE);
+ RTMP_Log(RTMP_LOGDEBUG, "Server signature:");
+ RTMP_LogHex(RTMP_LOGDEBUG, serversig, RTMP_SIG_SIZE);
#endif
if (FP9HandShake)
if (!VerifyDigest(digestPosServer, serversig, GenuineFMSKey, 36))
{
- Log(LOGWARNING, "Trying different position for server digest!\n");
+ RTMP_Log(RTMP_LOGWARNING, "Trying different position for server digest!\n");
digestPosServer = GetDigestOffset1(serversig, RTMP_SIG_SIZE);
if (!VerifyDigest(digestPosServer, serversig, GenuineFMSKey, 36))
{
- Log(LOGERROR, "Couldn't verify the server digest\n"); /* continuing anyway will probably fail */
+ RTMP_Log(RTMP_LOGERROR, "Couldn't verify the server digest\n"); /* continuing anyway will probably fail */
return false;
}
dhposServer = GetDHOffset1(serversig, RTMP_SIG_SIZE);
dhposServer = GetDHOffset2(serversig, RTMP_SIG_SIZE);
}
- Log(LOGDEBUG, "%s: Server DH public key offset: %d", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Server DH public key offset: %d", __FUNCTION__,
dhposServer);
/* generate SWFVerification token (SHA256 HMAC hash of decompressed SWF, key are the last 32 bytes of the server handshake) */
secretKey);
if (len < 0)
{
- Log(LOGDEBUG, "%s: Wrong secret key position!", __FUNCTION__);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Wrong secret key position!", __FUNCTION__);
return false;
}
- Log(LOGDEBUG, "%s: Secret key: ", __FUNCTION__);
- LogHex(LOGDEBUG, (char *) secretKey, 128);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Secret key: ", __FUNCTION__);
+ RTMP_LogHex(RTMP_LOGDEBUG, (char *) secretKey, 128);
InitRC4Encryption(secretKey,
(uint8_t *) & serversig[dhposServer],
SHA256_DIGEST_LENGTH, signatureResp);
/* some info output */
- Log(LOGDEBUG,
+ RTMP_Log(RTMP_LOGDEBUG,
"%s: Calculated digest key from secure key and server digest: ",
__FUNCTION__);
- LogHex(LOGDEBUG, digestResp, SHA256_DIGEST_LENGTH);
+ RTMP_LogHex(RTMP_LOGDEBUG, digestResp, SHA256_DIGEST_LENGTH);
#ifdef FP10
if (type == 8 )
}
#endif
#endif
- Log(LOGDEBUG, "%s: Client signature calculated:", __FUNCTION__);
- LogHex(LOGDEBUG, signatureResp, SHA256_DIGEST_LENGTH);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Client signature calculated:", __FUNCTION__);
+ RTMP_LogHex(RTMP_LOGDEBUG, signatureResp, SHA256_DIGEST_LENGTH);
}
else
{
}
#ifdef _DEBUG
- Log(LOGDEBUG, "%s: Sending handshake response: ",
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Sending handshake response: ",
__FUNCTION__);
- LogHex(LOGDEBUG, reply, RTMP_SIG_SIZE);
+ RTMP_LogHex(RTMP_LOGDEBUG, reply, RTMP_SIG_SIZE);
#endif
if (!WriteN(r, reply, RTMP_SIG_SIZE))
return false;
return false;
#ifdef _DEBUG
- Log(LOGDEBUG, "%s: 2nd handshake: ", __FUNCTION__);
- LogHex(LOGDEBUG, serversig, RTMP_SIG_SIZE);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: 2nd handshake: ", __FUNCTION__);
+ RTMP_LogHex(RTMP_LOGDEBUG, serversig, RTMP_SIG_SIZE);
#endif
if (FP9HandShake)
if (serversig[4] == 0 && serversig[5] == 0 && serversig[6] == 0
&& serversig[7] == 0)
{
- Log(LOGDEBUG,
+ RTMP_Log(RTMP_LOGDEBUG,
"%s: Wait, did the server just refuse signed authentication?",
__FUNCTION__);
}
- Log(LOGDEBUG, "%s: Server sent signature:", __FUNCTION__);
- LogHex(LOGDEBUG, &serversig[RTMP_SIG_SIZE - SHA256_DIGEST_LENGTH],
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Server sent signature:", __FUNCTION__);
+ RTMP_LogHex(RTMP_LOGDEBUG, &serversig[RTMP_SIG_SIZE - SHA256_DIGEST_LENGTH],
SHA256_DIGEST_LENGTH);
/* verify server response */
SHA256_DIGEST_LENGTH, signature);
/* show some information */
- Log(LOGDEBUG, "%s: Digest key: ", __FUNCTION__);
- LogHex(LOGDEBUG, digest, SHA256_DIGEST_LENGTH);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Digest key: ", __FUNCTION__);
+ RTMP_LogHex(RTMP_LOGDEBUG, digest, SHA256_DIGEST_LENGTH);
#ifdef FP10
if (type == 8 )
}
#endif
#endif
- Log(LOGDEBUG, "%s: Signature calculated:", __FUNCTION__);
- LogHex(LOGDEBUG, signature, SHA256_DIGEST_LENGTH);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Signature calculated:", __FUNCTION__);
+ RTMP_LogHex(RTMP_LOGDEBUG, signature, SHA256_DIGEST_LENGTH);
if (memcmp
(signature, &serversig[RTMP_SIG_SIZE - SHA256_DIGEST_LENGTH],
SHA256_DIGEST_LENGTH) != 0)
{
- Log(LOGWARNING, "%s: Server not genuine Adobe!", __FUNCTION__);
+ RTMP_Log(RTMP_LOGWARNING, "%s: Server not genuine Adobe!", __FUNCTION__);
return false;
}
else
{
- Log(LOGDEBUG, "%s: Genuine Adobe Flash Media Server", __FUNCTION__);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Genuine Adobe Flash Media Server", __FUNCTION__);
}
if (encrypted)
{
if (memcmp(serversig, clientsig, RTMP_SIG_SIZE) != 0)
{
- Log(LOGWARNING, "%s: client signature does not match!",
+ RTMP_Log(RTMP_LOGWARNING, "%s: client signature does not match!",
__FUNCTION__);
}
}
- Log(LOGDEBUG, "%s: Handshaking finished....", __FUNCTION__);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Handshaking finished....", __FUNCTION__);
return true;
}
if (ReadN(r, &type, 1) != 1) /* 0x03 or 0x06 */
return false;
- Log(LOGDEBUG, "%s: Type Requested : %02X", __FUNCTION__, type);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Type Requested : %02X", __FUNCTION__, type);
if (type == 3)
{
}
else
{
- Log(LOGERROR, "%s: Unknown version %02x",
+ RTMP_Log(RTMP_LOGERROR, "%s: Unknown version %02x",
__FUNCTION__, type);
return false;
}
r->Link.dh = DHInit(128);
if (!r->Link.dh)
{
- Log(LOGERROR, "%s: Couldn't initialize Diffie-Hellmann!",
+ RTMP_Log(RTMP_LOGERROR, "%s: Couldn't initialize Diffie-Hellmann!",
__FUNCTION__);
return false;
}
dhposServer = GetDHOffset2(serversig, RTMP_SIG_SIZE);
- Log(LOGDEBUG, "%s: DH pubkey position: %d", __FUNCTION__, dhposServer);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: DH pubkey position: %d", __FUNCTION__, dhposServer);
if (!DHGenerateKey(r->Link.dh))
{
- Log(LOGERROR, "%s: Couldn't generate Diffie-Hellmann public key!",
+ RTMP_Log(RTMP_LOGERROR, "%s: Couldn't generate Diffie-Hellmann public key!",
__FUNCTION__);
return false;
}
if (!DHGetPublicKey
(r->Link.dh, (uint8_t *) &serversig[dhposServer], 128))
{
- Log(LOGERROR, "%s: Couldn't write public key!", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s: Couldn't write public key!", __FUNCTION__);
return false;
}
}
digestPosServer = GetDigestOffset2(serversig, RTMP_SIG_SIZE); /* reuse this value in verification */
- Log(LOGDEBUG, "%s: Client digest offset: %d", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Client digest offset: %d", __FUNCTION__,
digestPosServer);
CalculateDigest(digestPosServer, serversig, GenuineFMSKey, 36,
&serversig[digestPosServer]);
- Log(LOGDEBUG, "%s: Initial server digest: ", __FUNCTION__);
- LogHex(LOGDEBUG, (char *) serversig + digestPosServer,
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Initial server digest: ", __FUNCTION__);
+ RTMP_LogHex(RTMP_LOGDEBUG, (char *) serversig + digestPosServer,
SHA256_DIGEST_LENGTH);
}
#ifdef _DEBUG
- Log(LOGDEBUG, "Serversig: ");
- LogHex(LOGDEBUG, serversig, RTMP_SIG_SIZE);
+ RTMP_Log(RTMP_LOGDEBUG, "Serversig: ");
+ RTMP_LogHex(RTMP_LOGDEBUG, serversig, RTMP_SIG_SIZE);
#endif
if (!WriteN(r, serversig-1, RTMP_SIG_SIZE + 1))
memcpy(&uptime, clientsig, 4);
uptime = ntohl(uptime);
- Log(LOGDEBUG, "%s: Client Uptime : %d", __FUNCTION__, uptime);
- Log(LOGDEBUG, "%s: Player Version: %d.%d.%d.%d", __FUNCTION__, clientsig[4],
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Client Uptime : %d", __FUNCTION__, uptime);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Player Version: %d.%d.%d.%d", __FUNCTION__, clientsig[4],
clientsig[5], clientsig[6], clientsig[7]);
#ifdef _DEBUG
- Log(LOGDEBUG, "Client signature:");
- LogHex(LOGDEBUG, clientsig, RTMP_SIG_SIZE);
+ RTMP_Log(RTMP_LOGDEBUG, "Client signature:");
+ RTMP_LogHex(RTMP_LOGDEBUG, clientsig, RTMP_SIG_SIZE);
#endif
if (FP9HandShake)
if (!VerifyDigest(digestPosClient, clientsig, GenuineFPKey, 30))
{
- Log(LOGWARNING, "Trying different position for client digest!\n");
+ RTMP_Log(RTMP_LOGWARNING, "Trying different position for client digest!\n");
digestPosClient = GetDigestOffset2(clientsig, RTMP_SIG_SIZE);
if (!VerifyDigest(digestPosClient, clientsig, GenuineFPKey, 30))
{
- Log(LOGERROR, "Couldn't verify the client digest\n"); /* continuing anyway will probably fail */
+ RTMP_Log(RTMP_LOGERROR, "Couldn't verify the client digest\n"); /* continuing anyway will probably fail */
return false;
}
dhposClient = GetDHOffset2(clientsig, RTMP_SIG_SIZE);
dhposClient = GetDHOffset1(clientsig, RTMP_SIG_SIZE);
}
- Log(LOGDEBUG, "%s: Client DH public key offset: %d", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Client DH public key offset: %d", __FUNCTION__,
dhposClient);
/* generate SWFVerification token (SHA256 HMAC hash of decompressed SWF, key are the last 32 bytes of the server handshake) */
secretKey);
if (len < 0)
{
- Log(LOGDEBUG, "%s: Wrong secret key position!", __FUNCTION__);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Wrong secret key position!", __FUNCTION__);
return false;
}
- Log(LOGDEBUG, "%s: Secret key: ", __FUNCTION__);
- LogHex(LOGDEBUG, (char *) secretKey, 128);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Secret key: ", __FUNCTION__);
+ RTMP_LogHex(RTMP_LOGDEBUG, (char *) secretKey, 128);
InitRC4Encryption(secretKey,
(uint8_t *) &clientsig[dhposClient],
SHA256_DIGEST_LENGTH, signatureResp);
/* some info output */
- Log(LOGDEBUG,
+ RTMP_Log(RTMP_LOGDEBUG,
"%s: Calculated digest key from secure key and server digest: ",
__FUNCTION__);
- LogHex(LOGDEBUG, digestResp, SHA256_DIGEST_LENGTH);
+ RTMP_LogHex(RTMP_LOGDEBUG, digestResp, SHA256_DIGEST_LENGTH);
- Log(LOGDEBUG, "%s: Server signature calculated:", __FUNCTION__);
- LogHex(LOGDEBUG, signatureResp, SHA256_DIGEST_LENGTH);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Server signature calculated:", __FUNCTION__);
+ RTMP_LogHex(RTMP_LOGDEBUG, signatureResp, SHA256_DIGEST_LENGTH);
}
else
{
}
#ifdef _DEBUG
- Log(LOGDEBUG, "%s: Sending handshake response: ",
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Sending handshake response: ",
__FUNCTION__);
- LogHex(LOGDEBUG, clientsig, RTMP_SIG_SIZE);
+ RTMP_LogHex(RTMP_LOGDEBUG, clientsig, RTMP_SIG_SIZE);
#endif
if (!WriteN(r, clientsig, RTMP_SIG_SIZE))
return false;
return false;
#ifdef _DEBUG
- Log(LOGDEBUG, "%s: 2nd handshake: ", __FUNCTION__);
- LogHex(LOGDEBUG, clientsig, RTMP_SIG_SIZE);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: 2nd handshake: ", __FUNCTION__);
+ RTMP_LogHex(RTMP_LOGDEBUG, clientsig, RTMP_SIG_SIZE);
#endif
if (FP9HandShake)
char signature[SHA256_DIGEST_LENGTH];
char digest[SHA256_DIGEST_LENGTH];
- Log(LOGDEBUG, "%s: Client sent signature:", __FUNCTION__);
- LogHex(LOGDEBUG, &clientsig[RTMP_SIG_SIZE - SHA256_DIGEST_LENGTH],
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Client sent signature:", __FUNCTION__);
+ RTMP_LogHex(RTMP_LOGDEBUG, &clientsig[RTMP_SIG_SIZE - SHA256_DIGEST_LENGTH],
SHA256_DIGEST_LENGTH);
/* verify client response */
SHA256_DIGEST_LENGTH, signature);
/* show some information */
- Log(LOGDEBUG, "%s: Digest key: ", __FUNCTION__);
- LogHex(LOGDEBUG, digest, SHA256_DIGEST_LENGTH);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Digest key: ", __FUNCTION__);
+ RTMP_LogHex(RTMP_LOGDEBUG, digest, SHA256_DIGEST_LENGTH);
- Log(LOGDEBUG, "%s: Signature calculated:", __FUNCTION__);
- LogHex(LOGDEBUG, signature, SHA256_DIGEST_LENGTH);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Signature calculated:", __FUNCTION__);
+ RTMP_LogHex(RTMP_LOGDEBUG, signature, SHA256_DIGEST_LENGTH);
if (memcmp
(signature, &clientsig[RTMP_SIG_SIZE - SHA256_DIGEST_LENGTH],
SHA256_DIGEST_LENGTH) != 0)
{
- Log(LOGWARNING, "%s: Client not genuine Adobe!", __FUNCTION__);
+ RTMP_Log(RTMP_LOGWARNING, "%s: Client not genuine Adobe!", __FUNCTION__);
return false;
}
else
{
- Log(LOGDEBUG, "%s: Genuine Adobe Flash Player", __FUNCTION__);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Genuine Adobe Flash Player", __FUNCTION__);
}
if (encrypted)
{
if (memcmp(serversig, clientsig, RTMP_SIG_SIZE) != 0)
{
- Log(LOGWARNING, "%s: client signature does not match!",
+ RTMP_Log(RTMP_LOGWARNING, "%s: client signature does not match!",
__FUNCTION__);
}
}
- Log(LOGDEBUG, "%s: Handshaking finished....", __FUNCTION__);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Handshaking finished....", __FUNCTION__);
return true;
}
TLS_setfd(sb.sb_ssl, sb.sb_socket);
if ((i = TLS_connect(sb.sb_ssl)) < 0)
{
- Log(LOGERROR, "%s, TLS_Connect failed", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s, TLS_Connect failed", __FUNCTION__);
ret = HTTPRES_LOST_CONNECTION;
goto leave;
}
if (setsockopt
(sb.sb_socket, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)))
{
- Log(LOGERROR, "%s, Setting socket timeout to %ds failed!",
+ RTMP_Log(RTMP_LOGERROR, "%s, Setting socket timeout to %ds failed!",
__FUNCTION__, HTTP_TIMEOUT);
}
{
ret = -1;
if (httpres == HTTPRES_LOST_CONNECTION)
- Log(LOGERROR, "%s: connection lost while downloading swfurl %s",
+ RTMP_Log(RTMP_LOGERROR, "%s: connection lost while downloading swfurl %s",
__FUNCTION__, url);
else if (httpres == HTTPRES_NOT_FOUND)
- Log(LOGERROR, "%s: swfurl %s not found", __FUNCTION__, url);
+ RTMP_Log(RTMP_LOGERROR, "%s: swfurl %s not found", __FUNCTION__, url);
else
- Log(LOGERROR, "%s: couldn't contact swfurl %s (HTTP error %d)",
+ RTMP_Log(RTMP_LOGERROR, "%s: couldn't contact swfurl %s (HTTP error %d)",
__FUNCTION__, url, http.status);
}
else
if (!f)
{
int err = errno;
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"%s: couldn't open %s for writing, errno %d (%s)",
__FUNCTION__, path, err, strerror(err));
ret = -1;
-#ifndef __HTTP_H__
-#define __HTTP_H__
+#ifndef __RTMP_HTTP_H__
+#define __RTMP_HTTP_H__
/*
* Copyright (C) 2010 Howard Chu
* Copyright (C) 2010 Antti Ajanki
#define MAX_PRINT_LEN 2048
-AMF_LogLevel AMF_debuglevel = LOGERROR;
+RTMP_LogLevel RTMP_debuglevel = RTMP_LOGERROR;
static int neednl;
"DEBUG", "DEBUG2"
};
-void LogSetOutput(FILE *file)
+void RTMP_LogSetOutput(FILE *file)
{
fmsg = file;
}
-void LogPrintf(const char *format, ...)
+void RTMP_LogPrintf(const char *format, ...)
{
char str[MAX_PRINT_LEN]="";
int len;
len = vsnprintf(str, MAX_PRINT_LEN-1, format, args);
va_end(args);
- if ( AMF_debuglevel==LOGCRIT )
+ if ( RTMP_debuglevel==RTMP_LOGCRIT )
return;
if ( !fmsg ) fmsg = stderr;
fflush(fmsg);
}
-void LogStatus(const char *format, ...)
+void RTMP_LogStatus(const char *format, ...)
{
char str[MAX_PRINT_LEN]="";
va_list args;
vsnprintf(str, MAX_PRINT_LEN-1, format, args);
va_end(args);
- if ( AMF_debuglevel==LOGCRIT )
+ if ( RTMP_debuglevel==RTMP_LOGCRIT )
return;
if ( !fmsg ) fmsg = stderr;
neednl = 1;
}
-void Log(int level, const char *format, ...)
+void RTMP_Log(int level, const char *format, ...)
{
char str[MAX_PRINT_LEN]="";
va_list args;
va_end(args);
// Filter out 'no-name'
- if ( AMF_debuglevel<LOGALL && strstr(str, "no-name" ) != NULL )
+ if ( RTMP_debuglevel<RTMP_LOGALL && strstr(str, "no-name" ) != NULL )
return;
if ( !fmsg ) fmsg = stderr;
- if ( level <= AMF_debuglevel ) {
+ if ( level <= RTMP_debuglevel ) {
if (neednl) {
putc('\n', fmsg);
neednl = 0;
}
}
-void LogHex(int level, const char *data, unsigned long len)
+void RTMP_LogHex(int level, const char *data, unsigned long len)
{
unsigned long i;
- if ( level > AMF_debuglevel )
+ if ( level > RTMP_debuglevel )
return;
for(i=0; i<len; i++) {
- LogPrintf("%02X ", (unsigned char)data[i]);
+ RTMP_LogPrintf("%02X ", (unsigned char)data[i]);
}
- LogPrintf("\n");
+ RTMP_LogPrintf("\n");
}
-void LogHexString(int level, const char *data, unsigned long len)
+void RTMP_LogHexString(int level, const char *data, unsigned long len)
{
static const char hexdig[] = "0123456789abcdef";
#define BP_OFFSET 9
char line[BP_LEN];
unsigned long i;
- if ( !data || level > AMF_debuglevel )
+ if ( !data || level > RTMP_debuglevel )
return;
/* in case len is zero */
unsigned off;
if( !n ) {
- if( i ) LogPrintf( "%s", line );
+ if( i ) RTMP_LogPrintf( "%s", line );
memset( line, ' ', sizeof(line)-2 );
line[sizeof(line)-2] = '\n';
line[sizeof(line)-1] = '\0';
}
}
- LogPrintf( "%s", line );
+ RTMP_LogPrintf( "%s", line );
}
/*
* Copyright (C) 2008-2009 Andrej Stepanchuk
- * Copyright (C) 2009 Howard Chu
+ * Copyright (C) 2009-2010 Howard Chu
*
* This file is part of librtmp.
*
* http://www.gnu.org/copyleft/lgpl.html
*/
-#ifndef __LOG_H__
-#define __LOG_H__
+#ifndef __RTMP_LOG_H__
+#define __RTMP_LOG_H__
#include <stdio.h>
#endif
typedef enum
-{ LOGCRIT=0, LOGERROR, LOGWARNING, LOGINFO,
- LOGDEBUG, LOGDEBUG2, LOGALL
-} AMF_LogLevel;
-
-#define Log AMF_Log
-#define LogHex AMF_LogHex
-#define LogHexString AMF_LogHexString
-#define LogPrintf AMF_LogPrintf
-#define LogSetOutput AMF_LogSetOutput
-#define LogStatus AMF_LogStatus
-
-extern AMF_LogLevel AMF_debuglevel;
-
-void LogSetOutput(FILE *file);
-void LogPrintf(const char *format, ...);
-void LogStatus(const char *format, ...);
-void Log(int level, const char *format, ...);
-void LogHex(int level, const char *data, unsigned long len);
-void LogHexString(int level, const char *data, unsigned long len);
+{ RTMP_LOGCRIT=0, RTMP_LOGERROR, RTMP_LOGWARNING, RTMP_LOGINFO,
+ RTMP_LOGDEBUG, RTMP_LOGDEBUG2, RTMP_LOGALL
+} RTMP_LogLevel;
+
+extern RTMP_LogLevel RTMP_debuglevel;
+
+void RTMP_LogSetOutput(FILE *file);
+void RTMP_LogPrintf(const char *format, ...);
+void RTMP_LogStatus(const char *format, ...);
+void RTMP_Log(int level, const char *format, ...);
+void RTMP_LogHex(int level, const char *data, unsigned long len);
+void RTMP_LogHexString(int level, const char *data, unsigned long len);
#ifdef __cplusplus
}
{
char *p, *end, *col, *ques, *slash;
- Log(LOGDEBUG, "Parsing...");
+ RTMP_Log(RTMP_LOGDEBUG, "Parsing...");
*protocol = RTMP_PROTOCOL_RTMP;
*port = 0;
// look for usual :// pattern
p = strstr(url, "://");
if(!p) {
- Log(LOGERROR, "RTMP URL: No :// in url!");
+ RTMP_Log(RTMP_LOGERROR, "RTMP URL: No :// in url!");
return false;
}
{
else if(len == 6 && strncasecmp(url, "rtmpte", 6)==0)
*protocol = RTMP_PROTOCOL_RTMPTE;
else {
- Log(LOGWARNING, "Unknown protocol!\n");
+ RTMP_Log(RTMP_LOGWARNING, "Unknown protocol!\n");
goto parsehost;
}
}
- Log(LOGDEBUG, "Parsed protocol: %d", *protocol);
+ RTMP_Log(RTMP_LOGDEBUG, "Parsed protocol: %d", *protocol);
parsehost:
// lets get the hostname
// check for sudden death
if(*p==0) {
- Log(LOGWARNING, "No hostname in URL!");
+ RTMP_Log(RTMP_LOGWARNING, "No hostname in URL!");
return false;
}
strncpy(*host, p, hostlen);
(*host)[hostlen]=0;
- Log(LOGDEBUG, "Parsed host : %s", *host);
+ RTMP_Log(RTMP_LOGDEBUG, "Parsed host : %s", *host);
} else {
- Log(LOGWARNING, "Hostname exceeds 255 characters!");
+ RTMP_Log(RTMP_LOGWARNING, "Hostname exceeds 255 characters!");
}
p+=hostlen;
p++;
unsigned int p2 = atoi(p);
if(p2 > 65535) {
- Log(LOGWARNING, "Invalid port number!");
+ RTMP_Log(RTMP_LOGWARNING, "Invalid port number!");
} else {
*port = p2;
}
}
if(!slash) {
- Log(LOGWARNING, "No application or playpath in URL!");
+ RTMP_Log(RTMP_LOGWARNING, "No application or playpath in URL!");
return true;
}
p = slash+1;
app->av_val = p;
app->av_len = applen;
- Log(LOGDEBUG, "Parsed app : %.*s", applen, p);
+ RTMP_Log(RTMP_LOGDEBUG, "Parsed app : %.*s", applen, p);
p += appnamelen;
}
void
RTMPPacket_Dump(RTMPPacket *p)
{
- Log(LOGDEBUG,
+ RTMP_Log(RTMP_LOGDEBUG,
"RTMP PACKET: packet type: 0x%02x. channel: 0x%02x. info 1: %d info 2: %d. Body size: %lu. body: 0x%02x",
p->m_packetType, p->m_nChannel, p->m_nInfoField1, p->m_nInfoField2,
p->m_nBodySize, p->m_body ? (unsigned char)p->m_body[0] : 0);
double dTime,
uint32_t dLength, bool bLiveStream, long int timeout)
{
- Log(LOGDEBUG, "Protocol : %s", RTMPProtocolStrings[protocol&7]);
- Log(LOGDEBUG, "Hostname : %s", hostname);
- Log(LOGDEBUG, "Port : %d", port);
- Log(LOGDEBUG, "Playpath : %s", playpath->av_val);
+ RTMP_Log(RTMP_LOGDEBUG, "Protocol : %s", RTMPProtocolStrings[protocol&7]);
+ RTMP_Log(RTMP_LOGDEBUG, "Hostname : %s", hostname);
+ RTMP_Log(RTMP_LOGDEBUG, "Port : %d", port);
+ RTMP_Log(RTMP_LOGDEBUG, "Playpath : %s", playpath->av_val);
if (tcUrl && tcUrl->av_val)
- Log(LOGDEBUG, "tcUrl : %s", tcUrl->av_val);
+ RTMP_Log(RTMP_LOGDEBUG, "tcUrl : %s", tcUrl->av_val);
if (swfUrl && swfUrl->av_val)
- Log(LOGDEBUG, "swfUrl : %s", swfUrl->av_val);
+ RTMP_Log(RTMP_LOGDEBUG, "swfUrl : %s", swfUrl->av_val);
if (pageUrl && pageUrl->av_val)
- Log(LOGDEBUG, "pageUrl : %s", pageUrl->av_val);
+ RTMP_Log(RTMP_LOGDEBUG, "pageUrl : %s", pageUrl->av_val);
if (app && app->av_val)
- Log(LOGDEBUG, "app : %.*s", app->av_len, app->av_val);
+ RTMP_Log(RTMP_LOGDEBUG, "app : %.*s", app->av_len, app->av_val);
if (auth && auth->av_val)
- Log(LOGDEBUG, "auth : %s", auth->av_val);
+ RTMP_Log(RTMP_LOGDEBUG, "auth : %s", auth->av_val);
if (subscribepath && subscribepath->av_val)
- Log(LOGDEBUG, "subscribepath : %s", subscribepath->av_val);
+ RTMP_Log(RTMP_LOGDEBUG, "subscribepath : %s", subscribepath->av_val);
if (flashVer && flashVer->av_val)
- Log(LOGDEBUG, "flashVer : %s", flashVer->av_val);
+ RTMP_Log(RTMP_LOGDEBUG, "flashVer : %s", flashVer->av_val);
if (dTime > 0)
- Log(LOGDEBUG, "SeekTime : %.3f sec", (double)dTime / 1000.0);
+ RTMP_Log(RTMP_LOGDEBUG, "SeekTime : %.3f sec", (double)dTime / 1000.0);
if (dLength > 0)
- Log(LOGDEBUG, "playLength : %.3f sec", (double)dLength / 1000.0);
+ RTMP_Log(RTMP_LOGDEBUG, "playLength : %.3f sec", (double)dLength / 1000.0);
- Log(LOGDEBUG, "live : %s", bLiveStream ? "yes" : "no");
- Log(LOGDEBUG, "timeout : %d sec", timeout);
+ RTMP_Log(RTMP_LOGDEBUG, "live : %s", bLiveStream ? "yes" : "no");
+ RTMP_Log(RTMP_LOGDEBUG, "timeout : %d sec", timeout);
#ifdef CRYPTO
if (swfSHA256Hash != NULL && swfSize > 0)
{
r->Link.SWFHash = *swfSHA256Hash;
r->Link.SWFSize = swfSize;
- Log(LOGDEBUG, "SWFSHA256:");
- LogHex(LOGDEBUG, r->Link.SWFHash.av_val, 32);
- Log(LOGDEBUG, "SWFSize : %lu", r->Link.SWFSize);
+ RTMP_Log(RTMP_LOGDEBUG, "SWFSHA256:");
+ RTMP_LogHex(RTMP_LOGDEBUG, r->Link.SWFHash.av_val, 32);
+ RTMP_Log(RTMP_LOGDEBUG, "SWFSize : %lu", r->Link.SWFSize);
}
else
{
r->Link.sockshost = hostname;
r->Link.socksport = socksport ? atoi(socksport + 1) : 1080;
- Log(LOGDEBUG, "Connecting via SOCKS proxy: %s:%d", r->Link.sockshost,
+ RTMP_Log(RTMP_LOGDEBUG, "Connecting via SOCKS proxy: %s:%d", r->Link.sockshost,
r->Link.socksport);
}
else
struct hostent *host = gethostbyname(hostname);
if (host == NULL || host->h_addr == NULL)
{
- Log(LOGERROR, "Problem accessing the DNS. (addr: %s)", hostname);
+ RTMP_Log(RTMP_LOGERROR, "Problem accessing the DNS. (addr: %s)", hostname);
return false;
}
service->sin_addr = *(struct in_addr *)host->h_addr;
if (connect(r->m_sb.sb_socket, service, sizeof(struct sockaddr)) < 0)
{
int err = GetSockError();
- Log(LOGERROR, "%s, failed to connect socket. %d (%s)",
+ RTMP_Log(RTMP_LOGERROR, "%s, failed to connect socket. %d (%s)",
__FUNCTION__, err, strerror(err));
RTMP_Close(r);
return false;
if (r->Link.socksport)
{
- Log(LOGDEBUG, "%s ... SOCKS negotiation", __FUNCTION__);
+ RTMP_Log(RTMP_LOGDEBUG, "%s ... SOCKS negotiation", __FUNCTION__);
if (!SocksNegotiate(r))
{
- Log(LOGERROR, "%s, SOCKS negotiation failed.", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s, SOCKS negotiation failed.", __FUNCTION__);
RTMP_Close(r);
return false;
}
}
else
{
- Log(LOGERROR, "%s, failed to create socket. Error: %d", __FUNCTION__,
+ RTMP_Log(RTMP_LOGERROR, "%s, failed to create socket. Error: %d", __FUNCTION__,
GetSockError());
return false;
}
if (setsockopt
(r->m_sb.sb_socket, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)))
{
- Log(LOGERROR, "%s, Setting socket timeout to %ds failed!",
+ RTMP_Log(RTMP_LOGERROR, "%s, Setting socket timeout to %ds failed!",
__FUNCTION__, r->Link.timeout);
}
TLS_setfd(r->m_sb.sb_ssl, r->m_sb.sb_socket);
if (TLS_connect(r->m_sb.sb_ssl) < 0)
{
- Log(LOGERROR, "%s, TLS_Connect failed", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s, TLS_Connect failed", __FUNCTION__);
RTMP_Close(r);
return false;
}
HTTP_read(r, 1);
r->m_msgCounter = 0;
}
- Log(LOGDEBUG, "%s, ... connected, handshaking", __FUNCTION__);
+ RTMP_Log(RTMP_LOGDEBUG, "%s, ... connected, handshaking", __FUNCTION__);
if (!HandShake(r, true))
{
- Log(LOGERROR, "%s, handshake failed.", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s, handshake failed.", __FUNCTION__);
RTMP_Close(r);
return false;
}
- Log(LOGDEBUG, "%s, handshaked", __FUNCTION__);
+ RTMP_Log(RTMP_LOGDEBUG, "%s, handshaked", __FUNCTION__);
if (!SendConnectPacket(r, cp))
{
- Log(LOGERROR, "%s, RTMP connect failed.", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s, RTMP connect failed.", __FUNCTION__);
RTMP_Close(r);
return false;
}
}
else
{
- Log(LOGERROR, "%s, SOCKS returned error code %d", packet[1]);
+ RTMP_Log(RTMP_LOGERROR, "%s, SOCKS returned error code %d", packet[1]);
return false;
}
}
(packet.m_packetType == RTMP_PACKET_TYPE_VIDEO) ||
(packet.m_packetType == RTMP_PACKET_TYPE_INFO))
{
- Log(LOGWARNING, "Received FLV packet before play()! Ignoring.");
+ RTMP_Log(RTMP_LOGWARNING, "Received FLV packet before play()! Ignoring.");
RTMPPacket_Free(&packet);
continue;
}
{
bHasMediaPacket = 0;
#ifdef _DEBUG
- Log(LOGDEBUG,
+ RTMP_Log(RTMP_LOGDEBUG,
"Skipped type: %02X, size: %d, TS: %d ms, abs TS: %d, pause: %d ms",
packet->m_packetType, packet->m_nBodySize,
packet->m_nTimeStamp, packet->m_hasAbsTimestamp,
case 0x03:
// bytes read report
- Log(LOGDEBUG, "%s, received: bytes read report", __FUNCTION__);
+ RTMP_Log(RTMP_LOGDEBUG, "%s, received: bytes read report", __FUNCTION__);
break;
case 0x04:
case 0x08:
// audio data
- //Log(LOGDEBUG, "%s, received: audio %lu bytes", __FUNCTION__, packet.m_nBodySize);
+ //RTMP_Log(RTMP_LOGDEBUG, "%s, received: audio %lu bytes", __FUNCTION__, packet.m_nBodySize);
HandleAudio(r, packet);
bHasMediaPacket = 1;
if (!r->m_mediaChannel)
case 0x09:
// video data
- //Log(LOGDEBUG, "%s, received: video %lu bytes", __FUNCTION__, packet.m_nBodySize);
+ //RTMP_Log(RTMP_LOGDEBUG, "%s, received: video %lu bytes", __FUNCTION__, packet.m_nBodySize);
HandleVideo(r, packet);
bHasMediaPacket = 1;
if (!r->m_mediaChannel)
break;
case 0x0F: // flex stream send
- Log(LOGDEBUG,
+ RTMP_Log(RTMP_LOGDEBUG,
"%s, flex stream send, size %lu bytes, not supported, ignoring",
__FUNCTION__, packet->m_nBodySize);
break;
case 0x10: // flex shared object
- Log(LOGDEBUG,
+ RTMP_Log(RTMP_LOGDEBUG,
"%s, flex shared object, size %lu bytes, not supported, ignoring",
__FUNCTION__, packet->m_nBodySize);
break;
case 0x11: // flex message
{
- Log(LOGDEBUG,
+ RTMP_Log(RTMP_LOGDEBUG,
"%s, flex message, size %lu bytes, not fully supported",
__FUNCTION__, packet->m_nBodySize);
- //LogHex(packet.m_body, packet.m_nBodySize);
+ //RTMP_LogHex(packet.m_body, packet.m_nBodySize);
// some DEBUG code
/*RTMP_LIB_AMFObject obj;
int nRes = obj.Decode(packet.m_body+1, packet.m_nBodySize-1);
if(nRes < 0) {
- Log(LOGERROR, "%s, error decoding AMF3 packet", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s, error decoding AMF3 packet", __FUNCTION__);
//return;
}
}
case 0x12:
// metadata (notify)
- Log(LOGDEBUG, "%s, received: notify %lu bytes", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s, received: notify %lu bytes", __FUNCTION__,
packet->m_nBodySize);
if (HandleMetadata(r, packet->m_body, packet->m_nBodySize))
bHasMediaPacket = 1;
break;
case 0x13:
- Log(LOGDEBUG, "%s, shared object, not supported, ignoring",
+ RTMP_Log(RTMP_LOGDEBUG, "%s, shared object, not supported, ignoring",
__FUNCTION__);
break;
case 0x14:
// invoke
- Log(LOGDEBUG, "%s, received: invoke %lu bytes", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s, received: invoke %lu bytes", __FUNCTION__,
packet->m_nBodySize);
- //LogHex(packet.m_body, packet.m_nBodySize);
+ //RTMP_LogHex(packet.m_body, packet.m_nBodySize);
if (HandleInvoke(r, packet->m_body, packet->m_nBodySize) == 1)
bHasMediaPacket = 2;
if (pos + 11 + dataSize + 4 > packet->m_nBodySize)
{
- Log(LOGWARNING, "Stream corrupt?!");
+ RTMP_Log(RTMP_LOGWARNING, "Stream corrupt?!");
break;
}
if (packet->m_body[pos] == 0x12)
r->m_mediaStamp = nTimeStamp;
// FLV tag(s)
- //Log(LOGDEBUG, "%s, received: FLV tag(s) %lu bytes", __FUNCTION__, packet.m_nBodySize);
+ //RTMP_Log(RTMP_LOGDEBUG, "%s, received: FLV tag(s) %lu bytes", __FUNCTION__, packet.m_nBodySize);
bHasMediaPacket = 1;
break;
}
default:
- Log(LOGDEBUG, "%s, unknown packet type received: 0x%02x", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s, unknown packet type received: 0x%02x", __FUNCTION__,
packet->m_packetType);
#ifdef _DEBUG
- LogHex(LOGDEBUG, packet->m_body, packet->m_nBodySize);
+ RTMP_LogHex(RTMP_LOGDEBUG, packet->m_body, packet->m_nBodySize);
#endif
}
&& r->m_nBytesIn > r->m_nBytesInSent + r->m_nClientBW / 2)
SendBytesReceived(r);
}
- //Log(LOGDEBUG, "%s: %d bytes\n", __FUNCTION__, nBytes);
+ //RTMP_Log(RTMP_LOGDEBUG, "%s: %d bytes\n", __FUNCTION__, nBytes);
#ifdef _DEBUG
fwrite(ptr, 1, nBytes, netstackdump_read);
#endif
if (nBytes == 0)
{
- Log(LOGDEBUG, "%s, RTMP socket closed by peer", __FUNCTION__);
+ RTMP_Log(RTMP_LOGDEBUG, "%s, RTMP socket closed by peer", __FUNCTION__);
//goto again;
RTMP_Close(r);
break;
nBytes = HTTP_Post(r, RTMPT_SEND, ptr, n);
else
nBytes = RTMPSockBuf_Send(&r->m_sb, ptr, n);
- //Log(LOGDEBUG, "%s: %d\n", __FUNCTION__, nBytes);
+ //RTMP_Log(RTMP_LOGDEBUG, "%s: %d\n", __FUNCTION__, nBytes);
if (nBytes < 0)
{
int sockerr = GetSockError();
- Log(LOGERROR, "%s, RTMP send error %d (%d bytes)", __FUNCTION__,
+ RTMP_Log(RTMP_LOGERROR, "%s, RTMP send error %d (%d bytes)", __FUNCTION__,
sockerr, n);
if (sockerr == EINTR && !RTMP_ctrlC)
packet.m_hasAbsTimestamp = 0;
packet.m_body = pbuf + RTMP_MAX_HEADER_SIZE;
- Log(LOGDEBUG, "FCSubscribe: %s", subscribepath->av_val);
+ RTMP_Log(RTMP_LOGDEBUG, "FCSubscribe: %s", subscribepath->av_val);
char *enc = packet.m_body;
enc = AMF_EncodeString(enc, pend, &av_FCSubscribe);
enc = AMF_EncodeNumber(enc, pend, ++r->m_numInvokes);
packet.m_nBodySize = enc - packet.m_body;
- Log(LOGDEBUG, "%s, %d, pauseTime=%.2f", __FUNCTION__, DoPause, dTime);
+ RTMP_Log(RTMP_LOGDEBUG, "%s, %d, pauseTime=%.2f", __FUNCTION__, DoPause, dTime);
return RTMP_SendPacket(r, &packet, true);
}
AMF_EncodeInt32(packet.m_body, pend, r->m_nBytesIn); // hard coded for now
r->m_nBytesInSent = r->m_nBytesIn;
- //Log(LOGDEBUG, "Send bytes report. 0x%x (%d bytes)", (unsigned int)m_nBytesIn, 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);
}
enc = AMF_EncodeNumber(enc, pend, ++r->m_numInvokes);
*enc++ = AMF_NULL;
- Log(LOGDEBUG, "%s, seekTime=%.2f, dLength=%d, sending play: %s",
+ RTMP_Log(RTMP_LOGDEBUG, "%s, seekTime=%.2f, dLength=%d, sending play: %s",
__FUNCTION__, r->Link.seekTime, r->Link.length,
r->Link.playpath.av_val);
enc = AMF_EncodeString(enc, pend, &r->Link.playpath);
bool
RTMP_SendCtrl(RTMP *r, short nType, unsigned int nObject, unsigned int nTime)
{
- Log(LOGDEBUG, "sending ctrl. type: 0x%04x", (unsigned short)nType);
+ RTMP_Log(RTMP_LOGDEBUG, "sending ctrl. type: 0x%04x", (unsigned short)nType);
RTMPPacket packet;
char pbuf[256], *pend = pbuf + sizeof(pbuf);
{
#ifdef CRYPTO
memcpy(buf, r->Link.SWFVerificationResponse, 42);
- Log(LOGDEBUG, "Sending SWFVerification response: ");
- LogHex(LOGDEBUG, packet.m_body, packet.m_nBodySize);
+ RTMP_Log(RTMP_LOGDEBUG, "Sending SWFVerification response: ");
+ RTMP_LogHex(RTMP_LOGDEBUG, packet.m_body, packet.m_nBodySize);
#endif
}
else
int ret = 0, nRes;
if (body[0] != 0x02) // make sure it is a string method name we start with
{
- Log(LOGWARNING, "%s, Sanity failed. no string method in invoke packet",
+ RTMP_Log(RTMP_LOGWARNING, "%s, Sanity failed. no string method in invoke packet",
__FUNCTION__);
return 0;
}
nRes = AMF_Decode(&obj, body, nBodySize, false);
if (nRes < 0)
{
- Log(LOGERROR, "%s, error decoding invoke packet", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s, error decoding invoke packet", __FUNCTION__);
return 0;
}
AVal method;
AMFProp_GetString(AMF_GetProp(&obj, NULL, 0), &method);
double txn = AMFProp_GetNumber(AMF_GetProp(&obj, NULL, 1));
- Log(LOGDEBUG, "%s, server invoking <%s>", __FUNCTION__, method.av_val);
+ RTMP_Log(RTMP_LOGDEBUG, "%s, server invoking <%s>", __FUNCTION__, method.av_val);
if (AVMATCH(&method, &av__result))
{
AVal methodInvoked = r->m_methodCalls[0];
AV_erase(r->m_methodCalls, &r->m_numCalls, 0, false);
- Log(LOGDEBUG, "%s, received result for method call <%s>", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s, received result for method call <%s>", __FUNCTION__,
methodInvoked.av_val);
if (AVMATCH(&methodInvoked, &av_connect))
}
else if (AVMATCH(&method, &av__error))
{
- Log(LOGERROR, "rtmp server sent error");
+ RTMP_Log(RTMP_LOGERROR, "rtmp server sent error");
}
else if (AVMATCH(&method, &av_close))
{
- Log(LOGERROR, "rtmp server requested close");
+ RTMP_Log(RTMP_LOGERROR, "rtmp server requested close");
RTMP_Close(r);
}
else if (AVMATCH(&method, &av_onStatus))
AMFProp_GetString(AMF_GetProp(&obj2, &av_code, -1), &code);
AMFProp_GetString(AMF_GetProp(&obj2, &av_level, -1), &level);
- Log(LOGDEBUG, "%s, onStatus: %s", __FUNCTION__, code.av_val);
+ RTMP_Log(RTMP_LOGDEBUG, "%s, onStatus: %s", __FUNCTION__, code.av_val);
if (AVMATCH(&code, &av_NetStream_Failed)
|| AVMATCH(&code, &av_NetStream_Play_Failed)
|| AVMATCH(&code, &av_NetStream_Play_StreamNotFound)
{
r->m_stream_id = -1;
RTMP_Close(r);
- Log(LOGERROR, "Closing connection: %s", code.av_val);
+ RTMP_Log(RTMP_LOGERROR, "Closing connection: %s", code.av_val);
}
else if (AVMATCH(&code, &av_NetStream_Play_Start))
// chomp
if (strlen(str) >= 1 && str[strlen(str) - 1] == '\n')
str[strlen(str) - 1] = '\0';
- LogPrintf(" %-22.*s%s\n", prop->p_name.av_len,
+ RTMP_LogPrintf(" %-22.*s%s\n", prop->p_name.av_len,
prop->p_name.av_val, str);
}
}
else
{
if (prop->p_name.av_len)
- LogPrintf("%.*s:\n", prop->p_name.av_len, prop->p_name.av_val);
+ RTMP_LogPrintf("%.*s:\n", prop->p_name.av_len, prop->p_name.av_val);
DumpMetaData(&prop->p_vu.p_object);
}
}
int nRes = AMF_Decode(&obj, body, len, false);
if (nRes < 0)
{
- Log(LOGERROR, "%s, error decoding meta data packet", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s, error decoding meta data packet", __FUNCTION__);
return false;
}
{
AMFObjectProperty prop;
// Show metadata
- LogPrintf("Metadata:\n");
+ RTMP_LogPrintf("Metadata:\n");
DumpMetaData(&obj);
if (RTMP_FindFirstMatchingProperty(&obj, &av_duration, &prop))
{
r->m_fDuration = prop.p_vu.p_number;
- //Log(LOGDEBUG, "Set duration: %.2f", m_fDuration);
+ //RTMP_Log(RTMP_LOGDEBUG, "Set duration: %.2f", m_fDuration);
}
ret = true;
}
if (packet->m_nBodySize >= 4)
{
r->m_inChunkSize = AMF_DecodeInt32(packet->m_body);
- Log(LOGDEBUG, "%s, received: chunk size change to %d", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s, received: chunk size change to %d", __FUNCTION__,
r->m_inChunkSize);
}
}
unsigned int tmp;
if (packet->m_body && packet->m_nBodySize >= 2)
nType = AMF_DecodeInt16(packet->m_body);
- Log(LOGDEBUG, "%s, received ctrl. type: %d, len: %d", __FUNCTION__, nType,
+ RTMP_Log(RTMP_LOGDEBUG, "%s, received ctrl. type: %d, len: %d", __FUNCTION__, nType,
packet->m_nBodySize);
- //LogHex(packet.m_body, packet.m_nBodySize);
+ //RTMP_LogHex(packet.m_body, packet.m_nBodySize);
if (packet->m_nBodySize >= 6)
{
{
case 0:
tmp = AMF_DecodeInt32(packet->m_body + 2);
- Log(LOGDEBUG, "%s, Stream Begin %d", __FUNCTION__, tmp);
+ RTMP_Log(RTMP_LOGDEBUG, "%s, Stream Begin %d", __FUNCTION__, tmp);
break;
case 1:
tmp = AMF_DecodeInt32(packet->m_body + 2);
- Log(LOGDEBUG, "%s, Stream EOF %d", __FUNCTION__, tmp);
+ RTMP_Log(RTMP_LOGDEBUG, "%s, Stream EOF %d", __FUNCTION__, tmp);
if (r->m_pausing == 1)
r->m_pausing = 2;
break;
case 2:
tmp = AMF_DecodeInt32(packet->m_body + 2);
- Log(LOGDEBUG, "%s, Stream Dry %d", __FUNCTION__, tmp);
+ RTMP_Log(RTMP_LOGDEBUG, "%s, Stream Dry %d", __FUNCTION__, tmp);
break;
case 4:
tmp = AMF_DecodeInt32(packet->m_body + 2);
- Log(LOGDEBUG, "%s, Stream IsRecorded %d", __FUNCTION__, tmp);
+ RTMP_Log(RTMP_LOGDEBUG, "%s, Stream IsRecorded %d", __FUNCTION__, tmp);
break;
case 6: // server ping. reply with pong.
tmp = AMF_DecodeInt32(packet->m_body + 2);
- Log(LOGDEBUG, "%s, Ping %d", __FUNCTION__, tmp);
+ RTMP_Log(RTMP_LOGDEBUG, "%s, Ping %d", __FUNCTION__, tmp);
RTMP_SendCtrl(r, 0x07, tmp, 0);
break;
case 31:
tmp = AMF_DecodeInt32(packet->m_body + 2);
- Log(LOGDEBUG, "%s, Stream BufferEmpty %d", __FUNCTION__, tmp);
+ RTMP_Log(RTMP_LOGDEBUG, "%s, Stream BufferEmpty %d", __FUNCTION__, tmp);
if (r->Link.bLiveStream || (r->Link.protocol & RTMP_FEATURE_HTTP))
break;
if (!r->m_pausing)
case 32:
tmp = AMF_DecodeInt32(packet->m_body + 2);
- Log(LOGDEBUG, "%s, Stream BufferReady %d", __FUNCTION__, tmp);
+ RTMP_Log(RTMP_LOGDEBUG, "%s, Stream BufferReady %d", __FUNCTION__, tmp);
break;
default:
tmp = AMF_DecodeInt32(packet->m_body + 2);
- Log(LOGDEBUG, "%s, Stream xx %d", __FUNCTION__, tmp);
+ RTMP_Log(RTMP_LOGDEBUG, "%s, Stream xx %d", __FUNCTION__, tmp);
break;
}
if (nType == 0x1A)
{
- Log(LOGDEBUG, "%s, SWFVerification ping received: ", __FUNCTION__);
+ RTMP_Log(RTMP_LOGDEBUG, "%s, SWFVerification ping received: ", __FUNCTION__);
#ifdef CRYPTO
- //LogHex(packet.m_body, packet.m_nBodySize);
+ //RTMP_LogHex(packet.m_body, packet.m_nBodySize);
// respond with HMAC SHA256 of decompressed SWF, key is the 30byte player key, also the last 30 bytes of the server handshake are applied
if (r->Link.SWFHash.av_len)
}
else
{
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"%s: Ignoring SWFVerification request, use --swfVfy!",
__FUNCTION__);
}
#else
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"%s: Ignoring SWFVerification request, no CRYPTO support!",
__FUNCTION__);
#endif
HandleServerBW(RTMP *r, const RTMPPacket *packet)
{
r->m_nServerBW = AMF_DecodeInt32(packet->m_body);
- Log(LOGDEBUG, "%s: server BW = %d", __FUNCTION__, r->m_nServerBW);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: server BW = %d", __FUNCTION__, r->m_nServerBW);
}
static void
r->m_nClientBW2 = packet->m_body[4];
else
r->m_nClientBW2 = -1;
- Log(LOGDEBUG, "%s: client BW = %d %d", __FUNCTION__, r->m_nClientBW,
+ RTMP_Log(RTMP_LOGDEBUG, "%s: client BW = %d %d", __FUNCTION__, r->m_nClientBW,
r->m_nClientBW2);
}
{
char hbuf[RTMP_MAX_HEADER_SIZE] = { 0 }, *header = hbuf;
- Log(LOGDEBUG2, "%s: fd=%d", __FUNCTION__, r->m_sb.sb_socket);
+ RTMP_Log(RTMP_LOGDEBUG2, "%s: fd=%d", __FUNCTION__, r->m_sb.sb_socket);
if (ReadN(r, hbuf, 1) == 0)
{
- Log(LOGERROR, "%s, failed to read RTMP packet header", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s, failed to read RTMP packet header", __FUNCTION__);
return false;
}
{
if (ReadN(r, &hbuf[1], 1) != 1)
{
- Log(LOGERROR, "%s, failed to read RTMP packet header 2nd byte",
+ RTMP_Log(RTMP_LOGERROR, "%s, failed to read RTMP packet header 2nd byte",
__FUNCTION__);
return false;
}
int tmp;
if (ReadN(r, &hbuf[1], 2) != 2)
{
- Log(LOGERROR, "%s, failed to read RTMP packet header 3nd byte",
+ RTMP_Log(RTMP_LOGERROR, "%s, failed to read RTMP packet header 3nd byte",
__FUNCTION__);
return false;
}
tmp = (((unsigned)hbuf[2]) << 8) + (unsigned)hbuf[1];
packet->m_nChannel = tmp + 64;
- Log(LOGDEBUG, "%s, m_nChannel: %0x", __FUNCTION__, packet->m_nChannel);
+ RTMP_Log(RTMP_LOGDEBUG, "%s, m_nChannel: %0x", __FUNCTION__, packet->m_nChannel);
header += 2;
}
if (nSize > 0 && ReadN(r, header, nSize) != nSize)
{
- Log(LOGERROR, "%s, failed to read RTMP packet header. type: %x",
+ RTMP_Log(RTMP_LOGERROR, "%s, failed to read RTMP packet header. type: %x",
__FUNCTION__, (unsigned int)hbuf[0]);
return false;
}
{
packet->m_nInfoField1 = AMF_DecodeInt24(header);
- //Log(LOGDEBUG, "%s, reading RTMP packet chunk on channel %x, headersz %i, timestamp %i, abs timestamp %i", __FUNCTION__, packet.m_nChannel, nSize, packet.m_nInfoField1, packet.m_hasAbsTimestamp);
+ //RTMP_Log(RTMP_LOGDEBUG, "%s, reading RTMP packet chunk on channel %x, headersz %i, timestamp %i, abs timestamp %i", __FUNCTION__, packet.m_nChannel, nSize, packet.m_nInfoField1, packet.m_hasAbsTimestamp);
if (nSize >= 6)
{
{
if (ReadN(r, header + nSize, 4) != 4)
{
- Log(LOGERROR, "%s, failed to read extended timestamp",
+ RTMP_Log(RTMP_LOGERROR, "%s, failed to read extended timestamp",
__FUNCTION__);
return false;
}
}
}
- LogHexString(LOGDEBUG2, hbuf, hSize);
+ RTMP_LogHexString(RTMP_LOGDEBUG2, hbuf, hSize);
bool didAlloc = false;
if (packet->m_nBodySize > 0 && packet->m_body == NULL)
{
if (!RTMPPacket_Alloc(packet, packet->m_nBodySize))
{
- Log(LOGDEBUG, "%s, failed to allocate packet", __FUNCTION__);
+ RTMP_Log(RTMP_LOGDEBUG, "%s, failed to allocate packet", __FUNCTION__);
return false;
}
didAlloc = true;
if (ReadN(r, packet->m_body + packet->m_nBytesRead, nChunk) != nChunk)
{
- Log(LOGERROR, "%s, failed to read RTMP packet body. len: %lu",
+ RTMP_Log(RTMP_LOGERROR, "%s, failed to read RTMP packet body. len: %lu",
__FUNCTION__, packet->m_nBodySize);
return false;
}
- LogHexString(LOGDEBUG2, packet->m_body + packet->m_nBytesRead, nChunk);
+ RTMP_LogHexString(RTMP_LOGDEBUG2, packet->m_body + packet->m_nBytesRead, nChunk);
packet->m_nBytesRead += nChunk;
if (ReadN(r, &type, 1) != 1) // 0x03 or 0x06
return false;
- Log(LOGDEBUG, "%s: Type Answer : %02X", __FUNCTION__, type);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Type Answer : %02X", __FUNCTION__, type);
if (type != clientbuf[0])
- Log(LOGWARNING, "%s: Type mismatch: client sent %d, server answered %d",
+ RTMP_Log(RTMP_LOGWARNING, "%s: Type mismatch: client sent %d, server answered %d",
__FUNCTION__, clientbuf[0], type);
if (ReadN(r, serversig, RTMP_SIG_SIZE) != RTMP_SIG_SIZE)
memcpy(&suptime, serversig, 4);
suptime = ntohl(suptime);
- Log(LOGDEBUG, "%s: Server Uptime : %d", __FUNCTION__, suptime);
- Log(LOGDEBUG, "%s: FMS Version : %d.%d.%d.%d", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Server Uptime : %d", __FUNCTION__, suptime);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: FMS Version : %d.%d.%d.%d", __FUNCTION__,
serversig[4], serversig[5], serversig[6], serversig[7]);
// 2nd part of handshake
bool bMatch = (memcmp(serversig, clientsig, RTMP_SIG_SIZE) == 0);
if (!bMatch)
{
- Log(LOGWARNING, "%s, client signature does not match!", __FUNCTION__);
+ RTMP_Log(RTMP_LOGWARNING, "%s, client signature does not match!", __FUNCTION__);
}
return true;
}
if (ReadN(r, serverbuf, 1) != 1) // 0x03 or 0x06
return false;
- Log(LOGDEBUG, "%s: Type Request : %02X", __FUNCTION__, serverbuf[0]);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Type Request : %02X", __FUNCTION__, serverbuf[0]);
if (serverbuf[0] != 3)
{
- Log(LOGERROR, "%s: Type unknown: client sent %02X",
+ RTMP_Log(RTMP_LOGERROR, "%s: Type unknown: client sent %02X",
__FUNCTION__, serverbuf[0]);
return false;
}
memcpy(&uptime, clientsig, 4);
uptime = ntohl(uptime);
- Log(LOGDEBUG, "%s: Client Uptime : %d", __FUNCTION__, uptime);
- Log(LOGDEBUG, "%s: Player Version: %d.%d.%d.%d", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Client Uptime : %d", __FUNCTION__, uptime);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Player Version: %d.%d.%d.%d", __FUNCTION__,
clientsig[4], clientsig[5], clientsig[6], clientsig[7]);
// 2nd part of handshake
bool bMatch = (memcmp(serversig, clientsig, RTMP_SIG_SIZE) == 0);
if (!bMatch)
{
- Log(LOGWARNING, "%s, client signature does not match!", __FUNCTION__);
+ RTMP_Log(RTMP_LOGWARNING, "%s, client signature does not match!", __FUNCTION__);
}
return true;
}
bool wrote;
char hbuf[RTMP_MAX_HEADER_SIZE];
- Log(LOGDEBUG2, "%s: fd=%d, size=%d", __FUNCTION__, r->m_sb.sb_socket,
+ RTMP_Log(RTMP_LOGDEBUG2, "%s: fd=%d, size=%d", __FUNCTION__, r->m_sb.sb_socket,
chunk->c_chunkSize);
- LogHexString(LOGDEBUG2, chunk->c_header, chunk->c_headerSize);
+ RTMP_LogHexString(RTMP_LOGDEBUG2, chunk->c_header, chunk->c_headerSize);
if (chunk->c_chunkSize)
{
char *ptr = chunk->c_chunk - chunk->c_headerSize;
- LogHexString(LOGDEBUG2, chunk->c_chunk, chunk->c_chunkSize);
+ RTMP_LogHexString(RTMP_LOGDEBUG2, chunk->c_chunk, chunk->c_chunkSize);
/* save header bytes we're about to overwrite */
memcpy(hbuf, ptr, chunk->c_headerSize);
memcpy(ptr, chunk->c_header, chunk->c_headerSize);
if (packet->m_headerType > 3) // sanity
{
- Log(LOGERROR, "sanity failed!! trying to send header of type: 0x%02x.",
+ RTMP_Log(RTMP_LOGERROR, "sanity failed!! trying to send header of type: 0x%02x.",
(unsigned char)packet->m_headerType);
return false;
}
int nChunkSize = r->m_outChunkSize;
int tlen;
- Log(LOGDEBUG2, "%s: fd=%d, size=%d", __FUNCTION__, r->m_sb.sb_socket,
+ RTMP_Log(RTMP_LOGDEBUG2, "%s: fd=%d, size=%d", __FUNCTION__, r->m_sb.sb_socket,
nSize);
/* send all chunks in one HTTP request */
if (r->Link.protocol & RTMP_FEATURE_HTTP)
if (nSize < nChunkSize)
nChunkSize = nSize;
- LogHexString(LOGDEBUG2, header, hSize);
- LogHexString(LOGDEBUG2, buffer, nChunkSize);
+ RTMP_LogHexString(RTMP_LOGDEBUG2, header, hSize);
+ RTMP_LogHexString(RTMP_LOGDEBUG2, buffer, nChunkSize);
if (tbuf)
{
memcpy(toff, header, nChunkSize + hSize);
{
AVal method;
AMF_DecodeString(packet->m_body + 1, &method);
- Log(LOGDEBUG, "Invoking %s", method.av_val);
+ RTMP_Log(RTMP_LOGDEBUG, "Invoking %s", method.av_val);
/* keep it in call queue till result arrives */
if (queue)
AV_queue(&r->m_methodCalls, &r->m_numCalls, &method);
else
{
int sockerr = GetSockError();
- Log(LOGDEBUG, "%s, recv returned %d. GetSockError(): %d (%s)",
+ RTMP_Log(RTMP_LOGDEBUG, "%s, recv returned %d. GetSockError(): %d (%s)",
__FUNCTION__, nBytes, sockerr, strerror(sockerr));
if (sockerr == EINTR && !RTMP_ctrlC)
continue;
*/
if (rtnGetNextMediaPacket == 2)
{
- Log(LOGDEBUG,
+ RTMP_Log(RTMP_LOGDEBUG,
"Got Play.Complete or Play.Stop from server. "
"Assuming stream is complete");
ret = RTMP_READ_COMPLETE;
if (packet.m_packetType == 0x09 && nPacketLen <= 5)
{
- Log(LOGWARNING, "ignoring too small video packet: size: %d",
+ RTMP_Log(RTMP_LOGWARNING, "ignoring too small video packet: size: %d",
nPacketLen);
ret = RTMP_READ_IGNORE;
break;
}
if (packet.m_packetType == 0x08 && nPacketLen <= 1)
{
- Log(LOGWARNING, "ignoring too small audio packet: size: %d",
+ RTMP_Log(RTMP_LOGWARNING, "ignoring too small audio packet: size: %d",
nPacketLen);
ret = RTMP_READ_IGNORE;
break;
break;
}
#ifdef _DEBUG
- Log(LOGDEBUG, "type: %02X, size: %d, TS: %d ms, abs TS: %d",
+ RTMP_Log(RTMP_LOGDEBUG, "type: %02X, size: %d, TS: %d ms, abs TS: %d",
packet.m_packetType, nPacketLen, packet.m_nTimeStamp,
packet.m_hasAbsTimestamp);
if (packet.m_packetType == 0x09)
- Log(LOGDEBUG, "frametype: %02X", (*packetBody & 0xf0));
+ RTMP_Log(RTMP_LOGDEBUG, "frametype: %02X", (*packetBody & 0xf0));
#endif
if (r->m_read.flags & RTMP_READ_RESUME)
(r->m_read.initialFrame, packetBody,
r->m_read.nInitialFrameSize) == 0)
{
- Log(LOGDEBUG, "Checked keyframe successfully!");
+ RTMP_Log(RTMP_LOGDEBUG, "Checked keyframe successfully!");
r->m_read.flags |= RTMP_READ_GOTKF;
/* ignore it! (what about audio data after it? it is
* handled by ignoring all 0ms frames, see below)
ts |= (packetBody[pos + 7] << 24);
#ifdef _DEBUG
- Log(LOGDEBUG,
+ RTMP_Log(RTMP_LOGDEBUG,
"keyframe search: FLV Packet: type %02X, dataSize: %d, timeStamp: %d ms",
packetBody[pos], dataSize, ts);
#endif
{
if (ts == r->m_read.nResumeTS)
{
- Log(LOGDEBUG,
+ RTMP_Log(RTMP_LOGDEBUG,
"Found keyframe with resume-keyframe timestamp!");
if (r->m_read.nInitialFrameSize != dataSize
|| memcmp(r->m_read.initialFrame,
r->m_read.
nInitialFrameSize) != 0)
{
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"FLV Stream: Keyframe doesn't match!");
ret = RTMP_READ_ERROR;
break;
*/
if (pos + 11 + dataSize + 4 > nPacketLen)
{
- Log(LOGWARNING,
+ RTMP_Log(RTMP_LOGWARNING,
"Non skipable packet since it doesn't end with chunk, stream corrupt!");
ret = RTMP_READ_ERROR;
break;
}
if (ts < r->m_read.nResumeTS)
{
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"First packet does not contain keyframe, all "
"timestamps are smaller than the keyframe "
"timestamp; probably the resume seek failed?");
;
if (!(r->m_read.flags & RTMP_READ_GOTFLVK))
{
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"Couldn't find the seeked keyframe in this chunk!");
ret = RTMP_READ_IGNORE;
break;
if (!(r->m_read.flags & RTMP_READ_GOTKF) &&
packet.m_packetType != 0x16)
{
- Log(LOGWARNING,
+ RTMP_Log(RTMP_LOGWARNING,
"Stream does not start with requested frame, ignoring data... ");
r->m_read.nIgnoredFrameCounter++;
if (r->m_read.nIgnoredFrameCounter > MAX_IGNORED_FRAMES)
if (!(r->m_read.flags & RTMP_READ_GOTFLVK) &&
packet.m_packetType == 0x16)
{
- Log(LOGWARNING,
+ RTMP_Log(RTMP_LOGWARNING,
"Stream does not start with requested FLV frame, ignoring data... ");
r->m_read.nIgnoredFlvFrameCounter++;
if (r->m_read.nIgnoredFlvFrameCounter > MAX_IGNORED_FRAMES)
r->m_read.buf = malloc(size + 4);
if (r->m_read.buf == 0)
{
- Log(LOGERROR, "Couldn't allocate memory!");
+ RTMP_Log(RTMP_LOGERROR, "Couldn't allocate memory!");
ret = RTMP_READ_ERROR; // fatal error
break;
}
uint32_t ts = AMF_DecodeInt24(packetBody+2); // composition time
int32_t cts = (ts+0xff800000)^0xff800000;
- Log(LOGDEBUG, "cts : %d\n", cts);
+ RTMP_Log(RTMP_LOGDEBUG, "cts : %d\n", cts);
nTimeStamp -= cts;
// get rid of the composition time
CRTMP::EncodeInt24(packetBody+2, 0);
}
- Log(LOGDEBUG, "VIDEO: nTimeStamp: 0x%08X (%d)\n", nTimeStamp, nTimeStamp);
+ RTMP_Log(RTMP_LOGDEBUG, "VIDEO: nTimeStamp: 0x%08X (%d)\n", nTimeStamp, nTimeStamp);
} */
ptr = AMF_EncodeInt24(ptr, pend, nTimeStamp);
{
if (pos + 11 + dataSize > nPacketLen)
{
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"Wrong data size (%lu), stream corrupted, aborting!",
dataSize);
ret = RTMP_READ_ERROR;
break;
}
- Log(LOGWARNING, "No tagSize found, appending!");
+ RTMP_Log(RTMP_LOGWARNING, "No tagSize found, appending!");
/* we have to append a last tagSize! */
prevTagSize = dataSize + 11;
AMF_DecodeInt32(packetBody + pos + 11 + dataSize);
#ifdef _DEBUG
- Log(LOGDEBUG,
+ RTMP_Log(RTMP_LOGDEBUG,
"FLV Packet: type %02X, dataSize: %lu, tagSize: %lu, timeStamp: %lu ms",
(unsigned char)packetBody[pos], dataSize, prevTagSize,
nTimeStamp);
if (prevTagSize != (dataSize + 11))
{
#ifdef _DEBUG
- Log(LOGWARNING,
+ RTMP_Log(RTMP_LOGWARNING,
"Tag and data size are not consitent, writing tag size according to dataSize+11: %d",
dataSize + 11);
#endif
* Update ext timestamp with this absolute offset in non-live mode
* otherwise report the relative one
*/
- // LogPrintf("\nDEBUG: type: %02X, size: %d, pktTS: %dms, TS: %dms, bLiveStream: %d", packet.m_packetType, nPacketLen, packet.m_nTimeStamp, nTimeStamp, bLiveStream);
+ // RTMP_LogPrintf("\nDEBUG: type: %02X, size: %d, pktTS: %dms, TS: %dms, bLiveStream: %d", packet.m_packetType, nPacketLen, packet.m_nTimeStamp, nTimeStamp, bLiveStream);
r->m_read.timestamp = r->Link.bLiveStream ? packet.m_nTimeStamp : nTimeStamp;
ret = size;
if (!RTMPPacket_Alloc(pkt, pkt->m_nBodySize))
{
- Log(LOGDEBUG, "%s, failed to allocate packet", __FUNCTION__);
+ RTMP_Log(RTMP_LOGDEBUG, "%s, failed to allocate packet", __FUNCTION__);
return false;
}
enc = pkt->m_body;
sigIntHandler(int sig)
{
RTMP_ctrlC = true;
- LogPrintf("Caught signal: %d, cleaning up, just a second...\n", sig);
+ 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);
signal(SIGTERM, SIG_IGN);
// check we've got a valid FLV file to continue!
if (fread(hbuf, 1, 13, *file) != 13)
{
- Log(LOGERROR, "Couldn't read FLV file header!");
+ RTMP_Log(RTMP_LOGERROR, "Couldn't read FLV file header!");
return RD_FAILED;
}
if (hbuf[0] != 'F' || hbuf[1] != 'L' || hbuf[2] != 'V'
|| hbuf[3] != 0x01)
{
- Log(LOGERROR, "Invalid FLV file!");
+ RTMP_Log(RTMP_LOGERROR, "Invalid FLV file!");
return RD_FAILED;
}
if ((hbuf[4] & 0x05) == 0)
{
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"FLV file contains neither video nor audio, aborting!");
return RD_FAILED;
}
if (fread(hbuf, 1, 4, *file) != 4)
{
- Log(LOGERROR, "Invalid FLV file: missing first prevTagSize!");
+ RTMP_Log(RTMP_LOGERROR, "Invalid FLV file: missing first prevTagSize!");
return RD_FAILED;
}
prevTagSize = AMF_DecodeInt32(hbuf);
if (prevTagSize != 0)
{
- Log(LOGWARNING,
+ RTMP_Log(RTMP_LOGWARNING,
"First prevTagSize is not zero: prevTagSize = 0x%08X",
prevTagSize);
}
int nRes = AMF_Decode(&metaObj, buffer, dataSize, false);
if (nRes < 0)
{
- Log(LOGERROR, "%s, error decoding meta data packet",
+ RTMP_Log(RTMP_LOGERROR, "%s, error decoding meta data packet",
__FUNCTION__);
break;
}
(&metaObj, &av_duration, &prop))
{
*duration = AMFProp_GetNumber(&prop);
- Log(LOGDEBUG, "File has duration: %f", *duration);
+ RTMP_Log(RTMP_LOGDEBUG, "File has duration: %f", *duration);
}
bFoundMetaHeader = true;
free(buffer);
if (!bFoundMetaHeader)
- Log(LOGWARNING, "Couldn't locate meta data!");
+ RTMP_Log(RTMP_LOGWARNING, "Couldn't locate meta data!");
}
return RD_SUCCESS;
bAudioOnly = (dataType & 0x4) && !(dataType & 0x1);
- Log(LOGDEBUG, "bAudioOnly: %d, size: %llu", bAudioOnly,
+ RTMP_Log(RTMP_LOGDEBUG, "bAudioOnly: %d, size: %llu", bAudioOnly,
(unsigned long long) size);
// ok, we have to get the timestamp of the last keyframe (only keyframes are seekable) / last audio frame (audio only streams)
skipkeyframe:
if (size - tsize < 13)
{
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"Unexpected start of file, error in tag sizes, couldn't arrive at prevTagSize=0");
return RD_FAILED;
}
xread = fread(buffer, 1, 4, file);
if (xread != 4)
{
- Log(LOGERROR, "Couldn't read prevTagSize from file!");
+ RTMP_Log(RTMP_LOGERROR, "Couldn't read prevTagSize from file!");
return RD_FAILED;
}
prevTagSize = AMF_DecodeInt32(buffer);
- //Log(LOGDEBUG, "Last packet: prevTagSize: %d", prevTagSize);
+ //RTMP_Log(RTMP_LOGDEBUG, "Last packet: prevTagSize: %d", prevTagSize);
if (prevTagSize == 0)
{
- Log(LOGERROR, "Couldn't find keyframe to resume from!");
+ RTMP_Log(RTMP_LOGERROR, "Couldn't find keyframe to resume from!");
return RD_FAILED;
}
if (prevTagSize < 0 || prevTagSize > size - 4 - 13)
{
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"Last tag size must be greater/equal zero (prevTagSize=%d) and smaller then filesize, corrupt file!",
prevTagSize);
return RD_FAILED;
fseeko(file, size - tsize, SEEK_SET);
if (fread(buffer, 1, 12, file) != 12)
{
- Log(LOGERROR, "Couldn't read header!");
+ RTMP_Log(RTMP_LOGERROR, "Couldn't read header!");
return RD_FAILED;
}
//*
#ifdef _DEBUG
uint32_t ts = AMF_DecodeInt24(buffer + 4);
ts |= (buffer[7] << 24);
- Log(LOGDEBUG, "%02X: TS: %d ms", buffer[0], ts);
+ RTMP_Log(RTMP_LOGDEBUG, "%02X: TS: %d ms", buffer[0], ts);
#endif //*/
// this just continues the loop whenever the number of skipped frames is > 0,
&& (buffer[0] != 0x09 || (buffer[11] & 0xf0) != 0x10)))
{
#ifdef _DEBUG
- Log(LOGDEBUG,
+ RTMP_Log(RTMP_LOGDEBUG,
"xxxxxxxxxxxxxxxxxxxxxxxx Well, lets go one more back!");
#endif
nSkipKeyFrames--;
fseeko(file, size - tsize + 11, SEEK_SET);
if (fread(*initialFrame, 1, *nInitialFrameSize, file) != *nInitialFrameSize)
{
- Log(LOGERROR, "Couldn't read last keyframe, aborting!");
+ RTMP_Log(RTMP_LOGERROR, "Couldn't read last keyframe, aborting!");
return RD_FAILED;
}
if (*dSeek < 0)
{
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"Last keyframe timestamp is negative, aborting, your file is corrupt!");
return RD_FAILED;
}
- Log(LOGDEBUG, "Last keyframe found at: %d ms, size: %d, type: %02X", *dSeek,
+ RTMP_Log(RTMP_LOGDEBUG, "Last keyframe found at: %d ms, size: %d, type: %02X", *dSeek,
*nInitialFrameSize, *initialFrameType);
/*
// now read the timestamp of the frame before the seekable keyframe:
fseeko(file, size-tsize-4, SEEK_SET);
if(fread(buffer, 1, 4, file) != 4) {
- Log(LOGERROR, "Couldn't read prevTagSize from file!");
+ RTMP_Log(RTMP_LOGERROR, "Couldn't read prevTagSize from file!");
goto start;
}
uint32_t prevTagSize = RTMP_LIB::AMF_DecodeInt32(buffer);
fseeko(file, size-tsize-4-prevTagSize+4, SEEK_SET);
if(fread(buffer, 1, 4, file) != 4) {
- Log(LOGERROR, "Couldn't read previous timestamp!");
+ RTMP_Log(RTMP_LOGERROR, "Couldn't read previous timestamp!");
goto start;
}
uint32_t timestamp = RTMP_LIB::AMF_DecodeInt24(buffer);
timestamp |= (buffer[3]<<24);
- Log(LOGDEBUG, "Previous timestamp: %d ms", timestamp);
+ RTMP_Log(RTMP_LOGDEBUG, "Previous timestamp: %d ms", timestamp);
*/
if (*dSeek != 0)
if (rtmp->m_read.timestamp)
{
- Log(LOGDEBUG, "Continuing at TS: %d ms\n", rtmp->m_read.timestamp);
+ RTMP_Log(RTMP_LOGDEBUG, "Continuing at TS: %d ms\n", rtmp->m_read.timestamp);
}
if (bLiveStream)
{
- LogPrintf("Starting Live Stream\n");
+ RTMP_LogPrintf("Starting Live Stream\n");
}
else
{
{
if ((double) rtmp->m_read.timestamp >= (double) duration * 999.0)
{
- LogPrintf("Already Completed at: %.3f sec Duration=%.3f sec\n",
+ RTMP_LogPrintf("Already Completed at: %.3f sec Duration=%.3f sec\n",
(double) rtmp->m_read.timestamp / 1000.0,
(double) duration / 1000.0);
return RD_SUCCESS;
{
*percent = ((double) rtmp->m_read.timestamp) / (duration * 1000.0) * 100.0;
*percent = ((double) (int) (*percent * 10.0)) / 10.0;
- LogPrintf("%s download at: %.3f kB / %.3f sec (%.1f%%)\n",
+ RTMP_LogPrintf("%s download at: %.3f kB / %.3f sec (%.1f%%)\n",
bResume ? "Resuming" : "Starting",
(double) size / 1024.0, (double) rtmp->m_read.timestamp / 1000.0,
*percent);
}
else
{
- LogPrintf("%s download at: %.3f kB\n",
+ RTMP_LogPrintf("%s download at: %.3f kB\n",
bResume ? "Resuming" : "Starting",
(double) size / 1024.0);
}
}
if (dLength > 0)
- LogPrintf("For duration: %.3f sec\n", (double) dLength / 1000.0);
+ RTMP_LogPrintf("For duration: %.3f sec\n", (double) dLength / 1000.0);
if (bResume && nInitialFrameSize > 0)
rtmp->m_read.flags |= RTMP_READ_RESUME;
do
{
nRead = RTMP_Read(rtmp, buffer, bufferSize);
- //LogPrintf("nRead: %d\n", nRead);
+ //RTMP_LogPrintf("nRead: %d\n", nRead);
if (nRead > 0)
{
if (fwrite(buffer, sizeof(unsigned char), nRead, file) !=
(size_t) nRead)
{
- Log(LOGERROR, "%s: Failed writing, exiting!", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s: Failed writing, exiting!", __FUNCTION__);
free(buffer);
return RD_FAILED;
}
size += nRead;
- //LogPrintf("write %dbytes (%.1f kB)\n", nRead, nRead/1024.0);
+ //RTMP_LogPrintf("write %dbytes (%.1f kB)\n", nRead, nRead/1024.0);
if (duration <= 0) // if duration unknown try to get it from the stream (onMetaData)
duration = RTMP_GetDuration(rtmp);
{
bufferTime = (uint32_t) (duration * 1000.0) + 5000; // extra 5sec to make sure we've got enough
- Log(LOGDEBUG,
+ RTMP_Log(RTMP_LOGDEBUG,
"Detected that buffer time is less than duration, resetting to: %dms",
bufferTime);
RTMP_SetBufferMS(rtmp, bufferTime);
{
if (lastPercent + 1 <= *percent)
{
- LogStatus("#");
+ RTMP_LogStatus("#");
lastPercent = (unsigned long) *percent;
}
}
now = RTMP_GetTime();
if (abs(now - lastUpdate) > 200)
{
- LogStatus("\r%.3f kB / %.2f sec (%.1f%%)",
+ RTMP_LogStatus("\r%.3f kB / %.2f sec (%.1f%%)",
(double) size / 1024.0,
(double) (rtmp->m_read.timestamp) / 1000.0, *percent);
lastUpdate = now;
if (abs(now - lastUpdate) > 200)
{
if (bHashes)
- LogStatus("#");
+ RTMP_LogStatus("#");
else
- LogStatus("\r%.3f kB / %.2f sec", (double) size / 1024.0,
+ RTMP_LogStatus("\r%.3f kB / %.2f sec", (double) size / 1024.0,
(double) (rtmp->m_read.timestamp) / 1000.0);
lastUpdate = now;
}
#ifdef _DEBUG
else
{
- Log(LOGDEBUG, "zero read!");
+ RTMP_Log(RTMP_LOGDEBUG, "zero read!");
}
#endif
{
*percent = ((double) rtmp->m_read.timestamp) / (duration * 1000.0) * 100.0;
*percent = ((double) (int) (*percent * 10.0)) / 10.0;
- LogStatus("\r%.3f kB / %.2f sec (%.1f%%)",
+ RTMP_LogStatus("\r%.3f kB / %.2f sec (%.1f%%)",
(double) size / 1024.0,
(double) (rtmp->m_read.timestamp) / 1000.0, *percent);
}
else
{
- LogStatus("\r%.3f kB / %.2f sec", (double) size / 1024.0,
+ RTMP_LogStatus("\r%.3f kB / %.2f sec", (double) size / 1024.0,
(double) (rtmp->m_read.timestamp) / 1000.0);
}
}
- Log(LOGDEBUG, "RTMP_Read returned: %d", nRead);
+ RTMP_Log(RTMP_LOGDEBUG, "RTMP_Read returned: %d", nRead);
if (bResume && nRead == -2)
{
- LogPrintf("Couldn't resume FLV file, try --skip %d\n\n",
+ RTMP_LogPrintf("Couldn't resume FLV file, try --skip %d\n\n",
nSkipKeyFrames + 1);
return RD_FAILED;
}
{
if (strcmp(argv[index], "--quiet") == 0
|| strcmp(argv[index], "-q") == 0)
- AMF_debuglevel = LOGCRIT;
+ RTMP_debuglevel = RTMP_LOGCRIT;
index++;
}
- LogPrintf("RTMPDump %s\n", RTMPDUMP_VERSION);
- LogPrintf
+ RTMP_LogPrintf("RTMPDump %s\n", RTMPDUMP_VERSION);
+ RTMP_LogPrintf
("(c) 2010 Andrej Stepanchuk, Howard Chu, The Flvstreamer Team; license: GPL\n");
if (!InitSockets())
{
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"Couldn't load sockets support on your platform, exiting!");
return RD_FAILED;
}
switch (opt)
{
case 'h':
- LogPrintf
+ RTMP_LogPrintf
("\nThis program dumps the media content streamed over RTMP.\n\n");
- LogPrintf("--help|-h Prints this help screen.\n");
- LogPrintf
+ RTMP_LogPrintf("--help|-h Prints this help screen.\n");
+ RTMP_LogPrintf
("--rtmp|-r url URL (e.g. rtmp//host[:port]/path)\n");
- LogPrintf
+ RTMP_LogPrintf
("--host|-n hostname Overrides the hostname in the rtmp url\n");
- LogPrintf
+ RTMP_LogPrintf
("--port|-c port Overrides the port in the rtmp url\n");
- LogPrintf
+ RTMP_LogPrintf
("--socks|-S host:port Use the specified SOCKS proxy\n");
- LogPrintf
+ RTMP_LogPrintf
("--protocol|-l Overrides the protocol in the rtmp url (0 - RTMP, 2 - RTMPE)\n");
- LogPrintf
+ RTMP_LogPrintf
("--playpath|-y Overrides the playpath parsed from rtmp url\n");
- LogPrintf("--swfUrl|-s url URL to player swf file\n");
- LogPrintf
+ RTMP_LogPrintf("--swfUrl|-s url URL to player swf file\n");
+ RTMP_LogPrintf
("--tcUrl|-t url URL to played stream (default: \"rtmp://host[:port]/app\")\n");
- LogPrintf("--pageUrl|-p url Web URL of played programme\n");
- LogPrintf("--app|-a app Name of target app on server\n");
+ RTMP_LogPrintf("--pageUrl|-p url Web URL of played programme\n");
+ RTMP_LogPrintf("--app|-a app Name of target app on server\n");
#ifdef CRYPTO
- LogPrintf
+ RTMP_LogPrintf
("--swfhash|-w hexstring SHA256 hash of the decompressed SWF file (32 bytes)\n");
- LogPrintf
+ RTMP_LogPrintf
("--swfsize|-x num Size of the decompressed SWF file, required for SWFVerification\n");
- LogPrintf
+ RTMP_LogPrintf
("--swfVfy|-W url URL to player swf file, compute hash/size automatically\n");
- LogPrintf
+ RTMP_LogPrintf
("--swfAge|-X days Number of days to use cached SWF hash before refreshing\n");
#endif
- LogPrintf
+ RTMP_LogPrintf
("--auth|-u string Authentication string to be appended to the connect string\n");
- LogPrintf
+ RTMP_LogPrintf
("--conn|-C type:data Arbitrary AMF data to be appended to the connect string\n");
- LogPrintf
+ RTMP_LogPrintf
(" B:boolean(0|1), S:string, N:number, O:object-flag(0|1),\n");
- LogPrintf
+ RTMP_LogPrintf
(" Z:(null), NB:name:boolean, NS:name:string, NN:name:number\n");
- LogPrintf
+ RTMP_LogPrintf
("--flashVer|-f string Flash version string (default: \"%s\")\n",
RTMP_DefaultFlashVer.av_val);
- LogPrintf
+ RTMP_LogPrintf
("--live|-v Save a live stream, no --resume (seeking) of live streams possible\n");
- LogPrintf
+ RTMP_LogPrintf
("--subscribe|-d string Stream name to subscribe to (otherwise defaults to playpath if live is specifed)\n");
- LogPrintf
+ RTMP_LogPrintf
("--flv|-o string FLV output file name, if the file name is - print stream to stdout\n");
- LogPrintf
+ RTMP_LogPrintf
("--resume|-e Resume a partial RTMP download\n");
- LogPrintf
+ RTMP_LogPrintf
("--timeout|-m num Timeout connection num seconds (default: %lu)\n",
timeout);
- LogPrintf
+ RTMP_LogPrintf
("--start|-A num Start at num seconds into stream (not valid when using --live)\n");
- LogPrintf
+ RTMP_LogPrintf
("--stop|-B num Stop at num seconds into stream\n");
- LogPrintf
+ RTMP_LogPrintf
("--token|-T key Key for SecureToken response\n");
- LogPrintf
+ RTMP_LogPrintf
("--hashes|-# Display progress with hashes, not with the byte counter\n");
- LogPrintf
+ RTMP_LogPrintf
("--buffer|-b Buffer time in milliseconds (default: %lu), this option makes only sense in stdout mode (-o -)\n",
bufferTime);
- LogPrintf
+ RTMP_LogPrintf
("--skip|-k num Skip num keyframes when looking for last keyframe to resume from. Useful if resume fails (default: %d)\n\n",
nSkipKeyFrames);
- LogPrintf
+ RTMP_LogPrintf
("--quiet|-q Suppresses all command output.\n");
- LogPrintf("--verbose|-V Verbose command output.\n");
- LogPrintf("--debug|-z Debug level command output.\n");
- LogPrintf
+ RTMP_LogPrintf("--verbose|-V Verbose command output.\n");
+ RTMP_LogPrintf("--debug|-z Debug level command output.\n");
+ RTMP_LogPrintf
("If you don't pass parameters for swfUrl, pageUrl, or auth these properties will not be included in the connect ");
- LogPrintf("packet.\n\n");
+ RTMP_LogPrintf("packet.\n\n");
return RD_SUCCESS;
#ifdef CRYPTO
case 'w':
if (res != HASHLEN)
{
swfHash.av_val = NULL;
- Log(LOGWARNING,
+ RTMP_Log(RTMP_LOGWARNING,
"Couldn't parse swf hash hex string, not hexstring or not %d bytes, ignoring!", HASHLEN);
}
swfHash.av_len = HASHLEN;
int size = atoi(optarg);
if (size <= 0)
{
- Log(LOGERROR, "SWF Size must be at least 1, ignoring\n");
+ RTMP_Log(RTMP_LOGERROR, "SWF Size must be at least 1, ignoring\n");
}
else
{
int num = atoi(optarg);
if (num < 0)
{
- Log(LOGERROR, "SWF Age must be non-negative, ignoring\n");
+ RTMP_Log(RTMP_LOGERROR, "SWF Age must be non-negative, ignoring\n");
}
else
{
nSkipKeyFrames = atoi(optarg);
if (nSkipKeyFrames < 0)
{
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"Number of keyframes skipped must be greater or equal zero, using zero!");
nSkipKeyFrames = 0;
}
else
{
- Log(LOGDEBUG, "Number of skipped key frames for resume: %d",
+ RTMP_Log(RTMP_LOGDEBUG, "Number of skipped key frames for resume: %d",
nSkipKeyFrames);
}
break;
int32_t bt = atol(optarg);
if (bt < 0)
{
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"Buffer time must be greater than zero, ignoring the specified value %d!",
bt);
}
if (protocol != RTMP_PROTOCOL_RTMP
&& protocol != RTMP_PROTOCOL_RTMPE)
{
- Log(LOGERROR, "Unknown protocol specified: %d", protocol);
+ RTMP_Log(RTMP_LOGERROR, "Unknown protocol specified: %d", protocol);
return RD_FAILED;
}
break;
(rtmpurl, &parsedProtocol, &parsedHost, &parsedPort,
&parsedPlaypath, &parsedApp))
{
- Log(LOGWARNING, "Couldn't parse the specified url (%s)!",
+ RTMP_Log(RTMP_LOGWARNING, "Couldn't parse the specified url (%s)!",
optarg);
}
else
case 'C':
if (parseAMF(&extras, optarg, &edepth))
{
- Log(LOGERROR, "Invalid AMF parameter: %s", optarg);
+ RTMP_Log(RTMP_LOGERROR, "Invalid AMF parameter: %s", optarg);
return RD_FAILED;
}
break;
bHashes = true;
break;
case 'q':
- AMF_debuglevel = LOGCRIT;
+ RTMP_debuglevel = RTMP_LOGCRIT;
break;
case 'V':
- AMF_debuglevel = LOGDEBUG;
+ RTMP_debuglevel = RTMP_LOGDEBUG;
break;
case 'z':
- AMF_debuglevel = LOGALL;
+ RTMP_debuglevel = RTMP_LOGALL;
break;
case 'S':
sockshost = optarg;
break;
default:
- LogPrintf("unknown option: %c\n", opt);
+ RTMP_LogPrintf("unknown option: %c\n", opt);
break;
}
}
if (hostname == 0)
{
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"You must specify a hostname (--host) or url (-r \"rtmp://host[:port]/playpath\") containing a hostname");
return RD_FAILED;
}
if (playpath.av_len == 0)
{
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"You must specify a playpath (--playpath) or url (-r \"rtmp://host[:port]/playpath\") containing a playpath");
return RD_FAILED;
}
if (protocol == RTMP_PROTOCOL_UNDEFINED)
{
- Log(LOGWARNING,
+ RTMP_Log(RTMP_LOGWARNING,
"You haven't specified a protocol (--protocol) or rtmp url (-r), using default protocol RTMP");
protocol = RTMP_PROTOCOL_RTMP;
}
if (port == -1)
{
- Log(LOGWARNING,
+ RTMP_Log(RTMP_LOGWARNING,
"You haven't specified a port (--port) or rtmp url (-r), using default port 1935");
port = 0;
}
if (flvFile == 0)
{
- Log(LOGWARNING,
+ RTMP_Log(RTMP_LOGWARNING,
"You haven't specified an output file (-o filename), using stdout");
bStdoutMode = true;
}
if (bStdoutMode && bResume)
{
- Log(LOGWARNING,
+ RTMP_Log(RTMP_LOGWARNING,
"Can't resume in stdout mode, ignoring --resume option");
bResume = false;
}
if (bLiveStream && bResume)
{
- Log(LOGWARNING, "Can't resume live stream, ignoring --resume option");
+ RTMP_Log(RTMP_LOGWARNING, "Can't resume live stream, ignoring --resume option");
bResume = false;
}
if (swfHash.av_len == 0 && swfSize > 0)
{
- Log(LOGWARNING,
+ RTMP_Log(RTMP_LOGWARNING,
"Ignoring SWF size, supply also the hash with --swfhash");
swfSize = 0;
}
if (swfHash.av_len != 0 && swfSize == 0)
{
- Log(LOGWARNING,
+ RTMP_Log(RTMP_LOGWARNING,
"Ignoring SWF hash, supply also the swf size with --swfsize");
swfHash.av_len = 0;
swfHash.av_val = NULL;
// Live stream
if (bLiveStream)
{
- Log(LOGWARNING,
+ RTMP_Log(RTMP_LOGWARNING,
"Can't seek in a live stream, ignoring --start option");
dStartOffset = 0;
}
&initialFrameType, &nInitialFrameSize);
if (nStatus == RD_FAILED)
{
- Log(LOGDEBUG, "Failed to get last keyframe.");
+ RTMP_Log(RTMP_LOGDEBUG, "Failed to get last keyframe.");
goto clean;
}
if (dSeek == 0)
{
- Log(LOGDEBUG,
+ RTMP_Log(RTMP_LOGDEBUG,
"Last keyframe is first frame in stream, switching from resume to normal mode!");
bResume = false;
}
file = fopen(flvFile, "w+b");
if (file == 0)
{
- LogPrintf("Failed to open file! %s\n", flvFile);
+ RTMP_LogPrintf("Failed to open file! %s\n", flvFile);
return RD_FAILED;
}
}
while (!RTMP_ctrlC)
{
- Log(LOGDEBUG, "Setting buffer time to: %dms", bufferTime);
+ RTMP_Log(RTMP_LOGDEBUG, "Setting buffer time to: %dms", bufferTime);
RTMP_SetBufferMS(&rtmp, bufferTime);
if (first)
{
first = 0;
- LogPrintf("Connecting ...\n");
+ RTMP_LogPrintf("Connecting ...\n");
if (!RTMP_Connect(&rtmp, NULL))
{
break;
}
- Log(LOGINFO, "Connected...");
+ RTMP_Log(RTMP_LOGINFO, "Connected...");
// User defined seek offset
if (dStartOffset > 0)
// Don't need the start offset if resuming an existing file
if (bResume)
{
- Log(LOGWARNING,
+ RTMP_Log(RTMP_LOGWARNING,
"Can't seek a resumed stream, ignoring --start option");
dStartOffset = 0;
}
// Quit if start seek is past required stop offset
if (dLength <= 0)
{
- LogPrintf("Already Completed\n");
+ RTMP_LogPrintf("Already Completed\n");
nStatus = RD_SUCCESS;
break;
}
if (retries)
{
- Log(LOGERROR, "Failed to resume the stream\n\n");
+ RTMP_Log(RTMP_LOGERROR, "Failed to resume the stream\n\n");
if (!RTMP_IsTimedout(&rtmp))
nStatus = RD_FAILED;
else
nStatus = RD_INCOMPLETE;
break;
}
- Log(LOGINFO, "Connection timed out, trying to resume.\n\n");
+ RTMP_Log(RTMP_LOGINFO, "Connection timed out, trying to resume.\n\n");
/* Did we already try pausing, and it still didn't work? */
if (rtmp.m_pausing == 3)
{
dLength = dStopOffset - dSeek;
if (dLength <= 0)
{
- LogPrintf("Already Completed\n");
+ RTMP_LogPrintf("Already Completed\n");
nStatus = RD_SUCCESS;
break;
}
}
if (!RTMP_ReconnectStream(&rtmp, bufferTime, dSeek, dLength))
{
- Log(LOGERROR, "Failed to resume the stream\n\n");
+ RTMP_Log(RTMP_LOGERROR, "Failed to resume the stream\n\n");
if (!RTMP_IsTimedout(&rtmp))
nStatus = RD_FAILED;
else
}
else if (!RTMP_ToggleStream(&rtmp))
{
- Log(LOGERROR, "Failed to resume the stream\n\n");
+ RTMP_Log(RTMP_LOGERROR, "Failed to resume the stream\n\n");
if (!RTMP_IsTimedout(&rtmp))
nStatus = RD_FAILED;
else
if (nStatus == RD_SUCCESS)
{
- LogPrintf("Download complete\n");
+ RTMP_LogPrintf("Download complete\n");
}
else if (nStatus == RD_INCOMPLETE)
{
- LogPrintf
+ RTMP_LogPrintf
("Download may be incomplete (downloaded about %.2f%%), try resuming\n",
percent);
}
clean:
- Log(LOGDEBUG, "Closing connection.\n");
+ RTMP_Log(RTMP_LOGDEBUG, "Closing connection.\n");
RTMP_Close(&rtmp);
if (file != 0)
switch (ich)
{
case 'q':
- LogPrintf("Exiting\n");
+ RTMP_LogPrintf("Exiting\n");
stopStreaming(httpServer);
exit(0);
break;
default:
- LogPrintf("Unknown command \'%c\', ignoring\n", ich);
+ RTMP_LogPrintf("Unknown command \'%c\', ignoring\n", ich);
}
}
TFRET();
if (select(sockfd + 1, &fds, NULL, NULL, &tv) <= 0)
{
- Log(LOGERROR, "Request timeout/select failed, ignoring request");
+ RTMP_Log(RTMP_LOGERROR, "Request timeout/select failed, ignoring request");
goto quit;
}
else
nRead = recv(sockfd, header, 2047, 0);
header[2047] = '\0';
- Log(LOGDEBUG, "%s: header: %s", __FUNCTION__, header);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: header: %s", __FUNCTION__, header);
if (strstr(header, "Range: bytes=") != 0)
{
// TODO check range starts from 0 and asking till the end.
- LogPrintf("%s, Range request not supported\n", __FUNCTION__);
+ RTMP_LogPrintf("%s, Range request not supported\n", __FUNCTION__);
len = sprintf(buf, "HTTP/1.0 416 Requested Range Not Satisfiable%s\r\n",
srvhead);
send(sockfd, buf, len, 0);
// if we got a filename from the GET method
if (filename != NULL)
{
- Log(LOGDEBUG, "%s: Request header: %s", __FUNCTION__, filename);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: Request header: %s", __FUNCTION__, filename);
if (filename[0] == '/')
{ // if its not empty, is it /?
ptr = filename + 1;
memcpy(arg, ptr, nArgLen * sizeof(char));
arg[nArgLen] = '\0';
- //Log(LOGDEBUG, "%s: unescaping parameter: %s", __FUNCTION__, arg);
+ //RTMP_Log(RTMP_LOGDEBUG, "%s: unescaping parameter: %s", __FUNCTION__, arg);
http_unescape(arg);
- Log(LOGDEBUG, "%s: parameter: %c, arg: %s", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s: parameter: %c, arg: %s", __FUNCTION__,
ich, arg);
ptr += nArgLen + 1;
}
else
{
- LogPrintf("%s: No request header received/unsupported method\n",
+ RTMP_LogPrintf("%s: No request header received/unsupported method\n",
__FUNCTION__);
}
// do necessary checks right here to make sure the combined request of default values and GET parameters is correct
if (req.hostname == 0)
{
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"You must specify a hostname (--host) or url (-r \"rtmp://host[:port]/playpath\") containing a hostname");
status = "400 Missing Hostname";
goto filenotfound;
}
if (req.playpath.av_len == 0)
{
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"You must specify a playpath (--playpath) or url (-r \"rtmp://host[:port]/playpath\") containing a playpath");
status = "400 Missing Playpath";
goto filenotfound;;
if (req.protocol == RTMP_PROTOCOL_UNDEFINED)
{
- Log(LOGWARNING,
+ RTMP_Log(RTMP_LOGWARNING,
"You haven't specified a protocol (--protocol) or rtmp url (-r), using default protocol RTMP");
req.protocol = RTMP_PROTOCOL_RTMP;
}
if (req.rtmpport == -1)
{
- Log(LOGWARNING,
+ RTMP_Log(RTMP_LOGWARNING,
"You haven't specified a port (--port) or rtmp url (-r), using default port");
req.rtmpport = 0;
}
if (req.dStartOffset > 0)
{
if (req.bLiveStream)
- Log(LOGWARNING,
+ RTMP_Log(RTMP_LOGWARNING,
"Can't seek in a live stream, ignoring --seek option");
else
dSeek += req.dStartOffset;
if (dSeek != 0)
{
- LogPrintf("Starting at TS: %d ms\n", dSeek);
+ RTMP_LogPrintf("Starting at TS: %d ms\n", dSeek);
}
if (req.dStopOffset > 0)
dLength = req.dStopOffset - dSeek;
}
- Log(LOGDEBUG, "Setting buffer time to: %dms", req.bufferTime);
+ RTMP_Log(RTMP_LOGDEBUG, "Setting buffer time to: %dms", req.bufferTime);
RTMP_Init(&rtmp);
RTMP_SetBufferMS(&rtmp, req.bufferTime);
RTMP_SetupStream(&rtmp, req.protocol, req.hostname, req.rtmpport, req.sockshost,
rtmp.Link.token = req.token;
rtmp.m_read.timestamp = dSeek;
- LogPrintf("Connecting ... port: %d, app: %s\n", req.rtmpport, req.app);
+ RTMP_LogPrintf("Connecting ... port: %d, app: %s\n", req.rtmpport, req.app);
if (!RTMP_Connect(&rtmp, NULL))
{
- LogPrintf("%s, failed to connect!\n", __FUNCTION__);
+ RTMP_LogPrintf("%s, failed to connect!\n", __FUNCTION__);
}
else
{
{
if ((nWritten = send(sockfd, buffer, nRead, 0)) < 0)
{
- Log(LOGERROR, "%s, sending failed, error: %d", __FUNCTION__,
+ RTMP_Log(RTMP_LOGERROR, "%s, sending failed, error: %d", __FUNCTION__,
GetSockError());
goto cleanup; // we are in STREAMING_IN_PROGRESS, so we'll go to STREAMING_ACCEPTING
}
size += nRead;
- //LogPrintf("write %dbytes (%.1f KB)\n", nRead, nRead/1024.0);
+ //RTMP_LogPrintf("write %dbytes (%.1f KB)\n", nRead, nRead/1024.0);
if (duration <= 0) // if duration unknown try to get it from the stream (onMetaData)
duration = RTMP_GetDuration(&rtmp);
((double) (dSeek + rtmp.m_read.timestamp)) / (duration *
1000.0) * 100.0;
percent = ((double) (int) (percent * 10.0)) / 10.0;
- LogStatus("\r%.3f KB / %.2f sec (%.1f%%)",
+ RTMP_LogStatus("\r%.3f KB / %.2f sec (%.1f%%)",
(double) size / 1024.0,
(double) (rtmp.m_read.timestamp) / 1000.0, percent);
}
else
{
- LogStatus("\r%.3f KB / %.2f sec", (double) size / 1024.0,
+ RTMP_LogStatus("\r%.3f KB / %.2f sec", (double) size / 1024.0,
(double) (rtmp.m_read.timestamp) / 1000.0);
}
}
#ifdef _DEBUG
else
{
- Log(LOGDEBUG, "zero read!");
+ RTMP_Log(RTMP_LOGDEBUG, "zero read!");
}
#endif
}
&& RTMP_IsConnected(&rtmp) && nWritten >= 0);
}
cleanup:
- LogPrintf("Closing connection... ");
+ RTMP_LogPrintf("Closing connection... ");
RTMP_Close(&rtmp);
- LogPrintf("done!\n\n");
+ RTMP_LogPrintf("done!\n\n");
quit:
if (buffer)
return;
filenotfound:
- LogPrintf("%s, %s, %s\n", __FUNCTION__, status, filename);
+ RTMP_LogPrintf("%s, %s, %s\n", __FUNCTION__, status, filename);
len = sprintf(buf, "HTTP/1.0 %s%s\r\n", status, srvhead);
send(sockfd, buf, len, 0);
goto quit;
if (sockfd > 0)
{
// Create a new process and transfer the control to that
- Log(LOGDEBUG, "%s: accepted connection from %s\n", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s: accepted connection from %s\n", __FUNCTION__,
inet_ntoa(addr.sin_addr));
processTCPrequest(server, sockfd);
- Log(LOGDEBUG, "%s: processed request\n", __FUNCTION__);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: processed request\n", __FUNCTION__);
}
else
{
- Log(LOGERROR, "%s: accept failed", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s: accept failed", __FUNCTION__);
}
}
server->state = STREAMING_STOPPED;
sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (sockfd == -1)
{
- Log(LOGERROR, "%s, couldn't create socket", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s, couldn't create socket", __FUNCTION__);
return 0;
}
if (bind(sockfd, (struct sockaddr *) &addr, sizeof(struct sockaddr_in)) ==
-1)
{
- Log(LOGERROR, "%s, TCP bind failed for port number: %d", __FUNCTION__,
+ RTMP_Log(RTMP_LOGERROR, "%s, TCP bind failed for port number: %d", __FUNCTION__,
port);
return 0;
}
if (listen(sockfd, 10) == -1)
{
- Log(LOGERROR, "%s, listen failed", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s, listen failed", __FUNCTION__);
closesocket(sockfd);
return 0;
}
}
if (closesocket(server->socket))
- Log(LOGERROR, "%s: Failed to close listening socket, error %d",
+ RTMP_Log(RTMP_LOGERROR, "%s: Failed to close listening socket, error %d",
GetSockError());
server->state = STREAMING_STOPPED;
sigIntHandler(int sig)
{
RTMP_ctrlC = true;
- LogPrintf("Caught signal: %d, cleaning up, just a second...\n", sig);
+ RTMP_LogPrintf("Caught signal: %d, cleaning up, just a second...\n", sig);
if (httpServer)
stopStreaming(httpServer);
signal(SIGINT, SIG_DFL);
if (!res || res != HASHLEN)
{
req->swfHash.av_val = NULL;
- Log(LOGWARNING,
+ RTMP_Log(RTMP_LOGWARNING,
"Couldn't parse swf hash hex string, not hexstring or not %d bytes, ignoring!", HASHLEN);
}
req->swfHash.av_len = HASHLEN;
int size = atoi(arg);
if (size <= 0)
{
- Log(LOGERROR, "SWF Size must be at least 1, ignoring\n");
+ RTMP_Log(RTMP_LOGERROR, "SWF Size must be at least 1, ignoring\n");
}
else
{
int num = atoi(arg);
if (num < 0)
{
- Log(LOGERROR, "SWF Age must be non-negative, ignoring\n");
+ RTMP_Log(RTMP_LOGERROR, "SWF Age must be non-negative, ignoring\n");
}
else
{
int32_t bt = atol(arg);
if (bt < 0)
{
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"Buffer time must be greater than zero, ignoring the specified value %d!",
bt);
}
int protocol = atoi(arg);
if (protocol != RTMP_PROTOCOL_RTMP && protocol != RTMP_PROTOCOL_RTMPE)
{
- Log(LOGERROR, "Unknown protocol specified: %d, using default",
+ RTMP_Log(RTMP_LOGERROR, "Unknown protocol specified: %d, using default",
protocol);
return false;
}
(req->rtmpurl, &parsedProtocol, &parsedHost, &parsedPort,
&parsedPlaypath, &parsedApp))
{
- Log(LOGWARNING, "Couldn't parse the specified url (%s)!", arg);
+ RTMP_Log(RTMP_LOGWARNING, "Couldn't parse the specified url (%s)!", arg);
}
else
{
case 'S':
req->sockshost = arg;
case 'q':
- AMF_debuglevel = LOGCRIT;
+ RTMP_debuglevel = RTMP_LOGCRIT;
break;
case 'V':
- AMF_debuglevel = LOGDEBUG;
+ RTMP_debuglevel = RTMP_LOGDEBUG;
break;
case 'z':
- AMF_debuglevel = LOGALL;
+ RTMP_debuglevel = RTMP_LOGALL;
break;
default:
- LogPrintf("unknown option: %c, arg: %s\n", opt, arg);
+ RTMP_LogPrintf("unknown option: %c, arg: %s\n", opt, arg);
break;
}
return true;
char *httpStreamingDevice = DEFAULT_HTTP_STREAMING_DEVICE; // streaming device, default 0.0.0.0
int nHttpStreamingPort = 80; // port
- LogPrintf("HTTP-RTMP Stream Gateway %s\n", RTMPDUMP_VERSION);
- LogPrintf("(c) 2010 Andrej Stepanchuk, Howard Chu; license: GPL\n\n");
+ RTMP_LogPrintf("HTTP-RTMP Stream Gateway %s\n", RTMPDUMP_VERSION);
+ RTMP_LogPrintf("(c) 2010 Andrej Stepanchuk, Howard Chu; license: GPL\n\n");
// init request
memset(&defaultRTMPRequest, 0, sizeof(RTMP_REQUEST));
switch (opt)
{
case 'h':
- LogPrintf
+ RTMP_LogPrintf
("\nThis program serves media content streamed from RTMP onto HTTP.\n\n");
- LogPrintf("--help|-h Prints this help screen.\n");
- LogPrintf
+ RTMP_LogPrintf("--help|-h Prints this help screen.\n");
+ RTMP_LogPrintf
("--rtmp|-r url URL (e.g. rtmp//host[:port]/path)\n");
- LogPrintf
+ RTMP_LogPrintf
("--host|-n hostname Overrides the hostname in the rtmp url\n");
- LogPrintf
+ RTMP_LogPrintf
("--port|-c port Overrides the port in the rtmp url\n");
- LogPrintf
+ RTMP_LogPrintf
("--socks|-S host:port Use the specified SOCKS proxy\n");
- LogPrintf
+ RTMP_LogPrintf
("--protocol|-l Overrides the protocol in the rtmp url (0 - RTMP, 2 - RTMPE)\n");
- LogPrintf
+ RTMP_LogPrintf
("--playpath|-y Overrides the playpath parsed from rtmp url\n");
- LogPrintf("--swfUrl|-s url URL to player swf file\n");
- LogPrintf
+ RTMP_LogPrintf("--swfUrl|-s url URL to player swf file\n");
+ RTMP_LogPrintf
("--tcUrl|-t url URL to played stream (default: \"rtmp://host[:port]/app\")\n");
- LogPrintf("--pageUrl|-p url Web URL of played programme\n");
- LogPrintf("--app|-a app Name of target app in server\n");
+ RTMP_LogPrintf("--pageUrl|-p url Web URL of played programme\n");
+ RTMP_LogPrintf("--app|-a app Name of target app in server\n");
#ifdef CRYPTO
- LogPrintf
+ RTMP_LogPrintf
("--swfhash|-w hexstring SHA256 hash of the decompressed SWF file (32 bytes)\n");
- LogPrintf
+ RTMP_LogPrintf
("--swfsize|-x num Size of the decompressed SWF file, required for SWFVerification\n");
- LogPrintf
+ RTMP_LogPrintf
("--swfVfy|-W url URL to player swf file, compute hash/size automatically\n");
- LogPrintf
+ RTMP_LogPrintf
("--swfAge|-X days Number of days to use cached SWF hash before refreshing\n");
#endif
- LogPrintf
+ RTMP_LogPrintf
("--auth|-u string Authentication string to be appended to the connect string\n");
- LogPrintf
+ RTMP_LogPrintf
("--conn|-C type:data Arbitrary AMF data to be appended to the connect string\n");
- LogPrintf
+ RTMP_LogPrintf
(" B:boolean(0|1), S:string, N:number, O:object-flag(0|1),\n");
- LogPrintf
+ RTMP_LogPrintf
(" Z:(null), NB:name:boolean, NS:name:string, NN:name:number\n");
- LogPrintf
+ RTMP_LogPrintf
("--flashVer|-f string Flash version string (default: \"%s\")\n",
RTMP_DefaultFlashVer.av_val);
- LogPrintf
+ RTMP_LogPrintf
("--live|-v Get a live stream, no --resume (seeking) of live streams possible\n");
- LogPrintf
+ RTMP_LogPrintf
("--subscribe|-d string Stream name to subscribe to (otherwise defaults to playpath if live is specifed)\n");
- LogPrintf
+ RTMP_LogPrintf
("--timeout|-m num Timeout connection num seconds (default: %lu)\n",
defaultRTMPRequest.timeout);
- LogPrintf
+ RTMP_LogPrintf
("--start|-A num Start at num seconds into stream (not valid when using --live)\n");
- LogPrintf
+ RTMP_LogPrintf
("--stop|-B num Stop at num seconds into stream\n");
- LogPrintf
+ RTMP_LogPrintf
("--token|-T key Key for SecureToken response\n");
- LogPrintf
+ RTMP_LogPrintf
("--buffer|-b Buffer time in milliseconds (default: %lu)\n\n",
defaultRTMPRequest.bufferTime);
- LogPrintf
+ RTMP_LogPrintf
("--device|-D Streaming device ip address (default: %s)\n",
DEFAULT_HTTP_STREAMING_DEVICE);
- LogPrintf
+ RTMP_LogPrintf
("--sport|-g Streaming port (default: %d)\n\n",
nHttpStreamingPort);
- LogPrintf
+ RTMP_LogPrintf
("--quiet|-q Suppresses all command output.\n");
- LogPrintf("--verbose|-V Verbose command output.\n");
- LogPrintf("--debug|-z Debug level command output.\n");
- LogPrintf
+ RTMP_LogPrintf("--verbose|-V Verbose command output.\n");
+ RTMP_LogPrintf("--debug|-z Debug level command output.\n");
+ RTMP_LogPrintf
("If you don't pass parameters for swfUrl, pageUrl, or auth these properties will not be included in the connect ");
- LogPrintf("packet.\n\n");
+ RTMP_LogPrintf("packet.\n\n");
return RD_SUCCESS;
break;
// streaming server specific options
case 'D':
if (inet_addr(optarg) == INADDR_NONE)
{
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"Invalid binding address (requested address %s), ignoring",
optarg);
}
int port = atoi(optarg);
if (port < 0 || port > 65535)
{
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"Streaming port out of range (requested port %d), ignoring\n",
port);
}
break;
}
default:
- //LogPrintf("unknown option: %c\n", opt);
+ //RTMP_LogPrintf("unknown option: %c\n", opt);
ParseOption(opt, optarg, &defaultRTMPRequest);
break;
}
if ((httpServer =
startStreaming(httpStreamingDevice, nHttpStreamingPort)) == 0)
{
- Log(LOGERROR, "Failed to start HTTP server, exiting!");
+ RTMP_Log(RTMP_LOGERROR, "Failed to start HTTP server, exiting!");
return RD_FAILED;
}
- LogPrintf("Streaming on http://%s:%d\n", httpStreamingDevice,
+ RTMP_LogPrintf("Streaming on http://%s:%d\n", httpStreamingDevice,
nHttpStreamingPort);
while (httpServer->state != STREAMING_STOPPED)
{
sleep(1);
}
- Log(LOGDEBUG, "Done, exiting...");
+ RTMP_Log(RTMP_LOGDEBUG, "Done, exiting...");
CleanupSockets();
if (body[0] != 0x02) // make sure it is a string method name we start with
{
- Log(LOGWARNING, "%s, Sanity failed. no string method in invoke packet",
+ RTMP_Log(RTMP_LOGWARNING, "%s, Sanity failed. no string method in invoke packet",
__FUNCTION__);
return 0;
}
nRes = AMF_Decode(&obj, body, nBodySize, false);
if (nRes < 0)
{
- Log(LOGERROR, "%s, error decoding invoke packet", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s, error decoding invoke packet", __FUNCTION__);
return 0;
}
AVal method;
AMFProp_GetString(AMF_GetProp(&obj, NULL, 0), &method);
double txn = AMFProp_GetNumber(AMF_GetProp(&obj, NULL, 1));
- Log(LOGDEBUG, "%s, client invoking <%s>", __FUNCTION__, method.av_val);
+ RTMP_Log(RTMP_LOGDEBUG, "%s, client invoking <%s>", __FUNCTION__, method.av_val);
if (AVMATCH(&method, &av_connect))
{
{
int ret = 0;
- Log(LOGDEBUG, "%s, received packet type %02X, size %lu bytes", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s, received packet type %02X, size %lu bytes", __FUNCTION__,
packet->m_packetType, packet->m_nBodySize);
switch (packet->m_packetType)
case 0x08:
// audio data
- //Log(LOGDEBUG, "%s, received: audio %lu bytes", __FUNCTION__, packet.m_nBodySize);
+ //RTMP_Log(RTMP_LOGDEBUG, "%s, received: audio %lu bytes", __FUNCTION__, packet.m_nBodySize);
break;
case 0x09:
// video data
- //Log(LOGDEBUG, "%s, received: video %lu bytes", __FUNCTION__, packet.m_nBodySize);
+ //RTMP_Log(RTMP_LOGDEBUG, "%s, received: video %lu bytes", __FUNCTION__, packet.m_nBodySize);
break;
case 0x0F: // flex stream send
case 0x11: // flex message
{
- Log(LOGDEBUG, "%s, flex message, size %lu bytes, not fully supported",
+ RTMP_Log(RTMP_LOGDEBUG, "%s, flex message, size %lu bytes, not fully supported",
__FUNCTION__, packet->m_nBodySize);
- //LogHex(packet.m_body, packet.m_nBodySize);
+ //RTMP_LogHex(packet.m_body, packet.m_nBodySize);
// some DEBUG code
/*RTMP_LIB_AMFObject obj;
int nRes = obj.Decode(packet.m_body+1, packet.m_nBodySize-1);
if(nRes < 0) {
- Log(LOGERROR, "%s, error decoding AMF3 packet", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s, error decoding AMF3 packet", __FUNCTION__);
//return;
}
case 0x14:
// invoke
- Log(LOGDEBUG, "%s, received: invoke %lu bytes", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s, received: invoke %lu bytes", __FUNCTION__,
packet->m_nBodySize);
- //LogHex(packet.m_body, packet.m_nBodySize);
+ //RTMP_LogHex(packet.m_body, packet.m_nBodySize);
if (ServeInvoke(server, r, packet, 0))
RTMP_Close(r);
/* flv */
break;
default:
- Log(LOGDEBUG, "%s, unknown packet type received: 0x%02x", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s, unknown packet type received: 0x%02x", __FUNCTION__,
packet->m_packetType);
#ifdef _DEBUG
- LogHex(LOGDEBUG, packet->m_body, packet->m_nBodySize);
+ RTMP_LogHex(RTMP_LOGDEBUG, packet->m_body, packet->m_nBodySize);
#endif
}
return ret;
switch (ich)
{
case 'q':
- LogPrintf("Exiting\n");
+ RTMP_LogPrintf("Exiting\n");
stopStreaming(rtmpServer);
exit(0);
break;
default:
- LogPrintf("Unknown command \'%c\', ignoring\n", ich);
+ RTMP_LogPrintf("Unknown command \'%c\', ignoring\n", ich);
}
}
TFRET();
if (select(sockfd + 1, &fds, NULL, NULL, &tv) <= 0)
{
- Log(LOGERROR, "Request timeout/select failed, ignoring request");
+ RTMP_Log(RTMP_LOGERROR, "Request timeout/select failed, ignoring request");
goto quit;
}
else
rtmp.m_sb.sb_socket = sockfd;
if (!RTMP_Serve(&rtmp))
{
- Log(LOGERROR, "Handshake failed");
+ RTMP_Log(RTMP_LOGERROR, "Handshake failed");
goto cleanup;
}
}
}
cleanup:
- LogPrintf("Closing connection... ");
+ RTMP_LogPrintf("Closing connection... ");
RTMP_Close(&rtmp);
/* Should probably be done by RTMP_Close() ... */
rtmp.Link.playpath.av_val = NULL;
rtmp.Link.pageUrl.av_val = NULL;
rtmp.Link.app.av_val = NULL;
rtmp.Link.flashVer.av_val = NULL;
- LogPrintf("done!\n\n");
+ RTMP_LogPrintf("done!\n\n");
quit:
if (server->state == STREAMING_IN_PROGRESS)
socklen_t destlen = sizeof(struct sockaddr_in);
getsockopt(sockfd, SOL_IP, SO_ORIGINAL_DST, &dest, &destlen);
strcpy(destch, inet_ntoa(dest.sin_addr));
- Log(LOGDEBUG, "%s: accepted connection from %s to %s\n", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s: accepted connection from %s to %s\n", __FUNCTION__,
inet_ntoa(addr.sin_addr), destch);
#else
- Log(LOGDEBUG, "%s: accepted connection from %s\n", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s: accepted connection from %s\n", __FUNCTION__,
inet_ntoa(addr.sin_addr));
#endif
/* Create a new thread and transfer the control to that */
doServe(server, sockfd);
- Log(LOGDEBUG, "%s: processed request\n", __FUNCTION__);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: processed request\n", __FUNCTION__);
}
else
{
- Log(LOGERROR, "%s: accept failed", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s: accept failed", __FUNCTION__);
}
}
server->state = STREAMING_STOPPED;
sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (sockfd == -1)
{
- Log(LOGERROR, "%s, couldn't create socket", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s, couldn't create socket", __FUNCTION__);
return 0;
}
if (bind(sockfd, (struct sockaddr *) &addr, sizeof(struct sockaddr_in)) ==
-1)
{
- Log(LOGERROR, "%s, TCP bind failed for port number: %d", __FUNCTION__,
+ RTMP_Log(RTMP_LOGERROR, "%s, TCP bind failed for port number: %d", __FUNCTION__,
port);
return 0;
}
if (listen(sockfd, 10) == -1)
{
- Log(LOGERROR, "%s, listen failed", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s, listen failed", __FUNCTION__);
closesocket(sockfd);
return 0;
}
}
if (closesocket(server->socket))
- Log(LOGERROR, "%s: Failed to close listening socket, error %d",
+ RTMP_Log(RTMP_LOGERROR, "%s: Failed to close listening socket, error %d",
GetSockError());
server->state = STREAMING_STOPPED;
sigIntHandler(int sig)
{
RTMP_ctrlC = true;
- LogPrintf("Caught signal: %d, cleaning up, just a second...\n", sig);
+ RTMP_LogPrintf("Caught signal: %d, cleaning up, just a second...\n", sig);
if (rtmpServer)
stopStreaming(rtmpServer);
signal(SIGINT, SIG_DFL);
char *rtmpStreamingDevice = DEFAULT_HTTP_STREAMING_DEVICE; // streaming device, default 0.0.0.0
int nRtmpStreamingPort = 1935; // port
- LogPrintf("RTMP Server %s\n", RTMPDUMP_VERSION);
- LogPrintf("(c) 2010 Andrej Stepanchuk, Howard Chu; license: GPL\n\n");
+ RTMP_LogPrintf("RTMP Server %s\n", RTMPDUMP_VERSION);
+ RTMP_LogPrintf("(c) 2010 Andrej Stepanchuk, Howard Chu; license: GPL\n\n");
- AMF_debuglevel = LOGINFO;
+ RTMP_debuglevel = RTMP_LOGINFO;
if (argc > 1 && !strcmp(argv[1], "-z"))
- AMF_debuglevel = LOGALL;
+ RTMP_debuglevel = RTMP_LOGALL;
// init request
memset(&defaultRTMPRequest, 0, sizeof(RTMP_REQUEST));
if ((rtmpServer =
startStreaming(rtmpStreamingDevice, nRtmpStreamingPort)) == 0)
{
- Log(LOGERROR, "Failed to start RTMP server, exiting!");
+ RTMP_Log(RTMP_LOGERROR, "Failed to start RTMP server, exiting!");
return RD_FAILED;
}
- LogPrintf("Streaming on rtmp://%s:%d\n", rtmpStreamingDevice,
+ RTMP_LogPrintf("Streaming on rtmp://%s:%d\n", rtmpStreamingDevice,
nRtmpStreamingPort);
while (rtmpServer->state != STREAMING_STOPPED)
{
sleep(1);
}
- Log(LOGDEBUG, "Done, exiting...");
+ RTMP_Log(RTMP_LOGDEBUG, "Done, exiting...");
CleanupSockets();
if (body[0] != 0x02) // make sure it is a string method name we start with
{
- Log(LOGWARNING, "%s, Sanity failed. no string method in invoke packet",
+ RTMP_Log(RTMP_LOGWARNING, "%s, Sanity failed. no string method in invoke packet",
__FUNCTION__);
return 0;
}
nRes = AMF_Decode(&obj, body, nBodySize, false);
if (nRes < 0)
{
- Log(LOGERROR, "%s, error decoding invoke packet", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s, error decoding invoke packet", __FUNCTION__);
return 0;
}
AMF_Dump(&obj);
AVal method;
AMFProp_GetString(AMF_GetProp(&obj, NULL, 0), &method);
- Log(LOGDEBUG, "%s, %s invoking <%s>", __FUNCTION__, cst[which], method.av_val);
+ RTMP_Log(RTMP_LOGDEBUG, "%s, %s invoking <%s>", __FUNCTION__, cst[which], method.av_val);
if (AVMATCH(&method, &av_connect))
{
AVal pname, pval;
int i;
AMFProp_GetObject(AMF_GetProp(&obj, NULL, 2), &cobj);
- LogPrintf("Processing connect\n");
+ RTMP_LogPrintf("Processing connect\n");
for (i=0; i<cobj.o_num; i++)
{
pname = cobj.o_props[i].p_name;
if (cobj.o_props[i].p_type == AMF_STRING)
{
pval = cobj.o_props[i].p_vu.p_aval;
- LogPrintf("%.*s: %.*s\n", pname.av_len, pname.av_val, pval.av_len, pval.av_val);
+ RTMP_LogPrintf("%.*s: %.*s\n", pname.av_len, pname.av_val, pval.av_len, pval.av_val);
}
if (AVMATCH(&pname, &av_app))
{
for (p=file; *p; p++)
if (*p == ':')
*p = '_';
- LogPrintf("Playpath: %.*s\nSaving as: %s\n",
+ RTMP_LogPrintf("Playpath: %.*s\nSaving as: %s\n",
server->rc.Link.playpath.av_len, server->rc.Link.playpath.av_val,
file);
out = fopen(file, "wb");
AMFProp_GetString(AMF_GetProp(&obj2, &av_code, -1), &code);
AMFProp_GetString(AMF_GetProp(&obj2, &av_level, -1), &level);
- Log(LOGDEBUG, "%s, onStatus: %s", __FUNCTION__, code.av_val);
+ RTMP_Log(RTMP_LOGDEBUG, "%s, onStatus: %s", __FUNCTION__, code.av_val);
if (AVMATCH(&code, &av_NetStream_Failed)
|| AVMATCH(&code, &av_NetStream_Play_Failed)
|| AVMATCH(&code, &av_NetStream_Play_StreamNotFound)
{
int ret = 0;
- Log(LOGDEBUG, "%s, %s sent packet type %02X, size %lu bytes", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s, %s sent packet type %02X, size %lu bytes", __FUNCTION__,
cst[which], packet->m_packetType, packet->m_nBodySize);
switch (packet->m_packetType)
case 0x08:
// audio data
- //Log(LOGDEBUG, "%s, received: audio %lu bytes", __FUNCTION__, packet.m_nBodySize);
+ //RTMP_Log(RTMP_LOGDEBUG, "%s, received: audio %lu bytes", __FUNCTION__, packet.m_nBodySize);
break;
case 0x09:
// video data
- //Log(LOGDEBUG, "%s, received: video %lu bytes", __FUNCTION__, packet.m_nBodySize);
+ //RTMP_Log(RTMP_LOGDEBUG, "%s, received: video %lu bytes", __FUNCTION__, packet.m_nBodySize);
break;
case 0x0F: // flex stream send
/* flv */
break;
default:
- Log(LOGDEBUG, "%s, unknown packet type received: 0x%02x", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s, unknown packet type received: 0x%02x", __FUNCTION__,
packet->m_packetType);
#ifdef _DEBUG
- LogHex(LOGDEBUG, packet->m_body, packet->m_nBodySize);
+ RTMP_LogHex(RTMP_LOGDEBUG, packet->m_body, packet->m_nBodySize);
#endif
}
return ret;
if (packet->m_packetType == 0x09 && nPacketLen <= 5)
{
- Log(LOGWARNING, "ignoring too small video packet: size: %d",
+ RTMP_Log(RTMP_LOGWARNING, "ignoring too small video packet: size: %d",
nPacketLen);
ret = 0;
break;
}
if (packet->m_packetType == 0x08 && nPacketLen <= 1)
{
- Log(LOGWARNING, "ignoring too small audio packet: size: %d",
+ RTMP_Log(RTMP_LOGWARNING, "ignoring too small audio packet: size: %d",
nPacketLen);
ret = 0;
break;
}
#ifdef _DEBUG
- Log(LOGDEBUG, "type: %02X, size: %d, TS: %d ms", packet->m_packetType,
+ RTMP_Log(RTMP_LOGDEBUG, "type: %02X, size: %d, TS: %d ms", packet->m_packetType,
nPacketLen, packet->m_nTimeStamp);
if (packet->m_packetType == 0x09)
- Log(LOGDEBUG, "frametype: %02X", (*packetBody & 0xf0));
+ RTMP_Log(RTMP_LOGDEBUG, "frametype: %02X", (*packetBody & 0xf0));
#endif
// calculate packet size and reallocate buffer if necessary
*buf = (char *) realloc(*buf, size + 4);
if (*buf == 0)
{
- Log(LOGERROR, "Couldn't reallocate memory!");
+ RTMP_Log(RTMP_LOGERROR, "Couldn't reallocate memory!");
ret = -1; // fatal error
break;
}
{
if (pos + 11 + dataSize > nPacketLen)
{
- Log(LOGERROR,
+ RTMP_Log(RTMP_LOGERROR,
"Wrong data size (%lu), stream corrupted, aborting!",
dataSize);
ret = -2;
break;
}
- Log(LOGWARNING, "No tagSize found, appending!");
+ RTMP_Log(RTMP_LOGWARNING, "No tagSize found, appending!");
// we have to append a last tagSize!
prevTagSize = dataSize + 11;
AMF_DecodeInt32(packetBody + pos + 11 + dataSize);
#ifdef _DEBUG
- Log(LOGDEBUG,
+ RTMP_Log(RTMP_LOGDEBUG,
"FLV Packet: type %02X, dataSize: %lu, tagSize: %lu, timeStamp: %lu ms",
(unsigned char) packetBody[pos], dataSize, prevTagSize,
*nTimeStamp);
if (prevTagSize != (dataSize + 11))
{
#ifdef _DEBUG
- Log(LOGWARNING,
+ RTMP_Log(RTMP_LOGWARNING,
"Tag and data size are not consitent, writing tag size according to dataSize+11: %d",
dataSize + 11);
#endif
switch (ich)
{
case 'q':
- LogPrintf("Exiting\n");
+ RTMP_LogPrintf("Exiting\n");
stopStreaming(rtmpServer);
free(rtmpServer);
exit(0);
break;
default:
- LogPrintf("Unknown command \'%c\', ignoring\n", ich);
+ RTMP_LogPrintf("Unknown command \'%c\', ignoring\n", ich);
}
}
TFRET();
if (select(sockfd + 1, &rfds, NULL, NULL, &tv) <= 0)
{
- Log(LOGERROR, "Request timeout/select failed, ignoring request");
+ RTMP_Log(RTMP_LOGERROR, "Request timeout/select failed, ignoring request");
goto quit;
}
else
server->rs.m_sb.sb_socket = sockfd;
if (!RTMP_Serve(&server->rs))
{
- Log(LOGERROR, "Handshake failed");
+ RTMP_Log(RTMP_LOGERROR, "Handshake failed");
goto cleanup;
}
}
continue;
}
}
- Log(LOGERROR, "Request timeout/select failed, ignoring request");
+ RTMP_Log(RTMP_LOGERROR, "Request timeout/select failed, ignoring request");
goto cleanup;
}
if (FD_ISSET(server->rs.m_sb.sb_socket, &rfds))
if (ps.m_nBodySize >= 4)
{
server->rs.m_inChunkSize = AMF_DecodeInt32(ps.m_body);
- Log(LOGDEBUG, "%s, client: chunk size change to %d", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s, client: chunk size change to %d", __FUNCTION__,
server->rs.m_inChunkSize);
server->rc.m_outChunkSize = server->rs.m_inChunkSize;
}
if (ps.m_nBodySize >= 4)
{
int count = AMF_DecodeInt32(ps.m_body);
- Log(LOGDEBUG, "%s, client: bytes received = %d", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s, client: bytes received = %d", __FUNCTION__,
count);
}
}
AMF_EncodeInt32(ptr+4, ptr+8, BUFFERTIME);
}
#endif
- Log(LOGDEBUG, "%s, client: BufferTime change in stream %d to %d", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s, client: BufferTime change in stream %d to %d", __FUNCTION__,
id, len);
}
}
if (pc.m_nBodySize >= 4)
{
server->rc.m_inChunkSize = AMF_DecodeInt32(pc.m_body);
- Log(LOGDEBUG, "%s, server: chunk size change to %d", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s, server: chunk size change to %d", __FUNCTION__,
server->rc.m_inChunkSize);
server->rs.m_outChunkSize = server->rc.m_inChunkSize;
}
}
#else
/* The session will certainly fail right after this */
- Log(LOGERROR, "%s, server requested SWF verification, need CRYPTO support! ", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s, server requested SWF verification, need CRYPTO support! ", __FUNCTION__);
#endif
}
else if (server->f_cur && (
}
cleanup:
- LogPrintf("Closing connection... ");
+ RTMP_LogPrintf("Closing connection... ");
RTMP_Close(&server->rs);
RTMP_Close(&server->rc);
while (server->f_head)
#ifdef CRYPTO
server->rc.Link.SWFHash.av_val = NULL;
#endif
- LogPrintf("done!\n\n");
+ RTMP_LogPrintf("done!\n\n");
quit:
if (server->state == STREAMING_IN_PROGRESS)
socklen_t destlen = sizeof(struct sockaddr_in);
getsockopt(sockfd, SOL_IP, SO_ORIGINAL_DST, &dest, &destlen);
strcpy(destch, inet_ntoa(dest.sin_addr));
- Log(LOGDEBUG, "%s: accepted connection from %s to %s\n", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s: accepted connection from %s to %s\n", __FUNCTION__,
inet_ntoa(addr.sin_addr), destch);
#else
- Log(LOGDEBUG, "%s: accepted connection from %s\n", __FUNCTION__,
+ RTMP_Log(RTMP_LOGDEBUG, "%s: accepted connection from %s\n", __FUNCTION__,
inet_ntoa(addr.sin_addr));
#endif
/* Create a new thread and transfer the control to that */
doServe(server, sockfd);
- Log(LOGDEBUG, "%s: processed request\n", __FUNCTION__);
+ RTMP_Log(RTMP_LOGDEBUG, "%s: processed request\n", __FUNCTION__);
}
else
{
- Log(LOGERROR, "%s: accept failed", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s: accept failed", __FUNCTION__);
}
}
server->state = STREAMING_STOPPED;
sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (sockfd == -1)
{
- Log(LOGERROR, "%s, couldn't create socket", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s, couldn't create socket", __FUNCTION__);
return 0;
}
if (bind(sockfd, (struct sockaddr *) &addr, sizeof(struct sockaddr_in)) ==
-1)
{
- Log(LOGERROR, "%s, TCP bind failed for port number: %d", __FUNCTION__,
+ RTMP_Log(RTMP_LOGERROR, "%s, TCP bind failed for port number: %d", __FUNCTION__,
port);
return 0;
}
if (listen(sockfd, 10) == -1)
{
- Log(LOGERROR, "%s, listen failed", __FUNCTION__);
+ RTMP_Log(RTMP_LOGERROR, "%s, listen failed", __FUNCTION__);
closesocket(sockfd);
return 0;
}
}
if (fd && closesocket(fd))
- Log(LOGERROR, "%s: Failed to close listening socket, error %d",
+ RTMP_Log(RTMP_LOGERROR, "%s: Failed to close listening socket, error %d",
GetSockError());
server->state = STREAMING_STOPPED;
sigIntHandler(int sig)
{
RTMP_ctrlC = true;
- LogPrintf("Caught signal: %d, cleaning up, just a second...\n", sig);
+ RTMP_LogPrintf("Caught signal: %d, cleaning up, just a second...\n", sig);
if (rtmpServer)
stopStreaming(rtmpServer);
signal(SIGINT, SIG_DFL);
char *rtmpStreamingDevice = DEFAULT_RTMP_STREAMING_DEVICE; // streaming device, default 0.0.0.0
int nRtmpStreamingPort = 1935; // port
- LogPrintf("RTMP Proxy Server %s\n", RTMPDUMP_VERSION);
- LogPrintf("(c) 2010 Andrej Stepanchuk, Howard Chu; license: GPL\n\n");
+ RTMP_LogPrintf("RTMP Proxy Server %s\n", RTMPDUMP_VERSION);
+ RTMP_LogPrintf("(c) 2010 Andrej Stepanchuk, Howard Chu; license: GPL\n\n");
- AMF_debuglevel = LOGINFO;
+ RTMP_debuglevel = RTMP_LOGINFO;
if (argc > 1 && !strcmp(argv[1], "-z"))
- AMF_debuglevel = LOGALL;
+ RTMP_debuglevel = RTMP_LOGALL;
signal(SIGINT, sigIntHandler);
#ifndef WIN32
if ((rtmpServer =
startStreaming(rtmpStreamingDevice, nRtmpStreamingPort)) == 0)
{
- Log(LOGERROR, "Failed to start RTMP server, exiting!");
+ RTMP_Log(RTMP_LOGERROR, "Failed to start RTMP server, exiting!");
return RD_FAILED;
}
- LogPrintf("Streaming on rtmp://%s:%d\n", rtmpStreamingDevice,
+ RTMP_LogPrintf("Streaming on rtmp://%s:%d\n", rtmpStreamingDevice,
nRtmpStreamingPort);
while (rtmpServer->state != STREAMING_STOPPED)
{
sleep(1);
}
- Log(LOGDEBUG, "Done, exiting...");
+ RTMP_Log(RTMP_LOGDEBUG, "Done, exiting...");
free(rtmpServer);
thd = (HANDLE) _beginthread(routine, 0, args);
if (thd == -1L)
- LogPrintf("%s, _beginthread failed with %d\n", __FUNCTION__, errno);
+ RTMP_LogPrintf("%s, _beginthread failed with %d\n", __FUNCTION__, errno);
return thd;
}
ret =
pthread_create(&id, &attributes, routine, args);
if (ret != 0)
- LogPrintf("%s, pthread_create failed with %d\n", __FUNCTION__, ret);
+ RTMP_LogPrintf("%s, pthread_create failed with %d\n", __FUNCTION__, ret);
return id;
}