FLV: Fix error on tag without enough data

This commit is contained in:
genteure 2022-06-22 23:05:23 +08:00
parent bb37dbdd3f
commit d454418980

View File

@ -173,9 +173,18 @@ namespace BililiveRecorder.Flv
if (this.Nalus?.Count > 0)
{
foreach (var nalu in this.Nalus)
{
var bytesLeft = buffer.Length - nalu.StartPosition;
if (bytesLeft >= nalu.FullSize)
{
nalu.NaluHash = BinaryConvertUtilities.ByteArrayToHexString(farmHash64.ComputeHash(buffer, nalu.StartPosition, (int)nalu.FullSize));
}
else
{
nalu.NaluHash = BinaryConvertUtilities.ByteArrayToHexString(farmHash64.ComputeHash(buffer, nalu.StartPosition, Math.Min(buffer.Length - nalu.StartPosition, (int)nalu.FullSize))) + "-PARTIAL";
}
}
}
}
return this.DataHash;