@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.
@@ -33132,6 +33132,9 @@ function isHeyTapBrowser() {
33132
33132
  function isVivoBrowser() {
33133
33133
  return /(VivoBrowser)/i.test(navigator.userAgent);
33134
33134
  }
33135
+ function isPositiveNumber(num) {
33136
+ return typeof num === "number" && num > 0;
33137
+ }
33135
33138
  var VideoFrameRecvCallback = /* @__PURE__ */ function() {
33136
33139
  function VideoFrameRecvCallback2() {
33137
33140
  var _this = this;
@@ -33222,7 +33225,8 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
33222
33225
  clearTimeout(_this._checkStatsErrorTimer);
33223
33226
  }
33224
33227
  _this._checkStatsErrorTimer = setTimeout(/* @__PURE__ */ _asyncToGenerator$a(/* @__PURE__ */ _regeneratorRuntime$a().mark(function _callee() {
33225
- var stats, _stats$video, framesDecoded, bytesReceived;
33228
+ var _stats$video, _stats$audio, _stats$video2, _stats$video3;
33229
+ var stats;
33226
33230
  return _regeneratorRuntime$a().wrap(function _callee$(_context) {
33227
33231
  while (1)
33228
33232
  switch (_context.prev = _context.next) {
@@ -33231,19 +33235,17 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
33231
33235
  return _this.getStatsSnapshoot();
33232
33236
  case 2:
33233
33237
  stats = _context.sent;
33234
- if (stats.video) {
33235
- _stats$video = stats.video, framesDecoded = _stats$video.framesDecoded, bytesReceived = _stats$video.bytesReceived;
33236
- if (!bytesReceived) {
33237
- _this._emitError(StreamingError$2.create(ERR$2.MEDIA, ERR$2.SUB_TYPES.MEDIA_ERR_DECODE, {
33238
- message: "rts receive empty"
33239
- }));
33240
- } else if (!framesDecoded) {
33241
- _this._emitError(StreamingError$2.create(ERR$2.MEDIA, ERR$2.SUB_TYPES.MEDIA_ERR_DECODE, {
33242
- message: "rts decode error"
33243
- }));
33244
- }
33238
+ 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)) {
33239
+ _this._emitError(StreamingError$2.create(ERR$2.MEDIA, ERR$2.SUB_TYPES.MEDIA_ERR_DECODE, {
33240
+ message: "rts receive empty"
33241
+ }));
33245
33242
  }
33246
- case 4:
33243
+ 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)) {
33244
+ _this._emitError(StreamingError$2.create(ERR$2.MEDIA, ERR$2.SUB_TYPES.MEDIA_ERR_DECODE, {
33245
+ message: "rts decode error"
33246
+ }));
33247
+ }
33248
+ case 5:
33247
33249
  case "end":
33248
33250
  return _context.stop();
33249
33251
  }
@@ -33661,6 +33663,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
33661
33663
  value: function _bindRTCEvents(pc) {
33662
33664
  var _this3 = this;
33663
33665
  pc.addEventListener("track", this._onTrack);
33666
+ var firstConnect = true;
33664
33667
  pc.addEventListener("connectionstatechange", function() {
33665
33668
  logger$b.warn("onconnectionstatechange:", pc.connectionState);
33666
33669
  _this3._clearPeerStateTimeout();
@@ -33668,26 +33671,31 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
33668
33671
  state: pc.connectionState,
33669
33672
  url: _this3._url
33670
33673
  });
33671
- if (pc.connectionState === "disconnected" || pc.connectionState === "failed") {
33672
- _this3.emit("waiting");
33673
- _this3._stopRtcReport();
33674
- }
33675
33674
  if (pc.connectionState === "failed") {
33675
+ var _this3$_preAudioStats, _this3$_preVideoStats;
33676
+ 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";
33676
33677
  if (_this3._retry === 0) {
33677
- _this3._emitError(StreamingError$2.network(new Error("rtc connect failed")));
33678
+ _this3._emitError(StreamingError$2.network(new Error(reason)));
33678
33679
  return;
33679
33680
  }
33680
33681
  _this3._retry--;
33681
- _this3.load(_this3._url, "rtc connect failed");
33682
+ _this3.load(_this3._url, reason);
33683
+ }
33684
+ if (pc.connectionState === "disconnected" || pc.connectionState === "failed") {
33685
+ _this3.emit("waiting");
33686
+ _this3._stopRtcReport();
33682
33687
  }
33683
33688
  if (pc.connectionState === "connected") {
33684
- _this3._handleMediaStream();
33685
- _this3.emit(EVENT$2.TTFB, {
33686
- url: _this3._url,
33687
- responseUrl: _this3._url,
33688
- elapsed: Date.now() - _this3._rctConnectStartTs
33689
- });
33690
- _this3._checkStatsError();
33689
+ if (firstConnect) {
33690
+ firstConnect = false;
33691
+ _this3._handleMediaStream();
33692
+ _this3.emit(EVENT$2.TTFB, {
33693
+ url: _this3._url,
33694
+ responseUrl: _this3._url,
33695
+ elapsed: Date.now() - _this3._rctConnectStartTs
33696
+ });
33697
+ _this3._checkStatsError();
33698
+ }
33691
33699
  _this3._startRtcReport();
33692
33700
  }
33693
33701
  });
@@ -34258,6 +34266,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
34258
34266
  this._firstFrameObserver.reset();
34259
34267
  this.emit(EVENT$2.ERROR, error);
34260
34268
  clearTimeout(this._checkStatsErrorTimer);
34269
+ this._stopRtcReport();
34261
34270
  this._clearPeerStateTimeout();
34262
34271
  if (this._pc) {
34263
34272
  this._pc.close();
@@ -34517,7 +34526,7 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
34517
34526
  }, {
34518
34527
  key: "version",
34519
34528
  get: function get4() {
34520
- return "0.2.1-alpha.53";
34529
+ return "0.2.1-alpha.57";
34521
34530
  }
34522
34531
  }, {
34523
34532
  key: "beforePlayerInit",