@volcengine/veplayer 2.12.1 → 2.13.1-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.
@@ -14715,7 +14715,7 @@ var __publicField = (obj, key, value) => {
14715
14715
  * @brief Retrieve the player SDK version number.
14716
14716
  */
14717
14717
  get playerVersion() {
14718
- return "2.12.1";
14718
+ return "2.13.1-rc.0";
14719
14719
  }
14720
14720
  /** {zh}
14721
14721
  * @brief 获取当前播放视频的清晰度唯一标识(definition)。
@@ -56510,7 +56510,7 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
56510
56510
  device_id: deviceId,
56511
56511
  error_report_stop: true,
56512
56512
  ext: {
56513
- veplayer_version: "2.12.1",
56513
+ veplayer_version: "2.13.1-rc.0",
56514
56514
  flv_version: "3.0.24-rc.6",
56515
56515
  hls_version: "3.0.24-rc.2",
56516
56516
  rts_version: "0.2.1-alpha.64"
@@ -56524,7 +56524,6 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
56524
56524
  return transform2 ? transform2(value) : value.toString();
56525
56525
  }
56526
56526
  function getDefaultRow(data2) {
56527
- var _a;
56528
56527
  return {
56529
56528
  rows: [
56530
56529
  {
@@ -56565,7 +56564,10 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
56565
56564
  {
56566
56565
  key: "bufferEnd",
56567
56566
  labelTextKey: "BUFFER_END",
56568
- value: normalizeNumber(Number((_a = data2.bufferEnd) == null ? void 0 : _a.toFixed(2)))
56567
+ value: normalizeNumber(
56568
+ data2.bufferEnd,
56569
+ (value) => Number(value.toFixed(2)).toString()
56570
+ )
56569
56571
  },
56570
56572
  {
56571
56573
  key: "currentTime",
@@ -73913,6 +73915,79 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
73913
73915
  }
73914
73916
  }
73915
73917
  const liveVeStrategy = new LiveVeStrategy();
73918
+ const isNumber = (value) => typeof value === "number" && Number.isFinite(value);
73919
+ const getTimestamp = (delaySEI, currentKey, legacyKey) => {
73920
+ const currentValue = delaySEI[currentKey];
73921
+ if (isNumber(currentValue)) {
73922
+ return currentValue;
73923
+ }
73924
+ const legacyValue = delaySEI[legacyKey];
73925
+ return isNumber(legacyValue) ? legacyValue : void 0;
73926
+ };
73927
+ const utf8ArrayToString = (array) => {
73928
+ let result = "";
73929
+ let index = 0;
73930
+ while (index < array.length) {
73931
+ const first = array[index++];
73932
+ if (first < 128) {
73933
+ result += String.fromCharCode(first);
73934
+ } else if (first < 224) {
73935
+ const second = array[index++];
73936
+ result += String.fromCharCode((first & 31) << 6 | second & 63);
73937
+ } else {
73938
+ const second = array[index++];
73939
+ const third = array[index++];
73940
+ result += String.fromCharCode(
73941
+ (first & 15) << 12 | (second & 63) << 6 | third & 63
73942
+ );
73943
+ }
73944
+ }
73945
+ return result;
73946
+ };
73947
+ const getSEIDelayStats = (sei, bufferTime = 0, now3 = Date.now()) => {
73948
+ if ((sei == null ? void 0 : sei.code) !== 100 || !sei.content) {
73949
+ return;
73950
+ }
73951
+ try {
73952
+ const rawSEI = utf8ArrayToString(sei.content);
73953
+ const jsonStart = rawSEI.indexOf("{");
73954
+ const jsonEnd = rawSEI.lastIndexOf("}");
73955
+ if (jsonStart < 0 || jsonEnd < jsonStart) {
73956
+ return;
73957
+ }
73958
+ const seiContent = JSON.parse(rawSEI.slice(jsonStart, jsonEnd + 1));
73959
+ const delaySEI = seiContent == null ? void 0 : seiContent.video_e2e_delay;
73960
+ if (!delaySEI || typeof delaySEI !== "object") {
73961
+ return;
73962
+ }
73963
+ const push3 = getTimestamp(delaySEI, "push_edge_ts", "push_node");
73964
+ const source = getTimestamp(delaySEI, "source_ts", "source_node");
73965
+ const cmafSource = getTimestamp(
73966
+ delaySEI,
73967
+ "cmaf_source_ts",
73968
+ "cmaf_source_node"
73969
+ );
73970
+ const hlsSource = getTimestamp(
73971
+ delaySEI,
73972
+ "hls_source_ts",
73973
+ "hls_source_node"
73974
+ );
73975
+ const pull = getTimestamp(delaySEI, "pull_edge_ts", "pull_node");
73976
+ const start = push3 ?? source;
73977
+ const end = pull ?? hlsSource ?? cmafSource;
73978
+ if (!isNumber(start) || !isNumber(end)) {
73979
+ return;
73980
+ }
73981
+ const delayS2S = end - start;
73982
+ const safeBufferTime = isNumber(bufferTime) ? Math.max(0, bufferTime) : 0;
73983
+ return {
73984
+ delay_s2s: delayS2S,
73985
+ delay_s2e: delayS2S + Math.max(0, now3 - end) + safeBufferTime
73986
+ };
73987
+ } catch (e2) {
73988
+ return;
73989
+ }
73990
+ };
73916
73991
  VeI18n.extend([
73917
73992
  {
73918
73993
  LANG: "zh-cn",
@@ -73951,6 +74026,22 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
73951
74026
  * @hidden
73952
74027
  */
73953
74028
  __publicField(this, "_protocolManager");
74029
+ __publicField(this, "_seiDelayStats", {});
74030
+ __publicField(this, "_resetSEIDelayStats", () => {
74031
+ this._seiDelayStats = {};
74032
+ });
74033
+ __publicField(this, "_handleSEI", (data2) => {
74034
+ const stats = getSEIDelayStats(data2 == null ? void 0 : data2.sei, this._getPlayerBufferTime());
74035
+ if (stats) {
74036
+ this._seiDelayStats = stats;
74037
+ }
74038
+ });
74039
+ this.on(Events.SEI, this._handleSEI);
74040
+ this.on(Events.URL_CHANGE, this._resetSEIDelayStats);
74041
+ this.on(Events.SOURCE_CHANGE, this._resetSEIDelayStats);
74042
+ this.on(Events.DEFINITION_CHANGE, this._resetSEIDelayStats);
74043
+ this.on(Events.REPLAY, this._resetSEIDelayStats);
74044
+ this.on(Events.FALLBACK, this._resetSEIDelayStats);
73954
74045
  }
73955
74046
  /** {zh}
73956
74047
  * @brief 获取已经播放的时长,不包含暂停和等待时间,单位为秒。
@@ -73992,6 +74083,22 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
73992
74083
  var _a, _b;
73993
74084
  return (_b = (_a = this._player.plugins) == null ? void 0 : _a.hls) == null ? void 0 : _b.hls;
73994
74085
  }
74086
+ /** {zh}
74087
+ * @hidden
74088
+ */
74089
+ /** {en}
74090
+ * @hidden
74091
+ */
74092
+ destroy() {
74093
+ this.off(Events.SEI, this._handleSEI);
74094
+ this.off(Events.URL_CHANGE, this._resetSEIDelayStats);
74095
+ this.off(Events.SOURCE_CHANGE, this._resetSEIDelayStats);
74096
+ this.off(Events.DEFINITION_CHANGE, this._resetSEIDelayStats);
74097
+ this.off(Events.REPLAY, this._resetSEIDelayStats);
74098
+ this.off(Events.FALLBACK, this._resetSEIDelayStats);
74099
+ this._resetSEIDelayStats();
74100
+ super.destroy();
74101
+ }
73995
74102
  /** {zh}
73996
74103
  * @brief 调用此方法开启直播日志上报。
73997
74104
  */
@@ -74128,7 +74235,8 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
74128
74235
  */
74129
74236
  async getRTMStats() {
74130
74237
  var _a, _b, _c;
74131
- return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.rts) == null ? void 0 : _c.getStatsSnapshoot();
74238
+ const stats = await ((_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.rts) == null ? void 0 : _c.getStatsSnapshoot());
74239
+ return this._mergeSEIDelayStats(stats);
74132
74240
  }
74133
74241
  /** {zh}
74134
74242
  * @brief 获取 FLV 拉流的播放信息。
@@ -74139,7 +74247,8 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
74139
74247
  */
74140
74248
  getFLVStats() {
74141
74249
  var _a, _b, _c;
74142
- return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.flv) == null ? void 0 : _c.getStats();
74250
+ const stats = (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.flv) == null ? void 0 : _c.getStats();
74251
+ return this._mergeSEIDelayStats(stats);
74143
74252
  }
74144
74253
  /** {zh}
74145
74254
  * @brief 获取 HLS 拉流的播放信息。
@@ -74151,8 +74260,9 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
74151
74260
  * @hidden
74152
74261
  */
74153
74262
  getHLSStats() {
74154
- var _a, _b, _c;
74155
- return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.hls) == null ? void 0 : _c.getStats();
74263
+ var _a, _b, _c, _d;
74264
+ const stats = ((_d = (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.hls) == null ? void 0 : _c.getStats) == null ? void 0 : _d.call(_c)) ?? {};
74265
+ return this._mergeSEIDelayStats(stats);
74156
74266
  }
74157
74267
  /** {en}
74158
74268
  * @brief This method is used to update the playlist, supporting updates to source, resolution, and related information.
@@ -74180,6 +74290,40 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
74180
74290
  }
74181
74291
  return super.updatePlaylist(playlist, target);
74182
74292
  }
74293
+ _getPlayerBufferTime() {
74294
+ var _a, _b, _c, _d, _e2;
74295
+ try {
74296
+ const rtm = ((_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.rts) ?? ((_d = (_c = this._player) == null ? void 0 : _c.plugins) == null ? void 0 : _d.rtm);
74297
+ if (rtm) {
74298
+ const jitterBufferDelay = rtm.jitterBufferDelay;
74299
+ if (Number.isFinite(jitterBufferDelay) && jitterBufferDelay >= 0) {
74300
+ return jitterBufferDelay;
74301
+ }
74302
+ }
74303
+ } catch (e2) {
74304
+ }
74305
+ const video = (_e2 = this._player) == null ? void 0 : _e2.video;
74306
+ const buffered = video == null ? void 0 : video.buffered;
74307
+ if (!video || !(buffered == null ? void 0 : buffered.length)) {
74308
+ return 0;
74309
+ }
74310
+ try {
74311
+ return Math.trunc(
74312
+ (buffered.end(buffered.length - 1) - video.currentTime) * 1e3
74313
+ );
74314
+ } catch (e2) {
74315
+ return 0;
74316
+ }
74317
+ }
74318
+ _mergeSEIDelayStats(stats) {
74319
+ if (!stats) {
74320
+ return stats;
74321
+ }
74322
+ return {
74323
+ ...stats,
74324
+ ...this._seiDelayStats
74325
+ };
74326
+ }
74183
74327
  }
74184
74328
  async function createLivePlayer(options) {
74185
74329
  var _a, _b, _c, _d, _e2, _f, _g, _h, _i2, _j, _k;
@@ -74212,6 +74356,10 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
74212
74356
  playerOptions,
74213
74357
  recommendation
74214
74358
  );
74359
+ finalOptions.rtm = {
74360
+ enableSei: true,
74361
+ ...finalOptions.rtm
74362
+ };
74215
74363
  await liveLicenseManager.create();
74216
74364
  const licenseFatalError = liveLicenseManager.getLicenseFatalError();
74217
74365
  const protocolManager = await ProtocolManager.create(finalOptions);
@@ -74315,7 +74463,7 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
74315
74463
  }
74316
74464
  await ((_a = liveVeStrategy.veStrategyManager) == null ? void 0 : _a.init({
74317
74465
  ...options,
74318
- playerVersion: "2.12.1",
74466
+ playerVersion: "2.13.1-rc.0",
74319
74467
  type: "LIVE"
74320
74468
  }));
74321
74469
  return liveVeStrategy.veStrategyManager;