update components
This commit is contained in:
parent
59ea1c2f7d
commit
cf577ba8eb
1136 changed files with 59263 additions and 576 deletions
|
@ -54,13 +54,14 @@ class MSEMediaController extends EventHandler {
|
|||
}
|
||||
|
||||
startLoad() {
|
||||
if (this.levels && this.media) {
|
||||
if (this.levels) {
|
||||
this.startInternal();
|
||||
if (this.lastCurrentTime) {
|
||||
logger.log(`seeking @ ${this.lastCurrentTime}`);
|
||||
var media = this.media, lastCurrentTime = this.lastCurrentTime;
|
||||
if (media && lastCurrentTime) {
|
||||
logger.log(`seeking @ ${lastCurrentTime}`);
|
||||
if (!this.lastPaused) {
|
||||
logger.log('resuming video');
|
||||
this.media.play();
|
||||
media.play();
|
||||
}
|
||||
this.state = State.IDLE;
|
||||
} else {
|
||||
|
@ -70,7 +71,7 @@ class MSEMediaController extends EventHandler {
|
|||
this.nextLoadPosition = this.startPosition = this.lastCurrentTime;
|
||||
this.tick();
|
||||
} else {
|
||||
logger.warn('cannot start loading as either manifest not parsed or video not attached');
|
||||
logger.warn('cannot start loading as manifest not parsed yet');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -666,7 +667,7 @@ class MSEMediaController extends EventHandler {
|
|||
to avoid rounding issues/infinite loop,
|
||||
only flush buffer range of length greater than 500ms.
|
||||
*/
|
||||
if (flushEnd - flushStart > 0.5) {
|
||||
if (Math.min(flushEnd,bufEnd) - flushStart > 0.5) {
|
||||
logger.log(`flush ${type} [${flushStart},${flushEnd}], of [${bufStart},${bufEnd}], pos:${this.media.currentTime}`);
|
||||
sb.remove(flushStart, flushEnd);
|
||||
return false;
|
||||
|
@ -679,6 +680,8 @@ class MSEMediaController extends EventHandler {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.warn('abort flushing too many retries');
|
||||
}
|
||||
|
||||
/* after successful buffer flushing, rebuild buffer Range array
|
||||
|
@ -1221,7 +1224,7 @@ _checkBuffer() {
|
|||
jumpThreshold = 0;
|
||||
} else {
|
||||
// playhead not moving AND media playing
|
||||
logger.log('playback seems stuck');
|
||||
logger.log(`playback seems stuck @${currentTime}`);
|
||||
if(!this.stalled) {
|
||||
this.hls.trigger(Event.ERROR, {type: ErrorTypes.MEDIA_ERROR, details: ErrorDetails.BUFFER_STALLED_ERROR, fatal: false});
|
||||
this.stalled = true;
|
||||
|
|
|
@ -16,11 +16,11 @@ import ID3 from '../demux/id3';
|
|||
|
||||
static probe(data) {
|
||||
// check if data contains ID3 timestamp and ADTS sync worc
|
||||
var id3 = new ID3(data), adtsStartOffset,len;
|
||||
var id3 = new ID3(data), offset,len;
|
||||
if(id3.hasTimeStamp) {
|
||||
// look for ADTS header (0xFFFx)
|
||||
for (adtsStartOffset = id3.length, len = data.length; adtsStartOffset < len - 1; adtsStartOffset++) {
|
||||
if ((data[adtsStartOffset] === 0xff) && (data[adtsStartOffset+1] & 0xf0) === 0xf0) {
|
||||
for (offset = id3.length, len = data.length; offset < len - 1; offset++) {
|
||||
if ((data[offset] === 0xff) && (data[offset+1] & 0xf0) === 0xf0) {
|
||||
//logger.log('ADTS sync word found !');
|
||||
return true;
|
||||
}
|
||||
|
@ -35,46 +35,47 @@ import ID3 from '../demux/id3';
|
|||
var track = this._aacTrack,
|
||||
id3 = new ID3(data),
|
||||
pts = 90*id3.timeStamp,
|
||||
config, adtsFrameSize, adtsStartOffset, adtsHeaderLen, stamp, nbSamples, len, aacSample;
|
||||
config, frameLength, frameDuration, frameIndex, offset, headerLength, stamp, len, aacSample;
|
||||
// look for ADTS header (0xFFFx)
|
||||
for (adtsStartOffset = id3.length, len = data.length; adtsStartOffset < len - 1; adtsStartOffset++) {
|
||||
if ((data[adtsStartOffset] === 0xff) && (data[adtsStartOffset+1] & 0xf0) === 0xf0) {
|
||||
for (offset = id3.length, len = data.length; offset < len - 1; offset++) {
|
||||
if ((data[offset] === 0xff) && (data[offset+1] & 0xf0) === 0xf0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!track.audiosamplerate) {
|
||||
config = ADTS.getAudioConfig(this.observer,data, adtsStartOffset, audioCodec);
|
||||
config = ADTS.getAudioConfig(this.observer,data, offset, audioCodec);
|
||||
track.config = config.config;
|
||||
track.audiosamplerate = config.samplerate;
|
||||
track.channelCount = config.channelCount;
|
||||
track.codec = config.codec;
|
||||
track.timescale = this.remuxer.timescale;
|
||||
track.duration = this.remuxer.timescale * duration;
|
||||
track.timescale = config.samplerate;
|
||||
track.duration = config.samplerate * duration;
|
||||
logger.log(`parsed codec:${track.codec},rate:${config.samplerate},nb channel:${config.channelCount}`);
|
||||
}
|
||||
nbSamples = 0;
|
||||
while ((adtsStartOffset + 5) < len) {
|
||||
frameIndex = 0;
|
||||
frameDuration = 1024 * 90000 / track.audiosamplerate;
|
||||
while ((offset + 5) < len) {
|
||||
// The protection skip bit tells us if we have 2 bytes of CRC data at the end of the ADTS header
|
||||
headerLength = (!!(data[offset + 1] & 0x01) ? 7 : 9);
|
||||
// retrieve frame size
|
||||
adtsFrameSize = ((data[adtsStartOffset + 3] & 0x03) << 11);
|
||||
// byte 4
|
||||
adtsFrameSize |= (data[adtsStartOffset + 4] << 3);
|
||||
// byte 5
|
||||
adtsFrameSize |= ((data[adtsStartOffset + 5] & 0xE0) >>> 5);
|
||||
adtsHeaderLen = (!!(data[adtsStartOffset + 1] & 0x01) ? 7 : 9);
|
||||
adtsFrameSize -= adtsHeaderLen;
|
||||
stamp = Math.round(pts + nbSamples * 1024 * 90000 / track.audiosamplerate);
|
||||
frameLength = ((data[offset + 3] & 0x03) << 11) |
|
||||
(data[offset + 4] << 3) |
|
||||
((data[offset + 5] & 0xE0) >>> 5);
|
||||
frameLength -= headerLength;
|
||||
//stamp = pes.pts;
|
||||
//console.log('AAC frame, offset/length/pts:' + (adtsStartOffset+7) + '/' + adtsFrameSize + '/' + stamp.toFixed(0));
|
||||
if ((adtsFrameSize > 0) && ((adtsStartOffset + adtsHeaderLen + adtsFrameSize) <= len)) {
|
||||
aacSample = {unit: data.subarray(adtsStartOffset + adtsHeaderLen, adtsStartOffset + adtsHeaderLen + adtsFrameSize), pts: stamp, dts: stamp};
|
||||
|
||||
if ((frameLength > 0) && ((offset + headerLength + frameLength) <= len)) {
|
||||
stamp = pts + frameIndex * frameDuration;
|
||||
//logger.log(`AAC frame, offset/length/total/pts:${offset+headerLength}/${frameLength}/${data.byteLength}/${(stamp/90).toFixed(0)}`);
|
||||
aacSample = {unit: data.subarray(offset + headerLength, offset + headerLength + frameLength), pts: stamp, dts: stamp};
|
||||
track.samples.push(aacSample);
|
||||
track.len += adtsFrameSize;
|
||||
adtsStartOffset += adtsFrameSize + adtsHeaderLen;
|
||||
nbSamples++;
|
||||
track.len += frameLength;
|
||||
offset += frameLength + headerLength;
|
||||
frameIndex++;
|
||||
// look for ADTS header (0xFFFx)
|
||||
for ( ; adtsStartOffset < (len - 1); adtsStartOffset++) {
|
||||
if ((data[adtsStartOffset] === 0xff) && ((data[adtsStartOffset + 1] & 0xf0) === 0xf0)) {
|
||||
for ( ; offset < (len - 1); offset++) {
|
||||
if ((data[offset] === 0xff) && ((data[offset + 1] & 0xf0) === 0xf0)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -568,8 +568,8 @@
|
|||
track.audiosamplerate = config.samplerate;
|
||||
track.channelCount = config.channelCount;
|
||||
track.codec = config.codec;
|
||||
track.timescale = this.remuxer.timescale;
|
||||
track.duration = track.timescale * duration;
|
||||
track.timescale = config.samplerate;
|
||||
track.duration = config.samplerate * duration;
|
||||
logger.log(`parsed codec:${track.codec},rate:${config.samplerate},nb channel:${config.channelCount}`);
|
||||
}
|
||||
frameIndex = 0;
|
||||
|
@ -596,7 +596,7 @@
|
|||
//stamp = pes.pts;
|
||||
|
||||
if ((frameLength > 0) && ((offset + headerLength + frameLength) <= len)) {
|
||||
stamp = Math.round(pts + frameIndex * frameDuration);
|
||||
stamp = pts + frameIndex * frameDuration;
|
||||
//logger.log(`AAC frame, offset/length/total/pts:${offset+headerLength}/${frameLength}/${data.byteLength}/${(stamp/90).toFixed(0)}`);
|
||||
aacSample = {unit: data.subarray(offset + headerLength, offset + headerLength + frameLength), pts: stamp, dts: stamp};
|
||||
track.samples.push(aacSample);
|
||||
|
|
|
@ -42,7 +42,7 @@ class Hls {
|
|||
debug: false,
|
||||
maxBufferLength: 30,
|
||||
maxBufferSize: 60 * 1000 * 1000,
|
||||
maxBufferHole: 0.3,
|
||||
maxBufferHole: 0.5,
|
||||
maxSeekHole: 2,
|
||||
liveSyncDurationCount:3,
|
||||
liveMaxLatencyDurationCount: Infinity,
|
||||
|
|
|
@ -253,7 +253,8 @@ class MP4Remuxer {
|
|||
var view,
|
||||
offset = 8,
|
||||
pesTimeScale = this.PES_TIMESCALE,
|
||||
pes2mp4ScaleFactor = this.PES2MP4SCALEFACTOR,
|
||||
mp4timeScale = track.timescale,
|
||||
pes2mp4ScaleFactor = pesTimeScale/mp4timeScale,
|
||||
aacSample, mp4Sample,
|
||||
unit,
|
||||
mdat, moof,
|
||||
|
@ -262,15 +263,10 @@ class MP4Remuxer {
|
|||
samples = [],
|
||||
samples0 = [];
|
||||
|
||||
track.samples.forEach(aacSample => {
|
||||
if(pts === undefined || aacSample.pts > pts) {
|
||||
samples0.push(aacSample);
|
||||
pts = aacSample.pts;
|
||||
} else {
|
||||
logger.warn('dropping past audio frame');
|
||||
track.len -= aacSample.unit.byteLength;
|
||||
}
|
||||
track.samples.sort(function(a, b) {
|
||||
return (a.pts-b.pts);
|
||||
});
|
||||
samples0 = track.samples;
|
||||
|
||||
while (samples0.length) {
|
||||
aacSample = samples0.shift();
|
||||
|
@ -282,13 +278,15 @@ class MP4Remuxer {
|
|||
if (lastDTS !== undefined) {
|
||||
ptsnorm = this._PTSNormalize(pts, lastDTS);
|
||||
dtsnorm = this._PTSNormalize(dts, lastDTS);
|
||||
// let's compute sample duration
|
||||
// let's compute sample duration.
|
||||
// there should be 1024 audio samples in one AAC frame
|
||||
mp4Sample.duration = (dtsnorm - lastDTS) / pes2mp4ScaleFactor;
|
||||
if (mp4Sample.duration < 0) {
|
||||
if(Math.abs(mp4Sample.duration - 1024) > 10) {
|
||||
// not expected to happen ...
|
||||
logger.log(`invalid AAC sample duration at PTS:${aacSample.pts}:${mp4Sample.duration}`);
|
||||
mp4Sample.duration = 0;
|
||||
logger.log(`invalid AAC sample duration at PTS ${Math.round(pts/90)},should be 1024,found :${Math.round(mp4Sample.duration)}`);
|
||||
}
|
||||
mp4Sample.duration = 1024;
|
||||
dtsnorm = 1024 * pes2mp4ScaleFactor + lastDTS;
|
||||
} else {
|
||||
var nextAacPts = this.nextAacPts,delta;
|
||||
ptsnorm = this._PTSNormalize(pts, nextAacPts);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue