@byteplus/veplayer-plugin 2.4.0 → 2.4.1-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.development.js +43395 -42054
- package/esm/index.production.js +3 -3
- package/esm/veplayer.plugin.abr.development.js +2555 -2238
- package/esm/veplayer.plugin.abr.production.js +1 -1
- package/esm/veplayer.plugin.flv.development.js +419 -158
- package/esm/veplayer.plugin.flv.production.js +1 -1
- package/esm/veplayer.plugin.hls.development.js +738 -79
- package/esm/veplayer.plugin.hls.production.js +1 -1
- package/esm/veplayer.plugin.mp4.development.js +2 -2
- package/esm/veplayer.plugin.mp4.production.js +1 -1
- package/esm/veplayer.plugin.rtm.development.js +10 -4
- package/esm/veplayer.plugin.rtm.production.js +1 -1
- package/esm/veplayer.plugin.shaka.development.js +1 -1
- package/esm/veplayer.plugin.shaka.production.js +1 -1
- package/package.json +1 -1
- package/umd/veplayer.plugin.abr.development.js +2555 -2238
- package/umd/veplayer.plugin.abr.production.js +1 -1
- package/umd/veplayer.plugin.flv.development.js +419 -158
- package/umd/veplayer.plugin.flv.production.js +1 -1
- package/umd/veplayer.plugin.hls.development.js +738 -79
- package/umd/veplayer.plugin.hls.production.js +1 -1
- package/umd/veplayer.plugin.mp4.development.js +2 -2
- package/umd/veplayer.plugin.mp4.production.js +1 -1
- package/umd/veplayer.plugin.rtm.development.js +10 -4
- package/umd/veplayer.plugin.rtm.production.js +1 -1
- package/umd/veplayer.plugin.shaka.development.js +1 -1
- package/umd/veplayer.plugin.shaka.production.js +1 -1
|
@@ -1538,7 +1538,7 @@ util.getCurrentTimeByOffset = function(offsetTime, segments) {
|
|
|
1538
1538
|
}
|
|
1539
1539
|
return offsetTime;
|
|
1540
1540
|
};
|
|
1541
|
-
var version = "3.0.
|
|
1541
|
+
var version = "3.0.20-rc.3";
|
|
1542
1542
|
var ERROR_MAP = {
|
|
1543
1543
|
1: 5101,
|
|
1544
1544
|
2: 5102,
|
|
@@ -2759,6 +2759,21 @@ var Buffer$1 = /* @__PURE__ */ function() {
|
|
|
2759
2759
|
length: Buffer2.totalLength && Buffer2.totalLength(buffers)
|
|
2760
2760
|
};
|
|
2761
2761
|
}
|
|
2762
|
+
}, {
|
|
2763
|
+
key: "isBuffered",
|
|
2764
|
+
value: function isBuffered(media, pos) {
|
|
2765
|
+
if (media) {
|
|
2766
|
+
var buffered = Buffer2.get(media);
|
|
2767
|
+
if (buffered !== null && buffered !== void 0 && buffered.length) {
|
|
2768
|
+
for (var i = 0; i < buffered.length; i++) {
|
|
2769
|
+
if (pos >= buffered.start(i) && pos <= buffered.end(i)) {
|
|
2770
|
+
return true;
|
|
2771
|
+
}
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2775
|
+
return false;
|
|
2776
|
+
}
|
|
2762
2777
|
}]);
|
|
2763
2778
|
return Buffer2;
|
|
2764
2779
|
}();
|
|
@@ -5523,6 +5538,7 @@ var TrackType = {
|
|
|
5523
5538
|
METADATA: "metadata"
|
|
5524
5539
|
};
|
|
5525
5540
|
var VideoCodecType = {
|
|
5541
|
+
AV1: "av1",
|
|
5526
5542
|
AVC: "avc",
|
|
5527
5543
|
HEVC: "hevc"
|
|
5528
5544
|
};
|
|
@@ -5569,6 +5585,7 @@ var VideoTrack = /* @__PURE__ */ function() {
|
|
|
5569
5585
|
_defineProperty(this, "isVideoEncryption", false);
|
|
5570
5586
|
_defineProperty(this, "isAudioEncryption", false);
|
|
5571
5587
|
_defineProperty(this, "isVideo", true);
|
|
5588
|
+
_defineProperty(this, "lastKeyFrameDts", 0);
|
|
5572
5589
|
_defineProperty(this, "kid", null);
|
|
5573
5590
|
_defineProperty(this, "pssh", null);
|
|
5574
5591
|
_defineProperty(this, "ext", void 0);
|
|
@@ -5611,6 +5628,9 @@ var VideoTrack = /* @__PURE__ */ function() {
|
|
|
5611
5628
|
}, {
|
|
5612
5629
|
key: "exist",
|
|
5613
5630
|
value: function exist() {
|
|
5631
|
+
if (/av01/.test(this.codec)) {
|
|
5632
|
+
return true;
|
|
5633
|
+
}
|
|
5614
5634
|
return !!(this.pps.length && this.sps.length && this.codec);
|
|
5615
5635
|
}
|
|
5616
5636
|
}, {
|
|
@@ -5888,7 +5908,7 @@ var AAC = /* @__PURE__ */ function() {
|
|
|
5888
5908
|
continue;
|
|
5889
5909
|
}
|
|
5890
5910
|
frameLength = (data[i + 3] & 3) << 11 | data[i + 4] << 3 | (data[i + 5] & 224) >> 5;
|
|
5891
|
-
if (len - i < frameLength)
|
|
5911
|
+
if (!frameLength || len - i < frameLength)
|
|
5892
5912
|
break;
|
|
5893
5913
|
protectionSkipBytes = (~data[i + 1] & 1) * 2;
|
|
5894
5914
|
frames.push({
|
|
@@ -7306,6 +7326,7 @@ var FlvDemuxer = /* @__PURE__ */ function() {
|
|
|
7306
7326
|
value: function demux(data) {
|
|
7307
7327
|
var discontinuity = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
7308
7328
|
var contiguous = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
|
|
7329
|
+
var seamlessLoadingSwitching = arguments.length > 3 ? arguments[3] : void 0;
|
|
7309
7330
|
var audioTrack = this.audioTrack, videoTrack = this.videoTrack, metadataTrack = this.metadataTrack;
|
|
7310
7331
|
if (discontinuity || !contiguous) {
|
|
7311
7332
|
this._remainingData = null;
|
|
@@ -7363,6 +7384,8 @@ var FlvDemuxer = /* @__PURE__ */ function() {
|
|
|
7363
7384
|
if (tagType === 8) {
|
|
7364
7385
|
this._parseAudio(bodyData, timestamp);
|
|
7365
7386
|
} else if (tagType === 9) {
|
|
7387
|
+
if (seamlessLoadingSwitching)
|
|
7388
|
+
this.seamlessLoadingSwitching = true;
|
|
7366
7389
|
this._parseVideo(bodyData, timestamp);
|
|
7367
7390
|
} else if (tagType === 18) {
|
|
7368
7391
|
this._parseScript(bodyData, timestamp);
|
|
@@ -7405,8 +7428,8 @@ var FlvDemuxer = /* @__PURE__ */ function() {
|
|
|
7405
7428
|
}
|
|
7406
7429
|
}, {
|
|
7407
7430
|
key: "demuxAndFix",
|
|
7408
|
-
value: function demuxAndFix(data, discontinuity, contiguous, startTime) {
|
|
7409
|
-
this.demux(data, discontinuity, contiguous);
|
|
7431
|
+
value: function demuxAndFix(data, discontinuity, contiguous, startTime, seamlessLoadingSwitching) {
|
|
7432
|
+
this.demux(data, discontinuity, contiguous, seamlessLoadingSwitching);
|
|
7410
7433
|
return this.fix(startTime, discontinuity, contiguous);
|
|
7411
7434
|
}
|
|
7412
7435
|
}, {
|
|
@@ -7520,8 +7543,13 @@ var FlvDemuxer = /* @__PURE__ */ function() {
|
|
|
7520
7543
|
units = this._checkAddMetaNalToUnits(isHevc, units, track);
|
|
7521
7544
|
if (units && units.length) {
|
|
7522
7545
|
var sample = new VideoSample(dts + cts, dts, units);
|
|
7546
|
+
if (this.seamlessLoadingSwitching && dts < track.lastKeyFrameDts) {
|
|
7547
|
+
return;
|
|
7548
|
+
}
|
|
7549
|
+
this.seamlessLoadingSwitching = false;
|
|
7523
7550
|
if (frameType === 1) {
|
|
7524
7551
|
sample.setToKeyframe();
|
|
7552
|
+
track.lastKeyFrameDts = dts;
|
|
7525
7553
|
}
|
|
7526
7554
|
track.samples.push(sample);
|
|
7527
7555
|
units.forEach(function(unit) {
|
|
@@ -7999,6 +8027,8 @@ var MP4 = /* @__PURE__ */ function() {
|
|
|
7999
8027
|
}
|
|
8000
8028
|
} else if (track.useEME && track.encv) {
|
|
8001
8029
|
content = MP42.encv(track);
|
|
8030
|
+
} else if (track.av1C) {
|
|
8031
|
+
content = MP42.av01(track);
|
|
8002
8032
|
} else {
|
|
8003
8033
|
content = MP42.avc1hev1(track);
|
|
8004
8034
|
}
|
|
@@ -8211,6 +8241,90 @@ var MP4 = /* @__PURE__ */ function() {
|
|
|
8211
8241
|
var schi = MP42.schi(data);
|
|
8212
8242
|
return MP42.box(MP42.types.sinf, content, MP42.box(MP42.types.frma, frma), MP42.box(MP42.types.schm, schm), schi);
|
|
8213
8243
|
}
|
|
8244
|
+
}, {
|
|
8245
|
+
key: "av01",
|
|
8246
|
+
value: function av01(track) {
|
|
8247
|
+
return MP42.box(MP42.types.av01, new Uint8Array([
|
|
8248
|
+
0,
|
|
8249
|
+
0,
|
|
8250
|
+
0,
|
|
8251
|
+
0,
|
|
8252
|
+
0,
|
|
8253
|
+
0,
|
|
8254
|
+
0,
|
|
8255
|
+
1,
|
|
8256
|
+
0,
|
|
8257
|
+
0,
|
|
8258
|
+
0,
|
|
8259
|
+
0,
|
|
8260
|
+
0,
|
|
8261
|
+
0,
|
|
8262
|
+
0,
|
|
8263
|
+
0,
|
|
8264
|
+
0,
|
|
8265
|
+
0,
|
|
8266
|
+
0,
|
|
8267
|
+
0,
|
|
8268
|
+
0,
|
|
8269
|
+
0,
|
|
8270
|
+
0,
|
|
8271
|
+
0,
|
|
8272
|
+
track.width >> 8 & 255,
|
|
8273
|
+
track.width & 255,
|
|
8274
|
+
track.height >> 8 & 255,
|
|
8275
|
+
track.height & 255,
|
|
8276
|
+
0,
|
|
8277
|
+
72,
|
|
8278
|
+
0,
|
|
8279
|
+
0,
|
|
8280
|
+
0,
|
|
8281
|
+
72,
|
|
8282
|
+
0,
|
|
8283
|
+
0,
|
|
8284
|
+
0,
|
|
8285
|
+
0,
|
|
8286
|
+
0,
|
|
8287
|
+
0,
|
|
8288
|
+
0,
|
|
8289
|
+
1,
|
|
8290
|
+
0,
|
|
8291
|
+
0,
|
|
8292
|
+
0,
|
|
8293
|
+
0,
|
|
8294
|
+
0,
|
|
8295
|
+
0,
|
|
8296
|
+
0,
|
|
8297
|
+
0,
|
|
8298
|
+
0,
|
|
8299
|
+
0,
|
|
8300
|
+
0,
|
|
8301
|
+
0,
|
|
8302
|
+
0,
|
|
8303
|
+
0,
|
|
8304
|
+
0,
|
|
8305
|
+
0,
|
|
8306
|
+
0,
|
|
8307
|
+
0,
|
|
8308
|
+
0,
|
|
8309
|
+
0,
|
|
8310
|
+
0,
|
|
8311
|
+
0,
|
|
8312
|
+
0,
|
|
8313
|
+
0,
|
|
8314
|
+
0,
|
|
8315
|
+
0,
|
|
8316
|
+
0,
|
|
8317
|
+
0,
|
|
8318
|
+
0,
|
|
8319
|
+
0,
|
|
8320
|
+
0,
|
|
8321
|
+
0,
|
|
8322
|
+
0,
|
|
8323
|
+
24,
|
|
8324
|
+
17,
|
|
8325
|
+
17
|
|
8326
|
+
]), track.av1C, track.colr);
|
|
8327
|
+
}
|
|
8214
8328
|
}, {
|
|
8215
8329
|
key: "avc1hev1",
|
|
8216
8330
|
value: function avc1hev1(track) {
|
|
@@ -9183,7 +9297,7 @@ var MP4 = /* @__PURE__ */ function() {
|
|
|
9183
9297
|
}]);
|
|
9184
9298
|
return MP42;
|
|
9185
9299
|
}();
|
|
9186
|
-
_defineProperty(MP4, "types", ["avc1", "avcC", "hvc1", "hvcC", "dinf", "dref", "esds", "ftyp", "hdlr", "mdat", "mdhd", "mdia", "mfhd", "minf", "moof", "moov", "mp4a", "mvex", "mvhd", "pasp", "stbl", "stco", "stsc", "stsd", "stsz", "stts", "tfdt", "tfhd", "traf", "trak", "trex", "tkhd", "vmhd", "smhd", "ctts", "stss", "styp", "pssh", "sidx", "sbgp", "saiz", "saio", "senc", "trun", "encv", "enca", "sinf", "btrt", "frma", "tenc", "schm", "schi", "mehd", "fiel", "sdtp"].reduce(function(p, c) {
|
|
9300
|
+
_defineProperty(MP4, "types", ["av01", "av1C", "avc1", "avcC", "hvc1", "hvcC", "dinf", "dref", "esds", "ftyp", "hdlr", "mdat", "mdhd", "mdia", "mfhd", "minf", "moof", "moov", "mp4a", "mvex", "mvhd", "pasp", "stbl", "stco", "stsc", "stsd", "stsz", "stts", "tfdt", "tfhd", "traf", "trak", "trex", "tkhd", "vmhd", "smhd", "ctts", "stss", "styp", "pssh", "sidx", "sbgp", "saiz", "saio", "senc", "trun", "encv", "enca", "sinf", "btrt", "frma", "tenc", "schm", "schi", "mehd", "fiel", "sdtp"].reduce(function(p, c) {
|
|
9187
9301
|
p[c] = [c.charCodeAt(0), c.charCodeAt(1), c.charCodeAt(2), c.charCodeAt(3)];
|
|
9188
9302
|
return p;
|
|
9189
9303
|
}, /* @__PURE__ */ Object.create(null)));
|
|
@@ -9518,30 +9632,46 @@ var FMP4Remuxer = /* @__PURE__ */ function() {
|
|
|
9518
9632
|
};
|
|
9519
9633
|
}
|
|
9520
9634
|
var samples = track.samples;
|
|
9635
|
+
var isAV01 = /av01/.test(track.codec);
|
|
9521
9636
|
var mdatSize = 0;
|
|
9522
|
-
|
|
9523
|
-
|
|
9524
|
-
|
|
9525
|
-
}
|
|
9526
|
-
|
|
9527
|
-
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
|
|
9531
|
-
|
|
9532
|
-
var sampleSize = 0;
|
|
9533
|
-
_sample.units.forEach(function(u) {
|
|
9534
|
-
mdatView.setUint32(_offset, u.byteLength);
|
|
9535
|
-
_offset += 4;
|
|
9536
|
-
mdata.set(u, _offset);
|
|
9537
|
-
_offset += u.byteLength;
|
|
9538
|
-
sampleSize += 4 + u.byteLength;
|
|
9637
|
+
if (isAV01) {
|
|
9638
|
+
samples.forEach(function(s) {
|
|
9639
|
+
mdatSize += s.data.byteLength;
|
|
9640
|
+
});
|
|
9641
|
+
} else {
|
|
9642
|
+
samples.forEach(function(s) {
|
|
9643
|
+
mdatSize += s.units.reduce(function(t, c) {
|
|
9644
|
+
return t + c.byteLength;
|
|
9645
|
+
}, 0);
|
|
9646
|
+
mdatSize += s.units.length * 4;
|
|
9539
9647
|
});
|
|
9540
|
-
|
|
9541
|
-
|
|
9542
|
-
|
|
9543
|
-
|
|
9544
|
-
|
|
9648
|
+
}
|
|
9649
|
+
var mdata = new Uint8Array(mdatSize);
|
|
9650
|
+
if (isAV01) {
|
|
9651
|
+
for (var i = 0, l = samples.length, offset = 0, sample; i < l; i++) {
|
|
9652
|
+
sample = samples[i];
|
|
9653
|
+
mdata.set(sample.data, offset);
|
|
9654
|
+
sample.size = sample.data.byteLength;
|
|
9655
|
+
offset += sample.size;
|
|
9656
|
+
}
|
|
9657
|
+
} else {
|
|
9658
|
+
var mdatView = new DataView(mdata.buffer);
|
|
9659
|
+
var _loop = function _loop2(_offset2, _sample2) {
|
|
9660
|
+
_sample2 = samples[_i];
|
|
9661
|
+
var sampleSize = 0;
|
|
9662
|
+
_sample2.units.forEach(function(u) {
|
|
9663
|
+
mdatView.setUint32(_offset2, u.byteLength);
|
|
9664
|
+
_offset2 += 4;
|
|
9665
|
+
mdata.set(u, _offset2);
|
|
9666
|
+
_offset2 += u.byteLength;
|
|
9667
|
+
sampleSize += 4 + u.byteLength;
|
|
9668
|
+
});
|
|
9669
|
+
_sample2.size = sampleSize;
|
|
9670
|
+
_offset = _offset2, _sample = _sample2;
|
|
9671
|
+
};
|
|
9672
|
+
for (var _i = 0, _l = samples.length, _offset = 0, _sample; _i < _l; _i++) {
|
|
9673
|
+
_loop(_offset, _sample);
|
|
9674
|
+
}
|
|
9545
9675
|
}
|
|
9546
9676
|
var mdat = MP4.mdat(mdata);
|
|
9547
9677
|
var moof = MP4.moof([track]);
|
|
@@ -9571,6 +9701,55 @@ var FMP4Remuxer = /* @__PURE__ */ function() {
|
|
|
9571
9701
|
}]);
|
|
9572
9702
|
return FMP4Remuxer2;
|
|
9573
9703
|
}();
|
|
9704
|
+
var TransferCost = /* @__PURE__ */ function() {
|
|
9705
|
+
function TransferCost2() {
|
|
9706
|
+
_classCallCheck$4(this, TransferCost2);
|
|
9707
|
+
_defineProperty$3(this, "_ttfb", 0);
|
|
9708
|
+
_defineProperty$3(this, "_demuxStart", 0);
|
|
9709
|
+
_defineProperty$3(this, "_demuxEnd", 0);
|
|
9710
|
+
_defineProperty$3(this, "_demuxCost", 0);
|
|
9711
|
+
_defineProperty$3(this, "_remuxStart", 0);
|
|
9712
|
+
_defineProperty$3(this, "_remuxEnd", 0);
|
|
9713
|
+
_defineProperty$3(this, "_remuxCost", 0);
|
|
9714
|
+
_defineProperty$3(this, "_appendStart", 0);
|
|
9715
|
+
_defineProperty$3(this, "_appendEnd", 0);
|
|
9716
|
+
_defineProperty$3(this, "_appendCost", 0);
|
|
9717
|
+
}
|
|
9718
|
+
_createClass$4(TransferCost2, [{
|
|
9719
|
+
key: "set",
|
|
9720
|
+
value: function set(event, value) {
|
|
9721
|
+
this["_".concat(event)] = value;
|
|
9722
|
+
}
|
|
9723
|
+
}, {
|
|
9724
|
+
key: "start",
|
|
9725
|
+
value: function start(event) {
|
|
9726
|
+
this["_".concat(event, "Start")] = Date.now();
|
|
9727
|
+
}
|
|
9728
|
+
}, {
|
|
9729
|
+
key: "end",
|
|
9730
|
+
value: function end(event) {
|
|
9731
|
+
this["_".concat(event, "End")] = Date.now();
|
|
9732
|
+
this["_".concat(event, "Cost")] = this["_".concat(event, "Cost")] + (this["_".concat(event, "End")] - this["_".concat(event, "Start")]);
|
|
9733
|
+
}
|
|
9734
|
+
}, {
|
|
9735
|
+
key: "transferCost",
|
|
9736
|
+
get: function get() {
|
|
9737
|
+
return {
|
|
9738
|
+
ttfbCost: this._ttfb,
|
|
9739
|
+
demuxCost: this._demuxCost,
|
|
9740
|
+
remuxCost: this._remuxCost,
|
|
9741
|
+
appendCost: this._appendCost
|
|
9742
|
+
};
|
|
9743
|
+
}
|
|
9744
|
+
}]);
|
|
9745
|
+
return TransferCost2;
|
|
9746
|
+
}();
|
|
9747
|
+
var TRANSFER_EVENT = {
|
|
9748
|
+
TTFB: "ttfb",
|
|
9749
|
+
DEMUX: "demux",
|
|
9750
|
+
REMUX: "remux",
|
|
9751
|
+
APPEND: "append"
|
|
9752
|
+
};
|
|
9574
9753
|
var logger$1 = new Logger$2("BufferService");
|
|
9575
9754
|
var BufferService = /* @__PURE__ */ function() {
|
|
9576
9755
|
function BufferService2(flv, softVideo) {
|
|
@@ -9658,7 +9837,8 @@ var BufferService = /* @__PURE__ */ function() {
|
|
|
9658
9837
|
this._contiguous = false;
|
|
9659
9838
|
this._sourceCreated = false;
|
|
9660
9839
|
this._initSegmentId = "";
|
|
9661
|
-
|
|
9840
|
+
this.resetSeamlessSwitchStats();
|
|
9841
|
+
case 12:
|
|
9662
9842
|
case "end":
|
|
9663
9843
|
return _context.stop();
|
|
9664
9844
|
}
|
|
@@ -9669,6 +9849,15 @@ var BufferService = /* @__PURE__ */ function() {
|
|
|
9669
9849
|
}
|
|
9670
9850
|
return reset;
|
|
9671
9851
|
}()
|
|
9852
|
+
}, {
|
|
9853
|
+
key: "resetSeamlessSwitchStats",
|
|
9854
|
+
value: function resetSeamlessSwitchStats() {
|
|
9855
|
+
this.seamlessLoadingSwitch = null;
|
|
9856
|
+
this.seamlessLoadingSwitching = false;
|
|
9857
|
+
if (this._demuxer) {
|
|
9858
|
+
this._demuxer.seamlessLoadingSwitching = false;
|
|
9859
|
+
}
|
|
9860
|
+
}
|
|
9672
9861
|
}, {
|
|
9673
9862
|
key: "endOfStream",
|
|
9674
9863
|
value: function() {
|
|
@@ -9774,32 +9963,56 @@ var BufferService = /* @__PURE__ */ function() {
|
|
|
9774
9963
|
key: "appendBuffer",
|
|
9775
9964
|
value: function() {
|
|
9776
9965
|
var _appendBuffer = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee5(chunk) {
|
|
9777
|
-
var
|
|
9966
|
+
var _this = this;
|
|
9967
|
+
var switchingNoReset, demuxer, videoTrack, audioTrack, metadataTrack, idx, videoExist, audioExist, duration, track, videoType, audioType, mse, newId, remuxResult, p;
|
|
9778
9968
|
return _regeneratorRuntime$1().wrap(function _callee5$(_context5) {
|
|
9779
9969
|
while (1)
|
|
9780
9970
|
switch (_context5.prev = _context5.next) {
|
|
9781
9971
|
case 0:
|
|
9972
|
+
switchingNoReset = false;
|
|
9782
9973
|
if (this._cachedBuffer) {
|
|
9783
9974
|
chunk = concatUint8Array$1(this._cachedBuffer, chunk);
|
|
9784
9975
|
this._cachedBuffer = null;
|
|
9785
9976
|
}
|
|
9786
9977
|
demuxer = this._demuxer;
|
|
9787
9978
|
if (!(!chunk || !chunk.length || !demuxer)) {
|
|
9788
|
-
_context5.next =
|
|
9979
|
+
_context5.next = 5;
|
|
9789
9980
|
break;
|
|
9790
9981
|
}
|
|
9791
9982
|
return _context5.abrupt("return");
|
|
9792
|
-
case
|
|
9793
|
-
_context5.prev =
|
|
9794
|
-
|
|
9795
|
-
|
|
9983
|
+
case 5:
|
|
9984
|
+
_context5.prev = 5;
|
|
9985
|
+
this.flv._transferCost.start(TRANSFER_EVENT.DEMUX);
|
|
9986
|
+
demuxer.demuxAndFix(chunk, this.seamlessLoadingSwitching || this._discontinuity, this._contiguous, this._demuxStartTime, this.seamlessLoadingSwitching);
|
|
9987
|
+
this.seamlessLoadingSwitching = false;
|
|
9988
|
+
this.flv._transferCost.end(TRANSFER_EVENT.DEMUX);
|
|
9989
|
+
_context5.next = 15;
|
|
9796
9990
|
break;
|
|
9797
|
-
case
|
|
9798
|
-
_context5.prev =
|
|
9799
|
-
_context5.t0 = _context5["catch"](
|
|
9991
|
+
case 12:
|
|
9992
|
+
_context5.prev = 12;
|
|
9993
|
+
_context5.t0 = _context5["catch"](5);
|
|
9800
9994
|
throw new StreamingError(ERR.DEMUX, ERR.SUB_TYPES.FLV, _context5.t0);
|
|
9801
|
-
case
|
|
9995
|
+
case 15:
|
|
9802
9996
|
videoTrack = demuxer.videoTrack, audioTrack = demuxer.audioTrack, metadataTrack = demuxer.metadataTrack;
|
|
9997
|
+
if (!this.seamlessLoadingSwitch) {
|
|
9998
|
+
_context5.next = 25;
|
|
9999
|
+
break;
|
|
10000
|
+
}
|
|
10001
|
+
idx = videoTrack.samples.findIndex(function(sample) {
|
|
10002
|
+
return sample.originDts === videoTrack.lastKeyFrameDts;
|
|
10003
|
+
});
|
|
10004
|
+
if (!(idx >= 0)) {
|
|
10005
|
+
_context5.next = 25;
|
|
10006
|
+
break;
|
|
10007
|
+
}
|
|
10008
|
+
videoTrack.samples.splice(idx);
|
|
10009
|
+
_context5.next = 22;
|
|
10010
|
+
return this.seamlessLoadingSwitch();
|
|
10011
|
+
case 22:
|
|
10012
|
+
this.seamlessLoadingSwitch = null;
|
|
10013
|
+
chunk = null;
|
|
10014
|
+
switchingNoReset = true;
|
|
10015
|
+
case 25:
|
|
9803
10016
|
videoExist = videoTrack.exist();
|
|
9804
10017
|
audioExist = audioTrack.exist();
|
|
9805
10018
|
if (this._opts.onlyAudio) {
|
|
@@ -9811,7 +10024,7 @@ var BufferService = /* @__PURE__ */ function() {
|
|
|
9811
10024
|
audioTrack.present = false;
|
|
9812
10025
|
}
|
|
9813
10026
|
if (!(!videoExist && videoTrack.present || !audioExist && audioTrack.present)) {
|
|
9814
|
-
_context5.next =
|
|
10027
|
+
_context5.next = 42;
|
|
9815
10028
|
break;
|
|
9816
10029
|
}
|
|
9817
10030
|
duration = 0;
|
|
@@ -9820,7 +10033,7 @@ var BufferService = /* @__PURE__ */ function() {
|
|
|
9820
10033
|
duration = (track.samples[track.samples.length - 1].originPts - track.samples[0].originPts) / track.timescale * 1e3;
|
|
9821
10034
|
}
|
|
9822
10035
|
if (!(duration > this._opts.analyzeDuration)) {
|
|
9823
|
-
_context5.next =
|
|
10036
|
+
_context5.next = 40;
|
|
9824
10037
|
break;
|
|
9825
10038
|
}
|
|
9826
10039
|
logger$1.warn("analyze duration exceeded, ".concat(duration, "ms"), track);
|
|
@@ -9829,18 +10042,20 @@ var BufferService = /* @__PURE__ */ function() {
|
|
|
9829
10042
|
this.flv.emit(EVENT.ANALYZE_DURATION_EXCEEDED, {
|
|
9830
10043
|
duration
|
|
9831
10044
|
});
|
|
9832
|
-
_context5.next =
|
|
10045
|
+
_context5.next = 42;
|
|
9833
10046
|
break;
|
|
9834
|
-
case
|
|
10047
|
+
case 40:
|
|
9835
10048
|
this._cachedBuffer = chunk;
|
|
9836
10049
|
return _context5.abrupt("return");
|
|
9837
|
-
case
|
|
10050
|
+
case 42:
|
|
9838
10051
|
videoType = videoTrack.type;
|
|
9839
10052
|
audioType = audioTrack.type;
|
|
9840
10053
|
this._fireEvents(videoTrack, audioTrack, metadataTrack);
|
|
9841
|
-
|
|
9842
|
-
|
|
9843
|
-
|
|
10054
|
+
if (!switchingNoReset) {
|
|
10055
|
+
this._discontinuity = false;
|
|
10056
|
+
this._contiguous = true;
|
|
10057
|
+
this._demuxStartTime = 0;
|
|
10058
|
+
}
|
|
9844
10059
|
mse = this._mse;
|
|
9845
10060
|
this.flv.emit(EVENT.DEMUXED_TRACK, {
|
|
9846
10061
|
videoTrack
|
|
@@ -9852,16 +10067,16 @@ var BufferService = /* @__PURE__ */ function() {
|
|
|
9852
10067
|
this._emitMetaParsedEvent(videoTrack, audioTrack);
|
|
9853
10068
|
}
|
|
9854
10069
|
if (!mse) {
|
|
9855
|
-
_context5.next =
|
|
10070
|
+
_context5.next = 80;
|
|
9856
10071
|
break;
|
|
9857
10072
|
}
|
|
9858
10073
|
if (this._sourceCreated) {
|
|
9859
|
-
_context5.next =
|
|
10074
|
+
_context5.next = 58;
|
|
9860
10075
|
break;
|
|
9861
10076
|
}
|
|
9862
|
-
_context5.next =
|
|
10077
|
+
_context5.next = 54;
|
|
9863
10078
|
return mse.open();
|
|
9864
|
-
case
|
|
10079
|
+
case 54:
|
|
9865
10080
|
if (videoExist) {
|
|
9866
10081
|
logger$1.log("codec: video/mp4;codecs=".concat(videoTrack.codec));
|
|
9867
10082
|
mse.createSource(videoType, "video/mp4;codecs=".concat(videoTrack.codec));
|
|
@@ -9872,26 +10087,28 @@ var BufferService = /* @__PURE__ */ function() {
|
|
|
9872
10087
|
}
|
|
9873
10088
|
this._sourceCreated = true;
|
|
9874
10089
|
this.flv.emit(EVENT.SOURCEBUFFER_CREATED);
|
|
9875
|
-
case
|
|
9876
|
-
_context5.prev =
|
|
10090
|
+
case 58:
|
|
10091
|
+
_context5.prev = 58;
|
|
9877
10092
|
if (this._needInitSegment && !this._opts.mseLowLatency) {
|
|
9878
10093
|
videoTrack.duration = this._opts.durationForMSELowLatencyOff * videoTrack.timescale;
|
|
9879
10094
|
audioTrack.duration = this._opts.durationForMSELowLatencyOff * audioExist.timescale;
|
|
9880
10095
|
}
|
|
10096
|
+
this.flv._transferCost.start(TRANSFER_EVENT.REMUX);
|
|
9881
10097
|
remuxResult = this._remuxer.remux(this._needInitSegment);
|
|
9882
|
-
|
|
10098
|
+
this.flv._transferCost.end(TRANSFER_EVENT.REMUX);
|
|
10099
|
+
_context5.next = 68;
|
|
9883
10100
|
break;
|
|
9884
|
-
case
|
|
9885
|
-
_context5.prev =
|
|
9886
|
-
_context5.t1 = _context5["catch"](
|
|
10101
|
+
case 65:
|
|
10102
|
+
_context5.prev = 65;
|
|
10103
|
+
_context5.t1 = _context5["catch"](58);
|
|
9887
10104
|
throw new StreamingError(ERR.REMUX, ERR.SUB_TYPES.FMP4, _context5.t1);
|
|
9888
|
-
case
|
|
10105
|
+
case 68:
|
|
9889
10106
|
if (!(this._needInitSegment && !remuxResult.videoInitSegment && !remuxResult.audioInitSegment)) {
|
|
9890
|
-
_context5.next =
|
|
10107
|
+
_context5.next = 70;
|
|
9891
10108
|
break;
|
|
9892
10109
|
}
|
|
9893
10110
|
return _context5.abrupt("return");
|
|
9894
|
-
case
|
|
10111
|
+
case 70:
|
|
9895
10112
|
this._needInitSegment = false;
|
|
9896
10113
|
p = [];
|
|
9897
10114
|
if (remuxResult.videoInitSegment)
|
|
@@ -9902,16 +10119,19 @@ var BufferService = /* @__PURE__ */ function() {
|
|
|
9902
10119
|
p.push(mse.append(videoType, remuxResult.videoSegment));
|
|
9903
10120
|
if (remuxResult.audioSegment)
|
|
9904
10121
|
p.push(mse.append(audioType, remuxResult.audioSegment));
|
|
9905
|
-
|
|
9906
|
-
|
|
10122
|
+
this.flv._transferCost.start(TRANSFER_EVENT.APPEND);
|
|
10123
|
+
return _context5.abrupt("return", Promise.all(p).then(function() {
|
|
10124
|
+
_this.flv._transferCost.end(TRANSFER_EVENT.APPEND);
|
|
10125
|
+
}));
|
|
10126
|
+
case 80:
|
|
9907
10127
|
if (this._softVideo) {
|
|
9908
10128
|
this._softVideo.appendBuffer(videoTrack, audioTrack);
|
|
9909
10129
|
}
|
|
9910
|
-
case
|
|
10130
|
+
case 81:
|
|
9911
10131
|
case "end":
|
|
9912
10132
|
return _context5.stop();
|
|
9913
10133
|
}
|
|
9914
|
-
}, _callee5, this, [[
|
|
10134
|
+
}, _callee5, this, [[5, 12], [58, 65]]);
|
|
9915
10135
|
}));
|
|
9916
10136
|
function appendBuffer(_x2) {
|
|
9917
10137
|
return _appendBuffer.apply(this, arguments);
|
|
@@ -9922,7 +10142,7 @@ var BufferService = /* @__PURE__ */ function() {
|
|
|
9922
10142
|
key: "evictBuffer",
|
|
9923
10143
|
value: function() {
|
|
9924
10144
|
var _evictBuffer = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee6(bufferBehind) {
|
|
9925
|
-
var
|
|
10145
|
+
var _this2 = this;
|
|
9926
10146
|
var media, currentTime, removeEnd, start;
|
|
9927
10147
|
return _regeneratorRuntime$1().wrap(function _callee6$(_context6) {
|
|
9928
10148
|
while (1)
|
|
@@ -9951,7 +10171,7 @@ var BufferService = /* @__PURE__ */ function() {
|
|
|
9951
10171
|
return _context6.abrupt("return");
|
|
9952
10172
|
case 10:
|
|
9953
10173
|
return _context6.abrupt("return", this._mse.clearBuffer(0, removeEnd).then(function() {
|
|
9954
|
-
return
|
|
10174
|
+
return _this2.flv.emit(EVENT.REMOVE_BUFFER, {
|
|
9955
10175
|
removeEnd
|
|
9956
10176
|
});
|
|
9957
10177
|
}));
|
|
@@ -10001,16 +10221,16 @@ var BufferService = /* @__PURE__ */ function() {
|
|
|
10001
10221
|
}, {
|
|
10002
10222
|
key: "_fireEvents",
|
|
10003
10223
|
value: function _fireEvents(videoTrack, audioTrack, metadataTrack) {
|
|
10004
|
-
var
|
|
10224
|
+
var _this3 = this;
|
|
10005
10225
|
logger$1.debug(videoTrack.samples, audioTrack.samples);
|
|
10006
10226
|
metadataTrack.flvScriptSamples.forEach(function(sample) {
|
|
10007
|
-
|
|
10227
|
+
_this3.flv.emit(EVENT.FLV_SCRIPT_DATA, sample);
|
|
10008
10228
|
logger$1.debug("flvScriptData", sample);
|
|
10009
10229
|
});
|
|
10010
10230
|
videoTrack.samples.forEach(function(sample) {
|
|
10011
10231
|
if (sample.keyframe) {
|
|
10012
|
-
|
|
10013
|
-
pts: sample.
|
|
10232
|
+
_this3.flv.emit(EVENT.KEYFRAME, {
|
|
10233
|
+
pts: sample.originPts
|
|
10014
10234
|
});
|
|
10015
10235
|
}
|
|
10016
10236
|
});
|
|
@@ -10028,7 +10248,7 @@ var BufferService = /* @__PURE__ */ function() {
|
|
|
10028
10248
|
break;
|
|
10029
10249
|
}
|
|
10030
10250
|
if (type)
|
|
10031
|
-
|
|
10251
|
+
_this3.flv.emit(EVENT.STREAM_EXCEPTION, _objectSpread2$2(_objectSpread2$2({}, warn), {}, {
|
|
10032
10252
|
type
|
|
10033
10253
|
}));
|
|
10034
10254
|
logger$1.warn("video exception", warn);
|
|
@@ -10047,13 +10267,13 @@ var BufferService = /* @__PURE__ */ function() {
|
|
|
10047
10267
|
break;
|
|
10048
10268
|
}
|
|
10049
10269
|
if (type)
|
|
10050
|
-
|
|
10270
|
+
_this3.flv.emit(EVENT.STREAM_EXCEPTION, _objectSpread2$2(_objectSpread2$2({}, warn), {}, {
|
|
10051
10271
|
type
|
|
10052
10272
|
}));
|
|
10053
10273
|
logger$1.warn("audio exception", warn);
|
|
10054
10274
|
});
|
|
10055
10275
|
metadataTrack.seiSamples.forEach(function(sei) {
|
|
10056
|
-
|
|
10276
|
+
_this3.flv.emit(EVENT.SEI, _objectSpread2$2(_objectSpread2$2({}, sei), {}, {
|
|
10057
10277
|
sei: {
|
|
10058
10278
|
code: sei.data.type,
|
|
10059
10279
|
content: sei.data.payload,
|
|
@@ -10088,7 +10308,8 @@ function getOption(opts) {
|
|
|
10088
10308
|
durationForMSELowLatencyOff: 6,
|
|
10089
10309
|
chunkCountForSpeed: 50,
|
|
10090
10310
|
skipChunkSize: 1e3,
|
|
10091
|
-
longtimeNoReceived: 3e3
|
|
10311
|
+
longtimeNoReceived: 3e3,
|
|
10312
|
+
enableStartGapJump: true
|
|
10092
10313
|
}, opts);
|
|
10093
10314
|
if (ret.isLive) {
|
|
10094
10315
|
if (ret.preloadTime) {
|
|
@@ -10156,7 +10377,7 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
10156
10377
|
_defineProperty$3(_assertThisInitialized$3(_this), "_acceptRanges", true);
|
|
10157
10378
|
_defineProperty$3(_assertThisInitialized$3(_this), "_onProgress", /* @__PURE__ */ function() {
|
|
10158
10379
|
var _ref2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee(chunk, done, _ref, response) {
|
|
10159
|
-
var startTime, endTime, st, firstByteTime, _this$_mediaLoader, headers, _this$_bufferService, remaining, maxReaderInterval;
|
|
10380
|
+
var startTime, endTime, st, firstByteTime, _this$_mediaLoader, headers, elapsed, _this$_bufferService, remaining, maxReaderInterval;
|
|
10160
10381
|
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
10161
10382
|
while (1)
|
|
10162
10383
|
switch (_context.prev = _context.next) {
|
|
@@ -10164,7 +10385,7 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
10164
10385
|
startTime = _ref.startTime, endTime = _ref.endTime, st = _ref.st, firstByteTime = _ref.firstByteTime;
|
|
10165
10386
|
_this._loading = !done;
|
|
10166
10387
|
if (_this._firstProgressEmit) {
|
|
10167
|
-
_context.next =
|
|
10388
|
+
_context.next = 13;
|
|
10168
10389
|
break;
|
|
10169
10390
|
}
|
|
10170
10391
|
if (_this.media) {
|
|
@@ -10175,49 +10396,51 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
10175
10396
|
return _context.abrupt("return");
|
|
10176
10397
|
case 6:
|
|
10177
10398
|
headers = response.headers;
|
|
10399
|
+
elapsed = st ? firstByteTime - st : endTime - startTime;
|
|
10178
10400
|
_this.emit(EVENT.TTFB, {
|
|
10179
10401
|
url: _this._opts.url,
|
|
10180
10402
|
responseUrl: response.url,
|
|
10181
|
-
elapsed
|
|
10403
|
+
elapsed
|
|
10182
10404
|
});
|
|
10183
10405
|
_this.emit(EVENT.LOAD_RESPONSE_HEADERS, {
|
|
10184
10406
|
headers
|
|
10185
10407
|
});
|
|
10408
|
+
_this._transferCost.set(TRANSFER_EVENT.TTFB, elapsed);
|
|
10186
10409
|
_this._acceptRanges = !!(headers !== null && headers !== void 0 && headers.get("Accept-Ranges")) || !!(headers !== null && headers !== void 0 && headers.get("Content-Range"));
|
|
10187
10410
|
_this._firstProgressEmit = true;
|
|
10188
|
-
case
|
|
10411
|
+
case 13:
|
|
10189
10412
|
if (_this._bufferService) {
|
|
10190
|
-
_context.next =
|
|
10413
|
+
_context.next = 15;
|
|
10191
10414
|
break;
|
|
10192
10415
|
}
|
|
10193
10416
|
return _context.abrupt("return");
|
|
10194
|
-
case
|
|
10417
|
+
case 15:
|
|
10195
10418
|
clearTimeout(_this._maxChunkWaitTimer);
|
|
10196
10419
|
_this._bandwidthService.addChunkRecord(chunk === null || chunk === void 0 ? void 0 : chunk.byteLength, endTime - startTime);
|
|
10197
|
-
_context.prev =
|
|
10198
|
-
_context.next =
|
|
10420
|
+
_context.prev = 17;
|
|
10421
|
+
_context.next = 20;
|
|
10199
10422
|
return _this._bufferService.appendBuffer(chunk);
|
|
10200
|
-
case
|
|
10423
|
+
case 20:
|
|
10201
10424
|
(_this$_bufferService = _this._bufferService) === null || _this$_bufferService === void 0 ? void 0 : _this$_bufferService.evictBuffer(_this._opts.bufferBehind);
|
|
10202
|
-
_context.next =
|
|
10425
|
+
_context.next = 33;
|
|
10203
10426
|
break;
|
|
10204
|
-
case
|
|
10205
|
-
_context.prev =
|
|
10206
|
-
_context.t0 = _context["catch"](
|
|
10427
|
+
case 23:
|
|
10428
|
+
_context.prev = 23;
|
|
10429
|
+
_context.t0 = _context["catch"](17);
|
|
10207
10430
|
if (!(!_this.isLive && _this._bufferService.isFull())) {
|
|
10208
|
-
_context.next =
|
|
10431
|
+
_context.next = 32;
|
|
10209
10432
|
break;
|
|
10210
10433
|
}
|
|
10211
|
-
_context.next =
|
|
10434
|
+
_context.next = 28;
|
|
10212
10435
|
return _this._mediaLoader.cancel();
|
|
10213
|
-
case
|
|
10436
|
+
case 28:
|
|
10214
10437
|
_this._loading = false;
|
|
10215
10438
|
remaining = _this.bufferInfo().remaining;
|
|
10216
10439
|
_this._opts.preloadTime = parseInt(remaining) / 2;
|
|
10217
10440
|
return _context.abrupt("return");
|
|
10218
|
-
case
|
|
10441
|
+
case 32:
|
|
10219
10442
|
return _context.abrupt("return", _this._emitError(StreamingError.create(_context.t0)));
|
|
10220
|
-
case
|
|
10443
|
+
case 33:
|
|
10221
10444
|
if (_this._urlSwitching) {
|
|
10222
10445
|
_this._urlSwitching = false;
|
|
10223
10446
|
_this.emit(EVENT.SWITCH_URL_SUCCESS, {
|
|
@@ -10229,7 +10452,7 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
10229
10452
|
_this._tick();
|
|
10230
10453
|
}
|
|
10231
10454
|
if (!(done && !_this.media.seeking)) {
|
|
10232
|
-
_context.next =
|
|
10455
|
+
_context.next = 40;
|
|
10233
10456
|
break;
|
|
10234
10457
|
}
|
|
10235
10458
|
_this.emit(EVENT.LOAD_COMPLETE);
|
|
@@ -10238,13 +10461,13 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
10238
10461
|
_this._end();
|
|
10239
10462
|
}
|
|
10240
10463
|
return _context.abrupt("return");
|
|
10241
|
-
case
|
|
10464
|
+
case 40:
|
|
10242
10465
|
if (_this.isLive) {
|
|
10243
|
-
_context.next =
|
|
10466
|
+
_context.next = 42;
|
|
10244
10467
|
break;
|
|
10245
10468
|
}
|
|
10246
10469
|
return _context.abrupt("return");
|
|
10247
|
-
case
|
|
10470
|
+
case 42:
|
|
10248
10471
|
maxReaderInterval = _this._opts.maxReaderInterval;
|
|
10249
10472
|
if (maxReaderInterval && _this._firstProgressEmit) {
|
|
10250
10473
|
clearTimeout(_this._maxChunkWaitTimer);
|
|
@@ -10258,11 +10481,11 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
10258
10481
|
_this._end();
|
|
10259
10482
|
}, maxReaderInterval);
|
|
10260
10483
|
}
|
|
10261
|
-
case
|
|
10484
|
+
case 44:
|
|
10262
10485
|
case "end":
|
|
10263
10486
|
return _context.stop();
|
|
10264
10487
|
}
|
|
10265
|
-
}, _callee, null, [[
|
|
10488
|
+
}, _callee, null, [[17, 23]]);
|
|
10266
10489
|
}));
|
|
10267
10490
|
return function(_x, _x2, _x3, _x4) {
|
|
10268
10491
|
return _ref2.apply(this, arguments);
|
|
@@ -10295,19 +10518,19 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
10295
10518
|
if (bufferEnd < MAX_HOLE || !media.readyState)
|
|
10296
10519
|
return;
|
|
10297
10520
|
var opts = _this._opts;
|
|
10298
|
-
if (isMediaPlaying(media)) {
|
|
10521
|
+
if (isMediaPlaying(media) && media.currentTime) {
|
|
10299
10522
|
if (_this._gapService) {
|
|
10300
10523
|
_this._gapService.do(media, opts.maxJumpDistance, _this.isLive, 3);
|
|
10301
10524
|
}
|
|
10302
10525
|
} else {
|
|
10303
|
-
if (!media.currentTime && _this._gapService) {
|
|
10526
|
+
if (!media.currentTime && _this._gapService && opts.enableStartGapJump) {
|
|
10304
10527
|
var gapJump = _this._opts.mseLowLatency || _this._opts.mseLowLatency === false && _this.bufferInfo(MAX_START_GAP).nextStart;
|
|
10305
10528
|
if (gapJump) {
|
|
10306
10529
|
_this._gapService.do(media, opts.maxJumpDistance, _this.isLive, 3);
|
|
10307
10530
|
}
|
|
10308
10531
|
return;
|
|
10309
10532
|
}
|
|
10310
|
-
if (opts.isLive && media.readyState === 4 && bufferEnd > opts.disconnectTime) {
|
|
10533
|
+
if (opts.isLive && media.readyState === 4 && bufferEnd - media.currentTime > opts.disconnectTime) {
|
|
10311
10534
|
_this.disconnect();
|
|
10312
10535
|
}
|
|
10313
10536
|
}
|
|
@@ -10456,6 +10679,7 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
10456
10679
|
responseType: "arraybuffer"
|
|
10457
10680
|
}));
|
|
10458
10681
|
_this._disconnectRetryCount = _this._opts.disconnectRetryCount;
|
|
10682
|
+
_this._transferCost = new TransferCost();
|
|
10459
10683
|
_this._bufferService = new BufferService(_assertThisInitialized$3(_this), _this._opts.softDecode ? _this.media : void 0, _this._opts);
|
|
10460
10684
|
_this._seiService = new SeiService(_assertThisInitialized$3(_this));
|
|
10461
10685
|
_this._bandwidthService = new BandwidthService({
|
|
@@ -10479,7 +10703,7 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
10479
10703
|
_createClass$4(Flv2, [{
|
|
10480
10704
|
key: "version",
|
|
10481
10705
|
get: function get() {
|
|
10482
|
-
return "3.0.
|
|
10706
|
+
return "3.0.20-rc.3";
|
|
10483
10707
|
}
|
|
10484
10708
|
}, {
|
|
10485
10709
|
key: "isLive",
|
|
@@ -10595,9 +10819,9 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
10595
10819
|
return this._clear();
|
|
10596
10820
|
case 8:
|
|
10597
10821
|
setTimeout(function() {
|
|
10822
|
+
_this2._seamlessSwitching = true;
|
|
10598
10823
|
_this2._loadData(_this2._opts.url);
|
|
10599
10824
|
_this2._bufferService.seamlessSwitch();
|
|
10600
|
-
_this2._seamlessSwitching = true;
|
|
10601
10825
|
});
|
|
10602
10826
|
_context5.next = 13;
|
|
10603
10827
|
break;
|
|
@@ -10621,50 +10845,82 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
10621
10845
|
}, {
|
|
10622
10846
|
key: "disconnect",
|
|
10623
10847
|
value: function disconnect() {
|
|
10848
|
+
var _this$_bufferService4;
|
|
10624
10849
|
logger.debug("disconnect!");
|
|
10850
|
+
(_this$_bufferService4 = this._bufferService) === null || _this$_bufferService4 === void 0 ? void 0 : _this$_bufferService4.resetSeamlessSwitchStats();
|
|
10625
10851
|
return this._clear();
|
|
10626
10852
|
}
|
|
10627
10853
|
}, {
|
|
10628
10854
|
key: "switchURL",
|
|
10629
10855
|
value: function() {
|
|
10630
|
-
var _switchURL = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function
|
|
10856
|
+
var _switchURL = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee7(url, seamless) {
|
|
10631
10857
|
var _this3 = this;
|
|
10632
|
-
return _regeneratorRuntime$1().wrap(function
|
|
10858
|
+
return _regeneratorRuntime$1().wrap(function _callee7$(_context7) {
|
|
10633
10859
|
while (1)
|
|
10634
|
-
switch (
|
|
10860
|
+
switch (_context7.prev = _context7.next) {
|
|
10635
10861
|
case 0:
|
|
10636
10862
|
if (this._bufferService) {
|
|
10637
|
-
|
|
10863
|
+
_context7.next = 2;
|
|
10638
10864
|
break;
|
|
10639
10865
|
}
|
|
10640
|
-
return
|
|
10866
|
+
return _context7.abrupt("return");
|
|
10641
10867
|
case 2:
|
|
10642
10868
|
this._resetDisconnectCount();
|
|
10869
|
+
if (!(this._loading && seamless)) {
|
|
10870
|
+
_context7.next = 6;
|
|
10871
|
+
break;
|
|
10872
|
+
}
|
|
10873
|
+
this._bufferService.seamlessLoadingSwitch = /* @__PURE__ */ function() {
|
|
10874
|
+
var _ref5 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee6(pts) {
|
|
10875
|
+
return _regeneratorRuntime$1().wrap(function _callee6$(_context6) {
|
|
10876
|
+
while (1)
|
|
10877
|
+
switch (_context6.prev = _context6.next) {
|
|
10878
|
+
case 0:
|
|
10879
|
+
_context6.next = 2;
|
|
10880
|
+
return _this3._clear();
|
|
10881
|
+
case 2:
|
|
10882
|
+
_this3._bufferService.seamlessLoadingSwitching = true;
|
|
10883
|
+
_this3._urlSwitching = true;
|
|
10884
|
+
_this3._seamlessSwitching = true;
|
|
10885
|
+
_this3._bufferService.seamlessSwitch();
|
|
10886
|
+
_this3._loadData(url);
|
|
10887
|
+
case 7:
|
|
10888
|
+
case "end":
|
|
10889
|
+
return _context6.stop();
|
|
10890
|
+
}
|
|
10891
|
+
}, _callee6);
|
|
10892
|
+
}));
|
|
10893
|
+
return function(_x8) {
|
|
10894
|
+
return _ref5.apply(this, arguments);
|
|
10895
|
+
};
|
|
10896
|
+
}();
|
|
10897
|
+
return _context7.abrupt("return");
|
|
10898
|
+
case 6:
|
|
10643
10899
|
if (!(!seamless || !this._opts.isLive)) {
|
|
10644
|
-
|
|
10900
|
+
_context7.next = 11;
|
|
10645
10901
|
break;
|
|
10646
10902
|
}
|
|
10647
|
-
|
|
10903
|
+
_context7.next = 9;
|
|
10648
10904
|
return this.load(url);
|
|
10649
|
-
case
|
|
10905
|
+
case 9:
|
|
10650
10906
|
this._urlSwitching = true;
|
|
10651
|
-
return
|
|
10907
|
+
return _context7.abrupt("return", this.media.play(true).catch(function() {
|
|
10652
10908
|
}));
|
|
10653
|
-
case
|
|
10654
|
-
|
|
10909
|
+
case 11:
|
|
10910
|
+
_context7.next = 13;
|
|
10655
10911
|
return this._clear();
|
|
10656
|
-
case
|
|
10912
|
+
case 13:
|
|
10657
10913
|
setTimeout(function() {
|
|
10658
10914
|
_this3._urlSwitching = true;
|
|
10659
10915
|
_this3._seamlessSwitching = true;
|
|
10660
10916
|
_this3._loadData(url);
|
|
10661
10917
|
_this3._bufferService.seamlessSwitch();
|
|
10662
10918
|
});
|
|
10663
|
-
case
|
|
10919
|
+
case 14:
|
|
10664
10920
|
case "end":
|
|
10665
|
-
return
|
|
10921
|
+
return _context7.stop();
|
|
10666
10922
|
}
|
|
10667
|
-
},
|
|
10923
|
+
}, _callee7, this);
|
|
10668
10924
|
}));
|
|
10669
10925
|
function switchURL(_x6, _x7) {
|
|
10670
10926
|
return _switchURL.apply(this, arguments);
|
|
@@ -10674,16 +10930,16 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
10674
10930
|
}, {
|
|
10675
10931
|
key: "destroy",
|
|
10676
10932
|
value: function() {
|
|
10677
|
-
var _destroy = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function
|
|
10678
|
-
return _regeneratorRuntime$1().wrap(function
|
|
10933
|
+
var _destroy = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee8() {
|
|
10934
|
+
return _regeneratorRuntime$1().wrap(function _callee8$(_context8) {
|
|
10679
10935
|
while (1)
|
|
10680
|
-
switch (
|
|
10936
|
+
switch (_context8.prev = _context8.next) {
|
|
10681
10937
|
case 0:
|
|
10682
10938
|
if (this.media) {
|
|
10683
|
-
|
|
10939
|
+
_context8.next = 2;
|
|
10684
10940
|
break;
|
|
10685
10941
|
}
|
|
10686
|
-
return
|
|
10942
|
+
return _context8.abrupt("return");
|
|
10687
10943
|
case 2:
|
|
10688
10944
|
this.removeAllListeners();
|
|
10689
10945
|
this._seiService.reset();
|
|
@@ -10693,16 +10949,16 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
10693
10949
|
this.media.removeEventListener("timeupdate", this._onTimeupdate);
|
|
10694
10950
|
this.media.removeEventListener("waiting", this._onWaiting);
|
|
10695
10951
|
this.media.removeEventListener("progress", this._onBufferUpdate);
|
|
10696
|
-
|
|
10952
|
+
_context8.next = 12;
|
|
10697
10953
|
return Promise.all([this._clear(), this._bufferService.destroy()]);
|
|
10698
10954
|
case 12:
|
|
10699
10955
|
this.media = null;
|
|
10700
10956
|
this._bufferService = null;
|
|
10701
10957
|
case 14:
|
|
10702
10958
|
case "end":
|
|
10703
|
-
return
|
|
10959
|
+
return _context8.stop();
|
|
10704
10960
|
}
|
|
10705
|
-
},
|
|
10961
|
+
}, _callee8, this);
|
|
10706
10962
|
}));
|
|
10707
10963
|
function destroy() {
|
|
10708
10964
|
return _destroy.apply(this, arguments);
|
|
@@ -10731,26 +10987,26 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
10731
10987
|
}, {
|
|
10732
10988
|
key: "_reset",
|
|
10733
10989
|
value: function() {
|
|
10734
|
-
var _reset2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function
|
|
10735
|
-
var reuseMse,
|
|
10736
|
-
return _regeneratorRuntime$1().wrap(function
|
|
10990
|
+
var _reset2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee9() {
|
|
10991
|
+
var reuseMse, _args9 = arguments;
|
|
10992
|
+
return _regeneratorRuntime$1().wrap(function _callee9$(_context9) {
|
|
10737
10993
|
while (1)
|
|
10738
|
-
switch (
|
|
10994
|
+
switch (_context9.prev = _context9.next) {
|
|
10739
10995
|
case 0:
|
|
10740
|
-
reuseMse =
|
|
10996
|
+
reuseMse = _args9.length > 0 && _args9[0] !== void 0 ? _args9[0] : false;
|
|
10741
10997
|
this._seiService.reset();
|
|
10742
10998
|
this._bandwidthService.reset();
|
|
10743
10999
|
this._stats.reset();
|
|
10744
|
-
|
|
11000
|
+
_context9.next = 6;
|
|
10745
11001
|
return this._clear();
|
|
10746
11002
|
case 6:
|
|
10747
|
-
|
|
11003
|
+
_context9.next = 8;
|
|
10748
11004
|
return this._bufferService.reset(reuseMse);
|
|
10749
11005
|
case 8:
|
|
10750
11006
|
case "end":
|
|
10751
|
-
return
|
|
11007
|
+
return _context9.stop();
|
|
10752
11008
|
}
|
|
10753
|
-
},
|
|
11009
|
+
}, _callee9, this);
|
|
10754
11010
|
}));
|
|
10755
11011
|
function _reset() {
|
|
10756
11012
|
return _reset2.apply(this, arguments);
|
|
@@ -10760,17 +11016,17 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
10760
11016
|
}, {
|
|
10761
11017
|
key: "_loadData",
|
|
10762
11018
|
value: function() {
|
|
10763
|
-
var _loadData2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function
|
|
11019
|
+
var _loadData2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee10(url, range) {
|
|
10764
11020
|
var finnalUrl;
|
|
10765
|
-
return _regeneratorRuntime$1().wrap(function
|
|
11021
|
+
return _regeneratorRuntime$1().wrap(function _callee10$(_context10) {
|
|
10766
11022
|
while (1)
|
|
10767
|
-
switch (
|
|
11023
|
+
switch (_context10.prev = _context10.next) {
|
|
10768
11024
|
case 0:
|
|
10769
11025
|
if (url)
|
|
10770
11026
|
this._opts.url = url;
|
|
10771
11027
|
finnalUrl = url = this._opts.url;
|
|
10772
11028
|
if (url) {
|
|
10773
|
-
|
|
11029
|
+
_context10.next = 4;
|
|
10774
11030
|
break;
|
|
10775
11031
|
}
|
|
10776
11032
|
throw new Error("Source url is missing");
|
|
@@ -10785,34 +11041,34 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
10785
11041
|
});
|
|
10786
11042
|
logger.debug("load data, loading:", this._loading, finnalUrl);
|
|
10787
11043
|
if (!this._loading) {
|
|
10788
|
-
|
|
11044
|
+
_context10.next = 11;
|
|
10789
11045
|
break;
|
|
10790
11046
|
}
|
|
10791
|
-
|
|
11047
|
+
_context10.next = 11;
|
|
10792
11048
|
return this._mediaLoader.cancel();
|
|
10793
11049
|
case 11:
|
|
10794
11050
|
this._loading = true;
|
|
10795
|
-
|
|
10796
|
-
|
|
11051
|
+
_context10.prev = 12;
|
|
11052
|
+
_context10.next = 15;
|
|
10797
11053
|
return this._mediaLoader.load({
|
|
10798
11054
|
url: finnalUrl,
|
|
10799
11055
|
range
|
|
10800
11056
|
});
|
|
10801
11057
|
case 15:
|
|
10802
|
-
|
|
11058
|
+
_context10.next = 21;
|
|
10803
11059
|
break;
|
|
10804
11060
|
case 17:
|
|
10805
|
-
|
|
10806
|
-
|
|
11061
|
+
_context10.prev = 17;
|
|
11062
|
+
_context10.t0 = _context10["catch"](12);
|
|
10807
11063
|
this._loading = false;
|
|
10808
|
-
return
|
|
11064
|
+
return _context10.abrupt("return", this._emitError(StreamingError.network(_context10.t0), false));
|
|
10809
11065
|
case 21:
|
|
10810
11066
|
case "end":
|
|
10811
|
-
return
|
|
11067
|
+
return _context10.stop();
|
|
10812
11068
|
}
|
|
10813
|
-
},
|
|
11069
|
+
}, _callee10, this, [[12, 17]]);
|
|
10814
11070
|
}));
|
|
10815
|
-
function _loadData(
|
|
11071
|
+
function _loadData(_x9, _x10) {
|
|
10816
11072
|
return _loadData2.apply(this, arguments);
|
|
10817
11073
|
}
|
|
10818
11074
|
return _loadData;
|
|
@@ -10820,16 +11076,16 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
10820
11076
|
}, {
|
|
10821
11077
|
key: "_clear",
|
|
10822
11078
|
value: function() {
|
|
10823
|
-
var _clear2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function
|
|
10824
|
-
return _regeneratorRuntime$1().wrap(function
|
|
11079
|
+
var _clear2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee11() {
|
|
11080
|
+
return _regeneratorRuntime$1().wrap(function _callee11$(_context11) {
|
|
10825
11081
|
while (1)
|
|
10826
|
-
switch (
|
|
11082
|
+
switch (_context11.prev = _context11.next) {
|
|
10827
11083
|
case 0:
|
|
10828
11084
|
if (!this._mediaLoader) {
|
|
10829
|
-
|
|
11085
|
+
_context11.next = 3;
|
|
10830
11086
|
break;
|
|
10831
11087
|
}
|
|
10832
|
-
|
|
11088
|
+
_context11.next = 3;
|
|
10833
11089
|
return this._mediaLoader.cancel();
|
|
10834
11090
|
case 3:
|
|
10835
11091
|
clearTimeout(this._maxChunkWaitTimer);
|
|
@@ -10838,9 +11094,9 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
10838
11094
|
this._firstProgressEmit = false;
|
|
10839
11095
|
case 7:
|
|
10840
11096
|
case "end":
|
|
10841
|
-
return
|
|
11097
|
+
return _context11.stop();
|
|
10842
11098
|
}
|
|
10843
|
-
},
|
|
11099
|
+
}, _callee11, this);
|
|
10844
11100
|
}));
|
|
10845
11101
|
function _clear() {
|
|
10846
11102
|
return _clear2.apply(this, arguments);
|
|
@@ -11034,6 +11290,11 @@ var FlvPlugin = /* @__PURE__ */ function(_BasePlugin) {
|
|
|
11034
11290
|
var _this$flv3;
|
|
11035
11291
|
return (_this$flv3 = this.flv) === null || _this$flv3 === void 0 ? void 0 : _this$flv3.loader;
|
|
11036
11292
|
}
|
|
11293
|
+
}, {
|
|
11294
|
+
key: "transferCost",
|
|
11295
|
+
get: function get() {
|
|
11296
|
+
return this.flv._transferCost.transferCost;
|
|
11297
|
+
}
|
|
11037
11298
|
}, {
|
|
11038
11299
|
key: "beforePlayerInit",
|
|
11039
11300
|
value: function beforePlayerInit() {
|
|
@@ -11053,8 +11314,8 @@ var FlvPlugin = /* @__PURE__ */ function(_BasePlugin) {
|
|
|
11053
11314
|
isLive: config.isLive,
|
|
11054
11315
|
media: this.player.video,
|
|
11055
11316
|
preProcessUrl: function preProcessUrl(url, ext) {
|
|
11056
|
-
var _this2$player
|
|
11057
|
-
return ((_this2$player
|
|
11317
|
+
var _this2$player, _this2$player$preProc;
|
|
11318
|
+
return ((_this2$player = _this2.player) === null || _this2$player === void 0 ? void 0 : (_this2$player$preProc = _this2$player.preProcessUrl) === null || _this2$player$preProc === void 0 ? void 0 : _this2$player$preProc.call(_this2$player, url, ext)) || {
|
|
11058
11319
|
url,
|
|
11059
11320
|
ext
|
|
11060
11321
|
};
|