@byteplus/veplayer-plugin 2.4.2-rc.1 → 2.4.2-rc.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.
@@ -2,6 +2,32 @@
2
2
  typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.__VEPLAYER_PLUGIN_RTM__ = {}));
3
3
  })(this, function(exports2) {
4
4
  "use strict";
5
+ function _iterableToArrayLimit(arr, i) {
6
+ var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
7
+ if (null != _i) {
8
+ var _s, _e, _x, _r, _arr = [], _n = true, _d = false;
9
+ try {
10
+ if (_x = (_i = _i.call(arr)).next, 0 === i) {
11
+ if (Object(_i) !== _i)
12
+ return;
13
+ _n = false;
14
+ } else
15
+ for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = true)
16
+ ;
17
+ } catch (err) {
18
+ _d = true, _e = err;
19
+ } finally {
20
+ try {
21
+ if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r))
22
+ return;
23
+ } finally {
24
+ if (_d)
25
+ throw _e;
26
+ }
27
+ }
28
+ return _arr;
29
+ }
30
+ }
5
31
  function ownKeys$2(object, enumerableOnly) {
6
32
  var keys = Object.keys(object);
7
33
  if (Object.getOwnPropertySymbols) {
@@ -339,14 +365,6 @@
339
365
  }
340
366
  }, exports3;
341
367
  }
342
- function _typeof$2(obj) {
343
- "@babel/helpers - typeof";
344
- return _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
345
- return typeof obj2;
346
- } : function(obj2) {
347
- return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
348
- }, _typeof$2(obj);
349
- }
350
368
  function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
351
369
  try {
352
370
  var info = gen[key](arg);
@@ -487,6 +505,104 @@
487
505
  return _possibleConstructorReturn$1(this, result);
488
506
  };
489
507
  }
508
+ function _slicedToArray(arr, i) {
509
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$2(arr, i) || _nonIterableRest();
510
+ }
511
+ function _toConsumableArray$1(arr) {
512
+ return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$2(arr) || _nonIterableSpread$1();
513
+ }
514
+ function _arrayWithoutHoles$1(arr) {
515
+ if (Array.isArray(arr))
516
+ return _arrayLikeToArray$2(arr);
517
+ }
518
+ function _arrayWithHoles(arr) {
519
+ if (Array.isArray(arr))
520
+ return arr;
521
+ }
522
+ function _iterableToArray$1(iter) {
523
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
524
+ return Array.from(iter);
525
+ }
526
+ function _unsupportedIterableToArray$2(o, minLen) {
527
+ if (!o)
528
+ return;
529
+ if (typeof o === "string")
530
+ return _arrayLikeToArray$2(o, minLen);
531
+ var n = Object.prototype.toString.call(o).slice(8, -1);
532
+ if (n === "Object" && o.constructor)
533
+ n = o.constructor.name;
534
+ if (n === "Map" || n === "Set")
535
+ return Array.from(o);
536
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
537
+ return _arrayLikeToArray$2(o, minLen);
538
+ }
539
+ function _arrayLikeToArray$2(arr, len) {
540
+ if (len == null || len > arr.length)
541
+ len = arr.length;
542
+ for (var i = 0, arr2 = new Array(len); i < len; i++)
543
+ arr2[i] = arr[i];
544
+ return arr2;
545
+ }
546
+ function _nonIterableSpread$1() {
547
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
548
+ }
549
+ function _nonIterableRest() {
550
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
551
+ }
552
+ function _createForOfIteratorHelper$1(o, allowArrayLike) {
553
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
554
+ if (!it) {
555
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray$2(o)) || allowArrayLike && o && typeof o.length === "number") {
556
+ if (it)
557
+ o = it;
558
+ var i = 0;
559
+ var F = function() {
560
+ };
561
+ return {
562
+ s: F,
563
+ n: function() {
564
+ if (i >= o.length)
565
+ return {
566
+ done: true
567
+ };
568
+ return {
569
+ done: false,
570
+ value: o[i++]
571
+ };
572
+ },
573
+ e: function(e) {
574
+ throw e;
575
+ },
576
+ f: F
577
+ };
578
+ }
579
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
580
+ }
581
+ var normalCompletion = true, didErr = false, err;
582
+ return {
583
+ s: function() {
584
+ it = it.call(o);
585
+ },
586
+ n: function() {
587
+ var step = it.next();
588
+ normalCompletion = step.done;
589
+ return step;
590
+ },
591
+ e: function(e) {
592
+ didErr = true;
593
+ err = e;
594
+ },
595
+ f: function() {
596
+ try {
597
+ if (!normalCompletion && it.return != null)
598
+ it.return();
599
+ } finally {
600
+ if (didErr)
601
+ throw err;
602
+ }
603
+ }
604
+ };
605
+ }
490
606
  function _toPrimitive$2(input, hint) {
491
607
  if (typeof input !== "object" || input === null)
492
608
  return input;
@@ -5073,6 +5189,519 @@
5073
5189
  }]);
5074
5190
  return NetworkEvaluate2;
5075
5191
  }();
5192
+ var RTC_SEI_TYPE = /* @__PURE__ */ function(RTC_SEI_TYPE2) {
5193
+ RTC_SEI_TYPE2[RTC_SEI_TYPE2["internal"] = 0] = "internal";
5194
+ RTC_SEI_TYPE2[RTC_SEI_TYPE2["external"] = 1] = "external";
5195
+ RTC_SEI_TYPE2[RTC_SEI_TYPE2["bypass"] = 2] = "bypass";
5196
+ return RTC_SEI_TYPE2;
5197
+ }(RTC_SEI_TYPE || {});
5198
+ var UUID_INTERNAL = new Uint8Array([109, 167, 53, 190, 103, 90, 72, 1, 170, 89, 63, 164, 194, 199, 19, 85]);
5199
+ var UUID_EXTERNAL = new Uint8Array([109, 167, 53, 190, 103, 90, 72, 1, 170, 89, 63, 164, 194, 199, 19, 84]);
5200
+ var rbsp2ebsp = function rbsp2ebsp2(src) {
5201
+ var result = [];
5202
+ for (var i = 0; i < src.length; i++) {
5203
+ if (src[i] <= 3 && src[i - 1] === 0 && src[i - 2] === 0) {
5204
+ result.push(3);
5205
+ }
5206
+ result.push(src[i]);
5207
+ }
5208
+ return new Uint8Array(result);
5209
+ };
5210
+ var ebsp2rbsp = function ebsp2rbsp2(src) {
5211
+ var result = [];
5212
+ for (var i = 0; i < src.length; i++) {
5213
+ if (src[i] <= 3 && src[i - 1] === 0 && src[i - 2] === 0) {
5214
+ continue;
5215
+ }
5216
+ result.push(src[i]);
5217
+ }
5218
+ return new Uint8Array(result);
5219
+ };
5220
+ function serializeData(num) {
5221
+ var result = [];
5222
+ while (num >= 255) {
5223
+ num -= 255;
5224
+ result.push(255);
5225
+ }
5226
+ result.push(num);
5227
+ return new Uint8Array(result);
5228
+ }
5229
+ function deserializeData(data) {
5230
+ var offset = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
5231
+ var result = 0;
5232
+ while (data[offset] === 255 && offset < data.byteLength) {
5233
+ offset++;
5234
+ result += 255;
5235
+ }
5236
+ if (offset < data.byteLength) {
5237
+ result += data[offset++];
5238
+ }
5239
+ return [result, offset];
5240
+ }
5241
+ var SEIHelper = /* @__PURE__ */ function() {
5242
+ function SEIHelper2() {
5243
+ _classCallCheck$2(this, SEIHelper2);
5244
+ }
5245
+ _createClass$2(SEIHelper2, null, [{
5246
+ key: "generateSEI",
5247
+ value: function generateSEI(src) {
5248
+ var internal = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
5249
+ var annexbHeader = new Uint8Array([0, 0, 0, 1]);
5250
+ var nalType = new Uint8Array([6]);
5251
+ var seiType = new Uint8Array([5]);
5252
+ var uuid = internal ? UUID_INTERNAL : UUID_EXTERNAL;
5253
+ var serializedPayloadSize = serializeData(src.byteLength + uuid.byteLength);
5254
+ var payloadEbsp = rbsp2ebsp(src);
5255
+ return new Uint8Array([].concat(_toConsumableArray$1(annexbHeader), _toConsumableArray$1(nalType), _toConsumableArray$1(seiType), _toConsumableArray$1(serializedPayloadSize), _toConsumableArray$1(uuid), _toConsumableArray$1(payloadEbsp), [128]));
5256
+ }
5257
+ }, {
5258
+ key: "decodeSeiBody",
5259
+ value: function decodeSeiBody(src) {
5260
+ src = src.slice(0, src.length - 1);
5261
+ var rbsp = ebsp2rbsp(src);
5262
+ if (rbsp.byteLength < 2) {
5263
+ return;
5264
+ }
5265
+ var offset = 0;
5266
+ if (!(rbsp[1] === 5 || rbsp[1] === 100)) {
5267
+ return;
5268
+ }
5269
+ offset += 2;
5270
+ var _deserializeData = deserializeData(rbsp, offset), _deserializeData2 = _slicedToArray(_deserializeData, 2), payloadLength = _deserializeData2[0], newOffset = _deserializeData2[1];
5271
+ offset = newOffset;
5272
+ var rtcSeiType = 2;
5273
+ var end = offset + payloadLength;
5274
+ if (rbsp.byteLength >= UUID_EXTERNAL.byteLength && payloadLength >= UUID_EXTERNAL.byteLength && rbsp.slice(offset, offset + UUID_EXTERNAL.byteLength).toString() === UUID_EXTERNAL.toString()) {
5275
+ offset += UUID_EXTERNAL.byteLength;
5276
+ rtcSeiType = 1;
5277
+ } else if (rbsp.byteLength >= UUID_EXTERNAL.byteLength && payloadLength >= UUID_EXTERNAL.byteLength && rbsp.slice(offset, offset + UUID_INTERNAL.byteLength).toString() === UUID_INTERNAL.toString()) {
5278
+ offset += UUID_INTERNAL.byteLength;
5279
+ rtcSeiType = 0;
5280
+ }
5281
+ var seiPayload = rbsp.slice(offset, end);
5282
+ return {
5283
+ type: rtcSeiType,
5284
+ payload: seiPayload
5285
+ };
5286
+ }
5287
+ }, {
5288
+ key: "parseInternalSEI",
5289
+ value: function parseInternalSEI(decodedSEI) {
5290
+ var result = /* @__PURE__ */ new Map();
5291
+ var offset = 0;
5292
+ if (decodedSEI.type === 0) {
5293
+ while (decodedSEI.payload.byteLength - offset >= 2) {
5294
+ var _deserializeData3 = deserializeData(decodedSEI.payload, offset), _deserializeData4 = _slicedToArray(_deserializeData3, 2), internalSeiType = _deserializeData4[0], newOffset = _deserializeData4[1];
5295
+ offset = newOffset;
5296
+ var _deserializeData5 = deserializeData(decodedSEI.payload, offset), _deserializeData6 = _slicedToArray(_deserializeData5, 2), internalSeiLength = _deserializeData6[0], newOff = _deserializeData6[1];
5297
+ offset = newOff;
5298
+ if (!result.get(internalSeiType) && internalSeiLength <= decodedSEI.payload.byteLength - offset) {
5299
+ result.set(internalSeiType, decodedSEI.payload.slice(offset, offset + internalSeiLength));
5300
+ offset += internalSeiLength;
5301
+ } else {
5302
+ break;
5303
+ }
5304
+ }
5305
+ return result;
5306
+ }
5307
+ }
5308
+ }, {
5309
+ key: "makeInternalSei",
5310
+ value: function makeInternalSei(map) {
5311
+ var resultSeiList = [];
5312
+ var _iterator = _createForOfIteratorHelper$1(map), _step;
5313
+ try {
5314
+ for (_iterator.s(); !(_step = _iterator.n()).done; ) {
5315
+ var _step$value = _slicedToArray(_step.value, 2), type = _step$value[0], payload = _step$value[1];
5316
+ var serializedType = serializeData(type);
5317
+ var size = serializeData(payload.byteLength);
5318
+ resultSeiList.push(serializedType, size, payload);
5319
+ }
5320
+ } catch (err) {
5321
+ _iterator.e(err);
5322
+ } finally {
5323
+ _iterator.f();
5324
+ }
5325
+ var resultLength = resultSeiList.reduce(function(pre, cur) {
5326
+ return pre + cur.byteLength;
5327
+ }, 0);
5328
+ var result = new Uint8Array(resultLength);
5329
+ resultSeiList.reduce(function(pre, cur) {
5330
+ result.set(cur, pre);
5331
+ return pre + cur.byteLength;
5332
+ }, 0);
5333
+ return result;
5334
+ }
5335
+ }]);
5336
+ return SEIHelper2;
5337
+ }();
5338
+ var Nalunit = /* @__PURE__ */ function() {
5339
+ function Nalunit2() {
5340
+ _classCallCheck$2(this, Nalunit2);
5341
+ }
5342
+ _createClass$2(Nalunit2, null, [{
5343
+ key: "getNalunits",
5344
+ value: function getNalunits(buffer) {
5345
+ if (buffer.length - buffer.position < 4) {
5346
+ return [];
5347
+ }
5348
+ var position = buffer.position;
5349
+ if (buffer.getInt32(position) === 1 || buffer.getInt16(position) === 0 && buffer.getInt8(position + 2) === 1) {
5350
+ return Nalunit2.getAnnexbNals(buffer);
5351
+ } else {
5352
+ return Nalunit2.getAvccNals(buffer);
5353
+ }
5354
+ }
5355
+ }, {
5356
+ key: "getAnnexbNals",
5357
+ value: function getAnnexbNals(buffer) {
5358
+ var nals = [];
5359
+ var position = Nalunit2.getHeaderPositionAnnexB(buffer);
5360
+ var start = position.pos;
5361
+ var end = start;
5362
+ while (start < buffer.length - 4) {
5363
+ var header = new Uint8Array(buffer.buffer.slice(start, start + position.headerLength));
5364
+ if (position.pos === buffer.position) {
5365
+ buffer.skip(position.headerLength);
5366
+ }
5367
+ position = Nalunit2.getHeaderPositionAnnexB(buffer);
5368
+ end = position.pos;
5369
+ var body = new Uint8Array(buffer.buffer.slice(start + header.byteLength, end));
5370
+ var unit = {
5371
+ header,
5372
+ body,
5373
+ type: -1
5374
+ };
5375
+ Nalunit2.analyseNal(unit);
5376
+ if (unit.type <= 9 && unit.type !== 0) {
5377
+ nals.push(unit);
5378
+ }
5379
+ buffer.skip(end - buffer.position);
5380
+ start = end;
5381
+ }
5382
+ return nals;
5383
+ }
5384
+ }, {
5385
+ key: "getAvccNals",
5386
+ value: function getAvccNals(buffer) {
5387
+ var nals = [];
5388
+ while (buffer.position < buffer.length - 4) {
5389
+ var length = buffer.getInt32(buffer.position);
5390
+ if (buffer.length - buffer.position >= length) {
5391
+ var header = new Uint8Array(buffer.buffer.slice(buffer.position, buffer.position + 4));
5392
+ buffer.skip(4);
5393
+ var body = new Uint8Array(buffer.buffer.slice(buffer.position, buffer.position + length));
5394
+ buffer.skip(length);
5395
+ var unit = {
5396
+ header,
5397
+ body,
5398
+ type: -1
5399
+ };
5400
+ Nalunit2.analyseNal(unit);
5401
+ if (unit.type <= 9 && unit.type !== 0) {
5402
+ nals.push(unit);
5403
+ }
5404
+ } else {
5405
+ break;
5406
+ }
5407
+ }
5408
+ return nals;
5409
+ }
5410
+ }, {
5411
+ key: "analyseNal",
5412
+ value: function analyseNal(unit) {
5413
+ var type = unit.body[0] & 31;
5414
+ unit.type = type;
5415
+ switch (type) {
5416
+ case 1:
5417
+ unit.ndr = true;
5418
+ break;
5419
+ case 5:
5420
+ unit.idr = true;
5421
+ break;
5422
+ case 6:
5423
+ unit.sei = true;
5424
+ break;
5425
+ case 7:
5426
+ unit.sps = true;
5427
+ break;
5428
+ case 8:
5429
+ unit.pps = true;
5430
+ break;
5431
+ }
5432
+ }
5433
+ }, {
5434
+ key: "getHeaderPositionAnnexB",
5435
+ value: function getHeaderPositionAnnexB(buffer) {
5436
+ var pos = buffer.position;
5437
+ var headerLength = 0;
5438
+ var bufferLen = buffer.length;
5439
+ while (headerLength !== 3 && headerLength !== 4 && pos < bufferLen - 4) {
5440
+ if (buffer.getInt16(pos) === 0) {
5441
+ if (buffer.getInt16(pos + 2) === 1) {
5442
+ headerLength = 4;
5443
+ } else if (buffer.getInt8(pos + 2) === 1) {
5444
+ headerLength = 3;
5445
+ } else {
5446
+ pos++;
5447
+ }
5448
+ } else {
5449
+ pos++;
5450
+ }
5451
+ }
5452
+ if (pos === bufferLen - 4) {
5453
+ if (buffer.getInt16(pos) === 0) {
5454
+ if (buffer.getInt16(pos + 2) === 1) {
5455
+ headerLength = 4;
5456
+ } else {
5457
+ pos = bufferLen;
5458
+ }
5459
+ } else {
5460
+ pos++;
5461
+ if (buffer.getInt16(pos) === 0 && buffer.getInt8(pos) === 1) {
5462
+ headerLength = 3;
5463
+ } else {
5464
+ pos = bufferLen;
5465
+ }
5466
+ }
5467
+ }
5468
+ return {
5469
+ pos,
5470
+ headerLength
5471
+ };
5472
+ }
5473
+ }]);
5474
+ return Nalunit2;
5475
+ }();
5476
+ var RTCDataView = /* @__PURE__ */ function() {
5477
+ function RTCDataView2(buffer) {
5478
+ _classCallCheck$2(this, RTCDataView2);
5479
+ this._position = 0;
5480
+ this._dataview = new DataView(buffer);
5481
+ }
5482
+ _createClass$2(RTCDataView2, [{
5483
+ key: "length",
5484
+ get: function get() {
5485
+ return this.buffer.byteLength;
5486
+ }
5487
+ }, {
5488
+ key: "buffer",
5489
+ get: function get() {
5490
+ return this._dataview.buffer;
5491
+ }
5492
+ }, {
5493
+ key: "position",
5494
+ get: function get() {
5495
+ return this._position;
5496
+ },
5497
+ set: function set(value) {
5498
+ this._position = value;
5499
+ }
5500
+ }, {
5501
+ key: "back",
5502
+ value: function back(count) {
5503
+ this.position -= count;
5504
+ }
5505
+ }, {
5506
+ key: "getUint8",
5507
+ value: function getUint8(offset) {
5508
+ return this._dataview.getUint8(offset);
5509
+ }
5510
+ }, {
5511
+ key: "getInt8",
5512
+ value: function getInt8(offset) {
5513
+ return this._dataview.getInt8(offset);
5514
+ }
5515
+ }, {
5516
+ key: "getInt16",
5517
+ value: function getInt16(offset) {
5518
+ return this._dataview.getInt16(offset);
5519
+ }
5520
+ }, {
5521
+ key: "getUint16",
5522
+ value: function getUint16(offset) {
5523
+ return this._dataview.getUint16(offset);
5524
+ }
5525
+ }, {
5526
+ key: "getUint32",
5527
+ value: function getUint32(offset) {
5528
+ return this._dataview.getUint32(offset);
5529
+ }
5530
+ }, {
5531
+ key: "getInt32",
5532
+ value: function getInt32(offset) {
5533
+ return this._dataview.getInt32(offset);
5534
+ }
5535
+ }, {
5536
+ key: "skip",
5537
+ value: function skip(count) {
5538
+ var loop = Math.floor(count / 4);
5539
+ var last = count % 4;
5540
+ for (var i = 0; i < loop; i++) {
5541
+ RTCDataView2.readByte(this, 4);
5542
+ }
5543
+ if (last > 0) {
5544
+ RTCDataView2.readByte(this, last);
5545
+ }
5546
+ }
5547
+ }, {
5548
+ key: "readUint8",
5549
+ value: function readUint8() {
5550
+ return RTCDataView2.readByte(this, 1);
5551
+ }
5552
+ }, {
5553
+ key: "readUint16",
5554
+ value: function readUint16() {
5555
+ return RTCDataView2.readByte(this, 2);
5556
+ }
5557
+ }, {
5558
+ key: "readUint24",
5559
+ value: function readUint24() {
5560
+ return RTCDataView2.readByte(this, 3);
5561
+ }
5562
+ }, {
5563
+ key: "readUint32",
5564
+ value: function readUint32() {
5565
+ return RTCDataView2.readByte(this, 4);
5566
+ }
5567
+ }, {
5568
+ key: "readUint64",
5569
+ value: function readUint64() {
5570
+ return RTCDataView2.readByte(this, 8);
5571
+ }
5572
+ }, {
5573
+ key: "readInt8",
5574
+ value: function readInt8() {
5575
+ return RTCDataView2.readByte(this, 1, true);
5576
+ }
5577
+ }, {
5578
+ key: "readInt16",
5579
+ value: function readInt16() {
5580
+ return RTCDataView2.readByte(this, 2, true);
5581
+ }
5582
+ }, {
5583
+ key: "readInt32",
5584
+ value: function readInt32() {
5585
+ return RTCDataView2.readByte(this, 4, true);
5586
+ }
5587
+ }, {
5588
+ key: "writeUint32",
5589
+ value: function writeUint32(value) {
5590
+ return new Uint8Array([value >>> 24 & 255, value >>> 16 & 255, value >>> 8 & 255, value & 255]);
5591
+ }
5592
+ }], [{
5593
+ key: "readByte",
5594
+ value: function readByte(buffer, size, sign) {
5595
+ var res;
5596
+ switch (size) {
5597
+ case 1:
5598
+ if (sign) {
5599
+ res = buffer.getInt8(buffer.position);
5600
+ } else {
5601
+ res = buffer.getUint8(buffer.position);
5602
+ }
5603
+ break;
5604
+ case 2:
5605
+ if (sign) {
5606
+ res = buffer.getInt16(buffer.position);
5607
+ } else {
5608
+ res = buffer.getUint16(buffer.position);
5609
+ }
5610
+ break;
5611
+ case 3:
5612
+ if (sign) {
5613
+ throw new Error("not supported for readByte 3");
5614
+ } else {
5615
+ res = buffer.getUint8(buffer.position) << 16;
5616
+ res |= buffer.getUint8(buffer.position + 1) << 8;
5617
+ res |= buffer.getUint8(buffer.position + 2);
5618
+ }
5619
+ break;
5620
+ case 4:
5621
+ if (sign) {
5622
+ res = buffer.getInt32(buffer.position);
5623
+ } else {
5624
+ res = buffer.getUint32(buffer.position);
5625
+ }
5626
+ break;
5627
+ case 8:
5628
+ if (sign) {
5629
+ throw new Error("not supported for readBody 8");
5630
+ } else {
5631
+ res = buffer.getUint32(buffer.position) << 32;
5632
+ res |= buffer.getUint32(buffer.position + 4);
5633
+ }
5634
+ break;
5635
+ default:
5636
+ res = "";
5637
+ }
5638
+ buffer.position += size;
5639
+ return res;
5640
+ }
5641
+ }]);
5642
+ return RTCDataView2;
5643
+ }();
5644
+ function isSupported() {
5645
+ if (!window.RTCPeerConnection || !window.RTCPeerConnection.prototype.addTransceiver) {
5646
+ return false;
5647
+ }
5648
+ return true;
5649
+ }
5650
+ function getCapacity() {
5651
+ if (!isSupported())
5652
+ return Promise.reject("RTCPeerConnection no support");
5653
+ var pc;
5654
+ try {
5655
+ pc = new RTCPeerConnection();
5656
+ pc.addTransceiver("video", {
5657
+ direction: "recvonly"
5658
+ });
5659
+ pc.addTransceiver("audio", {
5660
+ direction: "recvonly"
5661
+ });
5662
+ } catch (e) {
5663
+ return Promise.reject(e === null || e === void 0 ? void 0 : e.message);
5664
+ }
5665
+ return pc.createOffer().then(function(offer) {
5666
+ var _sdpJson$media, _sdpJson$media2, _vMedia$rtp, _aMedia$rtp;
5667
+ logger.log(offer.sdp);
5668
+ var sdpJson = lib.parse(offer.sdp);
5669
+ var vMedia = (_sdpJson$media = sdpJson.media) === null || _sdpJson$media === void 0 ? void 0 : _sdpJson$media.filter(function(x) {
5670
+ return x.type === "video";
5671
+ })[0];
5672
+ var aMedia = (_sdpJson$media2 = sdpJson.media) === null || _sdpJson$media2 === void 0 ? void 0 : _sdpJson$media2.filter(function(x) {
5673
+ return x.type === "audio";
5674
+ })[0];
5675
+ var vCodecs = vMedia === null || vMedia === void 0 ? void 0 : (_vMedia$rtp = vMedia.rtp) === null || _vMedia$rtp === void 0 ? void 0 : _vMedia$rtp.filter(function(x) {
5676
+ return x.codec === "VP8" || x.codec === "VP9" || x.codec === "H264";
5677
+ });
5678
+ var aCodecs = aMedia === null || aMedia === void 0 ? void 0 : (_aMedia$rtp = aMedia.rtp) === null || _aMedia$rtp === void 0 ? void 0 : _aMedia$rtp.filter(function(x) {
5679
+ return x.codec === "opus";
5680
+ });
5681
+ var vFmtp = vMedia === null || vMedia === void 0 ? void 0 : vMedia.fmtp;
5682
+ var aFmtp = aMedia === null || aMedia === void 0 ? void 0 : aMedia.fmtp;
5683
+ vFmtp && vCodecs.map(function(codec) {
5684
+ var _vFmtp$filter$;
5685
+ codec.config = (_vFmtp$filter$ = vFmtp.filter(function(x) {
5686
+ return x.payload === codec.payload;
5687
+ })[0]) === null || _vFmtp$filter$ === void 0 ? void 0 : _vFmtp$filter$.config;
5688
+ });
5689
+ aFmtp && aCodecs.map(function(codec) {
5690
+ var _aFmtp$filter$;
5691
+ codec.config = (_aFmtp$filter$ = aFmtp.filter(function(x) {
5692
+ return x.payload === codec.payload;
5693
+ })[0]) === null || _aFmtp$filter$ === void 0 ? void 0 : _aFmtp$filter$.config;
5694
+ });
5695
+ pc.close();
5696
+ return {
5697
+ video: vCodecs,
5698
+ audio: aCodecs
5699
+ };
5700
+ });
5701
+ }
5702
+ var isEncodedTransformSupported = function isEncodedTransformSupported2() {
5703
+ return typeof TransformStream !== "undefined" && typeof RTCRtpReceiver !== "undefined" && typeof RTCRtpReceiver.prototype.createEncodedStreams !== "undefined";
5704
+ };
5076
5705
  var logger = new Logger("rts");
5077
5706
  var Rts = /* @__PURE__ */ function(_EventEmitter) {
5078
5707
  _inherits$1(Rts2, _EventEmitter);
@@ -5086,7 +5715,6 @@
5086
5715
  _defineProperty$2(_assertThisInitialized$1(_this), "_audioTransceicer", null);
5087
5716
  _defineProperty$2(_assertThisInitialized$1(_this), "_videoTransceicer", null);
5088
5717
  _defineProperty$2(_assertThisInitialized$1(_this), "_mediaStream", null);
5089
- _defineProperty$2(_assertThisInitialized$1(_this), "_lastMediaStream", null);
5090
5718
  _defineProperty$2(_assertThisInitialized$1(_this), "_media", null);
5091
5719
  _defineProperty$2(_assertThisInitialized$1(_this), "_opts", null);
5092
5720
  _defineProperty$2(_assertThisInitialized$1(_this), "_loader", null);
@@ -5094,7 +5722,6 @@
5094
5722
  _defineProperty$2(_assertThisInitialized$1(_this), "_retry", 0);
5095
5723
  _defineProperty$2(_assertThisInitialized$1(_this), "_waitingTimer", 0);
5096
5724
  _defineProperty$2(_assertThisInitialized$1(_this), "_rctConnectStartTs", 0);
5097
- _defineProperty$2(_assertThisInitialized$1(_this), "_isReplacing", false);
5098
5725
  _defineProperty$2(_assertThisInitialized$1(_this), "_onTrack", function(e) {
5099
5726
  logger.log("addTrack: ", e.track, e.streams);
5100
5727
  _this["_".concat(e.track.kind)] = e.track;
@@ -5145,9 +5772,6 @@
5145
5772
  }));
5146
5773
  _this._retry = _this._opts.retryCount;
5147
5774
  _this._bindMediaEvent();
5148
- if (_this._opts.mediaStream && _this._opts.seamlesslyReload) {
5149
- _this._lastMediaStream = _this._opts.mediaStream;
5150
- }
5151
5775
  return _this;
5152
5776
  }
5153
5777
  _createClass$2(Rts2, [{
@@ -5191,9 +5815,9 @@
5191
5815
  }, {
5192
5816
  key: "load",
5193
5817
  value: function() {
5194
- var _load = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee(url, seamless) {
5818
+ var _load = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee(url) {
5195
5819
  var _this2 = this;
5196
- var _this$_pc3;
5820
+ var lastPc;
5197
5821
  return _regeneratorRuntime$1().wrap(function _callee$(_context) {
5198
5822
  while (1)
5199
5823
  switch (_context.prev = _context.next) {
@@ -5201,43 +5825,39 @@
5201
5825
  this._disconnect();
5202
5826
  this._url = url;
5203
5827
  this._retry = this._opts.retryCount;
5204
- if (seamless) {
5205
- this._lastPc = this._pc;
5206
- } else {
5207
- (_this$_pc3 = this._pc) === null || _this$_pc3 === void 0 ? void 0 : _this$_pc3.close();
5828
+ lastPc = this._pc;
5829
+ if (lastPc) {
5830
+ lastPc.close();
5208
5831
  }
5209
- _context.prev = 4;
5832
+ _context.prev = 5;
5210
5833
  this._pc = new RTCPeerConnection();
5211
5834
  this._bindRTCEvents();
5212
- _context.next = 9;
5835
+ _context.next = 10;
5213
5836
  return this._connect(url);
5214
- case 9:
5215
- _context.next = 14;
5837
+ case 10:
5838
+ _context.next = 15;
5216
5839
  break;
5217
- case 11:
5218
- _context.prev = 11;
5219
- _context.t0 = _context["catch"](4);
5840
+ case 12:
5841
+ _context.prev = 12;
5842
+ _context.t0 = _context["catch"](5);
5220
5843
  setTimeout(function() {
5221
5844
  return _this2._emitError(StreamingError.create(ERR.OTHER, null, _context.t0));
5222
5845
  });
5223
- case 14:
5846
+ case 15:
5224
5847
  case "end":
5225
5848
  return _context.stop();
5226
5849
  }
5227
- }, _callee, this, [[4, 11]]);
5850
+ }, _callee, this, [[5, 12]]);
5228
5851
  }));
5229
- function load(_x, _x2) {
5852
+ function load(_x) {
5230
5853
  return _load.apply(this, arguments);
5231
5854
  }
5232
5855
  return load;
5233
5856
  }()
5234
5857
  }, {
5235
5858
  key: "switchURL",
5236
- value: function switchURL(url, seamless) {
5237
- if (seamless) {
5238
- this._lastMediaStream = this._mediaStream;
5239
- }
5240
- this.load(url || this._url, seamless);
5859
+ value: function switchURL(url) {
5860
+ this.load(url || this._url);
5241
5861
  }
5242
5862
  }, {
5243
5863
  key: "_bindRTCEvents",
@@ -5263,7 +5883,6 @@
5263
5883
  _this3.load(_this3._url);
5264
5884
  }
5265
5885
  if (pc.connectionState === "connected") {
5266
- _this3._closeLastPc();
5267
5886
  _this3._handleMediaStream();
5268
5887
  _this3.emit(EVENT.TTFB, {
5269
5888
  url: _this3._url,
@@ -5276,29 +5895,18 @@
5276
5895
  }, {
5277
5896
  key: "_handleMediaStream",
5278
5897
  value: function _handleMediaStream() {
5279
- var _this4 = this;
5280
- if (this._lastMediaStream) {
5281
- var _this$_media$play;
5282
- var videoTrack = this._lastMediaStream.getVideoTracks()[0];
5283
- var audioTrack = this._lastMediaStream.getAudioTracks()[0];
5898
+ if (this._opts.mediaStream && this._opts.seamlesslyReload) {
5899
+ var videoTrack = this._opts.mediaStream.getVideoTracks()[0];
5900
+ var audioTrack = this._opts.mediaStream.getAudioTracks()[0];
5284
5901
  if (videoTrack) {
5285
- this._lastMediaStream.removeTrack(videoTrack);
5902
+ this._opts.mediaStream.removeTrack(videoTrack);
5286
5903
  }
5287
5904
  if (audioTrack) {
5288
- this._lastMediaStream.removeTrack(audioTrack);
5905
+ this._opts.mediaStream.removeTrack(audioTrack);
5289
5906
  }
5290
- this._mediaStream = this._lastMediaStream;
5291
- this._mediaStream.addTrack(this._audio);
5292
- this._mediaStream.addTrack(this._video);
5293
- this._isReplacing = true;
5294
- this._media.pause();
5295
- (_this$_media$play = this._media.play()) === null || _this$_media$play === void 0 ? void 0 : _this$_media$play.finally(function() {
5296
- _this4._isReplacing = false;
5297
- });
5907
+ this._mediaStream = this._opts.mediaStream;
5298
5908
  } else {
5299
5909
  this._mediaStream = new MediaStream();
5300
- this._mediaStream.addTrack(this._audio);
5301
- this._mediaStream.addTrack(this._video);
5302
5910
  this._media.srcObject = this._mediaStream;
5303
5911
  var req = this._media.play();
5304
5912
  if (req && req.catch) {
@@ -5306,6 +5914,39 @@
5306
5914
  });
5307
5915
  }
5308
5916
  }
5917
+ this._mediaStream.addTrack(this._audio);
5918
+ this._mediaStream.addTrack(this._video);
5919
+ }
5920
+ }, {
5921
+ key: "initVideoEncodedTransform",
5922
+ value: function initVideoEncodedTransform() {
5923
+ var _this4 = this;
5924
+ if (!this._videoTransceicer || !this._videoTransceicer.receiver) {
5925
+ console.log("no receiver found when trying to bind encodedTransform");
5926
+ return;
5927
+ }
5928
+ var receiver = this._videoTransceicer.receiver;
5929
+ if (isEncodedTransformSupported()) {
5930
+ var _receiver$createEncod = receiver.createEncodedStreams(), readable = _receiver$createEncod.readable, writable = _receiver$createEncod.writable;
5931
+ readable.pipeThrough(new TransformStream({
5932
+ transform: function transform(chunk, controller) {
5933
+ var nals = Nalunit.getNalunits(new RTCDataView(chunk.data));
5934
+ nals.forEach(function(nalUnit) {
5935
+ if (nalUnit.sei) {
5936
+ var decodedSei = SEIHelper.decodeSeiBody(nalUnit.body);
5937
+ if (decodedSei && decodedSei.type !== RTC_SEI_TYPE.internal) {
5938
+ _this4.emit(EVENT.SEI, {
5939
+ sei: {
5940
+ content: decodedSei.payload
5941
+ }
5942
+ });
5943
+ }
5944
+ }
5945
+ });
5946
+ controller.enqueue(chunk);
5947
+ }
5948
+ })).pipeTo(writable);
5949
+ }
5309
5950
  }
5310
5951
  }, {
5311
5952
  key: "_bindMediaEvent",
@@ -5324,7 +5965,7 @@
5324
5965
  case 0:
5325
5966
  pc = this._pc;
5326
5967
  if (!pc.addTransceiver) {
5327
- _context2.next = 11;
5968
+ _context2.next = 12;
5328
5969
  break;
5329
5970
  }
5330
5971
  this._audioTransceicer = pc.addTransceiver("audio", {
@@ -5333,6 +5974,7 @@
5333
5974
  this._videoTransceicer = pc.addTransceiver("video", {
5334
5975
  direction: "recvonly"
5335
5976
  });
5977
+ this.initVideoEncodedTransform();
5336
5978
  delayHint = this._opts.delayHint;
5337
5979
  if (delayHint) {
5338
5980
  this._audioTransceicer.receiver.playoutDelayHint = delayHint;
@@ -5340,22 +5982,22 @@
5340
5982
  this._videoTransceicer.receiver.playoutDelayHint = delayHint;
5341
5983
  this._videoTransceicer.receiver.jitterBufferDelayHint = delayHint;
5342
5984
  }
5343
- _context2.next = 8;
5985
+ _context2.next = 9;
5344
5986
  return pc.createOffer();
5345
- case 8:
5987
+ case 9:
5346
5988
  offer = _context2.sent;
5347
- _context2.next = 14;
5989
+ _context2.next = 15;
5348
5990
  break;
5349
- case 11:
5350
- _context2.next = 13;
5991
+ case 12:
5992
+ _context2.next = 14;
5351
5993
  return pc.createOffer({
5352
5994
  iceRestart: true,
5353
5995
  offerToReceiveAudio: true,
5354
5996
  offerToReceiveVideo: true
5355
5997
  });
5356
- case 13:
5357
- offer = _context2.sent;
5358
5998
  case 14:
5999
+ offer = _context2.sent;
6000
+ case 15:
5359
6001
  logger.log("local offer");
5360
6002
  logger.log(offer.sdp);
5361
6003
  parsed = lib.parse(offer.sdp);
@@ -5380,11 +6022,11 @@
5380
6022
  });
5381
6023
  offer.sdp = lib.write(parsed);
5382
6024
  logger.log("local offer modified:\n", offer.sdp);
5383
- _context2.next = 22;
6025
+ _context2.next = 23;
5384
6026
  return pc.setLocalDescription(offer);
5385
- case 22:
6027
+ case 23:
5386
6028
  finnalUrl = this._url;
5387
- _context2.prev = 23;
6029
+ _context2.prev = 24;
5388
6030
  if (this._opts.preProcessUrl) {
5389
6031
  finnalUrl = this._opts.preProcessUrl(finnalUrl).url;
5390
6032
  }
@@ -5397,7 +6039,7 @@
5397
6039
  sessionId
5398
6040
  });
5399
6041
  reqStart = Date.now();
5400
- _context2.next = 32;
6042
+ _context2.next = 33;
5401
6043
  return this._loader.load(finnalUrl, {
5402
6044
  body: JSON.stringify({
5403
6045
  sessionId,
@@ -5405,27 +6047,27 @@
5405
6047
  localSdp: offer
5406
6048
  })
5407
6049
  });
5408
- case 32:
6050
+ case 33:
5409
6051
  res = _context2.sent;
5410
6052
  this.emit(EVENT.LOAD_RESPONSE_HEADERS, {
5411
6053
  headers: res.response.headers
5412
6054
  });
5413
6055
  answer = res === null || res === void 0 ? void 0 : res.data;
5414
6056
  if (!((answer === null || answer === void 0 ? void 0 : answer.code) === 404 || (answer === null || answer === void 0 ? void 0 : answer.code) === 403)) {
5415
- _context2.next = 40;
6057
+ _context2.next = 41;
5416
6058
  break;
5417
6059
  }
5418
6060
  err = StreamingError.create(answer.code === 404 ? ERR.NETWORK_NOTFOUND : ERR.NETWORK_FORBIDDEN, null, answer);
5419
6061
  err.errorType = ERR.NETWORK;
5420
6062
  this._emitError(err);
5421
6063
  return _context2.abrupt("return");
5422
- case 40:
6064
+ case 41:
5423
6065
  if (!((answer === null || answer === void 0 ? void 0 : answer.code) !== 200)) {
5424
- _context2.next = 42;
6066
+ _context2.next = 43;
5425
6067
  break;
5426
6068
  }
5427
6069
  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));
5428
- case 42:
6070
+ case 43:
5429
6071
  logger.log("answer:");
5430
6072
  logger.log((_answer$remoteSdp = answer.remoteSdp) === null || _answer$remoteSdp === void 0 ? void 0 : _answer$remoteSdp.sdp);
5431
6073
  this.emit(EVENT.LOAD_COMPLETE, {
@@ -5440,41 +6082,35 @@
5440
6082
  answer.remoteSdp.sdp = lib.write(_parsed);
5441
6083
  logger.log("answer modified:\n", answer.remoteSdp.sdp);
5442
6084
  this._rctConnectStartTs = Date.now();
5443
- _context2.next = 52;
6085
+ _context2.next = 53;
5444
6086
  return this._pc.setRemoteDescription(answer.remoteSdp);
5445
- case 52:
6087
+ case 53:
5446
6088
  this._networkEvaluate = new NetworkEvaluate(pc, this._opts.networkEvaluateInterval);
5447
- _context2.next = 58;
6089
+ _context2.next = 59;
5448
6090
  break;
5449
- case 55:
5450
- _context2.prev = 55;
5451
- _context2.t0 = _context2["catch"](23);
6091
+ case 56:
6092
+ _context2.prev = 56;
6093
+ _context2.t0 = _context2["catch"](24);
5452
6094
  this._emitError(StreamingError.network(_context2.t0));
5453
- case 58:
6095
+ case 59:
5454
6096
  case "end":
5455
6097
  return _context2.stop();
5456
6098
  }
5457
- }, _callee2, this, [[23, 55]]);
6099
+ }, _callee2, this, [[24, 56]]);
5458
6100
  }));
5459
6101
  function _connect() {
5460
6102
  return _connect2.apply(this, arguments);
5461
6103
  }
5462
6104
  return _connect;
5463
6105
  }()
5464
- }, {
5465
- key: "_closeLastPc",
5466
- value: function _closeLastPc() {
5467
- if (this._lastPc) {
5468
- this._lastPc.close();
5469
- this._lastPc = null;
5470
- }
5471
- }
5472
6106
  }, {
5473
6107
  key: "_disconnect",
5474
6108
  value: function _disconnect() {
5475
- var _this$_loader, _this$_networkEvaluat2;
6109
+ var _this$_loader, _this$_networkEvaluat2, _this$_videoTransceic, _this$_audioTransceic;
5476
6110
  (_this$_loader = this._loader) === null || _this$_loader === void 0 ? void 0 : _this$_loader.cancel();
5477
6111
  (_this$_networkEvaluat2 = this._networkEvaluate) === null || _this$_networkEvaluat2 === void 0 ? void 0 : _this$_networkEvaluat2.destroy();
6112
+ (_this$_videoTransceic = this._videoTransceicer) === null || _this$_videoTransceic === void 0 ? void 0 : _this$_videoTransceic.stop();
6113
+ (_this$_audioTransceic = this._audioTransceicer) === null || _this$_audioTransceic === void 0 ? void 0 : _this$_audioTransceic.stop();
5478
6114
  this._audioTransceicer = null;
5479
6115
  this._videoTransceicer = null;
5480
6116
  this._mediaStream = null;
@@ -5483,7 +6119,6 @@
5483
6119
  }, {
5484
6120
  key: "_emitError",
5485
6121
  value: function _emitError(error) {
5486
- this._closeLastPc();
5487
6122
  this.emit(EVENT.ERROR, error);
5488
6123
  }
5489
6124
  }, {
@@ -5495,7 +6130,6 @@
5495
6130
  if (this._media && !((_this$_opts = this._opts) !== null && _this$_opts !== void 0 && _this$_opts.seamlesslyReload)) {
5496
6131
  this._media.srcObject = null;
5497
6132
  }
5498
- this._closeLastPc();
5499
6133
  if (this._pc) {
5500
6134
  this._pc.close();
5501
6135
  }
@@ -5524,64 +6158,6 @@
5524
6158
  }
5525
6159
  } catch (error) {
5526
6160
  }
5527
- function isSupported() {
5528
- if (!window.RTCPeerConnection || !window.RTCPeerConnection.prototype.addTransceiver) {
5529
- return false;
5530
- }
5531
- return true;
5532
- }
5533
- function getCapacity() {
5534
- if (!isSupported())
5535
- return Promise.reject("RTCPeerConnection no support");
5536
- var pc;
5537
- try {
5538
- pc = new RTCPeerConnection();
5539
- pc.addTransceiver("video", {
5540
- direction: "recvonly"
5541
- });
5542
- pc.addTransceiver("audio", {
5543
- direction: "recvonly"
5544
- });
5545
- } catch (e) {
5546
- return Promise.reject(e === null || e === void 0 ? void 0 : e.message);
5547
- }
5548
- return pc.createOffer().then(function(offer) {
5549
- var _sdpJson$media, _sdpJson$media2, _vMedia$rtp, _aMedia$rtp;
5550
- logger.log(offer.sdp);
5551
- var sdpJson = lib.parse(offer.sdp);
5552
- var vMedia = (_sdpJson$media = sdpJson.media) === null || _sdpJson$media === void 0 ? void 0 : _sdpJson$media.filter(function(x) {
5553
- return x.type === "video";
5554
- })[0];
5555
- var aMedia = (_sdpJson$media2 = sdpJson.media) === null || _sdpJson$media2 === void 0 ? void 0 : _sdpJson$media2.filter(function(x) {
5556
- return x.type === "audio";
5557
- })[0];
5558
- var vCodecs = vMedia === null || vMedia === void 0 ? void 0 : (_vMedia$rtp = vMedia.rtp) === null || _vMedia$rtp === void 0 ? void 0 : _vMedia$rtp.filter(function(x) {
5559
- return x.codec === "VP8" || x.codec === "VP9" || x.codec === "H264";
5560
- });
5561
- var aCodecs = aMedia === null || aMedia === void 0 ? void 0 : (_aMedia$rtp = aMedia.rtp) === null || _aMedia$rtp === void 0 ? void 0 : _aMedia$rtp.filter(function(x) {
5562
- return x.codec === "opus";
5563
- });
5564
- var vFmtp = vMedia === null || vMedia === void 0 ? void 0 : vMedia.fmtp;
5565
- var aFmtp = aMedia === null || aMedia === void 0 ? void 0 : aMedia.fmtp;
5566
- vFmtp && vCodecs.map(function(codec) {
5567
- var _vFmtp$filter$;
5568
- codec.config = (_vFmtp$filter$ = vFmtp.filter(function(x) {
5569
- return x.payload === codec.payload;
5570
- })[0]) === null || _vFmtp$filter$ === void 0 ? void 0 : _vFmtp$filter$.config;
5571
- });
5572
- aFmtp && aCodecs.map(function(codec) {
5573
- var _aFmtp$filter$;
5574
- codec.config = (_aFmtp$filter$ = aFmtp.filter(function(x) {
5575
- return x.payload === codec.payload;
5576
- })[0]) === null || _aFmtp$filter$ === void 0 ? void 0 : _aFmtp$filter$.config;
5577
- });
5578
- pc.close();
5579
- return {
5580
- video: vCodecs,
5581
- audio: aCodecs
5582
- };
5583
- });
5584
- }
5585
6161
  var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
5586
6162
  _inherits$1(RtsPlugin2, _BasePlugin);
5587
6163
  var _super = _createSuper$1(RtsPlugin2);
@@ -5596,26 +6172,26 @@
5596
6172
  _defineProperty$2(_assertThisInitialized$1(_this), "_mediaStream", null);
5597
6173
  _defineProperty$2(_assertThisInitialized$1(_this), "_rtsOpts", null);
5598
6174
  _defineProperty$2(_assertThisInitialized$1(_this), "_onPause", function() {
5599
- var _this$_rts, _this$_rts2, _this$config, _this$_rts4;
5600
- if (!((_this$_rts = _this._rts) !== null && _this$_rts !== void 0 && _this$_rts._pc) || (_this$_rts2 = _this._rts) !== null && _this$_rts2 !== void 0 && _this$_rts2._isReplacing) {
6175
+ var _this$_rts, _this$config, _this$_rts3;
6176
+ if (!((_this$_rts = _this._rts) !== null && _this$_rts !== void 0 && _this$_rts._pc)) {
5601
6177
  return;
5602
6178
  }
5603
6179
  if ((_this$config = _this.config) !== null && _this$config !== void 0 && _this$config.seamlesslyReload) {
5604
- var _this$_rts3;
5605
- _this._mediaStream = (_this$_rts3 = _this._rts) === null || _this$_rts3 === void 0 ? void 0 : _this$_rts3._mediaStream;
6180
+ var _this$_rts2;
6181
+ _this._mediaStream = (_this$_rts2 = _this._rts) === null || _this$_rts2 === void 0 ? void 0 : _this$_rts2._mediaStream;
5606
6182
  }
5607
- (_this$_rts4 = _this._rts) === null || _this$_rts4 === void 0 ? void 0 : _this$_rts4.destroy();
6183
+ (_this$_rts3 = _this._rts) === null || _this$_rts3 === void 0 ? void 0 : _this$_rts3.destroy();
5608
6184
  });
5609
6185
  _defineProperty$2(_assertThisInitialized$1(_this), "_onPlay", function() {
5610
- var _this$_rts5, _this$_rts6;
5611
- if ((_this$_rts5 = _this._rts) !== null && _this$_rts5 !== void 0 && _this$_rts5._pc || (_this$_rts6 = _this._rts) !== null && _this$_rts6 !== void 0 && _this$_rts6._isReplacing) {
6186
+ var _this$_rts4;
6187
+ if ((_this$_rts4 = _this._rts) !== null && _this$_rts4 !== void 0 && _this$_rts4._pc) {
5612
6188
  return;
5613
6189
  }
5614
6190
  _this._init();
5615
6191
  });
5616
6192
  _defineProperty$2(_assertThisInitialized$1(_this), "_init", function() {
5617
- var _this$_rts7;
5618
- (_this$_rts7 = _this._rts) === null || _this$_rts7 === void 0 ? void 0 : _this$_rts7.destroy();
6193
+ var _this$_rts5;
6194
+ (_this$_rts5 = _this._rts) === null || _this$_rts5 === void 0 ? void 0 : _this$_rts5.destroy();
5619
6195
  var config = _this.player.config;
5620
6196
  var rtsOpts = config.rts || {};
5621
6197
  _this._rtsOpts = rtsOpts;
@@ -5632,39 +6208,36 @@
5632
6208
  }, rtsOpts));
5633
6209
  _this._rts.load(config.url);
5634
6210
  });
5635
- _defineProperty$2(_assertThisInitialized$1(_this), "_onSwitchURL", function(url, seamless) {
6211
+ _defineProperty$2(_assertThisInitialized$1(_this), "_onSwitchURL", function(url) {
5636
6212
  if (_this._rts) {
5637
- if (_typeof$2(seamless) === "object") {
5638
- seamless = seamless.seamless;
5639
- }
5640
6213
  _this.player.config.url = url;
5641
- _this._rts.switchURL(url, seamless);
6214
+ _this._rts.switchURL(url);
5642
6215
  }
5643
6216
  });
5644
6217
  _defineProperty$2(_assertThisInitialized$1(_this), "destroy", function() {
5645
- var _this$_rts8;
6218
+ var _this$_rts6;
5646
6219
  _this.player.switchURL = _this._originSwitchFn;
5647
- (_this$_rts8 = _this._rts) === null || _this$_rts8 === void 0 ? void 0 : _this$_rts8.destroy();
6220
+ (_this$_rts6 = _this._rts) === null || _this$_rts6 === void 0 ? void 0 : _this$_rts6.destroy();
5648
6221
  });
5649
6222
  return _this;
5650
6223
  }
5651
6224
  _createClass$2(RtsPlugin2, [{
5652
6225
  key: "pc",
5653
6226
  get: function get() {
5654
- var _this$_rts9;
5655
- return (_this$_rts9 = this._rts) === null || _this$_rts9 === void 0 ? void 0 : _this$_rts9.pc;
6227
+ var _this$_rts7;
6228
+ return (_this$_rts7 = this._rts) === null || _this$_rts7 === void 0 ? void 0 : _this$_rts7.pc;
5656
6229
  }
5657
6230
  }, {
5658
6231
  key: "videoTrack",
5659
6232
  get: function get() {
5660
- var _this$_rts10;
5661
- return (_this$_rts10 = this._rts) === null || _this$_rts10 === void 0 ? void 0 : _this$_rts10.videoTack;
6233
+ var _this$_rts8;
6234
+ return (_this$_rts8 = this._rts) === null || _this$_rts8 === void 0 ? void 0 : _this$_rts8.videoTack;
5662
6235
  }
5663
6236
  }, {
5664
6237
  key: "audioTrack",
5665
6238
  get: function get() {
5666
- var _this$_rts11;
5667
- return (_this$_rts11 = this._rts) === null || _this$_rts11 === void 0 ? void 0 : _this$_rts11.audioTrack;
6239
+ var _this$_rts9;
6240
+ return (_this$_rts9 = this._rts) === null || _this$_rts9 === void 0 ? void 0 : _this$_rts9.audioTrack;
5668
6241
  }
5669
6242
  }, {
5670
6243
  key: "core",
@@ -5674,13 +6247,13 @@
5674
6247
  }, {
5675
6248
  key: "loader",
5676
6249
  get: function get() {
5677
- var _this$_rts12;
5678
- return (_this$_rts12 = this._rts) === null || _this$_rts12 === void 0 ? void 0 : _this$_rts12.loader;
6250
+ var _this$_rts10;
6251
+ return (_this$_rts10 = this._rts) === null || _this$_rts10 === void 0 ? void 0 : _this$_rts10.loader;
5679
6252
  }
5680
6253
  }, {
5681
6254
  key: "version",
5682
6255
  get: function get() {
5683
- return "0.2.1-alpha.4";
6256
+ return "0.2.1-alpha.5";
5684
6257
  }
5685
6258
  }, {
5686
6259
  key: "beforePlayerInit",
@@ -5708,6 +6281,7 @@
5708
6281
  this._transCoreEvent(EVENT.LOAD_RESPONSE_HEADERS);
5709
6282
  this._transCoreEvent(EVENT.LOAD_RETRY);
5710
6283
  this._transCoreEvent(EVENT.METADATA_PARSED);
6284
+ this._transCoreEvent(EVENT.SEI);
5711
6285
  this._transCoreEvent(EXTEND_EVENTS.RTC_STATE_CHANGE);
5712
6286
  try {
5713
6287
  BasePlugin.defineGetterOrSetter(this.player, {
@@ -5730,20 +6304,20 @@
5730
6304
  }, {
5731
6305
  key: "getStats",
5732
6306
  value: function getStats2() {
5733
- var _this$_rts13;
5734
- return (_this$_rts13 = this._rts) === null || _this$_rts13 === void 0 ? void 0 : _this$_rts13.getStats();
6307
+ var _this$_rts11;
6308
+ return (_this$_rts11 = this._rts) === null || _this$_rts11 === void 0 ? void 0 : _this$_rts11.getStats();
5735
6309
  }
5736
6310
  }, {
5737
6311
  key: "getStatsSnapshoot",
5738
6312
  value: function getStatsSnapshoot2() {
5739
- var _this$_rts14;
5740
- return (_this$_rts14 = this._rts) === null || _this$_rts14 === void 0 ? void 0 : _this$_rts14.getStatsSnapshoot();
6313
+ var _this$_rts12;
6314
+ return (_this$_rts12 = this._rts) === null || _this$_rts12 === void 0 ? void 0 : _this$_rts12.getStatsSnapshoot();
5741
6315
  }
5742
6316
  }, {
5743
6317
  key: "getNetWorkInfo",
5744
6318
  value: function getNetWorkInfo() {
5745
- var _this$_rts15;
5746
- return (_this$_rts15 = this._rts) === null || _this$_rts15 === void 0 ? void 0 : _this$_rts15.networkStats;
6319
+ var _this$_rts13;
6320
+ return (_this$_rts13 = this._rts) === null || _this$_rts13 === void 0 ? void 0 : _this$_rts13.networkStats;
5747
6321
  }
5748
6322
  }, {
5749
6323
  key: "_transErrorEvent",