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