@volcengine/veplayer-plugin 2.10.2-rc.0 → 2.10.2

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.
@@ -1757,6 +1757,7 @@
1757
1757
  var PLAY = "play";
1758
1758
  var PAUSE = "pause";
1759
1759
  var ERROR = "error";
1760
+ var CANPLAY = "canplay";
1760
1761
  var DESTROY = "destroy";
1761
1762
  var URL_CHANGE = "urlchange";
1762
1763
  function callHandler(obj, handler, next) {
@@ -2185,6 +2186,37 @@
2185
2186
  }]);
2186
2187
  return BasePlugin2;
2187
2188
  }();
2189
+ var STATE_CLASS = {
2190
+ DEFAULT: "xgplayer",
2191
+ DEFAULT_SKIN: "xgplayer-skin-default",
2192
+ ENTER: "xgplayer-is-enter",
2193
+ PAUSED: "xgplayer-pause",
2194
+ PLAYING: "xgplayer-playing",
2195
+ ENDED: "xgplayer-ended",
2196
+ CANPLAY: "xgplayer-canplay",
2197
+ LOADING: "xgplayer-isloading",
2198
+ ERROR: "xgplayer-is-error",
2199
+ REPLAY: "xgplayer-replay",
2200
+ NO_START: "xgplayer-nostart",
2201
+ ACTIVE: "xgplayer-active",
2202
+ INACTIVE: "xgplayer-inactive",
2203
+ FULLSCREEN: "xgplayer-is-fullscreen",
2204
+ CSS_FULLSCREEN: "xgplayer-is-cssfullscreen",
2205
+ ROTATE_FULLSCREEN: "xgplayer-rotate-fullscreen",
2206
+ PARENT_ROTATE_FULLSCREEN: "xgplayer-rotate-parent",
2207
+ PARENT_FULLSCREEN: "xgplayer-fullscreen-parent",
2208
+ INNER_FULLSCREEN: "xgplayer-fullscreen-inner",
2209
+ NO_CONTROLS: "no-controls",
2210
+ FLEX_CONTROLS: "flex-controls",
2211
+ CONTROLS_FOLLOW: "controls-follow",
2212
+ CONTROLS_AUTOHIDE: "controls-autohide",
2213
+ TOP_BAR_AUTOHIDE: "top-bar-autohide",
2214
+ NOT_ALLOW_AUTOPLAY: "not-allow-autoplay",
2215
+ SEEKING: "seeking",
2216
+ PC: "xgplayer-pc",
2217
+ MOBILE: "xgplayer-mobile",
2218
+ MINI: "xgplayer-mini"
2219
+ };
2188
2220
  function ownKeys(object, enumerableOnly) {
2189
2221
  var keys = Object.keys(object);
2190
2222
  if (Object.getOwnPropertySymbols) {
@@ -6699,7 +6731,7 @@
6699
6731
  width: newStats.width || 0,
6700
6732
  height: newStats.height || 0,
6701
6733
  estimatedPlayoutTimestamp: newStats.estimatedPlayoutTimestamp,
6702
- videoLossRate: +(packetsLostDiff / (diffNumber(oldStats, newStats, "packetsReceived") + packetsLostDiff)),
6734
+ videoLossRate: +(packetsLostDiff / (diffNumber(oldStats, newStats, "packetsReceived") + packetsLostDiff)).toFixed(2),
6703
6735
  receivedKBitrate: +(diffNumber(oldStats, newStats, "bytesReceived") * 8 / statsInterval).toFixed(2),
6704
6736
  decoderOutputFrameRate: Math.round(diffNumber(oldStats, newStats, "framesDecoded") * 1e3 / statsInterval),
6705
6737
  receivedFrameRate: Math.round(diffNumber(oldStats, newStats, "framesReceived") * 1e3 / statsInterval),
@@ -6881,13 +6913,22 @@
6881
6913
  }
6882
6914
  };
6883
6915
  this._handlePlaying = function() {
6916
+ if (!_this._state[RTC_FIRST_FRAME_STATE.PEER_CONNECTED]) {
6917
+ return;
6918
+ }
6884
6919
  _this.changeFirstFrameState(RTC_FIRST_FRAME_STATE.VIDEO_PLAYING);
6885
6920
  _this.reset();
6886
6921
  };
6887
6922
  this._handleCanplay = function() {
6923
+ if (!_this._state[RTC_FIRST_FRAME_STATE.PEER_CONNECTED]) {
6924
+ return;
6925
+ }
6888
6926
  _this.changeFirstFrameState(RTC_FIRST_FRAME_STATE.VIDEO_CANPLAY);
6889
6927
  };
6890
6928
  this._handleLoadeddata = function() {
6929
+ if (!_this._state[RTC_FIRST_FRAME_STATE.PEER_CONNECTED]) {
6930
+ return;
6931
+ }
6891
6932
  _this.changeFirstFrameState(RTC_FIRST_FRAME_STATE.VIDEO_LOADEDDATA);
6892
6933
  };
6893
6934
  this._handleError = function() {
@@ -6954,6 +6995,7 @@
6954
6995
  var hasFrameDecoded = false;
6955
6996
  this._cancelWatchForFirstVideoFrameRecv();
6956
6997
  this._firstVideoFrameInterval = window.setInterval(/* @__PURE__ */ _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee() {
6998
+ var _inboundRtpStats, _inboundRtpStats2, _inboundRtpStats3;
6957
6999
  var receiver, reports, inboundRtpStats;
6958
7000
  return _regeneratorRuntime$1().wrap(function _callee$(_context) {
6959
7001
  while (1)
@@ -6969,15 +7011,15 @@
6969
7011
  inboundRtpStats = report;
6970
7012
  }
6971
7013
  });
6972
- if (!hasPacketsReceived && inboundRtpStats.packetsReceived > 0) {
7014
+ if (!hasPacketsReceived && (_inboundRtpStats = inboundRtpStats) !== null && _inboundRtpStats !== void 0 && _inboundRtpStats.packetsReceived && inboundRtpStats.packetsReceived > 0) {
6973
7015
  hasPacketsReceived = true;
6974
7016
  _this4.changeFirstFrameState(RTC_FIRST_FRAME_STATE.FIRST_PACKET_RECV);
6975
7017
  }
6976
- if (!hasFrameReceived && inboundRtpStats.framesReceived > 0) {
7018
+ if (!hasFrameReceived && (_inboundRtpStats2 = inboundRtpStats) !== null && _inboundRtpStats2 !== void 0 && _inboundRtpStats2.framesReceived && inboundRtpStats.framesReceived > 0) {
6977
7019
  hasFrameReceived = true;
6978
7020
  _this4.changeFirstFrameState(RTC_FIRST_FRAME_STATE.FIRST_FRAME_RECV);
6979
7021
  }
6980
- if (!hasFrameDecoded && inboundRtpStats.framesDecoded > 0) {
7022
+ if (!hasFrameDecoded && (_inboundRtpStats3 = inboundRtpStats) !== null && _inboundRtpStats3 !== void 0 && _inboundRtpStats3.framesDecoded && inboundRtpStats.framesDecoded > 0) {
6981
7023
  hasFrameDecoded = true;
6982
7024
  _this4.changeFirstFrameState(RTC_FIRST_FRAME_STATE.FIRST_FRAME_DECODED);
6983
7025
  _this4._cancelWatchForFirstVideoFrameRecv();
@@ -6997,103 +7039,84 @@
6997
7039
  this._firstVideoFrameInterval = null;
6998
7040
  }
6999
7041
  }
7000
- }, {
7001
- key: "_getTransportInfo",
7002
- value: function() {
7003
- var _getTransportInfo2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee2() {
7004
- var _this$_videoTransceiv, _this$_videoTransceiv2;
7005
- var reports, candidatePairStats, localCandidateStats, remoteCandidateStats;
7006
- return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
7007
- while (1)
7008
- switch (_context2.prev = _context2.next) {
7009
- case 0:
7010
- _context2.next = 2;
7011
- return (_this$_videoTransceiv = this._videoTransceiver) === null || _this$_videoTransceiv === void 0 ? void 0 : (_this$_videoTransceiv2 = _this$_videoTransceiv.receiver) === null || _this$_videoTransceiv2 === void 0 ? void 0 : _this$_videoTransceiv2.getStats();
7012
- case 2:
7013
- reports = _context2.sent;
7014
- reports === null || reports === void 0 ? void 0 : reports.forEach(function(report) {
7015
- if (report.type === "candidate-pair") {
7016
- candidatePairStats = report;
7017
- localCandidateStats = reports.get(report.localCandidateId);
7018
- remoteCandidateStats = reports.get(report.remoteCandidateId);
7019
- }
7020
- });
7021
- if (remoteCandidateStats) {
7022
- this._extraInfo.remote_ip = remoteCandidateStats.ip || remoteCandidateStats.address;
7023
- this._extraInfo.remote_port = remoteCandidateStats.port;
7024
- this._extraInfo.remote_candidate_type = remoteCandidateStats.candidateType;
7025
- this._extraInfo.protocol = remoteCandidateStats.protocol;
7026
- }
7027
- if (localCandidateStats) {
7028
- this._extraInfo.local_ip = localCandidateStats.ip || localCandidateStats.address;
7029
- this._extraInfo.local_port = localCandidateStats.port;
7030
- this._extraInfo.local_candidate_type = localCandidateStats.candidateType;
7031
- }
7032
- if (candidatePairStats) {
7033
- this._extraInfo.rtt = candidatePairStats.currentRoundTripTime;
7034
- this._extraInfo.stun_requests_sent = candidatePairStats.requestsSent;
7035
- this._extraInfo.stun_requests_received = candidatePairStats.requestsReceived;
7036
- this._extraInfo.stun_responses_sent = candidatePairStats.responsesSent;
7037
- this._extraInfo.stun_responses_received = candidatePairStats.responsesReceived;
7038
- }
7039
- case 7:
7040
- case "end":
7041
- return _context2.stop();
7042
- }
7043
- }, _callee2, this);
7044
- }));
7045
- function _getTransportInfo() {
7046
- return _getTransportInfo2.apply(this, arguments);
7047
- }
7048
- return _getTransportInfo;
7049
- }()
7050
7042
  }, {
7051
7043
  key: "reset",
7052
- value: function() {
7053
- var _reset = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee3() {
7054
- var _this$_video, _this$_video2, _this$_video3, _this$_video4, _this$_pc3, _this$_pc4;
7055
- return _regeneratorRuntime$1().wrap(function _callee3$(_context3) {
7056
- while (1)
7057
- switch (_context3.prev = _context3.next) {
7058
- case 0:
7059
- if (!(Object.keys(this._state).length > 0)) {
7060
- _context3.next = 4;
7061
- break;
7062
- }
7063
- _context3.next = 3;
7064
- return this._getTransportInfo();
7065
- case 3:
7066
- this._emitFirstFrameState(this._state, this._extraInfo);
7067
- case 4:
7068
- this._preState = null;
7069
- this._extraInfo = {
7070
- is_preload: false
7071
- };
7072
- this._state = {};
7073
- (_this$_video = this._video) === null || _this$_video === void 0 ? void 0 : _this$_video.removeEventListener("playing", this._handlePlaying);
7074
- (_this$_video2 = this._video) === null || _this$_video2 === void 0 ? void 0 : _this$_video2.removeEventListener("canplay", this._handleCanplay);
7075
- (_this$_video3 = this._video) === null || _this$_video3 === void 0 ? void 0 : _this$_video3.removeEventListener("loadeddata", this._handleLoadeddata);
7076
- (_this$_video4 = this._video) === null || _this$_video4 === void 0 ? void 0 : _this$_video4.removeEventListener("error", this._handleError);
7077
- (_this$_pc3 = this._pc) === null || _this$_pc3 === void 0 ? void 0 : _this$_pc3.removeEventListener("connectionstatechange", this._handleConnectionStateChange);
7078
- (_this$_pc4 = this._pc) === null || _this$_pc4 === void 0 ? void 0 : _this$_pc4.removeEventListener("iceconnectionstatechange", this._handleICEConnectionStateChange);
7079
- this._cancelWatchForFirstVideoFrameRecv();
7080
- this._pc = null;
7081
- this._video = null;
7082
- this._videoTransceiver = null;
7083
- case 17:
7084
- case "end":
7085
- return _context3.stop();
7086
- }
7087
- }, _callee3, this);
7088
- }));
7089
- function reset() {
7090
- return _reset.apply(this, arguments);
7044
+ value: function reset() {
7045
+ var _this5 = this, _this$_video, _this$_video2, _this$_video3, _this$_video4, _this$_pc3, _this$_pc4;
7046
+ if (Object.keys(this._state).length > 0) {
7047
+ var state = _objectSpread2$2({}, this._state);
7048
+ var extraInfo = _objectSpread2$2({}, this._extraInfo);
7049
+ getTransportInfo(this._videoTransceiver, extraInfo).then(function() {
7050
+ _this5._emitFirstFrameState(state, extraInfo);
7051
+ });
7091
7052
  }
7092
- return reset;
7093
- }()
7053
+ this._preState = null;
7054
+ this._extraInfo = {
7055
+ is_preload: false
7056
+ };
7057
+ this._state = {};
7058
+ (_this$_video = this._video) === null || _this$_video === void 0 ? void 0 : _this$_video.removeEventListener("playing", this._handlePlaying);
7059
+ (_this$_video2 = this._video) === null || _this$_video2 === void 0 ? void 0 : _this$_video2.removeEventListener("canplay", this._handleCanplay);
7060
+ (_this$_video3 = this._video) === null || _this$_video3 === void 0 ? void 0 : _this$_video3.removeEventListener("loadeddata", this._handleLoadeddata);
7061
+ (_this$_video4 = this._video) === null || _this$_video4 === void 0 ? void 0 : _this$_video4.removeEventListener("error", this._handleError);
7062
+ (_this$_pc3 = this._pc) === null || _this$_pc3 === void 0 ? void 0 : _this$_pc3.removeEventListener("connectionstatechange", this._handleConnectionStateChange);
7063
+ (_this$_pc4 = this._pc) === null || _this$_pc4 === void 0 ? void 0 : _this$_pc4.removeEventListener("iceconnectionstatechange", this._handleICEConnectionStateChange);
7064
+ this._cancelWatchForFirstVideoFrameRecv();
7065
+ this._pc = null;
7066
+ this._video = null;
7067
+ this._videoTransceiver = null;
7068
+ }
7094
7069
  }]);
7095
7070
  return FirstFrameObserver2;
7096
7071
  }();
7072
+ var getTransportInfo = /* @__PURE__ */ function() {
7073
+ var _ref4 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee2(videoTransceiver, extraInfo) {
7074
+ var _videoTransceiver$rec;
7075
+ var reports, candidatePairStats, localCandidateStats, remoteCandidateStats;
7076
+ return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
7077
+ while (1)
7078
+ switch (_context2.prev = _context2.next) {
7079
+ case 0:
7080
+ _context2.next = 2;
7081
+ return videoTransceiver === null || videoTransceiver === void 0 ? void 0 : (_videoTransceiver$rec = videoTransceiver.receiver) === null || _videoTransceiver$rec === void 0 ? void 0 : _videoTransceiver$rec.getStats().catch(function() {
7082
+ });
7083
+ case 2:
7084
+ reports = _context2.sent;
7085
+ reports === null || reports === void 0 ? void 0 : reports.forEach(function(report) {
7086
+ if (report.type === "candidate-pair") {
7087
+ candidatePairStats = report;
7088
+ localCandidateStats = reports.get(report.localCandidateId);
7089
+ remoteCandidateStats = reports.get(report.remoteCandidateId);
7090
+ }
7091
+ });
7092
+ if (remoteCandidateStats) {
7093
+ extraInfo.remote_ip = remoteCandidateStats.ip || remoteCandidateStats.address;
7094
+ extraInfo.remote_port = remoteCandidateStats.port;
7095
+ extraInfo.remote_candidate_type = remoteCandidateStats.candidateType;
7096
+ extraInfo.protocol = remoteCandidateStats.protocol;
7097
+ }
7098
+ if (localCandidateStats) {
7099
+ extraInfo.local_ip = localCandidateStats.ip || localCandidateStats.address;
7100
+ extraInfo.local_port = localCandidateStats.port;
7101
+ extraInfo.local_candidate_type = localCandidateStats.candidateType;
7102
+ }
7103
+ if (candidatePairStats) {
7104
+ extraInfo.rtt = candidatePairStats.currentRoundTripTime;
7105
+ extraInfo.stun_requests_sent = candidatePairStats.requestsSent;
7106
+ extraInfo.stun_requests_received = candidatePairStats.requestsReceived;
7107
+ extraInfo.stun_responses_sent = candidatePairStats.responsesSent;
7108
+ extraInfo.stun_responses_received = candidatePairStats.responsesReceived;
7109
+ }
7110
+ case 7:
7111
+ case "end":
7112
+ return _context2.stop();
7113
+ }
7114
+ }, _callee2);
7115
+ }));
7116
+ return function getTransportInfo2(_x, _x2) {
7117
+ return _ref4.apply(this, arguments);
7118
+ };
7119
+ }();
7097
7120
  function changeNumberInRange(source, min, max, delta) {
7098
7121
  var target = source + delta;
7099
7122
  if (target > max) {
@@ -7157,6 +7180,58 @@
7157
7180
  function isVivoBrowser() {
7158
7181
  return /(VivoBrowser)/i.test(navigator.userAgent);
7159
7182
  }
7183
+ var VideoFrameRecvCallback = /* @__PURE__ */ function() {
7184
+ function VideoFrameRecvCallback2() {
7185
+ var _this = this;
7186
+ _classCallCheck$3(this, VideoFrameRecvCallback2);
7187
+ this._onVideoRefresh = function(_, data) {
7188
+ var _this$_domElement;
7189
+ _this._recentVideoInfo = data;
7190
+ _this._requestVideoFrameCallbackTimer = (_this$_domElement = _this._domElement) === null || _this$_domElement === void 0 ? void 0 : _this$_domElement.requestVideoFrameCallback(_this._onVideoRefresh);
7191
+ };
7192
+ }
7193
+ _createClass$3(VideoFrameRecvCallback2, [{
7194
+ key: "start",
7195
+ value: function start(domElement) {
7196
+ var _this2 = this;
7197
+ this._domElement = domElement;
7198
+ if (typeof HTMLVideoElement.prototype.requestVideoFrameCallback === "function") {
7199
+ if (domElement) {
7200
+ this._requestVideoFrameCallbackTimer = domElement.requestVideoFrameCallback(this._onVideoRefresh.bind(this));
7201
+ this._removeHandler = function() {
7202
+ _this2._requestVideoFrameCallbackTimer && (domElement === null || domElement === void 0 ? void 0 : domElement.cancelVideoFrameCallback(_this2._requestVideoFrameCallbackTimer));
7203
+ };
7204
+ }
7205
+ }
7206
+ }
7207
+ }, {
7208
+ key: "stop",
7209
+ value: function stop() {
7210
+ var _this$_removeHandler;
7211
+ delete this._recentVideoInfo;
7212
+ delete this._domElement;
7213
+ (_this$_removeHandler = this._removeHandler) === null || _this$_removeHandler === void 0 ? void 0 : _this$_removeHandler.call(this);
7214
+ delete this._removeHandler;
7215
+ }
7216
+ }, {
7217
+ key: "getRecentRenderInfo4Report",
7218
+ value: function getRecentRenderInfo4Report() {
7219
+ var _this3 = this;
7220
+ var obj = {};
7221
+ if (this._recentVideoInfo) {
7222
+ Object.keys(this._recentVideoInfo).forEach(function(k) {
7223
+ var _this3$_recentVideoIn;
7224
+ var key = k.replace(/[a-z]{1}[A-Z]{1}/g, function(e) {
7225
+ return "".concat(e[0], "_").concat(e[1].toLowerCase());
7226
+ });
7227
+ obj["video_".concat(key)] = (_this3$_recentVideoIn = _this3._recentVideoInfo) === null || _this3$_recentVideoIn === void 0 ? void 0 : _this3$_recentVideoIn[k];
7228
+ });
7229
+ }
7230
+ return obj;
7231
+ }
7232
+ }]);
7233
+ return VideoFrameRecvCallback2;
7234
+ }();
7160
7235
  var logger = new Logger("rts");
7161
7236
  var Rts = /* @__PURE__ */ function(_EventEmitter) {
7162
7237
  _inherits$1(Rts2, _EventEmitter);
@@ -7520,7 +7595,7 @@
7520
7595
  }, {
7521
7596
  key: "load",
7522
7597
  value: function() {
7523
- var _load = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee6(url) {
7598
+ var _load = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee6(url, failureReason) {
7524
7599
  var _this2 = this;
7525
7600
  var lastPc, answerSdp, errorStr, preloadPromise, info, encodedTransformSupported;
7526
7601
  return _regeneratorRuntime$1().wrap(function _callee6$(_context6) {
@@ -7528,7 +7603,7 @@
7528
7603
  switch (_context6.prev = _context6.next) {
7529
7604
  case 0:
7530
7605
  logger.log("load()", 'invoked, url: "'.concat(url, '"'));
7531
- this._disconnect();
7606
+ this._disconnect(failureReason || "invoke load");
7532
7607
  this._url = url;
7533
7608
  lastPc = this._pc;
7534
7609
  if (!this._opts.hackCreateOfferIssue) {
@@ -7541,7 +7616,7 @@
7541
7616
  _context6.prev = 7;
7542
7617
  this._firstFrameObserver.start();
7543
7618
  if (!this._preloadPromise) {
7544
- _context6.next = 39;
7619
+ _context6.next = 38;
7545
7620
  break;
7546
7621
  }
7547
7622
  logger.log("load()", "in preload process...");
@@ -7575,51 +7650,50 @@
7575
7650
  this.initVideoEncodedTransform();
7576
7651
  this.initAudioEncodedTransform();
7577
7652
  }
7578
- _context6.next = 37;
7653
+ _context6.next = 36;
7579
7654
  break;
7580
7655
  case 31:
7581
7656
  _context6.prev = 31;
7582
7657
  _context6.t0 = _context6["catch"](11);
7583
7658
  logger.warn("load()", "preload failed, ".concat(_context6.t0.message || _context6.t0.toString()));
7584
- this._firstFrameObserver.setFailureReason(_context6.t0.message || _context6.t0.toString());
7585
- this.load(url);
7659
+ this.load(url, _context6.t0.message || _context6.t0.toString());
7586
7660
  return _context6.abrupt("return");
7587
- case 37:
7588
- _context6.next = 45;
7661
+ case 36:
7662
+ _context6.next = 44;
7589
7663
  break;
7590
- case 39:
7664
+ case 38:
7591
7665
  encodedTransformSupported = isLegacyEncodedTransformSupported();
7592
7666
  logger.log("load()", "isLegacyEncodedTransformSupported: ".concat(encodedTransformSupported));
7593
7667
  this._pc = new RTCPeerConnection({
7594
7668
  encodedInsertableStreams: encodedTransformSupported && this._opts.enableSei ? true : void 0
7595
7669
  });
7596
- _context6.next = 44;
7670
+ _context6.next = 43;
7597
7671
  return this._getAnswerSdp(this._pc);
7598
- case 44:
7672
+ case 43:
7599
7673
  answerSdp = _context6.sent;
7600
- case 45:
7674
+ case 44:
7601
7675
  this._bindRTCEvents(this._pc);
7602
- _context6.next = 48;
7676
+ _context6.next = 47;
7603
7677
  return this._handleAnswerSdp(this._pc, answerSdp);
7604
- case 48:
7678
+ case 47:
7605
7679
  if (lastPc) {
7606
7680
  lastPc.close();
7607
7681
  }
7608
- _context6.next = 54;
7682
+ _context6.next = 53;
7609
7683
  break;
7610
- case 51:
7611
- _context6.prev = 51;
7684
+ case 50:
7685
+ _context6.prev = 50;
7612
7686
  _context6.t1 = _context6["catch"](7);
7613
7687
  setTimeout(function() {
7614
7688
  return _this2._emitError(StreamingError.create(ERR.OTHER, null, _context6.t1));
7615
7689
  });
7616
- case 54:
7690
+ case 53:
7617
7691
  case "end":
7618
7692
  return _context6.stop();
7619
7693
  }
7620
- }, _callee6, this, [[7, 51], [11, 31]]);
7694
+ }, _callee6, this, [[7, 50], [11, 31]]);
7621
7695
  }));
7622
- function load(_x2) {
7696
+ function load(_x2, _x3) {
7623
7697
  return _load.apply(this, arguments);
7624
7698
  }
7625
7699
  return load;
@@ -7628,7 +7702,7 @@
7628
7702
  key: "switchURL",
7629
7703
  value: function switchURL(url) {
7630
7704
  logger.log("switchURL()", 'invoked, url: "'.concat(url, '"'));
7631
- this.load(url || this._url);
7705
+ this.load(url || this._url, "invoke switchURL");
7632
7706
  }
7633
7707
  }, {
7634
7708
  key: "_bindRTCEvents",
@@ -7652,7 +7726,7 @@
7652
7726
  return;
7653
7727
  }
7654
7728
  _this3._retry--;
7655
- _this3.load(_this3._url);
7729
+ _this3.load(_this3._url, "rtc connect failed");
7656
7730
  }
7657
7731
  if (pc.connectionState === "connected") {
7658
7732
  _this3._handleMediaStream();
@@ -7907,7 +7981,7 @@
7907
7981
  }
7908
7982
  }, _callee7, this, [[26, 51]]);
7909
7983
  }));
7910
- function _getAnswerSdp(_x3) {
7984
+ function _getAnswerSdp(_x4) {
7911
7985
  return _getAnswerSdp2.apply(this, arguments);
7912
7986
  }
7913
7987
  return _getAnswerSdp;
@@ -7971,7 +8045,7 @@
7971
8045
  }
7972
8046
  }, _callee8, this);
7973
8047
  }));
7974
- function _handleAnswerSdp(_x4, _x5) {
8048
+ function _handleAnswerSdp(_x5, _x6) {
7975
8049
  return _handleAnswerSdp2.apply(this, arguments);
7976
8050
  }
7977
8051
  return _handleAnswerSdp;
@@ -8005,7 +8079,7 @@
8005
8079
  var report = /* @__PURE__ */ function() {
8006
8080
  var _ref5 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee9() {
8007
8081
  var _this7$_audioTranscei, _this7$_videoTranscei;
8008
- var _yield$Promise$all3, _yield$Promise$all4, curAudioStats, curVideoStats, _this7$_audioStallObs, _this7$_videoStallObs, _this7$_networkQualit, _this7$_networkQualit2, _this7$_media, _this7$_media2, audioStats, videoStats, audioStallInfo, videoStallInfo, _ref6, _ref7, quality, qualityInfo, av_sync_diff;
8082
+ var _this7$_frameRecvCall, _yield$Promise$all3, _yield$Promise$all4, curAudioStats, curVideoStats, _this7$_audioStallObs, _this7$_videoStallObs, _this7$_networkQualit, _this7$_networkQualit2, _this7$_media, _this7$_media2, _this7$_media3, _this7$_media4, _this7$_media5, _this7$_media6, _this7$_frameRecvCall2, audioStats, videoStats, audioStallInfo, videoStallInfo, _ref6, _ref7, quality, qualityInfo, av_sync_diff;
8009
8083
  return _regeneratorRuntime$1().wrap(function _callee9$(_context9) {
8010
8084
  while (1)
8011
8085
  switch (_context9.prev = _context9.next) {
@@ -8026,35 +8100,39 @@
8026
8100
  _this7._videoStallObserver = new VideoStallObserver();
8027
8101
  _this7._videoStallObserver.start(_this7._media);
8028
8102
  }
8103
+ if (!_this7._frameRecvCallback && _this7._media) {
8104
+ _this7._frameRecvCallback = new VideoFrameRecvCallback();
8105
+ (_this7$_frameRecvCall = _this7._frameRecvCallback) === null || _this7$_frameRecvCall === void 0 ? void 0 : _this7$_frameRecvCall.start(_this7._media);
8106
+ }
8029
8107
  if (_this7._pc && !_this7._networkQuality && _this7._opts.enableNetworkQuality && _this7._opts.networkQuality) {
8030
8108
  _this7._networkQuality = new NetworkQuality(_this7._pc, _this7._opts.networkQuality);
8031
8109
  }
8032
- _context9.next = 9;
8110
+ _context9.next = 10;
8033
8111
  return Promise.all([getRecvAudioStats(_this7._audioTransceicer.receiver.getStats()), getRecvVideoStats(_this7._videoTransceicer.receiver.getStats())]);
8034
- case 9:
8112
+ case 10:
8035
8113
  _yield$Promise$all3 = _context9.sent;
8036
8114
  _yield$Promise$all4 = _slicedToArray(_yield$Promise$all3, 2);
8037
8115
  curAudioStats = _yield$Promise$all4[0];
8038
8116
  curVideoStats = _yield$Promise$all4[1];
8039
8117
  if (!(_this7._preAudioStats && _this7._preVideoStats)) {
8040
- _context9.next = 27;
8118
+ _context9.next = 28;
8041
8119
  break;
8042
8120
  }
8043
8121
  audioStats = diffRecvAudioStats(_this7._preAudioStats, curAudioStats);
8044
8122
  videoStats = diffRecvVideoStats(_this7._preVideoStats, curVideoStats);
8045
8123
  _this7._videoJitterBufferDelay = videoStats.jitterBufferDelay;
8046
- _context9.next = 19;
8124
+ _context9.next = 20;
8047
8125
  return (_this7$_audioStallObs = _this7._audioStallObserver) === null || _this7$_audioStallObs === void 0 ? void 0 : _this7$_audioStallObs.getAudioStallInfo();
8048
- case 19:
8126
+ case 20:
8049
8127
  audioStallInfo = _context9.sent;
8050
- _context9.next = 22;
8128
+ _context9.next = 23;
8051
8129
  return (_this7$_videoStallObs = _this7._videoStallObserver) === null || _this7$_videoStallObs === void 0 ? void 0 : _this7$_videoStallObs.getStallInfo({
8052
8130
  interval: videoStats.statsInterval,
8053
8131
  frameRateReceived: videoStats.receivedFrameRate,
8054
8132
  frameRateDecoded: videoStats.decoderOutputFrameRate,
8055
8133
  bitrate: videoStats.receivedKBitrate
8056
8134
  });
8057
- case 22:
8135
+ case 23:
8058
8136
  videoStallInfo = _context9.sent;
8059
8137
  _ref6 = (_this7$_networkQualit = (_this7$_networkQualit2 = _this7._networkQuality) === null || _this7$_networkQualit2 === void 0 ? void 0 : _this7$_networkQualit2.getDownlinkQuality(_objectSpread2$2(_objectSpread2$2({}, audioStats), {}, {
8060
8138
  stallDuration: (audioStallInfo === null || audioStallInfo === void 0 ? void 0 : audioStallInfo.stallDuration) || 0
@@ -8067,7 +8145,7 @@
8067
8145
  if (videoStats.estimatedPlayoutTimestamp && audioStats.estimatedPlayoutTimestamp) {
8068
8146
  av_sync_diff = videoStats.estimatedPlayoutTimestamp - audioStats.estimatedPlayoutTimestamp;
8069
8147
  }
8070
- _this7.emit(EXTEND_EVENTS.RTC_NETWORK, {
8148
+ _this7.emit(EXTEND_EVENTS.RTC_NETWORK, _objectSpread2$2({
8071
8149
  interval: videoStats.statsInterval,
8072
8150
  network_quality: quality,
8073
8151
  audio_stall_duration: audioStallInfo === null || audioStallInfo === void 0 ? void 0 : audioStallInfo.stallDuration,
@@ -8100,13 +8178,23 @@
8100
8178
  set_delay_error: _this7._setDelayError || null,
8101
8179
  video_width: ((_this7$_media = _this7._media) === null || _this7$_media === void 0 ? void 0 : _this7$_media.videoWidth) || 0,
8102
8180
  video_height: ((_this7$_media2 = _this7._media) === null || _this7$_media2 === void 0 ? void 0 : _this7$_media2.videoHeight) || 0,
8103
- abr_state: videoStats.abrState || "none"
8104
- });
8105
- case 27:
8181
+ abr_state: videoStats.abrState || "none",
8182
+ recv_frame_rate: videoStats.receivedFrameRate,
8183
+ decode_frame_rate: videoStats.decoderOutputFrameRate,
8184
+ pli: videoStats.pliCount,
8185
+ drop_frame_rate: videoStats.framesDropped,
8186
+ audio_packets_received: audioStats.packetsReceived,
8187
+ video_packets_received: videoStats.packetsReceived,
8188
+ video_muted: (_this7$_media3 = _this7._media) === null || _this7$_media3 === void 0 ? void 0 : _this7$_media3.muted,
8189
+ video_paused: (_this7$_media4 = _this7._media) === null || _this7$_media4 === void 0 ? void 0 : _this7$_media4.paused,
8190
+ video_volume: (_this7$_media5 = _this7._media) === null || _this7$_media5 === void 0 ? void 0 : _this7$_media5.volume,
8191
+ video_current_time: (_this7$_media6 = _this7._media) === null || _this7$_media6 === void 0 ? void 0 : _this7$_media6.currentTime
8192
+ }, ((_this7$_frameRecvCall2 = _this7._frameRecvCallback) === null || _this7$_frameRecvCall2 === void 0 ? void 0 : _this7$_frameRecvCall2.getRecentRenderInfo4Report()) || {}));
8193
+ case 28:
8106
8194
  _this7._preAudioStats = curAudioStats;
8107
8195
  _this7._preVideoStats = curVideoStats;
8108
8196
  _this7._setDelayError = null;
8109
- case 30:
8197
+ case 31:
8110
8198
  case "end":
8111
8199
  return _context9.stop();
8112
8200
  }
@@ -8157,9 +8245,11 @@
8157
8245
  }, {
8158
8246
  key: "_stopRtcReport",
8159
8247
  value: function _stopRtcReport() {
8160
- var _this$_audioStallObse, _this$_videoStallObse, _this$_networkQuality;
8248
+ var _this$_audioStallObse, _this$_videoStallObse, _this$_frameRecvCallb, _this$_networkQuality;
8161
8249
  (_this$_audioStallObse = this._audioStallObserver) === null || _this$_audioStallObse === void 0 ? void 0 : _this$_audioStallObse.destroy();
8162
8250
  (_this$_videoStallObse = this._videoStallObserver) === null || _this$_videoStallObse === void 0 ? void 0 : _this$_videoStallObse.destroy();
8251
+ (_this$_frameRecvCallb = this._frameRecvCallback) === null || _this$_frameRecvCallb === void 0 ? void 0 : _this$_frameRecvCallb.stop();
8252
+ delete this._frameRecvCallback;
8163
8253
  (_this$_networkQuality = this._networkQuality) === null || _this$_networkQuality === void 0 ? void 0 : _this$_networkQuality.destroy();
8164
8254
  delete this._audioStallObserver;
8165
8255
  delete this._videoStallObserver;
@@ -8183,23 +8273,34 @@
8183
8273
  }
8184
8274
  }, {
8185
8275
  key: "_disconnect",
8186
- value: function _disconnect() {
8276
+ value: function _disconnect(reason) {
8187
8277
  var _this$_loader2, _this$_networkEvaluat2;
8188
8278
  this._clearDelay();
8279
+ this._clearMediaSrc();
8189
8280
  (_this$_loader2 = this._loader) === null || _this$_loader2 === void 0 ? void 0 : _this$_loader2.cancel();
8190
8281
  (_this$_networkEvaluat2 = this._networkEvaluate) === null || _this$_networkEvaluat2 === void 0 ? void 0 : _this$_networkEvaluat2.destroy();
8191
8282
  this._stopRtcReport();
8192
8283
  clearTimeout(this._checkStatsErrorTimer);
8193
8284
  this._clearPeerStateTimeout();
8285
+ this._firstFrameObserver.setFailureReason(reason);
8194
8286
  this._firstFrameObserver.reset();
8195
8287
  this._audioTransceicer = null;
8196
8288
  this._videoTransceicer = null;
8197
8289
  this._mediaStream = null;
8198
8290
  }
8291
+ }, {
8292
+ key: "_clearMediaSrc",
8293
+ value: function _clearMediaSrc() {
8294
+ if (this._media) {
8295
+ this._media.srcObject = null;
8296
+ this._media.removeAttribute("src");
8297
+ }
8298
+ }
8199
8299
  }, {
8200
8300
  key: "_emitError",
8201
8301
  value: function _emitError(error) {
8202
8302
  var _error$originError;
8303
+ logger.warn(error);
8203
8304
  this._clearDelay();
8204
8305
  this._firstFrameObserver.setFailureReason((error === null || error === void 0 ? void 0 : (_error$originError = error.originError) === null || _error$originError === void 0 ? void 0 : _error$originError.message) || (error === null || error === void 0 ? void 0 : error.originError) || error);
8205
8306
  this._firstFrameObserver.reset();
@@ -8208,10 +8309,7 @@
8208
8309
  this._clearPeerStateTimeout();
8209
8310
  if (this._pc) {
8210
8311
  this._pc.close();
8211
- if (this._media) {
8212
- this._media.srcObject = null;
8213
- this._media.removeAttribute("src");
8214
- }
8312
+ this._clearMediaSrc();
8215
8313
  }
8216
8314
  }
8217
8315
  }, {
@@ -8313,7 +8411,7 @@
8313
8411
  key: "destroy",
8314
8412
  value: function destroy(keepClearMediaStream) {
8315
8413
  var _this$_revertVolumeWo, _this$_media3;
8316
- this._disconnect();
8414
+ this._disconnect("invoke destroy");
8317
8415
  (_this$_revertVolumeWo = this._revertVolumeWorkaround) === null || _this$_revertVolumeWo === void 0 ? void 0 : _this$_revertVolumeWo.call(this);
8318
8416
  delete this._revertVolumeWorkaround;
8319
8417
  (_this$_media3 = this._media) === null || _this$_media3 === void 0 ? void 0 : _this$_media3.removeEventListener("timeupdate", this._mockWaitingByTimeupdate);
@@ -8398,7 +8496,9 @@
8398
8496
  _this._rts.load(config.url);
8399
8497
  };
8400
8498
  _this._onSwitchURL = function(url) {
8401
- if (url) {
8499
+ if (url.startsWith("blob:") || url === "") {
8500
+ url = _this.player.config.url;
8501
+ } else if (url) {
8402
8502
  _this.player.config.url = url;
8403
8503
  }
8404
8504
  if (_this._rts) {
@@ -8407,9 +8507,20 @@
8407
8507
  _this._reInit();
8408
8508
  }
8409
8509
  };
8510
+ _this.__retry = function() {
8511
+ _this.player.removeClass(STATE_CLASS.ERROR);
8512
+ _this.player.addClass(STATE_CLASS.LOADING);
8513
+ runHooks(_assertThisInitialized$1(_this), "retry", function() {
8514
+ _this.player.src = "";
8515
+ _this.player.once(CANPLAY, function() {
8516
+ _this.player.mediaPlay();
8517
+ });
8518
+ });
8519
+ };
8410
8520
  _this.destroy = function() {
8411
8521
  var _this$_rts3;
8412
8522
  _this.player.switchURL = _this._originSwitchFn;
8523
+ _this.player.retry = _this._originRetry;
8413
8524
  _this._clearDisconnectTimer();
8414
8525
  (_this$_rts3 = _this._rts) === null || _this$_rts3 === void 0 ? void 0 : _this$_rts3.destroy();
8415
8526
  _this._rts = null;
@@ -8454,7 +8565,7 @@
8454
8565
  }, {
8455
8566
  key: "version",
8456
8567
  get: function get() {
8457
- return "0.2.1-alpha.51";
8568
+ return "0.2.1-alpha.53";
8458
8569
  }
8459
8570
  }, {
8460
8571
  key: "beforePlayerInit",
@@ -8465,7 +8576,12 @@
8465
8576
  var _this$player$switchUR;
8466
8577
  this._originSwitchFn = (_this$player$switchUR = this.player.switchURL) === null || _this$player$switchUR === void 0 ? void 0 : _this$player$switchUR.bind(this.player);
8467
8578
  }
8579
+ if (!this._originRetry) {
8580
+ var _this$player$retry;
8581
+ this._originRetry = (_this$player$retry = this.player.retry) === null || _this$player$retry === void 0 ? void 0 : _this$player$retry.bind(this.player);
8582
+ }
8468
8583
  this.player.switchURL = this._onSwitchURL;
8584
+ this.player.retry = this.__retry;
8469
8585
  (_this$player2 = this.player) === null || _this$player2 === void 0 ? void 0 : _this$player2.useHooks("replay", this._onSwitchURL);
8470
8586
  this.on(URL_CHANGE, this._onSwitchURL);
8471
8587
  this.on(DESTROY, this.destroy);
@@ -8495,6 +8611,7 @@
8495
8611
  if (!((_this2$player = _this2.player) !== null && _this2$player !== void 0 && (_this2$player$video = _this2$player.video) !== null && _this2$player$video !== void 0 && _this2$player$video.srcObject)) {
8496
8612
  _this2.player.video.srcObject = new MediaStream();
8497
8613
  }
8614
+ return "";
8498
8615
  }
8499
8616
  }
8500
8617
  }
@@ -8589,6 +8706,7 @@
8589
8706
  });
8590
8707
  player.unRegisterPlugin("rts");
8591
8708
  player.switchURL = _this3._originSwitchFn;
8709
+ player.retry = _this3._originRetry;
8592
8710
  _this3._rts = null;
8593
8711
  player.rts = null;
8594
8712
  if ((_player$video = player.video) !== null && _player$video !== void 0 && _player$video.srcObject) {