           break
         message.timestamp = (chunkMessageHeader[0] << 16) +
           (chunkMessageHeader[1] << 8) + chunkMessageHeader[2]
+
+        if message.timestamp is 0xffffff
+          message.extendedTimestampType = EXTENDED_TIMESTAMP_TYPE_ABSOLUTE
+        else
+          message.extendedTimestampType = EXTENDED_TIMESTAMP_TYPE_NOT_USED
+
         message.timestampDelta = 0
         message.messageLength = (chunkMessageHeader[3] << 16) +
           (chunkMessageHeader[4] << 8) + chunkMessageHeader[5]

        throw new Error "Unknown format type: #{formatType}"

      # 5.3.1.3. Extended Timestamp
      if message.formatType is 0
        if message.timestamp is 0xffffff
          if chunkBody.length < 4  # buffer is incomplete
            break
          message.timestamp = (chunkBody[0] * Math.pow(256, 3)) +
            (chunkBody[1] << 16) + (chunkBody[2] << 8) + chunkBody[3]
          chunkBody = chunkBody[4..]
          headerLen += 4
      else if message.timestampDelta is 0xffffff
        if chunkBody.length < 4  # buffer is incomplete
          break
        message.timestampDelta = (chunkBody[0] * Math.pow(256, 3)) +

AVC_PACKET_TYPE_SEQUENCE_HEADER = 0
AVC_PACKET_TYPE_NALU            = 1
AVC_PACKET_TYPE_END_OF_SEQUENCE = 2

EXTENDED_TIMESTAMP_TYPE_NOT_USED = 'not-used'
EXTENDED_TIMESTAMP_TYPE_ABSOLUTE = 'absolute'
EXTENDED_TIMESTAMP_TYPE_DELTA    = 'delta'

TIMESTAMP_ROUNDOFF = 4294967296  # 32 bits

