<div dir="ltr"><div>Hi,</div><div><br></div><div>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.</div><div><br></div><div><span style="font-size:12.8000001907349px;font-family:Arial,Helvetica,sans-serif;line-height:18px"><br></span></div><div><span style="font-size:12.8000001907349px;font-family:Arial,Helvetica,sans-serif;line-height:18px">FYI, the related section from the RTMP spec (</span><a target="_blank" rel="nofollow" href="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" style="font-size:12.8000001907349px;margin:0px;border:0px;outline:0px;font-family:Arial,Helvetica,sans-serif;vertical-align:baseline;text-decoration:none;color:rgb(102,17,204);line-height:18px">http://www.adobe.com/content/dam/Adobe/en/devnet/rtmp/pdf/rtmp_specification_1.0.pdf</a><span style="font-size:12.8000001907349px;font-family:Arial,Helvetica,sans-serif;line-height:18px">) is:</span><br></div><div><br style="font-family:Arial,Helvetica,sans-serif;font-size:12.8000001907349px;line-height:18px"><span style="font-family:Arial,Helvetica,sans-serif;font-size:12.8000001907349px;line-height:18px">5.3.1.3. Extended Timestamp</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:12.8000001907349px;line-height:18px"><span style="font-family:Arial,Helvetica,sans-serif;font-size:12.8000001907349px;line-height:18px"> The Extended Timestamp field is used to encode timestamps or</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:12.8000001907349px;line-height:18px"><span style="font-family:Arial,Helvetica,sans-serif;font-size:12.8000001907349px;line-height:18px"> timestamp deltas that are greater than 16777215 (0xFFFFFF); that is,</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:12.8000001907349px;line-height:18px"><span style="font-family:Arial,Helvetica,sans-serif;font-size:12.8000001907349px;line-height:18px"> for timestamps or timestamp deltas that don’t fit in the 24 bit</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:12.8000001907349px;line-height:18px"><span style="font-family:Arial,Helvetica,sans-serif;font-size:12.8000001907349px;line-height:18px"> fields of Type 0, 1, or 2 chunks. This field encodes the complete</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:12.8000001907349px;line-height:18px"><span style="font-family:Arial,Helvetica,sans-serif;font-size:12.8000001907349px;line-height:18px"> 32-bit timestamp or timestamp delta. The presence of this field is</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:12.8000001907349px;line-height:18px"><span style="font-family:Arial,Helvetica,sans-serif;font-size:12.8000001907349px;line-height:18px"> indicated by setting the timestamp field of a Type 0 chunk, or the</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:12.8000001907349px;line-height:18px"><span style="font-family:Arial,Helvetica,sans-serif;font-size:12.8000001907349px;line-height:18px"> timestamp delta field of a Type 1 or 2 chunk, to 16777215 (0xFFFFFF).</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:12.8000001907349px;line-height:18px"><span style="font-family:Arial,Helvetica,sans-serif;font-size:12.8000001907349px;line-height:18px"> This field is present in Type 3 chunks when the most recent Type 0,</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:12.8000001907349px;line-height:18px"><span style="font-family:Arial,Helvetica,sans-serif;font-size:12.8000001907349px;line-height:18px"> 1, or 2 chunk for the same chunk stream ID indicated the presence of</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:12.8000001907349px;line-height:18px"><span style="font-family:Arial,Helvetica,sans-serif;font-size:12.8000001907349px;line-height:18px"> an extended timestamp field.</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:12.8000001907349px;line-height:18px"></div><div><br></div><div>This is my patch:</div><div><br></div><br><div><div>diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c</div><div>index 60f251c..ca7db6a 100644</div><div>--- a/librtmp/rtmp.c</div><div>+++ b/librtmp/rtmp.c</div><div>@@ -3965,10 +3965,11 @@ RTMP_SendPacket(RTMP *r, RTMPPacket *packet, int queue)</div><div>       hSize += cSize;</div><div>     }</div><div> </div><div>-  if (nSize > 1 && t >= 0xffffff)</div><div>+  if (t >= 0xffffff)</div><div>     {</div><div>       header -= 4;</div><div>       hSize += 4;</div><div>+      RTMP_Log(RTMP_LOGWARNING, "Larger timestamp than 24-bit: 0x%x", t);</div><div>     }</div><div> </div><div>   hptr = header;</div><div>@@ -4007,7 +4008,7 @@ RTMP_SendPacket(RTMP *r, RTMPPacket *packet, int queue)</div><div>   if (nSize > 8)</div><div>     hptr += EncodeInt32LE(hptr, packet->m_nInfoField2);</div><div> </div><div>-  if (nSize > 1 && t >= 0xffffff)</div><div>+  if (t >= 0xffffff)</div><div>     hptr = AMF_EncodeInt32(hptr, hend, t);</div><div> </div><div>   nSize = packet->m_nBodySize;</div><div>@@ -4062,6 +4063,11 @@ RTMP_SendPacket(RTMP *r, RTMPPacket *packet, int queue)</div><div>              header -= cSize;</div><div>              hSize += cSize;</div><div>            }</div><div>+          if (t >= 0xffffff)</div><div>+            {</div><div>+              header -= 4;</div><div>+              hSize += 4;</div><div>+            }</div><div>          *header = (0xc0 | c);</div><div>          if (cSize)</div><div>            {</div><div>@@ -4070,6 +4076,11 @@ RTMP_SendPacket(RTMP *r, RTMPPacket *packet, int queue)</div><div>              if (cSize == 2)</div><div>                header[2] = tmp >> 8;</div><div>            }</div><div>+          if (t >= 0xffffff)</div><div>+            {</div><div>+              char* extendedTimestamp = header + 1 + cSize;</div><div>+              AMF_EncodeInt32(extendedTimestamp, extendedTimestamp + 4, t);</div><div>+            }</div><div>        }</div><div>     }</div><div>   if (tbuf)</div></div><div><br></div><div><br></div><div>Regards,</div><div><br></div><div>Cheolho</div><div><br></div></div>