mjpeg-player: make maxScanWindow a const an document it.

This commit is contained in:
Trek H 2019-12-25 09:34:29 +10:30
parent 8accd624c1
commit fb11dde938
1 changed files with 4 additions and 3 deletions

View File

@ -64,13 +64,14 @@ class MTSDemuxer{
};
}
// _syncOffset scans the first 1000 bytes and returns an offset to the beginning of the first three MTS packets,
// _syncOffset scans the first 'maxScanWindow' bytes and returns an offset to the beginning of the first three MTS packets,
// or -1 if three are not found.
// A TS fragment should contain at least 3 TS packets, a PAT, a PMT, and one PID, each starting with 0x47.
static _syncOffset (data) {
const scanwindow = Math.min(1000, data.length - 3 * 188);
const maxScanWindow = 1000; // 1000 is a reasonable number of bytes to search for the first MTS packets.
const scanWindow = Math.min(maxScanWindow, data.length - 3 * 188);
let i = 0;
while (i < scanwindow) {
while (i < scanWindow) {
if (data[i] === 0x47 && data[i + 188] === 0x47 && data[i + 2 * 188] === 0x47) {
return i;
} else {