@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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volcengine/veplayer",
3
- "version": "2.12.1",
3
+ "version": "2.13.1-rc.0",
4
4
  "main": "./umd/veplayer.production.js",
5
5
  "module": "./esm/veplayer.production.js",
6
6
  "browser": "./umd/veplayer.production.js",
@@ -26723,7 +26723,7 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
26723
26723
  device_id: deviceId,
26724
26724
  error_report_stop: true,
26725
26725
  ext: {
26726
- veplayer_version: "2.3.0",
26726
+ veplayer_version: "2.3.1-rc.1",
26727
26727
  flv_version: "3.0.24-rc.6",
26728
26728
  hls_version: "3.0.24-rc.2",
26729
26729
  rts_version: "0.2.1-alpha.64"
@@ -26737,7 +26737,6 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
26737
26737
  return transform ? transform(value) : value.toString();
26738
26738
  }
26739
26739
  function getDefaultRow(data2) {
26740
- var _a;
26741
26740
  return {
26742
26741
  rows: [
26743
26742
  {
@@ -26778,7 +26777,10 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
26778
26777
  {
26779
26778
  key: "bufferEnd",
26780
26779
  labelTextKey: "BUFFER_END",
26781
- value: normalizeNumber(Number((_a = data2.bufferEnd) == null ? void 0 : _a.toFixed(2)))
26780
+ value: normalizeNumber(
26781
+ data2.bufferEnd,
26782
+ (value) => Number(value.toFixed(2)).toString()
26783
+ )
26782
26784
  },
26783
26785
  {
26784
26786
  key: "currentTime",
@@ -51020,6 +51022,79 @@ Radeong 0.4 on AMD TAHITI (DRM 2.43.0, LLVM 3.9.0)|-1
51020
51022
  }
51021
51023
  }
51022
51024
  const liveVeStrategy = new LiveVeStrategy();
51025
+ const isNumber = (value) => typeof value === "number" && Number.isFinite(value);
51026
+ const getTimestamp = (delaySEI, currentKey, legacyKey) => {
51027
+ const currentValue = delaySEI[currentKey];
51028
+ if (isNumber(currentValue)) {
51029
+ return currentValue;
51030
+ }
51031
+ const legacyValue = delaySEI[legacyKey];
51032
+ return isNumber(legacyValue) ? legacyValue : void 0;
51033
+ };
51034
+ const utf8ArrayToString = (array) => {
51035
+ let result = "";
51036
+ let index = 0;
51037
+ while (index < array.length) {
51038
+ const first = array[index++];
51039
+ if (first < 128) {
51040
+ result += String.fromCharCode(first);
51041
+ } else if (first < 224) {
51042
+ const second = array[index++];
51043
+ result += String.fromCharCode((first & 31) << 6 | second & 63);
51044
+ } else {
51045
+ const second = array[index++];
51046
+ const third = array[index++];
51047
+ result += String.fromCharCode(
51048
+ (first & 15) << 12 | (second & 63) << 6 | third & 63
51049
+ );
51050
+ }
51051
+ }
51052
+ return result;
51053
+ };
51054
+ const getSEIDelayStats = (sei, bufferTime = 0, now3 = Date.now()) => {
51055
+ if ((sei == null ? void 0 : sei.code) !== 100 || !sei.content) {
51056
+ return;
51057
+ }
51058
+ try {
51059
+ const rawSEI = utf8ArrayToString(sei.content);
51060
+ const jsonStart = rawSEI.indexOf("{");
51061
+ const jsonEnd = rawSEI.lastIndexOf("}");
51062
+ if (jsonStart < 0 || jsonEnd < jsonStart) {
51063
+ return;
51064
+ }
51065
+ const seiContent = JSON.parse(rawSEI.slice(jsonStart, jsonEnd + 1));
51066
+ const delaySEI = seiContent == null ? void 0 : seiContent.video_e2e_delay;
51067
+ if (!delaySEI || typeof delaySEI !== "object") {
51068
+ return;
51069
+ }
51070
+ const push3 = getTimestamp(delaySEI, "push_edge_ts", "push_node");
51071
+ const source = getTimestamp(delaySEI, "source_ts", "source_node");
51072
+ const cmafSource = getTimestamp(
51073
+ delaySEI,
51074
+ "cmaf_source_ts",
51075
+ "cmaf_source_node"
51076
+ );
51077
+ const hlsSource = getTimestamp(
51078
+ delaySEI,
51079
+ "hls_source_ts",
51080
+ "hls_source_node"
51081
+ );
51082
+ const pull = getTimestamp(delaySEI, "pull_edge_ts", "pull_node");
51083
+ const start = push3 ?? source;
51084
+ const end = pull ?? hlsSource ?? cmafSource;
51085
+ if (!isNumber(start) || !isNumber(end)) {
51086
+ return;
51087
+ }
51088
+ const delayS2S = end - start;
51089
+ const safeBufferTime = isNumber(bufferTime) ? Math.max(0, bufferTime) : 0;
51090
+ return {
51091
+ delay_s2s: delayS2S,
51092
+ delay_s2e: delayS2S + Math.max(0, now3 - end) + safeBufferTime
51093
+ };
51094
+ } catch (e2) {
51095
+ return;
51096
+ }
51097
+ };
51023
51098
  const DEFAULT_PLUGINS = window["VePlayer"].DEFAULT_PLUGINS;
51024
51099
  const VePlayerBase = window["VePlayer"].VePlayerBase;
51025
51100
  const VeI18n = window["VePlayer"].VeI18n;
@@ -51062,6 +51137,22 @@ Radeong 0.4 on AMD TAHITI (DRM 2.43.0, LLVM 3.9.0)|-1
51062
51137
  * @hidden
51063
51138
  */
51064
51139
  __publicField(this, "_protocolManager");
51140
+ __publicField(this, "_seiDelayStats", {});
51141
+ __publicField(this, "_resetSEIDelayStats", () => {
51142
+ this._seiDelayStats = {};
51143
+ });
51144
+ __publicField(this, "_handleSEI", (data2) => {
51145
+ const stats = getSEIDelayStats(data2 == null ? void 0 : data2.sei, this._getPlayerBufferTime());
51146
+ if (stats) {
51147
+ this._seiDelayStats = stats;
51148
+ }
51149
+ });
51150
+ this.on(Events$1.SEI, this._handleSEI);
51151
+ this.on(Events$1.URL_CHANGE, this._resetSEIDelayStats);
51152
+ this.on(Events$1.SOURCE_CHANGE, this._resetSEIDelayStats);
51153
+ this.on(Events$1.DEFINITION_CHANGE, this._resetSEIDelayStats);
51154
+ this.on(Events$1.REPLAY, this._resetSEIDelayStats);
51155
+ this.on(Events$1.FALLBACK, this._resetSEIDelayStats);
51065
51156
  }
51066
51157
  /** {zh}
51067
51158
  * @brief 获取已经播放的时长,不包含暂停和等待时间,单位为秒。
@@ -51103,6 +51194,22 @@ Radeong 0.4 on AMD TAHITI (DRM 2.43.0, LLVM 3.9.0)|-1
51103
51194
  var _a, _b;
51104
51195
  return (_b = (_a = this._player.plugins) == null ? void 0 : _a.hls) == null ? void 0 : _b.hls;
51105
51196
  }
51197
+ /** {zh}
51198
+ * @hidden
51199
+ */
51200
+ /** {en}
51201
+ * @hidden
51202
+ */
51203
+ destroy() {
51204
+ this.off(Events$1.SEI, this._handleSEI);
51205
+ this.off(Events$1.URL_CHANGE, this._resetSEIDelayStats);
51206
+ this.off(Events$1.SOURCE_CHANGE, this._resetSEIDelayStats);
51207
+ this.off(Events$1.DEFINITION_CHANGE, this._resetSEIDelayStats);
51208
+ this.off(Events$1.REPLAY, this._resetSEIDelayStats);
51209
+ this.off(Events$1.FALLBACK, this._resetSEIDelayStats);
51210
+ this._resetSEIDelayStats();
51211
+ super.destroy();
51212
+ }
51106
51213
  /** {zh}
51107
51214
  * @brief 调用此方法开启直播日志上报。
51108
51215
  */
@@ -51239,7 +51346,8 @@ Radeong 0.4 on AMD TAHITI (DRM 2.43.0, LLVM 3.9.0)|-1
51239
51346
  */
51240
51347
  async getRTMStats() {
51241
51348
  var _a, _b, _c;
51242
- return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.rts) == null ? void 0 : _c.getStatsSnapshoot();
51349
+ const stats = await ((_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.rts) == null ? void 0 : _c.getStatsSnapshoot());
51350
+ return this._mergeSEIDelayStats(stats);
51243
51351
  }
51244
51352
  /** {zh}
51245
51353
  * @brief 获取 FLV 拉流的播放信息。
@@ -51250,7 +51358,8 @@ Radeong 0.4 on AMD TAHITI (DRM 2.43.0, LLVM 3.9.0)|-1
51250
51358
  */
51251
51359
  getFLVStats() {
51252
51360
  var _a, _b, _c;
51253
- return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.flv) == null ? void 0 : _c.getStats();
51361
+ const stats = (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.flv) == null ? void 0 : _c.getStats();
51362
+ return this._mergeSEIDelayStats(stats);
51254
51363
  }
51255
51364
  /** {zh}
51256
51365
  * @brief 获取 HLS 拉流的播放信息。
@@ -51262,8 +51371,9 @@ Radeong 0.4 on AMD TAHITI (DRM 2.43.0, LLVM 3.9.0)|-1
51262
51371
  * @hidden
51263
51372
  */
51264
51373
  getHLSStats() {
51265
- var _a, _b, _c;
51266
- return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.hls) == null ? void 0 : _c.getStats();
51374
+ var _a, _b, _c, _d;
51375
+ 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)) ?? {};
51376
+ return this._mergeSEIDelayStats(stats);
51267
51377
  }
51268
51378
  /** {en}
51269
51379
  * @brief This method is used to update the playlist, supporting updates to source, resolution, and related information.
@@ -51291,6 +51401,40 @@ Radeong 0.4 on AMD TAHITI (DRM 2.43.0, LLVM 3.9.0)|-1
51291
51401
  }
51292
51402
  return super.updatePlaylist(playlist, target);
51293
51403
  }
51404
+ _getPlayerBufferTime() {
51405
+ var _a, _b, _c, _d, _e2;
51406
+ try {
51407
+ 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);
51408
+ if (rtm) {
51409
+ const jitterBufferDelay = rtm.jitterBufferDelay;
51410
+ if (Number.isFinite(jitterBufferDelay) && jitterBufferDelay >= 0) {
51411
+ return jitterBufferDelay;
51412
+ }
51413
+ }
51414
+ } catch (e2) {
51415
+ }
51416
+ const video = (_e2 = this._player) == null ? void 0 : _e2.video;
51417
+ const buffered = video == null ? void 0 : video.buffered;
51418
+ if (!video || !(buffered == null ? void 0 : buffered.length)) {
51419
+ return 0;
51420
+ }
51421
+ try {
51422
+ return Math.trunc(
51423
+ (buffered.end(buffered.length - 1) - video.currentTime) * 1e3
51424
+ );
51425
+ } catch (e2) {
51426
+ return 0;
51427
+ }
51428
+ }
51429
+ _mergeSEIDelayStats(stats) {
51430
+ if (!stats) {
51431
+ return stats;
51432
+ }
51433
+ return {
51434
+ ...stats,
51435
+ ...this._seiDelayStats
51436
+ };
51437
+ }
51294
51438
  }
51295
51439
  async function createLivePlayer(options) {
51296
51440
  var _a, _b, _c, _d, _e2, _f, _g, _h, _i2, _j, _k;
@@ -51323,6 +51467,10 @@ Radeong 0.4 on AMD TAHITI (DRM 2.43.0, LLVM 3.9.0)|-1
51323
51467
  playerOptions,
51324
51468
  recommendation
51325
51469
  );
51470
+ finalOptions.rtm = {
51471
+ enableSei: true,
51472
+ ...finalOptions.rtm
51473
+ };
51326
51474
  await liveLicenseManager.create();
51327
51475
  const licenseFatalError = liveLicenseManager.getLicenseFatalError();
51328
51476
  const protocolManager = await ProtocolManager.create(finalOptions);
@@ -51426,7 +51574,7 @@ Radeong 0.4 on AMD TAHITI (DRM 2.43.0, LLVM 3.9.0)|-1
51426
51574
  }
51427
51575
  await ((_a = liveVeStrategy.veStrategyManager) == null ? void 0 : _a.init({
51428
51576
  ...options,
51429
- playerVersion: "2.3.0",
51577
+ playerVersion: "2.3.1-rc.1",
51430
51578
  type: "LIVE"
51431
51579
  }));
51432
51580
  return liveVeStrategy.veStrategyManager;