xgplayer-streaming-shared
Advanced tools
Comparing version 3.0.18-alpha.0 to 3.0.18-alpha.2
export class BandwidthService { | ||
/** | ||
* @typedef {{ | ||
* chunkCountForSpeed?: number, | ||
* skipChunkSize?: number | ||
* }} Opts | ||
* | ||
* @param {Opts} opts | ||
*/ | ||
constructor(opts: { | ||
chunkCountForSpeed?: number; | ||
skipChunkSize?: number; | ||
}); | ||
_chunkSpeed: number; | ||
_chunkCache: any[]; | ||
_speeds: any[]; | ||
_opts: { | ||
chunkCountForSpeed?: number; | ||
skipChunkSize?: number; | ||
}; | ||
addRecord(totalByte: any, ms: any): void; | ||
@@ -6,0 +22,0 @@ addChunkRecord(totalByte: any, ms: any): void; |
import { createClass as _createClass, classCallCheck as _classCallCheck, defineProperty as _defineProperty } from "../_virtual/_rollupPluginBabelHelpers.js"; | ||
var SKIP_SMALL_CHUNK = 1e3; | ||
var MAX_CHUNK_SAVE_SIZE = 100; | ||
var MAX_CHUNK_SAVE_SIZE = 50; | ||
var MAX_SEGMENT_SAVE_SIZE = 3; | ||
var BandwidthService = /* @__PURE__ */ function() { | ||
function BandwidthService2() { | ||
function BandwidthService2(opts) { | ||
_classCallCheck(this, BandwidthService2); | ||
@@ -11,2 +11,3 @@ _defineProperty(this, "_chunkSpeed", 0); | ||
_defineProperty(this, "_speeds", []); | ||
this._opts = opts || {}; | ||
} | ||
@@ -24,3 +25,4 @@ _createClass(BandwidthService2, [{ | ||
value: function addChunkRecord(totalByte, ms) { | ||
if (!totalByte || !ms || totalByte < SKIP_SMALL_CHUNK) | ||
var _this$_opts, _this$_opts2; | ||
if (!totalByte || !ms || totalByte < (((_this$_opts = this._opts) === null || _this$_opts === void 0 ? void 0 : _this$_opts.skipChunkSize) || SKIP_SMALL_CHUNK)) | ||
return; | ||
@@ -32,4 +34,5 @@ this._chunkSpeed = 8e3 * totalByte / ms; | ||
}); | ||
if (this._chunkCache.length > MAX_CHUNK_SAVE_SIZE) { | ||
this._chunkCache = this._chunkCache.slice(-MAX_CHUNK_SAVE_SIZE); | ||
var size = ((_this$_opts2 = this._opts) === null || _this$_opts2 === void 0 ? void 0 : _this$_opts2.chunkCountForSpeed) || MAX_CHUNK_SAVE_SIZE; | ||
if (this._chunkCache.length > size) { | ||
this._chunkCache = this._chunkCache.slice(-size); | ||
} | ||
@@ -36,0 +39,0 @@ } |
{ | ||
"name": "xgplayer-streaming-shared", | ||
"version": "3.0.18-alpha.0", | ||
"version": "3.0.18-alpha.2", | ||
"main": "dist/index.min.js", | ||
@@ -5,0 +5,0 @@ "module": "es/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
364401
4744