@volcengine/veplayer-plugin 2.4.3-rc.0 → 2.4.5-rc.0

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.
Files changed (31) hide show
  1. package/esm/index.development.js +499 -1891
  2. package/esm/index.production.js +1 -1
  3. package/esm/veplayer.plugin.abr.development.js +3 -71
  4. package/esm/veplayer.plugin.abr.production.js +1 -1
  5. package/esm/veplayer.plugin.drm.development.js +3 -71
  6. package/esm/veplayer.plugin.drm.production.js +1 -1
  7. package/esm/veplayer.plugin.flv.development.js +196 -727
  8. package/esm/veplayer.plugin.flv.production.js +1 -1
  9. package/esm/veplayer.plugin.hls.development.js +304 -1233
  10. package/esm/veplayer.plugin.hls.production.js +1 -1
  11. package/esm/veplayer.plugin.mp4.development.js +5 -73
  12. package/esm/veplayer.plugin.mp4.production.js +1 -1
  13. package/esm/veplayer.plugin.rtm.development.js +4 -72
  14. package/esm/veplayer.plugin.rtm.production.js +1 -1
  15. package/esm/veplayer.plugin.shaka.development.js +4 -72
  16. package/esm/veplayer.plugin.shaka.production.js +1 -1
  17. package/package.json +1 -1
  18. package/umd/veplayer.plugin.abr.development.js +3 -71
  19. package/umd/veplayer.plugin.abr.production.js +1 -1
  20. package/umd/veplayer.plugin.drm.development.js +3 -71
  21. package/umd/veplayer.plugin.drm.production.js +1 -1
  22. package/umd/veplayer.plugin.flv.development.js +196 -727
  23. package/umd/veplayer.plugin.flv.production.js +1 -1
  24. package/umd/veplayer.plugin.hls.development.js +304 -1233
  25. package/umd/veplayer.plugin.hls.production.js +1 -1
  26. package/umd/veplayer.plugin.mp4.development.js +5 -73
  27. package/umd/veplayer.plugin.mp4.production.js +1 -1
  28. package/umd/veplayer.plugin.rtm.development.js +4 -72
  29. package/umd/veplayer.plugin.rtm.production.js +1 -1
  30. package/umd/veplayer.plugin.shaka.development.js +4 -72
  31. 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.20-rc.6";
1541
+ var version = "3.0.19-rc.0";
1542
1542
  var ERROR_MAP = {
1543
1543
  1: 5101,
1544
1544
  2: 5102,
@@ -1646,7 +1646,8 @@ function hook(hookName, handler) {
1646
1646
  }
1647
1647
  if (this.__hooks && this.__hooks[hookName]) {
1648
1648
  try {
1649
- var preRet = runHooks(this, hookName, handler);
1649
+ var _this$__hooks$hookNam;
1650
+ var preRet = (_this$__hooks$hookNam = this.__hooks[hookName]).call.apply(_this$__hooks$hookNam, [this, this].concat(Array.prototype.slice.call(arguments)));
1650
1651
  if (preRet) {
1651
1652
  if (preRet.then) {
1652
1653
  preRet.then(function(isContinue) {
@@ -1671,19 +1672,6 @@ function hook(hookName, handler) {
1671
1672
  }
1672
1673
  }.bind(this);
1673
1674
  }
1674
- function findHookIndex(hookName, handler) {
1675
- var __hooks = this.__hooks;
1676
- if (!__hooks || !Array.isArray(__hooks[hookName])) {
1677
- return -1;
1678
- }
1679
- var hookHandlers = __hooks[hookName];
1680
- for (var i = 0; i < hookHandlers.length; i++) {
1681
- if (hookHandlers[i] === handler) {
1682
- return i;
1683
- }
1684
- }
1685
- return -1;
1686
- }
1687
1675
  function useHooks(hookName, handler) {
1688
1676
  var __hooks = this.__hooks;
1689
1677
  if (!__hooks) {
@@ -1693,12 +1681,7 @@ function useHooks(hookName, handler) {
1693
1681
  console.warn("has no supported hook which name [".concat(hookName, "]"));
1694
1682
  return false;
1695
1683
  }
1696
- if (!Array.isArray(__hooks[hookName])) {
1697
- __hooks[hookName] = [];
1698
- }
1699
- if (findHookIndex.call(this, hookName, handler) === -1) {
1700
- __hooks[hookName].push(handler);
1701
- }
1684
+ __hooks && (__hooks[hookName] = handler);
1702
1685
  return true;
1703
1686
  }
1704
1687
  function removeHooks(hookName, handler) {
@@ -1706,13 +1689,6 @@ function removeHooks(hookName, handler) {
1706
1689
  if (!__hooks) {
1707
1690
  return;
1708
1691
  }
1709
- if (Array.isArray(__hooks[hookName])) {
1710
- var hooks = __hooks[hookName];
1711
- var index = findHookIndex.call(this, hookName, handler);
1712
- if (index !== -1) {
1713
- hooks.splice(index, 1);
1714
- }
1715
- }
1716
1692
  delete __hooks[hookName];
1717
1693
  }
1718
1694
  function hooksDescriptor(instance) {
@@ -1734,38 +1710,6 @@ function hooksDescriptor(instance) {
1734
1710
  function delHooksDescriptor(instance) {
1735
1711
  instance.__hooks = null;
1736
1712
  }
1737
- function runHooks(obj, hookName, handler) {
1738
- for (var _len5 = arguments.length, args = new Array(_len5 > 3 ? _len5 - 3 : 0), _key5 = 3; _key5 < _len5; _key5++) {
1739
- args[_key5 - 3] = arguments[_key5];
1740
- }
1741
- if (obj.__hooks && Array.isArray(obj.__hooks[hookName])) {
1742
- var hooks = obj.__hooks[hookName];
1743
- var index = -1;
1744
- var runHooksRecursive = function runHooksRecursive2(obj2, hookName2, handler2) {
1745
- for (var _len6 = arguments.length, args2 = new Array(_len6 > 3 ? _len6 - 3 : 0), _key6 = 3; _key6 < _len6; _key6++) {
1746
- args2[_key6 - 3] = arguments[_key6];
1747
- }
1748
- index++;
1749
- if (hooks.length === 0 || index === hooks.length) {
1750
- return handler2.call.apply(handler2, [obj2, obj2].concat(args2));
1751
- }
1752
- var hook2 = hooks[index];
1753
- var ret = hook2.call.apply(hook2, [obj2, obj2].concat(args2));
1754
- if (ret && ret.then) {
1755
- return ret.then(function(data) {
1756
- return data === false ? null : runHooksRecursive2.apply(void 0, [obj2, hookName2, handler2].concat(args2));
1757
- }).catch(function(e) {
1758
- console.warn("[runHooks]".concat(hookName2, " reject"), e.message);
1759
- });
1760
- } else if (ret !== false) {
1761
- return runHooksRecursive2.apply(void 0, [obj2, hookName2, handler2].concat(args2));
1762
- }
1763
- };
1764
- return runHooksRecursive.apply(void 0, [obj, hookName, handler].concat(args));
1765
- } else {
1766
- return handler.call.apply(handler, [obj, obj].concat(args));
1767
- }
1768
- }
1769
1713
  function showErrorMsg(pluginName, msg) {
1770
1714
  XG_DEBUG.logError("[".concat(pluginName, "] event or callback cant be undefined or null when call ").concat(msg));
1771
1715
  }
@@ -2005,18 +1949,6 @@ var BasePlugin = /* @__PURE__ */ function() {
2005
1949
  }
2006
1950
  }
2007
1951
  }
2008
- }, {
2009
- key: "defineMethod",
2010
- value: function defineMethod(Obj, map) {
2011
- for (var key in map) {
2012
- if (Object.prototype.hasOwnProperty.call(map, key) && typeof map[key] === "function") {
2013
- Object.defineProperty(Obj, key, {
2014
- configurable: true,
2015
- value: map[key]
2016
- });
2017
- }
2018
- }
2019
- }
2020
1952
  }, {
2021
1953
  key: "defaultConfig",
2022
1954
  get: function get() {
@@ -2827,21 +2759,6 @@ var Buffer$1 = /* @__PURE__ */ function() {
2827
2759
  length: Buffer2.totalLength && Buffer2.totalLength(buffers)
2828
2760
  };
2829
2761
  }
2830
- }, {
2831
- key: "isBuffered",
2832
- value: function isBuffered(media, pos) {
2833
- if (media) {
2834
- var buffered = Buffer2.get(media);
2835
- if (buffered !== null && buffered !== void 0 && buffered.length) {
2836
- for (var i = 0; i < buffered.length; i++) {
2837
- if (pos >= buffered.start(i) && pos <= buffered.end(i)) {
2838
- return true;
2839
- }
2840
- }
2841
- }
2842
- }
2843
- return false;
2844
- }
2845
2762
  }]);
2846
2763
  return Buffer2;
2847
2764
  }();
@@ -2994,7 +2911,7 @@ var Logger$2 = /* @__PURE__ */ function() {
2994
2911
  this.logCache.apply(this, [LogCacheLevel.DEBUG].concat(args));
2995
2912
  if (Logger2.disabled)
2996
2913
  return;
2997
- (_console = console).debug.apply(_console, ["[".concat(nowTime$1(), "]"), this._prefix].concat(args));
2914
+ (_console = console).debug.apply(_console, [this._prefix, nowTime$1()].concat(args));
2998
2915
  }
2999
2916
  }, {
3000
2917
  key: "log",
@@ -3006,7 +2923,7 @@ var Logger$2 = /* @__PURE__ */ function() {
3006
2923
  this.logCache.apply(this, [LogCacheLevel.LOG].concat(args));
3007
2924
  if (Logger2.disabled)
3008
2925
  return;
3009
- (_console2 = console).log.apply(_console2, ["[".concat(nowTime$1(), "]"), this._prefix].concat(args));
2926
+ (_console2 = console).log.apply(_console2, [this._prefix, nowTime$1()].concat(args));
3010
2927
  }
3011
2928
  }, {
3012
2929
  key: "warn",
@@ -3018,7 +2935,7 @@ var Logger$2 = /* @__PURE__ */ function() {
3018
2935
  this.logCache.apply(this, [LogCacheLevel.WARN].concat(args));
3019
2936
  if (Logger2.disabled)
3020
2937
  return;
3021
- (_console3 = console).warn.apply(_console3, ["[".concat(nowTime$1(), "]"), this._prefix].concat(args));
2938
+ (_console3 = console).warn.apply(_console3, [this._prefix, nowTime$1()].concat(args));
3022
2939
  }
3023
2940
  }, {
3024
2941
  key: "error",
@@ -3030,7 +2947,7 @@ var Logger$2 = /* @__PURE__ */ function() {
3030
2947
  this.logCache.apply(this, [LogCacheLevel.ERROR].concat(args));
3031
2948
  if (Logger2.disabled)
3032
2949
  return;
3033
- (_console4 = console).error.apply(_console4, ["[".concat(nowTime$1(), "]"), this._prefix].concat(args));
2950
+ (_console4 = console).error.apply(_console4, [this._prefix, nowTime$1()].concat(args));
3034
2951
  }
3035
2952
  }, {
3036
2953
  key: "logCache",
@@ -3045,7 +2962,7 @@ var Logger$2 = /* @__PURE__ */ function() {
3045
2962
  var finLogText = logText.map(function(item) {
3046
2963
  return logable(item);
3047
2964
  });
3048
- text = "[".concat(nowTime$1(), "]") + this._prefix + JSON.stringify(finLogText);
2965
+ text = this._prefix + nowTime$1() + JSON.stringify(finLogText);
3049
2966
  } catch (e) {
3050
2967
  return;
3051
2968
  }
@@ -3961,8 +3878,8 @@ function createResponse(data, done, response, contentLength, age, startTime, fir
3961
3878
  response
3962
3879
  };
3963
3880
  }
3964
- function calculateSpeed(byteLen, milliSecond) {
3965
- return Math.round(byteLen * 8 * 1e3 / milliSecond / 1024);
3881
+ function calculateSpeed(byteLen, millisec) {
3882
+ return Math.round(byteLen * 8 * 1e3 / millisec / 1024);
3966
3883
  }
3967
3884
  var EVENT = {
3968
3885
  ERROR: "error",
@@ -3974,7 +3891,6 @@ var EVENT = {
3974
3891
  SOURCEBUFFER_CREATED: "core.sourcebuffercreated",
3975
3892
  MEDIASOURCE_OPENED: "core.mediasourceopened",
3976
3893
  ANALYZE_DURATION_EXCEEDED: "core.analyzedurationexceeded",
3977
- APPEND_BUFFER: "core.appendbuffer",
3978
3894
  REMOVE_BUFFER: "core.removebuffer",
3979
3895
  BUFFEREOS: "core.buffereos",
3980
3896
  KEYFRAME: "core.keyframe",
@@ -5607,15 +5523,13 @@ var TrackType = {
5607
5523
  METADATA: "metadata"
5608
5524
  };
5609
5525
  var VideoCodecType = {
5610
- AV1: "av1",
5611
5526
  AVC: "avc",
5612
5527
  HEVC: "hevc"
5613
5528
  };
5614
5529
  var AudioCodecType = {
5615
5530
  AAC: "aac",
5616
5531
  G711PCMA: "g7110a",
5617
- G711PCMU: "g7110m",
5618
- OPUS: "opus"
5532
+ G711PCMU: "g7110m"
5619
5533
  };
5620
5534
  var WarningType = {
5621
5535
  LARGE_AV_SHIFT: "LARGE_AV_SHIFT",
@@ -5655,7 +5569,6 @@ var VideoTrack = /* @__PURE__ */ function() {
5655
5569
  _defineProperty(this, "isVideoEncryption", false);
5656
5570
  _defineProperty(this, "isAudioEncryption", false);
5657
5571
  _defineProperty(this, "isVideo", true);
5658
- _defineProperty(this, "lastKeyFrameDts", 0);
5659
5572
  _defineProperty(this, "kid", null);
5660
5573
  _defineProperty(this, "pssh", null);
5661
5574
  _defineProperty(this, "ext", void 0);
@@ -5698,9 +5611,6 @@ var VideoTrack = /* @__PURE__ */ function() {
5698
5611
  }, {
5699
5612
  key: "exist",
5700
5613
  value: function exist() {
5701
- if (/av01/.test(this.codec)) {
5702
- return true;
5703
- }
5704
5614
  return !!(this.pps.length && this.sps.length && this.codec);
5705
5615
  }
5706
5616
  }, {
@@ -5764,7 +5674,7 @@ var AudioTrack = /* @__PURE__ */ function() {
5764
5674
  }, {
5765
5675
  key: "exist",
5766
5676
  value: function exist() {
5767
- return !!(this.sampleRate && this.channelCount && this.codec && (this.codecType === AudioCodecType.AAC || this.codecType === AudioCodecType.G711PCMA || this.codecType === AudioCodecType.G711PCMU || this.codecType === AudioCodecType.OPUS));
5677
+ return !!(this.sampleRate && this.channelCount && this.codec && this.codecType === AudioCodecType.AAC);
5768
5678
  }
5769
5679
  }, {
5770
5680
  key: "hasSample",
@@ -5978,7 +5888,7 @@ var AAC = /* @__PURE__ */ function() {
5978
5888
  continue;
5979
5889
  }
5980
5890
  frameLength = (data[i + 3] & 3) << 11 | data[i + 4] << 3 | (data[i + 5] & 224) >> 5;
5981
- if (!frameLength || len - i < frameLength)
5891
+ if (len - i < frameLength)
5982
5892
  break;
5983
5893
  protectionSkipBytes = (~data[i + 1] & 1) * 2;
5984
5894
  frames.push({
@@ -6112,57 +6022,14 @@ var AAC = /* @__PURE__ */ function() {
6112
6022
  return AAC2;
6113
6023
  }();
6114
6024
  _defineProperty(AAC, "FREQ", [96e3, 88200, 64e3, 48e3, 44100, 32e3, 24e3, 22050, 16e3, 12e3, 11025, 8e3, 7350]);
6115
- var OPUS = /* @__PURE__ */ function() {
6116
- function OPUS2() {
6117
- _classCallCheck$1(this, OPUS2);
6118
- }
6119
- _createClass$1(OPUS2, null, [{
6120
- key: "getFrameDuration",
6121
- value: function getFrameDuration(samples) {
6122
- return 20;
6123
- }
6124
- }, {
6125
- key: "parseHeaderPackets",
6126
- value: function parseHeaderPackets(data) {
6127
- if (!data.length)
6128
- return;
6129
- var dv = new DataView(data.buffer, data.byteOffset, data.byteLength);
6130
- var magicSignature = "";
6131
- for (var i = 0; i < 8; i++) {
6132
- magicSignature += String.fromCodePoint(data[i]);
6133
- }
6134
- if (magicSignature !== "OpusHead") {
6135
- throw new Error("Invalid Opus MagicSignature");
6136
- }
6137
- var channelCount = data[9];
6138
- console.log("Pre-skip", data[10], data[11]);
6139
- var sampleRate = dv.getUint32(12, true);
6140
- var outputGain = dv.getInt16(16, true);
6141
- if (!sampleRate)
6142
- return;
6143
- var codec = "opus";
6144
- var originCodec = "opus";
6145
- var config = new Uint8Array(data.buffer, data.byteOffset + 8, data.byteLength - 8);
6146
- return {
6147
- outputGain,
6148
- sampleRate,
6149
- channelCount,
6150
- config,
6151
- codec,
6152
- originCodec
6153
- };
6154
- }
6155
- }]);
6156
- return OPUS2;
6157
- }();
6158
6025
  var LARGE_AV_FIRST_FRAME_GAP = 500;
6159
6026
  var AUDIO_GAP_OVERLAP_THRESHOLD_COUNT = 3;
6160
6027
  var MAX_SILENT_FRAME_DURATION = 1e3;
6161
- var AUDIO_EXCEPTION_LOG_EMIT_DURATION = 5e3;
6028
+ var AUDIO_EXCETION_LOG_EMIT_DURATION = 5e3;
6162
6029
  var MAX_VIDEO_FRAME_DURATION = 1e3;
6163
6030
  var MAX_DTS_DELTA_WITH_NEXT_CHUNK = 200;
6164
- var VIDEO_EXCEPTION_LOG_EMIT_DURATION = 5e3;
6165
- var TRACK_BROKEN_CHECK_TIME = 5;
6031
+ var VIDEO_EXCETION_LOG_EMIT_DURATION = 5e3;
6032
+ var TRACK_BREACKED_CHECK_TIME = 5;
6166
6033
  var FlvFixer = /* @__PURE__ */ function() {
6167
6034
  function FlvFixer2(videoTrack, audioTrack, metadataTrack) {
6168
6035
  _classCallCheck$1(this, FlvFixer2);
@@ -6278,7 +6145,7 @@ var FlvFixer = /* @__PURE__ */ function() {
6278
6145
  var firstSample = samples[0];
6279
6146
  var vDelta = this._videoNextDts - firstSample.dts;
6280
6147
  if (Math.abs(vDelta) > MAX_DTS_DELTA_WITH_NEXT_CHUNK) {
6281
- if (Math.abs(firstSample.dts - this._lastVideoExceptionChunkFirstDtsDot) > VIDEO_EXCEPTION_LOG_EMIT_DURATION) {
6148
+ if (Math.abs(firstSample.dts - this._lastVideoExceptionChunkFirstDtsDot) > VIDEO_EXCETION_LOG_EMIT_DURATION) {
6282
6149
  var _samples$;
6283
6150
  this._lastVideoExceptionChunkFirstDtsDot = firstSample.dts;
6284
6151
  videoTrack.warnings.push({
@@ -6289,7 +6156,7 @@ var FlvFixer = /* @__PURE__ */ function() {
6289
6156
  sampleDuration: vDelta
6290
6157
  });
6291
6158
  }
6292
- if (this._videoTimestampBreak >= TRACK_BROKEN_CHECK_TIME) {
6159
+ if (this._videoTimestampBreak >= TRACK_BREACKED_CHECK_TIME) {
6293
6160
  this._videoNextDts = firstSample.dts;
6294
6161
  this._videoTimestampBreak = 0;
6295
6162
  } else {
@@ -6312,7 +6179,7 @@ var FlvFixer = /* @__PURE__ */ function() {
6312
6179
  }
6313
6180
  if (sampleDuration > MAX_VIDEO_FRAME_DURATION || sampleDuration < 0) {
6314
6181
  this._videoTimestampBreak++;
6315
- if (Math.abs(dts - this._lastVideoExceptionLargeGapDot) > VIDEO_EXCEPTION_LOG_EMIT_DURATION) {
6182
+ if (Math.abs(dts - this._lastVideoExceptionLargeGapDot) > VIDEO_EXCETION_LOG_EMIT_DURATION) {
6316
6183
  this._lastVideoExceptionLargeGapDot = dts;
6317
6184
  videoTrack.warnings.push({
6318
6185
  type: WarningType.LARGE_VIDEO_GAP,
@@ -6393,27 +6260,10 @@ var FlvFixer = /* @__PURE__ */ function() {
6393
6260
  key: "_doFixAudioInternal",
6394
6261
  value: function _doFixAudioInternal(audioTrack, samples, timescale) {
6395
6262
  if (!audioTrack.sampleDuration) {
6396
- switch (audioTrack.codecType) {
6397
- case AudioCodecType.AAC: {
6398
- audioTrack.sampleDuration = AAC.getFrameDuration(audioTrack.timescale, timescale);
6399
- break;
6400
- }
6401
- case AudioCodecType.OPUS: {
6402
- audioTrack.sampleDuration = OPUS.getFrameDuration(audioTrack.samples, timescale);
6403
- break;
6404
- }
6405
- case AudioCodecType.G711PCMA:
6406
- case AudioCodecType.G711PCMU: {
6407
- audioTrack.sampleDuration = this._getG711Duration(audioTrack);
6408
- break;
6409
- }
6410
- default:
6411
- console.error("can't fix audio codecType:", audioTrack.codecType);
6412
- break;
6413
- }
6263
+ audioTrack.sampleDuration = audioTrack.codecType === AudioCodecType.AAC ? AAC.getFrameDuration(audioTrack.timescale, timescale) : this._getG711Duration(audioTrack);
6414
6264
  }
6415
6265
  var refSampleDuration = audioTrack.sampleDuration;
6416
- var sampleDurationInSampleRate = audioTrack.codecType === AudioCodecType.OPUS ? 20 : audioTrack.codecType === AudioCodecType.AAC ? 1024 : refSampleDuration * audioTrack.timescale / 1e3;
6266
+ var sampleDurationInSampleRate = audioTrack.codecType === AudioCodecType.AAC ? 1024 : refSampleDuration * audioTrack.timescale / 1e3;
6417
6267
  if (this._audioNextPts === void 0) {
6418
6268
  var samp0 = samples[0];
6419
6269
  this._audioNextPts = samp0.pts;
@@ -6422,7 +6272,7 @@ var FlvFixer = /* @__PURE__ */ function() {
6422
6272
  var nextPts = this._audioNextPts;
6423
6273
  var sample = samples[i];
6424
6274
  var delta = sample.pts - nextPts;
6425
- if (i === 0 && this._audioTimestampBreak >= TRACK_BROKEN_CHECK_TIME && this._keyFrameInNextChunk) {
6275
+ if (i === 0 && this._audioTimestampBreak >= TRACK_BREACKED_CHECK_TIME && this._keyFrameInNextChunk) {
6426
6276
  nextPts = this._audioNextPts = sample.dts;
6427
6277
  delta = 0;
6428
6278
  this._audioTimestampBreak = 0;
@@ -6430,7 +6280,7 @@ var FlvFixer = /* @__PURE__ */ function() {
6430
6280
  if (!this._audioTimestampBreak && delta >= AUDIO_GAP_OVERLAP_THRESHOLD_COUNT * refSampleDuration && delta <= MAX_SILENT_FRAME_DURATION && !isSafari) {
6431
6281
  var silentFrame = this._getSilentFrame(audioTrack) || samples[0].data.subarray();
6432
6282
  var count = Math.floor(delta / refSampleDuration);
6433
- if (Math.abs(sample.pts - this._lastAudioExceptionGapDot) > AUDIO_EXCEPTION_LOG_EMIT_DURATION) {
6283
+ if (Math.abs(sample.pts - this._lastAudioExceptionGapDot) > AUDIO_EXCETION_LOG_EMIT_DURATION) {
6434
6284
  this._lastAudioExceptionGapDot = sample.pts;
6435
6285
  audioTrack.warnings.push({
6436
6286
  type: WarningType.AUDIO_FILLED,
@@ -6450,7 +6300,7 @@ var FlvFixer = /* @__PURE__ */ function() {
6450
6300
  }
6451
6301
  i--;
6452
6302
  } else if (delta <= -AUDIO_GAP_OVERLAP_THRESHOLD_COUNT * refSampleDuration && delta >= -1 * MAX_SILENT_FRAME_DURATION) {
6453
- if (Math.abs(sample.pts - this._lastAudioExceptionOverlapDot) > AUDIO_EXCEPTION_LOG_EMIT_DURATION) {
6303
+ if (Math.abs(sample.pts - this._lastAudioExceptionOverlapDot) > AUDIO_EXCETION_LOG_EMIT_DURATION) {
6454
6304
  this._lastAudioExceptionOverlapDot = sample.pts;
6455
6305
  audioTrack.warnings.push({
6456
6306
  type: WarningType.AUDIO_DROPPED,
@@ -6465,7 +6315,7 @@ var FlvFixer = /* @__PURE__ */ function() {
6465
6315
  } else {
6466
6316
  if (Math.abs(delta) > MAX_SILENT_FRAME_DURATION) {
6467
6317
  this._audioTimestampBreak++;
6468
- if (Math.abs(sample.pts - this._lastAudioExceptionLargeGapDot) > AUDIO_EXCEPTION_LOG_EMIT_DURATION) {
6318
+ if (Math.abs(sample.pts - this._lastAudioExceptionLargeGapDot) > AUDIO_EXCETION_LOG_EMIT_DURATION) {
6469
6319
  this._lastAudioExceptionLargeGapDot = sample.pts;
6470
6320
  audioTrack.warnings.push({
6471
6321
  type: WarningType.LARGE_AUDIO_GAP,
@@ -6478,15 +6328,8 @@ var FlvFixer = /* @__PURE__ */ function() {
6478
6328
  });
6479
6329
  }
6480
6330
  }
6481
- if (audioTrack.codecType === AudioCodecType.OPUS) {
6482
- var lastSample = samples[samples.length - 1];
6483
- if (lastSample) {
6484
- lastSample.duration = sample.pts - lastSample.pts;
6485
- }
6486
- } else {
6487
- sample.dts = sample.pts = nextPts;
6488
- sample.duration = sampleDurationInSampleRate;
6489
- }
6331
+ sample.dts = sample.pts = nextPts;
6332
+ sample.duration = sampleDurationInSampleRate;
6490
6333
  this._audioNextPts += refSampleDuration;
6491
6334
  }
6492
6335
  }
@@ -7445,13 +7288,6 @@ var AMF = /* @__PURE__ */ function() {
7445
7288
  }]);
7446
7289
  return AMF2;
7447
7290
  }();
7448
- var FlvSoundFormat = {
7449
- MP3: 2,
7450
- G711A: 7,
7451
- G711M: 8,
7452
- AAC: 10,
7453
- OPUS: 13
7454
- };
7455
7291
  var logger$2 = new Logger$1("FlvDemuxer");
7456
7292
  var FlvDemuxer = /* @__PURE__ */ function() {
7457
7293
  function FlvDemuxer2(videoTrack, audioTrack, metadataTrack) {
@@ -7468,10 +7304,8 @@ var FlvDemuxer = /* @__PURE__ */ function() {
7468
7304
  _createClass$1(FlvDemuxer2, [{
7469
7305
  key: "demux",
7470
7306
  value: function demux(data) {
7471
- var _scriptDataObject$dat;
7472
7307
  var discontinuity = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
7473
7308
  var contiguous = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
7474
- var seamlessLoadingSwitching = arguments.length > 3 ? arguments[3] : void 0;
7475
7309
  var audioTrack = this.audioTrack, videoTrack = this.videoTrack, metadataTrack = this.metadataTrack;
7476
7310
  if (discontinuity || !contiguous) {
7477
7311
  this._remainingData = null;
@@ -7529,8 +7363,6 @@ var FlvDemuxer = /* @__PURE__ */ function() {
7529
7363
  if (tagType === 8) {
7530
7364
  this._parseAudio(bodyData, timestamp);
7531
7365
  } else if (tagType === 9) {
7532
- if (seamlessLoadingSwitching)
7533
- this.seamlessLoadingSwitching = true;
7534
7366
  this._parseVideo(bodyData, timestamp);
7535
7367
  } else if (tagType === 18) {
7536
7368
  this._parseScript(bodyData, timestamp);
@@ -7548,31 +7380,13 @@ var FlvDemuxer = /* @__PURE__ */ function() {
7548
7380
  this._remainingData = data.subarray(offset);
7549
7381
  }
7550
7382
  audioTrack.formatTimescale = videoTrack.formatTimescale = videoTrack.timescale = metadataTrack.timescale = 1e3;
7551
- audioTrack.timescale = audioTrack.codecType === AudioCodecType.OPUS ? 1e3 : audioTrack.sampleRate || 0;
7383
+ audioTrack.timescale = audioTrack.sampleRate || 0;
7552
7384
  if (!audioTrack.exist() && audioTrack.hasSample()) {
7553
7385
  audioTrack.reset();
7554
7386
  }
7555
7387
  if (!videoTrack.exist() && videoTrack.hasSample()) {
7556
7388
  videoTrack.reset();
7557
7389
  }
7558
- var scriptDataObject = metadataTrack.flvScriptSamples[metadataTrack.flvScriptSamples.length - 1];
7559
- var metaData = scriptDataObject === null || scriptDataObject === void 0 ? void 0 : (_scriptDataObject$dat = scriptDataObject.data) === null || _scriptDataObject$dat === void 0 ? void 0 : _scriptDataObject$dat.onMetaData;
7560
- if (metaData) {
7561
- if (videoTrack !== null && videoTrack !== void 0 && videoTrack.exist()) {
7562
- if (metaData.hasOwnProperty("duration")) {
7563
- videoTrack.duration = metaData.duration * 1e3;
7564
- }
7565
- if (metaData.hasOwnProperty("width") && metaData.hasOwnProperty("height")) {
7566
- videoTrack.width = metaData.width;
7567
- videoTrack.height = metaData.height;
7568
- }
7569
- }
7570
- if (audioTrack !== null && audioTrack !== void 0 && audioTrack.exist()) {
7571
- if (metaData.hasOwnProperty("duration")) {
7572
- audioTrack.duration = metaData.duration * 1e3;
7573
- }
7574
- }
7575
- }
7576
7390
  return {
7577
7391
  videoTrack,
7578
7392
  audioTrack,
@@ -7591,8 +7405,8 @@ var FlvDemuxer = /* @__PURE__ */ function() {
7591
7405
  }
7592
7406
  }, {
7593
7407
  key: "demuxAndFix",
7594
- value: function demuxAndFix(data, discontinuity, contiguous, startTime, seamlessLoadingSwitching) {
7595
- this.demux(data, discontinuity, contiguous, seamlessLoadingSwitching);
7408
+ value: function demuxAndFix(data, discontinuity, contiguous, startTime) {
7409
+ this.demux(data, discontinuity, contiguous);
7596
7410
  return this.fix(startTime, discontinuity, contiguous);
7597
7411
  }
7598
7412
  }, {
@@ -7602,12 +7416,12 @@ var FlvDemuxer = /* @__PURE__ */ function() {
7602
7416
  return;
7603
7417
  var format = (data[0] & 240) >>> 4;
7604
7418
  var track = this.audioTrack;
7605
- if (format !== FlvSoundFormat.AAC && format !== FlvSoundFormat.G711A && format !== FlvSoundFormat.G711M && format !== FlvSoundFormat.OPUS) {
7419
+ if (format !== 10 && format !== 7 && format !== 8) {
7606
7420
  logger$2.warn("Unsupported sound format: ".concat(format));
7607
7421
  track.reset();
7608
7422
  return;
7609
7423
  }
7610
- if (format !== FlvSoundFormat.AAC && format !== FlvSoundFormat.OPUS) {
7424
+ if (format !== 10) {
7611
7425
  var soundRate = (data[0] & 12) >> 2;
7612
7426
  var soundSize = (data[0] & 2) >> 1;
7613
7427
  var soundType = data[0] & 1;
@@ -7615,49 +7429,10 @@ var FlvDemuxer = /* @__PURE__ */ function() {
7615
7429
  track.sampleSize = soundSize ? 16 : 8;
7616
7430
  track.channelCount = soundType + 1;
7617
7431
  }
7618
- switch (format) {
7619
- case FlvSoundFormat.G711A:
7620
- case FlvSoundFormat.G711M:
7621
- this._parseG711(data, pts, format);
7622
- break;
7623
- case FlvSoundFormat.AAC:
7624
- this._parseAac(data, pts);
7625
- break;
7626
- case FlvSoundFormat.OPUS:
7627
- this._parseOpus(data, pts);
7628
- break;
7629
- }
7630
- }
7631
- }, {
7632
- key: "_parseOpus",
7633
- value: function _parseOpus(data, pts) {
7634
- var track = this.audioTrack;
7635
- var packetType = data[1];
7636
- track.codecType = AudioCodecType.OPUS;
7637
- switch (packetType) {
7638
- case 0: {
7639
- var ret = OPUS.parseHeaderPackets(data.subarray(2));
7640
- if (ret) {
7641
- track.codec = ret.codec;
7642
- track.channelCount = ret.channelCount;
7643
- track.sampleRate = ret.sampleRate;
7644
- track.config = ret.config;
7645
- track.sampleDuration = OPUS.getFrameDuration([], track.timescale);
7646
- } else {
7647
- track.reset();
7648
- logger$2.warn("Cannot parse AudioSpecificConfig", data);
7649
- }
7650
- break;
7651
- }
7652
- case 1: {
7653
- if (pts === void 0 || pts === null)
7654
- return;
7655
- var newSample = new AudioSample(pts, data.subarray(2), track.sampleDuration);
7656
- track.samples.push(newSample);
7657
- break;
7658
- }
7659
- default:
7660
- logger$2.warn("Unknown OpusPacketType: ".concat(packetType));
7432
+ if (format === 10) {
7433
+ this._parseAac(data, pts);
7434
+ } else {
7435
+ this._parseG711(data, pts, format);
7661
7436
  }
7662
7437
  }
7663
7438
  }, {
@@ -7745,13 +7520,8 @@ var FlvDemuxer = /* @__PURE__ */ function() {
7745
7520
  units = this._checkAddMetaNalToUnits(isHevc, units, track);
7746
7521
  if (units && units.length) {
7747
7522
  var sample = new VideoSample(dts + cts, dts, units);
7748
- if (this.seamlessLoadingSwitching && dts < track.lastKeyFrameDts) {
7749
- return;
7750
- }
7751
- this.seamlessLoadingSwitching = false;
7752
7523
  if (frameType === 1) {
7753
7524
  sample.setToKeyframe();
7754
- track.lastKeyFrameDts = dts;
7755
7525
  }
7756
7526
  track.samples.push(sample);
7757
7527
  units.forEach(function(unit) {
@@ -8225,16 +7995,10 @@ var MP4 = /* @__PURE__ */ function() {
8225
7995
  if (track.useEME && track.enca) {
8226
7996
  content = MP42.enca(track);
8227
7997
  } else {
8228
- if (track.codecType === AudioCodecType.OPUS) {
8229
- content = MP42.opus(track);
8230
- } else {
8231
- content = MP42.mp4a(track);
8232
- }
7998
+ content = MP42.mp4a(track);
8233
7999
  }
8234
8000
  } else if (track.useEME && track.encv) {
8235
8001
  content = MP42.encv(track);
8236
- } else if (track.av1C) {
8237
- content = MP42.av01(track);
8238
8002
  } else {
8239
8003
  content = MP42.avc1hev1(track);
8240
8004
  }
@@ -8447,90 +8211,6 @@ var MP4 = /* @__PURE__ */ function() {
8447
8211
  var schi = MP42.schi(data);
8448
8212
  return MP42.box(MP42.types.sinf, content, MP42.box(MP42.types.frma, frma), MP42.box(MP42.types.schm, schm), schi);
8449
8213
  }
8450
- }, {
8451
- key: "av01",
8452
- value: function av01(track) {
8453
- return MP42.box(MP42.types.av01, new Uint8Array([
8454
- 0,
8455
- 0,
8456
- 0,
8457
- 0,
8458
- 0,
8459
- 0,
8460
- 0,
8461
- 1,
8462
- 0,
8463
- 0,
8464
- 0,
8465
- 0,
8466
- 0,
8467
- 0,
8468
- 0,
8469
- 0,
8470
- 0,
8471
- 0,
8472
- 0,
8473
- 0,
8474
- 0,
8475
- 0,
8476
- 0,
8477
- 0,
8478
- track.width >> 8 & 255,
8479
- track.width & 255,
8480
- track.height >> 8 & 255,
8481
- track.height & 255,
8482
- 0,
8483
- 72,
8484
- 0,
8485
- 0,
8486
- 0,
8487
- 72,
8488
- 0,
8489
- 0,
8490
- 0,
8491
- 0,
8492
- 0,
8493
- 0,
8494
- 0,
8495
- 1,
8496
- 0,
8497
- 0,
8498
- 0,
8499
- 0,
8500
- 0,
8501
- 0,
8502
- 0,
8503
- 0,
8504
- 0,
8505
- 0,
8506
- 0,
8507
- 0,
8508
- 0,
8509
- 0,
8510
- 0,
8511
- 0,
8512
- 0,
8513
- 0,
8514
- 0,
8515
- 0,
8516
- 0,
8517
- 0,
8518
- 0,
8519
- 0,
8520
- 0,
8521
- 0,
8522
- 0,
8523
- 0,
8524
- 0,
8525
- 0,
8526
- 0,
8527
- 0,
8528
- 0,
8529
- 24,
8530
- 17,
8531
- 17
8532
- ]), track.av1C, track.colr);
8533
- }
8534
8214
  }, {
8535
8215
  key: "avc1hev1",
8536
8216
  value: function avc1hev1(track) {
@@ -8901,53 +8581,6 @@ var MP4 = /* @__PURE__ */ function() {
8901
8581
  )));
8902
8582
  return esds2;
8903
8583
  }
8904
- }, {
8905
- key: "opus",
8906
- value: function opus(track) {
8907
- var opusAudioDescription = new Uint8Array([
8908
- 0,
8909
- 0,
8910
- 0,
8911
- 0,
8912
- 0,
8913
- 0,
8914
- 0,
8915
- 1,
8916
- 0,
8917
- 0,
8918
- 0,
8919
- 0,
8920
- 0,
8921
- 0,
8922
- 0,
8923
- 0,
8924
- 0,
8925
- track.channelCount,
8926
- 0,
8927
- 16,
8928
- 0,
8929
- 0,
8930
- 0,
8931
- 0,
8932
- track.sampleRate >> 8 & 255,
8933
- track.sampleRate & 255,
8934
- 0,
8935
- 0
8936
- ]);
8937
- var opusSpecificConfig = track.config.length ? MP42.dOps(track) : [];
8938
- return MP42.box(MP42.types.Opus, opusAudioDescription, opusSpecificConfig);
8939
- }
8940
- }, {
8941
- key: "dOps",
8942
- value: function dOps(track) {
8943
- if (track.config) {
8944
- track.config[4] = track.sampleRate >>> 24 & 255;
8945
- track.config[5] = track.sampleRate >>> 16 & 255;
8946
- track.config[6] = track.sampleRate >>> 8 & 255;
8947
- track.config[7] = track.sampleRate & 255;
8948
- return MP42.box(MP42.types.dOps, track.config);
8949
- }
8950
- }
8951
8584
  }, {
8952
8585
  key: "mvex",
8953
8586
  value: function mvex(tracks) {
@@ -9550,7 +9183,7 @@ var MP4 = /* @__PURE__ */ function() {
9550
9183
  }]);
9551
9184
  return MP42;
9552
9185
  }();
9553
- _defineProperty(MP4, "types", ["Opus", "dOps", "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) {
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) {
9554
9187
  p[c] = [c.charCodeAt(0), c.charCodeAt(1), c.charCodeAt(2), c.charCodeAt(3)];
9555
9188
  return p;
9556
9189
  }, /* @__PURE__ */ Object.create(null)));
@@ -9885,46 +9518,30 @@ var FMP4Remuxer = /* @__PURE__ */ function() {
9885
9518
  };
9886
9519
  }
9887
9520
  var samples = track.samples;
9888
- var isAV01 = /av01/.test(track.codec);
9889
9521
  var mdatSize = 0;
9890
- if (isAV01) {
9891
- samples.forEach(function(s) {
9892
- mdatSize += s.data.byteLength;
9893
- });
9894
- } else {
9895
- samples.forEach(function(s) {
9896
- mdatSize += s.units.reduce(function(t, c) {
9897
- return t + c.byteLength;
9898
- }, 0);
9899
- mdatSize += s.units.length * 4;
9900
- });
9901
- }
9522
+ samples.forEach(function(s) {
9523
+ mdatSize += s.units.reduce(function(t, c) {
9524
+ return t + c.byteLength;
9525
+ }, 0);
9526
+ mdatSize += s.units.length * 4;
9527
+ });
9902
9528
  var mdata = new Uint8Array(mdatSize);
9903
- if (isAV01) {
9904
- for (var i = 0, l = samples.length, offset = 0, sample; i < l; i++) {
9905
- sample = samples[i];
9906
- mdata.set(sample.data, offset);
9907
- sample.size = sample.data.byteLength;
9908
- offset += sample.size;
9909
- }
9910
- } else {
9911
- var mdatView = new DataView(mdata.buffer);
9912
- var _loop = function _loop2(_offset2, _sample2) {
9913
- _sample2 = samples[_i];
9914
- var sampleSize = 0;
9915
- _sample2.units.forEach(function(u) {
9916
- mdatView.setUint32(_offset2, u.byteLength);
9917
- _offset2 += 4;
9918
- mdata.set(u, _offset2);
9919
- _offset2 += u.byteLength;
9920
- sampleSize += 4 + u.byteLength;
9921
- });
9922
- _sample2.size = sampleSize;
9923
- _offset = _offset2, _sample = _sample2;
9924
- };
9925
- for (var _i = 0, _l = samples.length, _offset = 0, _sample; _i < _l; _i++) {
9926
- _loop(_offset, _sample);
9927
- }
9529
+ var mdatView = new DataView(mdata.buffer);
9530
+ var _loop = function _loop2(_offset, _sample) {
9531
+ _sample = samples[i];
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;
9539
+ });
9540
+ _sample.size = sampleSize;
9541
+ offset = _offset, sample = _sample;
9542
+ };
9543
+ for (var i = 0, l = samples.length, offset = 0, sample; i < l; i++) {
9544
+ _loop(offset, sample);
9928
9545
  }
9929
9546
  var mdat = MP4.mdat(mdata);
9930
9547
  var moof = MP4.moof([track]);
@@ -9954,55 +9571,6 @@ var FMP4Remuxer = /* @__PURE__ */ function() {
9954
9571
  }]);
9955
9572
  return FMP4Remuxer2;
9956
9573
  }();
9957
- var TransferCost = /* @__PURE__ */ function() {
9958
- function TransferCost2() {
9959
- _classCallCheck$4(this, TransferCost2);
9960
- _defineProperty$3(this, "_ttfb", 0);
9961
- _defineProperty$3(this, "_demuxStart", 0);
9962
- _defineProperty$3(this, "_demuxEnd", 0);
9963
- _defineProperty$3(this, "_demuxCost", 0);
9964
- _defineProperty$3(this, "_remuxStart", 0);
9965
- _defineProperty$3(this, "_remuxEnd", 0);
9966
- _defineProperty$3(this, "_remuxCost", 0);
9967
- _defineProperty$3(this, "_appendStart", 0);
9968
- _defineProperty$3(this, "_appendEnd", 0);
9969
- _defineProperty$3(this, "_appendCost", 0);
9970
- }
9971
- _createClass$4(TransferCost2, [{
9972
- key: "set",
9973
- value: function set(event, value) {
9974
- this["_".concat(event)] = value;
9975
- }
9976
- }, {
9977
- key: "start",
9978
- value: function start(event) {
9979
- this["_".concat(event, "Start")] = Date.now();
9980
- }
9981
- }, {
9982
- key: "end",
9983
- value: function end(event) {
9984
- this["_".concat(event, "End")] = Date.now();
9985
- this["_".concat(event, "Cost")] = this["_".concat(event, "Cost")] + (this["_".concat(event, "End")] - this["_".concat(event, "Start")]);
9986
- }
9987
- }, {
9988
- key: "transferCost",
9989
- get: function get() {
9990
- return {
9991
- ttfbCost: this._ttfb,
9992
- demuxCost: this._demuxCost,
9993
- remuxCost: this._remuxCost,
9994
- appendCost: this._appendCost
9995
- };
9996
- }
9997
- }]);
9998
- return TransferCost2;
9999
- }();
10000
- var TRANSFER_EVENT = {
10001
- TTFB: "ttfb",
10002
- DEMUX: "demux",
10003
- REMUX: "remux",
10004
- APPEND: "append"
10005
- };
10006
9574
  var logger$1 = new Logger$2("BufferService");
10007
9575
  var BufferService = /* @__PURE__ */ function() {
10008
9576
  function BufferService2(flv, softVideo) {
@@ -10090,8 +9658,7 @@ var BufferService = /* @__PURE__ */ function() {
10090
9658
  this._contiguous = false;
10091
9659
  this._sourceCreated = false;
10092
9660
  this._initSegmentId = "";
10093
- this.resetSeamlessSwitchStats();
10094
- case 12:
9661
+ case 11:
10095
9662
  case "end":
10096
9663
  return _context.stop();
10097
9664
  }
@@ -10102,15 +9669,6 @@ var BufferService = /* @__PURE__ */ function() {
10102
9669
  }
10103
9670
  return reset;
10104
9671
  }()
10105
- }, {
10106
- key: "resetSeamlessSwitchStats",
10107
- value: function resetSeamlessSwitchStats() {
10108
- this.seamlessLoadingSwitch = null;
10109
- this.seamlessLoadingSwitching = false;
10110
- if (this._demuxer) {
10111
- this._demuxer.seamlessLoadingSwitching = false;
10112
- }
10113
- }
10114
9672
  }, {
10115
9673
  key: "endOfStream",
10116
9674
  value: function() {
@@ -10216,56 +9774,32 @@ var BufferService = /* @__PURE__ */ function() {
10216
9774
  key: "appendBuffer",
10217
9775
  value: function() {
10218
9776
  var _appendBuffer = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee5(chunk) {
10219
- var _this = this;
10220
- var switchingNoReset, demuxer, videoTrack, audioTrack, metadataTrack, idx, videoExist, audioExist, duration, track, videoType, audioType, mse, afterAppend, newId, remuxResult, p;
9777
+ var demuxer, videoTrack, audioTrack, metadataTrack, videoExist, audioExist, duration, track, videoType, audioType, mse, newId, remuxResult, p;
10221
9778
  return _regeneratorRuntime$1().wrap(function _callee5$(_context5) {
10222
9779
  while (1)
10223
9780
  switch (_context5.prev = _context5.next) {
10224
9781
  case 0:
10225
- switchingNoReset = false;
10226
9782
  if (this._cachedBuffer) {
10227
9783
  chunk = concatUint8Array$1(this._cachedBuffer, chunk);
10228
9784
  this._cachedBuffer = null;
10229
9785
  }
10230
9786
  demuxer = this._demuxer;
10231
9787
  if (!(!chunk || !chunk.length || !demuxer)) {
10232
- _context5.next = 5;
9788
+ _context5.next = 4;
10233
9789
  break;
10234
9790
  }
10235
9791
  return _context5.abrupt("return");
10236
- case 5:
10237
- _context5.prev = 5;
10238
- this.flv._transferCost.start(TRANSFER_EVENT.DEMUX);
10239
- demuxer.demuxAndFix(chunk, this.seamlessLoadingSwitching || this._discontinuity, this._contiguous, this._demuxStartTime, this.seamlessLoadingSwitching);
10240
- this.seamlessLoadingSwitching = false;
10241
- this.flv._transferCost.end(TRANSFER_EVENT.DEMUX);
10242
- _context5.next = 15;
9792
+ case 4:
9793
+ _context5.prev = 4;
9794
+ demuxer.demuxAndFix(chunk, this._discontinuity, this._contiguous, this._demuxStartTime);
9795
+ _context5.next = 11;
10243
9796
  break;
10244
- case 12:
10245
- _context5.prev = 12;
10246
- _context5.t0 = _context5["catch"](5);
9797
+ case 8:
9798
+ _context5.prev = 8;
9799
+ _context5.t0 = _context5["catch"](4);
10247
9800
  throw new StreamingError(ERR.DEMUX, ERR.SUB_TYPES.FLV, _context5.t0);
10248
- case 15:
9801
+ case 11:
10249
9802
  videoTrack = demuxer.videoTrack, audioTrack = demuxer.audioTrack, metadataTrack = demuxer.metadataTrack;
10250
- if (!this.seamlessLoadingSwitch) {
10251
- _context5.next = 25;
10252
- break;
10253
- }
10254
- idx = videoTrack.samples.findIndex(function(sample) {
10255
- return sample.originDts === videoTrack.lastKeyFrameDts;
10256
- });
10257
- if (!(idx >= 0)) {
10258
- _context5.next = 25;
10259
- break;
10260
- }
10261
- videoTrack.samples.splice(idx);
10262
- _context5.next = 22;
10263
- return this.seamlessLoadingSwitch();
10264
- case 22:
10265
- this.seamlessLoadingSwitch = null;
10266
- chunk = null;
10267
- switchingNoReset = true;
10268
- case 25:
10269
9803
  videoExist = videoTrack.exist();
10270
9804
  audioExist = audioTrack.exist();
10271
9805
  if (this._opts.onlyAudio) {
@@ -10277,7 +9811,7 @@ var BufferService = /* @__PURE__ */ function() {
10277
9811
  audioTrack.present = false;
10278
9812
  }
10279
9813
  if (!(!videoExist && videoTrack.present || !audioExist && audioTrack.present)) {
10280
- _context5.next = 42;
9814
+ _context5.next = 29;
10281
9815
  break;
10282
9816
  }
10283
9817
  duration = 0;
@@ -10286,7 +9820,7 @@ var BufferService = /* @__PURE__ */ function() {
10286
9820
  duration = (track.samples[track.samples.length - 1].originPts - track.samples[0].originPts) / track.timescale * 1e3;
10287
9821
  }
10288
9822
  if (!(duration > this._opts.analyzeDuration)) {
10289
- _context5.next = 40;
9823
+ _context5.next = 27;
10290
9824
  break;
10291
9825
  }
10292
9826
  logger$1.warn("analyze duration exceeded, ".concat(duration, "ms"), track);
@@ -10295,28 +9829,19 @@ var BufferService = /* @__PURE__ */ function() {
10295
9829
  this.flv.emit(EVENT.ANALYZE_DURATION_EXCEEDED, {
10296
9830
  duration
10297
9831
  });
10298
- _context5.next = 42;
9832
+ _context5.next = 29;
10299
9833
  break;
10300
- case 40:
9834
+ case 27:
10301
9835
  this._cachedBuffer = chunk;
10302
9836
  return _context5.abrupt("return");
10303
- case 42:
9837
+ case 29:
10304
9838
  videoType = videoTrack.type;
10305
9839
  audioType = audioTrack.type;
10306
9840
  this._fireEvents(videoTrack, audioTrack, metadataTrack);
10307
- if (!switchingNoReset) {
10308
- this._discontinuity = false;
10309
- this._contiguous = true;
10310
- this._demuxStartTime = 0;
10311
- }
9841
+ this._discontinuity = false;
9842
+ this._contiguous = true;
9843
+ this._demuxStartTime = 0;
10312
9844
  mse = this._mse;
10313
- afterAppend = function afterAppend2() {
10314
- var _this$flv;
10315
- if ((_this$flv = _this.flv) !== null && _this$flv !== void 0 && _this$flv.emit) {
10316
- var _this$flv2;
10317
- (_this$flv2 = _this.flv) === null || _this$flv2 === void 0 ? void 0 : _this$flv2.emit(EVENT.APPEND_BUFFER, {});
10318
- }
10319
- };
10320
9845
  this.flv.emit(EVENT.DEMUXED_TRACK, {
10321
9846
  videoTrack
10322
9847
  });
@@ -10327,16 +9852,16 @@ var BufferService = /* @__PURE__ */ function() {
10327
9852
  this._emitMetaParsedEvent(videoTrack, audioTrack);
10328
9853
  }
10329
9854
  if (!mse) {
10330
- _context5.next = 81;
9855
+ _context5.next = 66;
10331
9856
  break;
10332
9857
  }
10333
9858
  if (this._sourceCreated) {
10334
- _context5.next = 59;
9859
+ _context5.next = 47;
10335
9860
  break;
10336
9861
  }
10337
- _context5.next = 55;
9862
+ _context5.next = 43;
10338
9863
  return mse.open();
10339
- case 55:
9864
+ case 43:
10340
9865
  if (videoExist) {
10341
9866
  logger$1.log("codec: video/mp4;codecs=".concat(videoTrack.codec));
10342
9867
  mse.createSource(videoType, "video/mp4;codecs=".concat(videoTrack.codec));
@@ -10347,28 +9872,26 @@ var BufferService = /* @__PURE__ */ function() {
10347
9872
  }
10348
9873
  this._sourceCreated = true;
10349
9874
  this.flv.emit(EVENT.SOURCEBUFFER_CREATED);
10350
- case 59:
10351
- _context5.prev = 59;
9875
+ case 47:
9876
+ _context5.prev = 47;
10352
9877
  if (this._needInitSegment && !this._opts.mseLowLatency) {
10353
9878
  videoTrack.duration = this._opts.durationForMSELowLatencyOff * videoTrack.timescale;
10354
9879
  audioTrack.duration = this._opts.durationForMSELowLatencyOff * audioExist.timescale;
10355
9880
  }
10356
- this.flv._transferCost.start(TRANSFER_EVENT.REMUX);
10357
9881
  remuxResult = this._remuxer.remux(this._needInitSegment);
10358
- this.flv._transferCost.end(TRANSFER_EVENT.REMUX);
10359
- _context5.next = 69;
9882
+ _context5.next = 55;
10360
9883
  break;
10361
- case 66:
10362
- _context5.prev = 66;
10363
- _context5.t1 = _context5["catch"](59);
9884
+ case 52:
9885
+ _context5.prev = 52;
9886
+ _context5.t1 = _context5["catch"](47);
10364
9887
  throw new StreamingError(ERR.REMUX, ERR.SUB_TYPES.FMP4, _context5.t1);
10365
- case 69:
9888
+ case 55:
10366
9889
  if (!(this._needInitSegment && !remuxResult.videoInitSegment && !remuxResult.audioInitSegment)) {
10367
- _context5.next = 71;
9890
+ _context5.next = 57;
10368
9891
  break;
10369
9892
  }
10370
9893
  return _context5.abrupt("return");
10371
- case 71:
9894
+ case 57:
10372
9895
  this._needInitSegment = false;
10373
9896
  p = [];
10374
9897
  if (remuxResult.videoInitSegment)
@@ -10379,21 +9902,16 @@ var BufferService = /* @__PURE__ */ function() {
10379
9902
  p.push(mse.append(videoType, remuxResult.videoSegment));
10380
9903
  if (remuxResult.audioSegment)
10381
9904
  p.push(mse.append(audioType, remuxResult.audioSegment));
10382
- this.flv._transferCost.start(TRANSFER_EVENT.APPEND);
10383
- return _context5.abrupt("return", Promise.all(p).then(afterAppend).then(function() {
10384
- _this.flv._transferCost.end(TRANSFER_EVENT.APPEND);
10385
- afterAppend();
10386
- }));
10387
- case 81:
9905
+ return _context5.abrupt("return", Promise.all(p));
9906
+ case 66:
10388
9907
  if (this._softVideo) {
10389
9908
  this._softVideo.appendBuffer(videoTrack, audioTrack);
10390
- afterAppend();
10391
9909
  }
10392
- case 82:
9910
+ case 67:
10393
9911
  case "end":
10394
9912
  return _context5.stop();
10395
9913
  }
10396
- }, _callee5, this, [[5, 12], [59, 66]]);
9914
+ }, _callee5, this, [[4, 8], [47, 52]]);
10397
9915
  }));
10398
9916
  function appendBuffer(_x2) {
10399
9917
  return _appendBuffer.apply(this, arguments);
@@ -10404,7 +9922,7 @@ var BufferService = /* @__PURE__ */ function() {
10404
9922
  key: "evictBuffer",
10405
9923
  value: function() {
10406
9924
  var _evictBuffer = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee6(bufferBehind) {
10407
- var _this2 = this;
9925
+ var _this = this;
10408
9926
  var media, currentTime, removeEnd, start;
10409
9927
  return _regeneratorRuntime$1().wrap(function _callee6$(_context6) {
10410
9928
  while (1)
@@ -10433,7 +9951,7 @@ var BufferService = /* @__PURE__ */ function() {
10433
9951
  return _context6.abrupt("return");
10434
9952
  case 10:
10435
9953
  return _context6.abrupt("return", this._mse.clearBuffer(0, removeEnd).then(function() {
10436
- return _this2.flv.emit(EVENT.REMOVE_BUFFER, {
9954
+ return _this.flv.emit(EVENT.REMOVE_BUFFER, {
10437
9955
  removeEnd
10438
9956
  });
10439
9957
  }));
@@ -10483,16 +10001,16 @@ var BufferService = /* @__PURE__ */ function() {
10483
10001
  }, {
10484
10002
  key: "_fireEvents",
10485
10003
  value: function _fireEvents(videoTrack, audioTrack, metadataTrack) {
10486
- var _this3 = this;
10487
- logger$1.debug("videoTrack samples count: ".concat(videoTrack.samples.length, ", audioTrack samples count: ").concat(audioTrack.samples.length));
10004
+ var _this2 = this;
10005
+ logger$1.debug(videoTrack.samples, audioTrack.samples);
10488
10006
  metadataTrack.flvScriptSamples.forEach(function(sample) {
10489
- _this3.flv.emit(EVENT.FLV_SCRIPT_DATA, sample);
10007
+ _this2.flv.emit(EVENT.FLV_SCRIPT_DATA, sample);
10490
10008
  logger$1.debug("flvScriptData", sample);
10491
10009
  });
10492
10010
  videoTrack.samples.forEach(function(sample) {
10493
10011
  if (sample.keyframe) {
10494
- _this3.flv.emit(EVENT.KEYFRAME, {
10495
- pts: sample.originPts
10012
+ _this2.flv.emit(EVENT.KEYFRAME, {
10013
+ pts: sample.pts
10496
10014
  });
10497
10015
  }
10498
10016
  });
@@ -10510,7 +10028,7 @@ var BufferService = /* @__PURE__ */ function() {
10510
10028
  break;
10511
10029
  }
10512
10030
  if (type)
10513
- _this3.flv.emit(EVENT.STREAM_EXCEPTION, _objectSpread2$2(_objectSpread2$2({}, warn), {}, {
10031
+ _this2.flv.emit(EVENT.STREAM_EXCEPTION, _objectSpread2$2(_objectSpread2$2({}, warn), {}, {
10514
10032
  type
10515
10033
  }));
10516
10034
  logger$1.warn("video exception", warn);
@@ -10529,13 +10047,13 @@ var BufferService = /* @__PURE__ */ function() {
10529
10047
  break;
10530
10048
  }
10531
10049
  if (type)
10532
- _this3.flv.emit(EVENT.STREAM_EXCEPTION, _objectSpread2$2(_objectSpread2$2({}, warn), {}, {
10050
+ _this2.flv.emit(EVENT.STREAM_EXCEPTION, _objectSpread2$2(_objectSpread2$2({}, warn), {}, {
10533
10051
  type
10534
10052
  }));
10535
10053
  logger$1.warn("audio exception", warn);
10536
10054
  });
10537
10055
  metadataTrack.seiSamples.forEach(function(sei) {
10538
- _this3.flv.emit(EVENT.SEI, _objectSpread2$2(_objectSpread2$2({}, sei), {}, {
10056
+ _this2.flv.emit(EVENT.SEI, _objectSpread2$2(_objectSpread2$2({}, sei), {}, {
10539
10057
  sei: {
10540
10058
  code: sei.data.type,
10541
10059
  content: sei.data.payload,
@@ -10570,8 +10088,7 @@ function getOption(opts) {
10570
10088
  durationForMSELowLatencyOff: 6,
10571
10089
  chunkCountForSpeed: 50,
10572
10090
  skipChunkSize: 1e3,
10573
- longtimeNoReceived: 3e3,
10574
- enableStartGapJump: true
10091
+ longtimeNoReceived: 3e3
10575
10092
  }, opts);
10576
10093
  if (ret.isLive) {
10577
10094
  if (ret.preloadTime) {
@@ -10639,7 +10156,7 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
10639
10156
  _defineProperty$3(_assertThisInitialized$3(_this), "_acceptRanges", true);
10640
10157
  _defineProperty$3(_assertThisInitialized$3(_this), "_onProgress", /* @__PURE__ */ function() {
10641
10158
  var _ref2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee(chunk, done, _ref, response) {
10642
- var startTime, endTime, st, firstByteTime, _this$_mediaLoader, headers, elapsed, _this$_bufferService, remaining, maxReaderInterval;
10159
+ var startTime, endTime, st, firstByteTime, _this$_mediaLoader, headers, _this$_bufferService, remaining, maxReaderInterval;
10643
10160
  return _regeneratorRuntime$1().wrap(function _callee$(_context) {
10644
10161
  while (1)
10645
10162
  switch (_context.prev = _context.next) {
@@ -10647,7 +10164,7 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
10647
10164
  startTime = _ref.startTime, endTime = _ref.endTime, st = _ref.st, firstByteTime = _ref.firstByteTime;
10648
10165
  _this._loading = !done;
10649
10166
  if (_this._firstProgressEmit) {
10650
- _context.next = 13;
10167
+ _context.next = 11;
10651
10168
  break;
10652
10169
  }
10653
10170
  if (_this.media) {
@@ -10658,51 +10175,49 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
10658
10175
  return _context.abrupt("return");
10659
10176
  case 6:
10660
10177
  headers = response.headers;
10661
- elapsed = st ? firstByteTime - st : endTime - startTime;
10662
10178
  _this.emit(EVENT.TTFB, {
10663
10179
  url: _this._opts.url,
10664
10180
  responseUrl: response.url,
10665
- elapsed
10181
+ elapsed: st ? firstByteTime - st : endTime - startTime
10666
10182
  });
10667
10183
  _this.emit(EVENT.LOAD_RESPONSE_HEADERS, {
10668
10184
  headers
10669
10185
  });
10670
- _this._transferCost.set(TRANSFER_EVENT.TTFB, elapsed);
10671
10186
  _this._acceptRanges = !!(headers !== null && headers !== void 0 && headers.get("Accept-Ranges")) || !!(headers !== null && headers !== void 0 && headers.get("Content-Range"));
10672
10187
  _this._firstProgressEmit = true;
10673
- case 13:
10188
+ case 11:
10674
10189
  if (_this._bufferService) {
10675
- _context.next = 15;
10190
+ _context.next = 13;
10676
10191
  break;
10677
10192
  }
10678
10193
  return _context.abrupt("return");
10679
- case 15:
10194
+ case 13:
10680
10195
  clearTimeout(_this._maxChunkWaitTimer);
10681
10196
  _this._bandwidthService.addChunkRecord(chunk === null || chunk === void 0 ? void 0 : chunk.byteLength, endTime - startTime);
10682
- _context.prev = 17;
10683
- _context.next = 20;
10197
+ _context.prev = 15;
10198
+ _context.next = 18;
10684
10199
  return _this._bufferService.appendBuffer(chunk);
10685
- case 20:
10200
+ case 18:
10686
10201
  (_this$_bufferService = _this._bufferService) === null || _this$_bufferService === void 0 ? void 0 : _this$_bufferService.evictBuffer(_this._opts.bufferBehind);
10687
- _context.next = 33;
10202
+ _context.next = 31;
10688
10203
  break;
10689
- case 23:
10690
- _context.prev = 23;
10691
- _context.t0 = _context["catch"](17);
10204
+ case 21:
10205
+ _context.prev = 21;
10206
+ _context.t0 = _context["catch"](15);
10692
10207
  if (!(!_this.isLive && _this._bufferService.isFull())) {
10693
- _context.next = 32;
10208
+ _context.next = 30;
10694
10209
  break;
10695
10210
  }
10696
- _context.next = 28;
10211
+ _context.next = 26;
10697
10212
  return _this._mediaLoader.cancel();
10698
- case 28:
10213
+ case 26:
10699
10214
  _this._loading = false;
10700
10215
  remaining = _this.bufferInfo().remaining;
10701
10216
  _this._opts.preloadTime = parseInt(remaining) / 2;
10702
10217
  return _context.abrupt("return");
10703
- case 32:
10218
+ case 30:
10704
10219
  return _context.abrupt("return", _this._emitError(StreamingError.create(_context.t0)));
10705
- case 33:
10220
+ case 31:
10706
10221
  if (_this._urlSwitching) {
10707
10222
  _this._urlSwitching = false;
10708
10223
  _this.emit(EVENT.SWITCH_URL_SUCCESS, {
@@ -10714,7 +10229,7 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
10714
10229
  _this._tick();
10715
10230
  }
10716
10231
  if (!(done && !_this.media.seeking)) {
10717
- _context.next = 40;
10232
+ _context.next = 38;
10718
10233
  break;
10719
10234
  }
10720
10235
  _this.emit(EVENT.LOAD_COMPLETE);
@@ -10723,13 +10238,13 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
10723
10238
  _this._end();
10724
10239
  }
10725
10240
  return _context.abrupt("return");
10726
- case 40:
10241
+ case 38:
10727
10242
  if (_this.isLive) {
10728
- _context.next = 42;
10243
+ _context.next = 40;
10729
10244
  break;
10730
10245
  }
10731
10246
  return _context.abrupt("return");
10732
- case 42:
10247
+ case 40:
10733
10248
  maxReaderInterval = _this._opts.maxReaderInterval;
10734
10249
  if (maxReaderInterval && _this._firstProgressEmit) {
10735
10250
  clearTimeout(_this._maxChunkWaitTimer);
@@ -10743,11 +10258,11 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
10743
10258
  _this._end();
10744
10259
  }, maxReaderInterval);
10745
10260
  }
10746
- case 44:
10261
+ case 42:
10747
10262
  case "end":
10748
10263
  return _context.stop();
10749
10264
  }
10750
- }, _callee, null, [[17, 23]]);
10265
+ }, _callee, null, [[15, 21]]);
10751
10266
  }));
10752
10267
  return function(_x, _x2, _x3, _x4) {
10753
10268
  return _ref2.apply(this, arguments);
@@ -10780,19 +10295,19 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
10780
10295
  if (bufferEnd < MAX_HOLE || !media.readyState)
10781
10296
  return;
10782
10297
  var opts = _this._opts;
10783
- if (isMediaPlaying(media) && media.currentTime) {
10298
+ if (isMediaPlaying(media)) {
10784
10299
  if (_this._gapService) {
10785
10300
  _this._gapService.do(media, opts.maxJumpDistance, _this.isLive, 3);
10786
10301
  }
10787
10302
  } else {
10788
- if (!media.currentTime && _this._gapService && opts.enableStartGapJump) {
10303
+ if (!media.currentTime && _this._gapService) {
10789
10304
  var gapJump = _this._opts.mseLowLatency || _this._opts.mseLowLatency === false && _this.bufferInfo(MAX_START_GAP).nextStart;
10790
10305
  if (gapJump) {
10791
10306
  _this._gapService.do(media, opts.maxJumpDistance, _this.isLive, 3);
10792
10307
  }
10793
10308
  return;
10794
10309
  }
10795
- if (opts.isLive && media.readyState === 4 && bufferEnd - media.currentTime > opts.disconnectTime) {
10310
+ if (opts.isLive && media.readyState === 4 && bufferEnd > opts.disconnectTime) {
10796
10311
  _this.disconnect();
10797
10312
  }
10798
10313
  }
@@ -10941,7 +10456,6 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
10941
10456
  responseType: "arraybuffer"
10942
10457
  }));
10943
10458
  _this._disconnectRetryCount = _this._opts.disconnectRetryCount;
10944
- _this._transferCost = new TransferCost();
10945
10459
  _this._bufferService = new BufferService(_assertThisInitialized$3(_this), _this._opts.softDecode ? _this.media : void 0, _this._opts);
10946
10460
  _this._seiService = new SeiService(_assertThisInitialized$3(_this));
10947
10461
  _this._bandwidthService = new BandwidthService({
@@ -10965,7 +10479,7 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
10965
10479
  _createClass$4(Flv2, [{
10966
10480
  key: "version",
10967
10481
  get: function get() {
10968
- return "3.0.20-rc.6";
10482
+ return "3.0.19-rc.0";
10969
10483
  }
10970
10484
  }, {
10971
10485
  key: "isLive",
@@ -11081,9 +10595,9 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
11081
10595
  return this._clear();
11082
10596
  case 8:
11083
10597
  setTimeout(function() {
11084
- _this2._seamlessSwitching = true;
11085
10598
  _this2._loadData(_this2._opts.url);
11086
10599
  _this2._bufferService.seamlessSwitch();
10600
+ _this2._seamlessSwitching = true;
11087
10601
  });
11088
10602
  _context5.next = 13;
11089
10603
  break;
@@ -11107,82 +10621,50 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
11107
10621
  }, {
11108
10622
  key: "disconnect",
11109
10623
  value: function disconnect() {
11110
- var _this$_bufferService4;
11111
10624
  logger.debug("disconnect!");
11112
- (_this$_bufferService4 = this._bufferService) === null || _this$_bufferService4 === void 0 ? void 0 : _this$_bufferService4.resetSeamlessSwitchStats();
11113
10625
  return this._clear();
11114
10626
  }
11115
10627
  }, {
11116
10628
  key: "switchURL",
11117
10629
  value: function() {
11118
- var _switchURL = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee7(url, seamless) {
10630
+ var _switchURL = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee6(url, seamless) {
11119
10631
  var _this3 = this;
11120
- return _regeneratorRuntime$1().wrap(function _callee7$(_context7) {
10632
+ return _regeneratorRuntime$1().wrap(function _callee6$(_context6) {
11121
10633
  while (1)
11122
- switch (_context7.prev = _context7.next) {
10634
+ switch (_context6.prev = _context6.next) {
11123
10635
  case 0:
11124
10636
  if (this._bufferService) {
11125
- _context7.next = 2;
10637
+ _context6.next = 2;
11126
10638
  break;
11127
10639
  }
11128
- return _context7.abrupt("return");
10640
+ return _context6.abrupt("return");
11129
10641
  case 2:
11130
10642
  this._resetDisconnectCount();
11131
- if (!(this._loading && seamless)) {
11132
- _context7.next = 6;
11133
- break;
11134
- }
11135
- this._bufferService.seamlessLoadingSwitch = /* @__PURE__ */ function() {
11136
- var _ref5 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee6(pts) {
11137
- return _regeneratorRuntime$1().wrap(function _callee6$(_context6) {
11138
- while (1)
11139
- switch (_context6.prev = _context6.next) {
11140
- case 0:
11141
- _context6.next = 2;
11142
- return _this3._clear();
11143
- case 2:
11144
- _this3._bufferService.seamlessLoadingSwitching = true;
11145
- _this3._urlSwitching = true;
11146
- _this3._seamlessSwitching = true;
11147
- _this3._bufferService.seamlessSwitch();
11148
- _this3._loadData(url);
11149
- case 7:
11150
- case "end":
11151
- return _context6.stop();
11152
- }
11153
- }, _callee6);
11154
- }));
11155
- return function(_x8) {
11156
- return _ref5.apply(this, arguments);
11157
- };
11158
- }();
11159
- return _context7.abrupt("return");
11160
- case 6:
11161
10643
  if (!(!seamless || !this._opts.isLive)) {
11162
- _context7.next = 11;
10644
+ _context6.next = 8;
11163
10645
  break;
11164
10646
  }
11165
- _context7.next = 9;
10647
+ _context6.next = 6;
11166
10648
  return this.load(url);
11167
- case 9:
10649
+ case 6:
11168
10650
  this._urlSwitching = true;
11169
- return _context7.abrupt("return", this.media.play(true).catch(function() {
10651
+ return _context6.abrupt("return", this.media.play(true).catch(function() {
11170
10652
  }));
11171
- case 11:
11172
- _context7.next = 13;
10653
+ case 8:
10654
+ _context6.next = 10;
11173
10655
  return this._clear();
11174
- case 13:
10656
+ case 10:
11175
10657
  setTimeout(function() {
11176
10658
  _this3._urlSwitching = true;
11177
10659
  _this3._seamlessSwitching = true;
11178
10660
  _this3._loadData(url);
11179
10661
  _this3._bufferService.seamlessSwitch();
11180
10662
  });
11181
- case 14:
10663
+ case 11:
11182
10664
  case "end":
11183
- return _context7.stop();
10665
+ return _context6.stop();
11184
10666
  }
11185
- }, _callee7, this);
10667
+ }, _callee6, this);
11186
10668
  }));
11187
10669
  function switchURL(_x6, _x7) {
11188
10670
  return _switchURL.apply(this, arguments);
@@ -11192,16 +10674,16 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
11192
10674
  }, {
11193
10675
  key: "destroy",
11194
10676
  value: function() {
11195
- var _destroy = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee8() {
11196
- return _regeneratorRuntime$1().wrap(function _callee8$(_context8) {
10677
+ var _destroy = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee7() {
10678
+ return _regeneratorRuntime$1().wrap(function _callee7$(_context7) {
11197
10679
  while (1)
11198
- switch (_context8.prev = _context8.next) {
10680
+ switch (_context7.prev = _context7.next) {
11199
10681
  case 0:
11200
10682
  if (this.media) {
11201
- _context8.next = 2;
10683
+ _context7.next = 2;
11202
10684
  break;
11203
10685
  }
11204
- return _context8.abrupt("return");
10686
+ return _context7.abrupt("return");
11205
10687
  case 2:
11206
10688
  this.removeAllListeners();
11207
10689
  this._seiService.reset();
@@ -11211,16 +10693,16 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
11211
10693
  this.media.removeEventListener("timeupdate", this._onTimeupdate);
11212
10694
  this.media.removeEventListener("waiting", this._onWaiting);
11213
10695
  this.media.removeEventListener("progress", this._onBufferUpdate);
11214
- _context8.next = 12;
10696
+ _context7.next = 12;
11215
10697
  return Promise.all([this._clear(), this._bufferService.destroy()]);
11216
10698
  case 12:
11217
10699
  this.media = null;
11218
10700
  this._bufferService = null;
11219
10701
  case 14:
11220
10702
  case "end":
11221
- return _context8.stop();
10703
+ return _context7.stop();
11222
10704
  }
11223
- }, _callee8, this);
10705
+ }, _callee7, this);
11224
10706
  }));
11225
10707
  function destroy() {
11226
10708
  return _destroy.apply(this, arguments);
@@ -11249,26 +10731,26 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
11249
10731
  }, {
11250
10732
  key: "_reset",
11251
10733
  value: function() {
11252
- var _reset2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee9() {
11253
- var reuseMse, _args9 = arguments;
11254
- return _regeneratorRuntime$1().wrap(function _callee9$(_context9) {
10734
+ var _reset2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee8() {
10735
+ var reuseMse, _args8 = arguments;
10736
+ return _regeneratorRuntime$1().wrap(function _callee8$(_context8) {
11255
10737
  while (1)
11256
- switch (_context9.prev = _context9.next) {
10738
+ switch (_context8.prev = _context8.next) {
11257
10739
  case 0:
11258
- reuseMse = _args9.length > 0 && _args9[0] !== void 0 ? _args9[0] : false;
10740
+ reuseMse = _args8.length > 0 && _args8[0] !== void 0 ? _args8[0] : false;
11259
10741
  this._seiService.reset();
11260
10742
  this._bandwidthService.reset();
11261
10743
  this._stats.reset();
11262
- _context9.next = 6;
10744
+ _context8.next = 6;
11263
10745
  return this._clear();
11264
10746
  case 6:
11265
- _context9.next = 8;
10747
+ _context8.next = 8;
11266
10748
  return this._bufferService.reset(reuseMse);
11267
10749
  case 8:
11268
10750
  case "end":
11269
- return _context9.stop();
10751
+ return _context8.stop();
11270
10752
  }
11271
- }, _callee9, this);
10753
+ }, _callee8, this);
11272
10754
  }));
11273
10755
  function _reset() {
11274
10756
  return _reset2.apply(this, arguments);
@@ -11278,17 +10760,17 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
11278
10760
  }, {
11279
10761
  key: "_loadData",
11280
10762
  value: function() {
11281
- var _loadData2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee10(url, range) {
10763
+ var _loadData2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee9(url, range) {
11282
10764
  var finnalUrl;
11283
- return _regeneratorRuntime$1().wrap(function _callee10$(_context10) {
10765
+ return _regeneratorRuntime$1().wrap(function _callee9$(_context9) {
11284
10766
  while (1)
11285
- switch (_context10.prev = _context10.next) {
10767
+ switch (_context9.prev = _context9.next) {
11286
10768
  case 0:
11287
10769
  if (url)
11288
10770
  this._opts.url = url;
11289
10771
  finnalUrl = url = this._opts.url;
11290
10772
  if (url) {
11291
- _context10.next = 4;
10773
+ _context9.next = 4;
11292
10774
  break;
11293
10775
  }
11294
10776
  throw new Error("Source url is missing");
@@ -11303,34 +10785,34 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
11303
10785
  });
11304
10786
  logger.debug("load data, loading:", this._loading, finnalUrl);
11305
10787
  if (!this._loading) {
11306
- _context10.next = 11;
10788
+ _context9.next = 11;
11307
10789
  break;
11308
10790
  }
11309
- _context10.next = 11;
10791
+ _context9.next = 11;
11310
10792
  return this._mediaLoader.cancel();
11311
10793
  case 11:
11312
10794
  this._loading = true;
11313
- _context10.prev = 12;
11314
- _context10.next = 15;
10795
+ _context9.prev = 12;
10796
+ _context9.next = 15;
11315
10797
  return this._mediaLoader.load({
11316
10798
  url: finnalUrl,
11317
10799
  range
11318
10800
  });
11319
10801
  case 15:
11320
- _context10.next = 21;
10802
+ _context9.next = 21;
11321
10803
  break;
11322
10804
  case 17:
11323
- _context10.prev = 17;
11324
- _context10.t0 = _context10["catch"](12);
10805
+ _context9.prev = 17;
10806
+ _context9.t0 = _context9["catch"](12);
11325
10807
  this._loading = false;
11326
- return _context10.abrupt("return", this._emitError(StreamingError.network(_context10.t0), false));
10808
+ return _context9.abrupt("return", this._emitError(StreamingError.network(_context9.t0), false));
11327
10809
  case 21:
11328
10810
  case "end":
11329
- return _context10.stop();
10811
+ return _context9.stop();
11330
10812
  }
11331
- }, _callee10, this, [[12, 17]]);
10813
+ }, _callee9, this, [[12, 17]]);
11332
10814
  }));
11333
- function _loadData(_x9, _x10) {
10815
+ function _loadData(_x8, _x9) {
11334
10816
  return _loadData2.apply(this, arguments);
11335
10817
  }
11336
10818
  return _loadData;
@@ -11338,16 +10820,16 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
11338
10820
  }, {
11339
10821
  key: "_clear",
11340
10822
  value: function() {
11341
- var _clear2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee11() {
11342
- return _regeneratorRuntime$1().wrap(function _callee11$(_context11) {
10823
+ var _clear2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee10() {
10824
+ return _regeneratorRuntime$1().wrap(function _callee10$(_context10) {
11343
10825
  while (1)
11344
- switch (_context11.prev = _context11.next) {
10826
+ switch (_context10.prev = _context10.next) {
11345
10827
  case 0:
11346
10828
  if (!this._mediaLoader) {
11347
- _context11.next = 3;
10829
+ _context10.next = 3;
11348
10830
  break;
11349
10831
  }
11350
- _context11.next = 3;
10832
+ _context10.next = 3;
11351
10833
  return this._mediaLoader.cancel();
11352
10834
  case 3:
11353
10835
  clearTimeout(this._maxChunkWaitTimer);
@@ -11356,9 +10838,9 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
11356
10838
  this._firstProgressEmit = false;
11357
10839
  case 7:
11358
10840
  case "end":
11359
- return _context11.stop();
10841
+ return _context10.stop();
11360
10842
  }
11361
- }, _callee11, this);
10843
+ }, _callee10, this);
11362
10844
  }));
11363
10845
  function _clear() {
11364
10846
  return _clear2.apply(this, arguments);
@@ -11445,13 +10927,9 @@ var PluginExtension = /* @__PURE__ */ function() {
11445
10927
  _createClass$4(PluginExtension2, [{
11446
10928
  key: "_init",
11447
10929
  value: function _init() {
11448
- var _this$_opts2 = this._opts, media = _this$_opts2.media, isLive = _this$_opts2.isLive, preloadTime = _this$_opts2.preloadTime, innerDegrade = _this$_opts2.innerDegrade, decodeMode = _this$_opts2.decodeMode;
10930
+ var _this$_opts2 = this._opts, media = _this$_opts2.media, preloadTime = _this$_opts2.preloadTime, innerDegrade = _this$_opts2.innerDegrade, decodeMode = _this$_opts2.decodeMode;
11449
10931
  if (!media)
11450
10932
  return;
11451
- if (!isLive && media.setPlayMode) {
11452
- media.setPlayMode("VOD");
11453
- return;
11454
- }
11455
10933
  if (innerDegrade) {
11456
10934
  media.setAttribute("innerdegrade", innerDegrade);
11457
10935
  }
@@ -11489,7 +10967,6 @@ var FlvPlugin = /* @__PURE__ */ function(_BasePlugin) {
11489
10967
  args[_key] = arguments[_key];
11490
10968
  }
11491
10969
  _this = _super.call.apply(_super, [this].concat(args));
11492
- _defineProperty$3(_assertThisInitialized$3(_this), "logger", logger);
11493
10970
  _defineProperty$3(_assertThisInitialized$3(_this), "flv", null);
11494
10971
  _defineProperty$3(_assertThisInitialized$3(_this), "pluginExtension", null);
11495
10972
  _defineProperty$3(_assertThisInitialized$3(_this), "getStats", function() {
@@ -11557,17 +11034,11 @@ var FlvPlugin = /* @__PURE__ */ function(_BasePlugin) {
11557
11034
  var _this$flv3;
11558
11035
  return (_this$flv3 = this.flv) === null || _this$flv3 === void 0 ? void 0 : _this$flv3.loader;
11559
11036
  }
11560
- }, {
11561
- key: "transferCost",
11562
- get: function get() {
11563
- return this.flv._transferCost.transferCost;
11564
- }
11565
11037
  }, {
11566
11038
  key: "beforePlayerInit",
11567
11039
  value: function beforePlayerInit() {
11568
11040
  var _this2 = this;
11569
11041
  var config = this.player.config;
11570
- var mediaElem = this.player.media || this.player.video;
11571
11042
  if (!config.url)
11572
11043
  return;
11573
11044
  if (this.flv)
@@ -11580,10 +11051,10 @@ var FlvPlugin = /* @__PURE__ */ function(_BasePlugin) {
11580
11051
  this.flv = new Flv(_objectSpread2$2({
11581
11052
  softDecode: this.softDecode,
11582
11053
  isLive: config.isLive,
11583
- media: mediaElem,
11054
+ media: this.player.video,
11584
11055
  preProcessUrl: function preProcessUrl(url, ext) {
11585
- var _this2$player, _this2$player$preProc;
11586
- 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)) || {
11056
+ var _this2$player$preProc, _this2$player;
11057
+ return ((_this2$player$preProc = (_this2$player = _this2.player).preProcessUrl) === null || _this2$player$preProc === void 0 ? void 0 : _this2$player$preProc.call(_this2$player, url, ext)) || {
11587
11058
  url,
11588
11059
  ext
11589
11060
  };
@@ -11602,8 +11073,7 @@ var FlvPlugin = /* @__PURE__ */ function(_BasePlugin) {
11602
11073
  }
11603
11074
  if (this.softDecode) {
11604
11075
  this.pluginExtension = new PluginExtension(_objectSpread2$2({
11605
- media: this.player.video,
11606
- isLive: config.isLive
11076
+ media: this.player.video
11607
11077
  }, config.flv), this);
11608
11078
  this.player.forceDegradeToVideo = function() {
11609
11079
  var _this2$pluginExtensio;
@@ -11630,7 +11100,6 @@ var FlvPlugin = /* @__PURE__ */ function(_BasePlugin) {
11630
11100
  this._transCoreEvent(EVENT.LOAD_RETRY);
11631
11101
  this._transCoreEvent(EVENT.SOURCEBUFFER_CREATED);
11632
11102
  this._transCoreEvent(EVENT.ANALYZE_DURATION_EXCEEDED);
11633
- this._transCoreEvent(EVENT.APPEND_BUFFER);
11634
11103
  this._transCoreEvent(EVENT.REMOVE_BUFFER);
11635
11104
  this._transCoreEvent(EVENT.BUFFEREOS);
11636
11105
  this._transCoreEvent(EVENT.KEYFRAME);