[rtmpdump] r513 - trunk/librtmp/rtmp.c

hyc subversion at mplayerhq.hu
Sat Jun 19 20:57:39 CEST 2010


Author: hyc
Date: Sat Jun 19 20:57:38 2010
New Revision: 513

Log:
Add ping/pong msg, from mybiiter at gmail.com. (Untested. Used with "ustream"?)

Modified:
   trunk/librtmp/rtmp.c

Modified: trunk/librtmp/rtmp.c
==============================================================================
--- trunk/librtmp/rtmp.c	Thu Jun 17 21:13:44 2010	(r512)
+++ trunk/librtmp/rtmp.c	Sat Jun 19 20:57:38 2010	(r513)
@@ -1943,6 +1943,34 @@ SendCheckBWResult(RTMP *r, double txn)
   return RTMP_SendPacket(r, &packet, FALSE);
 }
 
+SAVC(ping);
+SAVC(pong);
+
+static int
+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 int
@@ -2335,6 +2363,10 @@ HandleInvoke(RTMP *r, const char *body, 
       RTMP_Close(r);
       ret = 1;
     }
+  else if (AVMATCH(&method, &av_ping))
+    {
+      SendPong(r, txn);
+    }
   else if (AVMATCH(&method, &av__onbwcheck))
     {
       SendCheckBWResult(r, txn);


More information about the rtmpdump mailing list