@byteplus/veplayer-plugin 2.8.0-rc.7 → 2.8.0-rc.9

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byteplus/veplayer-plugin",
3
- "version": "2.8.0-rc.7",
3
+ "version": "2.8.0-rc.9",
4
4
  "main": "./umd/index.production.js",
5
5
  "module": "./esm/index.production.js",
6
6
  "browser": "./umd/index.production.js",
@@ -4962,6 +4962,7 @@
4962
4962
  checkStatsErrorDelay: 5e3,
4963
4963
  connectionStateChangeTimeout: 5e3,
4964
4964
  enableNetworkQuality: false,
4965
+ hackCreateOfferIssue: false,
4965
4966
  networkQuality: {
4966
4967
  networkQos: {
4967
4968
  1: {
@@ -6913,7 +6914,7 @@
6913
6914
  value: function() {
6914
6915
  var _load = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee3(url) {
6915
6916
  var _this2 = this;
6916
- var lastPc, encodedTransformSupported;
6917
+ var encodedTransformSupported, lastPc;
6917
6918
  return _regeneratorRuntime$1().wrap(function _callee3$(_context3) {
6918
6919
  while (1)
6919
6920
  switch (_context3.prev = _context3.next) {
@@ -6921,32 +6922,39 @@
6921
6922
  this._disconnect();
6922
6923
  this._url = url;
6923
6924
  this._retry = this._opts.retryCount;
6925
+ if (!this._opts.hackCreateOfferIssue) {
6926
+ _context3.next = 6;
6927
+ break;
6928
+ }
6929
+ _context3.next = 6;
6930
+ return this._createEmptyPeer();
6931
+ case 6:
6932
+ encodedTransformSupported = isLegacyEncodedTransformSupported();
6933
+ _context3.prev = 7;
6924
6934
  lastPc = this._pc;
6925
6935
  if (lastPc) {
6926
6936
  lastPc.close();
6927
6937
  }
6928
- encodedTransformSupported = isLegacyEncodedTransformSupported();
6929
- _context3.prev = 6;
6930
6938
  this._pc = new RTCPeerConnection({
6931
6939
  encodedInsertableStreams: encodedTransformSupported && this._opts.enableSei ? true : void 0
6932
6940
  });
6933
6941
  this._bindRTCEvents();
6934
- _context3.next = 11;
6942
+ _context3.next = 14;
6935
6943
  return this._connect(url);
6936
- case 11:
6937
- _context3.next = 16;
6944
+ case 14:
6945
+ _context3.next = 19;
6938
6946
  break;
6939
- case 13:
6940
- _context3.prev = 13;
6941
- _context3.t0 = _context3["catch"](6);
6947
+ case 16:
6948
+ _context3.prev = 16;
6949
+ _context3.t0 = _context3["catch"](7);
6942
6950
  setTimeout(function() {
6943
6951
  return _this2._emitError(StreamingError.create(ERR.OTHER, null, _context3.t0));
6944
6952
  });
6945
- case 16:
6953
+ case 19:
6946
6954
  case "end":
6947
6955
  return _context3.stop();
6948
6956
  }
6949
- }, _callee3, this, [[6, 13]]);
6957
+ }, _callee3, this, [[7, 16]]);
6950
6958
  }));
6951
6959
  function load(_x) {
6952
6960
  return _load.apply(this, arguments);
@@ -7124,6 +7132,9 @@
7124
7132
  case 13:
7125
7133
  offer = _context4.sent;
7126
7134
  case 14:
7135
+ if (this._opts.hackCreateOfferIssue) {
7136
+ this._createEmptyPeer();
7137
+ }
7127
7138
  logger.log("local offer");
7128
7139
  logger.log(offer.sdp);
7129
7140
  parsed = lib.parse(offer.sdp);
@@ -7148,11 +7159,11 @@
7148
7159
  });
7149
7160
  offer.sdp = lib.write(parsed);
7150
7161
  logger.log("local offer modified:\n", offer.sdp);
7151
- _context4.next = 22;
7162
+ _context4.next = 23;
7152
7163
  return pc.setLocalDescription(offer);
7153
- case 22:
7164
+ case 23:
7154
7165
  finnalUrl = this._url;
7155
- _context4.prev = 23;
7166
+ _context4.prev = 24;
7156
7167
  if (this._opts.preProcessUrl) {
7157
7168
  finnalUrl = this._opts.preProcessUrl(finnalUrl).url;
7158
7169
  }
@@ -7165,7 +7176,7 @@
7165
7176
  sessionId
7166
7177
  });
7167
7178
  reqStart = Date.now();
7168
- _context4.next = 32;
7179
+ _context4.next = 33;
7169
7180
  return this._loader.load(finnalUrl, {
7170
7181
  body: JSON.stringify({
7171
7182
  sessionId,
@@ -7173,27 +7184,27 @@
7173
7184
  localSdp: offer
7174
7185
  })
7175
7186
  });
7176
- case 32:
7187
+ case 33:
7177
7188
  res = _context4.sent;
7178
7189
  this.emit(EVENT.LOAD_RESPONSE_HEADERS, {
7179
7190
  headers: res.response.headers
7180
7191
  });
7181
7192
  answer = res === null || res === void 0 ? void 0 : res.data;
7182
7193
  if (!((answer === null || answer === void 0 ? void 0 : answer.code) === 404 || (answer === null || answer === void 0 ? void 0 : answer.code) === 403)) {
7183
- _context4.next = 40;
7194
+ _context4.next = 41;
7184
7195
  break;
7185
7196
  }
7186
7197
  err = StreamingError.create(answer.code === 404 ? ERR.NETWORK_NOTFOUND : ERR.NETWORK_FORBIDDEN, null, answer);
7187
7198
  err.errorType = ERR.NETWORK;
7188
7199
  this._emitError(err);
7189
7200
  return _context4.abrupt("return");
7190
- case 40:
7201
+ case 41:
7191
7202
  if (!((answer === null || answer === void 0 ? void 0 : answer.code) !== 200)) {
7192
- _context4.next = 42;
7203
+ _context4.next = 43;
7193
7204
  break;
7194
7205
  }
7195
7206
  throw new Error("code: ".concat(answer === null || answer === void 0 ? void 0 : answer.code, ", message:").concat(answer === null || answer === void 0 ? void 0 : answer.message));
7196
- case 42:
7207
+ case 43:
7197
7208
  logger.log("answer:");
7198
7209
  logger.log((_answer$remoteSdp = answer.remoteSdp) === null || _answer$remoteSdp === void 0 ? void 0 : _answer$remoteSdp.sdp);
7199
7210
  _parsed = lib.parse(answer.remoteSdp.sdp);
@@ -7222,22 +7233,28 @@
7222
7233
  answer.remoteSdp.sdp = lib.write(_parsed);
7223
7234
  logger.log("answer modified:\n", answer.remoteSdp.sdp);
7224
7235
  this._rctConnectStartTs = Date.now();
7225
- _context4.next = 52;
7226
- return this._pc.setRemoteDescription(answer.remoteSdp);
7227
- case 52:
7236
+ if (!(pc.signalingState === "closed")) {
7237
+ _context4.next = 53;
7238
+ break;
7239
+ }
7240
+ return _context4.abrupt("return");
7241
+ case 53:
7242
+ _context4.next = 55;
7243
+ return pc.setRemoteDescription(answer.remoteSdp);
7244
+ case 55:
7228
7245
  this._networkEvaluate = new NetworkEvaluate(pc, this._opts.networkEvaluateInterval);
7229
7246
  this._listenPeerStateTimeout();
7230
- _context4.next = 59;
7247
+ _context4.next = 62;
7231
7248
  break;
7232
- case 56:
7233
- _context4.prev = 56;
7234
- _context4.t0 = _context4["catch"](23);
7235
- this._emitError(StreamingError.network(_context4.t0));
7236
7249
  case 59:
7250
+ _context4.prev = 59;
7251
+ _context4.t0 = _context4["catch"](24);
7252
+ this._emitError(StreamingError.network(_context4.t0));
7253
+ case 62:
7237
7254
  case "end":
7238
7255
  return _context4.stop();
7239
7256
  }
7240
- }, _callee4, this, [[23, 56]]);
7257
+ }, _callee4, this, [[24, 59]]);
7241
7258
  }));
7242
7259
  function _connect() {
7243
7260
  return _connect2.apply(this, arguments);
@@ -7420,6 +7437,32 @@
7420
7437
  this._pc.close();
7421
7438
  }
7422
7439
  }
7440
+ }, {
7441
+ key: "_createEmptyPeer",
7442
+ value: function() {
7443
+ var _createEmptyPeer2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee6() {
7444
+ var pc;
7445
+ return _regeneratorRuntime$1().wrap(function _callee6$(_context6) {
7446
+ while (1)
7447
+ switch (_context6.prev = _context6.next) {
7448
+ case 0:
7449
+ pc = new RTCPeerConnection();
7450
+ _context6.next = 3;
7451
+ return pc.createOffer();
7452
+ case 3:
7453
+ pc.close();
7454
+ pc = null;
7455
+ case 5:
7456
+ case "end":
7457
+ return _context6.stop();
7458
+ }
7459
+ }, _callee6);
7460
+ }));
7461
+ function _createEmptyPeer() {
7462
+ return _createEmptyPeer2.apply(this, arguments);
7463
+ }
7464
+ return _createEmptyPeer;
7465
+ }()
7423
7466
  }, {
7424
7467
  key: "destroy",
7425
7468
  value: function destroy(keepClearMediaStream) {
@@ -7560,7 +7603,7 @@
7560
7603
  }, {
7561
7604
  key: "version",
7562
7605
  get: function get() {
7563
- return "0.2.1-alpha.34";
7606
+ return "0.2.1-alpha.37";
7564
7607
  }
7565
7608
  }, {
7566
7609
  key: "beforePlayerInit",