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

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.
@@ -5078,9 +5078,9 @@ lib.parsePayloads = parser.parsePayloads;
5078
5078
  lib.parseRemoteCandidates = parser.parseRemoteCandidates;
5079
5079
  lib.parseImageAttributes = parser.parseImageAttributes;
5080
5080
  lib.parseSimulcastStreamList = parser.parseSimulcastStreamList;
5081
- var _excluded = ["adaptiveJitterBuffer"];
5081
+ var _excluded = ["adaptiveJitterBuffer", "standardizeKillSwitch"];
5082
5082
  function getOption(options) {
5083
- var _ref = options || {}, _ref$adaptiveJitterBu = _ref.adaptiveJitterBuffer, adaptiveJitterBuffer = _ref$adaptiveJitterBu === void 0 ? {} : _ref$adaptiveJitterBu, opts = _objectWithoutProperties$1(_ref, _excluded);
5083
+ var _ref = options || {}, _ref$adaptiveJitterBu = _ref.adaptiveJitterBuffer, adaptiveJitterBuffer = _ref$adaptiveJitterBu === void 0 ? {} : _ref$adaptiveJitterBu, _ref$standardizeKillS = _ref.standardizeKillSwitch, standardizeKillSwitch = _ref$standardizeKillS === void 0 ? {} : _ref$standardizeKillS, opts = _objectWithoutProperties$1(_ref, _excluded);
5084
5084
  return _objectSpread2$2({
5085
5085
  retryCount: 0,
5086
5086
  retryDelay: 1e3,
@@ -5151,7 +5151,12 @@ function getOption(options) {
5151
5151
  5: {
5152
5152
  jitterBuffer: 3
5153
5153
  }
5154
- }
5154
+ },
5155
+ standardizeKillSwitch: _objectSpread2$2({
5156
+ sld_fmtp_opus: true,
5157
+ sld_rtcpfb_opus_nack: true,
5158
+ sld_fmtp_sps_pps: true
5159
+ }, standardizeKillSwitch)
5155
5160
  }, opts);
5156
5161
  }
5157
5162
  function _getStats(stats) {
@@ -5493,7 +5498,7 @@ function getCapacity() {
5493
5498
  });
5494
5499
  }
5495
5500
  var isEncodedTransformSupported = function isEncodedTransformSupported2() {
5496
- return typeof TransformStream !== "undefined" && typeof RTCRtpSender !== "undefined" && typeof RTCRtpReceiver !== "undefined" && typeof RTCRtpScriptTransform !== "undefined" && "transform" in RTCRtpSender.prototype && "transform" in RTCRtpReceiver.prototype && isWorkerSupported() && isMessageChannelSupported();
5501
+ return typeof window.TransformStream !== "undefined" && typeof window.RTCRtpSender !== "undefined" && typeof window.RTCRtpReceiver !== "undefined" && typeof window.RTCRtpScriptTransform !== "undefined" && "transform" in window.RTCRtpSender.prototype && "transform" in window.RTCRtpReceiver.prototype && isWorkerSupported() && isMessageChannelSupported();
5497
5502
  };
5498
5503
  var isWorkerSupported = function isWorkerSupported2() {
5499
5504
  return typeof window !== "undefined" && window.Worker;
@@ -5502,7 +5507,7 @@ var isMessageChannelSupported = function isMessageChannelSupported2() {
5502
5507
  return typeof MessageChannel !== "undefined";
5503
5508
  };
5504
5509
  var isLegacyEncodedTransformSupported = function isLegacyEncodedTransformSupported2() {
5505
- return typeof TransformStream !== "undefined" && typeof RTCRtpSender !== "undefined" && typeof RTCRtpReceiver !== "undefined" && typeof RTCRtpSender.prototype.createEncodedStreams !== "undefined" && typeof RTCRtpReceiver.prototype.createEncodedStreams !== "undefined";
5510
+ return typeof window.TransformStream !== "undefined" && typeof window.RTCRtpSender !== "undefined" && typeof window.RTCRtpReceiver !== "undefined" && typeof window.RTCRtpSender.prototype.createEncodedStreams !== "undefined" && typeof window.RTCRtpReceiver.prototype.createEncodedStreams !== "undefined";
5506
5511
  };
5507
5512
  var Nalunit = {
5508
5513
  getNALUnits: function getNALUnits(buffer) {
@@ -6680,6 +6685,8 @@ function _getRecvVideoStats() {
6680
6685
  currentStats.firCount = stat.firCount;
6681
6686
  currentStats.nackCount = stat.nackCount;
6682
6687
  currentStats.pliCount = stat.pliCount;
6688
+ currentStats.fecPacketsReceived = stat.fecPacketsReceived;
6689
+ currentStats.fecSsrc = stat.fecSsrc;
6683
6690
  if (stat.jitterBufferDelay !== void 0) {
6684
6691
  currentStats.jitterBufferEmittedCount = stat.jitterBufferEmittedCount;
6685
6692
  currentStats.jitterBufferDelay = stat.jitterBufferDelay;
@@ -6744,12 +6751,14 @@ function diffRecvVideoStats(oldStats, newStats) {
6744
6751
  nackCount,
6745
6752
  pliCount: diffNumber(oldStats, newStats, "pliCount"),
6746
6753
  e2eDelay: Math.round((newStats.rtt || 0) + jitterBufferDelay),
6747
- retransmittedRate: +(nackCount / (packetsReceived + packetsLostDiff)).toFixed(2)
6754
+ retransmittedRate: +(nackCount / (packetsReceived + packetsLostDiff)).toFixed(2),
6755
+ fecPacketsReceived: diffNumber(oldStats, newStats, "fecPacketsReceived"),
6756
+ fecSsrc: newStats.fecSsrc
6748
6757
  };
6749
6758
  }
6750
6759
  function diffNumber(oldValue, newValue, key) {
6751
- var oldV = Number.isNaN(oldValue[key]) ? 0 : +oldValue[key];
6752
- var newV = Number.isNaN(newValue[key]) ? 0 : +newValue[key];
6760
+ var oldV = !Number.isFinite(oldValue[key]) ? 0 : +oldValue[key];
6761
+ var newV = !Number.isFinite(newValue[key]) ? 0 : +newValue[key];
6753
6762
  return Math.max(0, newV - oldV);
6754
6763
  }
6755
6764
  var QoELevel = {
@@ -6880,6 +6889,63 @@ var NetworkQuality = /* @__PURE__ */ function() {
6880
6889
  }]);
6881
6890
  return NetworkQuality2;
6882
6891
  }();
6892
+ var gpuInfo;
6893
+ function getGpuInfo() {
6894
+ if (!gpuInfo) {
6895
+ gpuInfo = _getGpuInfo();
6896
+ }
6897
+ return gpuInfo;
6898
+ }
6899
+ function _getGpuInfo() {
6900
+ var canvas = document.createElement("canvas");
6901
+ var gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
6902
+ if (!gl) {
6903
+ return {
6904
+ renderer: "unknown(WebGLRenderingContext not existed)",
6905
+ vendor: "unknown(WebGLRenderingContext not existed)"
6906
+ };
6907
+ }
6908
+ var info = gl.getExtension("WEBGL_debug_renderer_info");
6909
+ if (!info) {
6910
+ return {
6911
+ renderer: "unknown(info not existed)",
6912
+ vendor: "unknown(info not existed)"
6913
+ };
6914
+ }
6915
+ var renderer = gl.getParameter(info.UNMASKED_RENDERER_WEBGL);
6916
+ var vendor = gl.getParameter(info.UNMASKED_VENDOR_WEBGL);
6917
+ if (canvas && canvas.parentNode) {
6918
+ canvas.parentNode.removeChild(canvas);
6919
+ }
6920
+ canvas = void 0;
6921
+ gl = void 0;
6922
+ return {
6923
+ renderer,
6924
+ vendor
6925
+ };
6926
+ }
6927
+ function extractProfileInfo(sdpFmtpLine) {
6928
+ var profileLevelId = "";
6929
+ if (!sdpFmtpLine) {
6930
+ return profileLevelId;
6931
+ }
6932
+ var paramArray = sdpFmtpLine.split(";");
6933
+ var _iterator = _createForOfIteratorHelper$1(paramArray), _step;
6934
+ try {
6935
+ for (_iterator.s(); !(_step = _iterator.n()).done; ) {
6936
+ var param = _step.value;
6937
+ var _param$trim$split = param.trim().split("="), _param$trim$split2 = _slicedToArray(_param$trim$split, 2), key = _param$trim$split2[0], value = _param$trim$split2[1];
6938
+ if (key === "profile-level-id") {
6939
+ profileLevelId = value;
6940
+ }
6941
+ }
6942
+ } catch (err) {
6943
+ _iterator.e(err);
6944
+ } finally {
6945
+ _iterator.f();
6946
+ }
6947
+ return profileLevelId;
6948
+ }
6883
6949
  var FIRST_FRAME_STATE_ORDER = [RTC_FIRST_FRAME_STATE.LOAD_START, RTC_FIRST_FRAME_STATE.OFFER_SDP_READY, RTC_FIRST_FRAME_STATE.ANSWER_SDP_RECV, RTC_FIRST_FRAME_STATE.ANSWER_SDP_READY, RTC_FIRST_FRAME_STATE.ICE_CONNECTED, RTC_FIRST_FRAME_STATE.DTLS_CONNECTED, RTC_FIRST_FRAME_STATE.PEER_CONNECTED, RTC_FIRST_FRAME_STATE.FIRST_PACKET_RECV, RTC_FIRST_FRAME_STATE.FIRST_FRAME_RECV, RTC_FIRST_FRAME_STATE.FIRST_FRAME_DECODED, RTC_FIRST_FRAME_STATE.VIDEO_LOADEDDATA, RTC_FIRST_FRAME_STATE.VIDEO_CANPLAY, RTC_FIRST_FRAME_STATE.VIDEO_PLAYING];
6884
6950
  var FirstFrameObserver = /* @__PURE__ */ function() {
6885
6951
  function FirstFrameObserver2(_emitFirstFrameState) {
@@ -6893,6 +6959,7 @@ var FirstFrameObserver = /* @__PURE__ */ function() {
6893
6959
  this._pc = null;
6894
6960
  this._video = null;
6895
6961
  this._videoTransceiver = null;
6962
+ this._audioTransceiver = null;
6896
6963
  this._extraInfo = {
6897
6964
  is_preload: false
6898
6965
  };
@@ -6965,11 +7032,12 @@ var FirstFrameObserver = /* @__PURE__ */ function() {
6965
7032
  }
6966
7033
  }, {
6967
7034
  key: "bindEvents",
6968
- value: function bindEvents(pc, videoTransceiver, video) {
7035
+ value: function bindEvents(pc, videoTransceiver, audioTransceiver, video) {
6969
7036
  var _this3 = this;
6970
7037
  this._pc = pc;
6971
7038
  this._video = video;
6972
7039
  this._videoTransceiver = videoTransceiver;
7040
+ this._audioTransceiver = audioTransceiver;
6973
7041
  pc.addEventListener("connectionstatechange", this._handleConnectionStateChange);
6974
7042
  pc.addEventListener("iceconnectionstatechange", this._handleICEConnectionStateChange);
6975
7043
  var _ref2 = (videoTransceiver === null || videoTransceiver === void 0 ? void 0 : videoTransceiver.receiver) || {}, transport = _ref2.transport;
@@ -7043,7 +7111,9 @@ var FirstFrameObserver = /* @__PURE__ */ function() {
7043
7111
  if (Object.keys(this._state).length > 0) {
7044
7112
  var state = _objectSpread2$2({}, this._state);
7045
7113
  var extraInfo = _objectSpread2$2({}, this._extraInfo);
7046
- getTransportInfo(this._videoTransceiver, extraInfo).then(function() {
7114
+ Promise.all([getTransportInfo(this._videoTransceiver, extraInfo), getAudioCodecInfo(this._audioTransceiver, extraInfo)]).catch(function(e) {
7115
+ extraInfo.failure_reason = e.message;
7116
+ }).finally(function() {
7047
7117
  _this5._emitFirstFrameState(state, extraInfo);
7048
7118
  });
7049
7119
  }
@@ -7062,6 +7132,7 @@ var FirstFrameObserver = /* @__PURE__ */ function() {
7062
7132
  this._pc = null;
7063
7133
  this._video = null;
7064
7134
  this._videoTransceiver = null;
7135
+ this._audioTransceiver = null;
7065
7136
  }
7066
7137
  }]);
7067
7138
  return FirstFrameObserver2;
@@ -7069,7 +7140,7 @@ var FirstFrameObserver = /* @__PURE__ */ function() {
7069
7140
  var getTransportInfo = /* @__PURE__ */ function() {
7070
7141
  var _ref4 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee2(videoTransceiver, extraInfo) {
7071
7142
  var _videoTransceiver$rec;
7072
- var reports, candidatePairStats, localCandidateStats, remoteCandidateStats;
7143
+ var reports, candidatePairStats, localCandidateStats, remoteCandidateStats, inboundRtpStats, codecStats, _inboundRtpStats4;
7073
7144
  return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
7074
7145
  while (1)
7075
7146
  switch (_context2.prev = _context2.next) {
@@ -7084,6 +7155,9 @@ var getTransportInfo = /* @__PURE__ */ function() {
7084
7155
  candidatePairStats = report;
7085
7156
  localCandidateStats = reports.get(report.localCandidateId);
7086
7157
  remoteCandidateStats = reports.get(report.remoteCandidateId);
7158
+ } else if (report.type === "inbound-rtp") {
7159
+ inboundRtpStats = report;
7160
+ codecStats = reports.get(report.codecId);
7087
7161
  }
7088
7162
  });
7089
7163
  if (remoteCandidateStats) {
@@ -7104,7 +7178,20 @@ var getTransportInfo = /* @__PURE__ */ function() {
7104
7178
  extraInfo.stun_responses_sent = candidatePairStats.responsesSent;
7105
7179
  extraInfo.stun_responses_received = candidatePairStats.responsesReceived;
7106
7180
  }
7107
- case 7:
7181
+ if (codecStats) {
7182
+ extraInfo.video_codec = codecStats.mimeType;
7183
+ extraInfo.video_fmtp = codecStats.sdpFmtpLine;
7184
+ extraInfo.video_profile_level_id = extractProfileInfo(codecStats.sdpFmtpLine);
7185
+ }
7186
+ if (inboundRtpStats) {
7187
+ extraInfo.video_width = inboundRtpStats.frameWidth;
7188
+ extraInfo.video_height = inboundRtpStats.frameHeight;
7189
+ extraInfo.video_framerate = inboundRtpStats.framesPerSecond;
7190
+ extraInfo.video_decoder_name = inboundRtpStats.decoderImplementation;
7191
+ extraInfo.video_result = ((_inboundRtpStats4 = inboundRtpStats) === null || _inboundRtpStats4 === void 0 ? void 0 : _inboundRtpStats4.framesDecoded) > 0 ? true : false;
7192
+ }
7193
+ extraInfo.gpu_info = getGpuInfo().renderer;
7194
+ case 10:
7108
7195
  case "end":
7109
7196
  return _context2.stop();
7110
7197
  }
@@ -7114,6 +7201,43 @@ var getTransportInfo = /* @__PURE__ */ function() {
7114
7201
  return _ref4.apply(this, arguments);
7115
7202
  };
7116
7203
  }();
7204
+ var getAudioCodecInfo = /* @__PURE__ */ function() {
7205
+ var _ref5 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee3(audioTransceiver, extraInfo) {
7206
+ var _audioTransceiver$rec;
7207
+ var reports, inboundRtpStats, codecStats, _inboundRtpStats5, _inboundRtpStats6, _inboundRtpStats7, _inboundRtpStats8, _inboundRtpStats9, _inboundRtpStats10;
7208
+ return _regeneratorRuntime$1().wrap(function _callee3$(_context3) {
7209
+ while (1)
7210
+ switch (_context3.prev = _context3.next) {
7211
+ case 0:
7212
+ _context3.next = 2;
7213
+ return audioTransceiver === null || audioTransceiver === void 0 ? void 0 : (_audioTransceiver$rec = audioTransceiver.receiver) === null || _audioTransceiver$rec === void 0 ? void 0 : _audioTransceiver$rec.getStats().catch(function() {
7214
+ });
7215
+ case 2:
7216
+ reports = _context3.sent;
7217
+ reports === null || reports === void 0 ? void 0 : reports.forEach(function(report) {
7218
+ if (report.type === "inbound-rtp") {
7219
+ inboundRtpStats = report;
7220
+ codecStats = reports.get(report.codecId);
7221
+ }
7222
+ });
7223
+ if (codecStats) {
7224
+ extraInfo.audio_codec = codecStats.mimeType;
7225
+ extraInfo.audio_fmtp = codecStats.sdpFmtpLine;
7226
+ }
7227
+ if (inboundRtpStats) {
7228
+ extraInfo.audio_packet_received = ((_inboundRtpStats5 = inboundRtpStats) === null || _inboundRtpStats5 === void 0 ? void 0 : _inboundRtpStats5.packetsReceived) > 0;
7229
+ extraInfo.audio_result = ((_inboundRtpStats6 = inboundRtpStats) === null || _inboundRtpStats6 === void 0 ? void 0 : _inboundRtpStats6.audioLevel) !== 0 || ((_inboundRtpStats7 = inboundRtpStats) === null || _inboundRtpStats7 === void 0 ? void 0 : _inboundRtpStats7.totalAudioEnergy) !== 0 || ((_inboundRtpStats8 = inboundRtpStats) === null || _inboundRtpStats8 === void 0 ? void 0 : _inboundRtpStats8.totalSamplesReceived) > 0 && ((_inboundRtpStats9 = inboundRtpStats) === null || _inboundRtpStats9 === void 0 ? void 0 : _inboundRtpStats9.totalSamplesReceived) !== ((_inboundRtpStats10 = inboundRtpStats) === null || _inboundRtpStats10 === void 0 ? void 0 : _inboundRtpStats10.concealedSamples) ? true : false;
7230
+ }
7231
+ case 6:
7232
+ case "end":
7233
+ return _context3.stop();
7234
+ }
7235
+ }, _callee3);
7236
+ }));
7237
+ return function getAudioCodecInfo2(_x3, _x4) {
7238
+ return _ref5.apply(this, arguments);
7239
+ };
7240
+ }();
7117
7241
  function changeNumberInRange(source, min, max, delta) {
7118
7242
  var target = source + delta;
7119
7243
  if (target > max) {
@@ -7177,6 +7301,9 @@ function isHeyTapBrowser() {
7177
7301
  function isVivoBrowser() {
7178
7302
  return /(VivoBrowser)/i.test(navigator.userAgent);
7179
7303
  }
7304
+ function isPositiveNumber(num) {
7305
+ return typeof num === "number" && num > 0;
7306
+ }
7180
7307
  var VideoFrameRecvCallback = /* @__PURE__ */ function() {
7181
7308
  function VideoFrameRecvCallback2() {
7182
7309
  var _this = this;
@@ -7267,7 +7394,8 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7267
7394
  clearTimeout(_this._checkStatsErrorTimer);
7268
7395
  }
7269
7396
  _this._checkStatsErrorTimer = setTimeout(/* @__PURE__ */ _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee() {
7270
- var stats, _stats$video, framesDecoded, bytesReceived;
7397
+ var _stats$video, _stats$audio, _stats$video2, _stats$video3;
7398
+ var stats;
7271
7399
  return _regeneratorRuntime$1().wrap(function _callee$(_context) {
7272
7400
  while (1)
7273
7401
  switch (_context.prev = _context.next) {
@@ -7276,19 +7404,17 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7276
7404
  return _this.getStatsSnapshoot();
7277
7405
  case 2:
7278
7406
  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
- }
7407
+ 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)) {
7408
+ _this._emitError(StreamingError.create(ERR.MEDIA, ERR.SUB_TYPES.MEDIA_ERR_DECODE, {
7409
+ message: "rts receive empty"
7410
+ }));
7411
+ }
7412
+ 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)) {
7413
+ _this._emitError(StreamingError.create(ERR.MEDIA, ERR.SUB_TYPES.MEDIA_ERR_DECODE, {
7414
+ message: "rts decode error"
7415
+ }));
7290
7416
  }
7291
- case 4:
7417
+ case 5:
7292
7418
  case "end":
7293
7419
  return _context.stop();
7294
7420
  }
@@ -7392,13 +7518,13 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7392
7518
  _this$_opts$adaptiveJ = _this._opts.adaptiveJitterBuffer, loopInterval = _this$_opts$adaptiveJ.loopInterval, maxAvSyncDelay = _this$_opts$adaptiveJ.maxAvSyncDelay, maxJitterBufferDiff = _this$_opts$adaptiveJ.maxJitterBufferDiff, maxStep = _this$_opts$adaptiveJ.maxStep;
7393
7519
  avDiffTooMuchCount = 0;
7394
7520
  _this._setDelayTimer = setInterval(/* @__PURE__ */ _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee3() {
7395
- var _this$_audioTransceic4, _this$_videoTransceic3, currentTargetDelay, targetDelayMs, currentTargetDelayMs, _yield$Promise$all, _yield$Promise$all2, curAudioStats, curVideoStats, audioStats, videoStats, av_sync_diff, currentAudioDelay, currentVideoDelay, addOrReduce, nextJitterBufferDelay;
7521
+ var _this$_audioTransceic4, _this$_audioTransceic5, _this$_videoTransceic3, _this$_videoTransceic4, currentTargetDelay, targetDelayMs, currentTargetDelayMs, _yield$Promise$all, _yield$Promise$all2, curAudioStats, curVideoStats, audioStats, videoStats, av_sync_diff, currentAudioDelay, currentVideoDelay, addOrReduce, nextJitterBufferDelay;
7396
7522
  return _regeneratorRuntime$1().wrap(function _callee3$(_context3) {
7397
7523
  while (1)
7398
7524
  switch (_context3.prev = _context3.next) {
7399
7525
  case 0:
7400
7526
  _context3.prev = 0;
7401
- if (!(!((_this$_audioTransceic4 = _this._audioTransceicer) !== null && _this$_audioTransceic4 !== void 0 && _this$_audioTransceic4.receiver) || !((_this$_videoTransceic3 = _this._videoTransceicer) !== null && _this$_videoTransceic3 !== void 0 && _this$_videoTransceic3.receiver))) {
7527
+ if (!(!((_this$_audioTransceic4 = _this._audioTransceicer) !== null && _this$_audioTransceic4 !== void 0 && (_this$_audioTransceic5 = _this$_audioTransceic4.receiver) !== null && _this$_audioTransceic5 !== void 0 && _this$_audioTransceic5.getStats) || !((_this$_videoTransceic3 = _this._videoTransceicer) !== null && _this$_videoTransceic3 !== void 0 && (_this$_videoTransceic4 = _this$_videoTransceic3.receiver) !== null && _this$_videoTransceic4 !== void 0 && _this$_videoTransceic4.getStats))) {
7402
7528
  _context3.next = 5;
7403
7529
  break;
7404
7530
  }
@@ -7489,20 +7615,19 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7489
7615
  }();
7490
7616
  _this._getDelay = function() {
7491
7617
  try {
7492
- var _this$_audioTransceic6;
7618
+ var _this$_audioTransceic7;
7493
7619
  var key = ["playoutDelayHint", "jitterBufferDelayHint", "jitterBufferTarget"].find(function(key2) {
7494
- var _this$_videoTransceic4, _this$_audioTransceic5;
7495
- return key2 in (((_this$_videoTransceic4 = _this._videoTransceicer) === null || _this$_videoTransceic4 === void 0 ? void 0 : _this$_videoTransceic4.receiver) || {}) && key2 in (((_this$_audioTransceic5 = _this._audioTransceicer) === null || _this$_audioTransceic5 === void 0 ? void 0 : _this$_audioTransceic5.receiver) || {});
7620
+ var _this$_videoTransceic5, _this$_audioTransceic6;
7621
+ return key2 in (((_this$_videoTransceic5 = _this._videoTransceicer) === null || _this$_videoTransceic5 === void 0 ? void 0 : _this$_videoTransceic5.receiver) || {}) && key2 in (((_this$_audioTransceic6 = _this._audioTransceicer) === null || _this$_audioTransceic6 === void 0 ? void 0 : _this$_audioTransceic6.receiver) || {});
7496
7622
  });
7497
7623
  if (!key)
7498
7624
  return;
7499
- return (_this$_audioTransceic6 = _this._audioTransceicer) === null || _this$_audioTransceic6 === void 0 ? void 0 : _this$_audioTransceic6.receiver[key];
7625
+ return (_this$_audioTransceic7 = _this._audioTransceicer) === null || _this$_audioTransceic7 === void 0 ? void 0 : _this$_audioTransceic7.receiver[key];
7500
7626
  } catch (error) {
7501
7627
  logger.error("get delay error");
7502
7628
  }
7503
7629
  };
7504
7630
  _this._onLoaderRetry = function(error, retryTime) {
7505
- console.log(error, "retryTime", retryTime);
7506
7631
  _this.emit(EVENT.LOAD_RETRY, {
7507
7632
  error: StreamingError.network(error),
7508
7633
  retryTime
@@ -7594,7 +7719,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7594
7719
  value: function() {
7595
7720
  var _load = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee6(url, failureReason) {
7596
7721
  var _this2 = this;
7597
- var lastPc, answerSdp, errorStr, preloadPromise, info, encodedTransformSupported;
7722
+ var lastPc, pc, answerSdp, errorStr, preloadPromise, info, encodedTransformSupported;
7598
7723
  return _regeneratorRuntime$1().wrap(function _callee6$(_context6) {
7599
7724
  while (1)
7600
7725
  switch (_context6.prev = _context6.next) {
@@ -7602,44 +7727,47 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7602
7727
  logger.log("load()", 'invoked, url: "'.concat(url, '"'));
7603
7728
  this._disconnect(failureReason || "invoke load");
7604
7729
  this._url = url;
7730
+ this._retry = this._opts.retryCount || 0;
7605
7731
  lastPc = this._pc;
7732
+ pc = null;
7606
7733
  if (!this._opts.hackCreateOfferIssue) {
7607
- _context6.next = 7;
7734
+ _context6.next = 9;
7608
7735
  break;
7609
7736
  }
7610
- _context6.next = 7;
7737
+ _context6.next = 9;
7611
7738
  return this._createEmptyPeer();
7612
- case 7:
7613
- _context6.prev = 7;
7739
+ case 9:
7740
+ _context6.prev = 9;
7614
7741
  this._firstFrameObserver.start();
7615
7742
  if (!this._preloadPromise) {
7616
- _context6.next = 38;
7743
+ _context6.next = 41;
7617
7744
  break;
7618
7745
  }
7619
7746
  logger.log("load()", "in preload process...");
7620
- _context6.prev = 11;
7747
+ _context6.prev = 13;
7621
7748
  this._firstFrameObserver.setIsPreload(true);
7622
7749
  if (compareURL(this._url, this._preloadPromise.url, ["tabr_start_bitrate"])) {
7623
- _context6.next = 17;
7750
+ _context6.next = 19;
7624
7751
  break;
7625
7752
  }
7626
7753
  errorStr = "preload url not match, current url: ".concat(this._url, ", preload url: ").concat(this._preloadPromise.url);
7627
7754
  delete this._preloadPromise;
7628
7755
  throw new Error(errorStr);
7629
- case 17:
7756
+ case 19:
7757
+ this._loader && (this._loader.finnalUrl = this._preloadPromise.url);
7630
7758
  preloadPromise = this._preloadPromise.promise;
7631
7759
  delete this._preloadPromise;
7632
- _context6.next = 21;
7760
+ _context6.next = 24;
7633
7761
  return preloadPromise;
7634
- case 21:
7762
+ case 24:
7635
7763
  info = _context6.sent;
7636
7764
  if (!(info.pc.signalingState !== "have-local-offer")) {
7637
- _context6.next = 24;
7765
+ _context6.next = 27;
7638
7766
  break;
7639
7767
  }
7640
7768
  throw new Error('pc.signalingState not equal "have-local-offer", current state is '.concat(info.pc.signalingState));
7641
- case 24:
7642
- this._pc = info.pc;
7769
+ case 27:
7770
+ pc = info.pc;
7643
7771
  answerSdp = info.answerSdp;
7644
7772
  this._videoTransceicer = info.videoTransceiver;
7645
7773
  this._audioTransceicer = info.audioTransceiver;
@@ -7647,48 +7775,49 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7647
7775
  this.initVideoEncodedTransform();
7648
7776
  this.initAudioEncodedTransform();
7649
7777
  }
7650
- _context6.next = 36;
7778
+ _context6.next = 39;
7651
7779
  break;
7652
- case 31:
7653
- _context6.prev = 31;
7654
- _context6.t0 = _context6["catch"](11);
7780
+ case 34:
7781
+ _context6.prev = 34;
7782
+ _context6.t0 = _context6["catch"](13);
7655
7783
  logger.warn("load()", "preload failed, ".concat(_context6.t0.message || _context6.t0.toString()));
7656
7784
  this.load(url, _context6.t0.message || _context6.t0.toString());
7657
7785
  return _context6.abrupt("return");
7658
- case 36:
7659
- _context6.next = 44;
7786
+ case 39:
7787
+ _context6.next = 47;
7660
7788
  break;
7661
- case 38:
7789
+ case 41:
7662
7790
  encodedTransformSupported = isLegacyEncodedTransformSupported();
7663
7791
  logger.log("load()", "isLegacyEncodedTransformSupported: ".concat(encodedTransformSupported));
7664
- this._pc = new RTCPeerConnection({
7792
+ pc = new RTCPeerConnection({
7665
7793
  encodedInsertableStreams: encodedTransformSupported && this._opts.enableSei ? true : void 0
7666
7794
  });
7667
- _context6.next = 43;
7668
- return this._getAnswerSdp(this._pc);
7669
- case 43:
7795
+ _context6.next = 46;
7796
+ return this._getAnswerSdp(pc);
7797
+ case 46:
7670
7798
  answerSdp = _context6.sent;
7671
- case 44:
7672
- this._bindRTCEvents(this._pc);
7673
- _context6.next = 47;
7674
- return this._handleAnswerSdp(this._pc, answerSdp);
7675
7799
  case 47:
7800
+ this._bindRTCEvents(pc);
7801
+ _context6.next = 50;
7802
+ return this._handleAnswerSdp(pc, answerSdp);
7803
+ case 50:
7676
7804
  if (lastPc) {
7677
7805
  lastPc.close();
7678
7806
  }
7679
- _context6.next = 53;
7807
+ this._pc = pc;
7808
+ _context6.next = 57;
7680
7809
  break;
7681
- case 50:
7682
- _context6.prev = 50;
7683
- _context6.t1 = _context6["catch"](7);
7810
+ case 54:
7811
+ _context6.prev = 54;
7812
+ _context6.t1 = _context6["catch"](9);
7684
7813
  setTimeout(function() {
7685
7814
  return _this2._emitError(StreamingError.create(ERR.OTHER, null, _context6.t1));
7686
7815
  });
7687
- case 53:
7816
+ case 57:
7688
7817
  case "end":
7689
7818
  return _context6.stop();
7690
7819
  }
7691
- }, _callee6, this, [[7, 50], [11, 31]]);
7820
+ }, _callee6, this, [[9, 54], [13, 34]]);
7692
7821
  }));
7693
7822
  function load(_x2, _x3) {
7694
7823
  return _load.apply(this, arguments);
@@ -7706,6 +7835,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7706
7835
  value: function _bindRTCEvents(pc) {
7707
7836
  var _this3 = this;
7708
7837
  pc.addEventListener("track", this._onTrack);
7838
+ var firstConnect = true;
7709
7839
  pc.addEventListener("connectionstatechange", function() {
7710
7840
  logger.warn("onconnectionstatechange:", pc.connectionState);
7711
7841
  _this3._clearPeerStateTimeout();
@@ -7713,26 +7843,31 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7713
7843
  state: pc.connectionState,
7714
7844
  url: _this3._url
7715
7845
  });
7716
- if (pc.connectionState === "disconnected" || pc.connectionState === "failed") {
7717
- _this3.emit("waiting");
7718
- _this3._stopRtcReport();
7719
- }
7720
7846
  if (pc.connectionState === "failed") {
7847
+ var _this3$_preAudioStats, _this3$_preVideoStats;
7848
+ 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
7849
  if (_this3._retry === 0) {
7722
- _this3._emitError(StreamingError.network(new Error("rtc connect failed")));
7850
+ _this3._emitError(StreamingError.network(new Error(reason)));
7723
7851
  return;
7724
7852
  }
7725
7853
  _this3._retry--;
7726
- _this3.load(_this3._url, "rtc connect failed");
7854
+ _this3.load(_this3._url, reason);
7855
+ }
7856
+ if (pc.connectionState === "disconnected" || pc.connectionState === "failed") {
7857
+ _this3.emit("waiting");
7858
+ _this3._stopRtcReport();
7727
7859
  }
7728
7860
  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();
7861
+ if (firstConnect) {
7862
+ firstConnect = false;
7863
+ _this3._handleMediaStream();
7864
+ _this3.emit(EVENT.TTFB, {
7865
+ url: _this3._url,
7866
+ responseUrl: _this3._url,
7867
+ elapsed: Date.now() - _this3._rctConnectStartTs
7868
+ });
7869
+ _this3._checkStatsError();
7870
+ }
7736
7871
  _this3._startRtcReport();
7737
7872
  }
7738
7873
  });
@@ -7825,6 +7960,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7825
7960
  key: "_getAnswerSdp",
7826
7961
  value: function() {
7827
7962
  var _getAnswerSdp2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee7(pc) {
7963
+ var _this6 = this, _this$_opts$standardi;
7828
7964
  var offer, answerSdp, parsed, finnalUrl, _this$_opts, _this$_loader, _this$_opts2, _parsed$media, parseSession, sessionId, reqStart, res, answer, err;
7829
7965
  return _regeneratorRuntime$1().wrap(function _callee7$(_context7) {
7830
7966
  while (1)
@@ -7876,31 +8012,38 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7876
8012
  parsed.media.filter(function(x) {
7877
8013
  return x.type === "audio";
7878
8014
  }).forEach(function(x) {
7879
- var _x$rtp$filter$, _x$rtcpFb;
8015
+ var _x$rtp$filter$, _this6$_opts$standard, _this6$_opts$standard2;
7880
8016
  var opusPayload = (_x$rtp$filter$ = x.rtp.filter(function(rtp) {
7881
8017
  return rtp.codec === "opus";
7882
8018
  })[0]) === null || _x$rtp$filter$ === void 0 ? void 0 : _x$rtp$filter$.payload;
7883
8019
  if (!opusPayload)
7884
8020
  return;
7885
- x.fmtp.forEach(function(fmtp) {
7886
- if (fmtp.payload !== opusPayload)
7887
- return;
7888
- fmtp.config = "minptime=10;stereo=1;useinbandfec=1";
7889
- });
7890
- (_x$rtcpFb = x.rtcpFb) === null || _x$rtcpFb === void 0 ? void 0 : _x$rtcpFb.push({
7891
- payload: opusPayload,
7892
- type: "nack"
7893
- });
8021
+ if ((_this6$_opts$standard = _this6._opts.standardizeKillSwitch) !== null && _this6$_opts$standard !== void 0 && _this6$_opts$standard.sld_fmtp_opus) {
8022
+ x.fmtp.forEach(function(fmtp) {
8023
+ if (fmtp.payload !== opusPayload)
8024
+ return;
8025
+ fmtp.config = "minptime=10;stereo=1;useinbandfec=1";
8026
+ });
8027
+ }
8028
+ if ((_this6$_opts$standard2 = _this6._opts.standardizeKillSwitch) !== null && _this6$_opts$standard2 !== void 0 && _this6$_opts$standard2.sld_rtcpfb_opus_nack) {
8029
+ var _x$rtcpFb;
8030
+ (_x$rtcpFb = x.rtcpFb) === null || _x$rtcpFb === void 0 ? void 0 : _x$rtcpFb.push({
8031
+ payload: opusPayload,
8032
+ type: "nack"
8033
+ });
8034
+ }
7894
8035
  });
7895
- parsed.media.filter(function(x) {
7896
- return x.type === "video";
7897
- }).forEach(function(x) {
7898
- x.fmtp.forEach(function(x2) {
7899
- if (x2.config.indexOf("profile-level-id") !== -1) {
7900
- x2.config = "".concat(x2.config, ";sps-pps-idr-in-keyframe=1");
7901
- }
8036
+ if ((_this$_opts$standardi = this._opts.standardizeKillSwitch) !== null && _this$_opts$standardi !== void 0 && _this$_opts$standardi.sld_fmtp_sps_pps) {
8037
+ parsed.media.filter(function(x) {
8038
+ return x.type === "video";
8039
+ }).forEach(function(x) {
8040
+ x.fmtp.forEach(function(x2) {
8041
+ if (x2.config.indexOf("profile-level-id") !== -1) {
8042
+ x2.config = "".concat(x2.config, ";sps-pps-idr-in-keyframe=1");
8043
+ }
8044
+ });
7902
8045
  });
7903
- });
8046
+ }
7904
8047
  offer.sdp = lib.write(parsed);
7905
8048
  logger.log("local offer modified:\n", offer);
7906
8049
  _context7.next = 25;
@@ -8035,7 +8178,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
8035
8178
  this._firstFrameObserver.changeFirstFrameState(RTC_FIRST_FRAME_STATE.ANSWER_SDP_READY);
8036
8179
  this._networkEvaluate = new NetworkEvaluate(pc, this._opts.networkEvaluateInterval);
8037
8180
  this._listenPeerStateTimeout();
8038
- this._firstFrameObserver.bindEvents(pc, this._videoTransceicer, this._media);
8181
+ this._firstFrameObserver.bindEvents(pc, this._videoTransceicer, this._audioTransceicer, this._media);
8039
8182
  case 17:
8040
8183
  case "end":
8041
8184
  return _context8.stop();
@@ -8050,11 +8193,11 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
8050
8193
  }, {
8051
8194
  key: "_listenPeerStateTimeout",
8052
8195
  value: function _listenPeerStateTimeout() {
8053
- var _this6 = this;
8196
+ var _this7 = this;
8054
8197
  this._clearPeerStateTimeout();
8055
8198
  if (this._opts.connectionStateChangeTimeout) {
8056
8199
  this._peerStateTimer = setTimeout(function() {
8057
- _this6._emitError(StreamingError.create(ERR.MEDIA, ERR.SUB_TYPES.MEDIA_ERR_SRC_NOT_SUPPORTED, {
8200
+ _this7._emitError(StreamingError.create(ERR.MEDIA, ERR.SUB_TYPES.MEDIA_ERR_SRC_NOT_SUPPORTED, {
8058
8201
  message: "listen connectionstatechange timeout"
8059
8202
  }));
8060
8203
  }, this._opts.connectionStateChangeTimeout);
@@ -8071,59 +8214,59 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
8071
8214
  }, {
8072
8215
  key: "_startRtcReport",
8073
8216
  value: function _startRtcReport() {
8074
- var _this7 = this;
8217
+ var _this8 = this;
8075
8218
  this._stopRtcReport();
8076
8219
  var report = /* @__PURE__ */ function() {
8077
8220
  var _ref5 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee9() {
8078
- var _this7$_audioTranscei, _this7$_videoTranscei;
8079
- 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;
8221
+ var _this8$_audioTranscei, _this8$_audioTranscei2, _this8$_videoTranscei, _this8$_videoTranscei2;
8222
+ var _this8$_frameRecvCall, _yield$Promise$all3, _yield$Promise$all4, curAudioStats, curVideoStats, _this8$_audioStallObs, _this8$_videoStallObs, _this8$_networkQualit, _this8$_networkQualit2, _this8$_media, _this8$_media2, _this8$_media3, _this8$_media4, _this8$_media5, _this8$_media6, _this8$_frameRecvCall2, audioStats, videoStats, audioStallInfo, videoStallInfo, _ref6, _ref7, quality, qualityInfo, av_sync_diff;
8080
8223
  return _regeneratorRuntime$1().wrap(function _callee9$(_context9) {
8081
8224
  while (1)
8082
8225
  switch (_context9.prev = _context9.next) {
8083
8226
  case 0:
8084
- if (!(!((_this7$_audioTranscei = _this7._audioTransceicer) !== null && _this7$_audioTranscei !== void 0 && _this7$_audioTranscei.receiver) || !((_this7$_videoTranscei = _this7._videoTransceicer) !== null && _this7$_videoTranscei !== void 0 && _this7$_videoTranscei.receiver))) {
8227
+ if (!(!((_this8$_audioTranscei = _this8._audioTransceicer) !== null && _this8$_audioTranscei !== void 0 && (_this8$_audioTranscei2 = _this8$_audioTranscei.receiver) !== null && _this8$_audioTranscei2 !== void 0 && _this8$_audioTranscei2.getStats) || !((_this8$_videoTranscei = _this8._videoTransceicer) !== null && _this8$_videoTranscei !== void 0 && (_this8$_videoTranscei2 = _this8$_videoTranscei.receiver) !== null && _this8$_videoTranscei2 !== void 0 && _this8$_videoTranscei2.getStats))) {
8085
8228
  _context9.next = 4;
8086
8229
  break;
8087
8230
  }
8088
- _this7._preAudioStats = null;
8089
- _this7._preVideoStats = null;
8231
+ _this8._preAudioStats = null;
8232
+ _this8._preVideoStats = null;
8090
8233
  return _context9.abrupt("return");
8091
8234
  case 4:
8092
- if (!_this7._audioStallObserver && _this7._audioTransceicer) {
8093
- _this7._audioStallObserver = new AudioStallObserver();
8094
- _this7._audioStallObserver.start(_this7._audioTransceicer);
8235
+ if (!_this8._audioStallObserver && _this8._audioTransceicer) {
8236
+ _this8._audioStallObserver = new AudioStallObserver();
8237
+ _this8._audioStallObserver.start(_this8._audioTransceicer);
8095
8238
  }
8096
- if (!_this7._videoStallObserver && _this7._video && _this7._media) {
8097
- _this7._videoStallObserver = new VideoStallObserver();
8098
- _this7._videoStallObserver.start(_this7._media);
8239
+ if (!_this8._videoStallObserver && _this8._video && _this8._media) {
8240
+ _this8._videoStallObserver = new VideoStallObserver();
8241
+ _this8._videoStallObserver.start(_this8._media);
8099
8242
  }
8100
- if (!_this7._frameRecvCallback && _this7._media) {
8101
- _this7._frameRecvCallback = new VideoFrameRecvCallback();
8102
- (_this7$_frameRecvCall = _this7._frameRecvCallback) === null || _this7$_frameRecvCall === void 0 ? void 0 : _this7$_frameRecvCall.start(_this7._media);
8243
+ if (!_this8._frameRecvCallback && _this8._media) {
8244
+ _this8._frameRecvCallback = new VideoFrameRecvCallback();
8245
+ (_this8$_frameRecvCall = _this8._frameRecvCallback) === null || _this8$_frameRecvCall === void 0 ? void 0 : _this8$_frameRecvCall.start(_this8._media);
8103
8246
  }
8104
- if (_this7._pc && !_this7._networkQuality && _this7._opts.enableNetworkQuality && _this7._opts.networkQuality) {
8105
- _this7._networkQuality = new NetworkQuality(_this7._pc, _this7._opts.networkQuality);
8247
+ if (_this8._pc && !_this8._networkQuality && _this8._opts.enableNetworkQuality && _this8._opts.networkQuality) {
8248
+ _this8._networkQuality = new NetworkQuality(_this8._pc, _this8._opts.networkQuality);
8106
8249
  }
8107
8250
  _context9.next = 10;
8108
- return Promise.all([getRecvAudioStats(_this7._audioTransceicer.receiver.getStats()), getRecvVideoStats(_this7._videoTransceicer.receiver.getStats())]);
8251
+ return Promise.all([getRecvAudioStats(_this8._audioTransceicer.receiver.getStats()), getRecvVideoStats(_this8._videoTransceicer.receiver.getStats())]);
8109
8252
  case 10:
8110
8253
  _yield$Promise$all3 = _context9.sent;
8111
8254
  _yield$Promise$all4 = _slicedToArray(_yield$Promise$all3, 2);
8112
8255
  curAudioStats = _yield$Promise$all4[0];
8113
8256
  curVideoStats = _yield$Promise$all4[1];
8114
- if (!(_this7._preAudioStats && _this7._preVideoStats)) {
8257
+ if (!(_this8._preAudioStats && _this8._preVideoStats)) {
8115
8258
  _context9.next = 28;
8116
8259
  break;
8117
8260
  }
8118
- audioStats = diffRecvAudioStats(_this7._preAudioStats, curAudioStats);
8119
- videoStats = diffRecvVideoStats(_this7._preVideoStats, curVideoStats);
8120
- _this7._videoJitterBufferDelay = videoStats.jitterBufferDelay;
8261
+ audioStats = diffRecvAudioStats(_this8._preAudioStats, curAudioStats);
8262
+ videoStats = diffRecvVideoStats(_this8._preVideoStats, curVideoStats);
8263
+ _this8._videoJitterBufferDelay = videoStats.jitterBufferDelay;
8121
8264
  _context9.next = 20;
8122
- return (_this7$_audioStallObs = _this7._audioStallObserver) === null || _this7$_audioStallObs === void 0 ? void 0 : _this7$_audioStallObs.getAudioStallInfo();
8265
+ return (_this8$_audioStallObs = _this8._audioStallObserver) === null || _this8$_audioStallObs === void 0 ? void 0 : _this8$_audioStallObs.getAudioStallInfo();
8123
8266
  case 20:
8124
8267
  audioStallInfo = _context9.sent;
8125
8268
  _context9.next = 23;
8126
- return (_this7$_videoStallObs = _this7._videoStallObserver) === null || _this7$_videoStallObs === void 0 ? void 0 : _this7$_videoStallObs.getStallInfo({
8269
+ return (_this8$_videoStallObs = _this8._videoStallObserver) === null || _this8$_videoStallObs === void 0 ? void 0 : _this8$_videoStallObs.getStallInfo({
8127
8270
  interval: videoStats.statsInterval,
8128
8271
  frameRateReceived: videoStats.receivedFrameRate,
8129
8272
  frameRateDecoded: videoStats.decoderOutputFrameRate,
@@ -8131,18 +8274,18 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
8131
8274
  });
8132
8275
  case 23:
8133
8276
  videoStallInfo = _context9.sent;
8134
- _ref6 = (_this7$_networkQualit = (_this7$_networkQualit2 = _this7._networkQuality) === null || _this7$_networkQualit2 === void 0 ? void 0 : _this7$_networkQualit2.getDownlinkQuality(_objectSpread2$2(_objectSpread2$2({}, audioStats), {}, {
8277
+ _ref6 = (_this8$_networkQualit = (_this8$_networkQualit2 = _this8._networkQuality) === null || _this8$_networkQualit2 === void 0 ? void 0 : _this8$_networkQualit2.getDownlinkQuality(_objectSpread2$2(_objectSpread2$2({}, audioStats), {}, {
8135
8278
  stallDuration: (audioStallInfo === null || audioStallInfo === void 0 ? void 0 : audioStallInfo.stallDuration) || 0
8136
8279
  }), _objectSpread2$2(_objectSpread2$2({}, videoStats), {}, {
8137
8280
  stallDuration: (videoStallInfo === null || videoStallInfo === void 0 ? void 0 : videoStallInfo.stall.stallDuration100ms) || (videoStallInfo === null || videoStallInfo === void 0 ? void 0 : videoStallInfo.stall.stallDuration500ms) || 0
8138
- }))) !== null && _this7$_networkQualit !== void 0 ? _this7$_networkQualit : [], _ref7 = _slicedToArray(_ref6, 2), quality = _ref7[0], qualityInfo = _ref7[1];
8139
- if (_this7._opts.enableAdaptiveJitterBuffer) {
8140
- _this7._handleJitterBuffer(qualityInfo === null || qualityInfo === void 0 ? void 0 : qualityInfo.qualityQos, _this7._opts.adaptiveJitterBuffer, _this7._opts.networkStrategy);
8281
+ }))) !== null && _this8$_networkQualit !== void 0 ? _this8$_networkQualit : [], _ref7 = _slicedToArray(_ref6, 2), quality = _ref7[0], qualityInfo = _ref7[1];
8282
+ if (_this8._opts.enableAdaptiveJitterBuffer) {
8283
+ _this8._handleJitterBuffer(qualityInfo === null || qualityInfo === void 0 ? void 0 : qualityInfo.qualityQos, _this8._opts.adaptiveJitterBuffer, _this8._opts.networkStrategy);
8141
8284
  }
8142
8285
  if (videoStats.estimatedPlayoutTimestamp && audioStats.estimatedPlayoutTimestamp) {
8143
8286
  av_sync_diff = videoStats.estimatedPlayoutTimestamp - audioStats.estimatedPlayoutTimestamp;
8144
8287
  }
8145
- _this7.emit(EXTEND_EVENTS.RTC_NETWORK, _objectSpread2$2({
8288
+ _this8.emit(EXTEND_EVENTS.RTC_NETWORK, _objectSpread2$2({
8146
8289
  interval: videoStats.statsInterval,
8147
8290
  network_quality: quality,
8148
8291
  audio_stall_duration: audioStallInfo === null || audioStallInfo === void 0 ? void 0 : audioStallInfo.stallDuration,
@@ -8168,13 +8311,13 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
8168
8311
  quality_qos: qualityInfo === null || qualityInfo === void 0 ? void 0 : qualityInfo.qualityQos,
8169
8312
  quality_audio_qoe: qualityInfo === null || qualityInfo === void 0 ? void 0 : qualityInfo.audioQoe,
8170
8313
  quality_video_qoe: qualityInfo === null || qualityInfo === void 0 ? void 0 : qualityInfo.videoQoe,
8171
- current_delay: _this7._getDelay(),
8314
+ current_delay: _this8._getDelay(),
8172
8315
  visibility_state: document.visibilityState,
8173
- target_delay: _this7._targetDelayHint,
8316
+ target_delay: _this8._targetDelayHint,
8174
8317
  av_sync_diff,
8175
- set_delay_error: _this7._setDelayError || null,
8176
- video_width: ((_this7$_media = _this7._media) === null || _this7$_media === void 0 ? void 0 : _this7$_media.videoWidth) || 0,
8177
- video_height: ((_this7$_media2 = _this7._media) === null || _this7$_media2 === void 0 ? void 0 : _this7$_media2.videoHeight) || 0,
8318
+ set_delay_error: _this8._setDelayError || null,
8319
+ video_width: ((_this8$_media = _this8._media) === null || _this8$_media === void 0 ? void 0 : _this8$_media.videoWidth) || 0,
8320
+ video_height: ((_this8$_media2 = _this8._media) === null || _this8$_media2 === void 0 ? void 0 : _this8$_media2.videoHeight) || 0,
8178
8321
  abr_state: videoStats.abrState || "none",
8179
8322
  recv_frame_rate: videoStats.receivedFrameRate,
8180
8323
  decode_frame_rate: videoStats.decoderOutputFrameRate,
@@ -8182,15 +8325,19 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
8182
8325
  drop_frame_rate: videoStats.framesDropped,
8183
8326
  audio_packets_received: audioStats.packetsReceived,
8184
8327
  video_packets_received: videoStats.packetsReceived,
8185
- video_muted: (_this7$_media3 = _this7._media) === null || _this7$_media3 === void 0 ? void 0 : _this7$_media3.muted,
8186
- video_paused: (_this7$_media4 = _this7._media) === null || _this7$_media4 === void 0 ? void 0 : _this7$_media4.paused,
8187
- video_volume: (_this7$_media5 = _this7._media) === null || _this7$_media5 === void 0 ? void 0 : _this7$_media5.volume,
8188
- video_current_time: (_this7$_media6 = _this7._media) === null || _this7$_media6 === void 0 ? void 0 : _this7$_media6.currentTime
8189
- }, ((_this7$_frameRecvCall2 = _this7._frameRecvCallback) === null || _this7$_frameRecvCall2 === void 0 ? void 0 : _this7$_frameRecvCall2.getRecentRenderInfo4Report()) || {}));
8328
+ video_muted: (_this8$_media3 = _this8._media) === null || _this8$_media3 === void 0 ? void 0 : _this8$_media3.muted,
8329
+ video_paused: (_this8$_media4 = _this8._media) === null || _this8$_media4 === void 0 ? void 0 : _this8$_media4.paused,
8330
+ video_volume: (_this8$_media5 = _this8._media) === null || _this8$_media5 === void 0 ? void 0 : _this8$_media5.volume,
8331
+ video_current_time: (_this8$_media6 = _this8._media) === null || _this8$_media6 === void 0 ? void 0 : _this8$_media6.currentTime,
8332
+ fec_packets_received: videoStats.fecPacketsReceived,
8333
+ video_kbps: videoStats.receivedKBitrate,
8334
+ audio_kbps: audioStats.receivedKBitrate,
8335
+ fec_ssrc: videoStats.fecSsrc
8336
+ }, ((_this8$_frameRecvCall2 = _this8._frameRecvCallback) === null || _this8$_frameRecvCall2 === void 0 ? void 0 : _this8$_frameRecvCall2.getRecentRenderInfo4Report()) || {}));
8190
8337
  case 28:
8191
- _this7._preAudioStats = curAudioStats;
8192
- _this7._preVideoStats = curVideoStats;
8193
- _this7._setDelayError = null;
8338
+ _this8._preAudioStats = curAudioStats;
8339
+ _this8._preVideoStats = curVideoStats;
8340
+ _this8._setDelayError = null;
8194
8341
  case 31:
8195
8342
  case "end":
8196
8343
  return _context9.stop();
@@ -8303,6 +8450,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
8303
8450
  this._firstFrameObserver.reset();
8304
8451
  this.emit(EVENT.ERROR, error);
8305
8452
  clearTimeout(this._checkStatsErrorTimer);
8453
+ this._stopRtcReport();
8306
8454
  this._clearPeerStateTimeout();
8307
8455
  if (this._pc) {
8308
8456
  this._pc.close();
@@ -8344,7 +8492,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
8344
8492
  }, {
8345
8493
  key: "_changeVolumeInHarmonyWorkaround",
8346
8494
  value: function _changeVolumeInHarmonyWorkaround() {
8347
- var _this8 = this;
8495
+ var _this9 = this;
8348
8496
  if (isHarmonyOS()) {
8349
8497
  var originalDescriptor = Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, "muted");
8350
8498
  if (this._media && originalDescriptor) {
@@ -8363,9 +8511,9 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
8363
8511
  }
8364
8512
  });
8365
8513
  this._revertVolumeWorkaround = function() {
8366
- logger.log("revert HarmonyOS muted workaround. video dom:", _this8._media);
8367
- if (_this8._media) {
8368
- Object.defineProperty(_this8._media, "muted", originalDescriptor);
8514
+ logger.log("revert HarmonyOS muted workaround. video dom:", _this9._media);
8515
+ if (_this9._media) {
8516
+ Object.defineProperty(_this9._media, "muted", originalDescriptor);
8369
8517
  }
8370
8518
  };
8371
8519
  }
@@ -8374,7 +8522,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
8374
8522
  }, {
8375
8523
  key: "_mutedBeforePlayingWorkaround",
8376
8524
  value: function _mutedBeforePlayingWorkaround() {
8377
- var _this9 = this;
8525
+ var _this10 = this;
8378
8526
  if (isHeyTapBrowser() || isVivoBrowser()) {
8379
8527
  var originalDescriptor = Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, "muted");
8380
8528
  if (this._media && originalDescriptor) {
@@ -8394,10 +8542,10 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
8394
8542
  });
8395
8543
  var revertMutedProxy = function revertMutedProxy2() {
8396
8544
  logger.log("revert muted workaround. muted:", originalMuted);
8397
- if (_this9._media) {
8398
- Object.defineProperty(_this9._media, "muted", originalDescriptor);
8399
- _this9._media.muted = originalMuted;
8400
- _this9._media.removeEventListener("playing", revertMutedProxy2);
8545
+ if (_this10._media) {
8546
+ Object.defineProperty(_this10._media, "muted", originalDescriptor);
8547
+ _this10._media.muted = originalMuted;
8548
+ _this10._media.removeEventListener("playing", revertMutedProxy2);
8401
8549
  }
8402
8550
  };
8403
8551
  this._media.addEventListener("playing", revertMutedProxy);
@@ -8507,10 +8655,11 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
8507
8655
  _this.__retry = function() {
8508
8656
  _this.player.removeClass(STATE_CLASS.ERROR);
8509
8657
  _this.player.addClass(STATE_CLASS.LOADING);
8510
- runHooks(_assertThisInitialized$1(_this), "retry", function() {
8658
+ _this.player.runHooks(_assertThisInitialized$1(_this), "retry", function() {
8511
8659
  _this.player.src = "";
8512
8660
  _this.player.once(CANPLAY, function() {
8513
- _this.player.mediaPlay();
8661
+ var _assertThisInitialize, _assertThisInitialize2;
8662
+ (_assertThisInitialize = _assertThisInitialized$1(_this)) === null || _assertThisInitialize === void 0 ? void 0 : (_assertThisInitialize2 = _assertThisInitialize.player) === null || _assertThisInitialize2 === void 0 ? void 0 : _assertThisInitialize2.mediaPlay();
8514
8663
  });
8515
8664
  });
8516
8665
  };
@@ -8562,7 +8711,7 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
8562
8711
  }, {
8563
8712
  key: "version",
8564
8713
  get: function get() {
8565
- return "0.2.1-alpha.53";
8714
+ return "0.2.1-alpha.61";
8566
8715
  }
8567
8716
  }, {
8568
8717
  key: "beforePlayerInit",