[rtmpdump] Patch: Add extended timestamp for Type 3 chunks
Cheolho Park
cheolhop at google.com
Thu Dec 11 00:04:34 CET 2014
Hi,
In the current code, extended timestamp is not added in Type 3 chunks when
it is necessary. This causes some servers to disconnect the connection when
receiving the chucks.
FYI, the related section from the RTMP spec (
http://www.adobe.com/content/dam/Adobe/en/devnet/rtmp/pdf/rtmp_specification_1.0.pdf
<https://google.com/url?sa=D&q=http%3A%2F%2Fwww.adobe.com%2Fcontent%2Fdam%2FAdobe%2Fen%2Fdevnet%2Frtmp%2Fpdf%2Frtmp_specification_1.0.pdf>)
is:
5.3.1.3. Extended Timestamp
The Extended Timestamp field is used to encode timestamps or
timestamp deltas that are greater than 16777215 (0xFFFFFF); that is,
for timestamps or timestamp deltas that don’t fit in the 24 bit
fields of Type 0, 1, or 2 chunks. This field encodes the complete
32-bit timestamp or timestamp delta. The presence of this field is
indicated by setting the timestamp field of a Type 0 chunk, or the
timestamp delta field of a Type 1 or 2 chunk, to 16777215 (0xFFFFFF).
This field is present in Type 3 chunks when the most recent Type 0,
1, or 2 chunk for the same chunk stream ID indicated the presence of
an extended timestamp field.
This is my patch:
diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
index 60f251c..ca7db6a 100644
--- a/librtmp/rtmp.c
+++ b/librtmp/rtmp.c
@@ -3965,10 +3965,11 @@ RTMP_SendPacket(RTMP *r, RTMPPacket *packet, int
queue)
hSize += cSize;
}
- if (nSize > 1 && t >= 0xffffff)
+ if (t >= 0xffffff)
{
header -= 4;
hSize += 4;
+ RTMP_Log(RTMP_LOGWARNING, "Larger timestamp than 24-bit: 0x%x", t);
}
hptr = header;
@@ -4007,7 +4008,7 @@ RTMP_SendPacket(RTMP *r, RTMPPacket *packet, int
queue)
if (nSize > 8)
hptr += EncodeInt32LE(hptr, packet->m_nInfoField2);
- if (nSize > 1 && t >= 0xffffff)
+ if (t >= 0xffffff)
hptr = AMF_EncodeInt32(hptr, hend, t);
nSize = packet->m_nBodySize;
@@ -4062,6 +4063,11 @@ RTMP_SendPacket(RTMP *r, RTMPPacket *packet, int
queue)
header -= cSize;
hSize += cSize;
}
+ if (t >= 0xffffff)
+ {
+ header -= 4;
+ hSize += 4;
+ }
*header = (0xc0 | c);
if (cSize)
{
@@ -4070,6 +4076,11 @@ RTMP_SendPacket(RTMP *r, RTMPPacket *packet, int
queue)
if (cSize == 2)
header[2] = tmp >> 8;
}
+ if (t >= 0xffffff)
+ {
+ char* extendedTimestamp = header + 1 + cSize;
+ AMF_EncodeInt32(extendedTimestamp, extendedTimestamp + 4, t);
+ }
}
}
if (tbuf)
Regards,
Cheolho
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.mplayerhq.hu/pipermail/rtmpdump/attachments/20141210/fc9855f6/attachment.html>
More information about the rtmpdump
mailing list