[rtmpdump] rtmpdump ustream patch
BIITER
mybiiter at gmail.com
Sun May 30 07:35:45 CEST 2010
Hi, this patch allows rtmpdump to keep connection with ustream server.
BIITER
--- old/rtmpdump/librtmp/rtmp.c 2010-05-29 06:15:18.000000000 +0200
+++ new/rtmpdump/librtmp/rtmp.c 2010-05-29 04:21:44.000000000 +0200
@@ -1929,6 +1929,35 @@ SendCheckBWResult(RTMP *r, double txn)
return RTMP_SendPacket(r, &packet, false);
}
+SAVC(ping);
+SAVC(pong);
+
+static bool
+SendPong(RTMP *r, double txn)
+{
+ RTMPPacket packet;
+ char pbuf[256], *pend = pbuf + sizeof(pbuf);
+ char *enc;
+
+ packet.m_nChannel = 0x03; /* control channel (invoke) */
+ packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+ packet.m_packetType = 0x14; /* INVOKE */
+ packet.m_nTimeStamp = 0x16 * r->m_nBWCheckCounter; /* temp inc
value. till we figure it out. */
+ packet.m_nInfoField2 = 0;
+ packet.m_hasAbsTimestamp = 0;
+ packet.m_body = pbuf + RTMP_MAX_HEADER_SIZE;
+
+ enc = packet.m_body;
+ enc = AMF_EncodeString(enc, pend, &av_pong);
+ enc = AMF_EncodeNumber(enc, pend, txn);
+ *enc++ = AMF_NULL;
+
+ packet.m_nBodySize = enc - packet.m_body;
+
+ return RTMP_SendPacket(r, &packet, false);
+}
+
+
SAVC(play);
static bool
@@ -2321,6 +2350,10 @@ HandleInvoke(RTMP *r, const char *body,
RTMP_Close(r);
ret = 1;
}
+ else if (AVMATCH(&method, &av_ping))
+ {
+ SendPong(r, 3.0);
+ }
else if (AVMATCH(&method, &av__onbwcheck))
{
SendCheckBWResult(r, txn);
More information about the rtmpdump
mailing list