@volcengine/veplayer-plugin 2.4.0-rc.0 → 2.4.0-rc.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volcengine/veplayer-plugin",
3
- "version": "2.4.0-rc.0",
3
+ "version": "2.4.0-rc.2",
4
4
  "main": "./umd/index.production.js",
5
5
  "module": "./esm/index.production.js",
6
6
  "browser": "./umd/index.production.js",
package/umd/index.d.ts CHANGED
@@ -6,3 +6,4 @@ export const shaka: any;
6
6
  export const xgvideo: any;
7
7
  export const timeShift: any;
8
8
  export const drm: any;
9
+ export const abr: any;
@@ -5043,11 +5043,17 @@
5043
5043
  }]);
5044
5044
  return SeiService2;
5045
5045
  }();
5046
+ var SKIP_SMALL_CHUNK = 1e3;
5047
+ var MAX_CHUNK_SAVE_SIZE = 50;
5048
+ var MAX_SEGMENT_SAVE_SIZE = 3;
5049
+ var LONGTIME_NO_RECEIVE = 3e3;
5046
5050
  var BandwidthService = /* @__PURE__ */ function() {
5047
- function BandwidthService2() {
5051
+ function BandwidthService2(opts) {
5048
5052
  _classCallCheck$2(this, BandwidthService2);
5049
- _defineProperty$1(this, "_chunkSpeeds", []);
5053
+ _defineProperty$1(this, "_chunkSpeed", 0);
5054
+ _defineProperty$1(this, "_chunkCache", []);
5050
5055
  _defineProperty$1(this, "_speeds", []);
5056
+ this._opts = opts || {};
5051
5057
  }
5052
5058
  _createClass$2(BandwidthService2, [{
5053
5059
  key: "addRecord",
@@ -5055,44 +5061,67 @@
5055
5061
  if (!totalByte || !ms)
5056
5062
  return;
5057
5063
  this._speeds.push(8e3 * totalByte / ms);
5058
- this._speeds = this._speeds.slice(-3);
5064
+ this._speeds = this._speeds.slice(-MAX_SEGMENT_SAVE_SIZE);
5059
5065
  }
5060
5066
  }, {
5061
5067
  key: "addChunkRecord",
5062
5068
  value: function addChunkRecord(totalByte, ms) {
5063
- if (!totalByte || !ms)
5069
+ var _this$_opts, _this$_opts2;
5070
+ if (!totalByte || !ms || totalByte < (((_this$_opts = this._opts) === null || _this$_opts === void 0 ? void 0 : _this$_opts.skipChunkSize) || SKIP_SMALL_CHUNK))
5064
5071
  return;
5065
- this._chunkSpeeds.push(8e3 * totalByte / ms);
5066
- this._chunkSpeeds = this._chunkSpeeds.slice(-100);
5072
+ this._chunkSpeed = 8e3 * totalByte / ms;
5073
+ this._chunkCache.push({
5074
+ size: totalByte,
5075
+ duration: ms,
5076
+ timestamp: performance.now()
5077
+ });
5078
+ var size = ((_this$_opts2 = this._opts) === null || _this$_opts2 === void 0 ? void 0 : _this$_opts2.chunkCountForSpeed) || MAX_CHUNK_SAVE_SIZE;
5079
+ if (this._chunkCache.length > size) {
5080
+ this._chunkCache = this._chunkCache.slice(-size);
5081
+ }
5067
5082
  }
5068
5083
  }, {
5069
5084
  key: "getAvgSpeed",
5070
5085
  value: function getAvgSpeed() {
5071
- if (!this._chunkSpeeds.length && !this._speeds.length)
5086
+ var _this$_opts3;
5087
+ if (!this._chunkCache.length && !this._speeds.length)
5072
5088
  return 0;
5073
5089
  if (this._speeds.length) {
5074
5090
  return this._speeds.reduce(function(a, c) {
5075
5091
  return a += c;
5076
5092
  }) / this._speeds.length;
5077
5093
  }
5078
- return this._chunkSpeeds.reduce(function(a, c) {
5079
- return a += c;
5080
- }) / this._chunkSpeeds.length;
5094
+ var lastSample = this._chunkCache[this._chunkCache.length - 1];
5095
+ var cost = performance.now() - lastSample.timestamp;
5096
+ if (cost > (((_this$_opts3 = this._opts) === null || _this$_opts3 === void 0 ? void 0 : _this$_opts3.longtimeNoReceived) || LONGTIME_NO_RECEIVE)) {
5097
+ this._chunkCache.push({
5098
+ size: 0,
5099
+ duration: cost,
5100
+ timestamp: performance.now()
5101
+ });
5102
+ }
5103
+ var totalSize = this._chunkCache.reduce(function(a, c) {
5104
+ return a += c.size;
5105
+ }, 0);
5106
+ var totalDuration = this._chunkCache.reduce(function(a, c) {
5107
+ return a += c.duration;
5108
+ }, 0);
5109
+ return 8e3 * totalSize / totalDuration;
5081
5110
  }
5082
5111
  }, {
5083
5112
  key: "getLatestSpeed",
5084
5113
  value: function getLatestSpeed() {
5085
- if (!this._chunkSpeeds.length && !this._speeds.length)
5114
+ if (!this._chunkCache.length && !this._speeds.length)
5086
5115
  return 0;
5087
5116
  if (this._speeds.length) {
5088
5117
  return this._speeds[this._speeds.length - 1];
5089
5118
  }
5090
- return this._chunkSpeeds[this._chunkSpeeds.length - 1];
5119
+ return this._chunkSpeed;
5091
5120
  }
5092
5121
  }, {
5093
5122
  key: "reset",
5094
5123
  value: function reset() {
5095
- this._chunkSpeeds = [];
5124
+ this._chunkCache = [];
5096
5125
  this._speeds = [];
5097
5126
  }
5098
5127
  }]);
@@ -10028,7 +10057,10 @@
10028
10057
  onlyAudio: false,
10029
10058
  preferMMS: false,
10030
10059
  mseLowLatency: true,
10031
- durationForMSELowLatencyOff: 6
10060
+ durationForMSELowLatencyOff: 6,
10061
+ chunkCountForSpeed: 50,
10062
+ skipChunkSize: 1e3,
10063
+ longtimeNoReceived: 3e3
10032
10064
  }, opts);
10033
10065
  if (ret.isLive) {
10034
10066
  if (ret.preloadTime) {
@@ -10186,7 +10218,7 @@
10186
10218
  return _context.abrupt("return");
10187
10219
  case 40:
10188
10220
  maxReaderInterval = _this._opts.maxReaderInterval;
10189
- if (maxReaderInterval) {
10221
+ if (maxReaderInterval && _this._firstProgressEmit) {
10190
10222
  clearTimeout(_this._maxChunkWaitTimer);
10191
10223
  _this._maxChunkWaitTimer = setTimeout(function() {
10192
10224
  if (_this._disconnectRetryCount) {
@@ -10398,7 +10430,11 @@
10398
10430
  _this._disconnectRetryCount = _this._opts.disconnectRetryCount;
10399
10431
  _this._bufferService = new BufferService(_assertThisInitialized$3(_this), _this._opts.softDecode ? _this.media : void 0, _this._opts);
10400
10432
  _this._seiService = new SeiService(_assertThisInitialized$3(_this));
10401
- _this._bandwidthService = new BandwidthService();
10433
+ _this._bandwidthService = new BandwidthService({
10434
+ chunkCountForSpeed: _this._opts.chunkCountForSpeed,
10435
+ skipChunkSize: _this._opts.skipChunkSize,
10436
+ longtimeNoReceived: _this._opts.longtimeNoReceived
10437
+ });
10402
10438
  _this._stats = new MediaStatsService(_assertThisInitialized$3(_this));
10403
10439
  if (!_this._opts.softDecode) {
10404
10440
  _this._gapService = new GapService();
@@ -10415,7 +10451,7 @@
10415
10451
  _createClass$4(Flv2, [{
10416
10452
  key: "version",
10417
10453
  get: function get() {
10418
- return "3.0.17";
10454
+ return "3.0.18-alpha.3";
10419
10455
  }
10420
10456
  }, {
10421
10457
  key: "isLive",