@byteplus/veplayer-plugin 2.8.0-rc.6 → 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.
@@ -4956,6 +4956,7 @@ function getOption(opts) {
4956
4956
  enableSei: false,
4957
4957
  enableOriginSdpLogger: false,
4958
4958
  checkStatsErrorDelay: 5e3,
4959
+ connectionStateChangeTimeout: 5e3,
4959
4960
  enableNetworkQuality: false,
4960
4961
  networkQuality: {
4961
4962
  networkQos: {
@@ -6729,6 +6730,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
6729
6730
  _defineProperty$2(_assertThisInitialized$1(_this), "_preVideoStats", null);
6730
6731
  _defineProperty$2(_assertThisInitialized$1(_this), "_rtcReportTimer", 0);
6731
6732
  _defineProperty$2(_assertThisInitialized$1(_this), "_networkQualityResult", []);
6733
+ _defineProperty$2(_assertThisInitialized$1(_this), "_peerStateTimer", null);
6732
6734
  _defineProperty$2(_assertThisInitialized$1(_this), "_checkStatsError", /* @__PURE__ */ _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee2() {
6733
6735
  return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
6734
6736
  while (1)
@@ -6960,6 +6962,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
6960
6962
  pc.addEventListener("track", this._onTrack);
6961
6963
  pc.addEventListener("connectionstatechange", function() {
6962
6964
  logger.warn("onconnectionstatechange:", pc.connectionState);
6965
+ _this3._clearPeerStateTimeout();
6963
6966
  _this3.emit(EXTEND_EVENTS.RTC_STATE_CHANGE, {
6964
6967
  state: pc.connectionState,
6965
6968
  url: _this3._url
@@ -7096,7 +7099,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7096
7099
  this._videoTransceicer = pc.addTransceiver("video", {
7097
7100
  direction: "recvonly"
7098
7101
  });
7099
- !this._opts.enableAdaptiveJitterBuffer && this._setDelay(this._opts.delayHint, this._opts.videoDelaySync);
7102
+ this._opts.delayHint !== void 0 && this._setDelay(this._opts.delayHint, this._opts.videoDelaySync);
7100
7103
  if (this._opts.enableSei) {
7101
7104
  this.initVideoEncodedTransform();
7102
7105
  this.initAudioEncodedTransform();
@@ -7219,64 +7222,84 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7219
7222
  return this._pc.setRemoteDescription(answer.remoteSdp);
7220
7223
  case 52:
7221
7224
  this._networkEvaluate = new NetworkEvaluate(pc, this._opts.networkEvaluateInterval);
7222
- _context4.next = 58;
7225
+ this._listenPeerStateTimeout();
7226
+ _context4.next = 59;
7223
7227
  break;
7224
- case 55:
7225
- _context4.prev = 55;
7228
+ case 56:
7229
+ _context4.prev = 56;
7226
7230
  _context4.t0 = _context4["catch"](23);
7227
7231
  this._emitError(StreamingError.network(_context4.t0));
7228
- case 58:
7232
+ case 59:
7229
7233
  case "end":
7230
7234
  return _context4.stop();
7231
7235
  }
7232
- }, _callee4, this, [[23, 55]]);
7236
+ }, _callee4, this, [[23, 56]]);
7233
7237
  }));
7234
7238
  function _connect() {
7235
7239
  return _connect2.apply(this, arguments);
7236
7240
  }
7237
7241
  return _connect;
7238
7242
  }()
7243
+ }, {
7244
+ key: "_listenPeerStateTimeout",
7245
+ value: function _listenPeerStateTimeout() {
7246
+ var _this6 = this;
7247
+ this._peerStateTimer && this._clearPeerStateTimeout();
7248
+ if (this._opts.connectionStateChangeTimeout) {
7249
+ this._peerStateTimer = setTimeout(function() {
7250
+ _this6._emitError(StreamingError.create(ERR.MEDIA, ERR.SUB_TYPES.MEDIA_ERR_SRC_NOT_SUPPORTED, {
7251
+ message: "listen connectionstatechange timeout"
7252
+ }));
7253
+ }, this._opts.connectionStateChangeTimeout);
7254
+ }
7255
+ }
7256
+ }, {
7257
+ key: "_clearPeerStateTimeout",
7258
+ value: function _clearPeerStateTimeout() {
7259
+ clearTimeout(this._peerStateTimer);
7260
+ this._peerStateTimer = null;
7261
+ }
7239
7262
  }, {
7240
7263
  key: "_startRtcReport",
7241
7264
  value: function _startRtcReport() {
7242
- var _this6 = this;
7265
+ var _this7 = this;
7243
7266
  this._stopRtcReport();
7244
7267
  this._rtcReportTimer = setInterval(/* @__PURE__ */ _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee5() {
7245
- 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;
7268
+ 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;
7246
7269
  return _regeneratorRuntime$1().wrap(function _callee5$(_context5) {
7247
7270
  while (1)
7248
7271
  switch (_context5.prev = _context5.next) {
7249
7272
  case 0:
7250
- if (!_this6._audioStallObserver && _this6._audioTransceicer) {
7251
- _this6._audioStallObserver = new AudioStallObserver();
7252
- _this6._audioStallObserver.start(_this6._audioTransceicer);
7273
+ if (!_this7._audioStallObserver && _this7._audioTransceicer) {
7274
+ _this7._audioStallObserver = new AudioStallObserver();
7275
+ _this7._audioStallObserver.start(_this7._audioTransceicer);
7253
7276
  }
7254
- if (!_this6._videoStallObserver && _this6._video) {
7255
- _this6._videoStallObserver = new VideoStallObserver();
7256
- _this6._videoStallObserver.start(_this6._media);
7277
+ if (!_this7._videoStallObserver && _this7._video) {
7278
+ _this7._videoStallObserver = new VideoStallObserver();
7279
+ _this7._videoStallObserver.start(_this7._media);
7257
7280
  }
7258
- if (!_this6._networkQuality && _this6._opts.enableNetworkQuality) {
7259
- _this6._networkQuality = new NetworkQuality(_this6._pc, _this6._opts.networkQuality);
7281
+ if (!_this7._networkQuality && _this7._opts.enableNetworkQuality) {
7282
+ _this7._networkQuality = new NetworkQuality(_this7._pc, _this7._opts.networkQuality);
7260
7283
  }
7261
7284
  _context5.next = 5;
7262
- return Promise.all([getRecvAudioStats(_this6._audioTransceicer.receiver.getStats()), getRecvVideoStats(_this6._videoTransceicer.receiver.getStats())]);
7285
+ return Promise.all([getRecvAudioStats(_this7._audioTransceicer.receiver.getStats()), getRecvVideoStats(_this7._videoTransceicer.receiver.getStats())]);
7263
7286
  case 5:
7264
7287
  _yield$Promise$all = _context5.sent;
7265
7288
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
7266
7289
  curAudioStats = _yield$Promise$all2[0];
7267
7290
  curVideoStats = _yield$Promise$all2[1];
7268
- if (!(_this6._preAudioStats && _this6._preVideoStats)) {
7291
+ if (!(_this7._preAudioStats && _this7._preVideoStats)) {
7269
7292
  _context5.next = 21;
7270
7293
  break;
7271
7294
  }
7272
- audioStats = diffRecvAudioStats(_this6._preAudioStats, curAudioStats);
7273
- videoStats = diffRecvVideoStats(_this6._preVideoStats, curVideoStats);
7295
+ audioStats = diffRecvAudioStats(_this7._preAudioStats, curAudioStats);
7296
+ videoStats = diffRecvVideoStats(_this7._preVideoStats, curVideoStats);
7274
7297
  _context5.next = 14;
7275
- return (_this6$_audioStallObs = _this6._audioStallObserver) === null || _this6$_audioStallObs === void 0 ? void 0 : _this6$_audioStallObs.getAudioStallInfo();
7298
+ return (_this7$_audioStallObs = _this7._audioStallObserver) === null || _this7$_audioStallObs === void 0 ? void 0 : _this7$_audioStallObs.getAudioStallInfo();
7276
7299
  case 14:
7277
7300
  audioStallInfo = _context5.sent;
7278
7301
  _context5.next = 17;
7279
- return (_this6$_videoStallObs = _this6._videoStallObserver) === null || _this6$_videoStallObs === void 0 ? void 0 : _this6$_videoStallObs.getStallInfo({
7302
+ return (_this7$_videoStallObs = _this7._videoStallObserver) === null || _this7$_videoStallObs === void 0 ? void 0 : _this7$_videoStallObs.getStallInfo({
7280
7303
  interval: videoStats.statsInterval,
7281
7304
  frameRateReceived: videoStats.frameRateReceived,
7282
7305
  frameRateDecoded: videoStats.frameRateDecoded,
@@ -7284,15 +7307,15 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7284
7307
  });
7285
7308
  case 17:
7286
7309
  videoStallInfo = _context5.sent;
7287
- _ref4 = (_this6$_networkQualit = (_this6$_networkQualit2 = _this6._networkQuality) === null || _this6$_networkQualit2 === void 0 ? void 0 : _this6$_networkQualit2.getDownlinkQuality(_objectSpread2$2(_objectSpread2$2({}, audioStats), {}, {
7310
+ _ref4 = (_this7$_networkQualit = (_this7$_networkQualit2 = _this7._networkQuality) === null || _this7$_networkQualit2 === void 0 ? void 0 : _this7$_networkQualit2.getDownlinkQuality(_objectSpread2$2(_objectSpread2$2({}, audioStats), {}, {
7288
7311
  stallDuration: audioStallInfo.stallDuration
7289
7312
  }), _objectSpread2$2(_objectSpread2$2({}, videoStats), {}, {
7290
7313
  stallDuration: videoStallInfo.stall.stallDuration100ms
7291
- }))) !== null && _this6$_networkQualit !== void 0 ? _this6$_networkQualit : [], _ref5 = _slicedToArray(_ref4, 2), quality = _ref5[0], qualityInfo = _ref5[1];
7292
- if (_this6._opts.enableAdaptiveJitterBuffer) {
7293
- targetDelay = _this6._handleJitterBuffer(qualityInfo === null || qualityInfo === void 0 ? void 0 : qualityInfo.qualityQos, _this6._opts.adaptiveJitterBuffer, _this6._opts.networkStrategy);
7314
+ }))) !== null && _this7$_networkQualit !== void 0 ? _this7$_networkQualit : [], _ref5 = _slicedToArray(_ref4, 2), quality = _ref5[0], qualityInfo = _ref5[1];
7315
+ if (_this7._opts.enableAdaptiveJitterBuffer) {
7316
+ targetDelay = _this7._handleJitterBuffer(qualityInfo === null || qualityInfo === void 0 ? void 0 : qualityInfo.qualityQos, _this7._opts.adaptiveJitterBuffer, _this7._opts.networkStrategy);
7294
7317
  }
7295
- _this6.emit(EXTEND_EVENTS.RTC_NETWORK, {
7318
+ _this7.emit(EXTEND_EVENTS.RTC_NETWORK, {
7296
7319
  interval: videoStats.statsInterval,
7297
7320
  visibility_state: document.visibilityState,
7298
7321
  network_quality: quality,
@@ -7319,12 +7342,12 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7319
7342
  quality_qos: qualityInfo === null || qualityInfo === void 0 ? void 0 : qualityInfo.qualityQos,
7320
7343
  quality_audio_qoe: qualityInfo === null || qualityInfo === void 0 ? void 0 : qualityInfo.audioQoe,
7321
7344
  quality_video_qoe: qualityInfo === null || qualityInfo === void 0 ? void 0 : qualityInfo.videoQoe,
7322
- current_delay: _this6._getDelay(),
7345
+ current_delay: _this7._getDelay(),
7323
7346
  target_delay: targetDelay
7324
7347
  });
7325
7348
  case 21:
7326
- _this6._preAudioStats = curAudioStats;
7327
- _this6._preVideoStats = curVideoStats;
7349
+ _this7._preAudioStats = curAudioStats;
7350
+ _this7._preVideoStats = curVideoStats;
7328
7351
  case 23:
7329
7352
  case "end":
7330
7353
  return _context5.stop();
@@ -7377,6 +7400,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7377
7400
  (_this$_networkEvaluat2 = this._networkEvaluate) === null || _this$_networkEvaluat2 === void 0 ? void 0 : _this$_networkEvaluat2.destroy();
7378
7401
  this._stopRtcReport();
7379
7402
  clearTimeout(this._checkStatsErrorTimer);
7403
+ this._clearPeerStateTimeout();
7380
7404
  this._audioTransceicer = null;
7381
7405
  this._videoTransceicer = null;
7382
7406
  this._mediaStream = null;
@@ -7387,6 +7411,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7387
7411
  value: function _emitError(error) {
7388
7412
  this.emit(EVENT.ERROR, error);
7389
7413
  clearTimeout(this._checkStatsErrorTimer);
7414
+ this._clearPeerStateTimeout();
7390
7415
  if (this._pc) {
7391
7416
  this._pc.close();
7392
7417
  }
@@ -7531,7 +7556,7 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
7531
7556
  }, {
7532
7557
  key: "version",
7533
7558
  get: function get() {
7534
- return "0.2.1-alpha.33";
7559
+ return "0.2.1-alpha.34";
7535
7560
  }
7536
7561
  }, {
7537
7562
  key: "beforePlayerInit",