diff --git a/cmd/mjpeg-player/hlsjs/mts-demuxer.js b/cmd/mjpeg-player/hlsjs/mts-demuxer.js index 11c1f5d6..415b057c 100644 --- a/cmd/mjpeg-player/hlsjs/mts-demuxer.js +++ b/cmd/mjpeg-player/hlsjs/mts-demuxer.js @@ -121,6 +121,43 @@ class MTSDemuxer{ offset = start + 4; } switch (pid) { + case videoId: + if (pusi) { + if (videoData && (pes = parsePES(videoData)) && pes.pts !== undefined) { + videoTrack.data.push(pes.data); + // TODO: here pes contains data, pts, dts and len. Are all these needed? + } + videoData = { data: [], size: 0 }; + } + if (videoData) { + videoData.data.push(data.subarray(offset, start + 188)); + videoData.size += start + 188 - offset; + } + break; + case audioId: + if (pusi) { + if (audioData && (pes = parsePES(audioData)) && pes.pts !== undefined) { + audioTrack.data.push(pes.data); + } + audioData = { data: [], size: 0 }; + } + if (audioData) { + audioData.data.push(data.subarray(offset, start + 188)); + audioData.size += start + 188 - offset; + } + break; + case id3Id: + if (pusi) { + if (id3Data && (pes = parsePES(id3Data)) && pes.pts !== undefined) { + id3Track.data.push(pes.data); + } + id3Data = { data: [], size: 0 }; + } + if (id3Data) { + id3Data.data.push(data.subarray(offset, start + 188)); + id3Data.size += start + 188 - offset; + } + break; case 0: if (pusi) { offset += data[offset] + 1; @@ -159,43 +196,6 @@ class MTSDemuxer{ } pmtParsed = this.pmtParsed = true; break; - case videoId: - if (pusi) { - if (videoData && (pes = parsePES(videoData)) && pes.pts !== undefined) { - videoTrack.data.push(pes.data); - // TODO: here pes contains data, pts, dts and len. Are all these needed? - } - videoData = { data: [], size: 0 }; - } - if (videoData) { - videoData.data.push(data.subarray(offset, start + 188)); - videoData.size += start + 188 - offset; - } - break; - case audioId: - if (pusi) { - if (audioData && (pes = parsePES(audioData)) && pes.pts !== undefined) { - audioTrack.data.push(pes.data); - } - audioData = { data: [], size: 0 }; - } - if (audioData) { - audioData.data.push(data.subarray(offset, start + 188)); - audioData.size += start + 188 - offset; - } - break; - case id3Id: - if (pusi) { - if (id3Data && (pes = parsePES(id3Data)) && pes.pts !== undefined) { - id3Track.data.push(pes.data); - } - id3Data = { data: [], size: 0 }; - } - if (id3Data) { - id3Data.data.push(data.subarray(offset, start + 188)); - id3Data.size += start + 188 - offset; - } - break; default: unknownPIDs = true; break;