static bool SendServerBW(RTMP * r);
static bool SendCheckBW(RTMP * r);
static bool SendCheckBWResult(RTMP * r, double txn);
-static bool SendCtrl(RTMP * r, short nType, unsigned int nObject,
- unsigned int nTime);
static bool SendBGHasStream(RTMP * r, double dId, AVal * playpath);
static bool SendCreateStream(RTMP * r, double dStreamId);
static bool SendDeleteStream(RTMP * r, double dStreamId);
bool
RTMPPacket_Alloc(RTMPPacket * p, int nSize)
{
- p->m_body = calloc(1, nSize);
+ char *ptr = calloc(1, nSize+RTMP_MAX_HEADER_SIZE);
+ p->m_body = ptr + RTMP_MAX_HEADER_SIZE;
if (!p->m_body)
return false;
p->m_nBytesRead = 0;
void
RTMPPacket_Free(RTMPPacket * p)
{
- free(p->m_body);
- p->m_body = NULL;
+ if (p->m_body)
+ {
+ free(p->m_body-RTMP_MAX_HEADER_SIZE);
+ p->m_body = NULL;
+ }
}
void
void
RTMP_UpdateBufferMS(RTMP * r)
{
- SendCtrl(r, 3, r->m_stream_id, r->m_nBufferMS);
+ RTMP_SendCtrl(r, 3, r->m_stream_id, r->m_nBufferMS);
}
void
* type 26: SWFVerification request
* type 27: SWFVerification response
*/
-static bool
-SendCtrl(RTMP * r, short nType, unsigned int nObject, unsigned int nTime)
+bool
+RTMP_SendCtrl(RTMP * r, short nType, unsigned int nObject, unsigned int nTime)
{
Log(LOGDEBUG, "sending ctrl. type: 0x%04x", (unsigned short) nType);
}
}
SendServerBW(r);
- SendCtrl(r, 3, 0, 300);
+ RTMP_SendCtrl(r, 3, 0, 300);
SendCreateStream(r, 2.0);
(int) AMFProp_GetNumber(AMF_GetProp(&obj, NULL, 3));
SendPlay(r);
- SendCtrl(r, 3, r->m_stream_id, r->m_nBufferMS);
+ RTMP_SendCtrl(r, 3, r->m_stream_id, r->m_nBufferMS);
}
else if (AVMATCH(&methodInvoked, &av_play))
{
case 6: // server ping. reply with pong.
tmp = AMF_DecodeInt32(packet->m_body + 2);
Log(LOGDEBUG, "%s, Ping %d", __FUNCTION__, tmp);
- SendCtrl(r, 0x07, tmp, 0);
+ RTMP_SendCtrl(r, 0x07, tmp, 0);
break;
case 31:
// 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)
{
- SendCtrl(r, 0x1B, 0, 0);
+ RTMP_SendCtrl(r, 0x1B, 0, 0);
}
else
{