@byteplus/veplayer-plugin 2.10.3-rc.1 → 2.10.3

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.
@@ -7177,6 +7177,9 @@ function isHeyTapBrowser() {
7177
7177
  function isVivoBrowser() {
7178
7178
  return /(VivoBrowser)/i.test(navigator.userAgent);
7179
7179
  }
7180
+ function isPositiveNumber(num) {
7181
+ return typeof num === "number" && num > 0;
7182
+ }
7180
7183
  var VideoFrameRecvCallback = /* @__PURE__ */ function() {
7181
7184
  function VideoFrameRecvCallback2() {
7182
7185
  var _this = this;
@@ -7267,7 +7270,8 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7267
7270
  clearTimeout(_this._checkStatsErrorTimer);
7268
7271
  }
7269
7272
  _this._checkStatsErrorTimer = setTimeout(/* @__PURE__ */ _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee() {
7270
- var stats, _stats$video, framesDecoded, bytesReceived;
7273
+ var _stats$video, _stats$audio, _stats$video2, _stats$video3;
7274
+ var stats;
7271
7275
  return _regeneratorRuntime$1().wrap(function _callee$(_context) {
7272
7276
  while (1)
7273
7277
  switch (_context.prev = _context.next) {
@@ -7276,19 +7280,17 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7276
7280
  return _this.getStatsSnapshoot();
7277
7281
  case 2:
7278
7282
  stats = _context.sent;
7279
- if (stats.video) {
7280
- _stats$video = stats.video, framesDecoded = _stats$video.framesDecoded, bytesReceived = _stats$video.bytesReceived;
7281
- if (!bytesReceived) {
7282
- _this._emitError(StreamingError.create(ERR.MEDIA, ERR.SUB_TYPES.MEDIA_ERR_DECODE, {
7283
- message: "rts receive empty"
7284
- }));
7285
- } else if (!framesDecoded) {
7286
- _this._emitError(StreamingError.create(ERR.MEDIA, ERR.SUB_TYPES.MEDIA_ERR_DECODE, {
7287
- message: "rts decode error"
7288
- }));
7289
- }
7283
+ if (!isPositiveNumber((_stats$video = stats.video) === null || _stats$video === void 0 ? void 0 : _stats$video.bytesReceived) && !isPositiveNumber((_stats$audio = stats.audio) === null || _stats$audio === void 0 ? void 0 : _stats$audio.bytesReceived)) {
7284
+ _this._emitError(StreamingError.create(ERR.MEDIA, ERR.SUB_TYPES.MEDIA_ERR_DECODE, {
7285
+ message: "rts receive empty"
7286
+ }));
7290
7287
  }
7291
- case 4:
7288
+ if (isPositiveNumber((_stats$video2 = stats.video) === null || _stats$video2 === void 0 ? void 0 : _stats$video2.bytesReceived) && !isPositiveNumber((_stats$video3 = stats.video) === null || _stats$video3 === void 0 ? void 0 : _stats$video3.framesDecoded)) {
7289
+ _this._emitError(StreamingError.create(ERR.MEDIA, ERR.SUB_TYPES.MEDIA_ERR_DECODE, {
7290
+ message: "rts decode error"
7291
+ }));
7292
+ }
7293
+ case 5:
7292
7294
  case "end":
7293
7295
  return _context.stop();
7294
7296
  }
@@ -7706,6 +7708,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7706
7708
  value: function _bindRTCEvents(pc) {
7707
7709
  var _this3 = this;
7708
7710
  pc.addEventListener("track", this._onTrack);
7711
+ var firstConnect = true;
7709
7712
  pc.addEventListener("connectionstatechange", function() {
7710
7713
  logger.warn("onconnectionstatechange:", pc.connectionState);
7711
7714
  _this3._clearPeerStateTimeout();
@@ -7713,26 +7716,31 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7713
7716
  state: pc.connectionState,
7714
7717
  url: _this3._url
7715
7718
  });
7716
- if (pc.connectionState === "disconnected" || pc.connectionState === "failed") {
7717
- _this3.emit("waiting");
7718
- _this3._stopRtcReport();
7719
- }
7720
7719
  if (pc.connectionState === "failed") {
7720
+ var _this3$_preAudioStats, _this3$_preVideoStats;
7721
+ var reason = isPositiveNumber((_this3$_preAudioStats = _this3._preAudioStats) === null || _this3$_preAudioStats === void 0 ? void 0 : _this3$_preAudioStats.bytesReceived) && !isPositiveNumber((_this3$_preVideoStats = _this3._preVideoStats) === null || _this3$_preVideoStats === void 0 ? void 0 : _this3$_preVideoStats.bytesReceived) ? "rtc connect failed(only audio)" : "rtc connect failed";
7721
7722
  if (_this3._retry === 0) {
7722
- _this3._emitError(StreamingError.network(new Error("rtc connect failed")));
7723
+ _this3._emitError(StreamingError.network(new Error(reason)));
7723
7724
  return;
7724
7725
  }
7725
7726
  _this3._retry--;
7726
- _this3.load(_this3._url, "rtc connect failed");
7727
+ _this3.load(_this3._url, reason);
7728
+ }
7729
+ if (pc.connectionState === "disconnected" || pc.connectionState === "failed") {
7730
+ _this3.emit("waiting");
7731
+ _this3._stopRtcReport();
7727
7732
  }
7728
7733
  if (pc.connectionState === "connected") {
7729
- _this3._handleMediaStream();
7730
- _this3.emit(EVENT.TTFB, {
7731
- url: _this3._url,
7732
- responseUrl: _this3._url,
7733
- elapsed: Date.now() - _this3._rctConnectStartTs
7734
- });
7735
- _this3._checkStatsError();
7734
+ if (firstConnect) {
7735
+ firstConnect = false;
7736
+ _this3._handleMediaStream();
7737
+ _this3.emit(EVENT.TTFB, {
7738
+ url: _this3._url,
7739
+ responseUrl: _this3._url,
7740
+ elapsed: Date.now() - _this3._rctConnectStartTs
7741
+ });
7742
+ _this3._checkStatsError();
7743
+ }
7736
7744
  _this3._startRtcReport();
7737
7745
  }
7738
7746
  });
@@ -8303,6 +8311,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
8303
8311
  this._firstFrameObserver.reset();
8304
8312
  this.emit(EVENT.ERROR, error);
8305
8313
  clearTimeout(this._checkStatsErrorTimer);
8314
+ this._stopRtcReport();
8306
8315
  this._clearPeerStateTimeout();
8307
8316
  if (this._pc) {
8308
8317
  this._pc.close();
@@ -8562,7 +8571,7 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
8562
8571
  }, {
8563
8572
  key: "version",
8564
8573
  get: function get() {
8565
- return "0.2.1-alpha.53";
8574
+ return "0.2.1-alpha.57";
8566
8575
  }
8567
8576
  }, {
8568
8577
  key: "beforePlayerInit",