[rtmpdump] [PATCH] Extended timestamp field may be present in type 3 chunk headers
Martin Panter
vadmium+rtmp at gmail.com
Sun Mar 2 00:43:23 CET 2014
Hello, there does not seem to be a whole lot going on in this mailing
list. A few months ago I sent this patch to fix a bug, and I haven’t
seen any action, so I am trying again.
Please consider applying this patch to the Git repository, or let me
know if there are any problems with it, somewhere else I should send
it, etc.
On 18 September 2013 13:15, Martin Panter <vadmium+rtmp at gmail.com> wrote:
> Subject: [PATCH] Extended timestamp field may be present in type 3 chunk
> headers
>
> As described in Adobe’s RTMP specification dated 21 Dec 2012; also:
>
> * RTMPY ticket #107, “Compressed headers also can have an extended
> timestamp”,
> http://web.archive.org/web/20120624031323/http://dev.rtmpy.org/ticket/107
> * https://rarut.wordpress.com/2012/03/21/announcing-nginx-rtmp-module/
>
> This resolves intermittent hangs, segfaults and crashes I was seeing when
> starting ABC News 24 streams, e.g.:
>
> rtmpdump -r rtmp://cp81899.live.edgefcs.net/live/news24-med@28772 --live
>
> Some of the packets seemed to contain junk timestamp fields, which often
> required the extended field.
> ---
> Original in case G Mail messes this up:
> https://github.com/vadmium/rtmpdump/commit/c5a88e2.patch
>
> librtmp/rtmp.c | 25 ++++++++++++++++---------
> 1 file changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
> index 014ff8b..91ad27f 100644
> --- a/librtmp/rtmp.c
> +++ b/librtmp/rtmp.c
> @@ -3573,6 +3573,7 @@ RTMP_ReadPacket(RTMP *r, RTMPPacket *packet)
> char *header = (char *)hbuf;
> int nSize, hSize, nToRead, nChunk;
> int didAlloc = FALSE;
> + int extendedTimestamp;
>
> RTMP_Log(RTMP_LOGDEBUG2, "%s: fd=%d", __FUNCTION__, r->m_sb.sb_socket);
>
> @@ -3675,17 +3676,19 @@ RTMP_ReadPacket(RTMP *r, RTMPPacket *packet)
> packet->m_nInfoField2 = DecodeInt32LE(header + 7);
> }
> }
> - if (packet->m_nTimeStamp == 0xffffff)
> + }
> +
> + extendedTimestamp = packet->m_nTimeStamp == 0xffffff;
> + if (extendedTimestamp)
> + {
> + if (ReadN(r, header + nSize, 4) != 4)
> {
> - if (ReadN(r, header + nSize, 4) != 4)
> - {
> - RTMP_Log(RTMP_LOGERROR, "%s, failed to read extended timestamp",
> - __FUNCTION__);
> - return FALSE;
> - }
> - packet->m_nTimeStamp = AMF_DecodeInt32(header + nSize);
> - hSize += 4;
> + RTMP_Log(RTMP_LOGERROR, "%s, failed to read extended timestamp",
> + __FUNCTION__);
> + return FALSE;
> }
> + packet->m_nTimeStamp = AMF_DecodeInt32(header + nSize);
> + hSize += 4;
> }
>
> RTMP_LogHexString(RTMP_LOGDEBUG2, (uint8_t *)hbuf, hSize);
> @@ -3730,6 +3733,10 @@ RTMP_ReadPacket(RTMP *r, RTMPPacket *packet)
> if (!r->m_vecChannelsIn[packet->m_nChannel])
> r->m_vecChannelsIn[packet->m_nChannel] = malloc(sizeof(RTMPPacket));
> memcpy(r->m_vecChannelsIn[packet->m_nChannel], packet, sizeof(RTMPPacket));
> + if (extendedTimestamp)
> + {
> + r->m_vecChannelsIn[packet->m_nChannel]->m_nTimeStamp = 0xffffff;
> + }
>
> if (RTMPPacket_IsReady(packet))
> {
> --
> 1.8.3.4
More information about the rtmpdump
mailing list