mjpeg-player: cosmetic changes to minimise diff

This commit is contained in:
Trek H 2019-12-13 13:53:52 +10:30
parent 47d9130385
commit 9ba9eb14af
1 changed files with 44 additions and 48 deletions

View File

@ -36,6 +36,7 @@ class MTSDemuxer{
init() {
this.pmtParsed = false;
this._pmtId = -1;
this._videoTrack = MTSDemuxer.createTrack('video');
this._audioTrack = MTSDemuxer.createTrack('audio');
this._id3Track = MTSDemuxer.createTrack('id3');
@ -80,26 +81,22 @@ class MTSDemuxer{
}
append(data) {
let videoTrack = this._videoTrack;
let videoData = videoTrack.pesData;
let videoId = videoTrack.pid;
let audioTrack = this._audioTrack;
let audioData = audioTrack.pesData;
let audioId = audioTrack.pid;
let id3Track = this._id3Track;
let id3Data = id3Track.pesData;
let id3Id = id3Track.pid;
let pmtId = this._pmtId;
let pmtParsed = this.pmtParsed;
let parsePAT = this._parsePAT;
let parsePMT = this._parsePMT;
let parsePES = this._parsePES;
let len = data.length;
let unknownPIDs = false;
let start, len = data.length, pusi, pid, afc, offset, pes,
unknownPIDs = false;
let pmtParsed = this.pmtParsed,
videoTrack = this._videoTrack,
audioTrack = this._audioTrack,
id3Track = this._id3Track,
videoId = videoTrack.pid,
audioId = audioTrack.pid,
id3Id = id3Track.pid,
pmtId = this._pmtId,
videoData = videoTrack.pesData,
audioData = audioTrack.pesData,
id3Data = id3Track.pesData,
parsePAT = this._parsePAT,
parsePMT = this._parsePMT,
parsePES = this._parsePES;
const syncOffset = MTSDemuxer._syncOffset(data);
@ -107,7 +104,6 @@ class MTSDemuxer{
len -= (len + syncOffset) % 188;
// Loop through TS packets.
let start, offset, pusi, pid, afc, pes;
for (start = syncOffset; start < len; start += 188) {
if (data[start] === 0x47) {
pusi = !!(data[start + 1] & 0x40);
@ -242,12 +238,12 @@ class MTSDemuxer{
}
_parsePMT (data, offset) {
let pid;
let result = { audio: -1, video: -1, id3: -1};
let sectionLength = (data[offset + 1] & 0x0f) << 8 | data[offset + 2];
let tableEnd = offset + 3 + sectionLength - 4;
// To determine where the table is, we have to figure out how long the program info descriptors are.
let programInfoLength = (data[offset + 10] & 0x0f) << 8 | data[offset + 11];
let programInfoLength, pid, result = { audio: -1, video: -1, id3: -1},
sectionLength = (data[offset + 1] & 0x0f) << 8 | data[offset + 2],
tableEnd = offset + 3 + sectionLength - 4;
// To determine where the table is, we have to figure out how
// long the program info descriptors are.
programInfoLength = (data[offset + 10] & 0x0f) << 8 | data[offset + 11];
// Advance the offset to the first entry in the mapping table.
offset += 12 + programInfoLength;
while (offset < tableEnd) {
@ -259,27 +255,27 @@ class MTSDemuxer{
if (result.video === -1) {
result.video = pid;
}
break;
case 0xcf: // SAMPLE-AES AAC.
case 0x0f: // ISO/IEC 13818-7 ADTS AAC (MPEG-2 lower bit-rate audio).
case 0xd2: // ADPCM audio.
case 0x03: // ISO/IEC 11172-3 (MPEG-1 audio).
case 0x24:
// console.warn('HEVC stream type found, not supported for now');
case 0x04: // or ISO/IEC 13818-3 (MPEG-2 halved sample rate audio).
if (result.audio === -1) {
result.audio = pid;
}
break;
case 0x15: // Packetized metadata (ID3)
// console.log('ID3 PID:' + pid);
if (result.id3 === -1) {
result.id3 = pid;
}
break;
default:
// console.log('unknown stream type:' + data[offset]);
break;
break;
case 0xcf: // SAMPLE-AES AAC.
case 0x0f: // ISO/IEC 13818-7 ADTS AAC (MPEG-2 lower bit-rate audio).
case 0xd2: // ADPCM audio.
case 0x03: // ISO/IEC 11172-3 (MPEG-1 audio).
case 0x24:
// console.warn('HEVC stream type found, not supported for now');
case 0x04: // or ISO/IEC 13818-3 (MPEG-2 halved sample rate audio).
if (result.audio === -1) {
result.audio = pid;
}
break;
case 0x15: // Packetized metadata (ID3)
// console.log('ID3 PID:' + pid);
if (result.id3 === -1) {
result.id3 = pid;
}
break;
default:
// console.log('unknown stream type:' + data[offset]);
break;
}
// Move to the next table entry, skip past the elementary stream descriptors, if present.
offset += ((data[offset + 3] & 0x0F) << 8 | data[offset + 4]) + 5;