@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.
@@ -1753,6 +1753,7 @@ var Errors = /* @__PURE__ */ _createClass$2(
1753
1753
  var PLAY = "play";
1754
1754
  var PAUSE = "pause";
1755
1755
  var ERROR = "error";
1756
+ var CANPLAY = "canplay";
1756
1757
  var DESTROY = "destroy";
1757
1758
  var URL_CHANGE = "urlchange";
1758
1759
  function callHandler(obj, handler, next) {
@@ -2181,6 +2182,37 @@ var BasePlugin = /* @__PURE__ */ function() {
2181
2182
  }]);
2182
2183
  return BasePlugin2;
2183
2184
  }();
2185
+ var STATE_CLASS = {
2186
+ DEFAULT: "xgplayer",
2187
+ DEFAULT_SKIN: "xgplayer-skin-default",
2188
+ ENTER: "xgplayer-is-enter",
2189
+ PAUSED: "xgplayer-pause",
2190
+ PLAYING: "xgplayer-playing",
2191
+ ENDED: "xgplayer-ended",
2192
+ CANPLAY: "xgplayer-canplay",
2193
+ LOADING: "xgplayer-isloading",
2194
+ ERROR: "xgplayer-is-error",
2195
+ REPLAY: "xgplayer-replay",
2196
+ NO_START: "xgplayer-nostart",
2197
+ ACTIVE: "xgplayer-active",
2198
+ INACTIVE: "xgplayer-inactive",
2199
+ FULLSCREEN: "xgplayer-is-fullscreen",
2200
+ CSS_FULLSCREEN: "xgplayer-is-cssfullscreen",
2201
+ ROTATE_FULLSCREEN: "xgplayer-rotate-fullscreen",
2202
+ PARENT_ROTATE_FULLSCREEN: "xgplayer-rotate-parent",
2203
+ PARENT_FULLSCREEN: "xgplayer-fullscreen-parent",
2204
+ INNER_FULLSCREEN: "xgplayer-fullscreen-inner",
2205
+ NO_CONTROLS: "no-controls",
2206
+ FLEX_CONTROLS: "flex-controls",
2207
+ CONTROLS_FOLLOW: "controls-follow",
2208
+ CONTROLS_AUTOHIDE: "controls-autohide",
2209
+ TOP_BAR_AUTOHIDE: "top-bar-autohide",
2210
+ NOT_ALLOW_AUTOPLAY: "not-allow-autoplay",
2211
+ SEEKING: "seeking",
2212
+ PC: "xgplayer-pc",
2213
+ MOBILE: "xgplayer-mobile",
2214
+ MINI: "xgplayer-mini"
2215
+ };
2184
2216
  function ownKeys(object, enumerableOnly) {
2185
2217
  var keys = Object.keys(object);
2186
2218
  if (Object.getOwnPropertySymbols) {
@@ -6695,7 +6727,7 @@ function diffRecvVideoStats(oldStats, newStats) {
6695
6727
  width: newStats.width || 0,
6696
6728
  height: newStats.height || 0,
6697
6729
  estimatedPlayoutTimestamp: newStats.estimatedPlayoutTimestamp,
6698
- videoLossRate: +(packetsLostDiff / (diffNumber(oldStats, newStats, "packetsReceived") + packetsLostDiff)),
6730
+ videoLossRate: +(packetsLostDiff / (diffNumber(oldStats, newStats, "packetsReceived") + packetsLostDiff)).toFixed(2),
6699
6731
  receivedKBitrate: +(diffNumber(oldStats, newStats, "bytesReceived") * 8 / statsInterval).toFixed(2),
6700
6732
  decoderOutputFrameRate: Math.round(diffNumber(oldStats, newStats, "framesDecoded") * 1e3 / statsInterval),
6701
6733
  receivedFrameRate: Math.round(diffNumber(oldStats, newStats, "framesReceived") * 1e3 / statsInterval),
@@ -6877,13 +6909,22 @@ var FirstFrameObserver = /* @__PURE__ */ function() {
6877
6909
  }
6878
6910
  };
6879
6911
  this._handlePlaying = function() {
6912
+ if (!_this._state[RTC_FIRST_FRAME_STATE.PEER_CONNECTED]) {
6913
+ return;
6914
+ }
6880
6915
  _this.changeFirstFrameState(RTC_FIRST_FRAME_STATE.VIDEO_PLAYING);
6881
6916
  _this.reset();
6882
6917
  };
6883
6918
  this._handleCanplay = function() {
6919
+ if (!_this._state[RTC_FIRST_FRAME_STATE.PEER_CONNECTED]) {
6920
+ return;
6921
+ }
6884
6922
  _this.changeFirstFrameState(RTC_FIRST_FRAME_STATE.VIDEO_CANPLAY);
6885
6923
  };
6886
6924
  this._handleLoadeddata = function() {
6925
+ if (!_this._state[RTC_FIRST_FRAME_STATE.PEER_CONNECTED]) {
6926
+ return;
6927
+ }
6887
6928
  _this.changeFirstFrameState(RTC_FIRST_FRAME_STATE.VIDEO_LOADEDDATA);
6888
6929
  };
6889
6930
  this._handleError = function() {
@@ -6950,6 +6991,7 @@ var FirstFrameObserver = /* @__PURE__ */ function() {
6950
6991
  var hasFrameDecoded = false;
6951
6992
  this._cancelWatchForFirstVideoFrameRecv();
6952
6993
  this._firstVideoFrameInterval = window.setInterval(/* @__PURE__ */ _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee() {
6994
+ var _inboundRtpStats, _inboundRtpStats2, _inboundRtpStats3;
6953
6995
  var receiver, reports, inboundRtpStats;
6954
6996
  return _regeneratorRuntime$1().wrap(function _callee$(_context) {
6955
6997
  while (1)
@@ -6965,15 +7007,15 @@ var FirstFrameObserver = /* @__PURE__ */ function() {
6965
7007
  inboundRtpStats = report;
6966
7008
  }
6967
7009
  });
6968
- if (!hasPacketsReceived && inboundRtpStats.packetsReceived > 0) {
7010
+ if (!hasPacketsReceived && (_inboundRtpStats = inboundRtpStats) !== null && _inboundRtpStats !== void 0 && _inboundRtpStats.packetsReceived && inboundRtpStats.packetsReceived > 0) {
6969
7011
  hasPacketsReceived = true;
6970
7012
  _this4.changeFirstFrameState(RTC_FIRST_FRAME_STATE.FIRST_PACKET_RECV);
6971
7013
  }
6972
- if (!hasFrameReceived && inboundRtpStats.framesReceived > 0) {
7014
+ if (!hasFrameReceived && (_inboundRtpStats2 = inboundRtpStats) !== null && _inboundRtpStats2 !== void 0 && _inboundRtpStats2.framesReceived && inboundRtpStats.framesReceived > 0) {
6973
7015
  hasFrameReceived = true;
6974
7016
  _this4.changeFirstFrameState(RTC_FIRST_FRAME_STATE.FIRST_FRAME_RECV);
6975
7017
  }
6976
- if (!hasFrameDecoded && inboundRtpStats.framesDecoded > 0) {
7018
+ if (!hasFrameDecoded && (_inboundRtpStats3 = inboundRtpStats) !== null && _inboundRtpStats3 !== void 0 && _inboundRtpStats3.framesDecoded && inboundRtpStats.framesDecoded > 0) {
6977
7019
  hasFrameDecoded = true;
6978
7020
  _this4.changeFirstFrameState(RTC_FIRST_FRAME_STATE.FIRST_FRAME_DECODED);
6979
7021
  _this4._cancelWatchForFirstVideoFrameRecv();
@@ -6993,103 +7035,84 @@ var FirstFrameObserver = /* @__PURE__ */ function() {
6993
7035
  this._firstVideoFrameInterval = null;
6994
7036
  }
6995
7037
  }
6996
- }, {
6997
- key: "_getTransportInfo",
6998
- value: function() {
6999
- var _getTransportInfo2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee2() {
7000
- var _this$_videoTransceiv, _this$_videoTransceiv2;
7001
- var reports, candidatePairStats, localCandidateStats, remoteCandidateStats;
7002
- return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
7003
- while (1)
7004
- switch (_context2.prev = _context2.next) {
7005
- case 0:
7006
- _context2.next = 2;
7007
- 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();
7008
- case 2:
7009
- reports = _context2.sent;
7010
- reports === null || reports === void 0 ? void 0 : reports.forEach(function(report) {
7011
- if (report.type === "candidate-pair") {
7012
- candidatePairStats = report;
7013
- localCandidateStats = reports.get(report.localCandidateId);
7014
- remoteCandidateStats = reports.get(report.remoteCandidateId);
7015
- }
7016
- });
7017
- if (remoteCandidateStats) {
7018
- this._extraInfo.remote_ip = remoteCandidateStats.ip || remoteCandidateStats.address;
7019
- this._extraInfo.remote_port = remoteCandidateStats.port;
7020
- this._extraInfo.remote_candidate_type = remoteCandidateStats.candidateType;
7021
- this._extraInfo.protocol = remoteCandidateStats.protocol;
7022
- }
7023
- if (localCandidateStats) {
7024
- this._extraInfo.local_ip = localCandidateStats.ip || localCandidateStats.address;
7025
- this._extraInfo.local_port = localCandidateStats.port;
7026
- this._extraInfo.local_candidate_type = localCandidateStats.candidateType;
7027
- }
7028
- if (candidatePairStats) {
7029
- this._extraInfo.rtt = candidatePairStats.currentRoundTripTime;
7030
- this._extraInfo.stun_requests_sent = candidatePairStats.requestsSent;
7031
- this._extraInfo.stun_requests_received = candidatePairStats.requestsReceived;
7032
- this._extraInfo.stun_responses_sent = candidatePairStats.responsesSent;
7033
- this._extraInfo.stun_responses_received = candidatePairStats.responsesReceived;
7034
- }
7035
- case 7:
7036
- case "end":
7037
- return _context2.stop();
7038
- }
7039
- }, _callee2, this);
7040
- }));
7041
- function _getTransportInfo() {
7042
- return _getTransportInfo2.apply(this, arguments);
7043
- }
7044
- return _getTransportInfo;
7045
- }()
7046
7038
  }, {
7047
7039
  key: "reset",
7048
- value: function() {
7049
- var _reset = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee3() {
7050
- var _this$_video, _this$_video2, _this$_video3, _this$_video4, _this$_pc3, _this$_pc4;
7051
- return _regeneratorRuntime$1().wrap(function _callee3$(_context3) {
7052
- while (1)
7053
- switch (_context3.prev = _context3.next) {
7054
- case 0:
7055
- if (!(Object.keys(this._state).length > 0)) {
7056
- _context3.next = 4;
7057
- break;
7058
- }
7059
- _context3.next = 3;
7060
- return this._getTransportInfo();
7061
- case 3:
7062
- this._emitFirstFrameState(this._state, this._extraInfo);
7063
- case 4:
7064
- this._preState = null;
7065
- this._extraInfo = {
7066
- is_preload: false
7067
- };
7068
- this._state = {};
7069
- (_this$_video = this._video) === null || _this$_video === void 0 ? void 0 : _this$_video.removeEventListener("playing", this._handlePlaying);
7070
- (_this$_video2 = this._video) === null || _this$_video2 === void 0 ? void 0 : _this$_video2.removeEventListener("canplay", this._handleCanplay);
7071
- (_this$_video3 = this._video) === null || _this$_video3 === void 0 ? void 0 : _this$_video3.removeEventListener("loadeddata", this._handleLoadeddata);
7072
- (_this$_video4 = this._video) === null || _this$_video4 === void 0 ? void 0 : _this$_video4.removeEventListener("error", this._handleError);
7073
- (_this$_pc3 = this._pc) === null || _this$_pc3 === void 0 ? void 0 : _this$_pc3.removeEventListener("connectionstatechange", this._handleConnectionStateChange);
7074
- (_this$_pc4 = this._pc) === null || _this$_pc4 === void 0 ? void 0 : _this$_pc4.removeEventListener("iceconnectionstatechange", this._handleICEConnectionStateChange);
7075
- this._cancelWatchForFirstVideoFrameRecv();
7076
- this._pc = null;
7077
- this._video = null;
7078
- this._videoTransceiver = null;
7079
- case 17:
7080
- case "end":
7081
- return _context3.stop();
7082
- }
7083
- }, _callee3, this);
7084
- }));
7085
- function reset() {
7086
- return _reset.apply(this, arguments);
7040
+ value: function reset() {
7041
+ var _this5 = this, _this$_video, _this$_video2, _this$_video3, _this$_video4, _this$_pc3, _this$_pc4;
7042
+ if (Object.keys(this._state).length > 0) {
7043
+ var state = _objectSpread2$2({}, this._state);
7044
+ var extraInfo = _objectSpread2$2({}, this._extraInfo);
7045
+ getTransportInfo(this._videoTransceiver, extraInfo).then(function() {
7046
+ _this5._emitFirstFrameState(state, extraInfo);
7047
+ });
7087
7048
  }
7088
- return reset;
7089
- }()
7049
+ this._preState = null;
7050
+ this._extraInfo = {
7051
+ is_preload: false
7052
+ };
7053
+ this._state = {};
7054
+ (_this$_video = this._video) === null || _this$_video === void 0 ? void 0 : _this$_video.removeEventListener("playing", this._handlePlaying);
7055
+ (_this$_video2 = this._video) === null || _this$_video2 === void 0 ? void 0 : _this$_video2.removeEventListener("canplay", this._handleCanplay);
7056
+ (_this$_video3 = this._video) === null || _this$_video3 === void 0 ? void 0 : _this$_video3.removeEventListener("loadeddata", this._handleLoadeddata);
7057
+ (_this$_video4 = this._video) === null || _this$_video4 === void 0 ? void 0 : _this$_video4.removeEventListener("error", this._handleError);
7058
+ (_this$_pc3 = this._pc) === null || _this$_pc3 === void 0 ? void 0 : _this$_pc3.removeEventListener("connectionstatechange", this._handleConnectionStateChange);
7059
+ (_this$_pc4 = this._pc) === null || _this$_pc4 === void 0 ? void 0 : _this$_pc4.removeEventListener("iceconnectionstatechange", this._handleICEConnectionStateChange);
7060
+ this._cancelWatchForFirstVideoFrameRecv();
7061
+ this._pc = null;
7062
+ this._video = null;
7063
+ this._videoTransceiver = null;
7064
+ }
7090
7065
  }]);
7091
7066
  return FirstFrameObserver2;
7092
7067
  }();
7068
+ var getTransportInfo = /* @__PURE__ */ function() {
7069
+ var _ref4 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee2(videoTransceiver, extraInfo) {
7070
+ var _videoTransceiver$rec;
7071
+ var reports, candidatePairStats, localCandidateStats, remoteCandidateStats;
7072
+ return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
7073
+ while (1)
7074
+ switch (_context2.prev = _context2.next) {
7075
+ case 0:
7076
+ _context2.next = 2;
7077
+ return videoTransceiver === null || videoTransceiver === void 0 ? void 0 : (_videoTransceiver$rec = videoTransceiver.receiver) === null || _videoTransceiver$rec === void 0 ? void 0 : _videoTransceiver$rec.getStats().catch(function() {
7078
+ });
7079
+ case 2:
7080
+ reports = _context2.sent;
7081
+ reports === null || reports === void 0 ? void 0 : reports.forEach(function(report) {
7082
+ if (report.type === "candidate-pair") {
7083
+ candidatePairStats = report;
7084
+ localCandidateStats = reports.get(report.localCandidateId);
7085
+ remoteCandidateStats = reports.get(report.remoteCandidateId);
7086
+ }
7087
+ });
7088
+ if (remoteCandidateStats) {
7089
+ extraInfo.remote_ip = remoteCandidateStats.ip || remoteCandidateStats.address;
7090
+ extraInfo.remote_port = remoteCandidateStats.port;
7091
+ extraInfo.remote_candidate_type = remoteCandidateStats.candidateType;
7092
+ extraInfo.protocol = remoteCandidateStats.protocol;
7093
+ }
7094
+ if (localCandidateStats) {
7095
+ extraInfo.local_ip = localCandidateStats.ip || localCandidateStats.address;
7096
+ extraInfo.local_port = localCandidateStats.port;
7097
+ extraInfo.local_candidate_type = localCandidateStats.candidateType;
7098
+ }
7099
+ if (candidatePairStats) {
7100
+ extraInfo.rtt = candidatePairStats.currentRoundTripTime;
7101
+ extraInfo.stun_requests_sent = candidatePairStats.requestsSent;
7102
+ extraInfo.stun_requests_received = candidatePairStats.requestsReceived;
7103
+ extraInfo.stun_responses_sent = candidatePairStats.responsesSent;
7104
+ extraInfo.stun_responses_received = candidatePairStats.responsesReceived;
7105
+ }
7106
+ case 7:
7107
+ case "end":
7108
+ return _context2.stop();
7109
+ }
7110
+ }, _callee2);
7111
+ }));
7112
+ return function getTransportInfo2(_x, _x2) {
7113
+ return _ref4.apply(this, arguments);
7114
+ };
7115
+ }();
7093
7116
  function changeNumberInRange(source, min, max, delta) {
7094
7117
  var target = source + delta;
7095
7118
  if (target > max) {
@@ -7153,6 +7176,58 @@ function isHeyTapBrowser() {
7153
7176
  function isVivoBrowser() {
7154
7177
  return /(VivoBrowser)/i.test(navigator.userAgent);
7155
7178
  }
7179
+ var VideoFrameRecvCallback = /* @__PURE__ */ function() {
7180
+ function VideoFrameRecvCallback2() {
7181
+ var _this = this;
7182
+ _classCallCheck$3(this, VideoFrameRecvCallback2);
7183
+ this._onVideoRefresh = function(_, data) {
7184
+ var _this$_domElement;
7185
+ _this._recentVideoInfo = data;
7186
+ _this._requestVideoFrameCallbackTimer = (_this$_domElement = _this._domElement) === null || _this$_domElement === void 0 ? void 0 : _this$_domElement.requestVideoFrameCallback(_this._onVideoRefresh);
7187
+ };
7188
+ }
7189
+ _createClass$3(VideoFrameRecvCallback2, [{
7190
+ key: "start",
7191
+ value: function start(domElement) {
7192
+ var _this2 = this;
7193
+ this._domElement = domElement;
7194
+ if (typeof HTMLVideoElement.prototype.requestVideoFrameCallback === "function") {
7195
+ if (domElement) {
7196
+ this._requestVideoFrameCallbackTimer = domElement.requestVideoFrameCallback(this._onVideoRefresh.bind(this));
7197
+ this._removeHandler = function() {
7198
+ _this2._requestVideoFrameCallbackTimer && (domElement === null || domElement === void 0 ? void 0 : domElement.cancelVideoFrameCallback(_this2._requestVideoFrameCallbackTimer));
7199
+ };
7200
+ }
7201
+ }
7202
+ }
7203
+ }, {
7204
+ key: "stop",
7205
+ value: function stop() {
7206
+ var _this$_removeHandler;
7207
+ delete this._recentVideoInfo;
7208
+ delete this._domElement;
7209
+ (_this$_removeHandler = this._removeHandler) === null || _this$_removeHandler === void 0 ? void 0 : _this$_removeHandler.call(this);
7210
+ delete this._removeHandler;
7211
+ }
7212
+ }, {
7213
+ key: "getRecentRenderInfo4Report",
7214
+ value: function getRecentRenderInfo4Report() {
7215
+ var _this3 = this;
7216
+ var obj = {};
7217
+ if (this._recentVideoInfo) {
7218
+ Object.keys(this._recentVideoInfo).forEach(function(k) {
7219
+ var _this3$_recentVideoIn;
7220
+ var key = k.replace(/[a-z]{1}[A-Z]{1}/g, function(e) {
7221
+ return "".concat(e[0], "_").concat(e[1].toLowerCase());
7222
+ });
7223
+ obj["video_".concat(key)] = (_this3$_recentVideoIn = _this3._recentVideoInfo) === null || _this3$_recentVideoIn === void 0 ? void 0 : _this3$_recentVideoIn[k];
7224
+ });
7225
+ }
7226
+ return obj;
7227
+ }
7228
+ }]);
7229
+ return VideoFrameRecvCallback2;
7230
+ }();
7156
7231
  var logger = new Logger("rts");
7157
7232
  var Rts = /* @__PURE__ */ function(_EventEmitter) {
7158
7233
  _inherits$1(Rts2, _EventEmitter);
@@ -7516,7 +7591,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7516
7591
  }, {
7517
7592
  key: "load",
7518
7593
  value: function() {
7519
- var _load = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee6(url) {
7594
+ var _load = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee6(url, failureReason) {
7520
7595
  var _this2 = this;
7521
7596
  var lastPc, answerSdp, errorStr, preloadPromise, info, encodedTransformSupported;
7522
7597
  return _regeneratorRuntime$1().wrap(function _callee6$(_context6) {
@@ -7524,7 +7599,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7524
7599
  switch (_context6.prev = _context6.next) {
7525
7600
  case 0:
7526
7601
  logger.log("load()", 'invoked, url: "'.concat(url, '"'));
7527
- this._disconnect();
7602
+ this._disconnect(failureReason || "invoke load");
7528
7603
  this._url = url;
7529
7604
  lastPc = this._pc;
7530
7605
  if (!this._opts.hackCreateOfferIssue) {
@@ -7537,7 +7612,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7537
7612
  _context6.prev = 7;
7538
7613
  this._firstFrameObserver.start();
7539
7614
  if (!this._preloadPromise) {
7540
- _context6.next = 39;
7615
+ _context6.next = 38;
7541
7616
  break;
7542
7617
  }
7543
7618
  logger.log("load()", "in preload process...");
@@ -7571,51 +7646,50 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7571
7646
  this.initVideoEncodedTransform();
7572
7647
  this.initAudioEncodedTransform();
7573
7648
  }
7574
- _context6.next = 37;
7649
+ _context6.next = 36;
7575
7650
  break;
7576
7651
  case 31:
7577
7652
  _context6.prev = 31;
7578
7653
  _context6.t0 = _context6["catch"](11);
7579
7654
  logger.warn("load()", "preload failed, ".concat(_context6.t0.message || _context6.t0.toString()));
7580
- this._firstFrameObserver.setFailureReason(_context6.t0.message || _context6.t0.toString());
7581
- this.load(url);
7655
+ this.load(url, _context6.t0.message || _context6.t0.toString());
7582
7656
  return _context6.abrupt("return");
7583
- case 37:
7584
- _context6.next = 45;
7657
+ case 36:
7658
+ _context6.next = 44;
7585
7659
  break;
7586
- case 39:
7660
+ case 38:
7587
7661
  encodedTransformSupported = isLegacyEncodedTransformSupported();
7588
7662
  logger.log("load()", "isLegacyEncodedTransformSupported: ".concat(encodedTransformSupported));
7589
7663
  this._pc = new RTCPeerConnection({
7590
7664
  encodedInsertableStreams: encodedTransformSupported && this._opts.enableSei ? true : void 0
7591
7665
  });
7592
- _context6.next = 44;
7666
+ _context6.next = 43;
7593
7667
  return this._getAnswerSdp(this._pc);
7594
- case 44:
7668
+ case 43:
7595
7669
  answerSdp = _context6.sent;
7596
- case 45:
7670
+ case 44:
7597
7671
  this._bindRTCEvents(this._pc);
7598
- _context6.next = 48;
7672
+ _context6.next = 47;
7599
7673
  return this._handleAnswerSdp(this._pc, answerSdp);
7600
- case 48:
7674
+ case 47:
7601
7675
  if (lastPc) {
7602
7676
  lastPc.close();
7603
7677
  }
7604
- _context6.next = 54;
7678
+ _context6.next = 53;
7605
7679
  break;
7606
- case 51:
7607
- _context6.prev = 51;
7680
+ case 50:
7681
+ _context6.prev = 50;
7608
7682
  _context6.t1 = _context6["catch"](7);
7609
7683
  setTimeout(function() {
7610
7684
  return _this2._emitError(StreamingError.create(ERR.OTHER, null, _context6.t1));
7611
7685
  });
7612
- case 54:
7686
+ case 53:
7613
7687
  case "end":
7614
7688
  return _context6.stop();
7615
7689
  }
7616
- }, _callee6, this, [[7, 51], [11, 31]]);
7690
+ }, _callee6, this, [[7, 50], [11, 31]]);
7617
7691
  }));
7618
- function load(_x2) {
7692
+ function load(_x2, _x3) {
7619
7693
  return _load.apply(this, arguments);
7620
7694
  }
7621
7695
  return load;
@@ -7624,7 +7698,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7624
7698
  key: "switchURL",
7625
7699
  value: function switchURL(url) {
7626
7700
  logger.log("switchURL()", 'invoked, url: "'.concat(url, '"'));
7627
- this.load(url || this._url);
7701
+ this.load(url || this._url, "invoke switchURL");
7628
7702
  }
7629
7703
  }, {
7630
7704
  key: "_bindRTCEvents",
@@ -7648,7 +7722,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7648
7722
  return;
7649
7723
  }
7650
7724
  _this3._retry--;
7651
- _this3.load(_this3._url);
7725
+ _this3.load(_this3._url, "rtc connect failed");
7652
7726
  }
7653
7727
  if (pc.connectionState === "connected") {
7654
7728
  _this3._handleMediaStream();
@@ -7903,7 +7977,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7903
7977
  }
7904
7978
  }, _callee7, this, [[26, 51]]);
7905
7979
  }));
7906
- function _getAnswerSdp(_x3) {
7980
+ function _getAnswerSdp(_x4) {
7907
7981
  return _getAnswerSdp2.apply(this, arguments);
7908
7982
  }
7909
7983
  return _getAnswerSdp;
@@ -7967,7 +8041,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7967
8041
  }
7968
8042
  }, _callee8, this);
7969
8043
  }));
7970
- function _handleAnswerSdp(_x4, _x5) {
8044
+ function _handleAnswerSdp(_x5, _x6) {
7971
8045
  return _handleAnswerSdp2.apply(this, arguments);
7972
8046
  }
7973
8047
  return _handleAnswerSdp;
@@ -8001,7 +8075,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
8001
8075
  var report = /* @__PURE__ */ function() {
8002
8076
  var _ref5 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee9() {
8003
8077
  var _this7$_audioTranscei, _this7$_videoTranscei;
8004
- 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;
8078
+ 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;
8005
8079
  return _regeneratorRuntime$1().wrap(function _callee9$(_context9) {
8006
8080
  while (1)
8007
8081
  switch (_context9.prev = _context9.next) {
@@ -8022,35 +8096,39 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
8022
8096
  _this7._videoStallObserver = new VideoStallObserver();
8023
8097
  _this7._videoStallObserver.start(_this7._media);
8024
8098
  }
8099
+ if (!_this7._frameRecvCallback && _this7._media) {
8100
+ _this7._frameRecvCallback = new VideoFrameRecvCallback();
8101
+ (_this7$_frameRecvCall = _this7._frameRecvCallback) === null || _this7$_frameRecvCall === void 0 ? void 0 : _this7$_frameRecvCall.start(_this7._media);
8102
+ }
8025
8103
  if (_this7._pc && !_this7._networkQuality && _this7._opts.enableNetworkQuality && _this7._opts.networkQuality) {
8026
8104
  _this7._networkQuality = new NetworkQuality(_this7._pc, _this7._opts.networkQuality);
8027
8105
  }
8028
- _context9.next = 9;
8106
+ _context9.next = 10;
8029
8107
  return Promise.all([getRecvAudioStats(_this7._audioTransceicer.receiver.getStats()), getRecvVideoStats(_this7._videoTransceicer.receiver.getStats())]);
8030
- case 9:
8108
+ case 10:
8031
8109
  _yield$Promise$all3 = _context9.sent;
8032
8110
  _yield$Promise$all4 = _slicedToArray(_yield$Promise$all3, 2);
8033
8111
  curAudioStats = _yield$Promise$all4[0];
8034
8112
  curVideoStats = _yield$Promise$all4[1];
8035
8113
  if (!(_this7._preAudioStats && _this7._preVideoStats)) {
8036
- _context9.next = 27;
8114
+ _context9.next = 28;
8037
8115
  break;
8038
8116
  }
8039
8117
  audioStats = diffRecvAudioStats(_this7._preAudioStats, curAudioStats);
8040
8118
  videoStats = diffRecvVideoStats(_this7._preVideoStats, curVideoStats);
8041
8119
  _this7._videoJitterBufferDelay = videoStats.jitterBufferDelay;
8042
- _context9.next = 19;
8120
+ _context9.next = 20;
8043
8121
  return (_this7$_audioStallObs = _this7._audioStallObserver) === null || _this7$_audioStallObs === void 0 ? void 0 : _this7$_audioStallObs.getAudioStallInfo();
8044
- case 19:
8122
+ case 20:
8045
8123
  audioStallInfo = _context9.sent;
8046
- _context9.next = 22;
8124
+ _context9.next = 23;
8047
8125
  return (_this7$_videoStallObs = _this7._videoStallObserver) === null || _this7$_videoStallObs === void 0 ? void 0 : _this7$_videoStallObs.getStallInfo({
8048
8126
  interval: videoStats.statsInterval,
8049
8127
  frameRateReceived: videoStats.receivedFrameRate,
8050
8128
  frameRateDecoded: videoStats.decoderOutputFrameRate,
8051
8129
  bitrate: videoStats.receivedKBitrate
8052
8130
  });
8053
- case 22:
8131
+ case 23:
8054
8132
  videoStallInfo = _context9.sent;
8055
8133
  _ref6 = (_this7$_networkQualit = (_this7$_networkQualit2 = _this7._networkQuality) === null || _this7$_networkQualit2 === void 0 ? void 0 : _this7$_networkQualit2.getDownlinkQuality(_objectSpread2$2(_objectSpread2$2({}, audioStats), {}, {
8056
8134
  stallDuration: (audioStallInfo === null || audioStallInfo === void 0 ? void 0 : audioStallInfo.stallDuration) || 0
@@ -8063,7 +8141,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
8063
8141
  if (videoStats.estimatedPlayoutTimestamp && audioStats.estimatedPlayoutTimestamp) {
8064
8142
  av_sync_diff = videoStats.estimatedPlayoutTimestamp - audioStats.estimatedPlayoutTimestamp;
8065
8143
  }
8066
- _this7.emit(EXTEND_EVENTS.RTC_NETWORK, {
8144
+ _this7.emit(EXTEND_EVENTS.RTC_NETWORK, _objectSpread2$2({
8067
8145
  interval: videoStats.statsInterval,
8068
8146
  network_quality: quality,
8069
8147
  audio_stall_duration: audioStallInfo === null || audioStallInfo === void 0 ? void 0 : audioStallInfo.stallDuration,
@@ -8096,13 +8174,23 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
8096
8174
  set_delay_error: _this7._setDelayError || null,
8097
8175
  video_width: ((_this7$_media = _this7._media) === null || _this7$_media === void 0 ? void 0 : _this7$_media.videoWidth) || 0,
8098
8176
  video_height: ((_this7$_media2 = _this7._media) === null || _this7$_media2 === void 0 ? void 0 : _this7$_media2.videoHeight) || 0,
8099
- abr_state: videoStats.abrState || "none"
8100
- });
8101
- case 27:
8177
+ abr_state: videoStats.abrState || "none",
8178
+ recv_frame_rate: videoStats.receivedFrameRate,
8179
+ decode_frame_rate: videoStats.decoderOutputFrameRate,
8180
+ pli: videoStats.pliCount,
8181
+ drop_frame_rate: videoStats.framesDropped,
8182
+ audio_packets_received: audioStats.packetsReceived,
8183
+ video_packets_received: videoStats.packetsReceived,
8184
+ video_muted: (_this7$_media3 = _this7._media) === null || _this7$_media3 === void 0 ? void 0 : _this7$_media3.muted,
8185
+ video_paused: (_this7$_media4 = _this7._media) === null || _this7$_media4 === void 0 ? void 0 : _this7$_media4.paused,
8186
+ video_volume: (_this7$_media5 = _this7._media) === null || _this7$_media5 === void 0 ? void 0 : _this7$_media5.volume,
8187
+ video_current_time: (_this7$_media6 = _this7._media) === null || _this7$_media6 === void 0 ? void 0 : _this7$_media6.currentTime
8188
+ }, ((_this7$_frameRecvCall2 = _this7._frameRecvCallback) === null || _this7$_frameRecvCall2 === void 0 ? void 0 : _this7$_frameRecvCall2.getRecentRenderInfo4Report()) || {}));
8189
+ case 28:
8102
8190
  _this7._preAudioStats = curAudioStats;
8103
8191
  _this7._preVideoStats = curVideoStats;
8104
8192
  _this7._setDelayError = null;
8105
- case 30:
8193
+ case 31:
8106
8194
  case "end":
8107
8195
  return _context9.stop();
8108
8196
  }
@@ -8153,9 +8241,11 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
8153
8241
  }, {
8154
8242
  key: "_stopRtcReport",
8155
8243
  value: function _stopRtcReport() {
8156
- var _this$_audioStallObse, _this$_videoStallObse, _this$_networkQuality;
8244
+ var _this$_audioStallObse, _this$_videoStallObse, _this$_frameRecvCallb, _this$_networkQuality;
8157
8245
  (_this$_audioStallObse = this._audioStallObserver) === null || _this$_audioStallObse === void 0 ? void 0 : _this$_audioStallObse.destroy();
8158
8246
  (_this$_videoStallObse = this._videoStallObserver) === null || _this$_videoStallObse === void 0 ? void 0 : _this$_videoStallObse.destroy();
8247
+ (_this$_frameRecvCallb = this._frameRecvCallback) === null || _this$_frameRecvCallb === void 0 ? void 0 : _this$_frameRecvCallb.stop();
8248
+ delete this._frameRecvCallback;
8159
8249
  (_this$_networkQuality = this._networkQuality) === null || _this$_networkQuality === void 0 ? void 0 : _this$_networkQuality.destroy();
8160
8250
  delete this._audioStallObserver;
8161
8251
  delete this._videoStallObserver;
@@ -8179,23 +8269,34 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
8179
8269
  }
8180
8270
  }, {
8181
8271
  key: "_disconnect",
8182
- value: function _disconnect() {
8272
+ value: function _disconnect(reason) {
8183
8273
  var _this$_loader2, _this$_networkEvaluat2;
8184
8274
  this._clearDelay();
8275
+ this._clearMediaSrc();
8185
8276
  (_this$_loader2 = this._loader) === null || _this$_loader2 === void 0 ? void 0 : _this$_loader2.cancel();
8186
8277
  (_this$_networkEvaluat2 = this._networkEvaluate) === null || _this$_networkEvaluat2 === void 0 ? void 0 : _this$_networkEvaluat2.destroy();
8187
8278
  this._stopRtcReport();
8188
8279
  clearTimeout(this._checkStatsErrorTimer);
8189
8280
  this._clearPeerStateTimeout();
8281
+ this._firstFrameObserver.setFailureReason(reason);
8190
8282
  this._firstFrameObserver.reset();
8191
8283
  this._audioTransceicer = null;
8192
8284
  this._videoTransceicer = null;
8193
8285
  this._mediaStream = null;
8194
8286
  }
8287
+ }, {
8288
+ key: "_clearMediaSrc",
8289
+ value: function _clearMediaSrc() {
8290
+ if (this._media) {
8291
+ this._media.srcObject = null;
8292
+ this._media.removeAttribute("src");
8293
+ }
8294
+ }
8195
8295
  }, {
8196
8296
  key: "_emitError",
8197
8297
  value: function _emitError(error) {
8198
8298
  var _error$originError;
8299
+ logger.warn(error);
8199
8300
  this._clearDelay();
8200
8301
  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);
8201
8302
  this._firstFrameObserver.reset();
@@ -8204,10 +8305,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
8204
8305
  this._clearPeerStateTimeout();
8205
8306
  if (this._pc) {
8206
8307
  this._pc.close();
8207
- if (this._media) {
8208
- this._media.srcObject = null;
8209
- this._media.removeAttribute("src");
8210
- }
8308
+ this._clearMediaSrc();
8211
8309
  }
8212
8310
  }
8213
8311
  }, {
@@ -8309,7 +8407,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
8309
8407
  key: "destroy",
8310
8408
  value: function destroy(keepClearMediaStream) {
8311
8409
  var _this$_revertVolumeWo, _this$_media3;
8312
- this._disconnect();
8410
+ this._disconnect("invoke destroy");
8313
8411
  (_this$_revertVolumeWo = this._revertVolumeWorkaround) === null || _this$_revertVolumeWo === void 0 ? void 0 : _this$_revertVolumeWo.call(this);
8314
8412
  delete this._revertVolumeWorkaround;
8315
8413
  (_this$_media3 = this._media) === null || _this$_media3 === void 0 ? void 0 : _this$_media3.removeEventListener("timeupdate", this._mockWaitingByTimeupdate);
@@ -8394,7 +8492,9 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
8394
8492
  _this._rts.load(config.url);
8395
8493
  };
8396
8494
  _this._onSwitchURL = function(url) {
8397
- if (url) {
8495
+ if (url.startsWith("blob:") || url === "") {
8496
+ url = _this.player.config.url;
8497
+ } else if (url) {
8398
8498
  _this.player.config.url = url;
8399
8499
  }
8400
8500
  if (_this._rts) {
@@ -8403,9 +8503,20 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
8403
8503
  _this._reInit();
8404
8504
  }
8405
8505
  };
8506
+ _this.__retry = function() {
8507
+ _this.player.removeClass(STATE_CLASS.ERROR);
8508
+ _this.player.addClass(STATE_CLASS.LOADING);
8509
+ runHooks(_assertThisInitialized$1(_this), "retry", function() {
8510
+ _this.player.src = "";
8511
+ _this.player.once(CANPLAY, function() {
8512
+ _this.player.mediaPlay();
8513
+ });
8514
+ });
8515
+ };
8406
8516
  _this.destroy = function() {
8407
8517
  var _this$_rts3;
8408
8518
  _this.player.switchURL = _this._originSwitchFn;
8519
+ _this.player.retry = _this._originRetry;
8409
8520
  _this._clearDisconnectTimer();
8410
8521
  (_this$_rts3 = _this._rts) === null || _this$_rts3 === void 0 ? void 0 : _this$_rts3.destroy();
8411
8522
  _this._rts = null;
@@ -8450,7 +8561,7 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
8450
8561
  }, {
8451
8562
  key: "version",
8452
8563
  get: function get() {
8453
- return "0.2.1-alpha.51";
8564
+ return "0.2.1-alpha.53";
8454
8565
  }
8455
8566
  }, {
8456
8567
  key: "beforePlayerInit",
@@ -8461,7 +8572,12 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
8461
8572
  var _this$player$switchUR;
8462
8573
  this._originSwitchFn = (_this$player$switchUR = this.player.switchURL) === null || _this$player$switchUR === void 0 ? void 0 : _this$player$switchUR.bind(this.player);
8463
8574
  }
8575
+ if (!this._originRetry) {
8576
+ var _this$player$retry;
8577
+ this._originRetry = (_this$player$retry = this.player.retry) === null || _this$player$retry === void 0 ? void 0 : _this$player$retry.bind(this.player);
8578
+ }
8464
8579
  this.player.switchURL = this._onSwitchURL;
8580
+ this.player.retry = this.__retry;
8465
8581
  (_this$player2 = this.player) === null || _this$player2 === void 0 ? void 0 : _this$player2.useHooks("replay", this._onSwitchURL);
8466
8582
  this.on(URL_CHANGE, this._onSwitchURL);
8467
8583
  this.on(DESTROY, this.destroy);
@@ -8491,6 +8607,7 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
8491
8607
  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)) {
8492
8608
  _this2.player.video.srcObject = new MediaStream();
8493
8609
  }
8610
+ return "";
8494
8611
  }
8495
8612
  }
8496
8613
  }
@@ -8585,6 +8702,7 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
8585
8702
  });
8586
8703
  player.unRegisterPlugin("rts");
8587
8704
  player.switchURL = _this3._originSwitchFn;
8705
+ player.retry = _this3._originRetry;
8588
8706
  _this3._rts = null;
8589
8707
  player.rts = null;
8590
8708
  if ((_player$video = player.video) !== null && _player$video !== void 0 && _player$video.srcObject) {