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