@byteplus/veplayer-plugin 2.8.0-rc.5 → 2.8.0-rc.7

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.
@@ -4955,10 +4955,12 @@
4955
4955
  stallInterval: 400,
4956
4956
  networkEvaluateInterval: 1e3,
4957
4957
  delayHint: 0,
4958
+ videoDelaySync: false,
4958
4959
  seamlesslyReload: false,
4959
4960
  enableSei: false,
4960
4961
  enableOriginSdpLogger: false,
4961
4962
  checkStatsErrorDelay: 5e3,
4963
+ connectionStateChangeTimeout: 5e3,
4962
4964
  enableNetworkQuality: false,
4963
4965
  networkQuality: {
4964
4966
  networkQos: {
@@ -6732,6 +6734,7 @@
6732
6734
  _defineProperty$2(_assertThisInitialized$1(_this), "_preVideoStats", null);
6733
6735
  _defineProperty$2(_assertThisInitialized$1(_this), "_rtcReportTimer", 0);
6734
6736
  _defineProperty$2(_assertThisInitialized$1(_this), "_networkQualityResult", []);
6737
+ _defineProperty$2(_assertThisInitialized$1(_this), "_peerStateTimer", null);
6735
6738
  _defineProperty$2(_assertThisInitialized$1(_this), "_checkStatsError", /* @__PURE__ */ _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee2() {
6736
6739
  return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
6737
6740
  while (1)
@@ -6806,6 +6809,7 @@
6806
6809
  });
6807
6810
  });
6808
6811
  _defineProperty$2(_assertThisInitialized$1(_this), "_setDelay", function(delayHint) {
6812
+ var videoDelaySync = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
6809
6813
  var currentDelay = _this._getDelay();
6810
6814
  delayHint = typeof delayHint === "number" && delayHint > 0 ? delayHint : null;
6811
6815
  if (currentDelay === delayHint)
@@ -6822,6 +6826,10 @@
6822
6826
  });
6823
6827
  if (key) {
6824
6828
  audioReceiver[key] = delayHint;
6829
+ if (!videoDelaySync) {
6830
+ videoReceiver[key] = delayHint;
6831
+ logger.log("set videoReceiver.".concat(key, " = ").concat(delayHint));
6832
+ }
6825
6833
  logger.log("set audioReceiver.".concat(key, " = ").concat(delayHint));
6826
6834
  }
6827
6835
  } catch (error) {
@@ -6958,6 +6966,7 @@
6958
6966
  pc.addEventListener("track", this._onTrack);
6959
6967
  pc.addEventListener("connectionstatechange", function() {
6960
6968
  logger.warn("onconnectionstatechange:", pc.connectionState);
6969
+ _this3._clearPeerStateTimeout();
6961
6970
  _this3.emit(EXTEND_EVENTS.RTC_STATE_CHANGE, {
6962
6971
  state: pc.connectionState,
6963
6972
  url: _this3._url
@@ -7094,7 +7103,7 @@
7094
7103
  this._videoTransceicer = pc.addTransceiver("video", {
7095
7104
  direction: "recvonly"
7096
7105
  });
7097
- !this._opts.enableAdaptiveJitterBuffer && this._setDelay(this._opts.delayHint);
7106
+ this._opts.delayHint !== void 0 && this._setDelay(this._opts.delayHint, this._opts.videoDelaySync);
7098
7107
  if (this._opts.enableSei) {
7099
7108
  this.initVideoEncodedTransform();
7100
7109
  this.initAudioEncodedTransform();
@@ -7217,64 +7226,84 @@
7217
7226
  return this._pc.setRemoteDescription(answer.remoteSdp);
7218
7227
  case 52:
7219
7228
  this._networkEvaluate = new NetworkEvaluate(pc, this._opts.networkEvaluateInterval);
7220
- _context4.next = 58;
7229
+ this._listenPeerStateTimeout();
7230
+ _context4.next = 59;
7221
7231
  break;
7222
- case 55:
7223
- _context4.prev = 55;
7232
+ case 56:
7233
+ _context4.prev = 56;
7224
7234
  _context4.t0 = _context4["catch"](23);
7225
7235
  this._emitError(StreamingError.network(_context4.t0));
7226
- case 58:
7236
+ case 59:
7227
7237
  case "end":
7228
7238
  return _context4.stop();
7229
7239
  }
7230
- }, _callee4, this, [[23, 55]]);
7240
+ }, _callee4, this, [[23, 56]]);
7231
7241
  }));
7232
7242
  function _connect() {
7233
7243
  return _connect2.apply(this, arguments);
7234
7244
  }
7235
7245
  return _connect;
7236
7246
  }()
7247
+ }, {
7248
+ key: "_listenPeerStateTimeout",
7249
+ value: function _listenPeerStateTimeout() {
7250
+ var _this6 = this;
7251
+ this._peerStateTimer && this._clearPeerStateTimeout();
7252
+ if (this._opts.connectionStateChangeTimeout) {
7253
+ this._peerStateTimer = setTimeout(function() {
7254
+ _this6._emitError(StreamingError.create(ERR.MEDIA, ERR.SUB_TYPES.MEDIA_ERR_SRC_NOT_SUPPORTED, {
7255
+ message: "listen connectionstatechange timeout"
7256
+ }));
7257
+ }, this._opts.connectionStateChangeTimeout);
7258
+ }
7259
+ }
7260
+ }, {
7261
+ key: "_clearPeerStateTimeout",
7262
+ value: function _clearPeerStateTimeout() {
7263
+ clearTimeout(this._peerStateTimer);
7264
+ this._peerStateTimer = null;
7265
+ }
7237
7266
  }, {
7238
7267
  key: "_startRtcReport",
7239
7268
  value: function _startRtcReport() {
7240
- var _this6 = this;
7269
+ var _this7 = this;
7241
7270
  this._stopRtcReport();
7242
7271
  this._rtcReportTimer = setInterval(/* @__PURE__ */ _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee5() {
7243
- var _yield$Promise$all, _yield$Promise$all2, curAudioStats, curVideoStats, _this6$_audioStallObs, _this6$_videoStallObs, _this6$_networkQualit, _this6$_networkQualit2, audioStats, videoStats, audioStallInfo, videoStallInfo, _ref4, _ref5, quality, qualityInfo, targetDelay;
7272
+ var _yield$Promise$all, _yield$Promise$all2, curAudioStats, curVideoStats, _this7$_audioStallObs, _this7$_videoStallObs, _this7$_networkQualit, _this7$_networkQualit2, audioStats, videoStats, audioStallInfo, videoStallInfo, _ref4, _ref5, quality, qualityInfo, targetDelay;
7244
7273
  return _regeneratorRuntime$1().wrap(function _callee5$(_context5) {
7245
7274
  while (1)
7246
7275
  switch (_context5.prev = _context5.next) {
7247
7276
  case 0:
7248
- if (!_this6._audioStallObserver && _this6._audioTransceicer) {
7249
- _this6._audioStallObserver = new AudioStallObserver();
7250
- _this6._audioStallObserver.start(_this6._audioTransceicer);
7277
+ if (!_this7._audioStallObserver && _this7._audioTransceicer) {
7278
+ _this7._audioStallObserver = new AudioStallObserver();
7279
+ _this7._audioStallObserver.start(_this7._audioTransceicer);
7251
7280
  }
7252
- if (!_this6._videoStallObserver && _this6._video) {
7253
- _this6._videoStallObserver = new VideoStallObserver();
7254
- _this6._videoStallObserver.start(_this6._media);
7281
+ if (!_this7._videoStallObserver && _this7._video) {
7282
+ _this7._videoStallObserver = new VideoStallObserver();
7283
+ _this7._videoStallObserver.start(_this7._media);
7255
7284
  }
7256
- if (!_this6._networkQuality && _this6._opts.enableNetworkQuality) {
7257
- _this6._networkQuality = new NetworkQuality(_this6._pc, _this6._opts.networkQuality);
7285
+ if (!_this7._networkQuality && _this7._opts.enableNetworkQuality) {
7286
+ _this7._networkQuality = new NetworkQuality(_this7._pc, _this7._opts.networkQuality);
7258
7287
  }
7259
7288
  _context5.next = 5;
7260
- return Promise.all([getRecvAudioStats(_this6._audioTransceicer.receiver.getStats()), getRecvVideoStats(_this6._videoTransceicer.receiver.getStats())]);
7289
+ return Promise.all([getRecvAudioStats(_this7._audioTransceicer.receiver.getStats()), getRecvVideoStats(_this7._videoTransceicer.receiver.getStats())]);
7261
7290
  case 5:
7262
7291
  _yield$Promise$all = _context5.sent;
7263
7292
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
7264
7293
  curAudioStats = _yield$Promise$all2[0];
7265
7294
  curVideoStats = _yield$Promise$all2[1];
7266
- if (!(_this6._preAudioStats && _this6._preVideoStats)) {
7295
+ if (!(_this7._preAudioStats && _this7._preVideoStats)) {
7267
7296
  _context5.next = 21;
7268
7297
  break;
7269
7298
  }
7270
- audioStats = diffRecvAudioStats(_this6._preAudioStats, curAudioStats);
7271
- videoStats = diffRecvVideoStats(_this6._preVideoStats, curVideoStats);
7299
+ audioStats = diffRecvAudioStats(_this7._preAudioStats, curAudioStats);
7300
+ videoStats = diffRecvVideoStats(_this7._preVideoStats, curVideoStats);
7272
7301
  _context5.next = 14;
7273
- return (_this6$_audioStallObs = _this6._audioStallObserver) === null || _this6$_audioStallObs === void 0 ? void 0 : _this6$_audioStallObs.getAudioStallInfo();
7302
+ return (_this7$_audioStallObs = _this7._audioStallObserver) === null || _this7$_audioStallObs === void 0 ? void 0 : _this7$_audioStallObs.getAudioStallInfo();
7274
7303
  case 14:
7275
7304
  audioStallInfo = _context5.sent;
7276
7305
  _context5.next = 17;
7277
- return (_this6$_videoStallObs = _this6._videoStallObserver) === null || _this6$_videoStallObs === void 0 ? void 0 : _this6$_videoStallObs.getStallInfo({
7306
+ return (_this7$_videoStallObs = _this7._videoStallObserver) === null || _this7$_videoStallObs === void 0 ? void 0 : _this7$_videoStallObs.getStallInfo({
7278
7307
  interval: videoStats.statsInterval,
7279
7308
  frameRateReceived: videoStats.frameRateReceived,
7280
7309
  frameRateDecoded: videoStats.frameRateDecoded,
@@ -7282,15 +7311,15 @@
7282
7311
  });
7283
7312
  case 17:
7284
7313
  videoStallInfo = _context5.sent;
7285
- _ref4 = (_this6$_networkQualit = (_this6$_networkQualit2 = _this6._networkQuality) === null || _this6$_networkQualit2 === void 0 ? void 0 : _this6$_networkQualit2.getDownlinkQuality(_objectSpread2$2(_objectSpread2$2({}, audioStats), {}, {
7314
+ _ref4 = (_this7$_networkQualit = (_this7$_networkQualit2 = _this7._networkQuality) === null || _this7$_networkQualit2 === void 0 ? void 0 : _this7$_networkQualit2.getDownlinkQuality(_objectSpread2$2(_objectSpread2$2({}, audioStats), {}, {
7286
7315
  stallDuration: audioStallInfo.stallDuration
7287
7316
  }), _objectSpread2$2(_objectSpread2$2({}, videoStats), {}, {
7288
7317
  stallDuration: videoStallInfo.stall.stallDuration100ms
7289
- }))) !== null && _this6$_networkQualit !== void 0 ? _this6$_networkQualit : [], _ref5 = _slicedToArray(_ref4, 2), quality = _ref5[0], qualityInfo = _ref5[1];
7290
- if (_this6._opts.enableAdaptiveJitterBuffer) {
7291
- targetDelay = _this6._handleJitterBuffer(qualityInfo === null || qualityInfo === void 0 ? void 0 : qualityInfo.qualityQos, _this6._opts.adaptiveJitterBuffer, _this6._opts.networkStrategy);
7318
+ }))) !== null && _this7$_networkQualit !== void 0 ? _this7$_networkQualit : [], _ref5 = _slicedToArray(_ref4, 2), quality = _ref5[0], qualityInfo = _ref5[1];
7319
+ if (_this7._opts.enableAdaptiveJitterBuffer) {
7320
+ targetDelay = _this7._handleJitterBuffer(qualityInfo === null || qualityInfo === void 0 ? void 0 : qualityInfo.qualityQos, _this7._opts.adaptiveJitterBuffer, _this7._opts.networkStrategy);
7292
7321
  }
7293
- _this6.emit(EXTEND_EVENTS.RTC_NETWORK, {
7322
+ _this7.emit(EXTEND_EVENTS.RTC_NETWORK, {
7294
7323
  interval: videoStats.statsInterval,
7295
7324
  visibility_state: document.visibilityState,
7296
7325
  network_quality: quality,
@@ -7317,12 +7346,12 @@
7317
7346
  quality_qos: qualityInfo === null || qualityInfo === void 0 ? void 0 : qualityInfo.qualityQos,
7318
7347
  quality_audio_qoe: qualityInfo === null || qualityInfo === void 0 ? void 0 : qualityInfo.audioQoe,
7319
7348
  quality_video_qoe: qualityInfo === null || qualityInfo === void 0 ? void 0 : qualityInfo.videoQoe,
7320
- current_delay: _this6._getDelay(),
7349
+ current_delay: _this7._getDelay(),
7321
7350
  target_delay: targetDelay
7322
7351
  });
7323
7352
  case 21:
7324
- _this6._preAudioStats = curAudioStats;
7325
- _this6._preVideoStats = curVideoStats;
7353
+ _this7._preAudioStats = curAudioStats;
7354
+ _this7._preVideoStats = curVideoStats;
7326
7355
  case 23:
7327
7356
  case "end":
7328
7357
  return _context5.stop();
@@ -7375,6 +7404,7 @@
7375
7404
  (_this$_networkEvaluat2 = this._networkEvaluate) === null || _this$_networkEvaluat2 === void 0 ? void 0 : _this$_networkEvaluat2.destroy();
7376
7405
  this._stopRtcReport();
7377
7406
  clearTimeout(this._checkStatsErrorTimer);
7407
+ this._clearPeerStateTimeout();
7378
7408
  this._audioTransceicer = null;
7379
7409
  this._videoTransceicer = null;
7380
7410
  this._mediaStream = null;
@@ -7385,6 +7415,7 @@
7385
7415
  value: function _emitError(error) {
7386
7416
  this.emit(EVENT.ERROR, error);
7387
7417
  clearTimeout(this._checkStatsErrorTimer);
7418
+ this._clearPeerStateTimeout();
7388
7419
  if (this._pc) {
7389
7420
  this._pc.close();
7390
7421
  }
@@ -7529,7 +7560,7 @@
7529
7560
  }, {
7530
7561
  key: "version",
7531
7562
  get: function get() {
7532
- return "0.2.1-alpha.31";
7563
+ return "0.2.1-alpha.34";
7533
7564
  }
7534
7565
  }, {
7535
7566
  key: "beforePlayerInit",