@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.
@@ -14711,7 +14711,7 @@ class VePlayerBase {
14711
14711
  * @brief Retrieve the player SDK version number.
14712
14712
  */
14713
14713
  get playerVersion() {
14714
- return "2.12.1";
14714
+ return "2.13.1-rc.0";
14715
14715
  }
14716
14716
  /** {zh}
14717
14717
  * @brief 获取当前播放视频的清晰度唯一标识(definition)。
@@ -56506,7 +56506,7 @@ let Logger$1 = class Logger2 extends Plugin {
56506
56506
  device_id: deviceId,
56507
56507
  error_report_stop: true,
56508
56508
  ext: {
56509
- veplayer_version: "2.12.1",
56509
+ veplayer_version: "2.13.1-rc.0",
56510
56510
  flv_version: "3.0.24-rc.6",
56511
56511
  hls_version: "3.0.24-rc.2",
56512
56512
  rts_version: "0.2.1-alpha.64"
@@ -56520,7 +56520,6 @@ function normalizeNumber(value, transform2) {
56520
56520
  return transform2 ? transform2(value) : value.toString();
56521
56521
  }
56522
56522
  function getDefaultRow(data2) {
56523
- var _a;
56524
56523
  return {
56525
56524
  rows: [
56526
56525
  {
@@ -56561,7 +56560,10 @@ function getDefaultRow(data2) {
56561
56560
  {
56562
56561
  key: "bufferEnd",
56563
56562
  labelTextKey: "BUFFER_END",
56564
- value: normalizeNumber(Number((_a = data2.bufferEnd) == null ? void 0 : _a.toFixed(2)))
56563
+ value: normalizeNumber(
56564
+ data2.bufferEnd,
56565
+ (value) => Number(value.toFixed(2)).toString()
56566
+ )
56565
56567
  },
56566
56568
  {
56567
56569
  key: "currentTime",
@@ -73908,6 +73910,79 @@ class LiveVeStrategy {
73908
73910
  }
73909
73911
  }
73910
73912
  const liveVeStrategy = new LiveVeStrategy();
73913
+ const isNumber = (value) => typeof value === "number" && Number.isFinite(value);
73914
+ const getTimestamp = (delaySEI, currentKey, legacyKey) => {
73915
+ const currentValue = delaySEI[currentKey];
73916
+ if (isNumber(currentValue)) {
73917
+ return currentValue;
73918
+ }
73919
+ const legacyValue = delaySEI[legacyKey];
73920
+ return isNumber(legacyValue) ? legacyValue : void 0;
73921
+ };
73922
+ const utf8ArrayToString = (array) => {
73923
+ let result = "";
73924
+ let index = 0;
73925
+ while (index < array.length) {
73926
+ const first = array[index++];
73927
+ if (first < 128) {
73928
+ result += String.fromCharCode(first);
73929
+ } else if (first < 224) {
73930
+ const second = array[index++];
73931
+ result += String.fromCharCode((first & 31) << 6 | second & 63);
73932
+ } else {
73933
+ const second = array[index++];
73934
+ const third = array[index++];
73935
+ result += String.fromCharCode(
73936
+ (first & 15) << 12 | (second & 63) << 6 | third & 63
73937
+ );
73938
+ }
73939
+ }
73940
+ return result;
73941
+ };
73942
+ const getSEIDelayStats = (sei, bufferTime = 0, now3 = Date.now()) => {
73943
+ if ((sei == null ? void 0 : sei.code) !== 100 || !sei.content) {
73944
+ return;
73945
+ }
73946
+ try {
73947
+ const rawSEI = utf8ArrayToString(sei.content);
73948
+ const jsonStart = rawSEI.indexOf("{");
73949
+ const jsonEnd = rawSEI.lastIndexOf("}");
73950
+ if (jsonStart < 0 || jsonEnd < jsonStart) {
73951
+ return;
73952
+ }
73953
+ const seiContent = JSON.parse(rawSEI.slice(jsonStart, jsonEnd + 1));
73954
+ const delaySEI = seiContent == null ? void 0 : seiContent.video_e2e_delay;
73955
+ if (!delaySEI || typeof delaySEI !== "object") {
73956
+ return;
73957
+ }
73958
+ const push3 = getTimestamp(delaySEI, "push_edge_ts", "push_node");
73959
+ const source = getTimestamp(delaySEI, "source_ts", "source_node");
73960
+ const cmafSource = getTimestamp(
73961
+ delaySEI,
73962
+ "cmaf_source_ts",
73963
+ "cmaf_source_node"
73964
+ );
73965
+ const hlsSource = getTimestamp(
73966
+ delaySEI,
73967
+ "hls_source_ts",
73968
+ "hls_source_node"
73969
+ );
73970
+ const pull = getTimestamp(delaySEI, "pull_edge_ts", "pull_node");
73971
+ const start = push3 ?? source;
73972
+ const end = pull ?? hlsSource ?? cmafSource;
73973
+ if (!isNumber(start) || !isNumber(end)) {
73974
+ return;
73975
+ }
73976
+ const delayS2S = end - start;
73977
+ const safeBufferTime = isNumber(bufferTime) ? Math.max(0, bufferTime) : 0;
73978
+ return {
73979
+ delay_s2s: delayS2S,
73980
+ delay_s2e: delayS2S + Math.max(0, now3 - end) + safeBufferTime
73981
+ };
73982
+ } catch (e2) {
73983
+ return;
73984
+ }
73985
+ };
73911
73986
  VeI18n.extend([
73912
73987
  {
73913
73988
  LANG: "zh-cn",
@@ -73946,6 +74021,22 @@ class VePlayerLive extends VePlayerBase {
73946
74021
  * @hidden
73947
74022
  */
73948
74023
  __publicField(this, "_protocolManager");
74024
+ __publicField(this, "_seiDelayStats", {});
74025
+ __publicField(this, "_resetSEIDelayStats", () => {
74026
+ this._seiDelayStats = {};
74027
+ });
74028
+ __publicField(this, "_handleSEI", (data2) => {
74029
+ const stats = getSEIDelayStats(data2 == null ? void 0 : data2.sei, this._getPlayerBufferTime());
74030
+ if (stats) {
74031
+ this._seiDelayStats = stats;
74032
+ }
74033
+ });
74034
+ this.on(Events.SEI, this._handleSEI);
74035
+ this.on(Events.URL_CHANGE, this._resetSEIDelayStats);
74036
+ this.on(Events.SOURCE_CHANGE, this._resetSEIDelayStats);
74037
+ this.on(Events.DEFINITION_CHANGE, this._resetSEIDelayStats);
74038
+ this.on(Events.REPLAY, this._resetSEIDelayStats);
74039
+ this.on(Events.FALLBACK, this._resetSEIDelayStats);
73949
74040
  }
73950
74041
  /** {zh}
73951
74042
  * @brief 获取已经播放的时长,不包含暂停和等待时间,单位为秒。
@@ -73987,6 +74078,22 @@ class VePlayerLive extends VePlayerBase {
73987
74078
  var _a, _b;
73988
74079
  return (_b = (_a = this._player.plugins) == null ? void 0 : _a.hls) == null ? void 0 : _b.hls;
73989
74080
  }
74081
+ /** {zh}
74082
+ * @hidden
74083
+ */
74084
+ /** {en}
74085
+ * @hidden
74086
+ */
74087
+ destroy() {
74088
+ this.off(Events.SEI, this._handleSEI);
74089
+ this.off(Events.URL_CHANGE, this._resetSEIDelayStats);
74090
+ this.off(Events.SOURCE_CHANGE, this._resetSEIDelayStats);
74091
+ this.off(Events.DEFINITION_CHANGE, this._resetSEIDelayStats);
74092
+ this.off(Events.REPLAY, this._resetSEIDelayStats);
74093
+ this.off(Events.FALLBACK, this._resetSEIDelayStats);
74094
+ this._resetSEIDelayStats();
74095
+ super.destroy();
74096
+ }
73990
74097
  /** {zh}
73991
74098
  * @brief 调用此方法开启直播日志上报。
73992
74099
  */
@@ -74123,7 +74230,8 @@ class VePlayerLive extends VePlayerBase {
74123
74230
  */
74124
74231
  async getRTMStats() {
74125
74232
  var _a, _b, _c;
74126
- return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.rts) == null ? void 0 : _c.getStatsSnapshoot();
74233
+ const stats = await ((_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.rts) == null ? void 0 : _c.getStatsSnapshoot());
74234
+ return this._mergeSEIDelayStats(stats);
74127
74235
  }
74128
74236
  /** {zh}
74129
74237
  * @brief 获取 FLV 拉流的播放信息。
@@ -74134,7 +74242,8 @@ class VePlayerLive extends VePlayerBase {
74134
74242
  */
74135
74243
  getFLVStats() {
74136
74244
  var _a, _b, _c;
74137
- return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.flv) == null ? void 0 : _c.getStats();
74245
+ const stats = (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.flv) == null ? void 0 : _c.getStats();
74246
+ return this._mergeSEIDelayStats(stats);
74138
74247
  }
74139
74248
  /** {zh}
74140
74249
  * @brief 获取 HLS 拉流的播放信息。
@@ -74146,8 +74255,9 @@ class VePlayerLive extends VePlayerBase {
74146
74255
  * @hidden
74147
74256
  */
74148
74257
  getHLSStats() {
74149
- var _a, _b, _c;
74150
- return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.hls) == null ? void 0 : _c.getStats();
74258
+ var _a, _b, _c, _d;
74259
+ 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)) ?? {};
74260
+ return this._mergeSEIDelayStats(stats);
74151
74261
  }
74152
74262
  /** {en}
74153
74263
  * @brief This method is used to update the playlist, supporting updates to source, resolution, and related information.
@@ -74175,6 +74285,40 @@ class VePlayerLive extends VePlayerBase {
74175
74285
  }
74176
74286
  return super.updatePlaylist(playlist, target);
74177
74287
  }
74288
+ _getPlayerBufferTime() {
74289
+ var _a, _b, _c, _d, _e2;
74290
+ try {
74291
+ 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);
74292
+ if (rtm) {
74293
+ const jitterBufferDelay = rtm.jitterBufferDelay;
74294
+ if (Number.isFinite(jitterBufferDelay) && jitterBufferDelay >= 0) {
74295
+ return jitterBufferDelay;
74296
+ }
74297
+ }
74298
+ } catch (e2) {
74299
+ }
74300
+ const video = (_e2 = this._player) == null ? void 0 : _e2.video;
74301
+ const buffered = video == null ? void 0 : video.buffered;
74302
+ if (!video || !(buffered == null ? void 0 : buffered.length)) {
74303
+ return 0;
74304
+ }
74305
+ try {
74306
+ return Math.trunc(
74307
+ (buffered.end(buffered.length - 1) - video.currentTime) * 1e3
74308
+ );
74309
+ } catch (e2) {
74310
+ return 0;
74311
+ }
74312
+ }
74313
+ _mergeSEIDelayStats(stats) {
74314
+ if (!stats) {
74315
+ return stats;
74316
+ }
74317
+ return {
74318
+ ...stats,
74319
+ ...this._seiDelayStats
74320
+ };
74321
+ }
74178
74322
  }
74179
74323
  async function createLivePlayer(options) {
74180
74324
  var _a, _b, _c, _d, _e2, _f, _g, _h, _i2, _j, _k;
@@ -74207,6 +74351,10 @@ async function createLivePlayer(options) {
74207
74351
  playerOptions,
74208
74352
  recommendation
74209
74353
  );
74354
+ finalOptions.rtm = {
74355
+ enableSei: true,
74356
+ ...finalOptions.rtm
74357
+ };
74210
74358
  await liveLicenseManager.create();
74211
74359
  const licenseFatalError = liveLicenseManager.getLicenseFatalError();
74212
74360
  const protocolManager = await ProtocolManager.create(finalOptions);
@@ -74310,7 +74458,7 @@ async function prepare(options) {
74310
74458
  }
74311
74459
  await ((_a = liveVeStrategy.veStrategyManager) == null ? void 0 : _a.init({
74312
74460
  ...options,
74313
- playerVersion: "2.12.1",
74461
+ playerVersion: "2.13.1-rc.0",
74314
74462
  type: "LIVE"
74315
74463
  }));
74316
74464
  return liveVeStrategy.veStrategyManager;