mirror of https://bitbucket.org/ausocean/av.git
mjpeg-player: cosmetic changes to minimise diff
This commit is contained in:
parent
47d9130385
commit
9ba9eb14af
|
@ -36,6 +36,7 @@ class MTSDemuxer{
|
||||||
init() {
|
init() {
|
||||||
this.pmtParsed = false;
|
this.pmtParsed = false;
|
||||||
this._pmtId = -1;
|
this._pmtId = -1;
|
||||||
|
|
||||||
this._videoTrack = MTSDemuxer.createTrack('video');
|
this._videoTrack = MTSDemuxer.createTrack('video');
|
||||||
this._audioTrack = MTSDemuxer.createTrack('audio');
|
this._audioTrack = MTSDemuxer.createTrack('audio');
|
||||||
this._id3Track = MTSDemuxer.createTrack('id3');
|
this._id3Track = MTSDemuxer.createTrack('id3');
|
||||||
|
@ -80,34 +81,29 @@ class MTSDemuxer{
|
||||||
}
|
}
|
||||||
|
|
||||||
append(data) {
|
append(data) {
|
||||||
let videoTrack = this._videoTrack;
|
let start, len = data.length, pusi, pid, afc, offset, pes,
|
||||||
let videoData = videoTrack.pesData;
|
unknownPIDs = false;
|
||||||
let videoId = videoTrack.pid;
|
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;
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
const syncOffset = MTSDemuxer._syncOffset(data);
|
const syncOffset = MTSDemuxer._syncOffset(data);
|
||||||
|
|
||||||
// Don't parse last TS packet if incomplete.
|
// Don't parse last TS packet if incomplete.
|
||||||
len -= (len + syncOffset) % 188;
|
len -= (len + syncOffset) % 188;
|
||||||
|
|
||||||
// Loop through TS packets.
|
// Loop through TS packets.
|
||||||
let start, offset, pusi, pid, afc, pes;
|
|
||||||
for (start = syncOffset; start < len; start += 188) {
|
for (start = syncOffset; start < len; start += 188) {
|
||||||
if (data[start] === 0x47) {
|
if (data[start] === 0x47) {
|
||||||
pusi = !!(data[start + 1] & 0x40);
|
pusi = !!(data[start + 1] & 0x40);
|
||||||
|
@ -242,12 +238,12 @@ class MTSDemuxer{
|
||||||
}
|
}
|
||||||
|
|
||||||
_parsePMT (data, offset) {
|
_parsePMT (data, offset) {
|
||||||
let pid;
|
let programInfoLength, pid, result = { audio: -1, video: -1, id3: -1},
|
||||||
let result = { audio: -1, video: -1, id3: -1};
|
sectionLength = (data[offset + 1] & 0x0f) << 8 | data[offset + 2],
|
||||||
let sectionLength = (data[offset + 1] & 0x0f) << 8 | data[offset + 2];
|
tableEnd = offset + 3 + sectionLength - 4;
|
||||||
let tableEnd = offset + 3 + sectionLength - 4;
|
// To determine where the table is, we have to figure out how
|
||||||
// To determine where the table is, we have to figure out how long the program info descriptors are.
|
// long the program info descriptors are.
|
||||||
let programInfoLength = (data[offset + 10] & 0x0f) << 8 | data[offset + 11];
|
programInfoLength = (data[offset + 10] & 0x0f) << 8 | data[offset + 11];
|
||||||
// Advance the offset to the first entry in the mapping table.
|
// Advance the offset to the first entry in the mapping table.
|
||||||
offset += 12 + programInfoLength;
|
offset += 12 + programInfoLength;
|
||||||
while (offset < tableEnd) {
|
while (offset < tableEnd) {
|
||||||
|
@ -259,27 +255,27 @@ class MTSDemuxer{
|
||||||
if (result.video === -1) {
|
if (result.video === -1) {
|
||||||
result.video = pid;
|
result.video = pid;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0xcf: // SAMPLE-AES AAC.
|
case 0xcf: // SAMPLE-AES AAC.
|
||||||
case 0x0f: // ISO/IEC 13818-7 ADTS AAC (MPEG-2 lower bit-rate audio).
|
case 0x0f: // ISO/IEC 13818-7 ADTS AAC (MPEG-2 lower bit-rate audio).
|
||||||
case 0xd2: // ADPCM audio.
|
case 0xd2: // ADPCM audio.
|
||||||
case 0x03: // ISO/IEC 11172-3 (MPEG-1 audio).
|
case 0x03: // ISO/IEC 11172-3 (MPEG-1 audio).
|
||||||
case 0x24:
|
case 0x24:
|
||||||
// console.warn('HEVC stream type found, not supported for now');
|
// console.warn('HEVC stream type found, not supported for now');
|
||||||
case 0x04: // or ISO/IEC 13818-3 (MPEG-2 halved sample rate audio).
|
case 0x04: // or ISO/IEC 13818-3 (MPEG-2 halved sample rate audio).
|
||||||
if (result.audio === -1) {
|
if (result.audio === -1) {
|
||||||
result.audio = pid;
|
result.audio = pid;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x15: // Packetized metadata (ID3)
|
case 0x15: // Packetized metadata (ID3)
|
||||||
// console.log('ID3 PID:' + pid);
|
// console.log('ID3 PID:' + pid);
|
||||||
if (result.id3 === -1) {
|
if (result.id3 === -1) {
|
||||||
result.id3 = pid;
|
result.id3 = pid;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// console.log('unknown stream type:' + data[offset]);
|
// console.log('unknown stream type:' + data[offset]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Move to the next table entry, skip past the elementary stream descriptors, if present.
|
// Move to the next table entry, skip past the elementary stream descriptors, if present.
|
||||||
offset += ((data[offset + 3] & 0x0F) << 8 | data[offset + 4]) + 5;
|
offset += ((data[offset + 3] & 0x0F) << 8 | data[offset + 4]) + 5;
|
||||||
|
|
Loading…
Reference in New Issue