[rtmpdump] r189 - in trunk: rtmp.c rtmp.h rtmpdump.c rtmpsuck.c streams.c
hyc
subversion at mplayerhq.hu
Tue Jan 5 04:46:40 CET 2010
Author: hyc
Date: Tue Jan 5 04:46:39 2010
New Revision: 189
Log:
Add optional packet param to RTMP_Connect(); rtmpsuck will just send
the original connect packet instead of generating its own.
Modified:
trunk/rtmp.c
trunk/rtmp.h
trunk/rtmpdump.c
trunk/rtmpsuck.c
trunk/streams.c
Modified: trunk/rtmp.c
==============================================================================
--- trunk/rtmp.c Tue Jan 5 02:56:26 2010 (r188)
+++ trunk/rtmp.c Tue Jan 5 04:46:39 2010 (r189)
@@ -67,7 +67,7 @@ static bool DumpMetaData(AMFObject * obj
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);
@@ -330,7 +330,7 @@ add_addr_info(struct sockaddr_in *servic
}
bool
-RTMP_Connect(RTMP * r)
+RTMP_Connect(RTMP *r, RTMPPacket *cp)
{
struct sockaddr_in service;
if (!r->Link.hostname)
@@ -393,7 +393,7 @@ RTMP_Connect(RTMP * r)
}
Log(LOGDEBUG, "%s, handshaked", __FUNCTION__);
- if (!SendConnectPacket(r))
+ if (!SendConnectPacket(r, cp))
{
Log(LOGERROR, "%s, RTMP connect failed.", __FUNCTION__);
RTMP_Close(r);
@@ -868,11 +868,14 @@ SAVC(secureToken);
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
Modified: trunk/rtmp.h
==============================================================================
--- trunk/rtmp.h Tue Jan 5 02:56:26 2010 (r188)
+++ trunk/rtmp.h Tue Jan 5 04:46:39 2010 (r189)
@@ -209,7 +209,7 @@ void RTMP_SetupStream(RTMP *r, int proto
double dTime,
uint32_t dLength, bool bLiveStream, long int timeout);
-bool RTMP_Connect(RTMP *r);
+bool RTMP_Connect(RTMP *r, RTMPPacket *cp);
bool RTMP_Serve(RTMP *r);
bool RTMP_ReadPacket(RTMP * r, RTMPPacket * packet);
Modified: trunk/rtmpdump.c
==============================================================================
--- trunk/rtmpdump.c Tue Jan 5 02:56:26 2010 (r188)
+++ trunk/rtmpdump.c Tue Jan 5 04:46:39 2010 (r189)
@@ -1615,7 +1615,7 @@ main(int argc, char **argv)
first = 0;
LogPrintf("Connecting ...\n");
- if (!RTMP_Connect(&rtmp))
+ if (!RTMP_Connect(&rtmp, NULL))
{
nStatus = RD_FAILED;
break;
Modified: trunk/rtmpsuck.c
==============================================================================
--- trunk/rtmpsuck.c Tue Jan 5 02:56:26 2010 (r188)
+++ trunk/rtmpsuck.c Tue Jan 5 04:46:39 2010 (r189)
@@ -124,6 +124,7 @@ SAVC(objectEncoding);
SAVC(_result);
SAVC(createStream);
SAVC(play);
+SAVC(closeStream);
SAVC(fmsVer);
SAVC(mode);
SAVC(level);
@@ -297,7 +298,7 @@ ServeInvoke(STREAMING_SERVER *server, in
}
}
- if (!RTMP_Connect(&server->rc))
+ if (!RTMP_Connect(&server->rc, pack))
{
/* failed */
return 1;
@@ -313,6 +314,7 @@ ServeInvoke(STREAMING_SERVER *server, in
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, '?');
@@ -371,6 +373,10 @@ ServeInvoke(STREAMING_SERVER *server, in
ret = 1;
}
}
+ else if (AVMATCH(&method, &av_closeStream))
+ {
+ ret = 1;
+ }
else if (AVMATCH(&method, &av_close))
{
RTMP_Close(&server->rc);
@@ -385,8 +391,8 @@ ServePacket(STREAMING_SERVER *server, in
{
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)
{
@@ -432,20 +438,6 @@ ServePacket(STREAMING_SERVER *server, in
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;
}
@@ -459,10 +451,6 @@ ServePacket(STREAMING_SERVER *server, in
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;
@@ -794,18 +782,24 @@ void doServe(STREAMING_SERVER * server,
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;
@@ -1048,7 +1042,7 @@ main(int argc, char **argv)
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;
Modified: trunk/streams.c
==============================================================================
--- trunk/streams.c Tue Jan 5 02:56:26 2010 (r188)
+++ trunk/streams.c Tue Jan 5 04:46:39 2010 (r189)
@@ -639,7 +639,7 @@ void processTCPrequest(STREAMING_SERVER
rtmp.Link.token = req.token;
LogPrintf("Connecting ... port: %d, app: %s\n", req.rtmpport, req.app);
- if (!RTMP_Connect(&rtmp))
+ if (!RTMP_Connect(&rtmp, NULL))
{
LogPrintf("%s, failed to connect!\n", __FUNCTION__);
}
More information about the rtmpdump
mailing list