Index: rtmpdump.c =================================================================== --- rtmpdump.c (revision 508) +++ rtmpdump.c (working copy) @@ -531,7 +531,7 @@ // make sure we claim to have enough buffer time! if (!bOverrideBufferTime && bufferTime < (duration * 1000.0)) { - bufferTime = (uint32_t) (duration * 1000.0) + 5000; // extra 5sec to make sure we've got enough + bufferTime = (uint32_t) (duration * 10.0) + 5; // extra 5sec to make sure we've got enough RTMP_Log(RTMP_LOGDEBUG, "Detected that buffer time is less than duration, resetting to: %dms", @@ -740,7 +740,7 @@ AVal subscribepath = { 0, 0 }; int port = -1; int protocol = RTMP_PROTOCOL_UNDEFINED; - int retries = 0; + int retries = 5; int bLiveStream = FALSE; // is it a live stream? then we can't seek/resume int bHashes = FALSE; // display byte counters not hashes by default Index: librtmp/rtmp.c =================================================================== --- librtmp/rtmp.c (revision 508) +++ librtmp/rtmp.c (working copy) @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -1930,6 +1931,35 @@ 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 int @@ -2322,6 +2352,10 @@ RTMP_Close(r); ret = 1; } + else if (AVMATCH(&method, &av_ping)) + { + SendPong(r, 3.0); + } else if (AVMATCH(&method, &av__onbwcheck)) { SendCheckBWResult(r, txn);