]> granicus.if.org Git - rtmpdump/commitdiff
Add extended timestamp for Type 3 chunks if necessary
authorCheolho Park <cheolhop@google.com>
Wed, 14 Jan 2015 21:24:12 +0000 (23:24 +0200)
committerMartin Storsjo <martin@martin.st>
Thu, 15 Jan 2015 08:24:28 +0000 (10:24 +0200)
Section 5.3.1.3 of the RTMP spec say that type 3 packets also
should repeat this field. This matches what the parsing code (in
RTMP_ReadPacket) does.

librtmp/rtmp.c

index 60f251c6583f82fff27d308ad96e2209d5feae7e..ca7db6a49aebb8f14b505d4505f3c6415a5daa00 100644 (file)
@@ -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)