static bool HandShake(RTMP * r, bool FP9HandShake);
static bool SocksNegotiate(RTMP * r);
-static bool SendConnectPacket(RTMP * r);
+static bool SendConnectPacket(RTMP * r, RTMPPacket *cp);
static bool SendServerBW(RTMP * r);
static bool SendCheckBW(RTMP * r);
static bool SendCheckBWResult(RTMP * r, double txn);
}
bool
-RTMP_Connect(RTMP * r)
+RTMP_Connect(RTMP *r, RTMPPacket *cp)
{
struct sockaddr_in service;
if (!r->Link.hostname)
}
Log(LOGDEBUG, "%s, handshaked", __FUNCTION__);
- if (!SendConnectPacket(r))
+ if (!SendConnectPacket(r, cp))
{
Log(LOGERROR, "%s, RTMP connect failed.", __FUNCTION__);
RTMP_Close(r);
SAVC(secureTokenResponse);
static bool
-SendConnectPacket(RTMP * r)
+SendConnectPacket(RTMP *r, RTMPPacket *cp)
{
RTMPPacket packet;
char pbuf[4096], *pend = pbuf+sizeof(pbuf);
+ if (cp)
+ return RTMP_SendPacket(r, cp, true);
+
packet.m_nChannel = 0x03; // control channel (invoke)
packet.m_headerType = RTMP_PACKET_SIZE_LARGE;
packet.m_packetType = 0x14; // INVOKE
SAVC(_result);
SAVC(createStream);
SAVC(play);
+SAVC(closeStream);
SAVC(fmsVer);
SAVC(mode);
SAVC(level);
}
}
- if (!RTMP_Connect(&server->rc))
+ if (!RTMP_Connect(&server->rc, pack))
{
/* failed */
return 1;
0x00, 0x00, 0x00, 0x00 // first prevTagSize=0
};
+ server->rc.m_stream_id = pack->m_nInfoField2;
AMFProp_GetString(AMF_GetProp(&obj, NULL, 3), &av);
server->rc.Link.playpath = av;
q = strchr(av.av_val, '?');
ret = 1;
}
}
+ else if (AVMATCH(&method, &av_closeStream))
+ {
+ ret = 1;
+ }
else if (AVMATCH(&method, &av_close))
{
RTMP_Close(&server->rc);
{
int ret = 0;
- Log(LOGDEBUG, "%s, received packet type %02X, size %lu bytes", __FUNCTION__,
- packet->m_packetType, packet->m_nBodySize);
+ Log(LOGDEBUG, "%s, %s sent packet type %02X, size %lu bytes", __FUNCTION__,
+ cst[which], packet->m_packetType, packet->m_nBodySize);
switch (packet->m_packetType)
{
case 0x11: // flex message
{
- Log(LOGDEBUG, "%s, flex message, size %lu bytes, not fully supported",
- __FUNCTION__, packet->m_nBodySize);
- //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__);
- //return;
- }
-
- obj.Dump(); */
-
ret = ServeInvoke(server, which, packet, packet->m_body + 1);
break;
}
case 0x14:
// invoke
- Log(LOGDEBUG, "%s, received: invoke %lu bytes", __FUNCTION__,
- packet->m_nBodySize);
- //LogHex(packet.m_body, packet.m_nBodySize);
-
ret = ServeInvoke(server, which, packet, packet->m_body);
break;
if (id)
{
len = AMF_DecodeInt32(ptr+4);
+#if 1
/* request a big buffer */
if (len < BUFFERTIME)
{
AMF_EncodeInt32(ptr+4, ptr+8, BUFFERTIME);
}
+#endif
Log(LOGDEBUG, "%s, client: BufferTime change in stream %d to %d", __FUNCTION__,
id, len);
}
}
}
- else if (!server->out && (ps.m_packetType == 0x11 || ps.m_packetType == 0x14))
- ServePacket(server, 0, &ps);
+ else if (ps.m_packetType == 0x11 || ps.m_packetType == 0x14)
+ if (ServePacket(server, 0, &ps) && server->out)
+ {
+ fclose(server->out);
+ server->out = NULL;
+ }
RTMP_SendPacket(&server->rc, &ps, false);
RTMPPacket_Free(&ps);
break;
LogPrintf("RTMP Proxy Server %s\n", RTMPDUMP_VERSION);
LogPrintf("(c) 2010 Andrej Stepanchuk, Howard Chu; license: GPL\n\n");
- debuglevel = LOGDEBUG;
+ debuglevel = LOGINFO;
if (argc > 1 && !strcmp(argv[1], "-z"))
debuglevel = LOGALL;