mirror of https://bitbucket.org/ausocean/av.git
mjpeg-player: make maxScanWindow a const an document it.
This commit is contained in:
parent
8accd624c1
commit
fb11dde938
|
@ -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.
|
// 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.
|
// A TS fragment should contain at least 3 TS packets, a PAT, a PMT, and one PID, each starting with 0x47.
|
||||||
static _syncOffset (data) {
|
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;
|
let i = 0;
|
||||||
while (i < scanwindow) {
|
while (i < scanWindow) {
|
||||||
if (data[i] === 0x47 && data[i + 188] === 0x47 && data[i + 2 * 188] === 0x47) {
|
if (data[i] === 0x47 && data[i + 188] === 0x47 && data[i + 2 * 188] === 0x47) {
|
||||||
return i;
|
return i;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue